Add missed DB column and APIs for process pool, TEP and 92/51892/1 submit/tizen/20151117.080527
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 17 Nov 2015 05:07:53 +0000 (14:07 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 17 Nov 2015 05:07:53 +0000 (14:07 +0900)
installed_storage in package_info and package_app_info

Change-Id: Icfe6db4b104b69d8b23774101f7fb1976438b19a
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
include/pkgmgr-info.h
include/pkgmgrinfo_basic.h
parser/pkgmgr_parser.c
parser/pkgmgr_parser_db.c
src/pkgmgrinfo_appinfo.c
src/pkgmgrinfo_basic.c
src/pkgmgrinfo_pkginfo.c

index 439cb6a..29c2537 100644 (file)
@@ -412,6 +412,44 @@ static int get_pkg_version(const char *pkgid)
 int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version);
 
 /**
+ * @fn int pkgmgrinfo_pkginfo_get_tep_name(pkgmgrinfo_pkginfo_h handle, char **tep_name)
+ * @brief      This API gets tep(tizen expansion package) file name associated with the package
+ *
+ * @par        This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in] handle           pointer to the pkginfo handle.
+ * @param[out] tep_name        pointer to hold tep name
+ * @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_pkginfo_get_pkginfo()
+ * @post               pkgmgrinfo_pkginfo_destroy_pkginfo()
+ * @see        pkgmgrinfo_pkginfo_get_pkgid()
+ * @code
+static int get_tep_name(const char *pkgid)
+{
+       int ret = 0;
+       char *tep_name = NULL;
+       pkgmgrinfo_pkginfo_h handle = NULL;
+       ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_pkginfo_get_tep_name(handle, &tep_name);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+               return -1;
+       }
+       printf("TEP name is: %s\n", tep_name);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_pkginfo_get_tep_name(pkgmgrinfo_pkginfo_h handle, char **tep_name);
+
+/**
  * @fn int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
  * @brief      This API gets the package install location from the package ID
  *
@@ -3662,6 +3700,83 @@ static int get_app_submode(const char *appid)
 int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode);
 
 /**
+ * @fn int int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
+ * @brief      This API gets the value for given application is process_pool 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] process_pool            pointer to hold process_pool 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()
+ * @code
+static int get_app_process_pool(const char *appid)
+{
+       int ret = 0;
+       bool process_pool = 0;
+       pkgmgrinfo_appinfo_h handle = NULL;
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_appinfo_is_process_pool(handle, &process_pool);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
+               return -1;
+       }
+       printf("process_pool: %d\n", process_pool);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool);
+
+/**
+ * @fn int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
+ * @brief      This API gets the installed storage location of the 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[out] app_type        pointer to hold installed storage location
+ * @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()
+ * @code
+static int get_app_installed_location(const char *appid)
+{
+       int ret = 0;
+       pkgmgrinfo_installed_storage storage;
+       pkgmgrinfo_appinfo_h handle = NULL;
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_appinfo_get_installed_storage_location(handle, &storage);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
+               return -1;
+       }
+       printf("Installed storage location : %d\n", storage);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage);
+
+
+/**
  * @fn int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
  * @brief      This API checks if the application has the given category
  *
index f34b5f9..e86378c 100644 (file)
@@ -119,6 +119,7 @@ typedef struct application_x {
        const char *submode;    /*attr, default: "false"*/
        const char *submode_mainid;     /*attr, default: "false"*/
        const char *process_pool;       /*attr, default: "false"*/
+       const char *installed_storage;
        const char *autorestart;        /*attr, default: "false"*/
        const char *onboot;     /*attr, default: "false"*/
        const char *multi_instance;     /*attr, default: "false"*/
