merge master branch
authorjunsuk77.oh <junsuk77.oh@samsung.com>
Thu, 13 Jun 2013 01:45:39 +0000 (10:45 +0900)
committerjunsuk77.oh <junsuk77.oh@samsung.com>
Thu, 13 Jun 2013 01:46:22 +0000 (10:46 +0900)
1. add subapp data of app
2. keep csc path data during update
3. add new api to check app preload status

Change-Id: I66f6ef2521ddc2e8100f65f7058841d52984631c
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
include/pkgmgr-info.h
packaging/pkgmgr-info.spec
parser/pkgmgr_parser.c
parser/pkgmgr_parser.h
parser/pkgmgr_parser_db.c
src/pkgmgr-info.c

index 592f8ad..3b70b78 100755 (executable)
@@ -2665,6 +2665,60 @@ int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h  handle,
                                                                                int *mime_count, char ***mime);
 
 /**
+ * @fn int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h  handle,
+                                                                               int *subapp_count, char ***subapp)
+ * @brief      This API gets the list of subapp of the application
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle           pointer to the appcontrol handle.
+ * @param[out] subapp_count            pointer to hold number of subapp
+ * @param[out] subapp          pointer to hold list of subapp
+ * @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()
+ * @see                pkgmgrinfo_appinfo_get_uri()
+ * @see                pkgmgrinfo_appinfo_get_operation()
+ * @code
+int appcontrol_func(pkgmgrinfo_appcontrol_h handle, void *user_data)
+{
+       int sc = 0;
+       int i = 0;
+       char **subapp = NULL;
+       pkgmgrinfo_appinfo_get_subapp(handle, &sc, &subapp);
+       for (i = 0; i < sc; i++) {
+               if (strcmp(subapp[i], (char *)user_data) == 0)
+                       return -1;
+               else
+                       return 0;
+       }
+}
+
+static int check_subapp(const char *appid, char *subapp)
+{
+       int ret = 0;
+       pkgmgrinfo_appinfo_h handle = NULL;
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_appinfo_foreach_appcontrol(handle, appcontrol_func, (void *)subapp);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
+               return -1;
+       }
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h  handle,
+                                               int *subapp_count, char ***subapp);
+
+/**
  * @fn int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
  * @brief      This API gets the notification icon of the application
  *
@@ -3481,6 +3535,46 @@ static int get_app_mainapp(const char *appid)
  */
 int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h  handle, bool *mainapp);
 
