Revert "Remove tep update API" 45/74045/3
authorTomasz Iwanek <t.iwanek@samsung.com>
Fri, 10 Jun 2016 12:23:27 +0000 (14:23 +0200)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Fri, 17 Jun 2016 04:03:12 +0000 (21:03 -0700)
This reverts commit 729210e8f340c0c2d899de09221e1dc08f34668b.

API will be used for move request where we need to update only
tep location and nothing more.

Change-Id: I933de75fad3db847db376d1d112be463985df9bd

parser/pkgmgr_parser.c
parser/pkgmgr_parser.h
parser/pkgmgr_parser_db.c

index 89adbc9..03066e6 100644 (file)
@@ -2024,6 +2024,16 @@ DEPRECATED API manifest_x *pkgmgr_parser_usr_process_manifest_xml(const char *ma
        return mfx;
 }
 
+API int pkgmgr_parser_usr_update_tep(const char *pkgid, const char *tep_path, uid_t uid)
+{
+       return pkgmgr_parser_update_tep_info_in_usr_db(pkgid, tep_path, uid);
+}
+
+API int pkgmgr_parser_update_tep(const char *pkgid, const char *tep_path)
+{
+       return pkgmgr_parser_update_tep_info_in_db(pkgid, tep_path);
+}
+
 DEPRECATED API int pkgmgr_parser_parse_manifest_for_installation(const char *manifest, char *const tagv[])
 {
        retvm_if(manifest == NULL, PMINFO_R_ERROR, "argument supplied is NULL");
index 4a5323f..c2d2ee4 100644 (file)
@@ -133,6 +133,37 @@ int pkgmgr_parser_process_manifest_x_for_installation(manifest_x* mfx, const cha
 int pkgmgr_parser_process_usr_manifest_x_for_installation(manifest_x* mfx, const char *manifest, uid_t uid);
 
 /**
+ * @fn int pkgmgr_parser_update_tep(const char* pkgid, const char * tep_path)
+ * @fn int pkgmgr_parser_usr_update_tep(const char* pkgid, const char* tep_path, uid_t uid)
+ * @brief      This API updates tep path information stored in DB.
+ *
+ * @par                This API is for package-manager installer backends.
+ * @par Sync (or) Async : Synchronous API
+ *
+ * @param[in]  pkgid   pointer to package ID
+  * @param[in]tep_path pointer to path of TEP file
+ * @param[in]  uid     the addressee user id of the instruction
+ * @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                None
+ * @post               None
+ * @code
+static int update_tep_info_for_upgrade(const char *pkgid, const char *tep_path)
+{
+       int ret = 0;
+       ret = pkgmgr_parser_update_tep(pkgid, tep_path);
+       if (ret)
+               return -1;
+       return 0;
+}
+ * @endcode
+ */
+int pkgmgr_parser_update_tep(const char* pkgid, const char* tep_path);
+int pkgmgr_parser_usr_update_tep(const char* pkgid, const char* tep_path, uid_t uid);
+
+/**
  * @fn int pkgmgr_parser_parse_usr_manifest_for_upgrade(const char *manifest,  uid_t uid, char *const tagv[])
  * @fn int pkgmgr_parser_parse_manifest_for_upgrade(const char *manifest, char *const tagv[])
  * @brief      This API parses the manifest file of the package after upgrade and stores the data in DB.
index 87bc1d9..f026826 100644 (file)
@@ -2773,6 +2773,86 @@ err:
        return ret;
 }
 
+API int pkgmgr_parser_update_tep_info_in_db(const char *pkgid, const char *tep_path)
+{
+       return pkgmgr_parser_update_tep_info_in_usr_db(pkgid, tep_path, _getuid());
+}
+
+API int pkgmgr_parser_update_tep_info_in_usr_db(const char *pkgid, const char *tep_path, uid_t uid)
+{
+       if (pkgid == NULL || tep_path == NULL) {
+               _LOGE("invalid parameter");
+               return -1;
+       }
+
+       int ret = -1;
+       char *query = NULL;
+
+       ret = pkgmgr_parser_check_and_create_db(uid);
+       if (ret == -1) {
+               _LOGD("Failed to open DB\n");
+               return ret;
+       }
+       ret = pkgmgr_parser_initialize_db(uid);
+       if (ret == -1)
+               goto err;
+
+       /*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");
+
+
+       /* Updating TEP info in "package_info" table */
+       query = sqlite3_mprintf("UPDATE package_info "\
+                                               "SET package_tep_name = %Q "\
+                                               "WHERE package = %Q", tep_path, pkgid);
+
+       ret = __exec_query(query);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               ret = PM_PARSER_R_ERROR;
+               _LOGE("sqlite exec failed to insert entries into package_info!!");
+               goto err;
+       }
+
+       /* Updating TEP info in "package_app_info" table */
+       query = sqlite3_mprintf("UPDATE package_app_info "\
+                                               "SET app_tep_name = %Q "\
+                                               "WHERE package = %Q", tep_path, pkgid);
+
+       ret = __exec_query(query);
+       sqlite3_free(query);
+       if (ret != SQLITE_OK) {
+               ret = PM_PARSER_R_ERROR;
+               _LOGE("sqlite exec failed to insert entries into package_app_info!!");
+               goto err;
+       }
+
+       /*Commit transaction*/
+       ret = sqlite3_exec(pkgmgr_parser_db, "COMMIT", NULL, NULL, NULL);
+       if (ret != SQLITE_OK) {
+               _LOGE("Failed to commit transaction, Rollback now\n");
+               ret = sqlite3_exec(pkgmgr_parser_db, "ROLLBACK", NULL, NULL, NULL);
+               if (ret != SQLITE_OK)
+                       _LOGE("Failed to Rollback\n");
+
+               ret = PM_PARSER_R_ERROR;
+               goto err;
+       }
+       _LOGD("Transaction Commit and End\n");
+       ret =  PM_PARSER_R_OK;
+
+err:
+       pkgmgr_parser_close_db();
+       return ret;
+}
+
+
 API int pkgmgr_parser_update_manifest_info_in_usr_db(manifest_x *mfx, uid_t uid)
 {
        if (mfx == NULL) {