Merge from tizen 2.4 77/40077/1 tizen_3.0.2015.q2_common accepted/tizen/mobile/20150603.042801 submit/tizen_common/20150604.888888 submit/tizen_mobile/20150601.083112 submit/tizen_mobile/20150601.135223 submit/tizen_mobile/20150602.034811 submit/tizen_mobile/20150603.020854
authorKyuho Jo <kyuho.jo@samsung.com>
Thu, 28 May 2015 13:09:44 +0000 (22:09 +0900)
committerKyuho Jo <kyuho.jo@samsung.com>
Thu, 28 May 2015 13:09:44 +0000 (22:09 +0900)
Change-Id: I8806d0d4caa849d219ef7abd005309840465c1ab
Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
TC/testcase/utc_shortcut.c
lib/include/shortcut.h
lib/include/shortcut_manager.h
lib/src/main.c
test/icon.c

index efdb4c3..d5879ee 100755 (executable)
@@ -133,7 +133,7 @@ static void utc_shortcut_get_list_p(void)
 static void utc_add_to_home_dynamicbox_n(void)
 {
        int ret;
-       ret = add_to_home_dynamicbox("fail", NULL, WIDGET_SIZE_1x1, NULL, NULL, -1.0f, 1, response_cb, (void *)1);
+       ret = add_to_home_dynamicbox("fail", NULL, DYNAMICBOX_TYPE_1x1, NULL, NULL, -1.0f, 1, response_cb, (void *)1);
        if (ret != SHORTCUT_ERROR_NONE) {
                dts_check_eq("add_to_home_dynamicbox", ret, SHORTCUT_ERROR_NONE, "success");
        }
@@ -142,7 +142,7 @@ static void utc_add_to_home_dynamicbox_n(void)
 static void utc_add_to_home_dynamicbox_p(void)
 {
        int ret;
-       ret = add_to_home_dynamicbox("success", NULL, WIDGET_SIZE_1x1, NULL, NULL, -1.0f, 1, response_cb, (void *)2);
+       ret = add_to_home_dynamicbox("success", NULL, DYNAMICBOX_TYPE_1x1, NULL, NULL, -1.0f, 1, response_cb, (void *)2);
        if (ret != SHORTCUT_ERROR_NONE) {
                dts_check_eq("add_to_home_dynamicbox", ret, SHORTCUT_ERROR_NONE, "success");
        }
@@ -260,7 +260,7 @@ static void utc_shortcut_icon_request_send_n(void)
 {
        int ret;
 
-       ret = shortcut_icon_request_send(NULL, WIDGET_SIZE_1x1, NULL, NULL, NULL, NULL, NULL);
+       ret = shortcut_icon_request_send(NULL, DYNAMICBOX_TYPE_1x1, NULL, NULL, NULL, NULL, NULL);
        dts_check_eq("shortcut_icon_request_send", ret, SHORTCUT_ERROR_INVALID_PARAMETER, "success");
 }
 
@@ -278,7 +278,7 @@ static void utc_shortcut_icon_request_send_p(void)
                return;
        }
 
-       ret = shortcut_icon_request_send(s_info.handle, WIDGET_SIZE_1x1, NULL, NULL, "/tmp/icon.png", result_cb, NULL);
+       ret = shortcut_icon_request_send(s_info.handle, DYNAMICBOX_TYPE_1x1, NULL, NULL, "/tmp/icon.png", result_cb, NULL);
        dts_check_eq("shortcut_icon_request_send", ret, 0, "success");
 }
 