+
+/**
+ * @fn int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
+ * @brief      This API gets the value for given application is preload or not from handle
+ *
+ * @par                This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  handle  pointer to application info handle
+ * @param[out] preload         pointer to hold preload is or not
+ * @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()
+ * @see                pkgmgrinfo_appinfo_get_appid()
+ * @see                pkgmgrinfo_appinfo_is_multiple()
+ * @code
+static int get_app_preload(const char *appid)
+{
+       int ret = 0;
+       bool preload = 0;
+       pkgmgrinfo_appinfo_h handle = NULL;
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_appinfo_is_preload(handle, &preload);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
+               return -1;
+       }
+       printf("preload: %d\n", preload);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload);
+
 /**
  * @fn int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
  * @brief      This API destroys the application information handle freeing up all the resources
index e728532..eb25e26 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       pkgmgr-info
 Summary:    Packager Manager infomation api for package
-Version:    0.0.119
+Version:    0.0.120
 Release:    1
 Group:      Application Framework/Package Management
 License:    Apache-2.0
index ff760d5..6c3d92e 100755 (executable)
@@ -1369,6 +1369,10 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
                free((void *)uiapplication->component_type);
                uiapplication->component_type = NULL;
        }
+       if (uiapplication->preload) {
+               free((void *)uiapplication->preload);
+               uiapplication->preload = NULL;
+       }
 
        free((void*)uiapplication);
        uiapplication = NULL;
@@ -4194,8 +4198,9 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con
        DBG("parsing manifest for upgradation: %s\n", manifest);
        manifest_x *mfx = NULL;
        int ret = -1;
-       bool preload;
-       pkgmgrinfo_pkginfo_h handle;
+       bool preload = 0;
+       char *csc_path = NULL;
+       pkgmgrinfo_pkginfo_h handle = NULL;
 
        xmlInitParser();
        mfx = pkgmgr_parser_process_manifest_xml(manifest);
@@ -4216,11 +4221,21 @@ API int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *con
        if (ret != PMINFO_R_OK)
                DBG("pkgmgrinfo_pkginfo_is_preload failed\n");
 
-       if (preload){
+       if (preload) {
                free((void *)mfx->preload);
                mfx->preload = strdup("true");
        }
 
+       ret = pkgmgrinfo_pkginfo_get_csc_path(handle, &csc_path);
+       if (ret != PMINFO_R_OK)
+               DBG("pkgmgrinfo_pkginfo_get_csc_path failed\n");
+
+       if (csc_path != NULL) {
+               if (mfx->csc_path)
+                       free((void *)mfx->csc_path);
+               mfx->csc_path = strdup(csc_path);
+       }
+
        ret = pkgmgr_parser_update_manifest_info_in_db(mfx);
        if (ret == -1)
                DBG("DB Update failed\n");
index e53a85c..e3a93b0 100755 (executable)
@@ -375,6 +375,7 @@ typedef struct uiapplication_x {
        const char *app_component;
        const char *permission_type;
        const char *component_type;
+       const char *preload;
        struct label_x *label;
        struct icon_x *icon;
        struct image_x *image;
index 20625be..18335f6 100755 (executable)
@@ -107,6 +107,7 @@ char *prev = NULL;
                                                "app_landscapeimg text, " \
                                                "app_guestmodevisibility text DEFAULT 'true', " \
                                                "app_permissiontype text DEFAULT 'normal', " \
+                                               "app_preload text DEFAULT 'false', " \
                                                "component_type text, " \
                                                "package text not null, " \
                                                "FOREIGN KEY(package) " \
@@ -800,11 +801,11 @@ static int __insert_uiapplication_info(manifest_x *mfx)
                snprintf(query, MAX_QUERY_LEN,
                         "insert into package_app_info(app_id, app_component, app_exec, app_nodisplay, app_type, app_onboot, " \
                        "app_multiple, app_autorestart, app_taskmanage, app_enabled, app_hwacceleration, app_mainapp , app_recentimage, " \
-                       "app_launchcondition, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, component_type, package) " \
-                       "values('%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
+                       "app_launchcondition, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, app_preload, component_type, package) " \
+                       "values('%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
                         up->appid, "uiapp", up->exec, up->nodisplay, up->type, "\0", up->multiple,
                         "\0", up->taskmanage, up->enabled, up->hwacceleration,up->mainapp, up->recentimage,
-                        up->launchcondition, up->indicatordisplay, up->portraitimg, up->landscapeimg, up->guestmode_visibility, up->permission_type, up->component_type, mfx->package);
+                        up->launchcondition, up->indicatordisplay, up->portraitimg, up->landscapeimg, up->guestmode_visibility, up->permission_type, mfx->preload, up->component_type, mfx->package);
                ret = __exec_query(query);
                if (ret == -1) {
                        DBG("Package UiApp Info DB Insert Failed\n");
index 1f9e5af..0319686 100755 (executable)
@@ -175,9 +175,11 @@ typedef struct _pkgmgrinfo_appcontrol_x {
        int operation_count;
        int uri_count;
        int mime_count;
+       int subapp_count;
        char **operation;
        char **uri;
        char **mime;
+       char **subapp;
 } pkgmgrinfo_appcontrol_x;
 
 typedef int (*sqlite_query_callback)(void *data, int ncols, char **coltxt, char **colname);
@@ -662,6 +664,11 @@ static int __uiapp_list_cb(void *data, int ncols, char **coltxt, char **colname)
                                info->manifest_info->uiapplication->component_type = strdup(coltxt[i]);
                        else
                                info->manifest_info->uiapplication->component_type = NULL;
+               } else if (strcmp(colname[i], "app_preload") == 0 ) {
+                       if (coltxt[i])
+                               info->manifest_info->uiapplication->preload = strdup(coltxt[i]);
+                       else
+                               info->manifest_info->uiapplication->preload = NULL;
                } else
                        continue;
        }
@@ -1307,6 +1314,11 @@ static int __mini_appinfo_cb(void *data, int ncols, char **coltxt, char **colnam
                                info->uiapp_info->component_type = strdup(coltxt[i]);
                        else
                                info->uiapp_info->component_type = NULL;
+               } else if (strcmp(colname[i], "app_preload") == 0 ) {
+                       if (coltxt[i])
+                               info->uiapp_info->preload = strdup(coltxt[i]);
+                       else
+                               info->uiapp_info->preload = NULL;
                } else
                        continue;
        }
@@ -1486,6 +1498,11 @@ static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
                                        info->uiapp_info->component_type = strdup(coltxt[i]);
                                else
                                        info->uiapp_info->component_type = NULL;
+                       } else if (strcmp(colname[i], "app_preload") == 0 ) {
+                               if (coltxt[i])
+                                       info->uiapp_info->preload = strdup(coltxt[i]);
+                               else
+                                       info->uiapp_info->preload = NULL;
                        } else
                                continue;
                }
@@ -1862,7 +1879,6 @@ static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const
        check_result = __check_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
        if(check_result == 1) {
                   locale_new = __get_app_locale_from_app_localized_info_by_fallback(db, appid, locale);
-                  _LOGD("%s found (%s) language-locale in DB by fallback!\n", appid, locale_new);
                   free(locale);
                   if (locale_new == NULL)
                           locale_new =  strdup(DEFAULT_LOCALE);
@@ -1871,7 +1887,6 @@ static char* __get_app_locale_by_fallback(sqlite3 *db, const char *appid, const
 
        /* default locale */
        free(locale);
