pkgmgr_client_usr_mount_install 69/66569/4 accepted/tizen/common/20160505.140351 accepted/tizen/ivi/20160506.035731 accepted/tizen/mobile/20160506.035155 accepted/tizen/tv/20160506.035523 accepted/tizen/wearable/20160506.035622 submit/tizen/20160504.074553
authorTomasz Iwanek <t.iwanek@samsung.com>
Mon, 18 Apr 2016 14:45:05 +0000 (16:45 +0200)
committerTomasz Iwanek <t.iwanek@samsung.com>
Mon, 25 Apr 2016 12:59:20 +0000 (14:59 +0200)
Requires:
 - https://review.tizen.org/gerrit/#/c/65834/

Change-Id: Ia05f8efea9613a297568d6983a1528c8b0e43e1d

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

index 9b10f89..0308221 100644 (file)
@@ -421,6 +421,34 @@ int pkgmgr_client_reinstall(pkgmgr_client *pc, const char *pkg_type, const char
 int pkgmgr_client_usr_reinstall(pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
                                  const char *optional_data, pkgmgr_mode mode,
                              pkgmgr_handler event_cb, void *data, uid_t uid);
+
+/**
+ * @brief      This API mount-installs package.
+ *
+ * This API is for package-manager client application.\n
+ *
+ * @param[in]  pc      pkgmgr_client
+ * @param[in]  pkg_type                package type
+ * @param[in]  descriptor_path full path that descriptor is located
+ * @param[in]  pkg_path                full path that package file is located
+ * @param[in]  optional_data   optional data which is used for installation
+ * @param[in]  mode            installation mode  - PM_DEFAULT, PM_QUIET
+ * @param[in]  event_cb        user callback
+ * @param[in]  data            user data
+ * @return     request_id (>0) if success, error code(<0) if fail\n
+ * @retval     PKGMGR_R_OK     success
+ * @retval     PKGMGR_R_EINVAL invalid argument
+ * @retval     PKGMGR_R_ECOMM  communication error
+*/
+int pkgmgr_client_mount_install(pkgmgr_client *pc, const char *pkg_type,
+                           const char *descriptor_path, const char *pkg_path,
+                           const char *optional_data, pkgmgr_mode mode,
+                           pkgmgr_handler event_cb, void *data);
+int pkgmgr_client_usr_mount_install(pkgmgr_client *pc, const char *pkg_type,
+                           const char *descriptor_path, const char *pkg_path,
+                           const char *optional_data, pkgmgr_mode mode,
+                           pkgmgr_handler event_cb, void *data, uid_t uid);
+
 /**
  * @brief      This API uninstalls package.
  *
index 32b8a78..1babdd6 100644 (file)
@@ -1291,6 +1291,94 @@ API int pkgmgr_client_usr_reinstall(pkgmgr_client * pc, const char *pkg_type,
        return req_id;
 }
 
+API int pkgmgr_client_usr_mount_install(pkgmgr_client *pc, const char *pkg_type,
+               const char *descriptor_path, const char *pkg_path,
+               const char *optional_data, pkgmgr_mode mode,
+               pkgmgr_handler event_cb, void *data, uid_t uid)
+{
+       GVariant *result;
+       int ret = PKGMGR_R_ECOMM;
+       char *req_key = NULL;
+       GVariantBuilder *builder = NULL;
+       GVariant *args = NULL;
+       int req_id;
+       pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc;
+       char *pkgtype;
+
+       if (pc == NULL || pkg_path == NULL) {
+               ERR("invalid parameter");
+               return PKGMGR_R_EINVAL;
+       }
+
+       if (mpc->ctype != PC_REQUEST) {
+               ERR("mpc->ctype is not PC_REQUEST");
+               return PKGMGR_R_EINVAL;
+       }
+
+       if (access(pkg_path, F_OK) != 0) {
+               ERR("failed to access: %s", pkg_path);
+               return PKGMGR_R_EINVAL;
+       }
+
+       if (mpc->tep_path != NULL && access(mpc->tep_path, F_OK) != 0) {
+               ERR("failed to access: %s", mpc->tep_path);
+               return PKGMGR_R_EINVAL;
+       }
+
+       /* TODO: check pkg's type on server-side */
+       if (pkg_type == NULL)
+               pkgtype = __get_type_from_path(pkg_path);
+       else
+               pkgtype = strdup(pkg_type);
+
+       /* build arguments */
+       builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
+       if (mpc->tep_path) {
+               g_variant_builder_add(builder, "s", "-e");
+               g_variant_builder_add(builder, "s", mpc->tep_path);
+               g_variant_builder_add(builder, "s", "-M");
+               g_variant_builder_add(builder, "s", mpc->tep_move);
+       }
+
+       args = g_variant_new("as", builder);
+       g_variant_builder_unref(builder);
+
+       ret = comm_client_request(mpc->info.request.cc, "mount_install",
+                       g_variant_new("(uss@as)", uid, pkgtype, pkg_path, args),
+                       &result);
+       if (ret != PKGMGR_R_OK) {
+               ERR("request failed: %d", ret);
+               return 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 req_id;
+}
+
+API int pkgmgr_client_mount_install(pkgmgr_client *pc, const char *pkg_type,
+               const char *descriptor_path, const char *pkg_path,
+               const char *optional_data, pkgmgr_mode mode,
+               pkgmgr_handler event_cb, void *data)
+{
+       return pkgmgr_client_usr_mount_install(pc, pkg_type, descriptor_path,
+                       pkg_path, optional_data, mode, event_cb,data,
+                       _getuid());
+}
+
 API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
                const char *pkgid, pkgmgr_mode mode, pkgmgr_handler event_cb,
                void *data)