ret = __open_db(dbpath, &db, SQLITE_OPEN_READONLY);
if (ret != SQLITE_OK) {
- _LOGE("failed to open db: %d", ret);
+ _LOGE("failed to open db(%s): %d", dbpath, ret);
free(dbpath);
return PMINFO_R_ERROR;
}
return PMINFO_R_OK;
}
-API int pkgmgrinfo_appinfo_get_setting_icon(pkgmgrinfo_appinfo_h handle, char **icon)
-{
- char *val;
- icon_x *ptr;
- GList *tmp;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
- ptr = (icon_x *)tmp->data;
- if (ptr == NULL || ptr->section == NULL)
- continue;
-
- val = (char *)ptr->section;
- if (val && strcmp(val, "setting") == 0) {
- *icon = (char *)ptr->text;
- return PMINFO_R_OK;
- }
- }
-
- return PMINFO_R_ERROR;
-}
-
-
API int pkgmgrinfo_appinfo_get_notification_icon(pkgmgrinfo_appinfo_h handle, char **icon)
{
char *val;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(permission_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
- int ret = -1;
- permission_x *ptr;
- GList *tmp;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (tmp = info->app_info->permission; tmp; tmp = tmp->next) {
- ptr = (permission_x *)tmp->data;
- if (ptr == NULL)
- continue;
- if (ptr->value) {
- ret = permission_func(ptr->value, user_data);
- if (ret < 0)
- break;
- }
- }
- return PMINFO_R_OK;
-}
-
API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
pkgmgrinfo_app_category_list_cb category_func, void *user_data)
{
return PMINFO_R_OK;
}
+API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
+ const char *operation, const char *uri, const char *mime,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func,
+ void *user_data, uid_t uid)
+{
+ static const char query_raw[] =
+ "SELECT privilege FROM package_app_app_control_privilege "
+ "WHERE app_id=%Q AND app_control=%Q";
+ int ret;
+ char *query;
+ sqlite3_stmt *stmt;
+ char *privilege;
+ char app_control[BUFSIZE];
+
+ if (appid == NULL || operation == NULL || privilege_func == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ snprintf(app_control, sizeof(app_control), "%s|%s|%s", operation,
+ uri ? uri : "NULL", mime ? mime : "NULL");
+
+ ret = __open_manifest_db(uid, true);
+ if (ret != SQLITE_OK) {
+ LOGE("open db failed");
+ return PMINFO_R_ERROR;
+ }
+
+ query = sqlite3_mprintf(query_raw, appid, app_control);
+ if (query == NULL) {
+ LOGE("out of memory");
+ __close_manifest_db();
+ return PMINFO_R_ERROR;
+ }
+
+ ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query),
+ &stmt, NULL);
+ sqlite3_free(query);
+ if (ret != PMINFO_R_OK) {
+ LOGE("prepare failed: %s", sqlite3_errmsg(GET_DB(manifest_db)));
+ __close_manifest_db();
+ return PMINFO_R_ERROR;
+ }
+
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ privilege = (char *)sqlite3_column_text(stmt, 0);
+ ret = privilege_func(privilege, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ sqlite3_finalize(stmt);
+ __close_manifest_db();
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
+ const char *operation, const char *uri, const char *mime,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func,
+ void *user_data)
+{
+ return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
+ operation, uri, mime, privilege_func, user_data,
+ _getuid());
+}
+
API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
{