-//\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
- LOGD("delete: %s", ppList[i]);\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
- std::string temp (reinterpret_cast<char*> (pPrivilege));\r
- LOGD(" test 1 : %s", temp.c_str());\r
- privilegeList.push_back(std::string( temp));\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
- LOGD(" test 2 : %s %d", iter->c_str(), i);\r
- ppPrivilegeList[i] = (char*)calloc (strlen(iter->c_str()) + 1, sizeof(char));\r
-\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
- LOGD(" test 3 : %s", ppPrivilegeList[0]);\r
- ++iter;\r
- }\r
- for (int i = 0; i < privilegeList.size(); ++i)\r
- LOGD(" values : %s %x", ppPrivilegeList[i], (int)ppPrivilegeList[i]);\r
-\r
- ppPrivilegeList[privilegeList.size()] = (char*)calloc (1, sizeof(char) + 1 );\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
-\r
-extern "C"\r
-__attribute__ ((visibility("default")))\r
-int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char* packageId)\r
-{\r
- LOGI("enter");\r
-\r
- privacy_manager_client_uninstall_privacy(packageId);\r
-\r
- return 0;\r
- LOGI("leave"); \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;
+}