From: Junghyun Yeon Date: Thu, 9 Jun 2016 02:19:14 +0000 (+0900) Subject: Fix pkgmgr move API to get event callback X-Git-Tag: accepted/tizen/common/20160613.144707^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bbf9b6c8e4fde275d5a9e15dc5d902878054fa55;p=platform%2Fcore%2Fappfw%2Fslp-pkgmgr.git Fix pkgmgr move API to get event callback - 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 Signed-off-by: jongmyeongko --- diff --git a/client/include/package-manager.h b/client/include/package-manager.h index 5d0709b..2741d4a 100644 --- a/client/include/package-manager.h +++ b/client/include/package-manager.h @@ -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. diff --git a/client/src/pkgmgr.c b/client/src/pkgmgr.c index 2766244..958d7c4 100644 --- a/client/src/pkgmgr.c +++ b/client/src/pkgmgr.c @@ -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;