*
* @remarks This function is only for App Framework internally.
*/
-int aul_comp_info_foreach(const char *app_id, aul_comp_info_cb callback,
+int aul_comp_info_foreach_from_app(const char *app_id, aul_comp_info_cb callback,
void *user_data);
/**
*
* @remarks This function is only for App Framework internally.
*/
-int aul_comp_info_foreach_usr(const char *app_id, uid_t uid,
+int aul_comp_info_foreach_usr_from_app(const char *app_id, uid_t uid,
aul_comp_info_cb callback, void *user_data);
+/**
+ * @brief Retrieves all installed components information.
+ * @since_tizen 5.5
+ *
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @see aul_comp_info_cb()
+ *
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_comp_info_foreach(aul_comp_info_cb callback, void *user_data);
+
+/**
+ * @brief Retrieves all installed components information.
+ * @since_tizen 5.5
+ *
+ * @param[in] uid The user ID
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @see aul_comp_info_cb()
+ *
+ * @remarks This function is only for App Framework internally.
+ */
+int aul_comp_info_foreach_usr(uid_t uid, aul_comp_info_cb callback,
+ void *user_data);
+
#ifdef __cplusplus
}
#endif
return AUL_R_OK;
}
-static int __get_comp_info_list(const char *app_id, const char *locale,
- uid_t uid, GList **list)
+static int __get_comp_info_list(const char *locale, uid_t uid, GList **list)
{
static const char query_raw[] = "SELECT DISTINCT ci.app_id, "
"ci.component_id, ci.component_type, ci.component_launch_mode, "
"WHERE ci.component_id=component_id AND component_locale=%Q), "
"(SELECT component_icon FROM component_localized_info "
"WHERE ci.component_id=component_id AND component_locale='No Locale')) "
- "FROM component_info as ci WHERE app_id=%Q";
+ "FROM component_info as ci";
sqlite3_stmt *stmt = NULL;
sqlite3 *db = NULL;
char *query = NULL;
}
free(db_path);
- query = sqlite3_mprintf(query_raw, locale, locale, app_id);
+ query = sqlite3_mprintf(query_raw, locale, locale);
if (!query) {
_E("Out of memory");
ret = AUL_R_ERROR;
return ret;
}
-API int aul_comp_info_foreach(const char *app_id, aul_comp_info_cb callback,
- void *user_data)
+API int aul_comp_info_foreach_from_app(const char *app_id,
+ aul_comp_info_cb callback, void *user_data)
{
- return aul_comp_info_foreach_usr(app_id, getuid(), callback, user_data);
+ return aul_comp_info_foreach_usr_from_app(app_id, getuid(),
+ callback, user_data);
}
-API int aul_comp_info_foreach_usr(const char *app_id, uid_t uid,
+API int aul_comp_info_foreach_usr_from_app(const char *app_id, uid_t uid,
aul_comp_info_cb callback, void *user_data)
{
struct aul_comp_info_s *info;
return AUL_R_ERROR;
}
- ret = __get_comp_info_list(app_id, locale, uid, &list);
+ ret = __get_comp_info_list(locale, uid, &list);
if (ret != AUL_R_OK && uid != GLOBAL_USER)
- ret = __get_comp_info_list(app_id, locale, GLOBAL_USER, &list);
+ ret = __get_comp_info_list(locale, GLOBAL_USER, &list);
free(locale);
if (ret != AUL_R_OK) {
iter = list;
while (iter) {
info = (struct aul_comp_info_s *)iter->data;
+ iter = g_list_next(iter);
+
+ if (strcmp(info->value[AUL_COMP_INFO_APP_ID], app_id) != 0)
+ continue;
+
if (!callback((aul_comp_info_h)info, user_data))
break;
- iter = g_list_next(iter);
}
g_list_free_full(list, __destroy_comp_info);
return AUL_R_OK;
}
+API int aul_comp_info_foreach(aul_comp_info_cb callback, void *user_data)
+{
+ return aul_comp_info_foreach_usr(getuid(), callback, user_data);
+}
+
+API int aul_comp_info_foreach_usr(uid_t uid, aul_comp_info_cb callback,
+ void *user_data)
+{
+ struct aul_comp_info_s *info;
+ GList *list = NULL;
+ GList *iter;
+ char *locale;
+ int ret;
+
+ if (!callback) {
+ LOGE("Invalid parameter");
+ return AUL_R_EINVAL;
+ }
+
+ locale = __get_system_locale();
+ if (!locale) {
+ _E("Failed to get system locale");
+ return AUL_R_ERROR;
+ }
+
+ ret = __get_comp_info_list(locale, uid, &list);
+ if (ret != AUL_R_OK && uid != GLOBAL_USER)
+ ret = __get_comp_info_list(locale, GLOBAL_USER, &list);
+
+ free(locale);
+ if (ret != AUL_R_OK) {
+ _E("Failed to get comp infos");
+ return ret;
+ }
+
+ iter = list;
+ while (iter) {
+ info = (struct aul_comp_info_s *)iter->data;
+ if (!callback((aul_comp_info_h)info, user_data))
+ break;
+ iter = g_list_next(iter);
+ }
+
+ g_list_free_full(list, __destroy_comp_info);
+
+ return AUL_R_OK;
+}