Add test automation privilege operation tizen_2.1 accepted/tizen/20130520.101223 submit/tizen/20130517.045140 submit/tizen_2.1/20130514.054822
authorHyunwoo Kim <hwlove.kim@samsung.com>
Wed, 8 May 2013 13:56:38 +0000 (22:56 +0900)
committerHyunwoo Kim <hwlove.kim@samsung.com>
Wed, 8 May 2013 13:56:43 +0000 (22:56 +0900)
Change-Id: I17b2995179c975ada01941f24aab6091d0c996f5
Signed-off-by: Hyunwoo Kim <hwlove.kim@samsung.com>
client/inc/PrivacyManagerClient.h
client/inc/privacy_manager_client.h
client/src/PrivacyManagerClient.cpp
client/src/privacy_manager_client.cpp
common/inc/IPrivacyManager.h
common/inc/PrivacyDb.h
common/src/PrivacyDb.cpp
pkgmgr_plugin/privileges.cpp
server/inc/PrivacyManagerServer.h
server/src/PrivacyManagerServer.cpp
server/src/service/PrivacyInfoService.cpp

index 960a96f..dcfca31 100644 (file)
@@ -42,7 +42,7 @@ private:
 public:\r
        static PrivacyManagerClient* getInstance(void);\r
 \r
-       int addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string >& list, bool isServerOperation = true);\r
+       int addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string >& list, bool privacyPopupRequired,  bool isServerOperation = true);\r
 \r
        int removeAppPackagePrivacyInfo(const std::string pkgId, bool isServerOperation = true);\r
 \r
@@ -63,4 +63,4 @@ public:
        int getPrivaycDescription(const std::string privacyId, std::string& description) const;\r
 };\r
 \r
-#endif // _PRIVACY_MANAGER_H_
\ No newline at end of file
+#endif // _PRIVACY_MANAGER_H_\r
index aea74dd..e2cb73b 100644 (file)
@@ -29,7 +29,7 @@ typedef bool (*privacy_manager_client_privacy_info_cb) (privacy_info_client_s* p
 typedef bool (*privacy_manager_client_all_privacy_info_cb) (privacy_info_client_s* privacy_info, void* user_data);\r
 typedef bool (*privacy_manager_client_packages_by_privacy_cb) (const char *package_id, bool is_enabled, void* user_data);\r
 \r
-EXTERN_API int privacy_manager_client_install_privacy(const char *package_id, const char** privacy_list);\r
+EXTERN_API int privacy_manager_client_install_privacy(const char *package_id, const char** privacy_list, bool privacy_popup_required);\r
 EXTERN_API int privacy_manager_client_uninstall_privacy(const char *package_id);\r
 EXTERN_API int privacy_manager_client_uninstall_privacy_by_server(const char *package_id);\r
 EXTERN_API int privacy_manager_client_foreach_privacy_packages(privacy_manager_client_privacy_packages_cb callback, void *user_data);\r
index f070dfe..fba5fc4 100644 (file)
@@ -45,7 +45,7 @@ PrivacyManagerClient::getInstance(void)
 }\r
 \r
 int\r
-PrivacyManagerClient::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string >& list, bool isServerOperation)\r
+PrivacyManagerClient::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string >& list, bool privacyPopupRequired, bool isServerOperation)\r
 {\r
 \r
        std::list < std::string > privacyList;\r
@@ -62,7 +62,7 @@ PrivacyManagerClient::addAppPackagePrivacyInfo(const std::string pkgId, const st
                int result = PRIV_MGR_ERROR_SUCCESS;\r
                res = m_pSocketClient->connect();\r
                TryReturn(res == PRIV_MGR_ERROR_SUCCESS, res, , "connect : %d", res);\r
-               res = m_pSocketClient->call("addPrivacyInfo", pkgId, privacyList, &result);\r
+               res = m_pSocketClient->call("addPrivacyInfo", pkgId, privacyList, privacyPopupRequired, &result);\r
                TryReturn(res == PRIV_MGR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);\r
                res = m_pSocketClient->disconnect();\r
                TryReturn(res == PRIV_MGR_ERROR_SUCCESS, res, , "disconnect : %d", res);\r
@@ -71,7 +71,7 @@ PrivacyManagerClient::addAppPackagePrivacyInfo(const std::string pkgId, const st
        }\r
        else\r
        {\r
-               return PrivacyDb::getInstance()->addAppPackagePrivacyInfo(pkgId, privacyList);\r
+               return PrivacyDb::getInstance()->addAppPackagePrivacyInfo(pkgId, privacyList, privacyPopupRequired);\r
        }\r
 }\r
 \r
@@ -198,7 +198,7 @@ int
 PrivacyManagerClient::getAppPackagesbyPrivacyId(const std::string privacyId, std::list < std::pair < std::string, bool > >& list) const\r
 {\r
        return PrivacyDb::getInstance()->getAppPackagesbyPrivacyId(privacyId, list);\r
-}
+}\r
 \r
 int\r
 PrivacyManagerClient::getPrivaycDisplayName(const std::string privacyId, std::string& displayName) const\r