index 3683c22..f888aee 100644 (file)
@@ -1649,6 +1649,7 @@ static int __ps_process_application(xmlTextReaderPtr reader, application_x *appl
        retvm_if(((strcmp(application->component_type, "svcapp") != 0) && (strcmp(application->component_type, "uiapp") != 0) && (strcmp(application->component_type, "widgetapp") != 0)), PM_PARSER_R_ERROR, "invalid component_type[%s]", application->component_type);
        __save_xml_attribute(reader, "submode", &application->submode, "false");
        __save_xml_attribute(reader, "submode-mainid", &application->submode_mainid, NULL);
+       __save_xml_attribute(reader, "process-pool", &application->process_pool, "false");
        __save_xml_attribute(reader, "launch_mode", &application->launch_mode, "caller");
        __save_xml_attribute(reader, "ui-gadget", &application->ui_gadget, "false");
        __save_xml_attribute(reader, "auto-restart", &application->autorestart, "false");
index 60e705b..2be532c 100644 (file)
@@ -137,6 +137,8 @@ sqlite3 *pkgmgr_cert_db;
                                                "app_preload text DEFAULT 'false', " \
                                                "app_submode text DEFAULT 'false', " \
                                                "app_submode_mainid text, " \
+                                               "app_installed_storage text, " \
+                                               "app_process_pool text DEFAULT 'false', " \
                                                "app_launch_mode text NOT NULL DEFAULT 'caller', " \
                                                "app_ui_gadget text DEFAULT 'false', " \
                                                "app_support_disable text DEFAULT 'false', " \
@@ -843,8 +845,8 @@ static int __insert_application_info(manifest_x *mfx)
                         "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_screenreader, app_mainapp , app_recentimage, " \
                        "app_launchcondition, app_indicatordisplay, app_portraitimg, app_landscapeimg, app_guestmodevisibility, app_permissiontype, "\
-                       "app_preload, app_submode, app_submode_mainid, app_launch_mode, app_ui_gadget, app_support_disable, component_type, package, app_tep_name) " \
-                       "values('%s', '%s', '%s', '%s', '%s', '%s', '%s','%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
+                       "app_preload, app_submode, app_submode_mainid, app_installed_storage, app_process_pool, app_launch_mode, app_ui_gadget, app_support_disable, component_type, package, app_tep_name) " \
+                       "values('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",\
                         app->appid,
                         app->component_type,
                         app->exec,
@@ -868,6 +870,8 @@ static int __insert_application_info(manifest_x *mfx)
                         mfx->preload,
                         app->submode,
                         __get_str(app->submode_mainid),
+                        mfx->installed_storage,
+                        app->process_pool,
                         app->launch_mode,
                         app->ui_gadget,
                         mfx->support_disable,
index 4e7384a..0b26c66 100644 (file)
@@ -503,7 +503,7 @@ static int _appinfo_get_application(sqlite3 *db, const char *appid,
                "app_permissiontype, app_preload, app_submode, "
                "app_submode_mainid, app_launch_mode, app_ui_gadget, "
                "app_support_disable, "
-               "component_type, package "
+               "component_type, package, app_process_pool, app_installed_storage "
                "FROM package_app_info WHERE app_id=%Q";
        int ret;
        char *query;
@@ -569,6 +569,8 @@ static int _appinfo_get_application(sqlite3 *db, const char *appid,
        _save_column_str(stmt, idx++, &info->support_disable);
        _save_column_str(stmt, idx++, &info->component_type);
        _save_column_str(stmt, idx++, &info->package);
+       _save_column_str(stmt, idx++, &info->process_pool);
+       _save_column_str(stmt, idx++, &info->installed_storage);
 
        if (_appinfo_get_label(db, info->appid, locale, &info->label)) {
                pkgmgrinfo_basic_free_application(info);
@@ -1339,6 +1341,42 @@ API int pkgmgrinfo_appinfo_get_submode_mainid(pkgmgrinfo_appinfo_h  handle, char
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_appinfo_is_process_pool(pkgmgrinfo_appinfo_h handle, bool *process_pool)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+       retvm_if(process_pool == 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->app_info->process_pool;
+       if (val) {
+               if (strcasecmp(val, "true") == 0)
+                       *process_pool = 1;
+               else if (strcasecmp(val, "false") == 0)
+                       *process_pool = 0;
+               else
+                       *process_pool = 0;
+       }
+       return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_installed_storage_location(pkgmgrinfo_appinfo_h handle, pkgmgrinfo_installed_storage *storage)
+{
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+       if (info->app_info && info->app_info->installed_storage){
+                if (strcmp(info->app_info->installed_storage,"installed_internal") == 0)
+                       *storage = PMINFO_INTERNAL_STORAGE;
+                else if (strcmp(info->app_info->installed_storage,"installed_external") == 0)
+                        *storage = PMINFO_EXTERNAL_STORAGE;
+                else
+                        return PMINFO_R_ERROR;
+       }else
+               return PMINFO_R_ERROR;
+
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_appinfo_get_launch_mode(pkgmgrinfo_appinfo_h handle, char **mode)
 {
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
index 2b6fb5b..5f614b6 100644 (file)
@@ -257,6 +257,10 @@ static void __ps_free_application(gpointer data)
                free((void *)application->submode);
        if (application->submode_mainid)
                free((void *)application->submode_mainid);
+       if (application->process_pool)
+               free((void *)application->process_pool);
+       if (application->installed_storage)
+               free((void *)application->installed_storage);
        if (application->launch_mode)
                free((void *)application->launch_mode);
        if (application->ui_gadget)
index 4b92bf0..a71f79e 100644 (file)
@@ -19,7 +19,7 @@
  * limitations under the License.
  *
  */
+
 #define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
@@ -639,7 +639,7 @@ static int _pkginfo_get_package(sqlite3 *db, const char *pkgid,
                "package_system, package_type, package_size, installed_time, "
                "installed_storage, storeclient_id, mainapp_id, package_url, "
                "root_path, csc_path, package_nodisplay, package_api_version, "
-               "package_support_disable "
+               "package_support_disable, package_tep_name "
                "FROM package_info WHERE package=%Q";
        int ret;
        char *query;
@@ -699,6 +699,7 @@ static int _pkginfo_get_package(sqlite3 *db, const char *pkgid,
        _save_column_str(stmt, idx++, &info->nodisplay_setting);
        _save_column_str(stmt, idx++, &info->api_version);
        _save_column_str(stmt, idx++, &info->support_disable);
+       _save_column_str(stmt, idx++, &info->tep_name);
 
        if (_pkginfo_get_author(db, info->package, &info->author)) {
                pkgmgrinfo_basic_free_package(info);
@@ -875,6 +876,21 @@ API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **versi
        return PMINFO_R_OK;
 }
 
+API int pkgmgrinfo_pkginfo_get_tep_name(pkgmgrinfo_pkginfo_h handle, char **tep_name)
+{
+       pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+       retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+       retvm_if(tep_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+       if (info->pkg_info == NULL || info->pkg_info->tep_name == NULL)
+               return PMINFO_R_ERROR;
+
+       *tep_name = (char *)info->pkg_info->tep_name;
+
+       return PMINFO_R_OK;
+}
+
 API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
 {
        char *val;