Fix privilege-checker to retrieve privacy information
authorhb.min <hb.min@samsung.com>
Wed, 8 May 2013 12:04:59 +0000 (21:04 +0900)
committerhb.min <hb.min@samsung.com>
Wed, 8 May 2013 12:04:59 +0000 (21:04 +0900)
Change-Id: Ibe1078383d300b3f69ce3da5da21d369c781ea87
Signed-off-by: hb.min <hb.min@samsung.com>
include/Parser.h
src/Parser.cpp

index 87a3babe9b204e13755ca7ff6a831be3258dd7e4..77b1bbde49cfabb07cf5d7d8e7a91ede143d4420 100644 (file)
@@ -34,10 +34,11 @@ public:
 private:
        static int SetPrivilegeDb(PrivilegeInfo* pPrivilegeInfo);
        static int SetPrivacyDb(PrivacyInfo* pPrivilegeInfo);
-       static int ParseStringInfo (xmlDocPtr stringInfoDoc, xmlNodePtr currentDoc, StringInfo** ppStringInfo);
-       static int ParsePrivilege (xmlDocPtr privilegeDoc, xmlNodePtr currentDoc);
-       static int ParsePrivilegeList (xmlDocPtr privilegeListDoc, xmlNodePtr currentDoc);
-       static int ParsePrivacyList (xmlDocPtr privacyListDoc, xmlNodePtr currentDoc);
+       static int ParseStringInfo(xmlDocPtr stringInfoDoc, xmlNodePtr currentDoc, StringInfo** ppStringInfo);
+       static int ParsePrivilege(xmlDocPtr privilegeDoc, xmlNodePtr currentDoc);
+       static int ParsePrivilegeList(xmlDocPtr privilegeListDoc, xmlNodePtr currentDoc);
+       static int ParsePrivacy(xmlDocPtr privacyDoc, xmlNodePtr currentDoc);
+       static int ParsePrivacyList(xmlDocPtr privacyListDoc, xmlNodePtr currentDoc);
 
 };
 
index 633b691a61f96e2aa70136ffdbe8f8ab7334a932..18e0f55087cb5baa2ba9be1a884582d3ea2ee92c 100644 (file)
@@ -192,7 +192,7 @@ Parser::ParsePrivilegeList (xmlDocPtr privilegeListDoc, xmlNodePtr currentDoc)
 }
 
 int
-Parser::ParsePrivacyList (xmlDocPtr privacyListDoc, xmlNodePtr currentDoc)
+Parser::ParsePrivacy(xmlDocPtr privacyDoc, xmlNodePtr currentDoc)
 {
        LOGI("enter");
        int res = PRIV_CHECKER_SUCCESS;
@@ -207,11 +207,11 @@ Parser::ParsePrivacyList (xmlDocPtr privacyListDoc, xmlNodePtr currentDoc)
                {
                        if ((!xmlStrcmp(currentDoc->name, (const xmlChar *)"id")))
                        {
-                               pPrivacyInfo->pId = xmlNodeListGetString(privacyListDoc, currentDoc->xmlChildrenNode, 1);
+                               pPrivacyInfo->pId = xmlNodeListGetString(privacyDoc, currentDoc->xmlChildrenNode, 1);
                        }
                        else if ((!xmlStrcmp(currentDoc->name, (const xmlChar *)"string_info")))
                        {
-                               res = ParseStringInfo(privacyListDoc, currentDoc, &(pPrivacyInfo->pStringInfo));
+                               res = ParseStringInfo(privacyDoc, currentDoc, &(pPrivacyInfo->pStringInfo));
                                TryCatch(res == PRIV_CHECKER_SUCCESS, , "[%s] Propagated.", Util::GetErrorMessage(res));
                        }
                        else
@@ -247,6 +247,36 @@ CATCH:
 
 }
 
+int
+Parser::ParsePrivacyList (xmlDocPtr privacyListDoc, xmlNodePtr currentDoc)
+{
+       LOGI("enter");
+       int res = PRIV_CHECKER_SUCCESS;
+
+       currentDoc = currentDoc->xmlChildrenNode;
+       while (currentDoc != NULL)
+       {
+               if (currentDoc->type == XML_ELEMENT_NODE)
+               {
+                       if ((!xmlStrcmp(currentDoc->name, (const xmlChar *)"privacy")))
+                       {
+                               res = ParsePrivacy(privacyListDoc, currentDoc);
+                               TryReturn(res == PRIV_CHECKER_SUCCESS, , res, "[%s] Propagated.", Util::GetErrorMessage(res));
+                       }
+                       else
+                       {
+                               LOGE("[PRIV_CHECKER_ERROR_INVALID_ARG] Invalid policy type: %s", currentDoc->name);
+                               res = PRIV_CHECKER_ERROR_INVALID_ARG;
+                               return res;
+                       }
+               }
+               currentDoc = currentDoc->next;
+       }
+
+       LOGI("leave");
+       return res;
+}
+
 
 int
 Parser::ParseExtendedPolicy(char *docName)