Set default operation for legacy splash screen
[platform/core/appfw/pkgmgr-info.git] / parser / pkgmgr_parser_db.c
index a95bcbe..c2b1477 100644 (file)
@@ -296,9 +296,9 @@ sqlite3 *pkgmgr_cert_db;
                                                "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)"
@@ -1679,11 +1679,13 @@ static int __insert_application_splashscreen_info(manifest_x *mfx)
                        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");
@@ -1706,7 +1708,7 @@ static int __insert_application_legacy_splashscreen_info(manifest_x *mfx)
        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) {
@@ -1792,9 +1794,9 @@ static int __insert_application_metadata_splashscreen_info(manifest_x *mfx)
                                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;
                        }
@@ -2412,6 +2414,7 @@ static int __enable_app_splash_screen(const char *appid)
 API int pkgmgr_parser_initialize_db(uid_t uid)
 {
        int ret = -1;
+       char *db_path;
 
        /*Manifest DB*/
        ret = __initialize_db(pkgmgr_parser_db, QUERY_CREATE_TABLE_PACKAGE_INFO);
@@ -2537,11 +2540,25 @@ API int pkgmgr_parser_initialize_db(uid_t uid)
                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;
 }
@@ -2627,21 +2644,38 @@ static int __parserdb_change_perm(const char *db_file, uid_t uid)
 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);
 
-       if (access(getUserPkgCertDBPathUID(uid), F_OK) != -1) {
+       db_path = getUserPkgCertDBPathUID(uid);
+       if (db_path == NULL) {
+               _LOGE("Failed to get pkg cert db path - %d", uid);
+               return -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)
@@ -2659,19 +2693,39 @@ API int pkgmgr_parser_create_and_initialize_db(uid_t uid)
 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;
 }