index d740651..95d7bad 100755 (executable)
@@ -36,28 +36,6 @@ extern "C" {
  */
 
 /**
- * @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.
- * @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 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,
@@ -87,23 +65,23 @@ enum shortcut_internal_type {
 
        LAUNCH_BY_PACKAGE       = 0x00000000,
 
-       SHORTCUT_REMOVE         = 0x40000000,   /**< Remove a shortcut */
-       DYNAMICBOX_REMOVE               = 0x80000000,   /**< Remove a dynamicbox */
+       SHORTCUT_REMOVE         = 0x40000000,       /**< Remove a shortcut */
+       DYNAMICBOX_REMOVE               = 0x80000000,   /**< Remove a widget */
 
-       DYNAMICBOX_TYPE_DEFAULT   = 0x10000000, /**< Type mask for the default dynamicbox */
-       DYNAMICBOX_TYPE_EASY_DEFAULT = 0x30000000,      /**< Type mask for the easy mode dynamicbox */
-       WIDGET_SIZE_1x1   = 0x10010000, /**< 1x1 */
-       WIDGET_SIZE_2x1   = 0x10020000, /**< 2x1 */
-       WIDGET_SIZE_2x2   = 0x10040000, /**< 2x2 */
-       WIDGET_SIZE_4x1   = 0x10080000, /**< 4x1 */
-       WIDGET_SIZE_4x2   = 0x10100000, /**< 4x2 */
-       WIDGET_SIZE_4x3           = 0x10200000, /**< 4x3 */
-       WIDGET_SIZE_4x4   = 0x10400000, /**< 4x4 */
-       WIDGET_SIZE_4x5   = 0x11000000, /**< 4x5 */
-       WIDGET_SIZE_4x6   = 0x12000000, /**< 4x6 */
-       WIDGET_SIZE_EASY_1x1      = 0x30010000, /**< Easy mode 1x1 */
-       WIDGET_SIZE_EASY_3x1      = 0x30020000, /**< Easy mode 3x2 */
-       WIDGET_SIZE_EASY_3x3      = 0x30040000, /**< Easy mode 3x3 */
+       DYNAMICBOX_TYPE_DEFAULT   = 0x10000000, /**< Type mask for the default widget */
+       DYNAMICBOX_TYPE_EASY_DEFAULT = 0x30000000,      /**< Type mask for the easy mode widget */
+       DYNAMICBOX_TYPE_1x1       = 0x10010000, /**< 1x1 */
+       DYNAMICBOX_TYPE_2x1       = 0x10020000, /**< 2x1 */
+       DYNAMICBOX_TYPE_2x2       = 0x10040000, /**< 2x2 */
+       DYNAMICBOX_TYPE_4x1       = 0x10080000, /**< 4x1 */
+       DYNAMICBOX_TYPE_4x2       = 0x10100000, /**< 4x2 */
+       DYNAMICBOX_TYPE_4x3       = 0x10200000, /**< 4x3 */
+       DYNAMICBOX_TYPE_4x4       = 0x10400000, /**< 4x4 */
+       DYNAMICBOX_TYPE_4x5       = 0x11000000, /**< 4x5 */
+       DYNAMICBOX_TYPE_4x6       = 0x12000000, /**< 4x6 */
+       DYNAMICBOX_TYPE_EASY_1x1          = 0x30010000, /**< Easy mode 1x1 */
+       DYNAMICBOX_TYPE_EASY_3x1          = 0x30020000, /**< Easy mode 3x2 */
+       DYNAMICBOX_TYPE_EASY_3x3          = 0x30040000, /**< Easy mode 3x3 */
        DYNAMICBOX_TYPE_UNKNOWN   = 0x1FFF0000, /**< Error */
 };
 
@@ -113,9 +91,7 @@ enum shortcut_internal_type {
  */
 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 */
 };
