Add attribute 'id' on app-control element 87/196887/6
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 7 Jan 2019 09:41:34 +0000 (18:41 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 8 Jan 2019 08:09:06 +0000 (17:09 +0900)
Change-Id: I3a44c4610e8831e3597a7d9b511f5e060dfbed88
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
include/pkgmgr-info.h
include/pkgmgrinfo_basic.h
include/pkgmgrinfo_type.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
src/pkgmgrinfo_basic.c

index 9be5008..1b5c965 100644 (file)
@@ -5742,6 +5742,32 @@ int pkgmgrinfo_appinfo_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filte
                pkgmgrinfo_app_list_cb app_cb, void *user_data);
 int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
                pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid);
+
+/**
+ * @fn int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+                       pkgmgrinfo_app_control_list_cb_v2 appcontrol_func, void *user_data);
+ * @fn int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+                       pkgmgrinfo_app_control_list_cb_v2 appcontrol_func, void *user_data);
+ * @brief      This API gets the list of app-control for a particular application
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ * @param[in]  handle          pointer to the application info handle.
+ * @param[in]  appcontrol_func callback function for list
+ * @param[in]   user_data      user data to be passed to callback function
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @retval     PMINFO_R_ERROR  internal error
+ * @pre                pkgmgrinfo_appinfo_get_appinfo()
+ * @post       pkgmgrinfo_appinfo_destroy_appinfo()
+ */
+int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+               pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
+               void *user_data);
+int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+               pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
+               void *user_data);
 /**
  * @fn int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
  * @brief      This API creates the package cert information handle to get data from db.
index deb93ab..b7bb44e 100644 (file)
@@ -82,6 +82,7 @@ typedef struct appcontrol_x {
        char *uri;
        char *mime;
        char *visibility;
+       char *id;
        GList *privileges;
 } appcontrol_x;
 
index a2404f7..f4e49a3 100644 (file)
@@ -353,6 +353,24 @@ typedef int (*pkgmgrinfo_app_metadata_list_cb) (const char *metadata_key,
  */
 typedef int (*pkgmgrinfo_app_control_list_cb) (const char *operation, const char *uri, const char *mime,
                                                        void *user_data);