index 920c12b..3670b86 100644 (file)
@@ -45,15 +45,15 @@ int create_privacy_info_client_s(const char* privacy_id, bool enabled, privacy_i
        return PRIV_MGR_ERROR_SUCCESS;\r
 }\r
 \r
-int privacy_manager_client_install_privacy(const char *package_id, const char** privacy_list)\r
+int privacy_manager_client_install_privacy(const char *package_id, const char** privacy_list, bool privacy_popup_required)\r
 {\r
        PrivacyManagerClient* pInst = PrivacyManagerClient::getInstance();\r
-       std::list < std::string > privacyList;\r
+       std::list < std::string > privacyList; \r
 \r
        while (*privacy_list[0] != '\0')\r
                privacyList.push_back(std::string(*privacy_list++));\r
 \r
-       int retval = pInst->addAppPackagePrivacyInfo(std::string(package_id), privacyList, false);\r
+       int retval = pInst->addAppPackagePrivacyInfo(std::string(package_id), privacyList, privacy_popup_required, false);\r
 \r
        return retval;\r
 }\r
index 599e964..26beb33 100644 (file)
@@ -29,7 +29,7 @@ class SocketClient;
 class EXTERN_API IPrivacyManager\r
 {\r
 public:\r
-       int addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string >& pList);\r
+       int addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string >& pList, bool privacyPopupRequired);\r
 \r
        int removeAppPackagePrivacyInfo(const std::string pkgId);\r
 \r
index c9286ae..dad0e9a 100644 (file)
@@ -46,7 +46,7 @@ public:
 
        int setPrivacySetting(const std::string pkgId, const std::string privacyId, bool enabled);
 
-       int addAppPackagePrivacyInfo(const std::string pkgcId, const std::list < std::string > privilegeList);
+       int addAppPackagePrivacyInfo(const std::string pkgcId, const std::list < std::string > privilegeList, bool privacyPopupRequired);
 
        int removeAppPackagePrivacyInfo(const std::string pkgId);
 
index 8709203..2ce0d7a 100644 (file)
@@ -134,7 +134,7 @@ PrivacyDb::getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pa
 
 
 int
