Fix the issues of TC
authorSung-jae Park <nicesj.park@samsung.com>
Fri, 30 May 2014 00:02:12 +0000 (09:02 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Fri, 30 May 2014 00:09:47 +0000 (09:09 +0900)
Change-Id: Iae760463a2b21d558087213e6279437ef6f37298

lib/include/shortcut.h
lib/src/main.c
packaging/libshortcut.spec

index 14241d3..d96d256 100644 (file)
@@ -458,8 +458,143 @@ extern int shortcut_get_list(const char *appid, int (*cb)(const char *appid, con
  */
 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);
 
+/*!
+ * @fn add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_cb_t result_cb, void *data);
+ *
+ * @brief The application, which supporting the add_to_home feature, should invoke this.
+ *
+ * @par 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.
+ *
+ * @param[in] appid Package name of owner of this shortcut.
+ * @param[in] name Name for created shortcut icon.
+ * @param[in] content_info Specific information for delivering to the viewer for creating a shortcut.
+ * @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
+ *
+ * @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
+ *
+ * @see result_cb_t
+ *
+ * @pre You have to prepare the callback function
+ *
+ * @post You have to check the return status from callback function which is passed by argument.
+ *
+ * @remarks - If a homescreen does not support this feature, you will get proper error code.
+ *
+ * @par Prospective Clients:
+ * Inhouse Apps.
+ *
+ * @par Example
+ * @code
+ *
+ * #include <stdio.h>
+ * #include <shortcut.h>
+ *
+ * static int result_cb(int ret, int pid, void *data)
+ * {
+ *     if (ret < 0)
+ *             printf("Failed to add a shortcut: %s\n", perror(ret));
+ *
+ *     printf("Processed by the %d\n", pid);
+ *     return 0;
+ * }
+ *
+ * static int app_create(void *data)
+ * {
+ *     add_to_home_remove_shortcut("com.samsung.gallery.livebox", "With friends",
+ *                                     "gallery:0000-0000",
+ *                                     result_cb, NULL);
+ *     return 0;
+ * }
+ *
+ * int main(int argc, char *argv[])
+ * {
+ *     appcore....
+ * }
+ *
+ * @endcode
+ */
 extern int add_to_home_remove_shortcut(const char *appid, const char *name, const char *content_info, result_cb_t result_cb, void *data);
 
+/*!
+ * @fn add_to_home_remove_livebox(const char *appid, const char *name, result_cb_t result_cb, void *data);
+ *
+ * @brief The application, which supporting the add_to_home feature, should invoke this.
+ *
+ * @par 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.
+ *
+ * @param[in] appid Package name of owner of this shortcut.
+ * @param[in] name Name for created shortcut icon.
+ * @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
+ *
+ * @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
+ *
+ * @see result_cb_t
+ *
+ * @pre You have to prepare the callback function
+ *
+ * @post You have to check the return status from callback function which is passed by argument.
+ *
+ * @remarks - If a homescreen does not support this feature, you will get proper error code.
+ *
+ * @par Prospective Clients:
+ * Inhouse Apps.
+ *
+ * @par Example
+ * @code
+ *
+ * #include <stdio.h>
+ * #include <shortcut.h>
+ *
+ * static int result_cb(int ret, int pid, void *data)
+ * {
+ *     if (ret < 0)
+ *             printf("Failed to add a shortcut: %s\n", perror(ret));
+ *
+ *     printf("Processed by the %d\n", pid);
+ *     return 0;
+ * }
+ *
+ * static int app_create(void *data)
+ * {
+ *     add_to_home_remove_livebox("com.samsung.gallery.livebox", "With friends", result_cb, NULL);
+ *     return 0;
+ * }
+ *
+ * int main(int argc, char *argv[])
+ * {
+ *     appcore....
+ * }
+ *
+ * @endcode
+ */
 extern int add_to_home_remove_livebox(const char *appid, const char *name, result_cb_t result_cb, void *data);
 
 
index 4261a39..9664a10 100644 (file)
@@ -496,8 +496,9 @@ EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, con
        struct result_cb_item *item;
        int ret;
 
-       if (ADD_TO_HOME_IS_LIVEBOX(type)) {
+       if (!appid || ADD_TO_HOME_IS_LIVEBOX(type)) {
                ErrPrint("Invalid type used for adding a shortcut\n");
+               return SHORTCUT_ERROR_INVALID;
        }
 
        if (!s_info.initialized) {
@@ -529,10 +530,6 @@ EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, con
        item->result_cb = result_cb;
        item->data = data;
 
-       if (!appid) {
-               appid = "";
-       }
-
        if (!name) {
                name = "";
        }
@@ -572,8 +569,9 @@ EAPI int add_to_home_livebox(const char *appid, const char *name, int type, cons
        struct result_cb_item *item;
        int ret;
 
-       if (!ADD_TO_HOME_IS_LIVEBOX(type)) {
+       if (!appid || !ADD_TO_HOME_IS_LIVEBOX(type)) {
                ErrPrint("Invalid type is used for adding a livebox\n");
+               return SHORTCUT_ERROR_INVALID;
        }
 
        if (!s_info.initialized) {
@@ -768,6 +766,10 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const
        int cnt;
        char *language;
 
+       if (cb == NULL) {
+               return SHORTCUT_ERROR_INVALID;
+       }
+
        if (!s_info.db_opened) {
                s_info.db_opened = (open_db() == 0);
        }
index 29dad07..195b30b 100644 (file)
@@ -1,6 +1,6 @@
 Name: libshortcut
 Summary: Shortcut add feature supporting library
-Version: 0.6.12
+Version: 0.6.13
 Release: 0
 Group: HomeTF/Framework
 License: Apache