TizenRefApp-5829 Implement View contact operation 14/61414/3
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Mon, 7 Mar 2016 15:06:57 +0000 (17:06 +0200)
committerAleksandr Sapozhnik <a.sapozhnik@samsung.com>
Wed, 9 Mar 2016 13:40:42 +0000 (05:40 -0800)
Change-Id: Ib9d41e3ea9797c1a51db8b5de4f65447179842b7
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-contact/inc/Contacts/Details/DetailsView.h
main-app/inc/OperationViewController.h [new file with mode: 0644]
main-app/src/MainApp.cpp
main-app/src/OperationViewController.cpp [new file with mode: 0644]
main-app/tizen-manifest.xml
main-app/tizen-manifest.xml.in

index 40ce4eb..a231d86 100644 (file)
@@ -38,7 +38,7 @@ namespace Contacts
                /**
                 * @brief Contact/My profile details view.
                 */
-               class DetailsView : public SelectView
+               class EXPORT_API DetailsView : public SelectView
                {
                public:
                        /**
diff --git a/main-app/inc/OperationViewController.h b/main-app/inc/OperationViewController.h
new file mode 100644 (file)
index 0000000..f51a284
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015 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 OPERATION_VIEW_CONTROLLER_H
+#define OPERATION_VIEW_CONTROLLER_H
+
+#include "OperationController.h"
+
+class OperationViewController : public OperationController
+{
+public:
+       OperationViewController();
+       virtual ~OperationViewController();
+
+private:
+       virtual void onCreate();
+       virtual void onRequest(Operation operation, app_control_h request);
+};
+
+#endif /* _OPERATION_VIEW_CONTROLLER_H_ */
index 58e3664..6a66b9a 100755 (executable)
@@ -27,9 +27,7 @@
 #include "OperationDefaultController.h"
 #include "OperationEditController.h"
 #include "OperationPickController.h"
-/* TODO:
 #include "OperationViewController.h"
- */
 
 MainApp::MainApp()
        : m_Window(nullptr), m_Navigator(nullptr), m_Controller(nullptr)
@@ -89,7 +87,7 @@ void MainApp::onAppControl(app_control_h request)
                                m_Controller = new OperationEditController();
                                break;
                        case OperationView:
-                               /* TODO: m_Controller = new OperationViewController(); */
+                               m_Controller = new OperationViewController();
                                break;
                        case OperationPick:
                                m_Controller = new OperationPickController();
diff --git a/main-app/src/OperationViewController.cpp b/main-app/src/OperationViewController.cpp
new file mode 100644 (file)
index 0000000..59d871c
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2015 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 "OperationViewController.h"
+
+#include "MainApp.h"
+#include "Contacts/Details/DetailsView.h"
+#include "Contacts/List/ListView.h"
+#include "Contacts/Utils.h"
+
+#include "App/AppControlRequest.h"
+#include "Ui/Navigator.h"
+#include "Ui/Window.h"
+
+#include <string.h>
+
+using namespace Contacts;
+using namespace Contacts::Details;
+using namespace Contacts::List;
+
+OperationViewController::OperationViewController()
+       : OperationController(OperationView)
+{
+}
+
+OperationViewController::~OperationViewController()
+{
+       getApplication()->getWindow()->unsetBackCallback();
+}
+
+void OperationViewController::onCreate()
+{
+       getApplication()->getWindow()->setBackCallback([] {
+               ui_app_exit();
+               return true;
+       });
+}
+
+void OperationViewController::onRequest(Operation operation, app_control_h request)
+{
+       Ui::View *view = nullptr;
+       char *mime = nullptr;
+       app_control_get_mime(request, &mime);
+
+       if (mime && strcmp(mime, APP_CONTROL_MIME_CONTACT) == 0) {
+               int personId = App::getIntExtraData(request, APP_CONTROL_DATA_ID);
+               if (personId > 0) {
+                       view = new DetailsView(getDisplayContactId(personId));
+               }
+       } else {
+               char *uri = NULL;
+               app_control_get_uri(request, &uri);
+               if (uri) {
+                       view = new ListView();
+                       /* TODO: use VcardProvider */
+                       free(uri);
+               }
+       }
+
+       free(mime);
+
+       if (view) {
+               getApplication()->getNavigator()->navigateTo(view);
+       } else {
+               ui_app_exit();
+       }
+}
index 9fd7e42..c965287 100644 (file)
             <operation name="http://tizen.org/appcontrol/operation/pick"/>
             <mime name="application/vnd.tizen.contact"/>
         </app-control>
+        <app-control>
+            <operation name="http://tizen.org/appcontrol/operation/view"/>
+            <mime name="application/vnd.tizen.contact"/>
+            <mime name="text/vcard"/>
+            <mime name="text/x-vcard"/>
+        </app-control>
     </ui-application>
     <privileges>
         <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
index 9fa0615..bf1a9b8 100644 (file)
                        <operation name="http://tizen.org/appcontrol/operation/pick"/>
                        <mime name="application/vnd.tizen.contact"/>
                </app-control>
+               <app-control>
+                       <operation name="http://tizen.org/appcontrol/operation/view"/>
+                       <mime name="application/vnd.tizen.contact"/>
+                       <mime name="text/vcard"/>
+                       <mime name="text/x-vcard"/>
+               </app-control>
        </ui-application>
        <privileges>
                <privilege>http://tizen.org/privilege/appmanager.launch</privilege>