@@ -131,6 +107,7 @@ enum shortcut_internal_error_e {
  */
 #define ADD_TO_HOME_IS_DYNAMICBOX(type)        (!!((type) & 0x10000000))
 
+
 /**
  * @brief Definition for a macro to check the request status.
  * @since_tizen 2.3
@@ -163,72 +140,8 @@ enum shortcut_internal_error_e {
 #define SHORTCUT_ERROR_CODE(status)    ((status) & ~SHORTCUT_STATUS_CARED)
 
 /**
- *
  * @internal
  *
- * @brief Supports the shortcut creating request.
- *
- * @details
- * Sync (or) Async:
- * This is an asynchronous API.
- *
- * Important Notes: \n
- * Should be used from the homescreen.\n
- * Should check the return value of this function.
- *
- * Prospective Clients:
- * Homescreen.
- *
- * @since_tizen 2.3
- *
- * @privlevel public
- * @privilege %http://tizen.org/privilege/shortcut
- *
- * @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
- *
- * @return The return type (int)
- * @retval 0 Callback function is successfully registered
- * @retval <0 Failed to register the callback function for the request
- *
- * @pre You have to prepare a callback function.
- *
- * @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>
- *
- * static int request_cb(const char *appid, const char *name, int type, const char *content_info, const char *icon, int pid, void *data)
- * {
- *     printf("Package name: %s\n", appid);
- *     printf("Name: %s\n", name);
- *     printf("Type: %d\n", type);
- *     printf("Content: %s\n", content_info);
- *     printf("Icon: %s\n", icon);
- *     printf("Requested from: %d\n", pid);
- *     printf("CBDATA: %p\n", data);
- *     return 0; // returns success.
- * }
- *
- * static int app_create(void *data)
- * {
- *     shortcut_set_request_cb(request_cb, NULL);
- *     return 0;
- * }
- *
- * int main(int argc, char *argv[])
- * {
- *     appcore....
- * }
- *
- * @endcode
- */
-extern int shortcut_set_request_cb(request_cb_t request_cb, void *data);
-
-/**
- *
  * @brief Supports the add_to_home feature, should invoke this.
  *
  * @details
@@ -308,49 +221,8 @@ extern int shortcut_set_request_cb(request_cb_t request_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);
 
 /**
- *
  * @internal
  *
- * @brief Gets the installed shortcut view list.
- *
- * @details
- * Sync (or) Async:
- * This is a synchronous API.
- *
- * 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.
- *
- * Prospective Clients:
- * Inhouse Apps.
- *
- * @since_tizen 2.3
- *
- * @privlevel public
- * @privilege %http://tizen.org/privilege/shortcut
- *
- * @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
- *
- * @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
- *
- * @pre You have to prepare the callback function.
- *
- * @post You have to check the return status from the callback function which is passed by the argument.
- *
- * @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);
-
-/**
- *
- *
  * @brief Supports the add_to_home feature, should invoke this.
  *
  * @details
index 7db738f..69b4248 100755 (executable)
@@ -35,18 +35,6 @@ extern "C" {
  */
 
 /**
- * @brief Called to receive the result of shortcut_add_to_home().
- * @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] data The callback data
- * @return int @c 0 if there is no error,
-               otherwise errno
- * @see shortcut_add_to_home()
- */
-typedef int (*result_cb_t)(int ret, void *data);
-
-/**
  * @brief Enumeration for shortcut types.
  * @details Basically, two types of shortcuts are defined.
  *          Every homescreen developer should support these types of shortcuts.
@@ -80,23 +68,47 @@ enum shortcut_error_e {
 };
 
 /**
- *
- * @brief Supports the add_to_home feature, should invoke this.
- *
- * @details
- * Sync (or) Async:
- * This is an asynchronous API.
- *
+ * @brief Enumeration for sizes of shortcut widget.
+ * @since_tizen 2.4
+ */
+typedef enum shortcut_widget_size {
+       WIDGET_SIZE_DEFAULT      = 0x10000000,  /* Type mask for the normal mode widget , don't use this value for specific size.*/
+       WIDGET_SIZE_1x1          = 0x10010000,  /**< 1x1 */
+       WIDGET_SIZE_2x1          = 0x10020000,  /**< 2x1 */
+       WIDGET_SIZE_2x2          = 0x10040000,  /**< 2x2 */
+       WIDGET_SIZE_4x1          = 0x10080000,  /**< 4x1 */
+       WIDGET_SIZE_4x2          = 0x10100000,  /**< 4x2 */
+       WIDGET_SIZE_4x3          = 0x10200000,  /**< 4x3 */
+       WIDGET_SIZE_4x4          = 0x10400000,  /**< 4x4 */
+       WIDGET_SIZE_4x5          = 0x11000000,  /**< 4x5 */
+       WIDGET_SIZE_4x6          = 0x12000000,  /**< 4x6 */
+       WIDGET_SIZE_EASY_DEFAULT = 0x30000000,  /* Type mask for the easy mode widget, don't use this value for specific size. */
+       WIDGET_SIZE_EASY_1x1     = 0x30010000,  /**< Easy mode 1x1 */
+       WIDGET_SIZE_EASY_3x1     = 0x30020000,  /**< Easy mode 3x2 */
+       WIDGET_SIZE_EASY_3x3     = 0x30040000,  /**< Easy mode 3x3 */
+} shortcut_widget_size_e;
+
+/**
+ * @brief Called to receive the result of shortcut_add_to_home().
  * @since_tizen 2.3
- *
- * @privlevel public
- * @privilege %http://tizen.org/privilege/shortcut
- *
- * @remarks Application must check the return value of this function.\n
+ * @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] data The callback data
+ * @return int @c 0 if there is no error,
+               otherwise errno
+ * @see shortcut_add_to_home()
+ */
+typedef int (*result_cb_t)(int ret, void *data);
+
+/**
+ * @brief Adds a shortcut to home, asynchronously
+ * @remarks If a homescreen does not support this feature, you will get a proper error code.\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.
- * @remarks If a homescreen does not support this feature, you will get a proper error code.
- *
+ * @since_tizen 2.3
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/shortcut
  * @param[in] name The name of the created shortcut icon
  * @param[in] type The type of shortcuts
  * @param[in] uri The specific information for delivering to the viewer for creating a shortcut
@@ -106,7 +118,7 @@ enum shortcut_error_e {
  * @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
  *
- * @return @c 0 on success, otherwise a negative error value
+ * @return #SHORTCUT_ERROR_NONE on success, other value on failure
  * @retval #SHORTCUT_ERROR_NONE Successful
  * @retval #SHORTCUT_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #SHORTCUT_ERROR_OUT_OF_MEMORY Out of memory
@@ -134,9 +146,9 @@ enum shortcut_error_e {
  * static int result_cb(int ret, int pid, void *data)
  * {
  *     if (ret < 0)
- *             printf("Failed to add a shortcut: %s\n", perror(ret));
+ *             dlog_print("Failed to add a shortcut: %s\n", perror(ret));
  *
- *     printf("Processed by the %d\n", pid);
+ *     dlog_print("Processed by the %d\n", pid);
  *     return 0;
  * }
  *
@@ -157,14 +169,157 @@ enum shortcut_error_e {
  *     return 0;
  * }
  *
- * int main(int argc, char *argv[])
+ * @endcode
+ */
+extern 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);
+
+/**
+ * @brief Adds a shortcut widget to home, asynchronously.
+ * @remarks If a homescreen does not support this feature, you will get a proper error code.\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.
+ *
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/shortcut
+ *
+ * @param[in] name The name of the created shortcut widget
+ * @param[in] size_type The size of widget
+ * @param[in] uri URI of the resource what to be executed
+ * @param[in] icon The absolute path of an icon file
+ * @param[in] period The Update period in seconds
+ * @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
+ *
+ * @return #SHORTCUT_ERROR_NONE on success, other value on failure
+ * @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
+ *
+ * @pre You have to prepare the callback function.
+ *
+ * @post You have to check the return status from the callback function which is passed by the argument.
+ *
+ * @see result_cb_t
+ * @see shortcut_widget_size_e
+ *
+ * @par Example
+ * @code
+ *
+ * #include <stdio.h>
+ * #include <shortcut.h>
+ *
+ * static int result_cb(int ret, int pid, void *data)
  * {
- *     appcore....
+ *     if (ret < 0)
+ *             dlog_print("Failed to add a shortcut: %s\n", perror(ret));
+ *
+ *     dlog_print("Processed by the %d\n", pid);
+ *     return 0;
+ * }
+ *
+ * static int app_create(void *data)
+ * {
+ *     shortcut_add_to_home_widget("With friends",
+ *                                     WIDGET_SIZE_1x1, "gallery:0000-0000",
+ *                                     "/opt/media/Pictures/Friends.jpg", -1.0f, 0, result_cb, NULL);
+ *     return 0;
  * }
  *
  * @endcode
  */