-       _LOGD("%s DEFAULT_LOCALE)\n", appid);
        return  strdup(DEFAULT_LOCALE);
 }
 
@@ -4696,6 +4711,18 @@ API int pkgmgrinfo_appinfo_get_mime(pkgmgrinfo_appcontrol_h  handle,
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_appinfo_get_subapp(pkgmgrinfo_appcontrol_h  handle,
+                                       int *subapp_count, char ***subapp)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+       retvm_if(subapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       retvm_if(subapp_count == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+       pkgmgrinfo_appcontrol_x *data = (pkgmgrinfo_appcontrol_x *)handle;
+       *subapp_count = data->subapp_count;
+       *subapp = data->subapp;
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h  handle, char **icon)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
@@ -4901,16 +4928,19 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
        int oc = 0;
        int mc = 0;
        int uc = 0;
+       int sc = 0;
        char *pkgid = NULL;
        char *manifest = NULL;
        char **operation = NULL;
        char **uri = NULL;
        char **mime = NULL;
+       char **subapp = NULL;
        appcontrol_x *appcontrol = NULL;
        manifest_x *mfx = NULL;
        operation_x *op = NULL;
        uri_x *ui = NULL;
        mime_x *mi = NULL;
+       subapp_x *sa = NULL;
        pkgmgrinfo_app_component component;
        pkgmgrinfo_appcontrol_x *ptr = NULL;
        ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
@@ -4977,6 +5007,11 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
                        mc = mc + 1;
                mi = appcontrol->mime;
 
+               sa = appcontrol->subapp;
+               for (; sa; sa = sa->next)
+                       sc = sc + 1;
+               sa = appcontrol->subapp;
+
                operation = (char **)calloc(oc, sizeof(char *));
                for (i = 0; i < oc; i++) {
                        operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
@@ -4994,13 +5029,23 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
                        mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
                        mi = mi->next;
                }
+
+               subapp = (char **)calloc(sc, sizeof(char *));
+               for (i = 0; i < sc; i++) {
+                       subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
+                       sa = sa->next;
+               }
+
                /*populate appcontrol handle*/
                ptr->operation_count = oc;
                ptr->uri_count = uc;
                ptr->mime_count = mc;
+               ptr->subapp_count = sc;
                ptr->operation = operation;
                ptr->uri = uri;
                ptr->mime = mime;
+               ptr->subapp = subapp;
+
                ret = appcontrol_func((void *)ptr, user_data);
                for (i = 0; i < oc; i++) {
                        if (operation[i]) {
@@ -5032,11 +5077,22 @@ API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
                        free(mime);
                        mime = NULL;
                }
+               for (i = 0; i < sc; i++) {
+                       if (subapp[i]) {
+                               free(subapp[i]);
+                               subapp[i] = NULL;
+                       }
+               }
+               if (subapp) {
+                       free(subapp);
+                       subapp = NULL;
+               }
                if (ret < 0)
                        break;
                uc = 0;
                mc = 0;
                oc = 0;
+               sc = 0;
        }
        pkgmgr_parser_free_manifest_xml(mfx);
        if (ptr) {
@@ -5234,6 +5290,24 @@ API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h  handle, bool *mainap
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_appinfo_is_preload(pkgmgrinfo_appinfo_h handle, bool *preload)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+       retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+       char *val = NULL;
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+       val = (char *)info->uiapp_info->preload;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *preload = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *preload = 0;
+               else
+                       *preload = 0;
+       }
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h  handle)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");