-static int _appinfo_get_label(sqlite3 *db, const char *appid,
- const char *locale, GList **label)
-{
- static const char query_raw[] =
- "SELECT app_label, app_locale "
- "FROM package_app_localized_info "
- "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
- int ret;
- char *query;
- sqlite3_stmt *stmt;
- int idx;
- label_x *info;
-
- query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
- if (query == NULL) {
- LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
-
- ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
- sqlite3_free(query);
- if (ret != SQLITE_OK) {
- LOGE("prepare failed: %s", sqlite3_errmsg(db));
- return PMINFO_R_ERROR;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- info = calloc(1, sizeof(label_x));
- if (info == NULL) {
- LOGE("out of memory");
- sqlite3_finalize(stmt);
- return PMINFO_R_ERROR;
- }
- idx = 0;
- _save_column_str(stmt, idx++, &info->text);
- _save_column_str(stmt, idx++, &info->lang);
- *label = g_list_append(*label, info);
- }
-
- sqlite3_finalize(stmt);
-
- return PMINFO_R_OK;
-}
-
-static int _appinfo_get_icon(sqlite3 *db, const char *appid, const char *locale,
- GList **icon)
-{
- static const char query_raw[] =
- "SELECT app_icon, app_locale "
- "FROM package_app_localized_info "
- "WHERE app_id=%Q AND app_locale IN (%Q, %Q)";
- int ret;
- char *query;
- sqlite3_stmt *stmt;
- int idx;
- icon_x *info;
-
- query = sqlite3_mprintf(query_raw, appid, locale, DEFAULT_LOCALE);
- if (query == NULL) {
- LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
-
- ret = sqlite3_prepare_v2(db, query, strlen(query),
- &stmt, NULL);
- sqlite3_free(query);
- if (ret != SQLITE_OK) {
- LOGE("prepare failed: %s", sqlite3_errmsg(db));
- return PMINFO_R_ERROR;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- info = calloc(1, sizeof(icon_x));
- if (info == NULL) {
- LOGE("out of memory");
- sqlite3_finalize(stmt);
- return PMINFO_R_ERROR;
- }
- idx = 0;
- _save_column_str(stmt, idx++, &info->text);
- _save_column_str(stmt, idx++, &info->lang);
- *icon = g_list_append(*icon, info);
- }
-
- sqlite3_finalize(stmt);
-
- return PMINFO_R_OK;
-}
-