From 9449de8023c64a9db05443db89699532f9074dcb Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 6 Jan 2015 14:08:20 +0900 Subject: [PATCH] Update source from tizen 2.3 TC-2325 add api from tizen 2.3 remove deprecated api Change-Id: Iada103642380db28f880bae5ccc20f1b1288fcbe Signed-off-by: Sangyoon Jang --- CMakeLists.txt | 3 +- capi-appfw-app-manager.manifest | 8 + include/app_context.h | 151 +++-- include/app_info.h | 502 +++++++++++--- include/app_info_internal.h | 66 ++ include/app_manager.h | 353 +++++----- ...pp_manager_private.h => app_manager_internal.h} | 39 +- packaging/capi-appfw-app-manager.manifest | 5 - packaging/capi-appfw-app-manager.spec | 20 +- src/app_context.c | 17 +- src/app_info.c | 755 +++++++++++---------- src/app_manager.c | 146 ++-- tool/CMakeLists.txt | 21 + tool/main.c | 104 +++ 14 files changed, 1390 insertions(+), 800 deletions(-) create mode 100644 capi-appfw-app-manager.manifest create mode 100644 include/app_info_internal.h rename include/{app_manager_private.h => app_manager_internal.h} (63%) mode change 100755 => 100644 delete mode 100644 packaging/capi-appfw-app-manager.manifest create mode 100644 tool/CMakeLists.txt create mode 100755 tool/main.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 003fb77..5bb9488 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(requires "capi-base-common dlog vconf aul ail pkgmgr pkgmgr-info glib-2.0") +SET(requires "capi-base-common dlog vconf aul pkgmgr pkgmgr-info glib-2.0") SET(pc_requires "capi-base-common") INCLUDE(FindPkgConfig) @@ -94,3 +94,4 @@ ADD_CUSTOM_COMMAND( ENDIF(UNIX) +add_subdirectory(tool) diff --git a/capi-appfw-app-manager.manifest b/capi-appfw-app-manager.manifest new file mode 100644 index 0000000..b97d120 --- /dev/null +++ b/capi-appfw-app-manager.manifest @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/include/app_context.h b/include/app_context.h index 79e8eb1..c4aa724 100755 --- a/include/app_context.h +++ b/include/app_context.h @@ -11,10 +11,10 @@ * 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. + * limitations under the License. */ - + #ifndef __TIZEN_APPFW_APP_CONTEXT_H #define __TIZEN_APPFW_APP_CONTEXT_H @@ -25,41 +25,42 @@ extern "C" { #endif - /** - * @defgroup CAPI_APP_CONTEXT_MODULE Application Context - * @ingroup CAPI_APPLICATION_MANAGER_MODULE + * @file app_context.h */ - /** - * @addtogroup CAPI_APP_CONTEXT_MODULE + * @addtogroup CAPI_APP_CONTEXT_MODULE * @{ */ /** - * @brief Application context handle. + * @brief Application context handle. + * @since_tizen 2.3 */ typedef struct app_context_s *app_context_h; /** - * @brief Enumerations of event type for the application context event + * @brief Enumeration for Application Context Event. + * @since_tizen 2.3 */ typedef enum { - APP_CONTEXT_EVENT_LAUNCHED, /**< The application is launched */ - APP_CONTEXT_EVENT_TERMINATED, /**< The application is terminated */ + APP_CONTEXT_EVENT_LAUNCHED, /**< The application is launched */ + APP_CONTEXT_EVENT_TERMINATED, /**< The application is terminated */ } app_context_event_e; /** - * @brief Destroys the application context handle and releases all its resources. - * @param [in] app_context The application context handle - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @brief Destroys the application context handle and releases all its resources. + * @since_tizen 2.3 + * @param[in] app_context The application context handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @see app_manager_foreach_app_context() * @see app_manager_get_app_context() */ @@ -67,83 +68,97 @@ int app_context_destroy(app_context_h app_context); /** - * @brief Gets the package with the given application context. - * @remark This function is @b deprecated. Use app_context_get_app_id() instead. - * @remarks @a package must be released with free() by you. - * @param [in] app_context The application context - * @param [out] package The package of the given application context - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Gets the package with the given application context. + * @since_tizen 2.3 + * @remarks This function is @b deprecated. Use app_context_get_app_id() instead. \n + * You must release @a package using free(). + * @param[in] app_context The application context + * @param[out] package The package of the given application context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_context_get_package(app_context_h app_context, char **package); /** - * @brief Gets the application ID with the given application context. - * @remarks @a app_id must be released with free() by you. - * @param [in] app_context The application context - * @param [out] app_id The application ID of the given application context - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Gets the application ID with the given application context. + * @since_tizen 2.3 + * @remarks You must release @a app_id using free(). + * @param[in] app_context The application context + * @param[out] app_id The application ID of the given application context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_context_get_app_id(app_context_h app_context, char **app_id); /** - * @brief Gets the process ID with the given application context. - * @param [in] app_context The application context - * @param [out] pid The process ID of the given application context - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Gets the process ID with the given application context. + * @since_tizen 2.3 + * @param[in] app_context The application context + * @param[out] pid The process ID of the given application context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_context_get_pid(app_context_h app_context, pid_t *pid); /** - * @brief Checks whether the application with the given application context is terminated. - * @param [in] app_context The application context - * @param [out] terminated true if the application is terminated, false if the application is running - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Checks whether the application with the given application context is terminated. + * @since_tizen 2.3 + * @param[in] app_context The application context + * @param[out] terminated @c true if the application is terminated, \n + * otherwise @c false if the application is running + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_context_is_terminated(app_context_h app_context, bool *terminated); /** - * @brief Checks whether two application contexts are equal. - * @param [in] lhs The first application context to compare - * @param [in] rhs The second application context to compare - * @param [out] equal true if the application contexts are equal, otherwise false - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Checks whether two application contexts are equal. + * @since_tizen 2.3 + * @param[in] lhs The first application context to compare + * @param[in] rhs The second application context to compare + * @param[out] equal @c true if the application contexts are equal, \n + * otherwise @c false if they are not equal + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_context_is_equal(app_context_h lhs, app_context_h rhs, bool *equal); /** - * @brief Clones the application context handle. - * @param [out] clone If successful, a newly created application context handle will be returned. - * @param [in] app_context The application context - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Clones the application context handle. + * @since_tizen 2.3 + * @param[out] clone The newly created application context handle, if cloning is successful + * @param[in] app_context The application context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_context_clone(app_context_h *clone, app_context_h app_context); diff --git a/include/app_info.h b/include/app_info.h index 484f6a0..fb1e1b8 100755 --- a/include/app_info.h +++ b/include/app_info.h @@ -11,10 +11,10 @@ * 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. + * limitations under the License. */ - + #ifndef __TIZEN_APPFW_APP_INFO_H #define __TIZEN_APPFW_APP_INFO_H @@ -24,159 +24,459 @@ extern "C" { #endif +/** + * @file app_info.h + */ + +/** +* @addtogroup CAPI_APP_INFO_MODULE +* @{ +*/ + +/** @brief Definition for string property for filtering based on app info. */ +#define PACKAGE_INFO_PROP_APP_ID "PACKAGE_INFO_PROP_APP_ID" +#define PACKAGE_INFO_PROP_APP_TYPE "PACKAGE_INFO_PROP_APP_TYPE" +#define PACKAGE_INFO_PROP_APP_CATEGORY "PACKAGE_INFO_PROP_APP_CATEGORY" + +/** @brief Definition for boolean property for filtering based on app info. */ +#define PACKAGE_INFO_PROP_APP_NODISPLAY "PACKAGE_INFO_PROP_APP_NODISPLAY" +#define PACKAGE_INFO_PROP_APP_TASKMANAGE "PACKAGE_INFO_PROP_APP_TASKMANAGE" /** * @brief Application information handle. + * @since_tizen 2.3 */ typedef struct app_info_s *app_info_h; +/** + * @brief Application filter handle. + * @since_tizen 2.3 + */ +typedef struct app_info_filter_s *app_info_filter_h; + +/** + * @brief Application metadata filter handle. + * @since_tizen 2.3 + */ +typedef struct app_info_metadata_filter_s *app_info_metadata_filter_h; + +/** + * @brief Called to get the application information once for each installed application. + * @since_tizen 2.3 + * @param[in] app_info The application information of each installed application + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n + * otherwise @c false to break out of the loop + * @pre app_manager_foreach_app_info() will invoke this callback. + * @see app_manager_foreach_app_info() + */ +typedef bool (*app_info_filter_cb) (app_info_h app_info, void *user_data); + +/** + * @brief Called to get application metadata in app_info_foreach_metadata(). + * @since_tizen 2.3 + * @param[in] metadata_name The name of the metadata + * @param[in] metadata_value The value of the metadata + * @param[in] user_data The user data passed to app_info_foreach_metadata() + * @return @c true to continue with the next iteration of the loop, \n + * otherwise @c false to break out of the loop + * @pre app_info_foreach_metadata() will invoke this callback. + * @see app_info_foreach_metadata() + */ +typedef bool (*app_info_metadata_cb) (const char *metadata_key, const char *metadata_value, void *user_data); /** - * @brief Enumerations of event type for the application information event + * @brief Enumeration for Application Information Event. + * @since_tizen 2.3 */ typedef enum { - APP_INFO_EVENT_INSTALLED, /**< The application is newly installed */ - APP_INFO_EVENT_UNINSTALLED, /**< The application is uninstalled */ - APP_INFO_EVENT_UPDATED, /**< The application is updated */ + APP_INFO_EVENT_INSTALLED, /**< The application is newly installed */ + APP_INFO_EVENT_UNINSTALLED, /**< The application is uninstalled */ + APP_INFO_EVENT_UPDATED, /**< The application is updated */ } app_info_event_e; +/** + * @brief Creates the application information handle. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/packagemanager.info + * @param[in] app_id The application ID + * @param[out] app_info The application information handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_NO_SUCH_APP The app is not installed + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied + * @see app_manager_foreach_app_info() + * @see app_manager_get_app_info() + */ +int app_info_create(const char *app_id, app_info_h *app_info); /** - * @brief Destroys the application information handle and releases all its resources. - * @param [in] app_info The application information handle - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @brief Destroys the application information handle and releases all its resources. + * @since_tizen 2.3 + * @param[in] app_info The application information handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter * @see app_manager_foreach_app_info() * @see app_manager_get_app_info() */ int app_info_destroy(app_info_h app_info); - /** - * @brief Gets the application ID with the given application context. - * @remarks @a app_id must be released with free() by you. - * @param [in] app_info The application information - * @param [out] app_id The application ID of the given application context - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Gets the application ID with the given application context. + * @since_tizen 2.3 + * @remarks You must release @a app_id using free(). + * @param[in] app_info The application information + * @param[out] app_id The application ID of the given application context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_info_get_app_id(app_info_h app_info, char **app_id); +/** + * @brief Gets the executable path of the application + * @since_tizen 2.3 + * @remarks You must release @a exec path using free(). + * @param[in] app_info The application information + * @param[out] exec The executable path of the application + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + */ +int app_info_get_exec(app_info_h app_info, char **exec); /** - * @brief Gets the name of the application - * @remarks @a name must be released with free() by you. - * @param [in] app_info The application information - * @param [out] name The label of the application - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Gets the label of the application. + * @since_tizen 2.3 + * @remarks You must release @a label using free(). + * @param[in] app_info The application information + * @param[out] label The label of the application + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_info_get_label(app_info_h app_info, char **label); +/** + * @brief Gets the localed name of the application. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/packagemanager.info + * @remarks You must release localed name using free(). + * @param[in] app_id The application ID + * @param[in] locale The locale information + * @param[out] label The localed name of the application + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied + */ +int app_info_get_localed_label(const char *app_id, const char *locale, char **label); /** - * @brief Gets the absolute path to the icon image - * @remarks @a path must be released with free() by you. - * @param [in] app_info The application information - * @param [out] path The absolute path to the icon - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Gets the absolute path to the icon image. + * @since_tizen 2.3 + * @remarks You must release @a path using free(). + * @param[in] app_info The application information + * @param[out] path The absolute path to the icon + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_info_get_icon(app_info_h app_info, char **path); +/** + * @brief Gets the package name. + * @since_tizen 2.3 + * @remarks You must release @a package name using free(). + * @param[in] app_info The application information + * @param[out] package The package name + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + */ +int app_info_get_package(app_info_h app_info, char **package); /** - * @brief Checks whether two application information are equal. - * @param [in] lhs The first application information to compare - * @param [in] rhs The second application information to compare - * @param [out] equal true if the application information are equal, otherwise false - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Gets the package type name. + * @since_tizen 2.3 + * @remarks You must release package @a type name using free(). + * @param[in] app_info The application information + * @param[out] type The package type + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + */ +int app_info_get_type(app_info_h app_info, char **type); + +/** + * @brief Gets the list of metadata for a particular application. + * @since_tizen 2.3 + * @param[in] app_info The application information + * @param[in] callback The callback function for list + * @param[in] user_data The user data to be passed to callback function + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + */ +int app_info_foreach_metadata(app_info_h app_info, app_info_metadata_cb callback, void *user_data); + +/** + * @brief Checks whether application information is nodisplay. + * @since_tizen 2.3 + * @param[in] app_info The application information + * @param[out] nodisplay @c true if the application is nodisplay, \n + * otherwise @c false + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + */ +int app_info_is_nodisplay(app_info_h app_info, bool *nodisplay); + +/** + * @brief Checks whether two application information are equal. + * @since_tizen 2.3 + * @param[in] lhs The first application information to compare + * @param[in] rhs The second application information to compare + * @param[out] equal @c true if the application information are equal, \n + * otherwise @c false + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_info_is_equal(app_info_h lhs, app_info_h rhs, bool *equal); +/** + * @brief Checks whether application is enabled. + * @since_tizen 2.3 + * @param[in] app_info The application information + * @param[out] enabled @c true if the application is enabled, \n + * otherwise @c false + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + */ +int app_info_is_enabled(app_info_h app_info, bool *enabled); + +/** + * @brief Checks whether application is launched on booting time. + * @since_tizen 2.3 + * @param[in] app_info The application information + * @param[out] onboot @c true if the application is launched on booting time, \n + * otherwise @c false + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + */ +int app_info_is_onboot(app_info_h app_info, bool *onboot); + +/** + * @brief Checks whether application is preloaded. + * @since_tizen 2.3 + * @param[in] app_info The application information + * @param[out] preload @c true if the application is preloaded, \n + * otherwise @c false + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + */ +int app_info_is_preload(app_info_h app_info, bool *preload); /** - * @brief Clones the application information handle. - * @param [out] clone If successful, a newly created application information handle will be returned. - * @param [in] app_info The application information - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Clones the application information handle. + * @since_tizen 2.3 + * @param[out] clone A newly created application information handle, if successfully cloned + * @param[in] app_info The application information + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ int app_info_clone(app_info_h *clone, app_info_h app_info); +/** + * @brief Creates the application information filter handle from DB. + * All filter properties will be ANDed. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/packagemanager.info + * @param[out] handle The pointer to the application info filter handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied + */ +int app_info_filter_create(app_info_filter_h *handle); /** - * @brief Gets the absolute path to the icon image - * @remarks @a path must be released with free() by you. - * @param [in] app_info The application information - * @param [out] package The package name - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Destroys the application information filter handle, freeing up all the resources. + * @since_tizen 2.3 + * @param[in] handle The pointer to the application info filter handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ -int app_info_get_package(app_info_h app_info, char **package); +int app_info_filter_destroy(app_info_filter_h handle); +/** + * @brief Adds a boolean filter property to the filter handle. + * @since_tizen 2.3 + * @param[in] handle The pointer to the application info filter handle + * @param[in] property The integer property name + * @param[in] value The value corresponding to the property + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + */ +int app_info_filter_add_bool(app_info_filter_h handle, const char *property, const bool value); /** - * @brief Gets the absolute path to the icon image - * @remarks @a path must be released with free() by you. - * @param [in] app_info The application information - * @param [out] type The package type - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Adds a string filter property to the filter handle. + * @since_tizen 2.3 + * @param[in] handle The pointer to the application info filter handle + * @param[in] property The integer property name + * @param[in] value The value corresponding to the property + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory */ -int app_info_get_type(app_info_h app_info, char **type); +int app_info_filter_add_string(app_info_filter_h handle, const char *property, const char *value); +/** + * @brief Gets the count of filtered apps. + * @since_tizen 2.3 + * @param[in] handle The pointer to the application info filter handle + * @param[out] count The pointer to the variable for count + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_IO_ERROR I/O error + */ +int app_info_filter_count_appinfo(app_info_filter_h handle, int *count); + +/** + * @brief Executes the user supplied callback function for each application that satisfy the filter conditions. + * @since_tizen 2.3 + * @param[in] handle The pointer to the application info filter handle + * @param[in] callback The callback function + * @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 #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + */ +int app_info_filter_foreach_appinfo(app_info_filter_h handle, app_info_filter_cb callback, void * user_data); + +/** + * @brief Creates the application's metadata information filter handle from DB. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/packagemanager.info + * @param[out] handle The pointer to the application metadata info filter handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied + */ +int app_info_metadata_filter_create(app_info_metadata_filter_h *handle); + +/** + * @brief Destroys the application's metadata information filter handle. + * @since_tizen 2.3 + * @param[in] handle The pointer to the application info filter handle + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + */ +int app_info_metadata_filter_destroy(app_info_metadata_filter_h handle); -#define __START_OF_DEPRECATED_API -int app_info_get_name(app_info_h app_info, char **name); - -typedef struct ui_app_info_s *ui_app_info_h; -typedef struct service_app_info_s *service_app_info_h; -int ui_app_info_destroy(ui_app_info_h ui_app_info); -int ui_app_info_get_app_id(ui_app_info_h ui_app_info, char **app_id); -int ui_app_info_get_label(ui_app_info_h ui_app_info, char **label); -int ui_app_info_get_icon(ui_app_info_h ui_app_info, char **iconpath); -int ui_app_info_is_equal(ui_app_info_h lhs, ui_app_info_h rhs, bool *equal); -int ui_app_info_clone(ui_app_info_h *clone, ui_app_info_h ui_app_info); -int ui_app_info_get_package(ui_app_info_h ui_app_info, char **package); -int ui_app_info_get_type(ui_app_info_h ui_app_info, char **type); -//int ui_app_info_get_category(ui_app_info_h ui_app_info, char **category); -int service_app_info_destroy(service_app_info_h service_app_info); -int service_app_info_get_app_id(service_app_info_h service_app_info, char **app_id); -int service_app_info_get_label(service_app_info_h service_app_info, char **label); -int service_app_info_get_icon(service_app_info_h service_app_info, char **iconpath); -int service_app_info_is_equal(service_app_info_h lhs, service_app_info_h rhs, bool *equal); -int service_app_info_clone(service_app_info_h *clone, service_app_info_h service_app_info); -int service_app_info_get_package(service_app_info_h service_app_info, char **package); -int service_app_info_get_type(service_app_info_h service_app_info, char **type); -int service_app_info_is_onboot(service_app_info_h service_app_info, bool *onboot); -int service_app_info_is_autorestart(service_app_info_h service_app_info, bool *autorestart); -#define __END_OF_DEPRECATED_API +/** + * @brief Adds filter condition for the query API. + * @details The query will search the entire application metadata information collected from + * the manifest file of all the installed packages. You can specify value as @c NULL to search based on key only. + * @since_tizen 2.3 + * @param[in] handle The pointer to the application metadata info filter handle + * @param[in] key The pointer to metadata key + * @param[in] value The pointer to metadata value + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + */ +int app_info_metadata_filter_add(app_info_metadata_filter_h handle, const char *key, const char *value); +/** + * @brief Executes the filter query. + * @details The query will search the entire application metadata information collected from + * the manifest file of all the installed packages. For each application returned by the query, the callback will be called. If callback returns + * negative value, no more callbacks will be called and API will return. + * @since_tizen 2.3 + * @param[in] handle The pointer to the application metadata info filter handle + * @param[in] callback The function pointer to callback + * @param[in] user_data The pointer to user data + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + */ +int app_info_metadata_filter_foreach(app_info_metadata_filter_h handle, app_info_filter_cb callback, void *user_data); + + +/** +* @} +*/ #ifdef __cplusplus } diff --git a/include/app_info_internal.h b/include/app_info_internal.h new file mode 100644 index 0000000..6381431 --- /dev/null +++ b/include/app_info_internal.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2011 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_APP_INFO_INTERNAL_H +#define __TIZEN_APPFW_APP_INFO_INTERNAL_H + +#include "app_info.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* @addtogroup CAPI_APP_INFO_MODULE +* @{ +*/ + +#define __START_OF_DEPRECATED_API +int app_info_get_name(app_info_h app_info, char **name); + +typedef struct ui_app_info_s *ui_app_info_h; +typedef struct service_app_info_s *service_app_info_h; +int ui_app_info_destroy(ui_app_info_h ui_app_info); +int ui_app_info_get_app_id(ui_app_info_h ui_app_info, char **app_id); +int ui_app_info_get_label(ui_app_info_h ui_app_info, char **label); +int ui_app_info_get_icon(ui_app_info_h ui_app_info, char **iconpath); +int ui_app_info_is_equal(ui_app_info_h lhs, ui_app_info_h rhs, bool *equal); +int ui_app_info_clone(ui_app_info_h *clone, ui_app_info_h ui_app_info); +int ui_app_info_get_package(ui_app_info_h ui_app_info, char **package); +int ui_app_info_get_type(ui_app_info_h ui_app_info, char **type); +//int ui_app_info_get_category(ui_app_info_h ui_app_info, char **category); +int service_app_info_destroy(service_app_info_h service_app_info); +int service_app_info_get_app_id(service_app_info_h service_app_info, char **app_id); +int service_app_info_get_label(service_app_info_h service_app_info, char **label); +int service_app_info_get_icon(service_app_info_h service_app_info, char **iconpath); +int service_app_info_is_equal(service_app_info_h lhs, service_app_info_h rhs, bool *equal); +int service_app_info_clone(service_app_info_h *clone, service_app_info_h service_app_info); +int service_app_info_get_package(service_app_info_h service_app_info, char **package); +int service_app_info_get_type(service_app_info_h service_app_info, char **type); +int service_app_info_is_onboot(service_app_info_h service_app_info, bool *onboot); +int service_app_info_is_autorestart(service_app_info_h service_app_info, bool *autorestart); +#define __END_OF_DEPRECATED_API + +/** +* @} +*/ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_APPFW_APP_INFO_INTERNAL_H */ diff --git a/include/app_manager.h b/include/app_manager.h index 2b98188..fb0b412 100755 --- a/include/app_manager.h +++ b/include/app_manager.h @@ -11,10 +11,9 @@ * 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. + * limitations under the License. */ - #ifndef __TIZEN_APPFW_APP_MANAGER_H #define __TIZEN_APPFW_APP_MANAGER_H @@ -23,258 +22,258 @@ #include #include - #ifdef __cplusplus extern "C" { #endif /** + * @file app_manager.h + */ + +/** * @addtogroup CAPI_APPLICATION_MANAGER_MODULE * @{ */ - /** - * @brief Enumerations of error code for Application Manager. + * @brief Enumerations for Application Manager Error . + * @since_tizen 2.3 */ typedef enum { - APP_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - APP_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - APP_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - APP_MANAGER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */ - APP_MANAGER_ERROR_NO_SUCH_APP = TIZEN_ERROR_APPLICATION_MANAGER | 0x01, /**< No such application */ - - APP_MANAGER_ERROR_DB_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x03, /**< Database error */ - APP_MANAGER_ERROR_INVALID_PACKAGE = TIZEN_ERROR_APPLICATION_MANAGER | 0x04, /**< Invalid package name */ - APP_MANAGER_ERROR_APP_NO_RUNNING = TIZEN_ERROR_APPLICATION_MANAGER | 0x05, /**< App is not running */ - APP_MANAGER_ERROR_REQUEST_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x06, /**< Internal aul request error */ - APP_MANAGER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED /**< Permission denied */ + APP_MANAGER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + APP_MANAGER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + APP_MANAGER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + APP_MANAGER_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< Internal I/O error */ + APP_MANAGER_ERROR_NO_SUCH_APP = TIZEN_ERROR_APPLICATION_MANAGER | 0x01, /**< No such application */ + + APP_MANAGER_ERROR_DB_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x03, /**< Database error */ + APP_MANAGER_ERROR_INVALID_PACKAGE = TIZEN_ERROR_APPLICATION_MANAGER | 0x04, /**< Invalid package name */ + APP_MANAGER_ERROR_APP_NO_RUNNING = TIZEN_ERROR_APPLICATION_MANAGER | 0x05, /**< App is not running */ + APP_MANAGER_ERROR_REQUEST_FAILED = TIZEN_ERROR_APPLICATION_MANAGER | 0x06, /**< Internal aul request error */ + APP_MANAGER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED /**< Permission denied */ } app_manager_error_e; - /** - * @brief Called when an application gets launched or termiated. - * @param[in] app_context The application context of the application launched or termiated - * @param[in] event The application context event - * @param[in] user_data The user data passed from the foreach function - * @pre This function is called when an application gets launched or terminated after you register this callback using app_manager_set_app_context_event_cb() + * @internal + * @brief Called when an application is launched or terminated. + * @since_tizen 2.3 + * @param[in] app_context The application context of the application launched or terminated + * @param[in] event The application context event + * @param[in] user_data The user data passed from the foreach function + * @pre This function is called when an application gets launched or terminated, after you register this callback using app_manager_set_app_context_event_cb(). * @see app_manager_set_app_context_event_cb() * @see app_manager_unset_app_context_event_cb() */ typedef void (*app_manager_app_context_event_cb) (app_context_h app_context, app_context_event_e event, void *user_data); - /** - * @brief Called to get the application context once for each running application. - * @param[in] app_context The application context of each running application - * @param[in] user_data The user data passed from the foreach function - * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop. + * @brief Called to get the application context once for each running application. + * @since_tizen 2.3 + * @param[in] app_context The application context of each running application + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n + * otherwise @c false to break out of the loop * @pre app_manager_foreach_app_context() will invoke this callback. * @see app_manager_foreach_app_context() */ typedef bool (*app_manager_app_context_cb) (app_context_h app_context, void *user_data); - /** - * @internal - * @brief Called when an application gets installed, terminated or updated. - * @param[in] app_info The application information of the application installed, terminated or updated - * @param[in] event The application information event - * @param[in] user_data The user data passed from the foreach function - * @pre This function is called when an application gets installed, uninstalled or updated after you register this callback using app_manager_set_app_info_event_cb() - * @see app_manager_set_app_info_event_cb() - * @see app_manager_unset_app_info_event_cb() - */ -typedef void (*app_manager_app_info_event_cb) (app_info_h app_info, app_info_event_e event, void *user_data); - - -/** - * @internal - * @brief Called to get the application information once for each installed application. - * @param[in] app_info The application information of each installed application - * @param[in] user_data The user data passed from the foreach function - * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop. + * @brief Called to get the application information once for each installed application. + * @since_tizen 2.3 + * @param[in] app_info The application information of each installed application + * @param[in] user_data The user data passed from the foreach function + * @return @c true to continue with the next iteration of the loop, \n + * otherwise @c false to break out of the loop * @pre app_manager_foreach_app_info() will invoke this callback. * @see app_manager_foreach_app_info() */ typedef bool (*app_manager_app_info_cb) (app_info_h app_info, void *user_data); - /** - * @brief Registers a callback function to be invoked when the applications gets launched or termiated. - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE On Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory - * @post It will invoke app_manager_app_context_event_cb() when the application is launched or termiated. + * @internal + * @brief Registers a callback function to be invoked when the applications get launched or terminated. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/packagemanager.info + * @param[in] callback The callback function to register + * @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 #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied + * @post It will invoke app_manager_app_context_event_cb() when the application is launched or terminated. * @see app_manager_unset_app_context_event_cb() * @see app_manager_app_context_event_cb() */ int app_manager_set_app_context_event_cb(app_manager_app_context_event_cb callback, void *user_data); - /** - * @brief Unregisters the callback function. - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful + * @internal + * @brief Unregisters the callback function. + * @since_tizen 2.3 * @see app_manager_set_app_event_cb() * @see app_manager_app_context_event_cb() */ void app_manager_unset_app_context_event_cb(void); - /** - * @brief Retrieves all application contexts of running applications - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @post This function invokes app_manager_app_context_cb() repeatedly for each application context. + * @brief Retrieves all application contexts of running applications. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/packagemanager.info + * @param[in] callback The callback function to invoke + * @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 #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied + * @post This function invokes app_manager_app_context_cb() for each application context. * @see app_manager_app_context_cb() */ int app_manager_foreach_app_context(app_manager_app_context_cb callback, void *user_data); - /** - * @brief Gets the application context for the given ID of the application - * @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given application ID is not running \n - * @a app_context must be released with app_context_destroy() by you. - * @param [in] app_id The ID of the application - * @param [out] app_context The application context of the given application ID - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory - * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application + * @brief Gets the application context for the given ID of the application. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/packagemanager.info + * @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given application ID is not running. \n + * You must release @a app_context using app_context_destroy(). + * @param[in] app_id The ID of the application + * @param[out] app_context The application context of the given application ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied */ int app_manager_get_app_context(const char *app_id, app_context_h *app_context); - -/** - * @brief Gets the name of the application package for the given process ID of the application - * @remark This function is @b deprecated. Use app_manager_get_app_id() instead. - * @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given process ID is not valid \n - * @a package must be released with free() by you. - * @param [in] pid The process ID of the given application - * @param [out] package The package name of the application - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory - * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application - */ -int app_manager_get_package(pid_t pid, char **package); - - /** - * @brief Gets the ID of the application for the given process ID - * @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given process ID is not valid \n - * @a app_id must be released with free() by you. - * @param [in] pid The process ID of the application - * @param [out] app_id The ID of the application - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory - * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application + * @brief Gets the ID of the application for the given process ID. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/packagemanager.info + * @remarks This function returns #APP_MANAGER_ERROR_NO_SUCH_APP if the application with the given process ID is not valid. \n + * You must release @a app_id using free(). + * @param[in] pid The process ID of the application + * @param[out] app_id The ID of the application + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied */ int app_manager_get_app_id(pid_t pid, char **app_id); - /** - * @brief Checks whether the application with the given package name is running. - * @param [in] app_id The ID of the application - * @param [out] running @c true if the application is running, \n @c false if not running. - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @brief Checks whether the application with the given package name is running. + * @since_tizen 2.3 + * @param[in] app_id The ID of the application + * @param[out] running @c true if the application is running, \n + * otherwise @c false if not running + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter */ int app_manager_is_running(const char *app_id, bool *running); - /** - * @brief Resume the application - * @param [in] app_context The application context - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @brief Resumes the application. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/appmanager.launch + * @param[in] app_context The application context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_APP_NO_RUNNING App is not running + * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal resume error + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied */ int app_manager_resume_app(app_context_h app_context); - -/** - * @brief Terminate the application - * @param [in] app_context The application context - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - */ -int app_manager_terminate_app(app_context_h app_context); - - /** * @internal - * @brief Registers a callback function to be invoked when the applications gets installed, uninstalled or updated. - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE On Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory - * @post It will invoke app_manager_app_info_event_cb() when the application gets installed, uninstalled or updated. - * @see app_manager_unset_app_info_event_cb() - * @see app_manager_app_info_event_cb() + * @brief Opens the application. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/appmanager.launch + * @param[in] app_id The ID of the application + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_NO_SUCH_APP No such application + * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal open error + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied */ -int app_manager_set_app_info_event_cb(app_manager_app_info_event_cb callback, void *user_data); - +int app_manager_open_app(const char *app_id); /** * @internal - * @brief Unregisters the callback function. - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @see app_manager_set_app_info_event_cb() - * @see app_manager_app_info_event_cb() + * @brief Terminates the application. + * @since_tizen 2.3 + * @privlevel platform + * @privilege %http://tizen.org/privilege/appmanager.kill + * @param[in] app_context The application context + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_REQUEST_FAILED Internal terminate error + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied */ -void app_manager_unset_app_info_event_cb(void); - +int app_manager_terminate_app(app_context_h app_context); /** - * @internal - * @brief Retrieves all application information of installed applications - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @post This function invokes app_manager_app_info_cb() repeatedly for each application information. + * @brief Retrieves all installed applications information. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/packagemanager.info + * @param[in] callback The callback function to invoke + * @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 #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied + * @post This function invokes app_manager_app_info_cb() for each application information. * @see app_manager_app_info_cb() */ int app_manager_foreach_app_info(app_manager_app_info_cb callback, void *user_data); - /** - * @internal - * @brief Gets the application information for the given application ID - * @remarks @a app_info must be released with app_info_destroy() by you. - * @param [in] app_id The ID of the application - * @param [out] app_info The application information for the given application ID - * @return 0 on success, otherwise a negative error value. - * @retval #APP_MANAGER_ERROR_NONE Successful - * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred - * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @brief Gets the application information for the given application ID. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/packagemanager.info + * @remarks You must release @a app_info using app_info_destroy(). + * @param[in] app_id The ID of the application + * @param[out] app_info The application information for the given application ID + * @return @c 0 on success, + * otherwise a negative error value + * @retval #APP_MANAGER_ERROR_NONE Successful + * @retval #APP_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #APP_MANAGER_ERROR_DB_FAILED Database error occurred + * @retval #APP_MANAGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #APP_MANAGER_ERROR_PERMISSION_DENIED Permission denied */ int app_manager_get_app_info(const char *app_id, app_info_h *app_info); - /** * @brief Gets the absolute path to the shared data directory of the application specified * with an application ID. @@ -352,24 +351,12 @@ int app_manager_get_shared_trusted_path(const char *app_id, char **path); */ int app_manager_get_external_shared_data_path(const char *app_id, char **path); -#define __START_OF_DEPRECATED_API -typedef bool (*app_manager_ui_app_info_cb) (ui_app_info_h ui_app_info, void *user_data); -typedef bool (*app_manager_service_app_info_cb) (service_app_info_h service_app_info, void *user_data); -int app_manager_foreach_ui_app_info(app_manager_ui_app_info_cb callback, void *user_data); -int app_manager_get_ui_app_info(const char *app_id, ui_app_info_h *ui_app_info); -int app_manager_foreach_service_app_info(app_manager_service_app_info_cb callback, void *user_data); -int app_manager_get_service_app_info(const char *app_id, service_app_info_h *service_app_info); -#define __END_OF_DEPRECATED_API - - /** * @} */ - #ifdef __cplusplus } #endif #endif /* __TIZEN_APPFW_APP_MANAGER_H */ - diff --git a/include/app_manager_private.h b/include/app_manager_internal.h old mode 100755 new mode 100644 similarity index 63% rename from include/app_manager_private.h rename to include/app_manager_internal.h index 88a9208..e283e01 --- a/include/app_manager_private.h +++ b/include/app_manager_internal.h @@ -14,17 +14,34 @@ * limitations under the License. */ +#ifndef __TIZEN_APPFW_APP_MANAGER_INTERNAL_H +#define __TIZEN_APPFW_APP_MANAGER_INTERNAL_H -#ifndef __TIZEN_APPFW_APP_MANAGER_PRIVATE_H__ -#define __TIZEN_APPFW_APP_MANAGER_PRIVATE_H__ - -#include -#include +#include "app_manager.h" +#include "app_info_internal.h" #ifdef __cplusplus extern "C" { #endif +/** + * @file app_manager_internal.h + */ + +/** + * @addtogroup CAPI_APPLICATION_MANAGER_MODULE + * @{ + */ + +#define __START_OF_DEPRECATED_API +typedef void (*app_manager_app_info_event_cb) (app_info_h app_info, app_info_event_e event, void *user_data); +int app_manager_get_ui_app_info(const char *app_id, ui_app_info_h *ui_app_info); +int app_manager_get_service_app_info(const char *app_id, service_app_info_h *service_app_info); +int app_manager_get_app_package(const char *app_id, app_context_h *app_context); +int app_manager_set_app_info_event_cb(app_manager_app_info_event_cb callback, void *user_data); +void app_manager_unset_app_info_event_cb(void); +#define __END_OF_DEPRECATED_API + int app_manager_error(app_manager_error_e error, const char* function, const char *description); int app_context_foreach_app_context(app_manager_app_context_cb callback, void *user_data); @@ -43,16 +60,12 @@ int app_info_set_event_cb(app_manager_app_info_event_cb callback, void *user_dat void app_info_unset_event_cb(void); - -#define __START_OF_DEPRECATED_API -int ui_app_info_get_app_info(const char *app_id, ui_app_info_h *ui_app_info); -int service_app_info_get_app_info(const char *app_id, service_app_info_h *service_app_info); -#define __END_OF_DEPRECATED_API - +/** + * @} + */ #ifdef __cplusplus } #endif -#endif /* __TIZEN_APPFW_APP_MANAGER_PRIVATE_H__ */ - +#endif /* __TIZEN_APPFW_APP_MANAGER_INTERNAL_H */ diff --git a/packaging/capi-appfw-app-manager.manifest b/packaging/capi-appfw-app-manager.manifest deleted file mode 100644 index 017d22d..0000000 --- a/packaging/capi-appfw-app-manager.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/capi-appfw-app-manager.spec b/packaging/capi-appfw-app-manager.spec index 642bcfb..ae9dd55 100755 --- a/packaging/capi-appfw-app-manager.spec +++ b/packaging/capi-appfw-app-manager.spec @@ -1,35 +1,36 @@ Name: capi-appfw-app-manager Summary: Application Manager API -Version: 0.1.0 -Release: 0 +Version: 0.2.4 +Release: 1 Group: Application Framework/API License: Apache-2.0 Source0: %{name}-%{version}.tar.gz -Source1001: capi-appfw-app-manager.manifest BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(aul) -BuildRequires: pkgconfig(ail) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(glib-2.0) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig %description The Application Manager API provides functions to get information about running applications. %package devel Summary: Application Manager API (Development) -Group: Application Framework/API +Group: Application Framework/Libraries Requires: %{name} = %{version}-%{release} %description devel The Application Manager API provides functions to get information about running applications. (DEV) + %prep %setup -q -cp %{SOURCE1001} . + %build MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` @@ -44,12 +45,15 @@ rm -rf %{buildroot} %postun -p /sbin/ldconfig + %files -%manifest %{name}.manifest %{_libdir}/libcapi-appfw-app-manager.so.* +%{_bindir}/appmgr_tool +%manifest %{name}.manifest %files devel -%manifest %{name}.manifest %{_includedir}/appfw/*.h %{_libdir}/libcapi-appfw-app-manager.so %{_libdir}/pkgconfig/*.pc + + diff --git a/src/app_context.c b/src/app_context.c index bd2338f..23a1613 100755 --- a/src/app_context.c +++ b/src/app_context.c @@ -11,7 +11,7 @@ * 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. + * limitations under the License. */ @@ -28,7 +28,7 @@ #include #include -#include +#include #ifdef LOG_TAG #undef LOG_TAG @@ -97,7 +97,10 @@ int app_context_foreach_app_context(app_manager_app_context_cb callback, void *u return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - aul_app_get_running_app_info(app_context_foreach_app_context_cb, &foreach_context); + if (aul_app_get_running_app_info(app_context_foreach_app_context_cb, &foreach_context) != AUL_R_OK) + { + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); + } return APP_MANAGER_ERROR_NONE; } @@ -348,7 +351,7 @@ static bool app_context_load_all_app_context_cb_locked(app_context_h app_context if (app_context_clone(&app_context_cloned, app_context) == APP_MANAGER_ERROR_NONE) { - LOGI("[%s] app_id(%s), pid(%d)", __FUNCTION__, app_context->app_id, app_context->pid); + SECURE_LOGI("[%s] app_id(%s), pid(%d)", __FUNCTION__, app_context->app_id, app_context->pid); if (event_cb_context != NULL && event_cb_context->pid_table != NULL) { @@ -374,7 +377,7 @@ static void app_context_pid_table_entry_destroyed_cb(void * data) int pid; app_context_get_app_id(app_context, &app_id); app_context_get_pid(app_context, &pid); - LOGI("[%s] app_id(%s), pid(%d)", __FUNCTION__, app_context->app_id, app_context->pid); + SECURE_LOGI("[%s] app_id(%s), pid(%d)", __FUNCTION__, app_context->app_id, app_context->pid); free(app_id); app_context_destroy(app_context); @@ -452,7 +455,7 @@ int app_context_set_event_cb(app_manager_app_context_event_cb callback, void *us } event_cb_context->pid_table = g_hash_table_new_full(g_int_hash, g_int_equal, NULL, app_context_pid_table_entry_destroyed_cb); - + if (event_cb_context->pid_table == NULL) { return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, "failed to initialize pid-table"); @@ -464,7 +467,7 @@ int app_context_set_event_cb(app_manager_app_context_event_cb callback, void *us aul_listen_app_launch_signal(app_context_launched_event_cb, NULL); } - + event_cb_context->callback = callback; event_cb_context->user_data = user_data; diff --git a/src/app_info.c b/src/app_info.c index 8807857..8ce0c55 100755 --- a/src/app_info.c +++ b/src/app_info.c @@ -11,7 +11,7 @@ * 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. + * limitations under the License. */ @@ -20,14 +20,13 @@ #include #include -#include #include #include #include #include #include -#include +#include #ifdef LOG_TAG #undef LOG_TAG @@ -35,38 +34,137 @@ #define LOG_TAG "TIZEN_N_APP_MANAGER" -static int app_info_create(const char *app_id, app_info_h *app_info); - struct app_info_s { char *app_id; pkgmgrinfo_appinfo_h pkg_app_info; }; +struct app_info_filter_s { + pkgmgrinfo_appinfo_filter_h pkg_app_info_filter; +}; + +struct app_info_metadata_filter_s { + pkgmgrinfo_appinfo_metadata_filter_h pkg_app_info_metadata_filter; +}; + typedef struct _foreach_context_{ app_manager_app_info_cb callback; void *user_data; } foreach_context_s; +typedef struct _foreach_metada_context_{ + app_info_metadata_cb callback; + void *user_data; +} foreach_metadata_context_s; + static pkgmgr_client *package_event_listener = NULL; static app_manager_app_info_event_cb app_info_event_cb = NULL; static void *app_info_event_cb_data = NULL; -static ail_cb_ret_e app_info_foreach_app_info_cb(const ail_appinfo_h ail_app_info, void *cb_data,uid_t uid) +static int app_info_convert_str_property(const char *property, char **converted_property) +{ + if (property == NULL) + return -1; + + if (strcmp(property, PACKAGE_INFO_PROP_APP_ID)==0) + *converted_property = PMINFO_APPINFO_PROP_APP_ID; + + else if (strcmp(property, PACKAGE_INFO_PROP_APP_TYPE)==0) + *converted_property = PMINFO_APPINFO_PROP_APP_TYPE; + + else if (strcmp(property, PACKAGE_INFO_PROP_APP_CATEGORY)==0) + *converted_property = PMINFO_APPINFO_PROP_APP_CATEGORY; + + else + return -1; + + return 0; +} + +static int app_info_convert_bool_property(const char *property, char **converted_property) +{ + if (property == NULL) + return -1; + + if (strcmp(property, PACKAGE_INFO_PROP_APP_NODISPLAY)==0) + *converted_property = PMINFO_APPINFO_PROP_APP_NODISPLAY; + + else if (strcmp(property, PACKAGE_INFO_PROP_APP_TASKMANAGE)==0) + *converted_property = PMINFO_APPINFO_PROP_APP_TASKMANAGE; + + else + return -1; + + return 0; +} + +int app_info_foreach_app_filter_cb(pkgmgrinfo_appinfo_h handle, void *user_data) +{ + int retval = 0; + char *appid = NULL; + app_info_h info = NULL; + info = calloc(1, sizeof(struct app_info_s)); + if (info == NULL) { + return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + } + + foreach_context_s *foreach_context = user_data; + if (handle == NULL || foreach_context == NULL) + { + free(info); + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); + } + + retval = pkgmgrinfo_appinfo_get_appid(handle, &appid); + if (retval < 0) + { + free(info); + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); + } + + info->app_id = strdup(appid); + info->pkg_app_info = handle; + + foreach_context->callback(info, foreach_context->user_data); + + return APP_MANAGER_ERROR_NONE; +} + +static int app_info_foreach_app_metadata_cb(const char *metadata_key, const char *metadata_value, void *user_data) +{ + foreach_metadata_context_s *foreach_context = user_data; + + if (metadata_value == NULL || foreach_context == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); + } + + foreach_context->callback(metadata_key, metadata_value, foreach_context->user_data); + + return APP_MANAGER_ERROR_NONE; +} + +int app_info_foreach_app_info_cb(pkgmgrinfo_appinfo_h handle, void *cb_data) { foreach_context_s *foreach_context = cb_data; app_info_h app_info = NULL; - char *app_id; + char *appid = NULL; + int ret = 0; bool iteration_next = true; - if (ail_app_info == NULL || foreach_context == NULL) + if (handle == NULL || foreach_context == NULL) { app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); - return AIL_CB_RET_CANCEL; + return PMINFO_R_ERROR; } - ail_appinfo_get_str(ail_app_info, AIL_PROP_PACKAGE_STR, &app_id); + ret = pkgmgrinfo_appinfo_get_appid(handle, &appid); + if (ret != PMINFO_R_OK) { + app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL); + return PMINFO_R_ERROR; + } - if (app_info_create(app_id, &app_info) == APP_MANAGER_ERROR_NONE) + if (app_info_create(appid, &app_info) == APP_MANAGER_ERROR_NONE) { iteration_next = foreach_context->callback(app_info, foreach_context->user_data); app_info_destroy(app_info); @@ -74,11 +172,11 @@ static ail_cb_ret_e app_info_foreach_app_info_cb(const ail_appinfo_h ail_app_inf if (iteration_next == true) { - return AIL_CB_RET_CONTINUE; + return PMINFO_R_OK; } else { - return AIL_CB_RET_CANCEL; + return PMINFO_R_ERROR; } } @@ -94,7 +192,7 @@ int app_info_foreach_app_info(app_manager_app_info_cb callback, void *user_data) return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - ail_filter_list_usr_appinfo_foreach(NULL, app_info_foreach_app_info_cb, &foreach_context,getuid()); + pkgmgrinfo_appinfo_get_usr_installed_list(app_info_foreach_app_info_cb, getuid(), &foreach_context); return APP_MANAGER_ERROR_NONE; } @@ -104,7 +202,7 @@ int app_info_get_app_info(const char *app_id, app_info_h *app_info) return app_info_create(app_id, app_info); } -static int app_info_create(const char *app_id, app_info_h *app_info) +int app_info_create(const char *app_id, app_info_h *app_info) { pkgmgrinfo_pkginfo_h pkginfo = NULL; pkgmgrinfo_appinfo_h appinfo = NULL; @@ -120,9 +218,9 @@ static int app_info_create(const char *app_id, app_info_h *app_info) return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); } - retval = pkgmgrinfo_pkginfo_get_pkginfo(app_id, &pkginfo); + retval = pkgmgrinfo_pkginfo_get_usr_pkginfo(app_id, getuid(), &pkginfo); if (retval < 0) { - if (pkgmgrinfo_appinfo_get_appinfo(app_id, &appinfo)) { + if (pkgmgrinfo_appinfo_get_usr_appinfo(app_id, getuid(), &appinfo)) { free(info); return app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL); } @@ -138,7 +236,8 @@ static int app_info_create(const char *app_id, app_info_h *app_info) app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL); } - if (pkgmgrinfo_appinfo_get_appinfo(main_appid, &appinfo)) { + if (pkgmgrinfo_appinfo_get_usr_appinfo(main_appid, getuid(), &appinfo)) { + free(info); return app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL); } @@ -187,11 +286,32 @@ int app_info_get_app_id(app_info_h app_info, char **app_id) return APP_MANAGER_ERROR_NONE; } -int app_info_get_name(app_info_h app_info, char **label) +int app_info_get_exec(app_info_h app_info, char **exec) { - return app_info_get_label(app_info, label); -} + char *val; + char *app_exec_dup; + + if (app_info == NULL || exec == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + pkgmgrinfo_appinfo_get_exec(app_info->pkg_app_info, &val); + if (val == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + app_exec_dup = strdup(val); + if (app_exec_dup == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + } + *exec = app_exec_dup; + + return APP_MANAGER_ERROR_NONE; +} int app_info_get_label(app_info_h app_info, char **label) { @@ -204,7 +324,11 @@ int app_info_get_label(app_info_h app_info, char **label) } pkgmgrinfo_appinfo_get_label(app_info->pkg_app_info, &val); - + if (val == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + app_label_dup = strdup(val); if (app_label_dup == NULL) { @@ -216,7 +340,33 @@ int app_info_get_label(app_info_h app_info, char **label) return APP_MANAGER_ERROR_NONE; } +int app_info_get_localed_label(const char *app_id, const char *locale, char **label) +{ + char *val; + char *app_label_dup; + + if (app_id == NULL || locale == NULL || label == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + pkgmgrinfo_appinfo_get_localed_label(app_id, locale, &val); + if (val == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + app_label_dup = strdup(val); + if (app_label_dup == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + } + *label = app_label_dup; + free(val); + + return APP_MANAGER_ERROR_NONE; +} int app_info_get_icon(app_info_h app_info, char **path) { @@ -229,7 +379,11 @@ int app_info_get_icon(app_info_h app_info, char **path) } pkgmgrinfo_appinfo_get_icon(app_info->pkg_app_info, &val); - + if (val == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + app_icon_dup = strdup(val); if (app_icon_dup == NULL) { @@ -241,7 +395,108 @@ int app_info_get_icon(app_info_h app_info, char **path) return APP_MANAGER_ERROR_NONE; } +int app_info_get_package(app_info_h app_info, char **package) +{ + char *val; + char *app_package_dup; + if (app_info == NULL || package == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + pkgmgrinfo_appinfo_get_pkgname(app_info->pkg_app_info, &val); + + app_package_dup = strdup(val); + if (app_package_dup == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + } + + *package = app_package_dup; + + return APP_MANAGER_ERROR_NONE; +} + + +int app_info_get_type(app_info_h app_info, char **type) +{ + char *val; + char *app_type_dup; + + if (app_info == NULL || type == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + pkgmgrinfo_appinfo_get_apptype(app_info->pkg_app_info, &val); + + app_type_dup = strdup(val); + if (app_type_dup == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + } + + *type = app_type_dup; + + return APP_MANAGER_ERROR_NONE; +} + +int app_info_foreach_metadata(app_info_h app_info, app_info_metadata_cb callback, void *user_data) +{ + int retval = 0; + + if (app_info == NULL || callback == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + foreach_metadata_context_s foreach_context = { + .callback = callback, + .user_data = user_data, + }; + + retval = pkgmgrinfo_appinfo_foreach_metadata(app_info->pkg_app_info, app_info_foreach_app_metadata_cb, &foreach_context); + if (retval < 0) + { + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); + } + + return APP_MANAGER_ERROR_NONE; +} + +int app_info_is_nodisplay(app_info_h app_info, bool *nodisplay) +{ + bool val; + + if (app_info == NULL || nodisplay == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + if (pkgmgrinfo_appinfo_is_nodisplay(app_info->pkg_app_info, &val) < 0) + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + + *nodisplay = val; + return APP_MANAGER_ERROR_NONE; +} + +int app_info_is_enabled(app_info_h app_info, bool *enabled) +{ + bool val; + + if (app_info == NULL || enabled == NULL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + + if (pkgmgrinfo_appinfo_is_enabled(app_info->pkg_app_info, &val) < 0) + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + + *enabled = val; + return APP_MANAGER_ERROR_NONE; + +} int app_info_is_equal(app_info_h lhs, app_info_h rhs, bool *equal) { @@ -262,71 +517,58 @@ int app_info_is_equal(app_info_h lhs, app_info_h rhs, bool *equal) return APP_MANAGER_ERROR_NONE; } - -int app_info_clone(app_info_h *clone, app_info_h app_info) +int app_info_is_onboot(app_info_h app_info, bool *onboot) { - int retval; + bool val; - if (clone == NULL || app_info == NULL) + if (app_info == NULL || onboot == NULL) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - retval = app_info_create(app_info->app_id, clone); - - if (retval != APP_MANAGER_ERROR_NONE) + if (pkgmgrinfo_appinfo_is_onboot(app_info->pkg_app_info, &val) < 0) { - return app_manager_error(retval, __FUNCTION__, NULL); + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } + *onboot = val; return APP_MANAGER_ERROR_NONE; } - -int app_info_get_package(app_info_h app_info, char **package) +int app_info_is_preload(app_info_h app_info, bool *preload) { - char *val; - char *app_package_dup; + bool val; - if (app_info == NULL || package == NULL) + if (app_info == NULL || preload == NULL) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_pkgname(app_info->pkg_app_info, &val); - - app_package_dup = strdup(val); - if (app_package_dup == NULL) + if (pkgmgrinfo_appinfo_is_preload(app_info->pkg_app_info, &val) < 0) { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - *package = app_package_dup; - + *preload = val; return APP_MANAGER_ERROR_NONE; } - -int app_info_get_type(app_info_h app_info, char **type) +int app_info_clone(app_info_h *clone, app_info_h app_info) { - char *val; - char *app_type_dup; + int retval; - if (app_info == NULL || type == NULL) + if (clone == NULL || app_info == NULL) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_apptype(app_info->pkg_app_info, &val); + retval = app_info_create(app_info->app_id, clone); - app_type_dup = strdup(val); - if (app_type_dup == NULL) + if (retval != APP_MANAGER_ERROR_NONE) { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + return app_manager_error(retval, __FUNCTION__, NULL); } - *type = app_type_dup; - return APP_MANAGER_ERROR_NONE; } @@ -338,11 +580,11 @@ static app_info_event_e app_info_get_app_info_event(const char *value) } else if (!strcasecmp(value, "uninstall")) { - return APP_INFO_EVENT_UNINSTALLED; + return APP_INFO_EVENT_UNINSTALLED; } else if (!strcasecmp(value, "update")) { - return APP_INFO_EVENT_UPDATED; + return APP_INFO_EVENT_UPDATED; } else { @@ -354,35 +596,25 @@ static int app_info_package_event_listener_cb( int id, const char *type, const char *package, const char *key, const char *val, const void *msg, void *data) { static app_info_event_e event_type = -1; + static int req_id = -1; app_info_h app_info; if (!strcasecmp(key, "start")) { + req_id = id; event_type = app_info_get_app_info_event(val); - if (event_type >= APP_INFO_EVENT_UNINSTALLED) - { - if (app_info_create(package, &app_info) == APP_MANAGER_ERROR_NONE) - { - if(app_info_event_cb) - app_info_event_cb(app_info, event_type, app_info_event_cb_data); - - app_info_destroy(app_info); - } - } } - else if (!strcasecmp(key, "end") && !strcasecmp(val, "ok")) + else if (!strcasecmp(key, "end") && !strcasecmp(val, "ok") + && event_type >= 0 && id == req_id) { - event_type = app_info_get_app_info_event(val); - if (event_type == APP_INFO_EVENT_INSTALLED) + if (app_info_create(package, &app_info) == APP_MANAGER_ERROR_NONE) { - if (app_info_create(package, &app_info) == APP_MANAGER_ERROR_NONE) - { - if(app_info_event_cb) - app_info_event_cb(app_info, event_type, app_info_event_cb_data); - - app_info_destroy(app_info); - } + if(app_info_event_cb) + app_info_event_cb(app_info, event_type, app_info_event_cb_data); + app_info_destroy(app_info); } + + req_id = -1; event_type = -1; } @@ -427,412 +659,237 @@ void app_info_unset_event_cb(void) app_info_event_cb_data = NULL; } - -#define __START_OF_DEPRECATED_API - -static int ui_app_info_create(const char *app_id, ui_app_info_h *ui_app_info); -static int service_app_info_create(const char *app_id, service_app_info_h *service_app_info); - -struct ui_app_info_s { - char *app_id; - pkgmgrinfo_appinfo_h ui_app_info; -}; - -struct service_app_info_s { - char *app_id; - pkgmgrinfo_appinfo_h service_app_info; -}; - - -int ui_app_info_get_app_info(const char *app_id, ui_app_info_h *ui_app_info) -{ - return ui_app_info_create(app_id, ui_app_info); -} - -int service_app_info_get_app_info(const char *app_id, service_app_info_h *service_app_info) +int app_info_filter_create(app_info_filter_h *handle) { - return service_app_info_create(app_id, service_app_info); -} + int retval = 0; + app_info_filter_h filter_created = NULL; + pkgmgrinfo_appinfo_filter_h filter_h = NULL; -static int ui_app_info_create(const char *app_id, ui_app_info_h *ui_app_info) -{ - pkgmgrinfo_appinfo_h app_info; - ui_app_info_h info; - if (app_id == NULL || ui_app_info == NULL) + if (handle == NULL) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - if (pkgmgrinfo_appinfo_get_appinfo(app_id, &app_info)) { - return app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL); - } - info = calloc(1, sizeof(struct ui_app_info_s)); - if (info == NULL) { - pkgmgrinfo_appinfo_destroy_appinfo(app_info); - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + + retval = pkgmgrinfo_appinfo_filter_create(&filter_h); + if (retval < 0) { + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); } - info->app_id = strdup(app_id); - info->ui_app_info = app_info; - *ui_app_info = info; - return APP_MANAGER_ERROR_NONE; -} -static int service_app_info_create(const char *app_id, service_app_info_h *service_app_info) -{ - pkgmgrinfo_appinfo_h app_info; - service_app_info_h info; - if (app_id == NULL || service_app_info == NULL) + filter_created = calloc(1, sizeof(struct app_info_filter_s)); + if (filter_created == NULL) { - return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); - } - if (pkgmgrinfo_appinfo_get_appinfo(app_id, &app_info)) { - return app_manager_error(APP_MANAGER_ERROR_NO_SUCH_APP, __FUNCTION__, NULL); - } - info = calloc(1, sizeof(struct service_app_info_s)); - if (info == NULL) { - pkgmgrinfo_appinfo_destroy_appinfo(app_info); + free(filter_h); return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); } - info->app_id = strdup(app_id); - info->service_app_info = app_info; - *service_app_info = info; - return APP_MANAGER_ERROR_NONE; -} + filter_created->pkg_app_info_filter = filter_h; + + *handle = filter_created; -int ui_app_info_destroy(ui_app_info_h ui_app_info) -{ - if (ui_app_info == NULL) - { - return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); - } - if (ui_app_info->app_id) { - free(ui_app_info->app_id); - ui_app_info->app_id = NULL; - } - pkgmgrinfo_appinfo_destroy_appinfo(ui_app_info->ui_app_info); - free(ui_app_info); return APP_MANAGER_ERROR_NONE; } -int ui_app_info_get_app_id(ui_app_info_h ui_app_info, char **app_id) +int app_info_filter_destroy(app_info_filter_h handle) { - char *val; - char *app_id_dup; + int retval = 0; - if (ui_app_info == NULL || app_id == NULL) + if (handle == NULL) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_appid(ui_app_info->ui_app_info, &val); - app_id_dup = strdup(val); - if (app_id_dup == NULL) + retval = pkgmgrinfo_appinfo_filter_destroy(handle->pkg_app_info_filter); + if (retval < 0) { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); } - *app_id = app_id_dup; + free(handle); return APP_MANAGER_ERROR_NONE; } - -int ui_app_info_get_label(ui_app_info_h ui_app_info, char **label) +int app_info_filter_add_bool(app_info_filter_h handle, const char *property, const bool value) { - char *val; - char *app_label_dup; + int retval = 0; + char *converted_property = NULL; - if (ui_app_info == NULL || label == NULL) + if ((handle == NULL) || (property == NULL)) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_label(ui_app_info->ui_app_info, &val); - app_label_dup = strdup(val); - if (app_label_dup == NULL) - { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); - } - - *label = app_label_dup; - return APP_MANAGER_ERROR_NONE; -} - -int ui_app_info_get_icon(ui_app_info_h ui_app_info, char **icon) -{ - char *val; - char *app_icon_dup; - - if (ui_app_info == NULL || icon == NULL) + retval = app_info_convert_bool_property(property, &converted_property); + if (retval < 0) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_icon(ui_app_info->ui_app_info, &val); - app_icon_dup = strdup(val); - if (app_icon_dup == NULL) + retval = pkgmgrinfo_appinfo_filter_add_bool(handle->pkg_app_info_filter, converted_property, value); + if (retval < 0) { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); } - *icon = app_icon_dup; return APP_MANAGER_ERROR_NONE; } - -int ui_app_info_get_type(ui_app_info_h ui_app_info, char **type) +int app_info_filter_add_string(app_info_filter_h handle, const char *property, const char *value) { - char *val; - char *app_type_dup; + int retval = 0; + char *converted_property = NULL; - if (ui_app_info == NULL || type == NULL) + if ((handle == NULL) || (property == NULL)) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_apptype(ui_app_info->ui_app_info, &val); - app_type_dup = strdup(val); - if (app_type_dup == NULL) - { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); - } - - *type = app_type_dup; - return APP_MANAGER_ERROR_NONE; -} - - -int ui_app_info_get_package(ui_app_info_h ui_app_info, char **package) -{ - char *val; - char *package_dup; - - if (ui_app_info == NULL || package == NULL) + retval = app_info_convert_str_property(property, &converted_property); + if (retval < 0) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_pkgname(ui_app_info->ui_app_info, &val); - package_dup = strdup(val); - if (package_dup == NULL) + retval = pkgmgrinfo_appinfo_filter_add_string(handle->pkg_app_info_filter, converted_property, value); + if (retval < 0) { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); } - *package = package_dup; return APP_MANAGER_ERROR_NONE; } - -int ui_app_info_is_equal(ui_app_info_h lhs, ui_app_info_h rhs, bool *equal) +int app_info_filter_count_appinfo(app_info_filter_h handle, int *count) { - if (lhs == NULL || rhs == NULL || equal == NULL) - { - return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); - } - if (!strcmp(lhs->app_id, rhs->app_id)) - { - *equal = true; - } - else - { - *equal = false; - } - return APP_MANAGER_ERROR_NONE; -} + int retval = 0; -int ui_app_info_clone(ui_app_info_h *clone, ui_app_info_h ui_app_info) -{ - int retval; - if (clone == NULL || ui_app_info == NULL) + if ((handle == NULL) || (count == NULL)) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - retval = ui_app_info_create(ui_app_info->app_id, clone); - if (retval != APP_MANAGER_ERROR_NONE) - { - return app_manager_error(retval, __FUNCTION__, NULL); - } - return APP_MANAGER_ERROR_NONE; -} -int service_app_info_destroy(service_app_info_h service_app_info) -{ - if (service_app_info == NULL) + retval = pkgmgrinfo_appinfo_filter_count(handle->pkg_app_info_filter, count); + if (retval < 0) { - return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); - } - if (service_app_info->app_id) { - free(service_app_info->app_id); - service_app_info->app_id = NULL; + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_destroy_appinfo(service_app_info->service_app_info); - free(service_app_info); + return APP_MANAGER_ERROR_NONE; } -int service_app_info_get_app_id(service_app_info_h service_app_info, char **app_id) +int app_info_filter_foreach_appinfo(app_info_filter_h handle, app_info_filter_cb callback, void * user_data) { - char *val; - char *app_id_dup; + int retval = 0; + + foreach_context_s foreach_context = { + .callback = callback, + .user_data = user_data, + }; - if (service_app_info == NULL || app_id == NULL) + if ((handle == NULL) || (callback == NULL)) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_appid(service_app_info->service_app_info, &val); - app_id_dup = strdup(val); - if (app_id_dup == NULL) + retval = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle->pkg_app_info_filter, app_info_foreach_app_filter_cb, &foreach_context); + if (retval < 0) { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); } - *app_id = app_id_dup; return APP_MANAGER_ERROR_NONE; } - -int service_app_info_get_label(service_app_info_h service_app_info, char **label) +int app_info_metadata_filter_create(app_info_metadata_filter_h *handle) { - char *val; - char *app_label_dup; + int retval = 0; + app_info_metadata_filter_h filter_created = NULL; + pkgmgrinfo_appinfo_metadata_filter_h filter_h = NULL; - if (service_app_info == NULL || label == NULL) + if (handle == NULL) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_label(service_app_info->service_app_info, &val); - app_label_dup = strdup(val); - if (app_label_dup == NULL) + filter_created = calloc(1, sizeof(struct app_info_metadata_filter_s)); + if (filter_created == NULL) { return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); } - *label = app_label_dup; - return APP_MANAGER_ERROR_NONE; -} - -int service_app_info_get_icon(service_app_info_h service_app_info, char **icon) -{ - char *val; - char *app_icon_dup; - - if (service_app_info == NULL || icon == NULL) - { - return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + retval = pkgmgrinfo_appinfo_metadata_filter_create(&filter_h); + if (retval < 0) { + free(filter_created); + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_icon(service_app_info->service_app_info, &val); - app_icon_dup = strdup(val); - if (app_icon_dup == NULL) - { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); - } + filter_created->pkg_app_info_metadata_filter = filter_h; + + *handle = filter_created; - *icon = app_icon_dup; return APP_MANAGER_ERROR_NONE; } - -int service_app_info_get_type(service_app_info_h service_app_info, char **type) +int app_info_metadata_filter_destroy(app_info_metadata_filter_h handle) { - char *val; - char *app_type_dup; + int retval = 0; - if (service_app_info == NULL || type == NULL) + if (handle == NULL) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_apptype(service_app_info->service_app_info, &val); - app_type_dup = strdup(val); - if (app_type_dup == NULL) + retval = pkgmgrinfo_appinfo_metadata_filter_destroy(handle->pkg_app_info_metadata_filter); + if (retval < 0) { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); } - *type = app_type_dup; + free(handle); return APP_MANAGER_ERROR_NONE; } - -int service_app_info_get_package(service_app_info_h service_app_info, char **package) +int app_info_metadata_filter_add(app_info_metadata_filter_h handle, const char *key, const char *value) { - char *val; - char *package_dup; + int retval = 0; - if (service_app_info == NULL || package == NULL) + if ((handle == NULL) || (key == NULL)) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_get_pkgname(service_app_info->service_app_info, &val); - package_dup = strdup(val); - if (package_dup == NULL) + retval = pkgmgrinfo_appinfo_metadata_filter_add(handle->pkg_app_info_metadata_filter, key, value); + if (retval < 0) { - return app_manager_error(APP_MANAGER_ERROR_OUT_OF_MEMORY, __FUNCTION__, NULL); + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); } - *package = package_dup; return APP_MANAGER_ERROR_NONE; } - -int service_app_info_is_equal(service_app_info_h lhs, service_app_info_h rhs, bool *equal) +int app_info_metadata_filter_foreach(app_info_metadata_filter_h handle, app_info_filter_cb callback, void *user_data) { - if (lhs == NULL || rhs == NULL || equal == NULL) - { - return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); - } - if (!strcmp(lhs->app_id, rhs->app_id)) - { - *equal = true; - } - else - { - *equal = false; - } - return APP_MANAGER_ERROR_NONE; -} + int retval = 0; -int service_app_info_clone(service_app_info_h *clone, service_app_info_h service_app_info) -{ - int retval; - if (clone == NULL || service_app_info == NULL) + foreach_context_s foreach_context = { + .callback = callback, + .user_data = user_data, + }; + + if (handle == NULL) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - retval = service_app_info_create(service_app_info->app_id, clone); - if (retval != APP_MANAGER_ERROR_NONE) - { - return app_manager_error(retval, __FUNCTION__, NULL); - } - return APP_MANAGER_ERROR_NONE; -} -int service_app_info_is_onboot(service_app_info_h service_app_info, bool *onboot) -{ - bool val; - if (service_app_info == NULL || onboot == NULL) + if (callback == NULL) { return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_is_onboot(service_app_info->service_app_info, &val); - *onboot = val; - return APP_MANAGER_ERROR_NONE; -} -int service_app_info_is_autorestart(service_app_info_h service_app_info, bool *autorestart) -{ - bool val; - if (service_app_info == NULL || autorestart == NULL) + retval = pkgmgrinfo_appinfo_metadata_filter_foreach(handle->pkg_app_info_metadata_filter, app_info_foreach_app_filter_cb, &foreach_context); + if (retval < 0) { - return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + return app_manager_error(APP_MANAGER_ERROR_IO_ERROR, __FUNCTION__, NULL); } - pkgmgrinfo_appinfo_is_autorestart(service_app_info->service_app_info, &val); - *autorestart = val; + return APP_MANAGER_ERROR_NONE; } - -#define __END_OF_DEPRECATED_API diff --git a/src/app_manager.c b/src/app_manager.c index 8639578..4feb769 100755 --- a/src/app_manager.c +++ b/src/app_manager.c @@ -24,7 +24,7 @@ #include #include -#include +#include #ifdef LOG_TAG #undef LOG_TAG @@ -38,37 +38,28 @@ static const char* app_manager_error_to_string(app_manager_error_e error) switch (error) { case APP_MANAGER_ERROR_NONE: - return "NONE"; + return "Successful"; case APP_MANAGER_ERROR_INVALID_PARAMETER: - return "INVALID_PARAMETER"; + return "Invalid parameter"; case APP_MANAGER_ERROR_OUT_OF_MEMORY: - return "OUT_OF_MEMORY"; + return "Out of memory"; case APP_MANAGER_ERROR_IO_ERROR: - return "IO_ERROR"; + return "IO error"; case APP_MANAGER_ERROR_NO_SUCH_APP: - return "NO_SUCH_APP"; + return "No such application"; case APP_MANAGER_ERROR_DB_FAILED: - return "DB_FAILED"; + return "DB error"; case APP_MANAGER_ERROR_INVALID_PACKAGE: - return "INVALID_PACKAGE"; + return "Invalid package"; - case APP_MANAGER_ERROR_APP_NO_RUNNING: - return "NO_RUNNING"; - - case APP_MANAGER_ERROR_REQUEST_FAILED: - return "AUL_REQUEST_FAILED"; - - case APP_MANAGER_ERROR_PERMISSION_DENIED: - return "PERMISSION_DENIED"; - - default : - return "UNKNOWN"; + default: + return "Unknown"; } } @@ -89,9 +80,7 @@ int app_manager_error(app_manager_error_e error, const char* function, const cha int app_manager_set_app_context_event_cb(app_manager_app_context_event_cb callback, void *user_data) { - int retval; - - retval = app_context_set_event_cb(callback, user_data); + int retval = app_context_set_event_cb(callback, user_data); if (retval != APP_MANAGER_ERROR_NONE) { @@ -110,9 +99,7 @@ void app_manager_unset_app_context_event_cb(void) int app_manager_foreach_app_context(app_manager_app_context_cb callback, void *user_data) { - int retval; - - retval = app_context_foreach_app_context(callback, user_data); + int retval = app_context_foreach_app_context(callback, user_data); if (retval != APP_MANAGER_ERROR_NONE) { @@ -126,9 +113,7 @@ int app_manager_foreach_app_context(app_manager_app_context_cb callback, void *u int app_manager_get_app_context(const char *app_id, app_context_h *app_context) { - int retval; - - retval = app_context_get_app_context(app_id, app_context); + int retval = app_context_get_app_context(app_id, app_context); if (retval != APP_MANAGER_ERROR_NONE) { @@ -143,6 +128,7 @@ int app_manager_get_app_context(const char *app_id, app_context_h *app_context) int app_manager_resume_app(app_context_h app_context) { char *app_id; + int retval; if (app_context == NULL) { @@ -154,16 +140,34 @@ int app_manager_resume_app(app_context_h app_context) return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, "failed to get the application ID"); } - aul_resume_app(app_id); + if (aul_app_is_running(app_id) == 0) + { + free(app_id); + return app_manager_error(APP_MANAGER_ERROR_APP_NO_RUNNING, __FUNCTION__, NULL); + } + + retval = aul_resume_app(app_id); + + free(app_id); + if (retval == AUL_R_EINVAL) + { + return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, NULL); + } + else if (retval == AUL_R_EILLACC) + { + return app_manager_error(APP_MANAGER_ERROR_PERMISSION_DENIED, __FUNCTION__, NULL); + } + else if (retval < 0) + { + return app_manager_error(APP_MANAGER_ERROR_REQUEST_FAILED, __FUNCTION__, NULL); + } return APP_MANAGER_ERROR_NONE; } int app_manager_set_app_info_event_cb(app_manager_app_info_event_cb callback, void *user_data) { - int retval; - - retval = app_info_set_event_cb(callback, user_data); + int retval = app_info_set_event_cb(callback, user_data); if (retval != APP_MANAGER_ERROR_NONE) { @@ -213,38 +217,6 @@ int app_manager_get_app_info(const char *app_id, app_info_h *app_info) } } -int app_manager_get_ui_app_info(const char *app_id, ui_app_info_h *ui_app_info) -{ - int retval; - - retval = ui_app_info_get_app_info(app_id, ui_app_info); - - if (retval != APP_MANAGER_ERROR_NONE) - { - return app_manager_error(retval, __FUNCTION__, NULL); - } - else - { - return APP_MANAGER_ERROR_NONE; - } -} - -int app_manager_get_service_app_info(const char *app_id, service_app_info_h *service_app_info) -{ - int retval; - - retval = service_app_info_get_app_info(app_id, service_app_info); - - if (retval != APP_MANAGER_ERROR_NONE) - { - return app_manager_error(retval, __FUNCTION__, NULL); - } - else - { - return APP_MANAGER_ERROR_NONE; - } -} - int app_manager_get_package(pid_t pid, char **package) { // TODO: this function must be deprecated @@ -281,6 +253,7 @@ int app_manager_get_app_id(pid_t pid, char **app_id) int app_manager_terminate_app(app_context_h app_context) { + int retval; pid_t pid = 0; if (app_context == NULL) @@ -292,7 +265,22 @@ int app_manager_terminate_app(app_context_h app_context) return app_manager_error(APP_MANAGER_ERROR_INVALID_PARAMETER, __FUNCTION__, "failed to get the process ID"); } - aul_terminate_pid(pid); + retval = aul_terminate_pid(pid); + + if (retval == AUL_R_EINVAL) + { + LOGE("[%s] APP_MANAGER_ERROR_INVALID_PARAMETER(0x%08x) : Invalid param", __FUNCTION__, APP_MANAGER_ERROR_INVALID_PARAMETER); + return APP_MANAGER_ERROR_INVALID_PARAMETER; + } + else if (retval == AUL_R_EILLACC) + { + LOGE("[%s] APP_MANAGER_ERROR_PERMISSION_DENIED(0x%08x) : Permission denied", __FUNCTION__, APP_MANAGER_ERROR_PERMISSION_DENIED); + return APP_MANAGER_ERROR_PERMISSION_DENIED; + } + else if (retval < 0) + { + return APP_MANAGER_ERROR_REQUEST_FAILED; + } return APP_MANAGER_ERROR_NONE; } @@ -316,6 +304,34 @@ int app_manager_is_running(const char *app_id, bool *running) return APP_MANAGER_ERROR_NONE; } +int app_manager_open_app(const char *app_id) +{ + int retval; + retval = aul_open_app(app_id); + + if (retval == AUL_R_ERROR) + { + LOGE("[%s] APP_MANAGER_ERROR_NO_SUCH_APP(0x%08x) : No such application", __FUNCTION__, APP_MANAGER_ERROR_NO_SUCH_APP); + return APP_MANAGER_ERROR_NO_SUCH_APP; + } + else if (retval == AUL_R_EINVAL) + { + LOGE("[%s] APP_MANAGER_ERROR_INVALID_PARAMETER(0x%08x) : Invalid param", __FUNCTION__, APP_MANAGER_ERROR_INVALID_PARAMETER); + return APP_MANAGER_ERROR_INVALID_PARAMETER; + } + else if (retval == AUL_R_EILLACC) + { + LOGE("[%s] APP_MANAGER_ERROR_PERMISSION_DENIED(0x%08x) : Permission denied", __FUNCTION__, APP_MANAGER_ERROR_PERMISSION_DENIED); + return APP_MANAGER_ERROR_PERMISSION_DENIED; + } + else if (retval < 0) + { + return APP_MANAGER_ERROR_REQUEST_FAILED; + } + + return APP_MANAGER_ERROR_NONE; +} + int app_manager_get_shared_data_path(const char *app_id, char **path) { int r; diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt new file mode 100644 index 0000000..9b5d16b --- /dev/null +++ b/tool/CMakeLists.txt @@ -0,0 +1,21 @@ +# Test executables + +#Verbose +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs_test REQUIRED glib-2.0) +FOREACH(flag ${pkgs_test_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" ) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_C_FLAGS_RELEASE "-O2") + +ADD_EXECUTABLE(appmgr_tool main.c) +TARGET_LINK_LIBRARIES(appmgr_tool capi-appfw-app-manager ${pkgs_test_LDFLAGS}) +INSTALL(TARGETS appmgr_tool DESTINATION bin) + diff --git a/tool/main.c b/tool/main.c new file mode 100755 index 0000000..fba4867 --- /dev/null +++ b/tool/main.c @@ -0,0 +1,104 @@ +/* +Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +PROPRIETARY/CONFIDENTIAL +This software is the confidential and proprietary information of +SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that +this software is owned by Samsung and you +shall not disclose such Confidential Information and shall +use it only in accordance with the terms of the license agreement +you entered into with SAMSUNG ELECTRONICS. SAMSUNG make no +representations or warranties about the suitability +of the software, either express or implied, including but not +limited to the implied warranties of merchantability, fitness for +a particular purpose, or non-infringement. +SAMSUNG shall not be liable for any damages suffered by licensee arising out of or +related to this software. +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include + + + +static void _print_help(const char *cmd) +{ + fprintf(stderr, "Usage:\n"); + fprintf(stderr, "\n"); + fprintf(stderr, "[Get appinfo value]\n"); + fprintf(stderr, " %s \n", cmd); + fprintf(stderr, "\n"); + fprintf(stderr, "Ex) %s com.samsung.memo\n", cmd); + fprintf(stderr, "\n"); +} + + + +static int _get_appinfo(const char *app_id) +{ + app_info_h app_info; + int ret; + char *appid = NULL; + char *label = NULL; + char *icon = NULL; + char *package = NULL; + char *type = NULL; + + ret = app_manager_get_app_info(app_id, &app_info); + if (ret != APP_MANAGER_ERROR_NONE) { + fprintf(stderr, "No corresponding app_id for [%s]\n", app_id); + return APP_MANAGER_ERROR_NO_SUCH_APP; + } + + app_info_get_app_id(app_info, &appid); + app_info_get_label(app_info, &label); + app_info_get_icon(app_info, &icon); + app_info_get_package(app_info, &package); + app_info_get_type(app_info, &type); + + fprintf(stderr, "appid = [%s]\n", appid); + fprintf(stderr, "label = [%s]\n", label); + fprintf(stderr, "icon = [%s]\n", icon); + fprintf(stderr, "package = [%s]\n", package); + fprintf(stderr, "type = [%s]\n", type); + + ret = app_info_destroy(app_info); + if (ret != APP_MANAGER_ERROR_NONE) { + return APP_MANAGER_ERROR_IO_ERROR; + } + + free(appid); + free(label); + free(icon); + free(package); + free(type); + + return APP_MANAGER_ERROR_NONE; +} + +int main(int argc, char** argv) +{ + int ret = APP_MANAGER_ERROR_NONE; + + if (2 == argc) { + ret = _get_appinfo(argv[1]); + } + else { + _print_help(argv[0]); + return EXIT_FAILURE; + } + + if (ret != APP_MANAGER_ERROR_NONE) { + fprintf(stderr, "There are some problems\n"); + } + + return EXIT_SUCCESS; +} + + -- 2.7.4