Parse ui-gadget attribute 65/45865/3
authorSangyoon Jang <s89.jang@samsung.com>
Wed, 12 Aug 2015 05:42:10 +0000 (14:42 +0900)
committerSangyoon Jang <s89.jang@samsung.com>
Wed, 12 Aug 2015 05:46:25 +0000 (14:46 +0900)
Change-Id: Ie86c603fdc9ee113e15975826798453330e586ad
Signed-off-by: Sangyoon Jang <s89.jang@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

index 089795b..ba37090 100644 (file)
@@ -3651,6 +3651,42 @@ static int is_category_exist(const char *appid, const char *category)
 int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const char *category, bool *exist);
 
 /**
+ * @fn int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle, bool *ui_gadget)
+ * @brief      This API gets the application 'ui_gadget' value from the app ID
+ *
+ * @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] ui_gadget       pointer to hold package ui_gadget value
+ * @return     0 if success, error code(<0) if fail
+ * @retval     PMINFO_R_OK     success
+ * @retval     PMINFO_R_EINVAL invalid argument
+ * @pre                pkgmgrinfo_appinfo_get_appinfo()
+ * @post       pkgmgrinfo_appinfo_destroy_appinfo()
+ * @code
+static int get_app_ui_gadget(const char *appid)
+{
+       int ret = 0;
+       bool ui_gadget;
+       pkgmgrinfo_appinfo_h handle = NULL;
+       ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+       if (ret != PMINFO_R_OK)
+               return -1;
+       ret = pkgmgrinfo_appinfo_is_ui_gadget(handle, &ui_gadget);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_appinfo_destroy_appinfo(handle);
+               return -1;
+       }
+       printf("app ui_gadget: %d\n", ui_gadget);
+       pkgmgrinfo_appinfo_destroy_appinfo(handle);
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle, bool *ui_gadget);
+
+/**
  * @fn int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
  * @brief      This API destroys the application information handle freeing up all the resources
  *
index 12ff378..bae3085 100644 (file)
@@ -310,6 +310,7 @@ typedef struct application_x {
        const char *submode;
        const char *submode_mainid;
        const char *launch_mode;
+       const char *ui_gadget;
        const char *component_type;
        const char *package;
        struct label_x *label;
@@ -355,6 +356,7 @@ typedef struct uiapplication_x {
        const char *submode;
        const char *submode_mainid;
        const char *launch_mode;
+       const char *ui_gadget;
        struct label_x *label;
        struct icon_x *icon;
        struct image_x *image;
index ce1d5f0..9b53af1 100644 (file)
@@ -1711,6 +1711,7 @@ static int __ps_process_uiapplication(xmlTextReaderPtr reader, uiapplication_x *
        __save_xml_attribute(reader, "submode", &uiapplication->submode, "false");
        __save_xml_attribute(reader, "submode-mainid", &uiapplication->submode_mainid, NULL);
        __save_xml_attribute(reader, "launch_mode", &uiapplication->launch_mode, "caller");
+       __save_xml_attribute(reader, "ui-gadget", &uiapplication->ui_gadget, "false");
 
        uiapplication->package= strdup(package);
 
index 37034b3..cb887d1 100644 (file)
@@ -135,6 +135,7 @@ sqlite3 *pkgmgr_cert_db;
                                                "app_submode text DEFAULT 'false', " \
                                                "app_submode_mainid text, " \
                                                "app_launch_mode text NOT NULL DEFAULT 'caller', " \
+                                               "app_ui_gadget text DEFAULT 'false', " \
                                                "component_type text, " \
                                                "package text not null, " \
                                                "FOREIGN KEY(package) " \
@@ -831,8 +832,8 @@ static int __insert_uiapplication_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, component_type, package, app_launch_mode) " \
-                       "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')",\
+                       "app_preload, app_submode, app_submode_mainid, app_launch_mode, app_ui_gadget, 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', '%s', '%s', '%s', '%s', '%s')",\
                         up->appid,
                         "uiapp",
                         up->exec,
@@ -856,9 +857,10 @@ static int __insert_uiapplication_info(manifest_x *mfx)
                         mfx->preload,
                         up->submode,
                         __get_str(up->submode_mainid),
+                        up->launch_mode,
+                        up->ui_gadget,
                         up->component_type,
-                        mfx->package,
-                        up->launch_mode);
+                        mfx->package);
 
                ret = __exec_query(query);
                if (ret == -1) {
index cc47899..55d9a91 100644 (file)
                                "LEFT OUTER JOIN package_app_app_category " \
                                "ON package_app_info.app_id=package_app_app_category.app_id where "
 
+static bool _get_bool_value(const char *str)
+{
+       if (str == NULL)
+               return false;
+       else if (!strcasecmp(str, "true"))
+               return true;
+       else
+               return false;
+}
+
 static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
 {
        pkgmgr_appinfo_x *info = data;
@@ -420,7 +430,8 @@ static int _appinfo_get_app(const char *appid, const char *locale,
                "app_launchcondition, app_indicatordisplay, app_portraitimg, "
                "app_landscapeimg, app_guestmodevisibility, "
                "app_permissiontype, app_preload, app_submode, "
-               "app_submode_mainid, app_launch_mode, component_type, package "
+               "app_submode_mainid, app_launch_mode, app_ui_gadget, "
+               "component_type, package "
                "FROM package_app_info WHERE app_id=%Q";
        int ret;
        char *query;
@@ -485,6 +496,7 @@ static int _appinfo_get_app(const char *appid, const char *locale,
        _save_column_str(stmt, idx++, &app->submode);
        _save_column_str(stmt, idx++, &app->submode_mainid);
        _save_column_str(stmt, idx++, &app->launch_mode);
+       _save_column_str(stmt, idx++, &app->ui_gadget);
        _save_column_str(stmt, idx++, &app->component_type);
        _save_column_str(stmt, idx++, &app->package);
 
@@ -1403,21 +1415,12 @@ API int pkgmgrinfo_appinfo_is_nodisplay(pkgmgrinfo_appinfo_h handle, bool *nodis
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(nodisplay == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_info == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->app_info->nodisplay;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *nodisplay = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *nodisplay = 0;
-               else
-                       *nodisplay = 0;
-       }
+       *nodisplay = _get_bool_value(info->app_info->nodisplay);
        return PMINFO_R_OK;
 }
 
@@ -1425,21 +1428,12 @@ API int pkgmgrinfo_appinfo_is_multiple(pkgmgrinfo_appinfo_h handle, bool *multip
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(multiple == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_info == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->app_info->multiple;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *multiple = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *multiple = 0;
-               else
-                       *multiple = 0;
-       }
+       *multiple = _get_bool_value(info->app_info->multiple);
        return PMINFO_R_OK;
 }
 
@@ -1447,22 +1441,12 @@ API int pkgmgrinfo_appinfo_is_indicator_display_allowed(pkgmgrinfo_appinfo_h han
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_info == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->app_info->indicatordisplay;
-       if (val) {
-               if (strcasecmp(val, "true") == 0){
-                       *indicator_disp = 1;
-               }else if (strcasecmp(val, "false") == 0){
-                       *indicator_disp = 0;
-               }else{
-                       *indicator_disp = 0;
-               }
-       }
+       *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
        return PMINFO_R_OK;
 }
 
@@ -1470,21 +1454,12 @@ API int pkgmgrinfo_appinfo_is_taskmanage(pkgmgrinfo_appinfo_h  handle, bool *tas
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(taskmanage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_info == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->app_info->taskmanage;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *taskmanage = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *taskmanage = 0;
-               else
-                       *taskmanage = 0;
-       }
+       *taskmanage = _get_bool_value(info->app_info->taskmanage);
        return PMINFO_R_OK;
 }
 
@@ -1492,21 +1467,12 @@ API int pkgmgrinfo_appinfo_is_enabled(pkgmgrinfo_appinfo_h  handle, bool *enable
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(enabled == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_info == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->app_info->enabled;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *enabled = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *enabled = 0;
-               else
-                       *enabled = 1;
-       }
+       *enabled = _get_bool_value(info->app_info->enabled);
        return PMINFO_R_OK;
 
 }
@@ -1515,21 +1481,12 @@ API int pkgmgrinfo_appinfo_is_onboot(pkgmgrinfo_appinfo_h  handle, bool *onboot)
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(onboot == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_info == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->app_info->onboot;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *onboot = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *onboot = 0;
-               else
-                       *onboot = 0;
-       }
+       *onboot = _get_bool_value(info->app_info->onboot);
        return PMINFO_R_OK;
 }
 
@@ -1537,21 +1494,12 @@ API int pkgmgrinfo_appinfo_is_autorestart(pkgmgrinfo_appinfo_h  handle, bool *au
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(autorestart == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_info == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->app_info->autorestart;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *autorestart = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *autorestart = 0;
-               else
-                       *autorestart = 0;
-       }
+       *autorestart = _get_bool_value(info->app_info->autorestart);
        return PMINFO_R_OK;
 }
 
@@ -1559,21 +1507,12 @@ API int pkgmgrinfo_appinfo_is_mainapp(pkgmgrinfo_appinfo_h  handle, bool *mainap
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
        retvm_if(mainapp == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-       char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_info == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->app_info->mainapp;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *mainapp = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *mainapp = 0;
-               else
-                       *mainapp = 0;
-       }
+       *mainapp = _get_bool_value(info->app_info->mainapp);
        return PMINFO_R_OK;
 }
 
@@ -1581,21 +1520,12 @@ 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;
 
        if (info->app_info == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->app_info->preload;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *preload = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *preload = 0;
-               else
-                       *preload = 0;
-       }
+       *preload = _get_bool_value(info->app_info->preload);
        return PMINFO_R_OK;
 }
 
@@ -1603,21 +1533,12 @@ API int pkgmgrinfo_appinfo_is_submode(pkgmgrinfo_appinfo_h handle, bool *submode
 {
        retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
        retvm_if(submode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-       char *val = NULL;
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
 
        if (info->app_info == NULL)
                return PMINFO_R_ERROR;
 
-       val = (char *)info->app_info->submode;
-       if (val) {
-               if (strcasecmp(val, "true") == 0)
-                       *submode = 1;
-               else if (strcasecmp(val, "false") == 0)
-                       *submode = 0;
-               else
-                       *submode = 0;
-       }
+       *submode = _get_bool_value(info->app_info->submode);
        return PMINFO_R_OK;
 }
 
@@ -1646,7 +1567,22 @@ API int pkgmgrinfo_appinfo_is_category_exist(pkgmgrinfo_appinfo_h handle, const
        return PMINFO_R_OK;
 }
 
-API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h  handle)
+API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
+               bool *ui_gadget)
+{
+       pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+       if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
+               _LOGE("invalid parameter");
+               return PMINFO_R_EINVAL;
+       }
+
+       *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
+
+       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");
        pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
@@ -2138,14 +2074,6 @@ API int pkgmgrinfo_appinfo_is_guestmode_visibility(pkgmgrinfo_appinfo_h handle,
        retvm_if(status == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
 
        val = info->uiapp_info->guestmode_visibility;
-       if (val) {
-               if (strcasecmp(val, "true") == 0){
-                       *status = 1;
-               }else if (strcasecmp(val, "false") == 0){
-                       *status = 0;
-               }else{
-                       *status = 1;
-               }
-       }
+       *status = _get_bool_value(val);
        return PMINFO_R_OK;
 }
index cd71e18..209d6aa 100644 (file)
@@ -739,6 +739,10 @@ static void __ps_free_uiapplication(uiapplication_x *uiapplication)
                free((void *)uiapplication->submode_mainid);
                uiapplication->submode_mainid = NULL;
        }
+       if (uiapplication->ui_gadget) {
+               free((void *)uiapplication->ui_gadget);
+               uiapplication->ui_gadget = NULL;
+       }
 
        free((void*)uiapplication);
        uiapplication = NULL;
@@ -1011,6 +1015,8 @@ API void pkgmgrinfo_basic_free_application(application_x *application)
                free((void *)application->submode_mainid);
        if (application->launch_mode)
                free((void *)application->launch_mode);
+       if (application->ui_gadget)
+               free((void *)application->ui_gadget);
        if (application->component_type)
                free((void *)application->component_type);
        if (application->package)