Remove fetching pkgLabel twice 13/137413/4
authorZofia Abramowska <z.abramowska@samsung.com>
Thu, 6 Jul 2017 08:37:02 +0000 (10:37 +0200)
committerZofia Abramowska <z.abramowska@samsung.com>
Fri, 7 Jul 2017 08:20:54 +0000 (10:20 +0200)
Creating popup message unnecessarily fetched pkg label
from pkg label.

Change-Id: Ie98a9e5e170a2d86a68856c39153c7581f598c42

src/notification-daemon/Logic.cpp
src/notification-daemon/Logic.h
src/notification-daemon/event/Event.h
src/notification-daemon/ui/Po.cpp
src/notification-daemon/ui/Po.h
src/notification-daemon/ui/Popupper.cpp
src/notification-daemon/ui/Popupper.h

index c0841dd05708cc0993fb236001ee2a1796c4270c..dafdd2cffdf9f1368c958c86ae85453c0b1533d7 100644 (file)
@@ -46,9 +46,9 @@ void Logic::addChannelFd(Protocol::ConnectionFd fd, const Protocol::Credentials
         return;
     }
 
-    std::string appId, pkgId;
-    identifyApp(creds.label, appId, pkgId);
-    ConnectionInfo connInfo{appId, pkgId, creds.uid};
+    std::string appId, pkgLabel;
+    identifyApp(creds.label, appId, pkgLabel);
+    ConnectionInfo connInfo{appId, pkgLabel, creds.uid};
     m_connToInfo.insert(it, std::make_pair(fd, connInfo));
 }
 
@@ -162,7 +162,7 @@ void Logic::popup(Protocol::ConnectionFd fd, Protocol::RequestId id, const std::
         return;
     }
 
-    auto &pkgId = it->second.pkgId;
+    auto &pkgId = it->second.pkgLabel;
     addEvent({fd, id}, new EventPopupCheck(&m_popupper, pkgId, privilege));
 }
 
index 41712e590c6bd8c8101f2014eabea77f34ee31d1..f8eeb6b574447c30b2f0094db39d26c9cd79865e 100644 (file)
@@ -106,7 +106,7 @@ private:
 
     struct ConnectionInfo {
         std::string appId;
-        std::string pkgId;
+        std::string pkgLabel;
         std::string user;
     };
 
index 232756994406cb88c30cfb35704ce4cb660ad646..239d91af8c45be7395c3699d89a978dea1ae079d 100644 (file)
@@ -40,8 +40,8 @@ protected:
 
 class EventPopupCheck : public IUIEvent {
 public:
-    EventPopupCheck(Popupper *popupper, const std::string &pkgName, const std::string &privilege)
-        : IUIEvent(popupper), m_pkgName(pkgName), m_privilege(privilege)
+    EventPopupCheck(Popupper *popupper, const std::string &pkgLabel, const std::string &privilege)
+        : IUIEvent(popupper), m_pkgLabel(pkgLabel), m_privilege(privilege)
     {}
 
     std::string getPrivilege() {
@@ -49,10 +49,10 @@ public:
     }
 
     virtual void process() {
-        m_popupper->popupCheck(m_pkgName, m_privilege);
+        m_popupper->popupCheck(m_pkgLabel, m_privilege);
     }
 private:
-    std::string m_pkgName;
+    std::string m_pkgLabel;
     std::string m_privilege;
 };
 
index 7ee82183967e5eb3b2ee194ea81767cf9ef71fd5..4da2d52dfc9efdb6d9fe306c67b4cc6a2c0dae62 100644 (file)
@@ -90,17 +90,12 @@ const char *getFormat(enum MsgType type) {
     return dgettext(PROJECT_NAME, MSG_PO[type]);
 }
 
-std::string getPkgLabel(const std::string &pkgName) {
-    PkgInfo pkgInfo(pkgName, geteuid());
-    return pkgInfo.pkgLabel();
-}
-
 } // namespace anonymous
 
 namespace Notification {
 namespace Po {
-std::string createPopupCheckMsg(const std::string &pkgName, const std::string &priv) {
-    return makeFromFormat(getFormat(MsgType::MSG_POPUP_TEXT), getPkgLabel(pkgName).c_str(),
+std::string createPopupCheckMsg(const std::string &pkgLabel, const std::string &priv) {
+    return makeFromFormat(getFormat(MsgType::MSG_POPUP_TEXT), pkgLabel.c_str(),
                           PrivilegeInfo::getPrivacyDisplayName(priv).c_str());
 }
 
index b702c938676551dc0dfde72590b27114d076cbc1..d4cb8bd6221a60257e082e95ef36d9f022873670 100644 (file)
@@ -26,7 +26,7 @@ namespace AskUser {
 namespace Notification {
 namespace Po {
 
-std::string createPopupCheckMsg(const std::string &pkgName, const std::string &priv);
+std::string createPopupCheckMsg(const std::string &pkgLabel, const std::string &priv);
 std::string createPrivilegeDescr(const std::string &priv);
 
 std::string getPopupTitleMsg();
index e8194bb824188bab93377f8cffe8abf3fe5cafe8..97f9e34bf6023a8860dc1e6890d31f56ca9cf4c8 100644 (file)
@@ -154,16 +154,16 @@ void Popupper::show() {
     evas_object_show(m_win);
 }
 
-void Popupper::popupCheck(const std::string &pkgId, const std::string &priv) {
+void Popupper::popupCheck(const std::string &pkgLabel, const std::string &priv) {
     std::string profileName = getProfileName();
     PopupCheck *popup;
     try {
         if (profileName[0] != 'w' && profileName[0] != 'W') {
             // Not wearable
-            popup = new PopupCheckMobile(m_win, Po::createPopupCheckMsg(pkgId, priv));
+            popup = new PopupCheckMobile(m_win, Po::createPopupCheckMsg(pkgLabel, priv));
         } else {
             // Wearable
-            popup = new PopupCheckWearable(m_win, Po::createPopupCheckMsg(pkgId, priv));
+            popup = new PopupCheckWearable(m_win, Po::createPopupCheckMsg(pkgLabel, priv));
         }
         popup->create();
     } catch (const std::exception &e) {
index 5855d53271959b1d69d7efdad98729e6fe06a526..c818a0d2ea256311b0c54c3c71e019f6c667e67e 100644 (file)
@@ -47,7 +47,7 @@ public:
     void registerPopupResponseHandler(PopupHandler handler);
     void start();
 
-    void popupCheck(const std::string &pkgId, const std::string &priv);
+    void popupCheck(const std::string &pkgLabel, const std::string &priv);
 
     void popupClose();
     void stop();