-PrivacyDb::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string > privilegeList)
+PrivacyDb::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string > privilegeList, bool privacyPopupRequired)
 {
        LOGI("enter");
 
@@ -147,7 +147,7 @@ PrivacyDb::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < s
        int res = sqlite3_bind_text(pPkgInfoStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
        TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
        
-       res = sqlite3_bind_int(pPkgInfoStmt.get(), 2, 0);
+       res = sqlite3_bind_int(pPkgInfoStmt.get(), 2, privacyPopupRequired ? 0 : 1);
        TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
 
        res = sqlite3_step(pPkgInfoStmt.get());
index c0612e3..8f6cd6f 100644 (file)
-//\r
-// Open Service Platform\r
-// Copyright (c) 2013 Samsung Electronics Co., Ltd.\r
-//\r
-// Licensed under the Apache License, Version 2.0 (the License);\r
-// you may not use this file except in compliance with the License.\r
-// You may obtain a copy of the License at\r
-//\r
-//     http://www.apache.org/licenses/LICENSE-2.0\r
-//\r
-// Unless required by applicable law or agreed to in writing, software\r
-// distributed under the License is distributed on an "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-// See the License for the specific language governing permissions and\r
-// limitations under the License.\r
-//\r
-\r
-#include <errno.h>\r
-#include <libxml/parser.h>\r
-#include <libxml/tree.h>\r
-#include <privacy_manager_client.h>\r
-#include <dlog.h>\r
-#include <list>\r
-#include <string>\r
-\r
-static const xmlChar _NODE_PRIVILEGES[]                = "privileges";\r
-static const xmlChar _NODE_PRIVILEGE[]         = "privilege";\r
-\r
-\r
-void destroy_char_list(char** ppList, int size)\r
-{\r
-       int i;\r
-       for (i = 0; i < size; ++i)\r
-       {\r
-               if (ppList[i])\r
-                       free(ppList[i]);\r
-       }\r
-       free(ppList);\r
-}\r
-\r
-extern "C"\r
-__attribute__ ((visibility("default")))\r
-int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char* packageId)\r
-{\r
-       int ret;\r
-       LOGI("enter");\r
-\r
-       // Node: <privileges>\r
-       xmlNodePtr curPtr = xmlFirstElementChild(xmlDocGetRootElement(docPtr));\r
-       LOGD("Node: %s", curPtr->name);\r
-\r
-       curPtr = curPtr->xmlChildrenNode;\r
-       if (curPtr == NULL)\r
-       {\r
-               LOGD("No privileges");\r
-               return 0;\r
-       }\r
-\r
-       std::list <std::string> privilegeList;\r
-       while (curPtr != NULL)\r
-       {\r
-               LOGD("Node: %s", curPtr->name);\r
-\r
-               if (xmlStrcmp(curPtr->name, _NODE_PRIVILEGE) == 0)\r
-               {\r
-                       xmlChar* pPrivilege = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);\r
-                       LOGD(" value= %s", reinterpret_cast<char*>(pPrivilege));\r
-                       if (pPrivilege == NULL)\r
-                       {\r
-                               LOGE("Failed to get value");\r
-                               return -EINVAL;\r
-                       }\r
-                       privilegeList.push_back(std::string( reinterpret_cast<char*> (pPrivilege)));\r
-               }\r
-               curPtr = curPtr->next;\r
-       }\r
-\r
-       char** ppPrivilegeList = (char**) calloc(privilegeList.size() + 1, sizeof(char*));\r
-       std::list <std::string>::iterator iter = privilegeList.begin();\r
-       for (int i = 0; i < privilegeList.size(); ++i)\r
-       {\r
-               ppPrivilegeList[i] = (char*)calloc (strlen(iter->c_str()) + 1, sizeof(char));\r
-               if (ppPrivilegeList[i] == NULL)\r
-               {\r
-                       destroy_char_list(ppPrivilegeList, privilegeList.size() + 1);\r
-                       return -ENOMEM;\r
-               }\r
-               memcpy(ppPrivilegeList[i], iter->c_str(), strlen(iter->c_str()));\r
-               ++iter;\r
-       }\r
-\r
-       ppPrivilegeList[privilegeList.size()] = (char*)calloc (2, sizeof(char));\r
-       memcpy(ppPrivilegeList[privilegeList.size()], "\0", 1);\r
-\r
-       ret = privacy_manager_client_install_privacy(packageId, (const char**) ppPrivilegeList);\r
-       destroy_char_list(ppPrivilegeList, privilegeList.size() + 1);\r
-       if (ret != PRIV_MGR_ERROR_SUCCESS)\r
-       {\r
-               LOGD("Failed to install privacy : %d", ret);\r
-               return -EINVAL;\r
-       }\r
-\r
-       LOGI("leave");\r
-    \r
-    return 0;\r
-}\r
-\r
-extern "C"\r
-__attribute__ ((visibility("default")))\r
-int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char* packageId)\r
-{\r
-       LOGI("enter");\r
-\r
-       int res = privacy_manager_client_uninstall_privacy_by_server(packageId);\r
-       if (res != PRIV_MGR_ERROR_SUCCESS)\r
-       {\r
-               LOGD("Failed to uninstall privacy in server: %d", res);\r
-               \r
-               res = privacy_manager_client_uninstall_privacy(packageId);\r
-               if (res != PRIV_MGR_ERROR_SUCCESS)\r
-               {\r
-                       LOGD("Failed to uninstall privacy: %d", res);\r
-                       return -EINVAL;\r
-               }\r
-       }\r
-\r
-       LOGI("leave");\r
-       return 0;\r
-}\r
+//
+// Open Service Platform
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
+//
+// 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 <errno.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <privacy_manager_client.h>
+#include <dlog.h>
+#include <list>
+#include <string>
+
+static const xmlChar _NODE_PRIVILEGES[]                = "privileges";
+static const xmlChar _NODE_PRIVILEGE[]         = "privilege";
+static const char TEST_AUTOMATION_PRIVILEGE[] = "http://tizen.org/privilege/testautomation";
+
+void destroy_char_list(char** ppList, int size)
+{
+       int i;
+       for (i = 0; i < size; ++i)
+       {
+               if (ppList[i])
+                       free(ppList[i]);
+       }
+       free(ppList);
+}
+
+extern "C"
+__attribute__ ((visibility("default")))
+int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char* packageId)
+{
+       int ret;
+    bool privacyPopupRequired = true;
+       LOGI("enter");
+
+       // Node: <privileges>
+       xmlNodePtr curPtr = xmlFirstElementChild(xmlDocGetRootElement(docPtr));
+       LOGD("Node: %s", curPtr->name);
+
+       curPtr = curPtr->xmlChildrenNode;
+       if (curPtr == NULL)
+       {
+               LOGD("No privileges");
+               return 0;
+       }
+
+       std::list <std::string> privilegeList;
+       while (curPtr != NULL)
+       {
+               LOGD("Node: %s", curPtr->name);
+
+               if (xmlStrcmp(curPtr->name, _NODE_PRIVILEGE) == 0)
+               {
+                       xmlChar* pPrivilege = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
+                       LOGD(" value= %s", reinterpret_cast<char*>(pPrivilege));
+                       if (pPrivilege == NULL)
+                       {
+                               LOGE("Failed to get value");
+                               return -EINVAL;
+                       }
+            if (strncmp(reinterpret_cast<char*>(pPrivilege), TEST_AUTOMATION_PRIVILEGE, strlen(TEST_AUTOMATION_PRIVILEGE) ) == 0 )
+            {
+                privacyPopupRequired = false;
+            }
+            else 
+                       {
+                               privilegeList.push_back(std::string( reinterpret_cast<char*> (pPrivilege)));
+                       }
+               }
+               curPtr = curPtr->next;
+       }
+
+       char** ppPrivilegeList = (char**) calloc(privilegeList.size() + 1, sizeof(char*));
+       std::list <std::string>::iterator iter = privilegeList.begin();
+       for (int i = 0; i < privilegeList.size(); ++i)
+       {
+               ppPrivilegeList[i] = (char*)calloc (strlen(iter->c_str()) + 1, sizeof(char));
+               if (ppPrivilegeList[i] == NULL)
+               {
+                       destroy_char_list(ppPrivilegeList, privilegeList.size() + 1);
+                       return -ENOMEM;
+               }
+               memcpy(ppPrivilegeList[i], iter->c_str(), strlen(iter->c_str()));
+               ++iter;
+       }
+
+       ppPrivilegeList[privilegeList.size()] = (char*)calloc (2, sizeof(char));
+       memcpy(ppPrivilegeList[privilegeList.size()], "\0", 1);
+
+       ret = privacy_manager_client_install_privacy(packageId, (const char**) ppPrivilegeList, privacyPopupRequired);
+       destroy_char_list(ppPrivilegeList, privilegeList.size() + 1);
+       if (ret != PRIV_MGR_ERROR_SUCCESS)
+       {
+               LOGD("Failed to install privacy : %d", ret);
+               return -EINVAL;
+       }
+
+       LOGI("leave");
+    
+    return 0;
+}
+
+extern "C"
+__attribute__ ((visibility("default")))
+int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char* packageId)
+{
+       LOGI("enter");
+
+       int res = privacy_manager_client_uninstall_privacy_by_server(packageId);
+       if (res != PRIV_MGR_ERROR_SUCCESS)
+       {
+               LOGD("Failed to uninstall privacy in server: %d", res);
+               
+               res = privacy_manager_client_uninstall_privacy(packageId);
+               if (res != PRIV_MGR_ERROR_SUCCESS)
+               {
+                       LOGD("Failed to uninstall privacy: %d", res);
+                       return -EINVAL;
+               }
+       }
+
+       LOGI("leave");
+       return 0;
+}
index f6f49f4..26c8b4d 100644 (file)
@@ -47,7 +47,7 @@ public:
 \r
        int setPrivacySetting(const std::string pkgId, const std::string privacyId, bool enabled);\r
 \r
