Fix pkgmgr move API to get event callback 21/73621/3 accepted/tizen/common/20160613.144707 accepted/tizen/ivi/20160610.114457 accepted/tizen/mobile/20160610.114406 accepted/tizen/tv/20160610.114425 accepted/tizen/wearable/20160610.114443 submit/tizen/20160610.015635
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 9 Jun 2016 02:19:14 +0000 (11:19 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 10 Jun 2016 01:24:09 +0000 (10:24 +0900)
- move function should receive signal to retrieve
current progress of job requested
- remove mode argument from move api for compatibility previous tizen version.
(actually, mode argument is not used)

changed should be applied with pkgmgr-server
https://review.tizen.org/gerrit/#/c/73622/

Change-Id: I914835ba95cc240ebe3aed06cc3f6217edb926ca
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
client/include/package-manager.h
client/src/pkgmgr.c

index 5d0709b..2741d4a 100644 (file)
@@ -491,34 +491,19 @@ int pkgmgr_client_usr_uninstall(pkgmgr_client *pc, const char *pkg_type,
  * @param[in]  pkgid   application package id
  * @param[in]  move_type               PM_MOVE_TO_INTERNAL or PM_MOVE_TO_SDCARD
  * @param[in]  mode            installation mode  - PM_DEFAULT, PM_QUIET
+ * @param[in]  event_cb        user callback
+ * @param[in]  data    user data
  * @param[in]  uid     the addressee user id of the instruction
  * @retval     PKGMGR_R_OK     success
  * @retval     PKGMGR_R_EINVAL invalid argument
  * @retval     PKGMGR_R_ERROR  general error
 */
 int pkgmgr_client_move(pkgmgr_client *pc, const char *pkg_type,
-                               const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode);
-int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
-                               const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode, uid_t uid);
-/**
- * @brief      This API moves installed package to SD card or vice versa.
- *
- * This API is for package-manager client application.\n
- *
- * @param[in]  pc      pkgmgr_client
- * @param[in]  pkg_type                package type
- * @param[in]  pkgid   application package id
- * @param[in]  move_type               PM_MOVE_TO_INTERNAL or PM_MOVE_TO_SDCARD
- * @param[in]  mode            installation mode  - PM_DEFAULT, PM_QUIET
- * @param[in]  event_cb        user callback
- * @param[in]  data            user data
- * @retval     PKGMGR_R_OK     success
- * @retval     PKGMGR_R_EINVAL invalid argument
- * @retval     PKGMGR_R_ERROR  general error
-*/
-int pkgmgr_client_move_pkg(pkgmgr_client *pc, const char *pkg_type,
-                               const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode,
+                               const char *pkgid, pkgmgr_move_type move_type,
                                pkgmgr_handler event_cb, void *data);
+int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
+                               const char *pkgid, pkgmgr_move_type move_type,
+                               pkgmgr_handler event_cb, void *data, uid_t uid);
 
 /**
  * @brief      This API activates package.
index 2766244..958d7c4 100644 (file)
@@ -217,7 +217,7 @@ static void __error_to_string(int errnumber, char **errstr)
        }
 }
 
-static void __add_op_cbinfo(pkgmgr_client_t * pc, int request_id,
+static void __add_op_cbinfo(pkgmgr_client_t *pc, int request_id,
                            const char *req_key, pkgmgr_handler event_cb, void *new_event_cb,
                            void *data)
 {
@@ -251,7 +251,7 @@ static void __add_op_cbinfo(pkgmgr_client_t * pc, int request_id,
        }
 }
 
-static void __add_op_app_cbinfo(pkgmgr_client_t * pc, int request_id,
+static void __add_op_app_cbinfo(pkgmgr_client_t *pc, int request_id,
                            const char *req_key, pkgmgr_app_handler app_event_cb, void *data)
 {
        req_cb_info *cb_info;
@@ -394,7 +394,7 @@ static void __operation_callback(void *cb_data, uid_t target_uid,
        /* find callback info */
        cb_info = __find_op_cbinfo(pc, req_id);
        if (cb_info == NULL) {
-               ERR("cannot fint cb_info for req_id:%s", req_id);
+               ERR("cannot find cb_info for req_id:%s", req_id);
                return;
        }
 
@@ -723,7 +723,7 @@ static int __move_pkg_process(pkgmgr_client *pc, const char *pkgid,
 {
        int ret;
 
-       ret = pkgmgr_client_usr_move(pc, pkg_type, pkgid, move_type, 0, uid);
+       ret = pkgmgr_client_usr_move(pc, pkg_type, pkgid, move_type, event_cb, data, uid);
        if (ret < 0) {
                ERR("move request failed");
                return ret;
@@ -1449,17 +1449,20 @@ API int pkgmgr_client_usr_uninstall(pkgmgr_client *pc, const char *pkg_type,
 }
 
 API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkg_type,
-               const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode)
+               const char *pkgid, pkgmgr_move_type move_type,
+               pkgmgr_handler event_cb, void *data)
 {
-       return pkgmgr_client_usr_move(pc, pkg_type, pkgid, move_type, mode,
-                       _getuid());
+       return pkgmgr_client_usr_move(pc, pkg_type, pkgid, move_type,
+                       event_cb, data, _getuid());
 }
 API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
                const char *pkgid, pkgmgr_move_type move_type,
-               pkgmgr_mode mode, uid_t uid)
+               pkgmgr_handler event_cb, void *data, uid_t uid)
 {
        GVariant *result;
        int ret = PKGMGR_R_ECOMM;
+       int req_id;
+       char *req_key = NULL;
        pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc;
 
        if (pc == NULL || pkg_type == NULL || pkgid == NULL) {
@@ -1482,7 +1485,18 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
                return ret;
        }
 
-       g_variant_get(result, "(i)", &ret);
+       g_variant_get(result, "(i&s)", &ret, &req_key);
+       if (req_key == NULL) {
+               g_variant_unref(result);
+               return PKGMGR_R_ECOMM;
+       }
+       if (ret != PKGMGR_R_OK) {
+               g_variant_unref(result);
+               return ret;
+       }
+
+       req_id = _get_request_id();
+       __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
        g_variant_unref(result);
 
        return ret;