Add client functions for pkg update info 42/128042/2 accepted/tizen/3.0/common/20170605.123902 accepted/tizen/3.0/ivi/20170605.014948 accepted/tizen/3.0/mobile/20170605.014859 accepted/tizen/3.0/tv/20170605.014916 accepted/tizen/3.0/wearable/20170605.014932 submit/tizen_3.0/20170601.102336
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 30 Mar 2017 05:31:50 +0000 (14:31 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 4 May 2017 07:52:26 +0000 (07:52 +0000)
- Add methods to be used to request register/unregister pkg update info

Related changes:
[pkgmgr-server] : https://review.tizen.org/gerrit/128043
[pkgmgr-info] : https://review.tizen.org/gerrit/128044

Change-Id: I2e6abbef46651967e17bfb6a12b7fed5894a6aa7
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
(cherry picked from commit a638ce63c181a5842c0f3b5935a459aa49627191)

client/include/package-manager.h
client/src/pkgmgr.c

index 9f78be4..968e2f5 100644 (file)
@@ -166,6 +166,18 @@ typedef struct {
        long long ext_app_size;
 } pkg_size_info_t;
 
+typedef enum {
+       PM_UPDATEINFO_TYPE_NONE = 0,
+       PM_UPDATEINFO_TYPE_FORCE,
+       PM_UPDATEINFO_TYPE_OPTIONAL
+} pkgmgr_updateinfo_type;
+
+typedef struct {
+       char *pkgid;
+       char *version;
+       pkgmgr_updateinfo_type type;
+} pkg_update_info_t;
+
 typedef int (*pkgmgr_iter_fn)(const char *pkg_type, const char *pkgid,
                                const char *version, void *data);
 
@@ -399,6 +411,54 @@ int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
                                pkgmgr_handler event_cb, void *data, uid_t uid);
 
 /**
+ * @brief      This API registers the update information of given packages
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in]  pc      pkgmgr_client
+ * @param[in]  update_info     update information
+ * @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_register_pkg_update_info(pkgmgr_client *pc,
+                               pkg_update_info_t *update_info);
+int pkgmgr_client_usr_register_pkg_update_info(pkgmgr_client *pc,
+                               pkg_update_info_t *update_info, uid_t uid);
+
+/**
+ * @brief      This API unregisters update information of certain package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in]  pc      pkgmgr_client
+ * @param[in]  pkgid   package id
+ * @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_unregister_pkg_update_info(pkgmgr_client *pc, const char *pkgid);
+int pkgmgr_client_usr_unregister_pkg_update_info(pkgmgr_client *pc,
+                               const char *pkgid, uid_t uid);
+
+/**
+ * @brief      This API unregister update information of all packages.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in]  pc      pkgmgr_client
+ * @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_unregister_all_pkg_update_info(pkgmgr_client *pc);
+int pkgmgr_client_usr_unregister_all_pkg_update_info(pkgmgr_client *pc,
+                               uid_t uid);
+
+/**
  * @brief      This API activates package.
  *
  * This API is for package-manager client application.\n
index a7c2d87..d30cdfc 100644 (file)
@@ -768,6 +768,129 @@ API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
        return cb_info->req_id;
 }
 
+API int pkgmgr_client_usr_register_pkg_update_info(pkgmgr_client *pc,
+               pkg_update_info_t *update_info, uid_t uid)
+{
+       int ret;
+       struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc;
+       GVariant *result;
+
+       if (pc == NULL || update_info == NULL || update_info->pkgid == NULL) {
+               ERR("invalid parameter");
+               return PKGMGR_R_EINVAL;
+       }
+
+       if (client->pc_type != PC_REQUEST) {
+               ERR("client->pc_type is not PC_REQUEST");
+               return PKGMGR_R_EINVAL;
+       }
+
+       ret = pkgmgr_client_connection_send_request(client, "register_pkg_update_info",
+                       g_variant_new("(ussi)", uid, update_info->pkgid, update_info->version,
+                       update_info->type), &result);
+       if (ret != PKGMGR_R_OK) {
+               ERR("request failed: %d", ret);
+               return ret;
+       }
+
+       g_variant_get(result, "(i)", &ret);
+       if (ret != PKGMGR_R_OK) {
+               g_variant_unref(result);
+               return ret;
+       }
+       g_variant_unref(result);
+
+       return PKGMGR_R_OK;
+}
+
+API int pkgmgr_client_register_pkg_update_info(pkgmgr_client *pc,
+               pkg_update_info_t *update_info)
+{
+       return pkgmgr_client_usr_register_pkg_update_info(pc, update_info,
+                       _getuid());
+}
+
+API int pkgmgr_client_usr_unregister_pkg_update_info(pkgmgr_client *pc,
+               const char *pkgid, uid_t uid)
+{
+       int ret;
+       struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc;
+       GVariant *result;
+
+       if (pc == NULL || pkgid == NULL) {
+               ERR("invalid parameter");
+               return PKGMGR_R_EINVAL;
+       }
+
+       if (client->pc_type != PC_REQUEST) {
+               ERR("client->pc_type is not PC_REQUEST");
+               return PKGMGR_R_EINVAL;
+       }
+
+       ret = pkgmgr_client_connection_send_request(client,
+                       "unregister_pkg_update_info",
+                       g_variant_new("(us)", uid, pkgid), &result);
+       if (ret != PKGMGR_R_OK) {
+               ERR("request failed: %d", ret);
+               return ret;
+       }
+
+       g_variant_get(result, "(i)", &ret);
+       if (ret != PKGMGR_R_OK) {
+               g_variant_unref(result);
+               return ret;
+       }
+       g_variant_unref(result);
+
+       return PKGMGR_R_OK;
+}
+
+API int pkgmgr_client_unregister_pkg_update_info(pkgmgr_client *pc,
+               const char *pkgid)
+{
+       return pkgmgr_client_usr_unregister_pkg_update_info(pc, pkgid, _getuid());
+}
+
+API int pkgmgr_client_usr_unregister_all_pkg_update_info(pkgmgr_client *pc,
+               uid_t uid)
+{
+       int ret;
+       struct pkgmgr_client_t *client = (struct pkgmgr_client_t *)pc;
+       GVariant *result;
+
+       if (pc == NULL) {
+               ERR("invalid parameter");
+               return PKGMGR_R_EINVAL;
+       }
+
+       if (client->pc_type != PC_REQUEST) {
+               ERR("client->pc_type is not PC_REQUEST");
+               return PKGMGR_R_EINVAL;
+       }
+
+       ret = pkgmgr_client_connection_send_request(client,
+                       "unregister_all_pkg_update_info",
+                       g_variant_new("(u)", uid), &result);
+       if (ret != PKGMGR_R_OK) {
+               ERR("request failed: %d", ret);
+               return ret;
+       }
+
+       g_variant_get(result, "(i)", &ret);
+       if (ret != PKGMGR_R_OK) {
+               g_variant_unref(result);
+               return ret;
+       }
+       g_variant_unref(result);
+
+       return PKGMGR_R_OK;
+}
+
+API int pkgmgr_client_unregister_all_pkg_update_info(pkgmgr_client *pc)
+{
+       return pkgmgr_client_usr_unregister_all_pkg_update_info(pc, _getuid());
+}
+
 API int pkgmgr_client_usr_activate(pkgmgr_client *pc, const char *pkg_type,
                const char *pkgid, uid_t uid)
 {