Add api for resource copy
[platform/core/api/package-manager.git] / include / package_manager.h
index bcb0b21..21cefce 100644 (file)
@@ -103,6 +103,10 @@ typedef enum {
        PACKAGE_MANAGER_EVENT_TYPE_UPDATE,         /**< Update event type */
        PACKAGE_MANAGER_EVENT_TYPE_MOVE,           /**< Move event type (Since 3.0) */
        PACKAGE_MANAGER_EVENT_TYPE_CLEAR,          /**< Clear event type (Since 3.0) */
+       PACKAGE_MANAGER_EVENT_TYPE_RES_COPY,       /**< Resource copy event type (Since 6.5) */
+       PACKAGE_MANAGER_EVENT_TYPE_RES_CREATE_DIR, /**< Create directory for resource event type (Since 6.5) */
+       PACKAGE_MANAGER_EVENT_TYPE_RES_REMOVE,     /**< Remove resource event type (Since 6.5) */
+       PACKAGE_MANAGER_EVENT_TYPE_RES_UNINSTALL,     /**< Uninstall resource event type (Since 6.5) */
 } package_manager_event_type_e;
 
 
@@ -166,8 +170,23 @@ typedef enum {
        PACKAGE_MANAGER_STATUS_TYPE_CLEAR_DATA = 0x10,        /**< Clear data status */
        PACKAGE_MANAGER_STATUS_TYPE_INSTALL_PROGRESS = 0x20,  /**< Install progress status */
        PACKAGE_MANAGER_STATUS_TYPE_GET_SIZE = 0x40,          /**< Get size status */
+       PACKAGE_MANAGER_STATUS_TYPE_RES_COPY = 0x80,          /**< Resource copy status (Since 6.5) */
+       PACKAGE_MANAGER_STATUS_TYPE_RES_CREATE_DIR = 0x100,   /**< Resource create directory status (Since 6.5) */
+       PACKAGE_MANAGER_STATUS_TYPE_RES_REMOVE = 0x200,       /**< Resource remove status (Since 6.5) */
+       PACKAGE_MANAGER_STATUS_TYPE_RES_UNINSTALL = 0x400,    /**< Resource uninstall status (Since 6.5) */
 } package_manager_status_type_e;
 
+
+/**
+ * @brief Enumeration for resource event path state.
+ * @since_tizen 6.5
+ */
+typedef enum {
+       PACKAGE_MANAGER_RES_EVENT_PATH_STATE_NONE = 0,   /**< State that operation do nothing about the path */
+       PACKAGE_MANAGER_RES_EVENT_PATH_STATE_OK,         /**< State that operation success about the path */
+       PACKAGE_MANAGER_RES_EVENT_PATH_STATE_FAILED,     /**< State that operation fail about the path */
+} package_manager_res_event_path_state_e;
+
 /**
  * @brief The Package manager update info request handle.
  * @since_tizen 4.0
@@ -187,6 +206,11 @@ typedef struct package_manager_s *package_manager_h;
  */
 typedef struct package_manager_filter_s *package_manager_filter_h;
 
+/**
+ * @brief Resource share event handle.
+ * @since_tizen 6.5
+ */
+typedef struct package_manager_res_event_info_s *package_manager_res_event_info_h;
 
 /**
  * @brief Called when the package is installed, uninstalled, or updated, and the progress of the request to the package manager changes.
@@ -204,6 +228,24 @@ typedef struct package_manager_filter_s *package_manager_filter_h;
  */
 typedef void (*package_manager_event_cb) (const char *type, const char *package, package_manager_event_type_e event_type, package_manager_event_state_e event_state, int progress, package_manager_error_e error, void *user_data);
 
