Add new extension APIs related to app_component_type 39/133839/2 accepted/tizen_3.0_wearable accepted/tizen/3.0/common/20170619.133417 accepted/tizen/3.0/ivi/20170619.075734 accepted/tizen/3.0/mobile/20170619.075644 accepted/tizen/3.0/tv/20170619.075701 accepted/tizen/3.0/wearable/20170619.075718 submit/tizen_3.0/20170616.060706
authorjongmyeongko <jongmyeong.ko@samsung.com>
Tue, 13 Jun 2017 13:15:59 +0000 (22:15 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 14 Jun 2017 03:48:27 +0000 (12:48 +0900)
Change-Id: I130c9792e1b2fe5ea066126f4fcf5a7ea9b5327c
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
include/app_info_extension.h
src/app_info.c

index 1963ebff44ced3e4058454f06a6c1b653eb0c6df..cf23ece41b9c0f0a4b0de45a10269dcac8813500 100644 (file)
@@ -40,6 +40,33 @@ extern "C" {
  */
 #define   PACKAGE_INFO_PROP_APP_DISABLED    "PACKAGE_INFO_PROP_APP_DISABLED"
 
+/**
+ * @brief Definition for string property for filtering based on app info: String property for
+ *        filtering with the application component type.
+ *        Value related with this property should be one of "uiapp", "svcapp", "widgetapp"
+ *        and "watchapp".
+ * @since_tizen 3.0
+ * @see app_info_app_component_type_e
+ * @see app_info_get_app_component_type()
+ */
+#define   PACKAGE_INFO_PROP_APP_COMPONENT_TYPE    "PACKAGE_INFO_PROP_APP_COMPONENT_TYPE"
+
+/**
+ * @brief Enumeration for application component type.
+ * @since_tizen 3.0
+ * @details A component is an application considered as a part of a package.
+ *          The application component type indicates what type of
+ *          a component an application is in a package.
+ * @see PACKAGE_INFO_PROP_APP_COMPONENT_TYPE
+ * @see app_info_get_app_component_type()
+ */
+typedef enum {
+        APP_INFO_APP_COMPONENT_TYPE_UI_APP,       /**< UI application */
+        APP_INFO_APP_COMPONENT_TYPE_SERVICE_APP,  /**< Service application */
+        APP_INFO_APP_COMPONENT_TYPE_WIDGET_APP,   /**< Widget application */
+        APP_INFO_APP_COMPONENT_TYPE_WATCH_APP,    /**< Watch application */
+} app_info_app_component_type_e;
+
 /**
  * @brief  Called for each application category in app_info_foreach_category().
  * @since_tizen 3.0
@@ -72,6 +99,21 @@ typedef bool (*app_info_category_cb) (const char *category, void *user_data);
  */
 int app_info_foreach_category(app_info_h app_info, app_info_category_cb callback, void *user_data);
 
+/**
+ * @brief  Gets the application component type.
+ * @since_tizen 3.0
+ * @param[in]   app_info  The application information
+ * @param[out]  type      The application component type
+ * @return      @c 0 on success,
+ *              otherwise a negative error value
+ * @retval  #APP_MANAGER_ERROR_NONE               Successful
+ * @retval  #APP_MANAGER_ERROR_INVALID_PARAMETER  Invalid parameter
+ * @retval  #APP_MANAGER_ERROR_IO_ERROR           I/O error
+ * @see #PACKAGE_INFO_PROP_APP_COMPONENT_TYPE
+ * @see #app_info_app_component_type_e
+ */
+int app_info_get_app_component_type(app_info_h app_info, app_info_app_component_type_e *type);
+
 #ifdef __cplusplus
 }
 #endif
index ab422d2ecad8659bb083dad8c4221a1025f2f08f..82aeffd47c9226c961d2179bc1bf2fdc8cff5b23 100644 (file)
@@ -80,6 +80,8 @@ static int app_info_convert_str_property(const char *property, char **converted_
                *converted_property = PMINFO_APPINFO_PROP_APP_CATEGORY;
        else if (strcmp(property, PACKAGE_INFO_PROP_APP_INSTALLED_STORAGE) == 0)
                *converted_property = PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE;
+       else if (strcmp(property, PACKAGE_INFO_PROP_APP_COMPONENT_TYPE) == 0)
+               *converted_property = PMINFO_APPINFO_PROP_APP_COMPONENT;
        else
                return -1;
 
@@ -103,6 +105,22 @@ static int app_info_convert_bool_property(const char *property, char **converted
        return 0;
 }
 
+static int app_info_convert_app_component(pkgmgrinfo_app_component component, app_info_app_component_type_e *converted_component)
+{
+       if (component == PMINFO_UI_APP)
+               *converted_component = APP_INFO_APP_COMPONENT_TYPE_UI_APP;
+       else if (component == PMINFO_SVC_APP)
+               *converted_component = APP_INFO_APP_COMPONENT_TYPE_SERVICE_APP;
+       else if (component == PMINFO_WIDGET_APP)
+               *converted_component = APP_INFO_APP_COMPONENT_TYPE_WIDGET_APP;
+       else if (component == PMINFO_WATCH_APP)
+               *converted_component = APP_INFO_APP_COMPONENT_TYPE_WATCH_APP;
+       else
+               return -1;
+
+       return 0;
+}
+
 static int app_info_foreach_app_filter_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
 {
        int retval = 0;
@@ -519,6 +537,28 @@ API int app_info_get_type(app_info_h app_info, char **type)
        return APP_MANAGER_ERROR_NONE;
 }
 
+API int app_info_get_app_component_type(app_info_h app_info, app_info_app_component_type_e *type)
+{
+       pkgmgrinfo_app_component comp_val;
+       app_info_app_component_type_e converted_comp_val;
+       int ret = 0;
+
+       if (app_info == NULL || type == NULL)
+               return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
+       ret = pkgmgrinfo_appinfo_get_component(app_info->pkg_app_info, &comp_val);
+       if (ret < 0)
+               return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL);
+
+       ret = app_info_convert_app_component(comp_val, &converted_comp_val);
+       if (ret < 0)
+               return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL);
+
+       *type = converted_comp_val;
+
+       return APP_MANAGER_ERROR_NONE;
+}
+
 API int app_info_foreach_metadata(app_info_h app_info, app_info_metadata_cb callback, void *user_data)
 {
        int retval = 0;