TizenRefApp-5579 Implement "View Contact" functionality 28/58128/2
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 27 Jan 2016 17:23:49 +0000 (19:23 +0200)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Thu, 28 Jan 2016 09:28:28 +0000 (11:28 +0200)
Change-Id: Iee3e27b1132017ed9b2c61d940ccadb41155e9aa
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
.cproject
CMakeLists.txt
src/Common/AppControl/inc/ContactViewer.h [new file with mode: 0644]
src/Common/AppControl/src/ContactViewer.cpp [new file with mode: 0644]
src/Conversation/AppControl/inc/AttachPanel.h [moved from src/Conversation/Main/Controller/inc/AttachPanel.h with 100% similarity]
src/Conversation/AppControl/inc/ContactPicker.h [moved from src/Conversation/Recipients/Controller/inc/ContactPicker.h with 100% similarity]
src/Conversation/AppControl/src/AttachPanel.cpp [moved from src/Conversation/Main/Controller/src/AttachPanel.cpp with 100% similarity]
src/Conversation/AppControl/src/ContactPicker.cpp [moved from src/Conversation/Recipients/Controller/src/ContactPicker.cpp with 97% similarity]
src/Conversation/Main/Controller/src/Conversation.cpp

index b18acdc..4df58a7 100644 (file)
--- a/.cproject
+++ b/.cproject
                                                                </option>
                                                                <option id="gnu.cpp.compiler.option.include.paths.1578788940" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Conversation/AppControl/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Conversation/ConvList/Controller/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Conversation/ConvList/View/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Conversation/Main/Controller/inc}&quot;"/>
                                                                </option>
                                                                <option id="gnu.cpp.compiler.option.include.paths.2132319922" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/inc}&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Conversation/AppControl/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Conversation/ConvList/Controller/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Conversation/ConvList/View/inc}&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}/src/Conversation/Main/Controller/inc}&quot;"/>
index f7c9330..02ee18d 100644 (file)
@@ -25,6 +25,7 @@ INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
                     ${CMAKE_CURRENT_SOURCE_DIR}/src/Conversation/ContactList/Controller/inc/
                     ${CMAKE_CURRENT_SOURCE_DIR}/src/Conversation/ConvList/View/inc/
                     ${CMAKE_CURRENT_SOURCE_DIR}/src/Conversation/ConvList/Controller/inc/
+                    ${CMAKE_CURRENT_SOURCE_DIR}/src/Conversation/AppControl/inc/
                     ${CMAKE_CURRENT_SOURCE_DIR}/src/MsgThread/Controller/inc/
                     ${CMAKE_CURRENT_SOURCE_DIR}/src/MsgThread/View/inc/
                     ${CMAKE_CURRENT_SOURCE_DIR}/src/Settings/Controller/inc/
diff --git a/src/Common/AppControl/inc/ContactViewer.h b/src/Common/AppControl/inc/ContactViewer.h
new file mode 100644 (file)
index 0000000..90a7c99
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2009-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef ContactViewer_h_
+#define ContactViewer_h_
+
+#include "AppControlUtils.h"
+
+namespace Msg
+{
+    /**
+     * An utility-class aimed to launch contacts-application with view-operation passed via app-control.
+     */
+    class ContactViewer
+    {
+    public:
+        ContactViewer();
+
+        /**
+         * Launches view-operation.
+         * @param personId Contact person id
+         * @return true in case of success, otherwise returns false.
+         */
+        static bool launch(int personId);
+
+    private:
+        ContactViewer(const ContactViewer&) = delete;
+        ContactViewer& operator=(const ContactViewer&) = delete;
+    };
+}
+
+#endif /* ContactViewer_h_ */
diff --git a/src/Common/AppControl/src/ContactViewer.cpp b/src/Common/AppControl/src/ContactViewer.cpp
new file mode 100644 (file)
index 0000000..f1ae45c
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2009-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "ContactViewer.h"
+#include "Logger.h"
+
+#include <app_control.h>
+#include <string>
+
+using namespace Msg;
+
+namespace
+{
+    const char* mimeContact = "application/vnd.tizen.contact";
+}
+
+ContactViewer::ContactViewer()
+{
+}
+
+bool ContactViewer::launch(int personId)
+{
+    bool res = false;
+    app_control_h svc_handle = nullptr;
+
+    if(APP_CONTROL_ERROR_NONE == app_control_create(&svc_handle))
+    {
+        app_control_set_operation(svc_handle, APP_CONTROL_OPERATION_VIEW);
+        app_control_set_mime(svc_handle, mimeContact);
+        app_control_add_extra_data(svc_handle, APP_CONTROL_DATA_ID, std::to_string(personId).c_str());
+        app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP);
+        int ret = app_control_send_launch_request(svc_handle, nullptr, nullptr);
+        MSG_LOG("Result code: ", ret);
+        res = ret == APP_CONTROL_ERROR_NONE;
+        app_control_destroy(svc_handle);
+    }
+
+    return res;
+}
+
@@ -60,6 +60,7 @@ bool ContactPicker::launch(size_t howManyToPick)
 
         //TODO: We have to request a possibility to acquire phone numbers and emails at the same time
         app_control_add_extra_data(svc_handle, APP_CONTROL_DATA_TYPE, resultTypePhone);
+        app_control_set_launch_mode(svc_handle, APP_CONTROL_LAUNCH_MODE_GROUP);
         int ret = app_control_send_launch_request(svc_handle, APP_CONTROL_RES_CALLBACK(ContactPicker, onAppControlRes), this);
         MSG_LOG("launching contacts, result-code: ", ret);
         res = (ret == APP_CONTROL_ERROR_NONE);
index 8e18535..dbfdf09 100644 (file)
@@ -25,6 +25,7 @@
 #include "RecipientItem.h"
 #include "LangUtils.h"
 #include "CallbackAssist.h"
+#include "ContactViewer.h"
 
 #include <Elementary.h>
 #include <sstream>
@@ -102,13 +103,9 @@ void Conversation::recipientClickHandler(const std::string &address)
     // TODO: impl for email
     ContactPersonNumber contactPersonNumber = getApp().getContactManager().getContactPersonNumber(address);
     if(contactPersonNumber.isValid())
-    {
-        // TODO: show Phone-Contacts
-    }
+        ContactViewer::launch(contactPersonNumber.getPersonId());
     else
-    {
         showRecipPopup(address);
-    }
 }
 
 void Conversation::navigateTo(MsgId msgId)