-extern 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);
+extern int shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e size, const char *uri, const char *icon, double period, int allow_duplicate, result_cb_t result_cb, void *data);
+
+
+/**
+ * @brief Called to receive the result of shortcut_get_list().
+ * @since_tizen 2.4
+ * @param[in] package_name The name of package
+ * @param[in] icon The absolute path of an icon file for this shortcut
+ * @param[in] name The name of the created shortcut icon
+ * @param[in] extra_key The user data. A property of shortcut element in manifest file
+ * @param[in] extra_data The user data. A property of shortcut element in manifest file
+ * @param[in] user_data The callback user data
+ * @return SHORTCUT_ERROR_NONE to continue with the next iteration of the loop, other error values to break out of the loop
+ * @see shortcut_get_list()
+ */
+typedef int (*shortcut_list_cb)(const char *package_name, const char *icon, const char *name, const char *extra_key, const char *extra_data, void *user_data);
+
+/**
+ * @brief Gets the installed shortcut view list, synchronously.
+ * @remarks If a homescreen does not support this feature, you will get a proper error code.\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.
+ *
+ * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/shortcut
+ * @param[in] package_name The package name
+ * @param[in] shortcut_list_cb The callback function to get the shortcut item information
+ * @param[in] data The callback data that is used in the callback function
+ *
+ * @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
+ * @pre You have to prepare the callback function.
+ * @post You have to check the return status from the callback function which is passed by the argument.
+ *
+ */
+extern int shortcut_get_list(const char *package_name, shortcut_list_cb list_cb, void *data);
+
+/**
+ * @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.
+ * @since_tizen 2.4
+ * @param[in] package_name The name of 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 (*shortcut_request_cb)(const char *package_name, const char *name, int type, const char *content_info, const char *icon, int pid, double period, int allow_duplicate, void *data);
+
+/**
+ * @brief Registers a callback function to listen requests from applications.
+ * @remarks Should be used in the homescreen.\n
+ * Should check the return value of this function.
+  * Prospective Clients: Homescreen.
+  * @since_tizen 2.4
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/shortcut
+ *
+ * @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
+ *
+ * @return #SHORTCUT_ERROR_NONE on success, other value on failure
+ * @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
+ * @pre You have to prepare a callback function.
+ *
+ * @post If a request is sent from the application, the registered callback will be invoked.
+ *
+ * @see request_cb_t
+ * @see shortcut_error_e
+ */
+extern int shortcut_set_request_cb(shortcut_request_cb request_cb, void *data);
+
 
 /**
  * @}
index 4e69a91..16594d9 100755 (executable)
@@ -41,6 +41,9 @@
 
 #define SHORTCUT_PKGNAME_LEN 512
 
+#define SHORTCUT_IS_WIDGET_SIZE(size)           (!!((size) & WIDGET_SIZE_DEFAULT))
+#define SHORTCUT_IS_EASY_MODE_WIDGET_SIZE(size) (!!((size) & WIDGET_SIZE_EASY_DEFAULT))
+
 int errno;
 
 static struct info {
@@ -102,7 +105,7 @@ static struct packet *remove_shortcut_handler(pid_t pid, int handle, const struc
 
 
 
-static struct packet *remove_dynamicbox_handler(pid_t pid, int handle, const struct packet *packet)
+static struct packet *remove_shortcut_widget_handler(pid_t pid, int handle, const struct packet *packet)
 {
        const char *appid;
        const char *name;
@@ -165,7 +168,7 @@ static struct packet *add_shortcut_handler(pid_t pid, int handle, const struct p
 
 
 
-static struct packet *add_dynamicbox_handler(pid_t pid, int handle, const struct packet *packet)
+static struct packet *add_shortcut_widget_handler(pid_t pid, int handle, const struct packet *packet)
 {
        const char *appid;
        const char *name;
@@ -283,16 +286,16 @@ static inline int make_connection(void)
                        .handler = add_shortcut_handler,
                },
                {
-                       .cmd = "add_dynamicbox",
-                       .handler = add_dynamicbox_handler,
+                       .cmd = "add_shortcut_widget",
+                       .handler = add_shortcut_widget_handler,
                },
                {
                        .cmd = "rm_shortcut",
                        .handler = remove_shortcut_handler,
                },
                {
-                       .cmd = "rm_dynamicbox",
-                       .handler = remove_dynamicbox_handler,
+                       .cmd = "rm_shortcut_widget",
+                       .handler = remove_shortcut_widget_handler,
                },
                {
                        .cmd = NULL,
@@ -382,7 +385,7 @@ static char *_shortcut_get_pkgname_by_pid(void)
 
 
 
-EAPI int shortcut_set_request_cb(request_cb_t request_cb, void *data)
+EAPI int shortcut_set_request_cb(shortcut_request_cb request_cb, void *data)
 {
        if (request_cb == NULL) {
                return SHORTCUT_ERROR_INVALID_PARAMETER;
@@ -774,7 +777,75 @@ EAPI int add_to_home_dynamicbox(const char *appid, const char *name, int type, c
        item->result_cb = NULL;
        item->data = data;
 
-       packet = packet_create("add_dynamicbox", "ississdi", getpid(), appid, name, type, content, icon, period, allow_duplicate);
+       packet = packet_create("add_shortcut_widget", "ississdi", getpid(), appid, name, type, content, icon, period, allow_duplicate);
+       if (!packet) {
+               ErrPrint("Failed to build a packet\n");
+               free(item);
+               return SHORTCUT_ERROR_FAULT;
+       }
+
+       ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item);
+       if (ret < 0) {
+               packet_destroy(packet);
+               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 shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e size, const char *uri, const char *icon, double period, int allow_duplicate, result_cb_t result_cb, void *data)
+{
+       struct packet *packet;
+       struct result_cb_item *item;
+       char *appid = NULL;
+       int ret;
+
+       if (name == NULL) {
+               ErrPrint("AppID is null\n");
+               return SHORTCUT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (!SHORTCUT_IS_WIDGET_SIZE(size)) {
+               ErrPrint("Invalid type used for adding a widget\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) {
+                       return SHORTCUT_ERROR_COMM;
+               }
+       }
+
+       item = malloc(sizeof(*item));
+       if (!item) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               return SHORTCUT_ERROR_OUT_OF_MEMORY;
+       }
+
+       item->result_internal_cb = NULL;
+       item->result_cb = result_cb;
+       item->data = data;
+
+       packet = packet_create("add_shortcut_widget", "ississdi", getpid(), appid, name, size, uri, icon, period, allow_duplicate);
        if (!packet) {
                ErrPrint("Failed to build a packet\n");
                free(item);
@@ -924,7 +995,7 @@ static inline char *cur_locale(void)
 /*!
  * \note READ ONLY DB
  */
