Add new APIs related to application component
[platform/core/api/app-manager.git] / src / app_info.c
index 76cc6d1..c4f0c1a 100644 (file)
@@ -79,6 +79,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;
 
@@ -102,6 +104,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;
@@ -518,6 +536,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;