} pkgmgr_appinfo_x;
typedef struct _pkgmgr_certinfo_x {
+ int for_all_users;
char *pkgid;
char *cert_value;
char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
static const char *_get_db_path(uid_t uid) {
const char *db_path = NULL;
- if (uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
tzplatform_set_user(uid);
db_path = tzplatform_getenv(TZ_USER_DB);
tzplatform_reset_user();
char *err;
char query[MAX_QUERY_LEN];
- if (uid == GLOBAL_USER)
+ if (uid == GLOBAL_USER || uid == ROOT_UID)
return SQLITE_OK;
snprintf(query, sizeof(query), "ATTACH DATABASE '%s' AS Global", db);
uid_t uid_caller = getuid();
gid_t gid = ROOT_UID;
- if (uid == ROOT_UID) {
- _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
-
- if (uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
tzplatform_set_user(uid);
path = tzplatform_mkpath(TZ_USER_ICONS, "/");
gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
uid_t uid_caller = getuid();
gid_t gid = ROOT_UID;
- if (uid == ROOT_UID) {
- _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
-
- if (uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
tzplatform_set_user(uid);
pkgmgr_parser_db = tzplatform_mkpath(TZ_USER_DB, ".pkgmgr_parser.db");
gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
uid_t uid_caller = getuid();
gid_t gid = ROOT_UID;
- if (uid == ROOT_UID) {
- _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
-
- if (uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
tzplatform_set_user(uid);
pkgmgr_cert_db = tzplatform_mkpath(TZ_USER_DB, ".pkgmgr_cert.db");
gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
uid_t uid_caller = getuid();
gid_t gid = ROOT_UID;
- if (uid == ROOT_UID) {
- _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
-
- if (uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
tzplatform_set_user(uid);
path = tzplatform_mkpath(TZ_USER_DESKTOP, "/");
gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
uid_t uid_caller = getuid();
gid_t gid = ROOT_UID;
- if (uid == ROOT_UID) {
- _LOGE("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
-
- if (uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER && uid != ROOT_UID) {
tzplatform_set_user(uid);
path = tzplatform_mkpath(TZ_USER_PACKAGES, "/");
gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
info->cert_value = strdup(coltxt[i]);
else
info->cert_value = NULL;
+ } else if (strcmp(colname[i], "for_all_users") == 0 ){
+ if (coltxt[i])
+ info->for_all_users = atoi(coltxt[i]);
+ else
+ info->for_all_users = 0;
} else
continue;
}
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;
}
int ret = PMINFO_R_OK;
char query[MAX_QUERY_LEN] = {'\0'};
char *error_message = NULL;
- pkgmgr_cert_x *info= NULL;
+ sqlite3_stmt *stmt = NULL;
+ char *lhs_certinfo = NULL;
+ char *rhs_certinfo = NULL;
int lcert = 0;
int rcert = 0;
int exist = -1;
+ int i;
+ int is_global = 0;
*compare_result = PMINFO_CERT_COMPARE_ERROR;
- info = (pkgmgr_cert_x *)calloc(1, sizeof(pkgmgr_cert_x));
- retvm_if(info == NULL, PMINFO_R_ERROR, "Out of Memory!!!");
ret = __open_cert_db(uid, "r");
if (ret != 0) {
ret = PMINFO_R_ERROR;
goto err;
}
-
- if (exist == 0) {
- lcert = 0;
- } else {
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", lhs_package_id);
- if (SQLITE_OK !=
- sqlite3_exec(GET_DB(cert_db), query, __cert_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
- ret = PMINFO_R_ERROR;
- goto err;
- }
- lcert = info->cert_id;
- }
+ lcert = exist;
snprintf(query, MAX_QUERY_LEN, "select exists(select * from package_cert_info where package='%s')", rhs_package_id);
if (SQLITE_OK !=
ret = PMINFO_R_ERROR;
goto err;
}
+ rcert = exist;
- if (exist == 0) {
- rcert = 0;
- } else {
- snprintf(query, MAX_QUERY_LEN, "select author_signer_cert from package_cert_info where package='%s'", rhs_package_id);
- if (SQLITE_OK !=
- sqlite3_exec(GET_DB(cert_db), query, __cert_cb, (void *)info, &error_message)) {
- _LOGE("Don't execute query = %s error message = %s\n", query,
- error_message);
+ if (uid == GLOBAL_USER || uid == ROOT_UID) {
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=(select author_signer_cert from package_cert_info where package=?)");
+ is_global = 1;
+ } else
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=(select author_signer_cert from package_cert_info where package=?) and for_all_users=(select for_all_users from package_cert_info where package=?)");
+ if (SQLITE_OK != sqlite3_prepare_v2(GET_DB(cert_db), query, strlen(query), &stmt, NULL)) {
+ _LOGE("sqlite3_prepare_v2 error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+
+ for (i = 1; i <= 2 - is_global; i++) {
+ if (SQLITE_OK != sqlite3_bind_text(stmt, i, lhs_package_id, -1, SQLITE_STATIC)) {
+ _LOGE("sqlite3_bind_text error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+ }
+ if (SQLITE_ROW != sqlite3_step(stmt) || sqlite3_column_text(stmt, 0) == NULL) {
+ _LOGE("sqlite3_step error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+ ret = PMINFO_R_ERROR;
+ goto err;
+ }
+
+ lhs_certinfo = strdup((const char *)sqlite3_column_text(stmt, 0));
+ sqlite3_reset(stmt);
+ sqlite3_clear_bindings(stmt);
+
+ for (i = 1; i <= 2 - is_global; i++) {
+ if (SQLITE_OK != sqlite3_bind_text(stmt, i, rhs_package_id, -1, SQLITE_STATIC)) {
+ _LOGE("sqlite3_bind_text error: %s", sqlite3_errmsg(GET_DB(cert_db)));
ret = PMINFO_R_ERROR;
goto err;
}
- rcert = info->cert_id;
+ }
+ if (SQLITE_ROW != sqlite3_step(stmt) || sqlite3_column_text(stmt, 0) == NULL) {
+ _LOGE("sqlite3_step error: %s", sqlite3_errmsg(GET_DB(cert_db)));
+ ret = PMINFO_R_ERROR;
+ goto err;
}
+ rhs_certinfo = strdup((const char *)sqlite3_column_text(stmt, 0));
+
if ((lcert == 0) || (rcert == 0))
{
if ((lcert == 0) && (rcert == 0))
else if (rcert == 0)
*compare_result = PMINFO_CERT_COMPARE_RHS_NO_CERT;
} else {
- if (lcert == rcert)
+ if (!strcmp(lhs_certinfo, rhs_certinfo))
*compare_result = PMINFO_CERT_COMPARE_MATCH;
else
*compare_result = PMINFO_CERT_COMPARE_MISMATCH;
}
err:
+ if (stmt)
+ sqlite3_finalize(stmt);
+ if (lhs_certinfo)
+ free(lhs_certinfo);
+ if (rhs_certinfo)
+ free(rhs_certinfo);
sqlite3_free(error_message);
__close_cert_db();
- if (info) {
- if (info->pkgid) {
- free(info->pkgid);
- info->pkgid = NULL;
- }
- free(info);
- info = NULL;
- }
+
return ret;
}
where[sizeof(where) - 1] = '\0';
}
}
- _LOGE("where = %s\n", where);
if (strlen(where) > 0) {
strncat(query, where, sizeof(query) - strlen(query) - 1);
query[sizeof(query) - 1] = '\0';
}
- _LOGE("query = %s\n", query);
/*Execute Query*/
if (SQLITE_OK !=
where[sizeof(where) - 1] = '\0';
}
}
- _LOGE("where = %s\n", where);
if (strlen(where) > 0) {
strncat(query, where, sizeof(query) - strlen(query) - 1);
query[sizeof(query) - 1] = '\0';
}
- _LOGE("query = %s\n", query);
tmphead = calloc(1, sizeof(pkgmgr_pkginfo_x));
if (tmphead == NULL) {
_LOGE("Out of Memory!!!\n");
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;
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
retvm_if(mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- if (info->uiapp_info->launch_mode)
- *mode = (char *)(info->uiapp_info->launch_mode);
- else
+
+ if (info->app_component != PMINFO_UI_APP)
+ return PMINFO_R_EINVAL;
+
+ if (info->uiapp_info->launch_mode == NULL)
return PMINFO_R_ERROR;
+ *mode = (char *)(info->uiapp_info->launch_mode);
+
return PMINFO_R_OK;
}
return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(providerid, GLOBAL_USER, appid);
}
-#define OPERATION_LAUNCH_ON_EVENT "http://tizen.org/appcontrol/operation/launch_on_event"
-
-API int pkgmgrinfo_appinfo_get_event_launch_list(GList **es_info)
-{
- pkgmgrinfo_appinfo_get_usr_event_launch_list(es_info, GLOBAL_USER);
-}
-
-API int pkgmgrinfo_appinfo_get_usr_event_launch_list(GList **es_info, uid_t uid)
-{
- int ret = PMINFO_R_OK;
- char *query = NULL;
- sqlite3_stmt *stmt = NULL;
- const char* user_pkg_parser = NULL;
-
- /*open db*/
- user_pkg_parser = getUserPkgParserDBPathUID(uid);
- ret = __open_manifest_db(uid);
- retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR,
- "connect db [%s] failed!", user_pkg_parser);
-
- /*Start constructing query*/
- query = sqlite3_mprintf("select * from package_app_app_control");
-
- /*prepare query*/
- ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
- tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR,
- "sqlite3_prepare_v2 failed[%s] : %s\n", query, sqlite3_errmsg(GET_DB(manifest_db)));
-
- /*step query*/
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- char *app_ctrl;
- app_ctrl = (char *)sqlite3_column_text(stmt, 1);
- if (app_ctrl == NULL) {
- continue;
- }
-
- gchar **appctrlv;
- int len_acv, cnt_acv;
- appctrlv = g_strsplit(app_ctrl, ";", 0);
- for (len_acv = 0; appctrlv[len_acv] != NULL; len_acv++);
- for (cnt_acv = 0; cnt_acv < len_acv; cnt_acv++) {
- if (strncmp(OPERATION_LAUNCH_ON_EVENT,
- (char *)appctrlv[cnt_acv],
- strlen(OPERATION_LAUNCH_ON_EVENT)) != 0) {
- continue;
- }
-
- gchar **launch_onevt;
- int len_lo;
- launch_onevt = g_strsplit(appctrlv[cnt_acv], "|", 3);
- for (len_lo = 0; launch_onevt[len_lo] != NULL; len_lo++);
- if (len_lo > 2 && g_str_has_prefix(launch_onevt[1], "event://") &&
- strlen(launch_onevt[1]) > 8) {
- eventsystem_info_s *esi =
- (eventsystem_info_s *)calloc(1,
- sizeof(eventsystem_info_s));
- esi->appid =
- strdup((const char *)sqlite3_column_text(stmt, 0));
- esi->event_name = strdup((const char*)&launch_onevt[1][8]);
- *es_info = g_list_append(*es_info, esi);
- }
- g_strfreev(launch_onevt);
- }
- g_strfreev(appctrlv);
- }
-
- ret = PMINFO_R_OK;
-catch:
- sqlite3_free(query);
- sqlite3_finalize(stmt);
- __close_manifest_db();
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_event_launch_list_by_appid(const char *appid, GList **es_info)
-{
- pkgmgrinfo_appinfo_get_usr_event_launch_list_by_appid(appid,
- es_info, GLOBAL_USER);
-}
-
-API int pkgmgrinfo_appinfo_get_usr_event_launch_list_by_appid(const char *appid, GList **es_info, uid_t uid)
-{
- int ret = PMINFO_R_OK;
- char *query = NULL;
- sqlite3_stmt *stmt = NULL;
- const char* user_pkg_parser = NULL;
-
- /*open db*/
- user_pkg_parser = getUserPkgParserDBPathUID(uid);
- ret = __open_manifest_db(uid);
- retvm_if(ret != SQLITE_OK, ret = PMINFO_R_ERROR,
- "connect db [%s] failed!", user_pkg_parser);
-
- /*Start constructing query*/
- query = sqlite3_mprintf("select * from package_app_app_control where app_id=%Q",
- appid);
-
- /*prepare query*/
- ret = sqlite3_prepare_v2(GET_DB(manifest_db), query, strlen(query), &stmt, NULL);
- tryvm_if(ret != PMINFO_R_OK, ret = PMINFO_R_ERROR,
- "sqlite3_prepare_v2 failed[%s] : %s\n", query, sqlite3_errmsg(GET_DB(manifest_db)));
-
- /*step query*/
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- char *app_ctrl;
- app_ctrl = (char *)sqlite3_column_text(stmt, 1);
- if (app_ctrl == NULL) {
- continue;
- }
-
- gchar **appctrlv;
- int len_acv, cnt_acv;
- appctrlv = g_strsplit(app_ctrl, ";", 0);
- for (len_acv = 0; appctrlv[len_acv] != NULL; len_acv++);
- for (cnt_acv = 0; cnt_acv < len_acv; cnt_acv++) {
- if (strncmp(OPERATION_LAUNCH_ON_EVENT,
- (char *)appctrlv[cnt_acv],
- strlen(OPERATION_LAUNCH_ON_EVENT)) != 0) {
- continue;
- }
-
- gchar **launch_onevt;
- int len_lo;
- launch_onevt = g_strsplit(appctrlv[cnt_acv], "|", 3);
- for (len_lo = 0; launch_onevt[len_lo] != NULL; len_lo++);
- if (len_lo > 2 && g_str_has_prefix(launch_onevt[1], "event://") &&
- strlen(launch_onevt[1]) > 8) {
- eventsystem_info_s *esi =
- (eventsystem_info_s *)calloc(1,
- sizeof(eventsystem_info_s));
- esi->appid = strdup(appid);
- esi->event_name = strdup((const char*)&launch_onevt[1][8]);
- *es_info = g_list_append(*es_info, esi);
- }
- g_strfreev(launch_onevt);
- }
- g_strfreev(appctrlv);
- }
-
- ret = PMINFO_R_OK;
-catch:
- sqlite3_free(query);
- sqlite3_finalize(stmt);
- __close_manifest_db();
- return ret;
-}
-
API int pkgmgrinfo_appinfo_foreach_permission(pkgmgrinfo_appinfo_h handle,
pkgmgrinfo_app_permission_list_cb permission_func, void *user_data)
{
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;
}
where[sizeof(where) - 1] = '\0';
}
}
- _LOGE("where = %s\n", where);
if (strlen(where) > 0) {
strncat(query, where, sizeof(query) - strlen(query) - 1);
query[sizeof(query) - 1] = '\0';
}
- _LOGE("query = %s\n", query);
/*Execute Query*/
if (SQLITE_OK !=
where[sizeof(where) - 1] = '\0';
}
}
- _LOGE("where = %s\n", where);
if (strlen(where) > 0) {
strncat(query, where, sizeof(query) - strlen(query) - 1);
query[sizeof(query) - 1] = '\0';
}
- _LOGE("query = %s\n", query);
/*To get filtered list*/
pkgmgr_pkginfo_x *info = NULL;
pkgmgr_pkginfo_x *filtinfo = NULL;
/*If the callback func return < 0 we break and no more call back is called*/
while(ptr1 != NULL)
{
+ appinfo->package = strdup(ptr1->package);
appinfo->locale = strdup(locale);
appinfo->uiapp_info = ptr1;
appinfo->app_component = PMINFO_UI_APP;
/*If the callback func return < 0 we break and no more call back is called*/
while(ptr2 != NULL)
{
+ appinfo->package = strdup(ptr2->package);
appinfo->locale = strdup(locale);
appinfo->svcapp_info = ptr2;
appinfo->app_component = PMINFO_SVC_APP;
strncat(where, METADATA_FILTER_QUERY_UNION_CLAUSE, sizeof(where) - strlen(where) - 1);
}
}
- _LOGE("where = %s (%d)\n", where, strlen(where));
if (strlen(where) > 0) {
strncat(query, where, sizeof(query) - strlen(query) - 1);
}
- _LOGE("query = %s (%d)\n", query, strlen(query));
/*To get filtered list*/
info = (pkgmgr_pkginfo_x *)calloc(1, sizeof(pkgmgr_pkginfo_x));
tryvm_if(info == NULL, ret = PMINFO_R_ERROR, "Out of Memory!!!\n");
}
for (i = 0; i < MAX_CERT_TYPE; i++) {
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
+ if (uid == GLOBAL_USER || uid == ROOT_UID)
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d", (certinfo->cert_id)[i]);
+ else
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d and for_all_users=%d", (certinfo->cert_id)[i], certinfo->for_all_users);
ret = __exec_certinfo_query(query, (void *)certinfo);
if (ret == -1) {
_LOGE("Cert Info DB Information retrieval failed\n");
retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
char *val = NULL;
int ret = 0;
- char *noti_string = NULL;
int len = 0;
char query[MAX_QUERY_LEN] = {'\0'};
char *errmsg = NULL;
else
snprintf(query, MAX_QUERY_LEN, "update package_app_info set app_guestmodevisibility = 'false' where app_id = '%s'", (char *)info->uiapp_info->appid);
- if (SQLITE_OK != sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg)) {
+ ret = sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &errmsg);
+ sqlite3_close(pkgmgr_parser_db);
+ if (ret != SQLITE_OK) {
_LOGE("DB update [%s] failed, error message = %s\n", query, errmsg);
free(errmsg);
- sqlite3_close(pkgmgr_parser_db);
- return PMINFO_R_ERROR;
- }else{
- sqlite3_close(pkgmgr_parser_db);
- len = strlen((char *)info->uiapp_info->appid) + 8;
- noti_string = calloc(1, len);
- if (noti_string == NULL){
- return PMINFO_R_ERROR;
- }
- snprintf(noti_string, len, "update:%s", (char *)info->uiapp_info->appid);
- vconf_set_str(VCONFKEY_AIL_INFO_STATE, noti_string);
- vconf_set_str(VCONFKEY_MENUSCREEN_DESKTOP, noti_string); // duplicate, will be removed
- free(noti_string);
+ return PMINFO_R_ERROR;
}
}
return PMINFO_R_OK;