#ifndef __SHORTCUT_H__
#define __SHORTCUT_H__
+#include <tizen.h>
+#include <shortcut_manager.h>
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * @addtogroup APPLICATION_FRAMEWORK
- * @{
+ * @file shortcut.h
+ * @brief This file declares the API of the libshortcut library.
*/
/**
- * @defgroup SHORTCUT Add to home (shortcut)
- * @version 0.1
- * @brief To enhance the Add to home feature. Two types of API set are supported.
- * One for the homescreen developers.
- * The others for the application developers who should implement the Add to home feature.
+ * @addtogroup SHORTCUT_MODULE
+ * @{
*/
-struct shortcut_icon;
/**
- * @brief This function prototype is used to define a callback function for the add_to_home reqeust.
- * The homescreen should define a callback as this type and implementing the service code
+ * @internal
+ * @brief Called to the add_to_home request.
+ * @details The homescreen should define a callback as this type and implement the service code
* for adding a new application shortcut.
- * @param[in] appid Shortcut is added for this package.
- * @param[in] name Name for created shortcut icon.
- * @param[in] type 3 kinds of types are defined.
- * @param[in] content_info Specific information for creating a new shortcut.
- * @param[in] icon Absolute path of an icon file for this shortcut.
- * @param[in] pid Process ID of who request add_to_home.
- * @param[in] allow_duplicate 1 if shortcut can be duplicated or a shourtcut should be exists only one.
- * @param[in] data Callback data.
- * @return int Developer should returns the result of handling shortcut creation request.
- * Returns 0, if succeed to handles the add_to_home request, or returns proper errno.
- * @see shortcut_set_request_cb
- * @pre None
- * @post None
- * @remarks None
+ * @since_tizen 2.3
+ * @param[in] appid The shortcut that is added for this package
+ * @param[in] name The name of the created shortcut icon
+ * @param[in] type One of the three defined types
+ * @param[in] content_info The specific information for creating a new shortcut
+ * @param[in] icon The absolute path of an icon file for this shortcut
+ * @param[in] pid The process ID of who request add_to_home
+ * @param[in] allow_duplicate @c 1 if the shortcut can be duplicated,
+ * otherwise a shourtcut should exist only once
+ * @param[in] data The callback data
+ * @return The result of handling a shortcut creation request\n
+ * This returns @c 0 if the add_to_home request is handled successfully,
+ * otherwise it returns a proper errno.
+ * @see shortcut_set_request_cb()
*/
typedef int (*request_cb_t)(const char *appid, const char *name, int type, const char *content_info, const char *icon, int pid, double period, int allow_duplicate, void *data);
/**
- * @brief This function prototype is used to define for receiving the result of add_to_home.
- * @param[in] ret Result value, it could be 0 if succeed to add a shortcut, or errno.
- * @param[in] pid Process ID of who handles this add_to_home request.
- * @param[in] data Callback data.
- * @return int Returns 0, if there is no error or returns errno.
+ * @brief Called to receive the result of add_to_home_shortcut().
+ * @since_tizen 2.3
+ * @param[in] ret The result value, it could be @c 0 if it succeeds to add a shortcut,
+ * otherwise it returns an errno
+ * @param[in] pid The process ID of who handle this add_to_home request
+ * @param[in] data The callback data
+ * @return int @c 0 if there is no error,
+ otherwise errno
* @see add_to_home_shortcut()
- * @pre None
- * @post None
- * @remarks None
*/
-typedef int (*result_cb_t)(int ret, int pid, void *data);
+typedef int (*result_internal_cb_t)(int ret, int pid, void *data);
/**
- * @brief After send a request to create a icon snapshot image, this callback will be called with its result.
- * @param[in] handle Handle of requestor
- * @param[in] ret status of request
- * @param[in] data Callback data
- * @return int result state of callback call
- * @retval 0 If it is successfully completed
- * @see shortcut_icon_request_send()
- * @pre None
- * @post None
- * @remarks None
+ * @brief Enumeration for shortcut types.
+ * @details Basically, three types of shortcuts are defined.
+ * Every homescreen developer should support these types of shortcuts.
+ * Or return a proper errno to figure out why the application failed to add a shortcut.
+ * #LAUNCH_BY_PACKAGE is used for adding a package itself as a shortcut.
+ * #LAUNCH_BY_URI is used for adding a shortcut for "uri" data.
+ * @since_tizen 2.3
*/
-typedef int (*icon_request_cb_t)(struct shortcut_icon *handle, int ret, void *data);
+enum shortcut_internal_type {
+ /**< Deprecated type */
+ SHORTCUT_PACKAGE = 0x00000000, /**< Launch the package using the given package name */
+ SHORTCUT_DATA = 0x00000001, /**< Launch the related package with the given data(content_info) */
+ SHORTCUT_FILE = 0x00000002, /**< Launch the related package with the given filename(content_info) */
+
+ LAUNCH_BY_PACKAGE = 0x00000000,
+
+ SHORTCUT_REMOVE = 0x40000000, /**< Remove a shortcut */
+ LIVEBOX_REMOVE = 0x80000000, /**< Remove a livebox */
+
+ LIVEBOX_TYPE_DEFAULT = 0x10000000, /**< Type mask for the default livebox */
+ LIVEBOX_TYPE_EASY_DEFAULT = 0x30000000, /**< Type mask for the easy mode livebox */
+ LIVEBOX_TYPE_1x1 = 0x10010000, /**< 1x1 */
+ LIVEBOX_TYPE_2x1 = 0x10020000, /**< 2x1 */
+ LIVEBOX_TYPE_2x2 = 0x10040000, /**< 2x2 */
+ LIVEBOX_TYPE_4x1 = 0x10080000, /**< 4x1 */
+ LIVEBOX_TYPE_4x2 = 0x10100000, /**< 4x2 */
+ LIVEBOX_TYPE_4x3 = 0x10200000, /**< 4x3 */
+ LIVEBOX_TYPE_4x4 = 0x10400000, /**< 4x4 */
+ LIVEBOX_TYPE_4x5 = 0x11000000, /**< 4x5 */
+ LIVEBOX_TYPE_4x6 = 0x12000000, /**< 4x6 */
+ LIVEBOX_TYPE_EASY_1x1 = 0x30010000, /**< Easy mode 1x1 */
+ LIVEBOX_TYPE_EASY_3x1 = 0x30020000, /**< Easy mode 3x2 */
+ LIVEBOX_TYPE_EASY_3x3 = 0x30040000, /**< Easy mode 3x3 */
+ LIVEBOX_TYPE_UNKNOWN = 0x1FFF0000, /**< Error */
+};
/**
- * @brief Basically, three types of shortcut is defined.
- * Every homescreen developer should support these types of shortcut.
- * Or returns proper errno to figure out why the application failed to add a shortcut.
- * LAUNCH_BY_PACKAGE is used for adding a package itself as a shortcut
- * LAUNCH_BY_URI is used for adding a shortcut for "uri" data.
+ * @brief Enumeration for values of shortcut response types.
+ * @since_tizen 2.3
*/
-//! [Enumeration values for type of shortcuts]
-enum shortcut_type {
- /*!< Deprecated type */
- SHORTCUT_PACKAGE = 0x00000000, /*!< Launch the package using given pakcage name. */
- SHORTCUT_DATA = 0x00000001, /*!< Launch the related package with given data(content_info). */
- SHORTCUT_FILE = 0x00000002, /*!< Launch the related package with given filename(content_info). */
-
- /*!< Use these */
- LAUNCH_BY_PACKAGE = 0x00000000, /*!< Launch the package using given pakcage name. */
- LAUNCH_BY_URI = 0x00000001, /*!< Launch the related package with given data(URI). */
-
- SHORTCUT_REMOVE = 0x40000000, /*!< Remove a shortcut */
- LIVEBOX_REMOVE = 0x80000000, /*!< Remove a livebox */
-
- LIVEBOX_TYPE_DEFAULT = 0x10000000, /*!< Type mask for default livebox */
- LIVEBOX_TYPE_EASY_DEFAULT = 0x30000000, /*!< Type mask for easy mode livebox */
- LIVEBOX_TYPE_1x1 = 0x10010000, /*!< 1x1 */
- LIVEBOX_TYPE_2x1 = 0x10020000, /*!< 2x1 */
- LIVEBOX_TYPE_2x2 = 0x10040000, /*!< 2x2 */
- LIVEBOX_TYPE_4x1 = 0x10080000, /*!< 4x1 */
- LIVEBOX_TYPE_4x2 = 0x10100000, /*!< 4x2 */
- LIVEBOX_TYPE_4x3 = 0x10200000, /*!< 4x3 */
- LIVEBOX_TYPE_4x4 = 0x10400000, /*!< 4x4 */
- LIVEBOX_TYPE_4x5 = 0x11000000, /*!< 4x5 */
- LIVEBOX_TYPE_4x6 = 0x12000000, /*!< 4x6 */
- LIVEBOX_TYPE_EASY_1x1 = 0x30010000, /*!< Easy mode 1x1 */
- LIVEBOX_TYPE_EASY_3x1 = 0x30020000, /*!< Easy mode 3x2 */
- LIVEBOX_TYPE_EASY_3x3 = 0x30040000, /*!< Easy mode 3x3 */
- LIVEBOX_TYPE_UNKNOWN = 0x1FFF0000 /*!< Error */
-};
-//! [Enumeration values for type of shortcuts]
-
-enum shortcut_response {
- SHORTCUT_SUCCESS = 0x00000000, /*!< Successfully handled */
- SHORTCUT_ERROR = 0x80000000, /*!< MSB(1). Check this using SHORTCUT_STATUS_IS_ERROR macro */
- SHORTCUT_ERROR_NO_SPACE = SHORTCUT_ERROR | 0x0001, /*!< There is no space to add new shortcut */
- SHORTCUT_ERROR_EXIST = SHORTCUT_ERROR | 0x0002, /*!< Shortcut is already added */
- SHORTCUT_ERROR_FAULT = SHORTCUT_ERROR | 0x0004, /*!< Failed to add a shortcut. Unrecoverable error */
- SHORTCUT_ERROR_UNSUPPORTED = SHORTCUT_ERROR | 0x0008, /*!< Unsupported shortcut */
- SHORTCUT_ERROR_BUSY = SHORTCUT_ERROR | 0x0010, /*!< Receiver is busy, try again later */
- SHORTCUT_ERROR_INVALID = SHORTCUT_ERROR | 0x0020, /*!< Shortcut request is not valid, invalid parameter or invalid argument value */
- SHORTCUT_ERROR_COMM = SHORTCUT_ERROR | 0x0040, /*!< Connection is not estabilished. or there is a problem of communication */
- SHORTCUT_ERROR_MEMORY = SHORTCUT_ERROR | 0x0080, /*!< Memory is not enough to handle new request */
- SHORTCUT_ERROR_IO = SHORTCUT_ERROR | 0x0100, /*!< Unable to access file or DB. Check your resource files */
- SHORTCUT_ERROR_PERMISSION = SHORTCUT_ERROR | 0x0200, /*!< Has no permission to add a shortcut */
-
- SHORTCUT_STATUS_CARED = 0x08000000 /*!< Shortcut status is already cared. check this using SHORTCUT_STATUS_IS_CARED macro */
+enum shortcut_internal_error_e {
+ SHORTCUT_ERROR = 0x80000000, /**< MSB(1). Check this using the #SHORTCUT_STATUS_IS_ERROR macro */
+
+ SHORTCUT_STATUS_CARED = 0x08000000, /**< Shortcut status is already cared. Check this using the #SHORTCUT_STATUS_IS_CARED macro */
+
+ SHORTCUT_ERROR_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Receiver is busy, try again later */
+ SHORTCUT_ERROR_UNSUPPORTED = SHORTCUT_ERROR | 0x0400 /**< Shortcut is not supported */
};
-/*!
- * \brief Macro function for checking the type
- * \param[in] type Type of box
- * \return bool
- * \retval true(1) If it is a livebox
- * \retval false(0) if it is not a livebox
- * \see shortcut_type
- * \pre None
- * \post None
- * \remarks None
+/**
+ * @brief Definition for a macro to check type.
+ * @since_tizen 2.3
+ * @param[in] type The type of box
+ * @return bool
+ * @retval true(1) If it is a livebox
+ * @retval false(0) If it is not a livebox
+ * @see shortcut_type
*/
#define ADD_TO_HOME_IS_LIVEBOX(type) (!!((type) & 0x10000000))
-/*!
- * \brief Macro function for checking the request type
- * \param[in] type Request type
- * \return bool
- * \retval true(1) Shortcut remove request
- * \retval false(0) Not a remove request
- * \see shortcut_type
- * \pre None
- * \post None
- * \remarks None
- */
-#define ADD_TO_HOME_IS_REMOVE_SHORTCUT(type) (!!((type) & SHORTCUT_REMOVE))
-
-/*!
- * \brief Macro function for checking the request type
- * \param[in] type Request type
- * \return bool
- * \retval true(1) Livebox remove request
- * \retval false(0) Not a remove request
- * \see shortcut_type
- * \pre None
- * \post None
- * \remarks None
- */
-#define ADD_TO_HOME_IS_REMOVE_LIVEBOX(type) (!!((type) & LIVEBOX_REMOVE))
-
-/*!
- * \brief Macro function for checking the status of request
- * \param[in] type Status
- * \return bool
- * \retval true(1) Error
- * \retval false(0) Not an error
- * \see shortcut_response
- * \pre None
- * \post None
- * \remarks None
+/**
+ * @brief Definition for a macro to check the request status.
+ * @since_tizen 2.3
+ * @param[in] type The status
+ * @return bool
+ * @retval true(1) Error
+ * @retval false(0) Not an error
+ * @see shortcut_error_e
*/
#define SHORTCUT_STATUS_IS_ERROR(type) (!!((type) & SHORTCUT_ERROR))
-/*!
- * \brief Macro function for checking the status of request
- * \param[in] type Status
- * \return bool
- * \retval true(1) Shortcut request is already handled by requestee (homescreen, viewer, ...)
- * \retval false(0) Request result should be cared by requestor
- * \see shortcut_response
- * \pre None
- * \post None
- * \remarks None
+/**
+ * @brief Definition for a macro to check the request status.
+ * @since_tizen 2.3
+ * @param[in] type The status
+ * @return bool
+ * @retval true(1) Shortcut request is already handled by the requestee (homescreen, viewer, ...)
+ * @retval false(0) Request result should be cared by the requestor
+ * @see shortcut_error_e
*/
#define SHORTCUT_STATUS_IS_CARED(type) (!!((type) & SHORTCUT_STATUS_CARED))
-/*!
- * \brief Filtering the pure error code from given status
- * \param[in] status status
- * \return status code (error)
- * \see shortcut_response
- * \pre None
- * \post None
- * \remarks None
- *
+/**
+ * @brief Definition for filtering the pure error code from the given status.
+ * @since_tizen 2.3
+ * @param[in] status The status
+ * @return The status code (error)
+ * @see shortcut_error_e
*/
#define SHORTCUT_ERROR_CODE(status) ((status) & ~SHORTCUT_STATUS_CARED)
/**
- * @fn int shortcut_set_request_cb(request_cb_t request_cb, void *data)
*
- * @brief Homescreen should use this function to service the shortcut creating request.
+ * @internal
+ *
+ * @brief Supports the shortcut creating request.
*
- * @par Sync (or) Async:
+ * @details
+ * Sync (or) Async:
* This is an asynchronous API.
*
- * @par Important Notes:
- * - Should be used from the homescreen.
- * - Should check the return value of this function
+ * Important Notes: \n
+ * Should be used from the homescreen.\n
+ * Should check the return value of this function.
*
- * @param[in] request_cb Callback function pointer which will be invoked when add_to_home is requested.
- * @param[in] data Callback data to deliver to the callback function.
+ * Prospective Clients:
+ * Homescreen.
*
- * @return Return Type (int)
- * - 0 - callback function is successfully registered
- * - < 0 - Failed to register the callback function for request.
+ * @since_tizen 2.3
*
- * @see request_cb_t
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/shortcut
*
- * @pre - You have to prepare a callback function
+ * @param[in] request_cb The callback function pointer that is invoked when add_to_home is requested
+ * @param[in] data The callback data to deliver to the callback function
*
- * @post - If a request is sent from the application, the registered callback will be invoked.
+ * @return The return type (int)
+ * @retval 0 Callback function is successfully registered
+ * @retval <0 Failed to register the callback function for the request
*
- * @remarks - None
+ * @pre You have to prepare a callback function.
*
- * @par Prospective Clients:
- * Homescreen
+ * @post If a request is sent from the application, the registered callback will be invoked.
*
+ * @see request_cb_t
* @par Example
* @code
* #include <shortcut.h>
extern int shortcut_set_request_cb(request_cb_t request_cb, void *data);
/**
- * @fn add_to_home_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data)
*
- * @brief The application, which supporting the add_to_home feature, should invoke this.
+ * @brief Supports the add_to_home feature, should invoke this.
*
- * @par Sync (or) Async:
+ * @details
+ * Sync (or) Async:
* This is an asynchronous API.
*
- * @par Important Notes:
- * - Application must check the return value of this function.
- * - Application must check the return status from the callback function
- * - Application should set the callback function to get the result of this request.
+ * Important Notes:\n
+ * Application must check the return value of this function.\n
+ * Application must check the return status from the callback function.\n
+ * Application should set the callback function to get the result of this request.
*
- * @param[in] appid Package name of owner of this shortcut.
- * @param[in] name Name for created shortcut icon.
- * @param[in] type Type of shortcuts (livebox or shortcut, and its size if it is for the livebox)
- * @param[in] content_info Specific information for delivering to the viewer for creating a shortcut.
- * @param[in] icon Absolute path of an icon file
- * @param[in] allow_duplicate set 1 If accept the duplicated shortcut or 0
- * @param[in] result_cb Address of callback function which will be called when the result comes back from the viewer.
- * @param[in] data Callback data which will be used in callback function
+ * Prospective Clients:
+ * Inhouse Apps.
*
- * @return Return Type (int)
- * \retval 0 Succeed to send the request
- * \retval SHORTCUT_ERROR_FAULT Unrecoverable error
- * \retval SHORTCUT_ERROR_INVALID Shortcut request is not valid, invalid parameter or invalid argument value
- * \retval SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem of communication
- * \retval SHORTCUT_ERROR_MEMORY Memory is not enough to handle new request
- * \retval SHORTCUT_ERROR_IO Unable to access file or DB. Check your resource files
- * \retval SHORTCUT_ERROR_PERMISSION Has no permission to add a shortcut
+ * @since_tizen 2.3
*
- * @see result_cb_t
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/shortcut
*
- * @pre You have to prepare the callback function
+ * @remarks If a homescreen does not support this feature, you will get a proper error code.
+ * @param[in] appid The package name of the owner of this shortcut
+ * @param[in] name The name of the created shortcut icon
+ * @param[in] type The type of shortcuts (livebox or shortcut, and its size if it is for the livebox)
+ * @param[in] content_info The specific information for delivering to the viewer for creating a shortcut
+ * @param[in] icon The absolute path of an icon file
+ * @param[in] allow_duplicate @c 1 if it accepts the duplicated shortcut,
+ * otherwise @c 0
+ * @param[in] result_cb The address of the callback function that is called when the result comes back from the viewer
+ * @param[in] data The callback data that is used in the callback function
*
- * @post You have to check the return status from callback function which is passed by argument.
+ * @return The return type (int)
+ * @retval 0 Succeeded to send the request
+ * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error
+ * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value
+ * @retval #SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem in the communication
+ * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle a new request
+ * @retval #SHORTCUT_ERROR_IO_ERROR Unable to access the file or DB. Check your resource files
+ * @retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut
+ * @retval #SHORTCUT_ERROR_NOT_SUPPORTED Shortcut is not supported
*
- * @remarks - If a homescreen does not support this feature, you will get proper error code.
+ * @pre You have to prepare the callback function.
*
- * @par Prospective Clients:
- * Inhouse Apps.
+ * @post You have to check the return status from the callback function which is passed by the argument.
+ *
+ * @see result_internal_cb_t
*
* @par Example
* @code
*
* @endcode
*/
-extern int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data);
+extern int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content_info, const char *icon, int allow_duplicate, result_internal_cb_t result_cb, void *data);
/**
- * @fn shortcut_get_list(const char *appid, int (*cb)(const char *appid, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data), void *data)
*
- * @brief Getting the installed shortcut view list
+ * @internal
+ *
+ * @brief Gets the installed shortcut view list.
*
- * @par Sync (or) Async:
+ * @details
+ * Sync (or) Async:
* This is a synchronous API.
*
- * @par Important Notes:
- * - Application must check the return value of this function.
- * - Application must check the return status from the callback function
- * - Application should set the callback function to get the result of this request.
+ * Important Notes:\n
+ * Application must check the return value of this function.\n
+ * Application must check the return status from the callback function.\n
+ * Application should set the callback function to get the result of this request.
*
- * @param[in] appid Package name
- * @param[in] cb Callback function to get the shortcut item information
- * @param[in] data Callback data which will be used in callback function
+ * Prospective Clients:
+ * Inhouse Apps.
*
- * @return Return Type (int)
- * \retval Number of items (call count of callback function)
- * \retval SHORTCUT_ERROR_FAULT Unrecoverable error
- * \retval SHORTCUT_ERROR_IO Unable to access file or DB. Check your resource files
+ * @since_tizen 2.3
*
- * @see result_cb_t
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/shortcut
*
- * @pre You have to prepare the callback function
+ * @remarks If a homescreen does not support this feature, you will get a proper error code.
+ * @param[in] appid The package name
+ * @param[in] cb The callback function to get the shortcut item information
+ * @param[in] data The callback data that is used in the callback function
*
- * @post You have to check the return status from callback function which is passed by argument.
+ * @return The return type (int)
+ * @retval @c N Number of items (call count of the callback function)
+ * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error
+ * @retval #SHORTCUT_ERROR_IO_ERROR Unable to access the file or DB. Check your resource files
*
- * @remarks - If a homescreen does not support this feature, you will get proper error code.
+ * @pre You have to prepare the callback function.
*
- * @par Prospective Clients:
- * Inhouse Apps.
+ * @post You have to check the return status from the callback function which is passed by the argument.
*
- * @par Example
- * @code
- * @endcode
+ * @see result_internal_cb_t
*/
extern int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *data), void *data);
/**
- * @fn add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_cb_t result_cb, void *data);
*
- * @brief The application, which supporting the add_to_home feature, should invoke this.
*
- * @par Sync (or) Async:
+ * @brief Supports the add_to_home feature, should invoke this.
+ *
+ * @details
+ * Sync (or) Async:
* This is an asynchronous API.
*
- * @par Important Notes:
- * - Application must check the return value of this function.
- * - Application must check the return status from the callback function
- * - Application should set the callback function to get the result of this request.
+ * Important Notes:\n
+ * Application must check the return value of this function.\n
+ * Application must check the return status from the callback function.\n
+ * Application should set the callback function to get the result of this request.
*
- * @param[in] appid Package name of owner of this shortcut.
- * @param[in] name Name for created shortcut icon.
- * @param[in] type Type of shortcuts (livebox or shortcut, and its size if it is for the livebox)
- * @param[in] content_info Specific information for delivering to the viewer for creating a shortcut.
- * @param[in] icon Absolute path of an icon file
- * @param[in] period Update period
- * @param[in] allow_duplicate set 1 If accept the duplicated shortcut or 0
- * @param[in] result_cb Address of callback function which will be called when the result comes back from the viewer.
- * @param[in] data Callback data which will be used in callback function
+ * Prospective Clients:
+ * Inhouse Apps.
*
- * @return Return Type (int)
- * \retval 0 Succeed to send the request
- * \retval SHORTCUT_ERROR_FAULT Unrecoverable error
- * \retval SHORTCUT_ERROR_INVALID Shortcut request is not valid, invalid parameter or invalid argument value
- * \retval SHORTCUT_ERROR_COMM Connection is not estabilished. or there is a problem of communication
- * \retval SHORTCUT_ERROR_MEMORY Memory is not enough to handle new request
- * \retval SHORTCUT_ERROR_IO Unable to access file or DB. Check your resource files
- * \retval SHORTCUT_ERROR_PERMISSION Has no permission to add a shortcut
+ * @since_tizen 2.3
*
- * @see result_cb_t
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/shortcut
*
- * @pre You have to prepare the callback function
+ * @remarks If a homescreen does not support this feature, you will get a proper error code.
+ * @param[in] appid The package name of the owner of this shortcut
+ * @param[in] name The name of the created shortcut icon
+ * @param[in] type The type of shortcuts (livebox or shortcut, and its size if it is for the livebox)
+ * @param[in] content_info The specific information for delivering to the viewer for creating a shortcut
+ * @param[in] icon The absolute path of an icon file
+ * @param[in] period The update period
+ * @param[in] allow_duplicate @c 1 if it accepts the duplicated shortcut,
+ * otherwise @c 0
+ * @param[in] result_cb The address of the callback function that is called when the result comes back from the viewer
+ * @param[in] data The callback data that is used in the callback function
*
- * @post You have to check the return status from callback function which is passed by argument.
+ * @return The return type (int)
+ * @retval 0 Succeeded to send the request
+ * @retval #SHORTCUT_ERROR_FAULT Unrecoverable error
+ * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Shortcut request is not valid, invalid parameter or invalid argument value
+ * @retval #SHORTCUT_ERROR_COMM Connection is not established or there is a problem in the communication
+ * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle a new request
+ * @retval #SHORTCUT_ERROR_IO_ERROR Unable to access the file or DB Check your resource files
+ * @retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut
+ * @retval #SHORTCUT_ERROR_NOT_SUPPORTED Shortcut is not supported
*
- * @remarks - If a homescreen does not support this feature, you will get proper error code.
+ * @pre You have to prepare the callback function.
*
- * @par Prospective Clients:
- * Inhouse Apps.
+ * @post You have to check the return status from the callback function which is passed by the argument.
+ *
+ * @see result_internal_cb_t
*
* @par Example
* @code
*
* @endcode
*/
-extern int add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_cb_t result_cb, void *data);
-
-extern int add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_cb_t result_cb, void *data);
-
-extern int add_to_home_remove_livebox(const char *appid, const char *name, result_cb_t result_cb, void *data);
-
+extern int add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_internal_cb_t result_cb, void *data);
+struct shortcut_icon;
-/*!
- * \note
- * Example)
- *
- * \code
- * static int init_cb(int status, void *data)
- * {
- * printf("Initializer returns: %d\n", status);
- * if (status == 0) {
- * printf("Succeed to initialize\n");
- * } else {
- * printf("Failed to initialize: %d\n", status);
- * }
- * }
- *
- * int main(int argc, char *argv[])
- * {
- * // Initialize the service request
- * int ret;
- *
- * // After the init_cb is called, you can use below functions.
- * struct shortcut_icon *handle;
- *
- * ret = shortcut_icon_init(init_cb, NULL);
- * if (ret < 0) {
- * ...
- *
- * // Create request for creating shortcut icon.
- * handle = shortcut_icon_create();
- * if (!handle) {
- * ...
- * }
- *
- * // Send the request to the shortcut service
- * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, "icon, "/usr/share/.../icon.png", NULL, NULL);
- * if (ret < 0) {
- * ...
- * }
- *
- * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, "text, "app icon", NULL, NULL);
- * if (ret < 0) {
- * ...
- * }
- *
- * ret = shortcut_icon_request_send(handle, LB_SIZE_TYPE_1x1, NULL, NULL, "/opt/usr/apps/org.tizen.cluster-home/data/out.png", result_cb, NULL);
- * if (ret < 0) {
- * ...
- * }
- *
- * ret = shortcut_icon_request_destroy(handle);
- * if (ret < 0) {
- * ...
- * }
- *
- * // Don't finalize the icon service if you don't get result callbacks of all requests
- * ret = shortcut_icon_fini();
- * if (ret < 0) {
- * ...
- * }
- *
- * return 0;
- * }
- * \endcode
+/**
+ * @brief Called when send a request to create a icon snapshot image.
+ * @details This callback will be called with its result.
+ * @param[in] handle Handle of requestor
+ * @param[in] ret status of request
+ * @param[in] data Callback data
+ * @return int result state of callback call
+ * @retval 0 If it is successfully completed
+ * @see shortcut_icon_request_send()
*/
+typedef int (*icon_request_cb_t)(struct shortcut_icon *handle, int ret, void *data);
#define DEFAULT_ICON_PART "icon"
#define DEFAULT_NAME_PART "name"
#define SHORTCUT_ICON_TYPE_TEXT "text"
#define SHORTCUT_ICON_TYPE_SCRIPT "script"
-/*!
- * \brief Initialize the icon creation service
- * \remarks N/A
- * \details N/A
- * \param[in] init_cb Initialized result will be delievered via this callback
- * \param[in] data Callback data
- * \pre N/A
- * \post N/A
- * \return int
- * \retval SHORTCUT_ERROR_INVALID Already initialized
- * \retval SHORTCUT_ERROR_SUCCESS Successfully initialized
- * \see shortcut_icon_service_fini
+/**
+ * @brief Initializes the icon creation service.
+ * @param[in] init_cb Initialized result will be delievered via this callback
+ * @param[in] data Callback data
+ * @return int value
+ * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Already initialized
+ * @retval #SHORTCUT_ERROR_NONE Successfully initialized
+ * @see shortcut_icon_service_fini()
*/
extern int shortcut_icon_service_init(int (*init_cb)(int status, void *data), void *data);
-/*!
- * \brief Finalize the icon creation service
- * \remarks N/A
- * \details N/A
- * \pre N/A
- * \post N/A
- * \return int
- * \retval SHORTCUT_SUCCESS Successfully initialized
- * \retval SHORTCUT_ERROR_INVALID icon service is not initialized
- * \see shortcut_icon_service_init
+/**
+ * @brief Finalizes the icon creation service.
+ * @return int value
+ * @retval #SHORTCUT_ERROR_NONE Successfully initialized
+ * @retval #SHORTCUT_ERROR_INVALID_PARAMETER icon service is not initialized
+ * @see shortcut_icon_service_init()
*/
extern int shortcut_icon_service_fini(void);
-/*!
- * \brief Create a request object to create a new icon image
- * \remarks N/A
- * \details N/A
- * \pre N/A
- * \post N/A
- * \return struct shortcut_icon *
- * \retval NULL If it fails to create a new handle
- * \retval pointer Handle address
- * \see shortcut_icon_request_destroy
+/**
+ * @brief Creates a request object to create a new icon image.
+ * @return struct shortcut_icon * value
+ * @retval @c NULL If it fails to create a new handle
+ * @retval pointer Handle address
+ * @see shortcut_icon_request_destroy()
*/
extern struct shortcut_icon *shortcut_icon_request_create(void);
-/*!
- * \brief Set infomration for creating icon image
- * \details N/A
- * \remarks N/A
- * \param[in] handle Request handle
- * \param[in] id Target ID to be affected by this data
- * \param[in] type SHORTCUT_ICON_TYPE_IMAGE, SHORTCUT_ICON_TYPE_TEXT, SHORTCUT_ICON_TYPE_SCRIPT can be used
- * \param[in] part Target part to be affect by this data
- * \param[in] data type == IMAGE ? Image file path : type == TEXT ? text string : type == SCRIPT ? script file path : N/A
- * \param[in] option Image load option or group name of script file to be loaded
- * \param[in] subid ID for script. this ID will be used as "id"
- * \pre N/A
- * \post N/A
- * \return int
- * \retval Index of data set
- * \retval SHORTCUT_ERROR_INVALID Invalid handle
- * \retval SHORTCUT_ERROR_MEMORY Out of memory
- * \see shortcut_icon_request_create
+/**
+ * @brief Sets information for creating icon image.
+ * @param[in] handle Request handle
+ * @param[in] id Target ID to be affected by this data
+ * @param[in] type SHORTCUT_ICON_TYPE_IMAGE, SHORTCUT_ICON_TYPE_TEXT, SHORTCUT_ICON_TYPE_SCRIPT can be used
+ * @param[in] part Target part to be affect by this data
+ * @param[in] data type == IMAGE ? Image file path : type == TEXT ? text string : type == SCRIPT ? script file path : N/A
+ * @param[in] option Image load option or group name of script file to be loaded
+ * @param[in] subid ID for script. this ID will be used as "id"
+ * @return int value
+ * @retval index Index of data set
+ * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid handle
+ * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see shortcut_icon_request_create()
*/
extern int shortcut_icon_request_set_info(struct shortcut_icon *handle, const char *id, const char *type, const char *part, const char *data, const char *option, const char *subid);
-/*!
- * \brief Send request to create an icon image
- * \remarks N/A
- * \details N/A
- * \param[in] handle Icon request handle
- * \param[in] size_type Size type to be created
- * \param[in] layout layout filename (edje filename)
- * \param[in] group group name
- * \param[in] outfile output image filename
- * \param[in] result_cb Result callback
- * \param[in] data Callback data
- * \pre N/A
- * \post N/A
- * \return int
- * \retval SHORTCUT_ERROR_INVALID Invalid parameters
- * \retval SHORTCUT_ERROR_MEMORY Out of memory
- * \retval SHORTCUT_ERROR_FAULT Failed to send a request
- * \retval SHORTCUT_SUCCESS Successfully sent
- * \see shortcut_icon_service_fini
+/**
+ * @brief Sends requests to create an icon image.
+ * @param[in] handle Icon request handle
+ * @param[in] size_type Size type to be created
+ * @param[in] layout Layout filename (edje filename)
+ * @param[in] group Group name
+ * @param[in] outfile Output image filename
+ * @param[in] result_cb Result callback
+ * @param[in] data Callback data
+ * @return int value
+ * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid parameters
+ * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #SHORTCUT_ERROR_FAULT Failed to send a request
+ * @retval #SHORTCUT_ERROR_NONE Successfully sent
+ * @see shortcut_icon_service_fini()
*/
extern int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type, const char *layout, const char *group, const char *outfile, icon_request_cb_t result_cb, void *data);
-/*!
- * \brief Destroy handle of creating shortcut icon request
- * \remarks N/A
- * \details N/A
- * \param[in] handle Shortcut request handle
- * \pre N/A
- * \post N/A
- * \return int
- * \retval SHORTCUT_ERROR_INVALID Invalid handle
- * \retval SHORTCUT_SUCCESS Successfully destroyed
- * \see shortcut_icon_service_fini
+/**
+ * @brief Destroys handle of creating shortcut icon request.
+ * @param[in] handle Shortcut request handle
+ * @return int value
+ * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid handle
+ * @retval #SHORTCUT_ERROR_NONE Successfully destroyed
+ * @see shortcut_icon_service_fini()
*/
extern int shortcut_icon_request_destroy(struct shortcut_icon *handle);
-/*!
- * \brief Set private data to the handle to carry it with a handle.
- * \remarks N/A
- * \details N/A
- * \param[in] handle Handle to be used for carrying a data
- * \param[in] data Private data
- * \pre N/A
- * \post N/A
- * \return int
- * \retval SHORTCUT_ERROR_INVALID Invalid handle
- * \retval SHORTCUT_SUCCESS Successfully done
- * \see shortcut_icon_service_fini
+/**
+ * @brief Sets private data to the handle to carry it with a handle.
+ * @param[in] handle Handle to be used for carrying a data
+ * @param[in] data Private data
+ * @return int value
+ * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid handle
+ * @retval #SHORTCUT_ERROR_NONE Successfully done
+ * @see shortcut_icon_service_fini()
*/
extern int shortcut_icon_request_set_data(struct shortcut_icon *handle, void *data);
-/*!
- * \brief Get the private data from handle
- * \remarks N/A
- * \details N/A
- * \param[in] handle
- * \pre N/A
- * \post N/A
- * \return int
- * \retval NULL If there is no data
- * \retval pointer data pointer
- * \see shortcut_icon_request_set_data
+/**
+ * @brief Gets the private data from handle.
+ * @param[in] handle
+ * @return int value
+ * @retval @c NULL If there is no data
+ * @retval pointer data pointer
+ * @see shortcut_icon_request_set_data()
*/
extern void *shortcut_icon_request_data(struct shortcut_icon *handle);
+/**
+ * @}
+ */
+
#ifdef __cplusplus
}
#endif
#endif
-/* @}
- * End of a file
- */
FILE *fp;
if (!handle) {
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
fp = fopen(filename, "w+t");
if (!fp) {
ErrPrint("Error: %s\n", strerror(errno));
- return SHORTCUT_ERROR_IO;
+ return SHORTCUT_ERROR_IO_ERROR;
}
DbgPrint("Close and flush\n");
if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
}
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
_data = strdup(data);
if (!_data) {
ErrPrint("Heap: %s\n", strerror(errno));
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
}
_option = strdup(option);
if (!_option) {
ErrPrint("Heap: %s\n", strerror(errno));
- return SHORTCUT_ERROR_MEMORY;
+ free(_data);
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
}
struct block *block;
if (!handle || !type) {
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
if (!part) {
if (target_id) {
if (strcmp(type, SHORTCUT_ICON_TYPE_SCRIPT)) {
ErrPrint("target id only can be used for script type\n");
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
}
block = calloc(1, sizeof(*block));
if (!block) {
ErrPrint("Heap: %s\n", strerror(errno));
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
block->type = strdup(type);
if (!block->type) {
ErrPrint("Heap: %s\n", strerror(errno));
free(block);
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
block->part = strdup(part);
ErrPrint("Heap: %s\n", strerror(errno));
free(block->type);
free(block);
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
block->data = strdup(data);
free(block->type);
free(block->part);
free(block);
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
if (option) {
free(block->type);
free(block->part);
free(block);
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
}
free(block->type);
free(block->part);
free(block);
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
}
free(block->type);
free(block->part);
free(block);
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
}
} else {
if (strcmp(block->type, type)) {
ErrPrint("type is not valid (%s, %s)\n", block->type, type);
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
if ((block->target_id && !target_id) || (!block->target_id && target_id)) {
ErrPrint("type is not valid (%s, %s)\n", block->type, type);
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
if (block->target_id && target_id && strcmp(block->target_id, target_id)) {
ErrPrint("type is not valid (%s, %s)\n", block->type, type);
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
update_block(block, data, option);
struct pending_item *pend;
if (s_info.init_cb) {
- s_info.init_cb(SHORTCUT_SUCCESS, s_info.cbdata);
+ s_info.init_cb(SHORTCUT_ERROR_NONE, s_info.cbdata);
}
dlist_foreach_safe(s_info.pending_list, l, n, pend) {
free(pend);
}
- ret = SHORTCUT_SUCCESS;
+ ret = SHORTCUT_ERROR_NONE;
}
return ret;
ErrPrint("Unable to get \"%s\"\n", VCONFKEY_MASTER_STARTED);
}
- if (state == 1 && make_connection() == SHORTCUT_SUCCESS) {
+ if (state == 1 && (make_connection() == SHORTCUT_ERROR_NONE)) {
int ret;
ret = vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb);
DbgPrint("Ignore VCONF [%d]\n", ret);
int ret;
if (s_info.fd >= 0) {
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
if (s_info.initialized) {
}
master_started_cb(NULL, NULL);
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
}
if (s_info.fd < 0) {
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
com_core_packet_client_fini(s_info.fd);
free(pend->item);
free(pend);
}
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
{
if (!handle || handle->state != CREATED) {
ErrPrint("Handle is not valid\n");
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
handle->data = data;
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
{
if (!handle || handle->state != CREATED) {
ErrPrint("Handle is not valid\n");
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
return shortcut_icon_desc_add_block(handle->desc, id, type, part, data, option, subid);
{
if (!handle || handle->state != CREATED) {
ErrPrint("Handle is not valid\n");
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
(void)shortcut_icon_request_unref(handle);
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
if (!handle || handle->state != CREATED) {
ErrPrint("Handle is not valid\n");
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
if (!layout) {
filename = malloc(len);
if (!filename) {
ErrPrint("Heap: %s\n", strerror(errno));
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
#if defined(_USE_ECORE_TIME_GET)
if (unlink(filename) < 0) {
ErrPrint("Unlink: %s\n", strerror(errno));
}
- ret = SHORTCUT_ERROR_MEMORY;
+ ret = SHORTCUT_ERROR_OUT_OF_MEMORY;
goto out;
}
ErrPrint("Unlink: %s\n", strerror(errno));
}
(void)shortcut_icon_request_unref(handle);
- ret = SHORTCUT_ERROR_MEMORY;
+ ret = SHORTCUT_ERROR_OUT_OF_MEMORY;
goto out;
}
s_info.pending_list = dlist_append(s_info.pending_list, pend);
DbgPrint("Request is pended\n");
- ret = SHORTCUT_SUCCESS;
+ ret = SHORTCUT_ERROR_NONE;
}
out:
#include <sys/ioctl.h>
#include <libgen.h>
+#include <aul.h>
#include <dlog.h>
#include <glib.h>
#include <db-util.h>
#include "shortcut.h"
#include "shortcut_internal.h"
+#include "shortcut_manager.h"
+
+#define SHORTCUT_PKGNAME_LEN 512
int errno;
ErrPrint("Unable to get \"%s\"\n", VCONFKEY_MASTER_STARTED);
}
- if (state == 1 && make_connection() == SHORTCUT_SUCCESS) {
+ if (state == 1 && make_connection() == SHORTCUT_ERROR_NONE) {
int ret;
ret = vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb);
DbgPrint("Ignore VCONF [%d]\n", ret);
+int shortcut_is_master_ready(void)
+{
+ int ret = -1, is_master_started = 0;
+
+ ret = vconf_get_bool(VCONFKEY_MASTER_STARTED, &is_master_started);
+ if (ret == 0 && is_master_started == 1) {
+ ErrPrint("the master has been started");
+ } else {
+ is_master_started = 0;
+ ErrPrint("the master has been stopped");
+ }
+
+ return is_master_started;
+}
+
+
+
static gboolean timeout_cb(void *data)
{
int ret;
static int disconnected_cb(int handle, void *data)
{
if (s_info.client_fd == handle) {
- s_info.client_fd = SHORTCUT_ERROR_INVALID;
+ s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER;
return 0;
}
if (s_info.server_fd == handle) {
if (!s_info.timer_id) {
- s_info.server_fd = SHORTCUT_ERROR_INVALID;
+ s_info.server_fd = SHORTCUT_ERROR_INVALID_PARAMETER;
s_info.timer_id = g_timeout_add(1000, timeout_cb, NULL);
if (!s_info.timer_id) {
ErrPrint("Unable to add timer\n");
s_info.server_fd = -1;
ret = SHORTCUT_ERROR_COMM;
} else {
- ret = SHORTCUT_SUCCESS;
+ ret = SHORTCUT_ERROR_NONE;
}
DbgPrint("Server FD: %d\n", s_info.server_fd);
+static char *_shortcut_get_pkgname_by_pid(void)
+{
+ char pkgname[SHORTCUT_PKGNAME_LEN + 1] = { 0, };
+ int pid = 0, ret = 0;
+ int fd;
+ char *dup_pkgname;
+
+ pid = getpid();
+
+ ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
+ if (ret != 0) {
+ char buf[SHORTCUT_PKGNAME_LEN + 1] = { 0, };
+
+ snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
+
+ fd = open(buf, O_RDONLY);
+ if (fd < 0) {
+ return NULL;
+ }
+
+ ret = read(fd, pkgname, sizeof(pkgname) - 1);
+ close(fd);
+
+ if (ret <= 0) {
+ return NULL;
+ }
+
+ pkgname[ret] = '\0';
+ /*!
+ * \NOTE
+ * "ret" is not able to be larger than "sizeof(pkgname) - 1",
+ * if the system is not going wrong.
+ */
+ } else {
+ if (strlen(pkgname) <= 0) {
+ return NULL;
+ }
+ }
+
+ dup_pkgname = strdup(pkgname);
+ if (!dup_pkgname)
+ ErrPrint("Heap: %s\n", strerror(errno));
+
+ return dup_pkgname;
+}
+
+
+
EAPI int shortcut_set_request_cb(request_cb_t request_cb, void *data)
{
+ if (request_cb == NULL) {
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
+ }
+
s_info.server_cb.request_cb = request_cb;
s_info.server_cb.data = data;
ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL);
if (ret < 0) {
ErrPrint("Failed to add vconf for service state [%d]\n", ret);
+ return SHORTCUT_ERROR_COMM;
} else {
DbgPrint("vconf is registered\n");
}
master_started_cb(NULL, NULL);
}
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
struct result_cb_item {
+ result_internal_cb_t result_internal_cb;
result_cb_t result_cb;
void *data;
};
ret = SHORTCUT_ERROR_FAULT;
} else if (packet_get(packet, "i", &ret) != 1) {
ErrPrint("Packet is not valid\n");
- ret = SHORTCUT_ERROR_INVALID;
+ ret = SHORTCUT_ERROR_INVALID_PARAMETER;
}
- if (item->result_cb) {
- ret = item->result_cb(ret, pid, item->data);
+ if (item->result_internal_cb) {
+ ret = item->result_internal_cb(ret, pid, item->data);
+ } else if (item->result_cb) {
+ ret = item->result_cb(ret, item->data);
} else {
- ret = SHORTCUT_SUCCESS;
+ ret = SHORTCUT_ERROR_NONE;
}
free(item);
return ret;
-EAPI int add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_cb_t result_cb, void *data)
+EAPI int add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_internal_cb_t result_cb, void *data)
{
struct packet *packet;
struct result_cb_item *item;
if (!appid || !name) {
ErrPrint("Invalid argument\n");
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
if (!s_info.initialized) {
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
- item->result_cb = result_cb;
+ item->result_internal_cb = result_cb;
+ item->result_cb = NULL;
item->data = data;
packet = packet_create("rm_shortcut", "isss", getpid(), appid, name, content_info);
packet_destroy(packet);
free(item);
com_core_packet_client_fini(s_info.client_fd);
- s_info.client_fd = SHORTCUT_ERROR_INVALID;
+ s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER;
return SHORTCUT_ERROR_COMM;
}
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
-EAPI int add_to_home_remove_livebox(const char *appid, const char *name, result_cb_t result_cb, void *data)
+EAPI int add_to_home_remove_livebox(const char *appid, const char *name, result_internal_cb_t result_cb, void *data)
{
struct packet *packet;
struct result_cb_item *item;
if (!appid || !name) {
ErrPrint("Invalid argument\n");
- return SHORTCUT_ERROR_INVALID;
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
if (!s_info.initialized) {
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
- item->result_cb = result_cb;
+ item->result_internal_cb = result_cb;
+ item->result_cb = NULL;
item->data = data;
packet = packet_create("rm_livebox", "iss", getpid(), appid, name);
packet_destroy(packet);
free(item);
com_core_packet_client_fini(s_info.client_fd);
- s_info.client_fd = SHORTCUT_ERROR_INVALID;
+ s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER;
return SHORTCUT_ERROR_COMM;
}
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
-EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data)
+EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, const char *content, const char *icon, int allow_duplicate, result_internal_cb_t result_cb, void *data)
{
struct packet *packet;
struct result_cb_item *item;
if (ADD_TO_HOME_IS_LIVEBOX(type)) {
ErrPrint("Invalid type used for adding a shortcut\n");
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
if (!s_info.initialized) {
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
- item->result_cb = result_cb;
+ item->result_internal_cb = result_cb;
+ item->result_cb = NULL;
item->data = data;
if (!appid) {
packet_destroy(packet);
free(item);
com_core_packet_client_fini(s_info.client_fd);
- s_info.client_fd = SHORTCUT_ERROR_INVALID;
+ s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER;
return SHORTCUT_ERROR_COMM;
}
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
+EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *uri, const char *icon, int allow_duplicate, result_cb_t result_cb, void *data)
+{
+ struct packet *packet;
+ struct result_cb_item *item;
+ char *appid = NULL;
+ int ret;
+
+ if (ADD_TO_HOME_IS_LIVEBOX(type)) {
+ ErrPrint("Invalid type used for adding a shortcut\n");
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
+ }
+
+ appid = _shortcut_get_pkgname_by_pid();
+
+ if (!s_info.initialized) {
+ s_info.initialized = 1;
+ com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL);
+ }
+
+ if (s_info.client_fd < 0) {
+ static struct method service_table[] = {
+ {
+ .cmd = NULL,
+ .handler = NULL,
+ },
+ };
+
+ s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table);
+ if (s_info.client_fd < 0) {
+ if (appid) {
+ free(appid);
+ }
+ if (shortcut_is_master_ready() == 1) {
+ return SHORTCUT_ERROR_PERMISSION_DENIED;
+ }
+ else {
+ return SHORTCUT_ERROR_COMM;
+ }
+ }
+ }
+
+ item = malloc(sizeof(*item));
+ if (!item) {
+ if (appid) {
+ free(appid);
+ }
+ ErrPrint("Heap: %s\n", strerror(errno));
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
+ }
+
+ item->result_cb = result_cb;
+ item->result_internal_cb = NULL;
+ item->data = data;
+
+ if (!name) {
+ name = "";
+ }
+
+ if (!uri) {
+ uri = "";
+ }
+
+ if (!icon) {
+ icon = "";
+ }
+
+ packet = packet_create("add_shortcut", "ississi", getpid(), appid, name, type, uri, icon, allow_duplicate);
+ if (!packet) {
+ ErrPrint("Failed to build a packet\n");
+ if (appid) {
+ free(appid);
+ }
+ if (item) {
+ free(item);
+ }
+ return SHORTCUT_ERROR_FAULT;
+ }
+
+ if (appid) {
+ free(appid);
+ }
+
+ ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item);
+ packet_destroy(packet);
+ if (ret < 0) {
+ if (item) {
+ free(item);
+ }
+ com_core_packet_client_fini(s_info.client_fd);
+ s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER;
+ return SHORTCUT_ERROR_COMM;
+ }
+
+ return SHORTCUT_ERROR_NONE;
+}
-EAPI int add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_cb_t result_cb, void *data)
+EAPI int add_to_home_livebox(const char *appid, const char *name, int type, const char *content, const char *icon, double period, int allow_duplicate, result_internal_cb_t result_cb, void *data)
{
struct packet *packet;
struct result_cb_item *item;
if (!ADD_TO_HOME_IS_LIVEBOX(type)) {
ErrPrint("Invalid type is used for adding a livebox\n");
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
}
if (!s_info.initialized) {
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- return SHORTCUT_ERROR_MEMORY;
+ return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
- item->result_cb = result_cb;
+ item->result_internal_cb = result_cb;
+ item->result_cb = NULL;
item->data = data;
packet = packet_create("add_livebox", "ississdi", getpid(), appid, name, type, content, icon, period, allow_duplicate);
packet_destroy(packet);
free(item);
com_core_packet_client_fini(s_info.client_fd);
- s_info.client_fd = SHORTCUT_ERROR_INVALID;
+ s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER;
return SHORTCUT_ERROR_COMM;
}
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
ret = db_util_open(s_info.dbfile, &s_info.handle, DB_UTIL_REGISTER_HOOK_METHOD);
if (ret != SQLITE_OK) {
DbgPrint("Failed to open a %s\n", s_info.dbfile);
- return SHORTCUT_ERROR_IO;
+ return SHORTCUT_ERROR_IO_ERROR;
}
- return SHORTCUT_SUCCESS;
+ return SHORTCUT_ERROR_NONE;
}
int cnt;
char *language;
+ if (cb == NULL) {
+ return SHORTCUT_ERROR_INVALID_PARAMETER;
+ }
+
if (!s_info.db_opened) {
s_info.db_opened = (open_db() == 0);
}
if (!s_info.db_opened) {
ErrPrint("Failed to open a DB\n");
- return SHORTCUT_ERROR_IO;
+ return SHORTCUT_ERROR_IO_ERROR;
}
language = cur_locale();
if (ret != SQLITE_OK) {
ErrPrint("prepare: %s\n", sqlite3_errmsg(s_info.handle));
free(language);
- return SHORTCUT_ERROR_IO;
+ return SHORTCUT_ERROR_IO_ERROR;
}
ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT);
ErrPrint("bind text: %s\n", sqlite3_errmsg(s_info.handle));
sqlite3_finalize(stmt);
free(language);
- return SHORTCUT_ERROR_IO;
+ return SHORTCUT_ERROR_IO_ERROR;
}
} else {
query = "SELECT id, appid, name, extra_key, extra_data, icon FROM shortcut_service";
if (ret != SQLITE_OK) {
ErrPrint("prepare: %s\n", sqlite3_errmsg(s_info.handle));
free(language);
- return SHORTCUT_ERROR_IO;
+ return SHORTCUT_ERROR_IO_ERROR;
}
}
}
free(i18n_name);
+ i18n_name = NULL;
+
free(i18n_icon);
+ i18n_icon = NULL;
}
sqlite3_reset(stmt);