{
if (appcontrol == NULL)
return;
- if (appcontrol->text) {
- free((void *)appcontrol->text);
- appcontrol->text = NULL;
- }
/*Free Operation*/
- if (appcontrol->operation) {
- operation_x *operation = appcontrol->operation;
- operation_x *tmp = NULL;
- while(operation != NULL) {
- tmp = operation->next;
- __ps_free_operation(operation);
- operation = tmp;
- }
- }
+ if (appcontrol->operation)
+ free(appcontrol->operation);
/*Free Uri*/
- if (appcontrol->uri) {
- uri_x *uri = appcontrol->uri;
- uri_x *tmp = NULL;
- while(uri != NULL) {
- tmp = uri->next;
- __ps_free_uri(uri);
- uri = tmp;
- }
- }
+ if (appcontrol->uri)
+ free(appcontrol->uri);
/*Free Mime*/
- if (appcontrol->mime) {
- mime_x *mime = appcontrol->mime;
- mime_x *tmp = NULL;
- while(mime != NULL) {
- tmp = mime->next;
- __ps_free_mime(mime);
- mime = tmp;
- }
- }
- /*Free subapp*/
- if (appcontrol->subapp) {
- subapp_x *subapp = appcontrol->subapp;
- subapp_x *tmp = NULL;
- while(subapp != NULL) {
- tmp = subapp->next;
- __ps_free_subapp(subapp);
- subapp = tmp;
- }
- }
+ if (appcontrol->mime)
+ free(appcontrol->mime);
free((void*)appcontrol);
appcontrol = NULL;
}
const xmlChar *node;
int ret = -1;
int depth = -1;
- operation_x *tmp1 = NULL;
- uri_x *tmp2 = NULL;
- mime_x *tmp3 = NULL;
- subapp_x *tmp4 = NULL;
depth = xmlTextReaderDepth(reader);
while ((ret = __next_child_element(reader, depth))) {
}
if (!strcmp(ASCII(node), "operation")) {
- operation_x *operation = malloc(sizeof(operation_x));
- if (operation == NULL) {
- _LOGD("Malloc Failed\n");
- return -1;
- }
- memset(operation, '\0', sizeof(operation_x));
- LISTADD(appcontrol->operation, operation);
- ret = __ps_process_operation(reader, operation);
+ appcontrol->operation = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
_LOGD("operation processing\n");
} else if (!strcmp(ASCII(node), "uri")) {
- uri_x *uri= malloc(sizeof(uri_x));
- if (uri == NULL) {
- _LOGD("Malloc Failed\n");
- return -1;
- }
- memset(uri, '\0', sizeof(uri_x));
- LISTADD(appcontrol->uri, uri);
- ret = __ps_process_uri(reader, uri);
+ appcontrol->uri = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
_LOGD("uri processing\n");
} else if (!strcmp(ASCII(node), "mime")) {
- mime_x *mime = malloc(sizeof(mime_x));
- if (mime == NULL) {
- _LOGD("Malloc Failed\n");
- return -1;
- }
- memset(mime, '\0', sizeof(mime_x));
- LISTADD(appcontrol->mime, mime);
- ret = __ps_process_mime(reader, mime);
+ appcontrol->mime = ASCII(xmlTextReaderGetAttribute(reader, XMLCHAR("name")));
_LOGD("mime processing\n");
- } else if (!strcmp(ASCII(node), "subapp")) {
- subapp_x *subapp = malloc(sizeof(subapp_x));
- if (subapp == NULL) {
- _LOGD("Malloc Failed\n");
- return -1;
- }
- memset(subapp, '\0', sizeof(subapp_x));
- LISTADD(appcontrol->subapp, subapp);
- ret = __ps_process_subapp(reader, subapp);
- _LOGD("subapp processing\n");
} else
return -1;
if (ret < 0) {
return ret;
}
}
- if (appcontrol->operation) {
- LISTHEAD(appcontrol->operation, tmp1);
- appcontrol->operation = tmp1;
- }
- if (appcontrol->uri) {
- LISTHEAD(appcontrol->uri, tmp2);
- appcontrol->uri = tmp2;
- }
- if (appcontrol->mime) {
- LISTHEAD(appcontrol->mime, tmp3);
- appcontrol->mime = tmp3;
- }
- if (appcontrol->subapp) {
- LISTHEAD(appcontrol->subapp, tmp4);
- appcontrol->subapp = tmp4;
- }
-
- xmlTextReaderRead(reader);
- if (xmlTextReaderValue(reader))
- appcontrol->text = ASCII(xmlTextReaderValue(reader));
return ret;
}
uiapplication_x *up = mfx->uiapplication;
appcontrol_x *acontrol = NULL;
- operation_x *op = NULL;
- mime_x *mi = NULL;
- uri_x *ui = NULL;
- subapp_x *sub = NULL;
- const char *operation = NULL;
- const char *mime = NULL;
- const char *uri = NULL;
- const char *subapp = NULL;
- int i = 0;
-
acontrol = up->appcontrol;
while(acontrol != NULL) {
- op = acontrol->operation;
- while(op != NULL) {
- if (op)
- operation = op->name;
- mi = acontrol->mime;
-
- do
- {
- if (mi)
- mime = mi->name;
- sub = acontrol->subapp;
- do
- {
- if (sub)
- subapp = sub->name;
- ui = acontrol->uri;
- do
- {
- if (ui)
- uri = ui->name;
-
- if(i++ > 0) {
- strncpy(buftemp, buf, BUFMAX);
- snprintf(buf, BUFMAX, "%s;", buftemp);
- }
-
- strncpy(buftemp, buf, BUFMAX);
- snprintf(buf, BUFMAX, "%s%s|%s|%s|%s", buftemp, operation?operation:"NULL", uri?uri:"NULL", mime?mime:"NULL", subapp?subapp:"NULL");
- _LOGD("buf[%s]\n", buf);
-
- if (ui)
- ui = ui->next;
- uri = NULL;
- } while(ui != NULL);
- if (sub)
- sub = sub->next;
- subapp = NULL;
- }while(sub != NULL);
- if (mi)
- mi = mi->next;
- mime = NULL;
- }while(mi != NULL);
- if (op)
- op = op->next;
- operation = NULL;
- }
+ snprintf(buf, BUFMAX, "%s|%s|%s",
+ acontrol->operation ? acontrol->operation : "NULL",
+ acontrol->uri ? acontrol->uri : "NULL",
+ acontrol->mime ? acontrol->mime : "NULL");
+ _LOGD("buf[%s]\n", buf);
acontrol = acontrol->next;
}
-
fwrite(buf, 1, strlen(buf), file);
// strncpy(buftemp, buf, BUFMAX);
{
uiapplication_x *up = mfx->uiapplication;
appcontrol_x *acontrol = NULL;
- operation_x *op = NULL;
- mime_x *mi = NULL;
- uri_x *ui = NULL;
- subapp_x *sub = NULL;
int ret = -1;
char query[MAX_QUERY_LEN] = {'\0'};
char buf[BUFSIZE] = {'\0'};
- const char *operation = NULL;
- const char *mime = NULL;
- const char *uri = NULL;
- const char *subapp = NULL;
while (up != NULL) {
acontrol = up->appcontrol;
while (acontrol != NULL) {
- op = acontrol->operation;
- while (op != NULL) {
- if (op)
- operation = op->name;
- mi = acontrol->mime;
-
- do {
- if (mi)
- mime = mi->name;
- sub = acontrol->subapp;
- do {
- if (sub)
- subapp = sub->name;
- ui = acontrol->uri;
- do {
- if (ui)
- uri = ui->name;
- snprintf(buf, BUFSIZE, "%s|%s|%s|%s",
- operation ? operation : "NULL",
- uri ? uri : "NULL",
- mime ? mime : "NULL",
- subapp ? subapp : "NULL");
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_app_control(app_id, app_control) " \
- "values('%s', '%s')",\
- up->appid, buf);
- ret = __exec_query(query);
- if (ret == -1) {
- _LOGD("Package UiApp AppSvc DB Insert Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- if (ui)
- ui = ui->next;
- uri = NULL;
- } while (ui != NULL);
- if (sub)
- sub = sub->next;
- subapp = NULL;
- } while (sub != NULL);
- if (mi)
- mi = mi->next;
- mime = NULL;
- } while (mi != NULL);
- if (op)
- op = op->next;
- operation = NULL;
+ snprintf(buf, BUFSIZE, "%s|%s|%s",\
+ acontrol->operation ? acontrol->operation : "NULL",
+ acontrol->uri ? acontrol->uri : "NULL",
+ acontrol->mime ? acontrol->mime : "NULL");
+ snprintf(query, MAX_QUERY_LEN,
+ "insert into package_app_app_control(app_id, app_control) " \
+ "values('%s', '%s')",\
+ up->appid, buf);
+ ret = __exec_query(query);
+ if (ret == -1) {
+ _LOGD("Package UiApp AppSvc DB Insert Failed\n");
+ return -1;
}
+ memset(query, '\0', MAX_QUERY_LEN);
acontrol = acontrol->next;
}
up = up->next;
int ret = -1;
char query[MAX_QUERY_LEN] = {'\0'};
char buf[BUFSIZE] = {'\0'};
- operation_x *op = NULL;
- mime_x *mi = NULL;
- uri_x *ui = NULL;
- subapp_x *sub = NULL;
- const char *operation = NULL;
- const char *mime = NULL;
- const char *uri = NULL;
- const char *subapp = NULL;
while (sp != NULL) {
acontrol = sp->appcontrol;
while (acontrol != NULL) {
- op = acontrol->operation;
- while (op != NULL) {
- if (op)
- operation = op->name;
- mi = acontrol->mime;
- do {
- if (mi)
- mime = mi->name;
- sub = acontrol->subapp;
- do {
- if (sub)
- subapp = sub->name;
- ui = acontrol->uri;
- do {
- if (ui)
- uri = ui->name;
- snprintf(buf, BUFSIZE, "%s|%s|%s|%s",
- operation ? operation : "NULL",
- uri ? uri : "NULL",
- mime ? mime : "NULL",
- subapp ? subapp : "NULL");
- snprintf(query, MAX_QUERY_LEN,
- "insert into package_app_app_control(app_id, app_control) " \
- "values('%s', '%s')",\
- sp->appid, buf);
- ret = __exec_query(query);
- if (ret == -1) {
- _LOGD("Package UiApp AppSvc DB Insert Failed\n");
- return -1;
- }
- memset(query, '\0', MAX_QUERY_LEN);
- if (ui)
- ui = ui->next;
- uri = NULL;
- } while (ui != NULL);
- if (sub)
- sub = sub->next;
- subapp = NULL;
- } while (sub != NULL);
- if (mi)
- mi = mi->next;
- mime = NULL;
- } while (mi != NULL);
- if (op)
- op = op->next;
- operation = NULL;
+ snprintf(buf, BUFSIZE, "%s|%s|%s",
+ acontrol->operation ? acontrol->operation : "NULL",
+ acontrol->uri ? acontrol->uri : "NULL",
+ acontrol->mime ? acontrol->mime : "NULL");
+ snprintf(query, MAX_QUERY_LEN,
+ "insert into package_app_app_control(app_id, app_control) " \
+ "values('%s', '%s')",\
+ sp->appid, buf);
+ ret = __exec_query(query);
+ if (ret == -1) {
+ _LOGD("Package UiApp AppSvc DB Insert Failed\n");
+ return -1;
}
+ memset(query, '\0', MAX_QUERY_LEN);
acontrol = acontrol->next;
}
sp = sp->next;
return 0;
}
+static void __parse_appcontrol(appcontrol_x **appcontrol, char *appcontrol_str)
+{
+ char *dup;
+ char *token;
+ char *ptr;
+ appcontrol_x *ac;
+
+ if (appcontrol_str == NULL)
+ return;
+
+ dup = strdup(appcontrol_str);
+ do {
+ ac = calloc(1, sizeof(appcontrol_x));
+ token = strtok_r(dup, "|", &ptr);
+ if (strcmp(token, "NULL"))
+ ac->operation = strdup(token);
+ token = strtok_r(NULL, "|", &ptr);
+ if (strcmp(token, "NULL"))
+ ac->uri = strdup(token);
+ token = strtok_r(NULL, "|", &ptr);
+ if (strcmp(token, "NULL"))
+ ac->mime = strdup(token);
+ LISTADD(*appcontrol, ac);
+ } while (token = strtok_r(NULL, ";", &ptr));
+
+ free(dup);
+}
+
static int __appinfo_cb(void *data, int ncols, char **coltxt, char **colname)
{
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)data;
metadata_x *metadata = NULL;
permission_x *permission = NULL;
image_x *image = NULL;
+ appcontrol_x *appcontrol = NULL;
switch (info->app_component) {
case PMINFO_UI_APP:
info->uiapp_info->launch_mode = strdup(coltxt[i]);
else
info->uiapp_info->launch_mode = NULL;
+ } else if (strcmp(colname[i], "app_control") == 0 ) {
+ __parse_appcontrol(&info->uiapp_info->appcontrol, coltxt[i]);
} else
continue;
}
info->svcapp_info->permission_type = strdup(coltxt[i]);
else
info->svcapp_info->permission_type = NULL;
+ } else if (strcmp(colname[i], "app_control") == 0 ) {
+ __parse_appcontrol(&info->svcapp_info->appcontrol, coltxt[i]);
} else
continue;
}
metadata_x *ptr4 = NULL;
permission_x *ptr5 = NULL;
image_x *ptr6 = NULL;
+ appcontrol_x *ptr7 = NULL;
const char* user_pkg_parser = NULL;
/*get system locale*/
ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+ /*store app control info*/
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
+ memset(query, '\0', MAX_QUERY_LEN);
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->label, ptr2);
appinfo->uiapp_info->label = ptr2;
LISTHEAD(appinfo->uiapp_info->image, ptr6);
appinfo->uiapp_info->image = ptr6;
}
+ if (appinfo->uiapp_info->appcontrol) {
+ LISTHEAD(appinfo->uiapp_info->appcontrol, ptr7);
+ appinfo->uiapp_info->appcontrol = ptr7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->svcapp_info->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->label, ptr2);
appinfo->svcapp_info->label = ptr2;
LISTHEAD(appinfo->svcapp_info->permission, ptr5);
appinfo->svcapp_info->permission = ptr5;
}
+ if (appinfo->svcapp_info->appcontrol) {
+ LISTHEAD(appinfo->svcapp_info->appcontrol, ptr7);
+ appinfo->svcapp_info->appcontrol = ptr7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+ /*store app control info*/
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->label, ptr2);
appinfo->uiapp_info->label = ptr2;
LISTHEAD(appinfo->uiapp_info->image, ptr6);
appinfo->uiapp_info->image = ptr6;
}
+ if (appinfo->uiapp_info->appcontrol) {
+ LISTHEAD(appinfo->uiapp_info->appcontrol, ptr7);
+ appinfo->uiapp_info->appcontrol = ptr7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Localized Info DB Information retrieval failed");
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->svcapp_info->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->label, ptr2);
appinfo->svcapp_info->label = ptr2;
LISTHEAD(appinfo->svcapp_info->permission, ptr5);
appinfo->svcapp_info->permission = ptr5;
}
+ if (appinfo->svcapp_info->appcontrol) {
+ LISTHEAD(appinfo->svcapp_info->appcontrol, ptr7);
+ appinfo->svcapp_info->appcontrol = ptr7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
metadata_x *tmp4 = NULL;
permission_x *tmp5 = NULL;
image_x *tmp6 = NULL;
+ appcontrol_x *tmp7 = NULL;
const char *user_pkg_parser = NULL;
/*get system locale*/
snprintf(query, MAX_QUERY_LEN, "select * from package_app_icon_section_info where app_id='%s'", ptr1->appid);
ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App icon section Info DB Information retrieval failed");
-
+
/*store app preview image info*/
memset(query, '\0', MAX_QUERY_LEN);
snprintf(query, MAX_QUERY_LEN, "select app_image_section, app_image from package_app_image_info where app_id='%s'", ptr1->appid);
ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+ /*store app control info*/
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", ptr1->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->label, tmp1);
appinfo->uiapp_info->label = tmp1;
LISTHEAD(appinfo->uiapp_info->image, tmp6);
appinfo->uiapp_info->image = tmp6;
}
+ if (appinfo->uiapp_info->appcontrol) {
+ LISTHEAD(appinfo->uiapp_info->appcontrol, tmp7);
+ appinfo->uiapp_info->appcontrol = tmp7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App Info DB Information retrieval failed");
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", ptr2->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->label, tmp1);
appinfo->svcapp_info->label = tmp1;
LISTHEAD(appinfo->svcapp_info->permission, tmp5);
appinfo->svcapp_info->permission = tmp5;
}
+ if (appinfo->svcapp_info->appcontrol) {
+ LISTHEAD(appinfo->svcapp_info->appcontrol, tmp7);
+ appinfo->svcapp_info->appcontrol = tmp7;
+ }
ret = app_func((void *)appinfo, user_data);
if (ret < 0)
break;
metadata_x *tmp4 = NULL;
permission_x *tmp5 = NULL;
image_x *tmp6 = NULL;
+ appcontrol_x *tmp7 = NULL;
char query[MAX_QUERY_LEN] = {'\0'};
const char* user_pkg_parser = NULL;
ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App image Info DB Information retrieval failed");
+ /*store app control info*/
+ snprintf(query, MAX_QUERY_LEN, "select app_control from package_app_app_control where app_id='%s'", appinfo->uiapp_info->appid);
+ ret = __exec_db_query(GET_DB(manifest_db), query, __appinfo_cb, (void *)appinfo);
+ tryvm_if(ret == -1, ret = PMINFO_R_ERROR, "App control Info DB Information retrieval failed");
+
switch (appinfo->app_component) {
case PMINFO_UI_APP:
if (appinfo->uiapp_info->label) {
LISTHEAD(appinfo->uiapp_info->image, tmp6);
appinfo->uiapp_info->image = tmp6;
}
+ if (appinfo->uiapp_info->appcontrol) {
+ LISTHEAD(appinfo->uiapp_info->appcontrol, tmp7);
+ appinfo->uiapp_info->appcontrol = tmp7;
+ }
break;
case PMINFO_SVC_APP:
if (appinfo->svcapp_info->label) {
LISTHEAD(appinfo->svcapp_info->permission, tmp5);
appinfo->svcapp_info->permission = tmp5;
}
+ if (appinfo->svcapp_info->appcontrol) {
+ LISTHEAD(appinfo->svcapp_info->appcontrol, tmp7);
+ appinfo->svcapp_info->appcontrol = tmp7;
+ }
break;
default:
break;
return PMINFO_R_OK;
}
-API int pkgmgrinfo_usr_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data, uid_t uid)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
- int i = 0;
- int ret = -1;
- int oc = 0;
- int mc = 0;
- int uc = 0;
- int sc = 0;
- char *pkgid = NULL;
- char *manifest = NULL;
- char **operation = NULL;
- char **uri = NULL;
- char **mime = NULL;
- char **subapp = NULL;
- appcontrol_x *appcontrol = NULL;
- manifest_x *mfx = NULL;
- operation_x *op = NULL;
- uri_x *ui = NULL;
- mime_x *mi = NULL;
- subapp_x *sa = NULL;
- pkgmgrinfo_app_component component;
- pkgmgrinfo_appcontrol_x *ptr = NULL;
- ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
- if (ret < 0) {
- _LOGE("Failed to get package name\n");
- return PMINFO_R_ERROR;
- }
- ret = pkgmgrinfo_appinfo_get_component(handle, &component);
- if (ret < 0) {
- _LOGE("Failed to get app component name\n");
- return PMINFO_R_ERROR;
- }
- manifest = pkgmgr_parser_get_usr_manifest_file(pkgid, uid);
- if (manifest == NULL) {
- _LOGE("Failed to fetch package manifest file\n");
- return PMINFO_R_ERROR;
- }
- mfx = pkgmgr_parser_usr_process_manifest_xml(manifest, uid);
- if (mfx == NULL) {
- _LOGE("Failed to parse package manifest file\n");
- free(manifest);
- manifest = NULL;
- return PMINFO_R_ERROR;
- }
- free(manifest);
- ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
- if (ptr == NULL) {
- _LOGE("Out of Memory!!!\n");
- pkgmgr_parser_free_manifest_xml(mfx);
- return PMINFO_R_ERROR;
- }
- /*Get Operation, Uri, Mime*/
- switch (component) {
- case PMINFO_UI_APP:
- if (mfx->uiapplication) {
- if (mfx->uiapplication->appsvc) {
- appcontrol = mfx->uiapplication->appsvc;
- }
- }
- break;
- case PMINFO_SVC_APP:
- if (mfx->serviceapplication) {
- if (mfx->serviceapplication->appsvc) {
- appcontrol = mfx->serviceapplication->appsvc;
- }
- }
- break;
- default:
- break;
- }
- for (; appcontrol; appcontrol = appcontrol->next) {
- op = appcontrol->operation;
- for (; op; op = op->next)
- oc = oc + 1;
- op = appcontrol->operation;
-
- ui = appcontrol->uri;
- for (; ui; ui = ui->next)
- uc = uc + 1;
- ui = appcontrol->uri;
-
- mi = appcontrol->mime;
- for (; mi; mi = mi->next)
- mc = mc + 1;
- mi = appcontrol->mime;
-
- sa = appcontrol->subapp;
- for (; sa; sa = sa->next)
- sc = sc + 1;
- sa = appcontrol->subapp;
-
- operation = (char **)calloc(oc, sizeof(char *));
- for (i = 0; i < oc; i++) {
- operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
- op = op->next;
- }
-
- uri = (char **)calloc(uc, sizeof(char *));
- for (i = 0; i < uc; i++) {
- uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
- ui = ui->next;
- }
-
- mime = (char **)calloc(mc, sizeof(char *));
- for (i = 0; i < mc; i++) {
- mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
- mi = mi->next;
- }
-
- subapp = (char **)calloc(sc, sizeof(char *));
- for (i = 0; i < sc; i++) {
- subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
- sa = sa->next;
- }
-
- /*populate appcontrol handle*/
- ptr->operation_count = oc;
- ptr->uri_count = uc;
- ptr->mime_count = mc;
- ptr->subapp_count = sc;
- ptr->operation = operation;
- ptr->uri = uri;
- ptr->mime = mime;
- ptr->subapp = subapp;
-
- ret = appcontrol_func((void *)ptr, user_data);
- for (i = 0; i < oc; i++) {
- if (operation[i]) {
- free(operation[i]);
- operation[i] = NULL;
- }
- }
- if (operation) {
- free(operation);
- operation = NULL;
- }
- for (i = 0; i < uc; i++) {
- if (uri[i]) {
- free(uri[i]);
- uri[i] = NULL;
- }
- }
- if (uri) {
- free(uri);
- uri = NULL;
- }
- for (i = 0; i < mc; i++) {
- if (mime[i]) {
- free(mime[i]);
- mime[i] = NULL;
- }
- }
- if (mime) {
- free(mime);
- mime = NULL;
- }
- for (i = 0; i < sc; i++) {
- if (subapp[i]) {
- free(subapp[i]);
- subapp[i] = NULL;
- }
- }
- if (subapp) {
- free(subapp);
- subapp = NULL;
- }
- if (ret < 0)
- break;
- uc = 0;
- mc = 0;
- oc = 0;
- sc = 0;
- }
- pkgmgr_parser_free_manifest_xml(mfx);
- if (ptr) {
- free(ptr);
- ptr = NULL;
- }
- return PMINFO_R_OK;
-}
-
API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
pkgmgrinfo_app_control_list_cb 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 i = 0;
- int ret = -1;
- int oc = 0;
- int mc = 0;
- int uc = 0;
- int sc = 0;
- char *pkgid = NULL;
- char *manifest = NULL;
- char **operation = NULL;
- char **uri = NULL;
- char **mime = NULL;
- char **subapp = NULL;
- appcontrol_x *appcontrol = NULL;
- manifest_x *mfx = NULL;
- operation_x *op = NULL;
- uri_x *ui = NULL;
- mime_x *mi = NULL;
- subapp_x *sa = NULL;
+ int ret;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ appcontrol_x *appcontrol;
pkgmgrinfo_app_component component;
- pkgmgrinfo_appcontrol_x *ptr = NULL;
- ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
- if (ret < 0) {
- _LOGE("Failed to get package name\n");
- return PMINFO_R_ERROR;
- }
ret = pkgmgrinfo_appinfo_get_component(handle, &component);
if (ret < 0) {
_LOGE("Failed to get app component name\n");
return PMINFO_R_ERROR;
}
- manifest = pkgmgr_parser_get_manifest_file(pkgid);
- if (manifest == NULL) {
- _LOGE("Failed to fetch package manifest file\n");
- return PMINFO_R_ERROR;
- }
- mfx = pkgmgr_parser_process_manifest_xml(manifest);
- if (mfx == NULL) {
- _LOGE("Failed to parse package manifest file\n");
- free(manifest);
- manifest = NULL;
- return PMINFO_R_ERROR;
- }
- free(manifest);
- ptr = calloc(1, sizeof(pkgmgrinfo_appcontrol_x));
- if (ptr == NULL) {
- _LOGE("Out of Memory!!!\n");
- pkgmgr_parser_free_manifest_xml(mfx);
- return PMINFO_R_ERROR;
- }
- /*Get Operation, Uri, Mime*/
switch (component) {
case PMINFO_UI_APP:
- if (mfx->uiapplication) {
- if (mfx->uiapplication->appsvc) {
- appcontrol = mfx->uiapplication->appsvc;
- }
- }
+ if (info->uiapp_info == NULL)
+ return PMINFO_R_EINVAL;
+ appcontrol = info->uiapp_info->appcontrol;
break;
case PMINFO_SVC_APP:
- if (mfx->serviceapplication) {
- if (mfx->serviceapplication->appsvc) {
- appcontrol = mfx->serviceapplication->appsvc;
- }
- }
+ if (info->svcapp_info == NULL)
+ return PMINFO_R_EINVAL;
+ appcontrol = info->svcapp_info->appcontrol;
break;
default:
break;
}
for (; appcontrol; appcontrol = appcontrol->next) {
- op = appcontrol->operation;
- for (; op; op = op->next)
- oc = oc + 1;
- op = appcontrol->operation;
-
- ui = appcontrol->uri;
- for (; ui; ui = ui->next)
- uc = uc + 1;
- ui = appcontrol->uri;
-
- mi = appcontrol->mime;
- for (; mi; mi = mi->next)
- mc = mc + 1;
- mi = appcontrol->mime;
-
- sa = appcontrol->subapp;
- for (; sa; sa = sa->next)
- sc = sc + 1;
- sa = appcontrol->subapp;
-
- operation = (char **)calloc(oc, sizeof(char *));
- for (i = 0; i < oc; i++) {
- operation[i] = strndup(op->name, PKG_STRING_LEN_MAX - 1);
- op = op->next;
- }
-
- uri = (char **)calloc(uc, sizeof(char *));
- for (i = 0; i < uc; i++) {
- uri[i] = strndup(ui->name, PKG_STRING_LEN_MAX - 1);
- ui = ui->next;
- }
-
- mime = (char **)calloc(mc, sizeof(char *));
- for (i = 0; i < mc; i++) {
- mime[i] = strndup(mi->name, PKG_STRING_LEN_MAX - 1);
- mi = mi->next;
- }
-
- subapp = (char **)calloc(sc, sizeof(char *));
- for (i = 0; i < sc; i++) {
- subapp[i] = strndup(sa->name, PKG_STRING_LEN_MAX - 1);
- sa = sa->next;
- }
-
- /*populate appcontrol handle*/
- ptr->operation_count = oc;
- ptr->uri_count = uc;
- ptr->mime_count = mc;
- ptr->subapp_count = sc;
- ptr->operation = operation;
- ptr->uri = uri;
- ptr->mime = mime;
- ptr->subapp = subapp;
-
- ret = appcontrol_func((void *)ptr, user_data);
- for (i = 0; i < oc; i++) {
- if (operation[i]) {
- free(operation[i]);
- operation[i] = NULL;
- }
- }
- if (operation) {
- free(operation);
- operation = NULL;
- }
- for (i = 0; i < uc; i++) {
- if (uri[i]) {
- free(uri[i]);
- uri[i] = NULL;
- }
- }
- if (uri) {
- free(uri);
- uri = NULL;
- }
- for (i = 0; i < mc; i++) {
- if (mime[i]) {
- free(mime[i]);
- mime[i] = NULL;
- }
- }
- if (mime) {
- free(mime);
- mime = NULL;
- }
- for (i = 0; i < sc; i++) {
- if (subapp[i]) {
- free(subapp[i]);
- subapp[i] = NULL;
- }
- }
- if (subapp) {
- free(subapp);
- subapp = NULL;
- }
+ ret = appcontrol_func(appcontrol->operation, appcontrol->uri, appcontrol->mime, user_data);
if (ret < 0)
break;
- uc = 0;
- mc = 0;
- oc = 0;
- sc = 0;
- }
- pkgmgr_parser_free_manifest_xml(mfx);
- if (ptr) {
- free(ptr);
- ptr = NULL;
}
+
return PMINFO_R_OK;
}