+/**
+ * @brief Called when the progress of the request to the package resource share changes.
+ * @since_tizen 6.5
+ * @remarks The @a pkgid should not be released. The @a pkgid can be used only in the callback.
+ * @remarks The @a handle should not be released. The @a handle can be used only in the callback.
+ * @param[in] pkgid The package ID of resource owner
+ * @param[in] event_type The type of resource event
+ * @param[in] event_state The state of resource event
+ * @param[in] handle    The handle which contains additional information of event
+ * @param[in] user_data   The user data passed from package_manager_set_res_event_cb()
+ * @see package_manager_set_res_event_cb()
+ * @see package_manager_unset_event_cb()
+ */
+typedef void (*package_manager_res_event_cb) (const char *pkgid,
+               package_manager_event_type_e event_type,
+               package_manager_event_state_e event_state,
+               package_manager_res_event_info_h handle, void *user_data);
+
 
 /**
  * @brief Creates a package manager handle.
@@ -276,6 +318,28 @@ int package_manager_set_event_cb(package_manager_h manager, package_manager_even
 
 
 /**
+ * @platform
+ * @brief Registers a callback function to be invoked when the progress of the request to the package resource share changes.
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] manager    The package manager handle
+ * @param[in] callback   The callback function to be registered
+ * @param[in] user_data  The user data to be passed to the callback function
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
+ * @retval #PACKAGE_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post package_manager_res_event_cb() will be invoked.
+ * @see package_manager_set_event_status()
+ * @see package_manager_res_event_cb()
+ * @see package_manager_unset_event_cb()
+ */
+int package_manager_set_res_event_cb(package_manager_h manager, package_manager_res_event_cb callback, void *user_data);
+
+
+/**
  * @brief Unregisters the callback function.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @param[in] manager The package manager handle
@@ -854,6 +918,27 @@ typedef void (*package_manager_request_event_cb) (int id, const char *type, cons
 
 /**
  * @platform
+ * @brief Called when the progress of the request to the package resource share changes.
+ * @since_tizen 6.5
+ * @remarks The @a pkgid should not be released. The @a pkgid can be used only in the callback.
+ * @remarks The @a handle should not be released. The @a handle can be used only in the callback.
+ * @param[in] req_id      The ID of the request to the package manager
+ * @param[in] pkgid       The package ID of resource owner
+ * @param[in] event_type  The type of resource event
+ * @param[in] event_state The state of resource event
+ * @param[in] handle      The handle which contains additional information of event
+ * @param[in] user_data   The user data passed from package_manager_request_res_copy_with_cb(), package_manager_request_res_create_dir_with_cb(), package_manager_request_res_remove_with_cb()
+ * @see package_manager_request_res_copy_with_cb()
+ * @see package_manager_request_res_create_dir_with_cb()
+ * @see package_manager_request_res_remove_with_cb()
+ */
+typedef void (*package_manager_request_res_event_cb) (int req_id,
+               const char *pkgid, package_manager_event_type_e event_type, package_manager_event_state_e event_state,
+               package_manager_res_event_info_h handle, void *user_data);
+
+
+/**
+ * @platform
  * @brief Creates a request handle to the package manager.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @remarks You must release @a request using package_manager_request_destroy().
@@ -1275,6 +1360,178 @@ int package_manager_updateinfo_request_unregister(package_updateinfo_request_h p
  */
 int package_manager_updateinfo_request_unregister_all(package_updateinfo_request_h pkg_updateinfo_req);
 