+/**
+ * @fn int (*pkgmgrinfo_app_control_list_cb_v2) (const char *operation, const char *uri, const char *mime, const char *id, void *user_data)
+ *
+ * @brief Specifies the type of function passed to pkgmgrinfo_appinfo_foreach_appcontrol_info()
+ *
+ * @param[in] operation The operation of the app-control
+ * @param[in] uri       The URI of the app-control
+ * @param[in] mime      The MIME-Type of the app-control
+ * @param[in] id        The ID of the app-control
+ * @param[in] user_data The user data passed from pkgmgrinfo_appinfo_foreach_appcontrol_v2()
+ *
+ * @return 0 if success, negative value(<0) if fail. Callback is not called if return value is negative.\n
+ *
+ * @see  pkgmgrinfo_appinfo_foreach_appcontrol_v2()
+ */
+typedef int (*pkgmgrinfo_app_control_list_cb_v2) (const char *operation,
+               const char *uri, const char *mime, const char *id,
+               void *user_data);
 
 /**
  * @fn int (*pkgmgrinfo_app_background_category_list_cb) (const char *category_name, void *user_data)
index 69aa09c..c8a624a 100644 (file)
         <xs:element ref="packages:subapp"/>
         <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax"/>
       </xs:choice>
+      <xs:attribute name="id" type="xs:string"/>
       <xs:attribute name="visibility" type="xs:string"/>
       <xs:anyAttribute namespace="##any" processContents="lax"/>
     </xs:complexType>
index f50d80e..253eef4 100644 (file)
         <xs:element ref="packages:mime"/>
         <xs:element ref="packages:subapp"/>
       </xs:choice>
+      <xs:attribute name="id" type="xs:string"/>
       <xs:attribute name="visibility" type="packages:AppControlVisibilityType"/>
     </xs:complexType>
   </xs:element>
index 62ffed3..b663211 100644 (file)
@@ -748,8 +748,8 @@ static int __insert_appcontrol_info(sqlite3 *db, application_x *app)
 {
        static const char query[] =
                "INSERT INTO package_app_app_control (app_id, app_control,"
-               "  visibility) "
-               "VALUES (?, ?, ?)";
+               "  visibility, app_control_id) "
+               "VALUES (?, ?, ?, ?)";
        int ret;
        sqlite3_stmt *stmt;
        int idx;
@@ -781,6 +781,7 @@ static int __insert_appcontrol_info(sqlite3 *db, application_x *app)
                __BIND_TEXT(db, stmt, idx++, app->appid);
                __BIND_TEXT(db, stmt, idx++, app_control);
                __BIND_TEXT(db, stmt, idx++, ac->visibility);
+               __BIND_TEXT(db, stmt, idx++, ac->id);
 
                ret = sqlite3_step(stmt);
                if (ret != SQLITE_DONE) {
index 531f6a2..282918b 100644 (file)
        "  app_id TEXT NOT NULL,\n" \
        "  app_control TEXT NOT NULL,\n" \
        "  visibility TEXT NOT NULL DEFAULT 'local-only',\n" \
+       "  app_control_id TEXT NOT NULL DEFAULT 'no-name-app-control',\n" \
        "  PRIMARY KEY(app_id,app_control)\n" \
        "  FOREIGN KEY(app_id)\n" \
        "  REFERENCES package_app_info(app_id) ON DELETE CASCADE)"
index dabc267..2085262 100644 (file)
@@ -1 +1 @@
-30002
+30003
index 232d75e..7d0f074 100644 (file)
@@ -155,7 +155,7 @@ static int _appinfo_get_category(sqlite3 *db, const char *appid,
 }
 
 static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str,
-               char *visibility)
+               char *visibility, char *id)
 {
        char *dup;
        char *token;
@@ -187,6 +187,7 @@ static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str,
                if (token && strcmp(token, "NULL"))
                        ac->mime = strdup(token);
                ac->visibility = strdup(visibility);
+               ac->id = strdup(id);
                *appcontrol = g_list_append(*appcontrol, ac);
        } while ((token = strtok_r(NULL, ";", &ptr)));
 
@@ -204,6 +205,7 @@ static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
        sqlite3_stmt *stmt;
        char *str;
        char *visibility;
+       char *id;
 
        query = sqlite3_mprintf(query_raw, appid);
        if (query == NULL) {
@@ -221,12 +223,15 @@ static int _appinfo_get_app_control(sqlite3 *db, const char *appid,
        while (sqlite3_step(stmt) == SQLITE_ROW) {
                str = NULL;
                visibility = NULL;
+               id = NULL;
                _save_column_str(stmt, 0, &str);
                _save_column_str(stmt, 0, &visibility);
+               _save_column_str(stmt, 0, &id);
                /* TODO: revise */
-               __parse_appcontrol(appcontrol, str, visibility);
+               __parse_appcontrol(appcontrol, str, visibility, id);
                free(str);
                free(visibility);
+               free(id);
        }
 
        sqlite3_finalize(stmt);
@@ -3623,3 +3628,60 @@ API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle,
        *status = _get_bool_value(val);
        return PMINFO_R_OK;
 }
+
+API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+               pkgmgrinfo_app_control_list_cb_v2 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, "remote-only"))
+                       continue;
+               ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
+                               appcontrol->mime, appcontrol->id, user_data);
+               if (ret < 0)
+                       break;
+       }
+
+       return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
+               pkgmgrinfo_appinfo_h handle,
+               pkgmgrinfo_app_control_list_cb_v2 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, appcontrol->id, user_data);
+               if (ret < 0)
+                       break;
+       }
+
+       return PMINFO_R_OK;
+}
index 330b1da..c5c95a8 100644 (file)
@@ -99,6 +99,13 @@ static void __ps_free_appcontrol(gpointer data)
        /*Free Mime*/
        if (appcontrol->mime)
                free((void *)appcontrol->mime);
+       /*Free Visibility*/
+       if (appcontrol->visibility)
+               free((void *)appcontrol->visibility);
+       /*Free Id*/
+       if (appcontrol->id)
+               free((void *)appcontrol->id);
+       /*Free Privileges*/
        if (appcontrol->privileges)
                g_list_free_full(appcontrol->privileges, free);
        free((void *)appcontrol);