--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TIZEN_APPFW_PACKAGE_MANAGER_EXTENSION_H
+#define __TIZEN_APPFW_PACKAGE_MANAGER_EXTENSION_H
+
+#include "package_manager.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file package_manager_extension.h
+ */
+
+/**
+ * @addtogroup CAPI_PACKAGE_MANAGER_MODULE
+ * @{
+ */
+
+/**
+ * @platform
+ * @brief Installs the package located at the given path as the runtime mountable package, asynchronously.
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] request The request handle
+ * @param[in] path The absolute path to the package to be installed
+ * @param[out] id The ID of the request to the package manager
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PACKAGE_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @see package_manager_request_uninstall()
+ */
+int package_manager_request_mount_install(package_manager_request_h request, const char *path, int *id);
+
+
+/**
+ * @platform
+ * @brief Installs the package located at the given path as the runtime mountable package, asynchronously.
+ * @details The progress of the request is asynchronously received by the callback function.
+ * The @a callback is the individual callback only called for the current API call.
+ * The @a callback is the only callback called, even if another callback was set for this request
+ * with package_manager_request_set_event_cb().
+ * @since_tizen 4.0
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] request The request handle
+ * @param[in] path The absolute path to the package to be installed
+ * @param[in] callback The callback function to be invoked
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] id The ID of the request to the package manager
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #PACKAGE_MANAGER_ERROR_NONE Successful
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PACKAGE_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ */
+int package_manager_request_mount_install_with_cb(package_manager_request_h request,
+ const char *path,
+ package_manager_request_event_cb callback,
+ void *user_data,
+ int *id);
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIZEN_APPFW_PACKAGE_MANAGER_EXTENSION_H */
return PACKAGE_MANAGER_ERROR_NONE;
}
+static int __request_mount_install(package_manager_request_h request,
+ const char *path, pkgmgr_handler event_cb, int *id)
+{
+ int retval;
+ retval = check_privilege(PRIVILEGE_PACKAGE_MANAGER_ADMIN);
+ if (retval != PACKAGE_MANAGER_ERROR_NONE)
+ return retval;
+
+ if (package_manager_client_validate_handle(request))
+ return package_manager_error(PACKAGE_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
+ if (path == NULL)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+
+ int request_id = 0;
+ request_id = pkgmgr_client_mount_install(request->pc, request->pkg_type, NULL,
+ path, NULL, request->mode, event_cb ? event_cb : request_event_handler, request);
+
+ if (request_id == PKGMGR_R_EINVAL)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL);
+ else if (request_id == PKGMGR_R_ENOPKG)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_NO_SUCH_PACKAGE, __FUNCTION__, NULL);
+ else if (request_id == PKGMGR_R_ENOMEM)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL);
+ else if (request_id == PKGMGR_R_EIO)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL);
+ else if (request_id == PKGMGR_R_EPRIV)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_PERMISSION_DENIED, __FUNCTION__, NULL);
+ else if (request_id == PKGMGR_R_ESYSTEM || request_id == PKGMGR_R_ECOMM || request_id == PKGMGR_R_ERROR)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_SYSTEM_ERROR, __FUNCTION__, NULL);
+
+ if (id)
+ *id = request_id;
+
+ return PACKAGE_MANAGER_ERROR_NONE;
+}
+
+
API int package_manager_request_install(package_manager_request_h request,
const char *path, int *id)
{
return ret;
}
+API int package_manager_request_mount_install(package_manager_request_h request,
+ const char *path, int *id)
+{
+ return __request_mount_install(request, path, NULL, id);
+}
+
+API int package_manager_request_mount_install_with_cb(package_manager_request_h request,
+ const char *path, package_manager_request_event_cb callback,
+ void *user_data, int *id)
+{
+ int ret;
+ int req_id = 0;
+
+ if (request->request_cb_table == NULL)
+ __initialize_request_cb_table(request);
+
+ ret = __request_mount_install(request, path, internal_request_callback, &req_id);
+
+ if (req_id > 0) {
+ ret = __insert_request_cb_info(request, req_id, callback, user_data);
+ if (ret < 0)
+ return package_manager_error(PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY,
+ __FUNCTION__, "failed to create request cb info");
+ if (id)
+ *id = req_id;
+ }
+
+ return ret;
+}
+
API int package_manager_create(package_manager_h *manager)
{
int retval;