-       int addAppPackagePrivacyInfo(const std::string pkgcId, const std::list < std::string > privilegeList);\r
+       int addAppPackagePrivacyInfo(const std::string pkgcId, const std::list < std::string > privilegeList, bool privacyPopupRequired);\r
 \r
        int removeAppPackagePrivacyInfo(const std::string pkgId);\r
 \r
index e6b2a4b..3887f88 100644 (file)
@@ -56,9 +56,9 @@ PrivacyManagerServer::getAppPackagePrivacyInfo(const std::string pkgId, std::lis
 \r
 \r
 int\r
-PrivacyManagerServer::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string > privilegeList)\r
+PrivacyManagerServer::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string > privilegeList, bool privacyPopupRequired)\r
 {\r
-       return PrivacyDb::getInstance()->addAppPackagePrivacyInfo(pkgId, privilegeList);\r
+       return PrivacyDb::getInstance()->addAppPackagePrivacyInfo(pkgId, privilegeList, privacyPopupRequired);\r
 }\r
 \r
 int\r
index a39698f..a8bbbe6 100644 (file)
@@ -26,10 +26,11 @@ PrivacyInfoService::addPrivacyInfo(SocketConnection* pConnector)
 \r
        std::string pkgId;\r
        std::list < std::string > list;\r
-       pConnector->read(&pkgId, &list);\r
+       bool privacyPopupRequired = true;\r
+       pConnector->read(&pkgId, &list, &privacyPopupRequired);\r
 \r
        PrivacyManagerServer* pPrivacyManagerServer = PrivacyManagerServer::getInstance();\r
-       int result = pPrivacyManagerServer->addAppPackagePrivacyInfo(pkgId, list);\r
+       int result = pPrivacyManagerServer->addAppPackagePrivacyInfo(pkgId, list, privacyPopupRequired);\r
 \r
        pConnector->write(result);\r
 }\r