+/**
+ * @platform
+ * @brief  Adds resource source and destination path into handle.
+ * @details Adds resource source path and destination path to be copied into handle
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] request      The package manager request handle
+ * @param[in] src_path     The relative path of resource file or directory to be copied
+ * @param[in] dest_path    The relative path of destination
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
+ * @retval #PACKAGE_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PACKAGE_MANAGER_ERROR_SYSTEM_ERROR      Severe system error
+ * @see package_manager_request_res_copy_with_cb()
+ */
+int package_manager_request_add_res_copy_path(package_manager_request_h request, const char *src_path, const char *dest_path);
+
+/**
+ * @platform
+ * @brief  Copies resources into target directory, asynchronously.
+ * @details Copies resources into directory, which could be access via privileged applications only.
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] request      The package manager request handle
+ * @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_PERMISSION_DENIED Permission denied
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
+ * @retval #PACKAGE_MANAGER_ERROR_IO_ERROR          I/O error
+ * @retval #PACKAGE_MANAGER_ERROR_SYSTEM_ERROR      Severe system error
+ * @see package_manager_request_add_res_copy_path()
+ */
+int package_manager_request_res_copy_with_cb(package_manager_request_h request, package_manager_request_res_event_cb callback, void *user_data, int *id);
+
+/**
+ * @platform
+ * @brief  Add directory path to be created at privileged shared directory into handle.
+ * @details Added directory path will be created into directory existed for sharing resources via privileged applications
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] request      The package manager request handle
+ * @param[in] dir_path     The relative path of directories to be created under shared resource path
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
+ * @retval #PACKAGE_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PACKAGE_MANAGER_ERROR_SYSTEM_ERROR      Severe system error
+ * @see package_manager_request_res_create_dir_with_cb()
+ */
+int package_manager_request_add_res_create_dir_path(package_manager_request_h request, const char *dir_path);
+
+/**
+ * @platform
+ * @brief  Create directories into directory for sharing resources via privileged application, asynchronously.
+ * @details Create directories into certain directory which could be access via privileged applications only.
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] request      The package manager request handle
+ * @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_PERMISSION_DENIED Permission denied
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
+ * @see package_manager_request_add_res_create_dir_path()
+ */
+int package_manager_request_res_create_dir_with_cb(package_manager_request_h request, package_manager_request_res_event_cb callback, void *user_data, int *id);
+
+/**
+ * @platform
+ * @brief  Adds file or directory path to be removed located at privileged shared directory into handle.
+ * @details Added path will be removed from directory existed for sharing resources via privileged applications
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] request      The package manager request handle
+ * @param[in] res_path     The relative path of resources to be removed from privileged shared resource directory
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
+ * @retval #PACKAGE_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PACKAGE_MANAGER_ERROR_SYSTEM_ERROR      Severe system error
+ * @see package_manager_request_res_remove_with_cb()
+ */
+int package_manager_request_add_res_remove_path(package_manager_request_h request, const char *res_path);
+
+/**
+ * @platform
+ * @brief  Removes resources from for sharing resources via privileged application, asynchronously.
+ * @details Removes resources added at handle from certain directory which could be access via privileged applications only.
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] request      The package manager request handle
+ * @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_PERMISSION_DENIED Permission denied
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PACKAGE_MANAGER_ERROR_OUT_OF_MEMORY     Out of memory
+ * @see package_manager_request_add_res_remove_path()
+ */
+int package_manager_request_res_remove_with_cb(package_manager_request_h request, package_manager_request_res_event_cb callback, void *user_data, int *id);
+
+/**
+ * @platform
+ * @brief Gets the error code from given resource event handle.
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] handle       Resource event info handle
+ * @param[out] error       Error will be returned
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
+ * @retval #PACKAGE_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int package_manager_res_event_info_get_error_code(package_manager_res_event_info_h handle, package_manager_error_e *error);
+
+
+/**
+ * @brief Called to retrieve all path state about resource event.
+ * @since_tizen 6.5
+ * @remarks The @a path should not be released. The @a path can be used only in the callback.
+ * @param[in] path         The path handled by a resource event
+ * @param[in] state        The state of the path
+ * @param[in] user_data    The user data passed from the foreach function
+ * @return  @c true to continue with the next iteration of the loop,
+ *          otherwise @c false to break out of the loop
+ * @see package_manager_res_event_info_foreach_path()
+ */
+typedef bool (*package_manager_res_event_path_cb) (const char *path, package_manager_res_event_path_state_e state, void *user_data);
+
+/**
+ * @platform
+ * @brief Retrieves all package information of installed packages.
+ * @since_tizen 6.5
+ * @privlevel platform
+ * @privilege %http://tizen.org/privilege/packagemanager.admin
+ * @param[in] handle    Resource event info handle
+ * @param[in] callback  The callback function to be invoked
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PACKAGE_MANAGER_ERROR_NONE              Successful
+ * @retval #PACKAGE_MANAGER_ERROR_PERMISSION_DENIED Permission denied
+ * @retval #PACKAGE_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post This function invokes package_manager_res_event_path_cb() repeatedly for each path state handled by resource event.
+ * @see package_manager_res_event_path_cb()
+ */
+int package_manager_res_event_info_foreach_path(package_manager_res_event_info_h handle, package_manager_res_event_path_cb callback, void *user_data);
+
 
 /**
 * @}