Modify identifyApp to get both appid and pkglabel for display 80/102180/2 accepted/tizen/3.0/common/20161206.125312 accepted/tizen/3.0/ivi/20161205.234435 accepted/tizen/3.0/mobile/20161205.234250 accepted/tizen/3.0/tv/20161205.234341 accepted/tizen/3.0/wearable/20161205.234407 submit/tizen_3.0/20161205.022357
authorYunjin Lee <yunjin-.lee@samsung.com>
Mon, 5 Dec 2016 07:01:25 +0000 (16:01 +0900)
committerYunjin Lee <yunjin-.lee@samsung.com>
Mon, 5 Dec 2016 07:19:11 +0000 (16:19 +0900)
Change-Id: Id23279085b3df45587ad7d4b591949181187f78b
Signed-off-by: Yunjin Lee <yunjin-.lee@samsung.com>
src/agent/notification-daemon/AskUserTalker.cpp
src/agent/notification-daemon/GuiRunner.cpp
src/agent/notification-daemon/GuiRunner.h
src/agent/notification-daemon/Policy.cpp
src/agent/notification-daemon/Policy.h

index 0ba69cf..40acc7c 100644 (file)
@@ -58,7 +58,8 @@ void setSecurityLevel(const std::string &app, const std::string &perm, const std
 
         ALOGD("SecurityManager: Setting security level to " << level);
         std::string appName;
-        identifyApp(app, appName);
+        std::string pkgLabel;
+        identifyApp(app, appName, pkgLabel);
         if (appName.empty()) {
             ALOGE("Couldn't fetch appName from cynara client. Cannot set policy");
             return;
@@ -160,6 +161,7 @@ void AskUserTalker::init() {
 #endif
         m_poller.setEvents(m_serverSocket.getFd(), POLLIN);
         setSignalDescriptor();
+        m_gui.setLocale();
         m_gui.initialize();
         ALOGD("Initialized");
 }
index 73f8dcc..f352507 100644 (file)
@@ -242,6 +242,7 @@ void GuiRunner::initialize()
     m_checkbox = elm_check_add(m_popup);
     elm_object_style_set(m_checkbox, "popup");
     elm_object_text_set(m_checkbox, checkBoxText);
+    elm_check_state_set(m_checkbox, EINA_FALSE);
     evas_object_size_hint_align_set(m_checkbox, EVAS_HINT_FILL, 0.0);
     elm_object_part_content_set(m_layoutInner, "elm.swallow.end", m_checkbox);
     evas_object_show(m_checkbox);
@@ -291,19 +292,19 @@ void GuiRunner::setLocale()
         ALOGE("textdomain failed");
 }
 
-void GuiRunner::refreshText()
+void GuiRunner::refresh()
 {
     char *popupTitle = dgettext(PROJECT_NAME, "IDS_IDLE_HEADER_PRIVACY_REQUEST");
     char *checkBoxText = dgettext(PROJECT_NAME, "IDS_ST_OPT_DONT_SHOW_AGAIN");
 #ifdef MOBILE_UI
     elm_object_part_text_set(m_popup, "title,text", popupTitle);
-    elm_object_text_set(m_checkbox, checkBoxText);
     elm_object_text_set(m_denyButton, dgettext(PROJECT_NAME, "IDS_IDLE_BUTTON_DENY"));
     elm_object_text_set(m_allowButton, dgettext(PROJECT_NAME, "IDS_IDLE_BUTTON_ALLOW_ABB7"));
 #elif defined(CIRCLE_UI)
     elm_object_part_text_set(m_layout, "elm.text.title", popupTitle);
-    elm_object_text_set(m_checkbox, checkBoxText);
 #endif
+    elm_object_text_set(m_checkbox, checkBoxText);
+    elm_check_state_set(m_checkbox, EINA_FALSE);
 }
 
 NResponseType GuiRunner::popupRun(const std::string &app, const std::string &perm)
@@ -312,12 +313,12 @@ NResponseType GuiRunner::popupRun(const std::string &app, const std::string &per
         setLocale();
         if (!m_initialized) {
             initialize();
-        } else {
-            refreshText();
         }
+        refresh();
         m_running = true;
+        std::string appId;
         std::string pkgLabel;
-        identifyApp(app, pkgLabel);
+        identifyApp(app, appId, pkgLabel);
 
         // create message
         char *messageFormat = dgettext(PROJECT_NAME, "IDS_IDLE_POP_ALLOW_P1SS_TO_ACCESS_YOUR_P2SS_Q");
index abab322..af364dc 100644 (file)
@@ -41,7 +41,7 @@ public:
     GuiRunner() = default;
     void initialize();
     void setLocale();
-    void refreshText();
+    void refresh();
     void addDismissFd(int fd, DissmissCb cb, void *data);
     void delDismissFd(int fd);
     ~GuiRunner();
index e257bfd..4fef2ff 100644 (file)
@@ -36,6 +36,24 @@ inline void throwOnSMError(std::string err, int ret)
 
 char * toAppId(const char *pkgId) {
     int ret = 0;
+    char *mainappid = 0;
+    pkgmgrinfo_pkginfo_h handle = NULL;
+    ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgId, &handle);
+    if (ret != PMINFO_R_OK)
+        return NULL;
+    ret = pkgmgrinfo_pkginfo_get_mainappid(handle, &mainappid);
+    if (ret != PMINFO_R_OK) {
+        pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+        return NULL;
+    }
+    printf("main app id: %s\n", mainappid);
+    char *result = strdup(mainappid);
+    pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+    return result;
+}
+
+char * toPkgLabel(const char *pkgId) {
+    int ret = 0;
     char *pkgLabel = 0;
     pkgmgrinfo_pkginfo_h handle = NULL;
     ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgId, &handle);
@@ -51,30 +69,40 @@ char * toAppId(const char *pkgId) {
     pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
     return result;
 }
-
 }
 
 namespace AskUser {
 
-void identifyApp(const std::string &client, std::string &appId) {
+void identifyApp(const std::string &client, std::string &appId, std::string &pkgLabel) {
     char *pkg_name = nullptr;
     char *app_name = nullptr;
+    char *pkg_label = nullptr;
 
     int ret = security_manager_identify_app_from_cynara_client(client.c_str(), &pkg_name, &app_name);
     std::unique_ptr<char, decltype(free)*> pkg_name_p(pkg_name, free);
 
-    if (!app_name && pkg_name_p)
+    if (!app_name && pkg_name_p) {
         app_name = toAppId(pkg_name_p.get());
+        pkg_label = toPkgLabel(pkg_name_p.get());
+    }
 
     std::unique_ptr<char, decltype(free)*> app_name_p(app_name, free);
     throwOnSMError("security_manager_identify_app_from_cynara_client", ret);
 
+    std::unique_ptr<char, decltype(free)*> pkg_label_p(pkg_label, free);
+
     if (!app_name) {
         ALOGW("Identifying of application failed!");
         return;
     }
 
+    if (!pkg_label) {
+        ALOGW("Get pkg label failed!");
+        return;
+    }
+
     appId = app_name;
+    pkgLabel = pkg_label;
 }
 
 PolicyEntry::PolicyEntry() {
index d4d2dea..24e114f 100644 (file)
@@ -27,7 +27,7 @@
 
 namespace AskUser {
 
-void identifyApp(const std::string &client, std::string &appId);
+void identifyApp(const std::string &client, std::string &appId, std::string &pkgLabel);
 
 class PolicyEntry {
 public: