Add webview when "More information" pressed 40/73840/4
authorsangwan.kwon <sangwan.kwon@samsung.com>
Thu, 9 Jun 2016 15:17:37 +0000 (00:17 +0900)
committerkyungwook tak <k.tak@samsung.com>
Fri, 10 Jun 2016 06:19:03 +0000 (23:19 -0700)
Change-Id: If0995f5652e791ae41b90a7f6f8ec9dd8341ffb6

packaging/csr-framework.spec
packaging/csr.manifest.smack.in
src/framework/ui/popup/CMakeLists.txt
src/framework/ui/popup/logic.cpp
src/framework/ui/popup/popup.cpp
src/framework/ui/popup/popup.h

index c4ef8a0..3e64545 100644 (file)
@@ -34,11 +34,12 @@ BuildRequires: cmake
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(libsystemd-daemon)
 BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(elementary)
 BuildRequires: pkgconfig(sqlite3)
 BuildRequires: pkgconfig(pkgmgr)
 BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: pkgconfig(libsmack)
+BuildRequires: pkgconfig(capi-appfw-application)
+BuildRequires: pkgconfig(elementary)
 %if "%{platform_version}" == "3.0"
 BuildRequires: pkgconfig(cynara-client)
 %else
index c14e266..7d9c68d 100644 (file)
@@ -18,6 +18,8 @@
                        <smack request="pkgmgr::db" type="rwx" />
                        <smack request="pkgmgr::svc" type="r" />
                        <smack request="system::use_internet" type="w" />
+                       <smack request="aul::launch" type="x" />
+                       <smack request="app-svc::db" type="rw" />
 
                        <smack request="system::media" type="rwxat" />
                        <smack request="system::homedir" type="rwxat" />
