write privilege list to manifest.xml
authorSoyoung Kim <sy037.kim@samsung.com>
Wed, 27 Mar 2013 09:07:48 +0000 (18:07 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Thu, 28 Mar 2013 07:38:43 +0000 (16:38 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] For privacy access control.
If widget use prilege installer write a list to manifest.xml
[SCMRequest] N/A

Change-Id: Ieb6d3666567dd37a383893ba6721683b42bb400a

src/jobs/widget_install/manifest.cpp
src/jobs/widget_install/manifest.h
src/jobs/widget_install/task_manifest_file.cpp
src/jobs/widget_install/task_manifest_file.h

index 1b1dbd7..d78fbac 100644 (file)
@@ -197,6 +197,10 @@ void Manifest::serialize(xmlTextWriterPtr writer)
         {
             acc->serialize(writer);
         }
+
+        if (!this->privileges.isEmpty()) {
+            this->privileges.serialize(writer);
+        }
     }
     endElement(writer);
 }
@@ -459,5 +463,19 @@ void Account::serialize(xmlTextWriterPtr writer)
     }
     endElement(writer);
 }
+
+void Privilege::serialize(xmlTextWriterPtr writer)
+{
+    startElement(writer, "privileges");
+    {
+        FOREACH(it, this->name)
+        {
+            startElement(writer, "privilege");
+            writeText(writer, *it);
+            endElement(writer);
+        }
+    }
+    endElement(writer);
+}
 } //namespace Jobs
 } //namespace WidgetInstall
index 28fed98..20236a4 100644 (file)
@@ -176,6 +176,27 @@ class Account
     AccountProviderType provider;
 };
 
+class Privilege
+{
+  public:
+    Privilege() {}
+    void addPrivilegeName(const DPL::String &x)
+    {
+        this->name.push_back(x);
+    }
+    bool isEmpty()
+    {
+        return this->name.empty();
+    }
+
+    void serialize(xmlTextWriterPtr writer);
+
+  private:
+    std::list<DPL::String> name;
+};
+
+typedef Privilege PrivilegeType;
+
 /**
  * @brief ime-application element
  */
@@ -478,6 +499,11 @@ class Manifest
         this->account.push_back(x);
     }
 
+    void addPrivileges(const PrivilegeType &x)
+    {
+        this->privileges = x;
+    }
+
     void setInstallLocation(const InstallLocationType &x)
     {
         this->installLocation = x;
@@ -512,6 +538,8 @@ class Manifest
     PackageType type;
     NmtokenType version;
     std::list<Account> account;
+    PrivilegeType privileges;
+
 };
 } //namespace Jobs
 } //namespace WidgetInstall
index 0c66504..95b53c5 100644 (file)
@@ -582,6 +582,7 @@ void TaskManifestFile::writeManifest(const DPL::String & path)
     setAppCategory(uiApp);
     setLiveBoxInfo(manifest);
     setAccount(manifest);
+    setPrivilege(manifest);
 
     manifest.addUiApplication(uiApp);
     manifest.generate(path);
@@ -1023,5 +1024,20 @@ void TaskManifestFile::setAccount(Manifest& manifest)
     manifest.addAccount(accountInfo);
 }
 
+void TaskManifestFile::setPrivilege(Manifest& manifest)
+{
+    WrtDB::ConfigParserData::PrivilegeList privileges =
+        m_context.widgetConfig.configInfo.privilegeList;
+
+    PrivilegeType privilege;
+
+    FOREACH(it, privileges)
+    {
+        privilege.addPrivilegeName(it->name);
+    }
+
+    manifest.addPrivileges(privilege);
+}
+
 } //namespace WidgetInstall
 } //namespace Jobs
index 98548cb..0cdbe61 100644 (file)
@@ -100,6 +100,7 @@ class TaskManifestFile :
     void setAppCategory(UiApplication & uiApp);
     void setLiveBoxInfo(Manifest& manifest);
     void setAccount(Manifest& uiApp);
+    void setPrivilege(Manifest& manifest);
 
     void generateWidgetName(Manifest & manifest,
                             UiApplication &uiApp,