"type TEXT NOT NULL, " \
"orientation TEXT NOT NULL, " \
"indicatordisplay TEXT, " \
- "operation TEXT, " \
+ "operation TEXT NOT NULL, " \
"color_depth TEXT NOT NULL DEFAULT '24', " \
- "PRIMARY KEY(app_id, orientation) " \
+ "PRIMARY KEY(app_id, orientation, operation) " \
"FOREIGN KEY(app_id) " \
"REFERENCES package_app_info(app_id) " \
"ON DELETE CASCADE)"
#define QUERY_CREATE_TABLE_PACKAGE_CERT_INFO \
"CREATE TABLE IF NOT EXISTS package_cert_info( " \
" package TEXT PRIMARY KEY, " \
+ " package_count INTEGER, " \
" author_root_cert INTEGER, " \
" author_im_cert INTEGER, " \
" author_signer_cert INTEGER, " \
" dist2_im_cert INTEGER, " \
" dist2_signer_cert INTEGER)"
+#define QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO \
+ "CREATE TRIGGER IF NOT EXISTS update_cert_info " \
+ "AFTER UPDATE ON package_cert_info " \
+ "WHEN (NEW.package_count = 0) " \
+ "BEGIN" \
+ " DELETE FROM package_cert_info WHERE package=OLD.package;" \
+ "END;"
+
+#define QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO2 \
+ "CREATE TRIGGER IF NOT EXISTS update_cert_info2 " \
+ "AFTER UPDATE ON package_cert_info " \
+ "WHEN (NEW.package_count = OLD.package_count + 1) " \
+ "BEGIN" \
+ " UPDATE package_cert_index_info SET" \
+ " cert_ref_count = cert_ref_count - 1" \
+ " WHERE cert_id = OLD.author_root_cert" \
+ " OR cert_id = OLD.author_im_cert" \
+ " OR cert_id = OLD.author_signer_cert" \
+ " OR cert_id = OLD.dist_root_cert" \
+ " OR cert_id = OLD.dist_im_cert" \
+ " OR cert_id = OLD.dist_signer_cert" \
+ " OR cert_id = OLD.dist2_root_cert" \
+ " OR cert_id = OLD.dist2_im_cert" \
+ " OR cert_id = OLD.dist2_signer_cert;" \
+ "END;"
+
#define QUERY_CREATE_TRIGGER_DELETE_CERT_INFO \
"CREATE TRIGGER IF NOT EXISTS delete_cert_info " \
"AFTER DELETE ON package_cert_info " \
" DELETE FROM package_cert_index_info WHERE cert_id = OLD.cert_id;" \
"END;"
-#define QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO_FORMAT \
- "CREATE TRIGGER IF NOT EXISTS update_%s_info " \
- "AFTER UPDATE ON package_cert_info " \
- "WHEN (OLD.%s IS NOT NULL) " \
- "BEGIN" \
- " UPDATE package_cert_index_info SET" \
- " cert_ref_count = cert_ref_count - 1" \
- " WHERE cert_id = OLD.%s;" \
- "END;"
-
static int __insert_application_info(manifest_x *mfx);
static int __insert_application_appcategory_info(manifest_x *mfx);
static int __insert_application_appcontrol_info(manifest_x *mfx);
if (mfx->application == NULL)
return -1;
app = (application_x *)mfx->application->data;
- for(i = 0; i < ncols; i++)
- {
+ for (i = 0; i < ncols; i++) {
if (strcmp(colname[i], "app_id") == 0) {
if (coltxt[i])
appid = strdup(coltxt[i]);
}
}
if (appid == NULL) {
- if(status != NULL)
+ if (status != NULL)
free(status);
_LOGD("app id is NULL\n");
return -1;
return 0;
}
-static int __exec_query_no_msg(char *query)
-{
- char *error_message = NULL;
- if (SQLITE_OK !=
- sqlite3_exec(pkgmgr_parser_db, query, NULL, NULL, &error_message)) {
- sqlite3_free(error_message);
- return -1;
- }
- sqlite3_free(error_message);
- return 0;
-}
-
static GList *__create_locale_list(GList *locale, GList *lbls, GList *lcns, GList *icns, GList *dcns, GList *aths)
{
GList *tmp;
continue;
} else
prev = trim_data;
- }
- else
+ } else {
prev = trim_data;
+ }
}
list = g_list_next(list);
}
for (i = 0; i < 2; i++) {
snprintf(modified_iconpath, BUFSIZE - 1, "%s/%s%s", icon_path, dpi_path[i], icon_filename);
if (access(modified_iconpath, F_OK) != -1) {
- // if exists, return modified icon path
+ /* if exists, return modified icon path */
*new_icon_path = strdup(modified_iconpath);
return 0;
}
if (strcasecmp(icon->lang, lang) == 0) {
if (strcasecmp(icon->lang, DEFAULT_LOCALE) == 0) {
- //icon for no locale. check existance of folder-hierachied default icons
+ /* icon for no locale. check existance of folder-hierachied default icons */
if (__check_icon_folder(icon->text, &icon_folder_path) == 0) {
free(icon->text);
icon->text = icon_folder_path;
int dpi = 0;
int ret;
- // first, find icon whose locale and dpi with given lang and system's dpi has matched
+ /* first, find icon whose locale and dpi with given lang and system's dpi has matched */
tmp = g_list_find_custom(icons, lang, (GCompareFunc)__compare_icon_with_lang_dpi);
if (tmp != NULL) {
icon = (icon_x *)tmp->data;
return (char *)icon->text;
}
- // if first has failed, find icon whose locale has matched
+ /* if first has failed, find icon whose locale has matched */
tmp = g_list_find_custom(icons, lang, (GCompareFunc)__compare_icon_with_lang);
if (tmp != NULL) {
icon = (icon_x *)tmp->data;
return (char *)icon->text;
}
- // if second has failed, find icon whose dpi has matched with system's dpi
+ /* if second has failed, find icon whose dpi has matched with system's dpi */
ret = system_info_get_platform_int("http://tizen.org/feature/screen.dpi", &dpi);
if (ret == SYSTEM_INFO_ERROR_NONE) {
tmp = g_list_find_custom(icons, GINT_TO_POINTER(dpi), (GCompareFunc)__compare_icon_with_dpi);
}
}
- // last, find default icon marked as "No Locale"
+ /* last, find default icon marked as "No Locale" */
tmp = g_list_find_custom(icons, NULL, (GCompareFunc)__compare_icon);
if (tmp != NULL) {
icon = (icon_x *)tmp->data;
char *label = NULL;
char *icon = NULL;
char *query = NULL;
+ char *locale = (char *)data;
application_x *app = (application_x*)userdata;
GList *lbl = app->label;
sqlite3_free(query);
/*insert ui app locale info to pkg locale to get mainapp data */
- if (strcasecmp(app->mainapp, "true")==0) {
- query = sqlite3_mprintf("INSERT INTO package_localized_info(package, package_locale, " \
- "package_label, package_icon, package_description, package_license, package_author) VALUES" \
- "(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
- app->package,
- (char*)data,
- label,
- icon,
- NULL,
- NULL,
- NULL);
-
- ret = __exec_query_no_msg(query);
- sqlite3_free(query);
+ if (strcasecmp(app->mainapp, "true") == 0) {
+ query = sqlite3_mprintf("INSERT OR REPLACE INTO package_localized_info(package, package_locale, "
+ "package_label, package_icon, package_description, package_license, package_author) VALUES"
+ "(%Q, %Q, "
+ "COALESCE((SELECT package_label FROM package_localized_info WHERE package=%Q AND package_locale=%Q), %Q), "
+ "COALESCE((SELECT package_icon FROM package_localized_info WHERE package=%Q AND package_locale=%Q), %Q), "
+ "(SELECT package_description FROM package_localized_info WHERE package=%Q AND package_locale=%Q), "
+ "(SELECT package_license FROM package_localized_info WHERE package=%Q AND package_locale=%Q), "
+ "(SELECT package_author FROM package_localized_info WHERE package=%Q AND package_locale=%Q))",
+ app->package, locale,
+ app->package, locale, label,
+ app->package, locale, icon,
+ app->package, locale,
+ app->package, locale,
+ app->package, locale);
- if (icon != NULL) {
- query = sqlite3_mprintf("UPDATE package_localized_info SET package_icon=%Q "\
- "WHERE package=%Q AND package_locale=%Q", icon, app->package, (char*)data);
- ret = __exec_query_no_msg(query);
- sqlite3_free(query);
- }
+ ret = __exec_query(query);
+ if (ret == -1)
+ _LOGE("Package Localized Info DB Insert failed");
+ sqlite3_free(query);
}
}
_LOGD("Package App Info DB Insert Failed\n");
return -1;
}
- if (strcasecmp(app->mainapp, "True")==0)
+ if (strcasecmp(app->mainapp, "True") == 0)
mfx->mainapp_id = strdup(app->appid);
}
}
free((void *)app->mainapp);
- app->mainapp= strdup("true");
+ app->mainapp = strdup("true");
mfx->mainapp_id = strdup(app->appid);
}
while (tmp_list != NULL) {
category_data = (char *)tmp_list->data;
- if (strcmp(category_data, APP_BG_CATEGORY_MEDIA_STR) == 0) {
+ if (strcmp(category_data, APP_BG_CATEGORY_MEDIA_STR) == 0)
ret = ret | APP_BG_CATEGORY_MEDIA_VAL;
- } else if (strcmp(category_data, APP_BG_CATEGORY_DOWNLOAD_STR) == 0) {
+ else if (strcmp(category_data, APP_BG_CATEGORY_DOWNLOAD_STR) == 0)
ret = ret | APP_BG_CATEGORY_DOWNLOAD_VAL;
- } else if (strcmp(category_data, APP_BG_CATEGORY_BGNETWORK_STR) == 0) {
+ else if (strcmp(category_data, APP_BG_CATEGORY_BGNETWORK_STR) == 0)
ret = ret | APP_BG_CATEGORY_BGNETWORK_VAL;
- } else if (strcmp(category_data, APP_BG_CATEGORY_LOCATION_STR) == 0) {
+ else if (strcmp(category_data, APP_BG_CATEGORY_LOCATION_STR) == 0)
ret = ret | APP_BG_CATEGORY_LOCATION_VAL;
- } else if (strcmp(category_data, APP_BG_CATEGORY_SENSOR_STR) == 0) {
+ else if (strcmp(category_data, APP_BG_CATEGORY_SENSOR_STR) == 0)
ret = ret | APP_BG_CATEGORY_SENSOR_VAL;
- } else if (strcmp(category_data, APP_BG_CATEGORY_IOTCOMM_STR) == 0) {
+ else if (strcmp(category_data, APP_BG_CATEGORY_IOTCOMM_STR) == 0)
ret = ret | APP_BG_CATEGORY_IOTCOMM_VAL;
- } else if (strcmp(category_data, APP_BG_CATEGORY_SYSTEM) == 0) {
+ else if (strcmp(category_data, APP_BG_CATEGORY_SYSTEM) == 0)
ret = ret | APP_BG_CATEGORY_SYSTEM_VAL;
- } else {
+ else
_LOGE("Unidentified category [%s]", category_data);
- }
tmp_list = g_list_next(tmp_list);
}
ss = (splashscreen_x *)tmp->data;
sqlite3_snprintf(MAX_QUERY_LEN, query,
"INSERT INTO package_app_splash_screen" \
- "(app_id, src, type, orientation, indicatordisplay, operation, color_depth) " \
+ "(app_id, src, type, orientation, indicatordisplay, " \
+ "operation, color_depth) " \
"VALUES(%Q, %Q, %Q, %Q, %Q, %Q, %Q)",
app->appid, ss->src, ss->type, ss->orientation,
ss->indicatordisplay, ss->operation,
ss->color_depth);
+
ret = __exec_query(query);
if (ret == -1) {
_LOGD("Package UiApp Splash Screen DB Insert Failed");
const char *image_type;
const char *indicatordisplay;
const char *orientation;
- const char *operation = NULL;
+ const char *operation = "launch-effect";
const char *color_depth = "24"; /* default */
for (app_tmp = mfx->application; app_tmp; app_tmp = app_tmp->next) {
if (operation && operation[1] != '\0')
operation++;
else
- operation = NULL;
+ operation = "launch-effect";
} else if (strcasestr(md->key, "launch_effect")) {
- operation = NULL;
+ operation = "launch-effect";
} else {
continue;
}
return ret;
}
+static int __disable_pkg(const char *pkgid)
+{
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ sqlite3_snprintf(MAX_QUERY_LEN, query,
+ "UPDATE package_info SET package_disable='true' WHERE package=%Q",
+ pkgid);
+ ret = __exec_query(query);
+ if (ret == -1)
+ _LOGD("Update pkg disable info has failed\n");
+
+ return ret;
+}
+
+static int __enable_pkg(const char *pkgid)
+{
+ int ret = -1;
+ char query[MAX_QUERY_LEN] = {'\0'};
+ sqlite3_snprintf(MAX_QUERY_LEN, query,
+ "UPDATE package_info SET package_disable='false' WHERE package=%Q",
+ pkgid);
+ ret = __exec_query(query);
+ if (ret == -1)
+ _LOGD("Update pkg disable info has failed\n");
+
+ return ret;
+}
+
static int __check_appinfo_for_uid_table(const char *appid, uid_t uid)
{
int ret = -1;
API int pkgmgr_parser_initialize_db(uid_t uid)
{
int ret = -1;
- int i;
- char query[MAX_QUERY_LEN];
- static const char *columns[] = {
- "author_root_cert", "author_im_cert", "author_signer_cert",
- "dist_root_cert", "dist_im_cert", "dist_signer_cert",
- "dist2_root_cert", "dist2_im_cert", "dist2_signer_cert",
- NULL};
+ char *db_path;
/*Manifest DB*/
ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO);
_LOGD("package cert index info DB initialization failed\n");
return ret;
}
+ ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO);
+ if (ret == -1) {
+ _LOGD("package cert info DB initialization failed\n");
+ return ret;
+ }
+ ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO2);
+ if (ret == -1) {
+ _LOGD("package cert info DB initialization failed\n");
+ return ret;
+ }
ret = __initialize_db(pkgmgr_cert_db, QUERY_CREATE_TRIGGER_DELETE_CERT_INFO);
if (ret == -1) {
_LOGD("package cert info DB initialization failed\n");
_LOGD("package cert index info DB initialization failed\n");
return ret;
}
- for (i = 0; columns[i] != NULL; i++) {
- snprintf(query, sizeof(query),
- QUERY_CREATE_TRIGGER_UPDATE_CERT_INFO_FORMAT,
- columns[i], columns[i], columns[i]);
- ret = __initialize_db(pkgmgr_cert_db, query);
- if (ret == -1) {
- _LOGD("package cert index info DB initialization failed\n");
- return ret;
- }
- }
- if( 0 != __parserdb_change_perm(getUserPkgCertDBPathUID(GLOBAL_USER), GLOBAL_USER)) {
- _LOGD("Failed to change cert db permission\n");
+ db_path = getUserPkgCertDBPathUID(GLOBAL_USER);
+ if (db_path == NULL) {
+ _LOGD("Failed to get user cert db path - GLOBAL_USER");
+ } else {
+ ret = __parserdb_change_perm(db_path, GLOBAL_USER);
+ if (ret != 0)
+ _LOGD("Failed to change cert db permission");
+ free(db_path);
}
- if( 0 != __parserdb_change_perm(getUserPkgParserDBPathUID(uid), uid)) {
- _LOGD("Failed to change parser db permission\n");
+
+ db_path = getUserPkgParserDBPathUID(uid);
+ if (db_path == NULL) {
+ _LOGD("Failed to get user pkg parser db path - %d", uid);
+ } else {
+ ret = __parserdb_change_perm(db_path, uid);
+ if (ret != 0)
+ _LOGD("Failed to change parser db permission\n");
+ free(db_path);
}
return 0;
if (db_file == NULL)
return -1;
- if (getuid() != OWNER_ROOT) //At this time we should be root to apply this
+ if (getuid() != OWNER_ROOT) /* At this time we should be root to apply this */
return 0;
snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
if (uid == OWNER_ROOT)
API int pkgmgr_parser_create_and_initialize_db(uid_t uid)
{
int ret;
+ char *db_path;
if (getuid() != OWNER_ROOT) {
_LOGE("Only root user is allowed");
return -1;
}
- if (access(getUserPkgParserDBPathUID(uid), F_OK) != -1) {
+ db_path = getUserPkgParserDBPathUID(uid);
+ if (db_path == NULL) {
+ _LOGE("Failed to get pkg parser db path - %d", uid);
+ return -1;
+ }
+
+ if (access(db_path, F_OK) != -1) {
_LOGE("Manifest db for user %d is already exists", uid);
+ free(db_path);
+ return -1;
+ }
+ free(db_path);
+
+ db_path = getUserPkgCertDBPathUID(uid);
+ if (db_path == NULL) {
+ _LOGE("Failed to get pkg cert db path - %d", uid);
return -1;
}
- if (access(getUserPkgCertDBPathUID(uid), F_OK) != -1) {
+ if (access(db_path, F_OK) != -1) {
_LOGE("Cert db for user %d is already exists", uid);
+ free(db_path);
return -1;
}
+ free(db_path);
ret = pkgmgr_parser_check_and_create_db(uid);
if (ret < 0)
API int pkgmgr_parser_check_and_create_db(uid_t uid)
{
int ret = -1;
+ char *db_path;
+
+ db_path = getUserPkgParserDBPathUID(uid);
+ if (db_path == NULL) {
+ _LOGD("Failed to get pkg parser db path - %d", uid);
+ return -1;
+ }
+
/*Manifest DB*/
- ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, getUserPkgParserDBPathUID(uid));
+ ret = __pkgmgr_parser_create_db(&pkgmgr_parser_db, db_path);
if (ret) {
_LOGD("Manifest DB creation Failed\n");
+ free(db_path);
+ return -1;
+ }
+ free(db_path);
+
+ db_path = getUserPkgCertDBPathUID(GLOBAL_USER);
+ if (db_path == NULL) {
+ _LOGE("Failed to get pkg cert db path - GLOBAL_USER");
return -1;
}
/*Cert DB*/
- ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, getUserPkgCertDBPathUID(GLOBAL_USER));
+ ret = __pkgmgr_parser_create_db(&pkgmgr_cert_db, db_path);
if (ret) {
_LOGD("Cert DB creation Failed\n");
+ free(db_path);
return -1;
}
+
+ free(db_path);
+
return 0;
}
if (ret == -1)
goto err;
/*Preserve guest mode visibility*/
- __preserve_guestmode_visibility_value( mfx);
+ __preserve_guestmode_visibility_value(mfx);
/*Begin transaction*/
ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
if (ret != SQLITE_OK) {
return pkgmgr_parser_update_app_disable_info_in_usr_db(appid, _getuid(), is_disable);
}
+API int pkgmgr_parser_update_pkg_disable_info_in_usr_db(const char *pkgid, uid_t uid, int is_disable)
+{
+ int ret = -1;
+
+ ret = pkgmgr_parser_check_and_create_db(uid);
+ if (ret == -1) {
+ _LOGD("Failed to open DB\n");
+ return ret;
+ }
+
+ /*Begin transaction*/
+ ret = sqlite3_exec(pkgmgr_parser_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGD("Failed to begin transaction\n");
+ ret = -1;
+ goto err;
+ }
+
+ _LOGD("Transaction Begin\n");
+ if (is_disable)
+ ret = __disable_pkg(pkgid);
+ else
+ ret = __enable_pkg(pkgid);
+
+ if (ret == -1) {
+ _LOGD("__update_pkg_disable_condition_in_db failed. Rollback now\n");
+ sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
+ goto err;
+ }
+
+ /*Commit transaction*/
+ ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
+ if (ret != SQLITE_OK) {
+ _LOGD("Failed to commit transaction, Rollback now\n");
+ sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
+ ret = -1;
+ goto err;
+ }
+ _LOGD("Transaction Commit and End\n");
+
+err:
+ pkgmgr_parser_close_db();
+ return ret;
+}
+
+API int pkgmgr_parser_update_pkg_disable_info_in_db(const char *pkgid, int is_disable)
+{
+ return pkgmgr_parser_update_pkg_disable_info_in_usr_db(pkgid, _getuid(), is_disable);
+}
+
API int pkgmgr_parser_update_app_disable_info_in_usr_db(const char *appid, uid_t uid, int is_disable)
{
int ret = -1;