index ae3e4fa..6812f7f 100644 (file)
@@ -23,6 +23,7 @@ PKG_CHECK_MODULES(${TARGET_CSR_POPUP}_DEP
        libsystemd-daemon
        vconf
        pkgmgr-info
+       capi-appfw-application
 )
 
 INCLUDE_DIRECTORIES(
index 928aaca..47d317c 100755 (executable)
@@ -66,7 +66,8 @@ RawBuffer Logic::csPromptData(const std::string &message, const CsDetected &d) c
        p.m_types.emplace_back(
                static_cast<int>(CSR_CS_USER_RESPONSE_PROCESSING_DISALLOWED));
 
-       p.callbackRegister(p.m_buttons[0], "clicked", &p.m_types[0]);
+       p.callbackRegister(p.m_buttons[0], &p.m_types[0]);
+       p.callbackRegister(p.m_hypertext, d.detailedUrl);
 
        p.run();
        return p.getResult();
@@ -103,9 +104,10 @@ RawBuffer Logic::csPromptFile(const std::string &message, const CsDetected &d) c
        p.m_types.emplace_back(
                static_cast<int>(CSR_CS_USER_RESPONSE_REMOVE));
 
-       p.callbackRegister(p.m_buttons[0], "clicked", &p.m_types[0]);
-       p.callbackRegister(p.m_buttons[1], "clicked", &p.m_types[1]);
-       p.callbackRegister(p.m_buttons[2], "clicked", &p.m_types[2]);
+       p.callbackRegister(p.m_buttons[0], &p.m_types[0]);
+       p.callbackRegister(p.m_buttons[1], &p.m_types[1]);
+       p.callbackRegister(p.m_buttons[2], &p.m_types[2]);
+       p.callbackRegister(p.m_hypertext, d.detailedUrl);
 
        p.run();
        return p.getResult();
@@ -142,9 +144,10 @@ RawBuffer Logic::csPromptApp(const std::string &message, const CsDetected &d) co
        p.m_types.emplace_back(
                static_cast<int>(CSR_CS_USER_RESPONSE_REMOVE));
 
-       p.callbackRegister(p.m_buttons[0], "clicked", &p.m_types[0]);
-       p.callbackRegister(p.m_buttons[1], "clicked", &p.m_types[1]);
-       p.callbackRegister(p.m_buttons[2], "clicked", &p.m_types[2]);
+       p.callbackRegister(p.m_buttons[0], &p.m_types[0]);
+       p.callbackRegister(p.m_buttons[1], &p.m_types[1]);
+       p.callbackRegister(p.m_buttons[2], &p.m_types[2]);
+       p.callbackRegister(p.m_hypertext, d.detailedUrl);
 
        p.run();
        return p.getResult();
@@ -165,7 +168,8 @@ RawBuffer Logic::csNotifyData(const std::string &message, const CsDetected &d) c
        p.m_types.emplace_back(
                static_cast<int>(CSR_CS_USER_RESPONSE_PROCESSING_DISALLOWED));
 
-       p.callbackRegister(p.m_buttons[0], "clicked", &p.m_types[0]);
+       p.callbackRegister(p.m_buttons[0], &p.m_types[0]);
+       p.callbackRegister(p.m_hypertext, d.detailedUrl);
 
        p.run();
        return p.getResult();
@@ -196,8 +200,9 @@ RawBuffer Logic::csNotifyFile(const std::string &message, const CsDetected &d) c
        p.m_types.emplace_back(
                static_cast<int>(CSR_CS_USER_RESPONSE_REMOVE));
 
-       p.callbackRegister(p.m_buttons[0], "clicked", &p.m_types[0]);
-       p.callbackRegister(p.m_buttons[1], "clicked", &p.m_types[1]);
+       p.callbackRegister(p.m_buttons[0], &p.m_types[0]);
+       p.callbackRegister(p.m_buttons[1], &p.m_types[1]);
+       p.callbackRegister(p.m_hypertext, d.detailedUrl);
 
        p.run();
        return p.getResult();
@@ -229,8 +234,9 @@ RawBuffer Logic::csNotifyApp(const std::string &message, const CsDetected &d) co
        p.m_types.emplace_back(
                static_cast<int>(CSR_CS_USER_RESPONSE_PROCESSING_ALLOWED));
 
-       p.callbackRegister(p.m_buttons[0], "clicked", &p.m_types[0]);
-       p.callbackRegister(p.m_buttons[1], "clicked", &p.m_types[1]);
+       p.callbackRegister(p.m_buttons[0], &p.m_types[0]);
+       p.callbackRegister(p.m_buttons[1], &p.m_types[1]);
+       p.callbackRegister(p.m_hypertext, d.detailedUrl);
 
        p.run();
        return p.getResult();
@@ -243,7 +249,7 @@ RawBuffer Logic::wpPrompt(const std::string &message, const UrlItem &item) const
        Popup p(1);
 
        p.setMessage(message);
-       p.setTitle("    Block malicious URL");
+       p.setTitle("Block malicious URL");
        p.setHeader("    This website may harm your phone.");
        p.setBody(FORMAT(
                "    - URL : " << item.url << "<br>" <<
@@ -256,7 +262,8 @@ RawBuffer Logic::wpPrompt(const std::string &message, const UrlItem &item) const
 
        p.m_types.emplace_back(static_cast<int>(CSR_WP_USER_RESPONSE_PROCESSING_DISALLOWED));
 
-       p.callbackRegister(p.m_buttons[0], "clicked", &p.m_types[0]);
+       p.callbackRegister(p.m_buttons[0], &p.m_types[0]);
+       p.callbackRegister(p.m_hypertext, item.url);
 
        p.run();
        return p.getResult();
@@ -267,7 +274,7 @@ RawBuffer Logic::wpNotify(const std::string &message, const UrlItem &item) const
        Popup p(2);
 
        p.setMessage(message);
-       p.setTitle("    Block malicious URL");
+       p.setTitle("Block malicious URL");
        p.setHeader("   This website may harm your phone.");
        p.setBody(FORMAT(
                "    - URL : " << item.url << "<br>" <<
@@ -284,8 +291,9 @@ RawBuffer Logic::wpNotify(const std::string &message, const UrlItem &item) const
        p.m_types.emplace_back(
                static_cast<int>(CSR_WP_USER_RESPONSE_PROCESSING_ALLOWED));
 
-       p.callbackRegister(p.m_buttons[0], "clicked", &p.m_types[0]);
-       p.callbackRegister(p.m_buttons[1], "clicked", &p.m_types[1]);
+       p.callbackRegister(p.m_buttons[0], &p.m_types[0]);
+       p.callbackRegister(p.m_buttons[1], &p.m_types[1]);
+       p.callbackRegister(p.m_hypertext, item.url);
 
        p.run();
        return p.getResult();
index 49890cf..a4b3882 100644 (file)
  * @brief
  */
 #include "popup.h"
+
 #include <package-info.h>
+#include <app_control.h>
 
 namespace Csr {
 namespace Ui {
 
+namespace {
+       struct AppControl {
+               AppControl() { app_control_create(&handle); }
+               ~AppControl() { app_control_destroy(handle); }
+
+               app_control_h handle;
+       };
+
+       const std::string DEFAULT_URL("https://developer.tizen.org/");
+}
+
 Popup::Popup(int buttonN)
 {
        // Set win properties.
@@ -53,7 +66,6 @@ Popup::Popup(int buttonN)
 
        // If icon is not set, it doesn't appear.
        m_icon = elm_icon_add(m_subBox);
-       // TODO(sangwan.kwon) Fix icon size
        elm_image_resizable_set(m_icon, EINA_FALSE, EINA_FALSE);
        elm_box_pack_end(m_subBox, m_icon);
        evas_object_show(m_icon);
@@ -67,12 +79,12 @@ Popup::Popup(int buttonN)
        evas_object_show(m_subBox);
 
        // This label is for linking to webview.
-       m_hypertext = elm_label_add(m_box);
-       elm_object_text_set(m_hypertext, "<color=#0000FFFF>"
-               "    More information</color>");
+       m_hypertext = elm_button_add(m_box);
+       elm_object_text_set(m_hypertext, "More information");
        evas_object_size_hint_align_set(m_hypertext, EVAS_HINT_FILL, 0);
        elm_box_pack_end(m_box, m_hypertext);
        evas_object_show(m_hypertext);
+       elm_object_style_set(m_hypertext, "anchor");
 
        m_footer = elm_label_add(m_box);
        evas_object_size_hint_align_set(m_footer, EVAS_HINT_FILL, 0);
@@ -166,9 +178,45 @@ void Popup::setText(Evas_Object *obj, const std::string &text) noexcept
        elm_object_text_set(obj, text.c_str());
 }
 
-void Popup::callbackRegister(Evas_Object *obj, const char *event, int *type)
+void Popup::callbackRegister(Evas_Object *obj, int *type)
 {
-       evas_object_smart_callback_add(obj, event, btnClickedCb, type);
+       evas_object_smart_callback_add(obj, "clicked", btnClickedCb, type);
+}
+
+void Popup::callbackRegister(Evas_Object *obj, const std::string &url)
+{
+       if (url.empty())
+               evas_object_smart_callback_add(
+                       obj, "clicked", hypertextClickedCb, &DEFAULT_URL);
+       else
+               evas_object_smart_callback_add(
+                       obj, "clicked", hypertextClickedCb, &url);
+}
+
+void Popup::hypertextClickedCb(void *data, Evas_Object *, void *)
+{
+       DEBUG("Launch browser for detailed url.");
+
+       std::string url = *(reinterpret_cast<std::string *>(data));
+       std::unique_ptr<AppControl> ac(new AppControl);
+
+       auto ret = app_control_set_operation(ac->handle, APP_CONTROL_OPERATION_VIEW);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               WARN("Cannot set app_control operation.");
+               return;
+       }
+
+       ret = app_control_set_uri(ac->handle, url.c_str());
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               WARN("Cannot set url to app_control handle.");
+               return;
+       }
+
+       ret = app_control_send_launch_request(ac->handle, NULL, NULL);
+       if (ret != APP_CONTROL_ERROR_NONE) {
+               WARN("Cannot launch browser.");
+               return;
+       }
 }
 
 void Popup::btnClickedCb(void *data, Evas_Object *, void *)
index 31ade9c..8841571 100644 (file)
@@ -73,11 +73,14 @@ public:
        void setIcon(const std::string &path) noexcept;
        void setText(Evas_Object *obj, const std::string &text) noexcept;
 
-       void callbackRegister(Evas_Object *obj, const char *event, int *type);
+       void callbackRegister(Evas_Object *obj, int *type);
+       void callbackRegister(Evas_Object *obj, const std::string &url);
        static void btnClickedCb(void *data, Evas_Object *, void *);
+       static void hypertextClickedCb(void *data, Evas_Object *, void *);
 
        std::vector<Evas_Object *> m_objects;
        std::vector<Evas_Object *> m_buttons;
+       Evas_Object *m_hypertext;
        std::vector<int> m_types;
 
 private:
@@ -87,7 +90,6 @@ private:
        Evas_Object *m_subBox;
        Evas_Object *m_header;
        Evas_Object *m_body;
-       Evas_Object *m_hypertext;
        Evas_Object *m_footer;
        Evas_Object *m_icon;