Implement remote appcontrol feature 05/170905/8
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 23 Feb 2018 06:39:56 +0000 (15:39 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Thu, 10 May 2018 06:19:36 +0000 (15:19 +0900)
Change-Id: I1168424c7920bad0f52ab73f98c008dd22d03b4f
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
include/pkgmgr-info.h
include/pkgmgrinfo_basic.h
parser/manifest.xsd.in
parser/manifest.xsd.ref
parser/src/pkgmgr_parser_db.c
parser/src/pkgmgr_parser_db_queries.h
pkg_db_version.txt.in
src/pkgmgrinfo_appinfo.c

index 76197e4..fe251f1 100644 (file)
@@ -4370,6 +4370,9 @@ static int check_operation(const char *appid, char *operation)
 int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
                        pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data);
 
+int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle,
+                       pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data);
+
 /**
  * @brief
  */
index d3ffd50..deb93ab 100644 (file)
@@ -81,6 +81,7 @@ typedef struct appcontrol_x {
        char *operation;
        char *uri;
        char *mime;
+       char *visibility;
        GList *privileges;
 } appcontrol_x;
 
index 19f9058..69aa09c 100644 (file)
         <xs:element ref="packages:subapp"/>
         <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax"/>
       </xs:choice>
+      <xs:attribute name="visibility" type="xs:string"/>
+      <xs:anyAttribute namespace="##any" processContents="lax"/>
     </xs:complexType>
   </xs:element>
   <xs:element name="category">
index f012ab8..f50d80e 100644 (file)
       <xs:enumeration value="wgt"/>
     </xs:restriction>
   </xs:simpleType>
+  <xs:simpleType name="AppControlVisibilityType">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="local-only"/>
+      <xs:enumeration value="remote-only"/>
+      <xs:enumeration value="both"/>
+    </xs:restriction>
+  </xs:simpleType>
 
   <xs:element name="author">
     <xs:complexType mixed="true">
         <xs:element ref="packages:mime"/>
         <xs:element ref="packages:subapp"/>
       </xs:choice>
+      <xs:attribute name="visibility" type="packages:AppControlVisibilityType"/>
     </xs:complexType>
   </xs:element>
   <xs:element name="category">
index 6afd1da..a5f992d 100644 (file)
@@ -626,8 +626,9 @@ static int __insert_appcontrol_privilege_info(sqlite3 *db, const char *appid,
 static int __insert_appcontrol_info(sqlite3 *db, application_x *app)
 {
        static const char query[] =
-               "INSERT INTO package_app_app_control (app_id, app_control) "
-               "VALUES (?, ?)";
+               "INSERT INTO package_app_app_control (app_id, app_control,"
+               "  visibility) "
+               "VALUES (?, ?, ?)";
        int ret;
        sqlite3_stmt *stmt;
        int idx;
@@ -658,6 +659,7 @@ static int __insert_appcontrol_info(sqlite3 *db, application_x *app)
                                        ac->mime : "NULL") : "NULL");
                __BIND_TEXT(db, stmt, idx++, app->appid);
                __BIND_TEXT(db, stmt, idx++, app_control);
+               __BIND_TEXT(db, stmt, idx++, ac->visibility);
 
                ret = sqlite3_step(stmt);
                if (ret != SQLITE_DONE) {
index 67d3304..531f6a2 100644 (file)
        "CREATE TABLE IF NOT EXISTS package_app_app_control (\n" \
        "  app_id TEXT NOT NULL,\n" \
        "  app_control TEXT NOT NULL,\n" \
+       "  visibility TEXT NOT NULL DEFAULT 'local-only',\n" \
        "  PRIMARY KEY(app_id,app_control)\n" \
        "  FOREIGN KEY(app_id)\n" \
        "  REFERENCES package_app_info(app_id) ON DELETE CASCADE)"
index 4b1526e..dabc267 100644 (file)
@@ -1 +1 @@
-30001
+30002
index a3833c1..ed3ba9a 100644 (file)
@@ -2825,7 +2825,32 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
 
        for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
                appcontrol = (appcontrol_x *)tmp->data;
-               if (appcontrol == NULL)
+               if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "remote-only"))
+                       continue;
+               ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
+               if (ret < 0)
+                       break;
+       }
+
+       return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(pkgmgrinfo_appinfo_h handle,
+                       pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
+       int ret;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       appcontrol_x *appcontrol;
+       GList *tmp;
+
+       if (info->app_info == NULL)
+               return PMINFO_R_ERROR;
+
+       for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
+               appcontrol = (appcontrol_x *)tmp->data;
+               if (appcontrol == NULL || !strcasecmp(appcontrol->visibility, "local-only"))
                        continue;
                ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
                if (ret < 0)