update installed storage to pkgmgr db when pkg is moved tizen_2.1 2.1b_release accepted/tizen_2.1/20130425.035457 submit/tizen_2.1/20130424.230740
authorjunsuk77.oh <junsuk77.oh@samsung.com>
Tue, 9 Apr 2013 07:58:59 +0000 (16:58 +0900)
committerjunsuk77.oh <junsuk77.oh@samsung.com>
Tue, 9 Apr 2013 07:58:59 +0000 (16:58 +0900)
Change-Id: I752ebecdb2769699f310ab1487cbfd7947722845
Signed-off-by: junsuk77.oh <junsuk77.oh@samsung.com>
packaging/app2sd.spec
plugin/app2sd/CMakeLists.txt
plugin/app2sd/src/app2sd_interface.c

index 235d059..927b222 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       app2sd
 Summary:    Application installation on external memory
-Version:    0.5.12
+Version:    0.5.13
 Release:    1
 Group:      Application Framework/Application Installer
 License:    Apache-2.0
@@ -11,6 +11,7 @@ BuildRequires:  pkgconfig(vconf)
 BuildRequires:  pkgconfig(dlog)
 BuildRequires:  pkgconfig(openssl)
 BuildRequires:  pkgconfig(db-util)
+BuildRequires:   pkgconfig(pkgmgr-info)
 BuildRequires:  cmake
 
 %description
index 8533b08..4d3ca20 100755 (executable)
@@ -3,13 +3,13 @@ PROJECT(app2sd C)
 
 ### Required packages
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED libssl dlog openssl db-util)
+pkg_check_modules(pkgs REQUIRED libssl dlog openssl db-util pkgmgr-info)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
-pkg_check_modules(libpkgs REQUIRED libssl dlog openssl db-util)
+pkg_check_modules(libpkgs REQUIRED libssl dlog openssl db-util pkgmgr-info)
 
 FOREACH(flag ${libpkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 110eb0e..3d94ee0 100755 (executable)
@@ -26,6 +26,7 @@
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <pkgmgr-info.h>
 
 int app2sd_pre_app_install(const char *pkgid, GList* dir_list,
                                int size)
@@ -201,6 +202,26 @@ int app2sd_post_app_install(const char *pkgid,
                             buf_dir);
                }
 
+       } else {
+               /*If  the status is success, then update installed storage to pkgmgr_parser db*/
+               int rt = 0;
+               pkgmgrinfo_pkgdbinfo_h handle = NULL;
+               rt = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+               if (rt < 0) {
+                       app2ext_print("pkgmgrinfo_create_pkgdbinfo[%s] fail.. \n", pkgid);
+               }
+               rt = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_EXTERNAL);
+               if (rt < 0) {
+                       app2ext_print("fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_EXTERNAL);
+               }
+               rt =pkgmgrinfo_save_pkgdbinfo(handle);
+               if (rt < 0) {
+                       app2ext_print("pkgmgrinfo_save_pkgdbinfo[%s] failed\n", pkgid);
+               }
+               rt =pkgmgrinfo_destroy_pkgdbinfo(handle);
+               if (rt < 0) {
+                       app2ext_print("pkgmgrinfo_destroy_pkgdbinfo[%s] failed\n", pkgid);
+               }
        }
        return ret;
 }
@@ -479,6 +500,35 @@ int app2sd_move_installed_app(const char *pkgid, GList* dir_list,
                app2ext_print("App2Sd Error : Unable to move application\n");
                return ret;
        }
+
+       /*If  move is completed, then update installed storage to pkgmgr_parser db*/
+       int rt = 0;
+       pkgmgrinfo_pkgdbinfo_h handle = NULL;
+       rt = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
+       if (rt < 0) {
+               app2ext_print("App2Sd Error : pkgmgrinfo_create_pkgdbinfo[%s] fail.. \n", pkgid);
+       }
+
+       if (move_type == APP2EXT_MOVE_TO_EXT) {
+               rt = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_EXTERNAL);
+               if (rt < 0) {
+                       app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_EXTERNAL);
+               }
+       } else {
+               rt = pkgmgrinfo_set_installed_storage_to_pkgdbinfo(handle, INSTALL_INTERNAL);
+               if (rt < 0) {
+                       app2ext_print("App2Sd Error : fail to update installed location to db[%s, %s]\n", pkgid, INSTALL_INTERNAL);
+               }
+       }
+       rt =pkgmgrinfo_save_pkgdbinfo(handle);
+       if (rt < 0) {
+               app2ext_print("pkgmgrinfo_save_pkgdbinfo[%s] failed\n", pkgid);
+       }
+       rt =pkgmgrinfo_destroy_pkgdbinfo(handle);
+       if (rt < 0) {
+               app2ext_print("pkgmgrinfo_destroy_pkgdbinfo failed\n");
+       }
+
        return ret;
 }