-EAPI 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)
+EAPI int shortcut_get_list(const char *package_name, shortcut_list_cb list_cb, void *data)
 {
        sqlite3_stmt *stmt;
        const char *query;
@@ -939,7 +1010,7 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const
        int cnt;
        char *language;
 
-       if (cb == NULL) {
+       if (list_cb == NULL) {
                return SHORTCUT_ERROR_INVALID_PARAMETER;
        }
 
@@ -958,7 +1029,7 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const
                return SHORTCUT_ERROR_FAULT;
        }
 
-       if (appid) {
+       if (package_name) {
                query = "SELECT id, appid, name, extra_key, extra_data, icon FROM shortcut_service WHERE appid = ?";
                ret = sqlite3_prepare_v2(s_info.handle, query, -1, &stmt, NULL);
                if (ret != SQLITE_OK) {
@@ -967,7 +1038,7 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const
                        return SHORTCUT_ERROR_IO_ERROR;
                }
 
-               ret = sqlite3_bind_text(stmt, 1, appid, -1, SQLITE_TRANSIENT);
+               ret = sqlite3_bind_text(stmt, 1, package_name, -1, SQLITE_TRANSIENT);
                if (ret != SQLITE_OK) {
                        ErrPrint("bind text: %s\n", sqlite3_errmsg(s_info.handle));
                        sqlite3_finalize(stmt);
@@ -988,8 +1059,8 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const
        while (SQLITE_ROW == sqlite3_step(stmt)) {
                id = sqlite3_column_int(stmt, 0);
 
-               appid = (const char *)sqlite3_column_text(stmt, 1);
-               if (!appid) {
+               package_name = (const char *)sqlite3_column_text(stmt, 1);
+               if (!package_name) {
                        LOGE("Failed to get package name\n");
                        continue;
                }
@@ -1027,7 +1098,7 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const
                }
 
                cnt++;
-               if (cb(appid, (i18n_icon != NULL ? i18n_icon : (char *)icon), (i18n_name != NULL ? i18n_name : (char *)name), (char *)extra_key, (char *)extra_data, data) < 0) {
+               if (list_cb(package_name, (i18n_icon != NULL ? i18n_icon : (char *)icon), (i18n_name != NULL ? i18n_name : (char *)name), (char *)extra_key, (char *)extra_data, data) < 0) {
                        free(i18n_name);
                        break;
                }
index a2ec08d..724153d 100755 (executable)
@@ -51,14 +51,14 @@ static Eina_Bool test_main(void *data)
        snprintf(filename, sizeof(filename), "/opt/usr/share/live_magazine/always/out%d.png", idx);
 
        switch (idx % 7) {
-       case 0: type = WIDGET_SIZE_1x1; break;
-       case 1: type = WIDGET_SIZE_2x1; break;
-       case 2: type = WIDGET_SIZE_2x2; break;
-       case 3: type = WIDGET_SIZE_4x1; break;
-       case 4: type = WIDGET_SIZE_4x2; break;
-       case 5: type = WIDGET_SIZE_4x3; break;
-       case 6: type = WIDGET_SIZE_4x4; break;
-       default: type = WIDGET_SIZE_1x1; break;
+       case 0: type = DYNAMICBOX_TYPE_1x1; break;
+       case 1: type = DYNAMICBOX_TYPE_2x1; break;
+       case 2: type = DYNAMICBOX_TYPE_2x2; break;
+       case 3: type = DYNAMICBOX_TYPE_4x1; break;
+       case 4: type = DYNAMICBOX_TYPE_4x2; break;
+       case 5: type = DYNAMICBOX_TYPE_4x3; break;
+       case 6: type = DYNAMICBOX_TYPE_4x4; break;
+       default: type = DYNAMICBOX_TYPE_1x1; break;
        }
 
        ret = shortcut_icon_request_send(handle, type, NULL, NULL, filename, result_cb, NULL);