pkgmgrinfo_app_list_cb app_cb, void *user_data);
int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(pkgmgrinfo_appinfo_metadata_filter_h handle,
pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid);
+
+/**
+ * @fn int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb_v2 appcontrol_func, void *user_data);
+ * @fn int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb_v2 appcontrol_func, void *user_data);
+ * @brief This API gets the list of app-control for a particular application
+ *
+ * @par This API is for package-manager client application
+ * @par Sync (or) Async : Synchronous API
+ * @param[in] handle pointer to the application info handle.
+ * @param[in] appcontrol_func callback function for list
+ * @param[in] user_data user data to be passed to callback function
+ * @return 0 if success, error code(<0) if fail
+ * @retval PMINFO_R_OK success
+ * @retval PMINFO_R_EINVAL invalid argument
+ * @retval PMINFO_R_ERROR internal error
+ * @pre pkgmgrinfo_appinfo_get_appinfo()
+ * @post pkgmgrinfo_appinfo_destroy_appinfo()
+ */
+int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
+ void *user_data);
+int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
+ void *user_data);
/**
* @fn int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
* @brief This API creates the package cert information handle to get data from db.
char *uri;
char *mime;
char *visibility;
+ char *id;
GList *privileges;
} appcontrol_x;
*/
typedef int (*pkgmgrinfo_app_control_list_cb) (const char *operation, const char *uri, const char *mime,
void *user_data);
+/**
+ * @fn int (*pkgmgrinfo_app_control_list_cb_v2) (const char *operation, const char *uri, const char *mime, const char *id, void *user_data)
+ *
+ * @brief Specifies the type of function passed to pkgmgrinfo_appinfo_foreach_appcontrol_info()
+ *
+ * @param[in] operation The operation of the app-control
+ * @param[in] uri The URI of the app-control
+ * @param[in] mime The MIME-Type of the app-control
+ * @param[in] id The ID of the app-control
+ * @param[in] user_data The user data passed from pkgmgrinfo_appinfo_foreach_appcontrol_v2()
+ *
+ * @return 0 if success, negative value(<0) if fail. Callback is not called if return value is negative.\n
+ *
+ * @see pkgmgrinfo_appinfo_foreach_appcontrol_v2()
+ */
+typedef int (*pkgmgrinfo_app_control_list_cb_v2) (const char *operation,
+ const char *uri, const char *mime, const char *id,
+ void *user_data);
/**
* @fn int (*pkgmgrinfo_app_background_category_list_cb) (const char *category_name, void *user_data)
<xs:element ref="packages:subapp"/>
<xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax"/>
</xs:choice>
+ <xs:attribute name="id" type="xs:string"/>
<xs:attribute name="visibility" type="xs:string"/>
<xs:anyAttribute namespace="##any" processContents="lax"/>
</xs:complexType>
<xs:element ref="packages:mime"/>
<xs:element ref="packages:subapp"/>
</xs:choice>
+ <xs:attribute name="id" type="xs:string"/>
<xs:attribute name="visibility" type="packages:AppControlVisibilityType"/>
</xs:complexType>
</xs:element>
{
static const char query[] =
"INSERT INTO package_app_app_control (app_id, app_control,"
- " visibility) "
- "VALUES (?, ?, ?)";
+ " visibility, app_control_id) "
+ "VALUES (?, ?, ?, ?)";
int ret;
sqlite3_stmt *stmt;
int idx;
__BIND_TEXT(db, stmt, idx++, app->appid);
__BIND_TEXT(db, stmt, idx++, app_control);
__BIND_TEXT(db, stmt, idx++, ac->visibility);
+ __BIND_TEXT(db, stmt, idx++, ac->id);
ret = sqlite3_step(stmt);
if (ret != SQLITE_DONE) {
" app_id TEXT NOT NULL,\n" \
" app_control TEXT NOT NULL,\n" \
" visibility TEXT NOT NULL DEFAULT 'local-only',\n" \
+ " app_control_id TEXT NOT NULL DEFAULT 'no-name-app-control',\n" \
" PRIMARY KEY(app_id,app_control)\n" \
" FOREIGN KEY(app_id)\n" \
" REFERENCES package_app_info(app_id) ON DELETE CASCADE)"
}
static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str,
- char *visibility)
+ char *visibility, char *id)
{
char *dup;
char *token;
if (token && strcmp(token, "NULL"))
ac->mime = strdup(token);
ac->visibility = strdup(visibility);
+ ac->id = strdup(id);
*appcontrol = g_list_append(*appcontrol, ac);
} while ((token = strtok_r(NULL, ";", &ptr)));
sqlite3_stmt *stmt;
char *str;
char *visibility;
+ char *id;
query = sqlite3_mprintf(query_raw, appid);
if (query == NULL) {
while (sqlite3_step(stmt) == SQLITE_ROW) {
str = NULL;
visibility = NULL;
+ id = NULL;
_save_column_str(stmt, 0, &str);
_save_column_str(stmt, 0, &visibility);
+ _save_column_str(stmt, 0, &id);
/* TODO: revise */
- __parse_appcontrol(appcontrol, str, visibility);
+ __parse_appcontrol(appcontrol, str, visibility, id);
free(str);
free(visibility);
+ free(id);
}
sqlite3_finalize(stmt);
*status = _get_bool_value(val);
return PMINFO_R_OK;
}
+
+API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
+ void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ appcontrol_x *appcontrol;
+ GList *tmp;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
+ appcontrol = (appcontrol_x *)tmp->data;
+ if (appcontrol == NULL ||
+ !strcasecmp(appcontrol->visibility, "remote-only"))
+ continue;
+ ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
+ appcontrol->mime, appcontrol->id, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
+ pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
+ void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ appcontrol_x *appcontrol;
+ GList *tmp;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
+ appcontrol = (appcontrol_x *)tmp->data;
+ if (appcontrol == NULL ||
+ !strcasecmp(appcontrol->visibility, "local-only"))
+ continue;
+ ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
+ appcontrol->mime, appcontrol->id, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
/*Free Mime*/
if (appcontrol->mime)
free((void *)appcontrol->mime);
+ /*Free Visibility*/
+ if (appcontrol->visibility)
+ free((void *)appcontrol->visibility);
+ /*Free Id*/
+ if (appcontrol->id)
+ free((void *)appcontrol->id);
+ /*Free Privileges*/
if (appcontrol->privileges)
g_list_free_full(appcontrol->privileges, free);
free((void *)appcontrol);