Merge from tizen 2.4 latest 65/51465/2 accepted/tizen/mobile/20151111.095210 accepted/tizen/tv/20151111.095227 accepted/tizen/wearable/20151111.095244 submit/tizen/20151111.080158
authorKyuho Jo <kyuho.jo@samsung.com>
Tue, 10 Nov 2015 03:15:42 +0000 (12:15 +0900)
committerKyuho Jo <kyuho.jo@samsung.com>
Tue, 10 Nov 2015 03:27:30 +0000 (12:27 +0900)
Change-Id: I64a1f9ab319d7d2c9477ac51d6f69fdeaf488b7d
Signed-off-by: Kyuho Jo <kyuho.jo@samsung.com>
lib/CMakeLists.txt
lib/include/dlist.h [deleted file]
lib/include/shortcut.h
lib/include/shortcut_manager.h
lib/include/shortcut_private.h
lib/src/dlist.c [deleted file]
lib/src/shortcut_manager.c [moved from lib/src/main.c with 65% similarity, mode: 0644]
packaging/libshortcut.spec
pkgmgr_shortcut/CMakeLists.txt
pkgmgr_shortcut/src/service_register.c

index 3c19d1d..dffc802 100755 (executable)
@@ -32,10 +32,10 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
 ADD_DEFINITIONS("-DLOG_TAG=\"SHORTCUT\"")
 ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET")
+ADD_DEFINITIONS("-DDB_PATH=\"${DB_PATH}\"")
 
 ADD_LIBRARY(${PROJECT_NAME} SHARED 
-       src/main.c
-       src/dlist.c
+       src/shortcut_manager.c
 )
 
 TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${svc_pkgs_LDFLAGS})
diff --git a/lib/include/dlist.h b/lib/include/dlist.h
deleted file mode 100755 (executable)
index c892923..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2011 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
-*/
-
-#define dlist_remove_data(list, data) do { \
-       struct dlist *l; \
-       l = dlist_find_data(list, data); \
-       list = dlist_remove(list, l); \
-} while (0)
-
-#define dlist_foreach(list, l, data) \
-       for ((l) = (list); (l) && ((data) = dlist_data(l)); (l) = dlist_next(l))
-
-#define dlist_foreach_safe(list, l, n, data) \
-       for ((l) = (list), (n) = dlist_next(l); \
-               (l) && ((data) = dlist_data(l)); \
-               (l) = (n), (n) = dlist_next(l))
-
-struct dlist;
-
-extern struct dlist *dlist_append(struct dlist *list, void *data);
-extern struct dlist *dlist_prepend(struct dlist *list, void *data);
-extern struct dlist *dlist_remove(struct dlist *list, struct dlist *l);
-extern struct dlist *dlist_find_data(struct dlist *list, void *data);
-extern void *dlist_data(struct dlist *l);
-extern struct dlist *dlist_next(struct dlist *l);
-extern struct dlist *dlist_prev(struct dlist *l);
-extern int dlist_count(struct dlist *l);
-extern struct dlist *dlist_nth(struct dlist *l, int nth);
-
-/* End of a file */
index 95d7bad..7d35a35 100755 (executable)
@@ -85,16 +85,6 @@ enum shortcut_internal_type {
        DYNAMICBOX_TYPE_UNKNOWN   = 0x1FFF0000, /**< Error */
 };
 
-/**
- * @brief Enumeration for values of shortcut response types.
- * @since_tizen 2.3
- */
-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 Definition for a macro to check type.
@@ -107,200 +97,9 @@ 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
- * @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 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 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)
-
-/**
- * @internal
- *
- * @brief Supports the add_to_home feature, should invoke this.
- *
- * @details
- * Sync (or) Async:
- * This is an asynchronous 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 of the owner of this shortcut
- * @param[in] name The name of the created shortcut icon
- * @param[in] type The type of shortcuts (dynamicbox or shortcut, and its size if it is for the dynamicbox)
- * @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
- *
- * @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
- *
- * @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
- *
- * @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_shortcut("org.tizen.gallery", "With friends",
- *                                     LAUNCH_BY_URI, "gallery:0000-0000",
- *                                     "/opt/media/Pictures/Friends.jpg", 0, result_cb, NULL);
- *     return 0;
- * }
- *
- * int main(int argc, char *argv[])
- * {
- *     appcore....
- * }
- *
- * @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_internal_cb_t result_cb, void *data);
-
-/**
- * @internal
- *
- * @brief Supports the add_to_home feature, should invoke this.
- *
- * @details
- * Sync (or) Async:
- * This is an asynchronous 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 of the owner of this shortcut
- * @param[in] name The name of the created shortcut icon
- * @param[in] type The type of shortcuts (dynamicbox or shortcut, and its size if it is for the dynamicbox)
- * @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
- *
- * @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
- *
- * @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
- *
- * @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_dynamicbox("org.tizen.gallery.dynamicbox", "With friends",
- *                                     LAUNCH_BY_URI, "gallery:0000-0000",
- *                                     "/opt/media/Pictures/Friends.jpg", -1.0f, 0, result_cb, NULL);
- *     return 0;
- * }
- *
- * int main(int argc, char *argv[])
- * {
- *     appcore....
- * }
- *
- * @endcode
- */
-extern int add_to_home_dynamicbox(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);
+/* DEPRECATED API */
+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) __attribute__((deprecated));
+extern int add_to_home_dynamicbox(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) __attribute__((deprecated));
 
 /**
  * @}
index 69b4248..441df55 100755 (executable)
@@ -174,7 +174,7 @@ typedef int (*result_cb_t)(int ret, void *data);
 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.
+ * @brief Adds a 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
@@ -184,23 +184,23 @@ extern int shortcut_add_to_home(const char *name, shortcut_type type, const char
  * @privlevel public
  * @privilege %http://tizen.org/privilege/shortcut
  *
- * @param[in] name The name of the created shortcut widget
+ * @param[in] name The name of the created widget. Will be shown when the widget is not prepared.
  * @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] widget_id Widget id
+ * @param[in] icon The absolute path of an icon file. Will be shown when the widget is not prepared.
  * @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] allow_duplicate @c 1 if it accepts the duplicated widget, 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_INVALID_PARAMETER 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
+ * @retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a widget
+ * @retval #SHORTCUT_ERROR_NOT_SUPPORTED Widget is not supported
  *
  * @pre You have to prepare the callback function.
  *
@@ -218,7 +218,7 @@ extern int shortcut_add_to_home(const char *name, shortcut_type type, const char
  * static int result_cb(int ret, int pid, void *data)
  * {
  *     if (ret < 0)
- *             dlog_print("Failed to add a shortcut: %s\n", perror(ret));
+ *             dlog_print("Failed to add a widget: %s\n", perror(ret));
  *
  *     dlog_print("Processed by the %d\n", pid);
  *     return 0;
@@ -226,15 +226,15 @@ extern int shortcut_add_to_home(const char *name, shortcut_type type, const char
  *
  * 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);
+ *     shortcut_add_to_home_widget("alter_name",
+ *                                     WIDGET_SIZE_1x1, "org.tizen.testwidget",
+ *                                     "/opt/media/Pictures/alter_icon.png", -1.0f, 0, result_cb, NULL);
  *     return 0;
  * }
  *
  * @endcode
  */
-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);
+extern int shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e size, const char *widget_id, const char *icon, double period, int allow_duplicate, result_cb_t result_cb, void *data);
 
 
 /**
index b69df43..260668c 100755 (executable)
@@ -36,169 +36,4 @@ extern FILE *__file_log_fp;
 #define DEFAULT_ICON_LAYOUT ""
 #define DEFAULT_ICON_GROUP ""
 
-/**
- * @brief Definition for a macro to check the request type.
- * @since_tizen 2.3
- * @param[in] type Request type
- * @return bool
- * @retval true(1) Shortcut remove request
- * @retval false(0) Not a remove request
- * @see shortcut_type
- */
-#define ADD_TO_HOME_IS_REMOVE_SHORTCUT(type)   (!!((type) & SHORTCUT_REMOVE))
-
-/**
- * @brief Definition for a macro to check the request type.
- * @since_tizen 2.3
- * @param[in] type Request type
- * @return bool
- * @retval true(1) Dynamicbox remove request
- * @retval false(0) Not a remove request
- * @see shortcut_type
- */
-#define ADD_TO_HOME_IS_REMOVE_DYNAMICBOX(type) (!!((type) & DYNAMICBOX_REMOVE))
-
-/**
- *
- *
- * @brief The application, which supporting the add_to_home feature, should invoke this.
- *
- * @details
- * Sync (or) Async:
- * This is an asynchronous 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
- *
- * @remarks - If a homescreen does not support this feature, you will get proper error code.
- * @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_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 of communication
- * \retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle new request
- * \retval #SHORTCUT_ERROR_IO_ERROR Unable to access file or DB. Check your resource files
- * \retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut
- *
- * @pre You have to prepare the callback function
- *
- * @post You have to check the return status from callback function which is passed by argument.
- *
- * @see result_internal_cb_t
- *
- * @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)
- * {
-5 *    add_to_home_remove_shortcut("org.tizen.gallery.dynamicbox", "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_internal_cb_t result_cb, void *data);
-
-/**
- *
- *
- * @brief The application, which supporting the add_to_home feature, should invoke this.
- *
- * @details
- * Sync (or) Async:
- * This is an asynchronous 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
- *
- * @remarks - If a homescreen does not support this feature, you will get proper error code.
- * @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_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 of communication
- * \retval #SHORTCUT_ERROR_OUT_OF_MEMORY Memory is not enough to handle new request
- * \retval #SHORTCUT_ERROR_IO_ERROR Unable to access file or DB. Check your resource files
- * \retval #SHORTCUT_ERROR_PERMISSION_DENIED Has no permission to add a shortcut
- *
- * @pre You have to prepare the callback function
- *
- * @post You have to check the return status from callback function which is passed by argument.
- *
- * @see result_internal_cb_t
- *
- * @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_dynamicbox("org.tizen.gallery.dynamicbox", "With friends", result_cb, NULL);
- *     return 0;
- * }
- *
- * int main(int argc, char *argv[])
- * {
- *     appcore....
- * }
- *
- * @endcode
- */
-extern int add_to_home_remove_dynamicbox(const char *appid, const char *name, result_internal_cb_t result_cb, void *data);
-
 /* End of a file */
diff --git a/lib/src/dlist.c b/lib/src/dlist.c
deleted file mode 100755 (executable)
index 71ec556..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2011 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "dlist.h"
-
-/*!
- * \brief
- * This dlist is called Modified Doubly Linked List.
- *
- * Noramlly, The dobule linked list contains address of previous and next element.
- * This dlist also contains them, but the tail element only contains prev address.
- *
- * The head element's prev pointer indicates the last element.
- * But the last element's next pointer indicates NIL.
- *
- * So we can find the last element while crawling this DList
- * But we have to remember the address of the head element.
- */
-
-struct dlist {
-       struct dlist *next;
-       struct dlist *prev;
-       void *data;
-};
-
-struct dlist *dlist_append(struct dlist *list, void *data)
-{
-       struct dlist *item;
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               return NULL;
-       }
-
-       item->next = NULL;
-       item->data = data;
-
-       if (!list) {
-               item->prev = item;
-
-               list = item;
-       } else {
-               item->prev = list->prev;
-               item->prev->next = item;
-               list->prev = item;
-       }
-
-       assert(!list->prev->next && "item NEXT");
-
-       return list;
-}
-
-struct dlist *dlist_prepend(struct dlist *list, void *data)
-{
-       struct dlist *item;
-
-       item = malloc(sizeof(*item));
-       if (!item) {
-               return NULL;
-       }
-
-       item->data = data;
-
-       if (!list) {
-               item->prev = item;
-               item->next = NULL;
-       } else {
-               if (list->prev->next) {
-                       list->prev->next = item;
-               }
-
-               item->prev = list->prev;
-               item->next = list;
-
-               list->prev = item;
-
-       }
-
-       return item;
-}
-
-struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
-{
-       if (!list || !l) {
-               return NULL;
-       }
-
-       if (l == list) {
-               list = l->next;
-       } else {
-               l->prev->next = l->next;
-       }
-
-       if (l->next) {
-               l->next->prev = l->prev;
-       }
-       /*!
-        * \note
-        * If the removed entry 'l' has no next element, it is the last element.
-        * In this case, check the existence of the list first,
-        * and if the list is not empty, update the 'prev' of the list (which is a head element of the list) 
-        *
-        * If we didn't care about this, the head element(list) can indicates the invalid element.
-        */
-       else if (list) {
-               list->prev = l->prev;
-       }
-
-       free(l);
-       return list;
-}
-
-struct dlist *dlist_find_data(struct dlist *list, void *data)
-{
-       struct dlist *l;
-       void *_data;
-
-       dlist_foreach(list, l, _data) {
-               if (data == _data) {
-                       return l;
-               }
-       }
-
-       return NULL;
-}
-
-void *dlist_data(struct dlist *l)
-{
-       return l ? l->data : NULL;
-}
-
-struct dlist *dlist_next(struct dlist *l)
-{
-       return l ? l->next : NULL;
-}
-
-struct dlist *dlist_prev(struct dlist *l)
-{
-       return l ? l->prev : NULL;
-}
-
-int dlist_count(struct dlist *l)
-{
-       register int i;
-       struct dlist *n;
-       void *data;
-
-       i = 0;
-       dlist_foreach(l, n, data) {
-               i++;
-       }
-
-       return i;
-}
-
-struct dlist *dlist_nth(struct dlist *l, int nth)
-{
-       register int i;
-       struct dlist *n;
-
-       i = 0;
-       for (n = l; n; n = n->next) {
-               if (i == nth) {
-                       return n;
-               }
-               i++;
-       }
-
-       return NULL;
-}
-
-/* End of a file */
old mode 100755 (executable)
new mode 100644 (file)
similarity index 65%
rename from lib/src/main.c
rename to lib/src/shortcut_manager.c
index 1b03ace..67542dc
@@ -46,6 +46,8 @@
 
 int errno;
 
+static inline int make_connection(void);
+
 static struct info {
        const char *dbfile;
        sqlite3 *handle;
@@ -63,78 +65,13 @@ static struct info {
        .server_fd = -1,
        .client_fd = -1,
        .socket_file = "/tmp/.shortcut.service",
-       .dbfile = "/usr/dbspace/.shortcut_service.db",
+       .dbfile = DB_PATH,
        .handle = NULL,
        .initialized = 0,
        .db_opened = 0,
        .timer_id = 0,
 };
 
-
-static inline int make_connection(void);
-
-
-static struct packet *remove_shortcut_handler(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *appid;
-       const char *name;
-       const char *content_info;
-       int ret;
-       int sender_pid;
-
-       if (!packet) {
-               ErrPrint("Packet is NIL, maybe disconnected?\n");
-               return NULL;
-       }
-
-       if (packet_get(packet, "isss", &sender_pid, &appid, &name, &content_info) != 4) {
-               ErrPrint("Invalid apcket\n");
-               return NULL;
-       }
-
-       DbgPrint("appid[%s], name[%s], content_info[%s]\n", appid, name, content_info);
-
-       if (s_info.server_cb.request_cb) {
-               ret = s_info.server_cb.request_cb(appid, name, SHORTCUT_REMOVE, content_info, NULL, sender_pid, -1.0f, 0, s_info.server_cb.data);
-       } else {
-               ret = SHORTCUT_ERROR_UNSUPPORTED;
-       }
-
-       return packet_create_reply(packet, "i", ret);
-}
-
-
-
-static struct packet *remove_shortcut_widget_handler(pid_t pid, int handle, const struct packet *packet)
-{
-       const char *appid;
-       const char *name;
-       int ret;
-       int sender_pid;
-
-       if (!packet) {
-               ErrPrint("PAcket is NIL, maybe disconnected?\n");
-               return NULL;
-       }
-
-       if (packet_get(packet, "iss", &sender_pid, &appid, &name) != 3) {
-               ErrPrint("Invalid packet\n");
-               return NULL;
-       }
-
-       DbgPrint("appid[%s], name[%s]\n", appid, name);
-
-       if (s_info.server_cb.request_cb) {
-               ret = s_info.server_cb.request_cb(appid, name, DYNAMICBOX_REMOVE, NULL, NULL, sender_pid, -1.0f, 0, s_info.server_cb.data);
-       } else {
-               ret = SHORTCUT_ERROR_UNSUPPORTED;
-       }
-
-       return packet_create_reply(packet, "i", ret);
-}
-
-
-
 static struct packet *add_shortcut_handler(pid_t pid, int handle, const struct packet *packet)
 {
        const char *appid;
@@ -143,7 +80,7 @@ static struct packet *add_shortcut_handler(pid_t pid, int handle, const struct p
        const char *content;
        const char *icon;
        int allow_duplicate;
-       int ret;
+       int ret = SHORTCUT_ERROR_NONE;
        int sender_pid;
 
        if (!packet) {
@@ -160,7 +97,11 @@ static struct packet *add_shortcut_handler(pid_t pid, int handle, const struct p
        if (s_info.server_cb.request_cb) {
                ret = s_info.server_cb.request_cb(appid, name, type, content, icon, sender_pid, -1.0f, allow_duplicate, s_info.server_cb.data);
        } else {
-               ret = SHORTCUT_ERROR_UNSUPPORTED;
+               ret = SHORTCUT_ERROR_NOT_SUPPORTED;
+       }
+
+       if (ret != SHORTCUT_ERROR_NONE) {
+               ErrPrint("ret [%d]\n", ret);
        }
 
        return packet_create_reply(packet, "i", ret);
@@ -170,53 +111,40 @@ static struct packet *add_shortcut_handler(pid_t pid, int handle, const struct p
 
 static struct packet *add_shortcut_widget_handler(pid_t pid, int handle, const struct packet *packet)
 {
-       const char *appid;
+       const char *widget_id;
        const char *name;
        int type;
        const char *content;
        const char *icon;
        double period;
        int allow_duplicate;
-       int ret;
+       int ret = SHORTCUT_ERROR_NONE;
        int sender_pid;
 
        if (!packet) {
                return NULL;
        }
 
-       if (packet_get(packet, "ississdi", &sender_pid, &appid, &name, &type, &content, &icon, &period, &allow_duplicate) != 8) {
+       if (packet_get(packet, "ississdi", &sender_pid, &widget_id, &name, &type, &content, &icon, &period, &allow_duplicate) != 8) {
                ErrPrint("Invalid packet\n");
                return NULL;
        }
 
-       DbgPrint("appid[%s], name[%s], type[0x%x], content[%s], icon[%s], period[%lf], allow_duplicate[%d]\n", appid, name, type, content, icon, period, allow_duplicate);
+       DbgPrint("widget_id[%s], name[%s], type[0x%x], content[%s], icon[%s], period[%lf], allow_duplicate[%d]\n", widget_id, name, type, content, icon, period, allow_duplicate);
 
        if (s_info.server_cb.request_cb) {
-               ret = s_info.server_cb.request_cb(appid, name, type, content, icon, sender_pid, period, allow_duplicate, s_info.server_cb.data);
+               ret = s_info.server_cb.request_cb(widget_id, name, type, content, icon, sender_pid, period, allow_duplicate, s_info.server_cb.data);
        } else {
                ret = 0;
        }
 
-       return packet_create_reply(packet, "i", ret);
-}
-
-
-
-static void master_started_cb(keynode_t *node, void *user_data)
-{
-       int state = 0;
-
-       if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &state) < 0) {
-               ErrPrint("Unable to get \"%s\"\n", VCONFKEY_MASTER_STARTED);
+       if (ret != SHORTCUT_ERROR_NONE) {
+               ErrPrint("ret [%d]\n", ret);
        }
 
-       if (state == 1 && make_connection() == SHORTCUT_ERROR_NONE) {
-               (void)vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb);
-       }
+       return packet_create_reply(packet, "i", ret);
 }
 
-
-
 int shortcut_is_master_ready(void)
 {
        int ret = -1, is_master_started = 0;
@@ -232,7 +160,18 @@ int shortcut_is_master_ready(void)
        return is_master_started;
 }
 
+static void master_started_cb(keynode_t *node, void *user_data)
+{
+       int state = 0;
+
+       if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &state) < 0) {
+               ErrPrint("Unable to get \"%s\"\n", VCONFKEY_MASTER_STARTED);
+       }
 
+       if (state == 1 && make_connection() == SHORTCUT_ERROR_NONE) {
+               (void)vconf_ignore_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb);
+       }
+}
 
 static gboolean timeout_cb(void *data)
 {
@@ -274,8 +213,6 @@ static int disconnected_cb(int handle, void *data)
        return 0;
 }
 
-
-
 static inline int make_connection(void)
 {
        int ret;
@@ -289,18 +226,6 @@ static inline int make_connection(void)
                        .cmd = "add_shortcut_widget",
                        .handler = add_shortcut_widget_handler,
                },
-               {
-                       .cmd = "rm_shortcut",
-                       .handler = remove_shortcut_handler,
-               },
-               {
-                       .cmd = "rm_shortcut_widget",
-                       .handler = remove_shortcut_widget_handler,
-               },
-               {
-                       .cmd = NULL,
-                       .handler = NULL,
-               },
        };
 
        if (s_info.initialized == 0) {
@@ -378,7 +303,7 @@ static char *_shortcut_get_pkgname_by_pid(void)
 
        dup_pkgname = strdup(pkgname);
        if (!dup_pkgname)
-               ErrPrint("Heap: %s\n", strerror(errno));
+               ErrPrint("Heap: %d\n", errno);
 
        return dup_pkgname;
 }
@@ -412,15 +337,12 @@ EAPI int shortcut_set_request_cb(shortcut_request_cb request_cb, void *data)
 }
 
 
-
 struct result_cb_item {
        result_internal_cb_t result_internal_cb;
        result_cb_t result_cb;
        void *data;
 };
 
-
-
 static int shortcut_send_cb(pid_t pid, int handle, const struct packet *packet, void *data)
 {
        struct result_cb_item *item = data;
@@ -434,6 +356,12 @@ static int shortcut_send_cb(pid_t pid, int handle, const struct packet *packet,
                ret = SHORTCUT_ERROR_INVALID_PARAMETER;
        }
 
+       if (ret != SHORTCUT_ERROR_NONE) {
+               DbgPrint("Packet reply [%d]\n", ret);
+               if (ret == SHORTCUT_ERROR_PERMISSION_DENIED)
+                       ret =SHORTCUT_ERROR_NONE;
+       }
+
        if (item->result_internal_cb) {
                ret = item->result_internal_cb(ret, pid, item->data);
        } else if (item->result_cb) {
@@ -446,204 +374,20 @@ static int shortcut_send_cb(pid_t pid, int handle, const struct packet *packet,
 }
 
 
-
-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)
+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;
-       int ret;
-
-       if (!appid || !name) {
-               ErrPrint("Invalid argument\n");
-               return SHORTCUT_ERROR_INVALID_PARAMETER;
-       }
-
-       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) {
-                       ErrPrint("Failed to make connection\n");
-                       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 = result_cb;
-       item->result_cb = NULL;
-       item->data = data;
-
-       packet = packet_create("rm_shortcut", "isss", getpid(), appid, name, content_info);
-       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;
-       }
-
+       /*Deprecated API */
        return SHORTCUT_ERROR_NONE;
 }
 
-
-
-EAPI int add_to_home_remove_dynamicbox(const char *appid, const char *name, result_internal_cb_t result_cb, void *data)
+EAPI int add_to_home_dynamicbox(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;
-       int ret;
-
-       if (!appid || !name) {
-               ErrPrint("Invalid argument\n");
-               return SHORTCUT_ERROR_INVALID_PARAMETER;
-       }
-
-       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) {
-                       ErrPrint("Failed to make connection\n");
-                       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 = result_cb;
-       item->result_cb = NULL;
-       item->data = data;
-
-       packet = packet_create("rm_dynamicbox", "iss", getpid(), appid, name);
-       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;
-       }
-
+       /*Deprecated API */
        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_internal_cb_t result_cb, void *data)
-{
-       struct packet *packet;
-       struct result_cb_item *item;
-       int ret;
-
-       if (!appid || ADD_TO_HOME_IS_DYNAMICBOX(type)) {
-               ErrPrint("Invalid type used for adding a shortcut\n");
-               return SHORTCUT_ERROR_INVALID_PARAMETER;
-       }
-
-       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) {
-                       ErrPrint("Failed to make connection\n");
-                       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 = result_cb;
-       item->result_cb = NULL;
-       item->data = data;
-
-       if (!name) {
-               name = "";
-       }
-
-       if (!content) {
-               content = "";
-       }
-
-       if (!icon) {
-               icon = "";
-       }
-
-       packet = packet_create("add_shortcut", "ississi", getpid(), appid, name, type, content, icon, 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(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;
@@ -690,7 +434,7 @@ EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *
                if (appid) {
                        free(appid);
                }
-               ErrPrint("Heap: %s\n", strerror(errno));
+               ErrPrint("Heap: %d\n", errno);
                return SHORTCUT_ERROR_OUT_OF_MEMORY;
        }
 
@@ -737,81 +481,24 @@ EAPI int shortcut_add_to_home(const char *name, shortcut_type type, const char *
 }
 
 
-EAPI int add_to_home_dynamicbox(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;
-       int ret;
-
-       if (!appid || !ADD_TO_HOME_IS_DYNAMICBOX(type)) {
-               ErrPrint("Invalid type is used for adding a dynamicbox\n");
-               return SHORTCUT_ERROR_INVALID_PARAMETER;
-       }
-
-       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 = result_cb;
-       item->result_cb = NULL;
-       item->data = data;
-
-       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)
+EAPI int shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e size, const char *widget_id, 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;
+       int err = SHORTCUT_ERROR_NONE;
 
        if (name == NULL) {
                ErrPrint("AppID is null\n");
-               return SHORTCUT_ERROR_INVALID_PARAMETER;
+               err = SHORTCUT_ERROR_INVALID_PARAMETER;
+               goto out;
        }
 
        if (!SHORTCUT_IS_WIDGET_SIZE(size)) {
                ErrPrint("Invalid type used for adding a widget\n");
-               return SHORTCUT_ERROR_INVALID_PARAMETER;
+               err = SHORTCUT_ERROR_INVALID_PARAMETER;
+               goto out;
        }
 
        appid = _shortcut_get_pkgname_by_pid();
@@ -831,25 +518,28 @@ EAPI int shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e si
 
                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;
+                       err = SHORTCUT_ERROR_COMM;
+                       goto out;
                }
        }
 
        item = malloc(sizeof(*item));
        if (!item) {
-               ErrPrint("Heap: %s\n", strerror(errno));
-               return SHORTCUT_ERROR_OUT_OF_MEMORY;
+               ErrPrint("Heap: %d\n", errno);
+               err = SHORTCUT_ERROR_OUT_OF_MEMORY;
+               goto out;
        }
 
        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);
+       packet = packet_create("add_shortcut_widget", "ississdi", getpid(), widget_id, name, size, NULL, icon, period, allow_duplicate);
        if (!packet) {
                ErrPrint("Failed to build a packet\n");
                free(item);
-               return SHORTCUT_ERROR_FAULT;
+               err = SHORTCUT_ERROR_FAULT;
+               goto out;
        }
 
        ret = com_core_packet_async_send(s_info.client_fd, packet, 0.0f, shortcut_send_cb, item);
@@ -858,29 +548,29 @@ EAPI int shortcut_add_to_home_widget(const char *name, shortcut_widget_size_e si
                free(item);
                com_core_packet_client_fini(s_info.client_fd);
                s_info.client_fd = SHORTCUT_ERROR_INVALID_PARAMETER;
-               return SHORTCUT_ERROR_COMM;
+               err =  SHORTCUT_ERROR_COMM;
+               goto out;
        }
+out:
+       if (appid)
+               free(appid);
 
-       return SHORTCUT_ERROR_NONE;
+       return err;
 }
 
-
-
 static inline int open_db(void)
 {
        int ret;
 
        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. error [%d]\n", s_info.dbfile, ret);
+               DbgPrint("Failed to open a %s\n", s_info.dbfile);
                return SHORTCUT_ERROR_IO_ERROR;
        }
 
        return SHORTCUT_ERROR_NONE;
 }
 
-
-
 /*!
  * \note this function will returns allocated(heap) string
  */
@@ -925,7 +615,7 @@ static inline int get_i18n_name(const char *lang, int id, char **name, char **ic
                if (_name && strlen((const char *)_name)) {
                        *name = strdup((const char *)_name);
                        if (!*name) {
-                               ErrPrint("strdup: %s\n", strerror(errno));
+                               ErrPrint("strdup: %d\n", errno);
                                ret = -ENOMEM;
                                goto out;
                        }
@@ -939,7 +629,7 @@ static inline int get_i18n_name(const char *lang, int id, char **name, char **ic
                if (_icon && strlen((const char *)_icon)) {
                        *icon = strdup((const char *)_icon);
                        if (!*icon) {
-                               ErrPrint("strdup: %s\n", strerror(errno));
+                               ErrPrint("strdup: %d\n", errno);
                                ret = -ENOMEM;
                                if (name && *name) {
                                        free(*name);
@@ -958,8 +648,6 @@ out:
        return ret;
 }
 
-
-
 static inline char *cur_locale(void)
 {
        char *language;
@@ -983,18 +671,13 @@ static inline char *cur_locale(void)
        } else {
                language = strdup("en-us");
                if (!language) {
-                       ErrPrint("Heap: %s\n", strerror(errno));
+                       ErrPrint("Heap: %d\n", errno);
                }
        }
 
        return language;
 }
 
-
-
-/*!
- * \note READ ONLY DB
- */
 EAPI int shortcut_get_list(const char *package_name, shortcut_list_cb list_cb, void *data)
 {
        sqlite3_stmt *stmt;
index 11ff7fa..fd422fb 100755 (executable)
@@ -1,6 +1,6 @@
 Name: libshortcut
 Summary: Shortcut add feature supporting library
-Version: 0.6.14
+Version: 0.6.16
 Release: 0
 Group: Applications/Core Applications
 License: Apache-2.0
@@ -49,26 +49,26 @@ export CXXFLAGS="${CXXFLAGS} -DTIZEN_ENGINEER_MODE"
 export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE"
 %endif
 
-%cmake . -DSYSCONFDIR=%{_sysconfdir}
+%cmake . -DSYSCONFDIR=%{_sysconfdir} -DDB_PATH=%{TZ_SYS_DB}/.shortcut_service.db
 make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
 
 %make_install
-mkdir -p %{buildroot}/usr/dbspace
+mkdir -p %{buildroot}%{TZ_SYS_DB}
 
 %post
 /sbin/ldconfig
 
-if [ ! -d /usr/dbspace ]
+if [ ! -d %{TZ_SYS_DB} ]
 then
-       mkdir /usr/dbspace
+       mkdir %{TZ_SYS_DB}
 fi
 
-if [ ! -f /usr/dbspace/.shortcut_service.db ]
+if [ ! -f %{TZ_SYS_DB}/.shortcut_service.db ]
 then
-       sqlite3 /usr/dbspace/.shortcut_service.db 'PRAGMA journal_mode = PERSIST;
+       sqlite3 %{TZ_SYS_DB}/.shortcut_service.db 'PRAGMA journal_mode = PERSIST;
                CREATE TABLE shortcut_service (
                id INTEGER PRIMARY KEY AUTOINCREMENT,
                pkgid TEXT,
@@ -87,10 +87,10 @@ then
        '
 fi
 
-chmod 664 /usr/dbspace/.shortcut_service.db
-chmod 664 /usr/dbspace/.shortcut_service.db-journal
-chsmack -a User::Home /usr/dbspace/.shortcut_service.db
-chsmack -a User::Home /usr/dbspace/.shortcut_service.db-journal
+chmod 664 %{TZ_SYS_DB}/.shortcut_service.db
+chmod 664 %{TZ_SYS_DB}/.shortcut_service.db-journal
+chsmack -a User::Home %{TZ_SYS_DB}/.shortcut_service.db
+chsmack -a User::Home %{TZ_SYS_DB}/.shortcut_service.db-journal
 
 %postun -n %{name} -p /sbin/ldconfig
 
index bcb4f0a..2207ec7 100644 (file)
@@ -18,6 +18,7 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -Wall -Werror")
 
 ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
 ADD_DEFINITIONS("-DLOG_TAG=\"PKGMGR_SHORTCUT\"")
+ADD_DEFINITIONS("-DDB_PATH=\"${DB_PATH}\"")
 
 ADD_LIBRARY(${PROJECT_NAME} SHARED
        src/service_register.c
index 190e351..d5763bf 100755 (executable)
@@ -69,7 +69,7 @@ static struct {
        const char *dbfile;
        sqlite3 *handle;
 } s_info = {
-       .dbfile = "/usr/dbspace/.shortcut_service.db",
+       .dbfile = DB_PATH,
        .handle = NULL,
 };
 
@@ -744,7 +744,7 @@ static int db_init(void)
        }
 
        if (lstat(s_info.dbfile, &stat) < 0) {
-               ErrPrint("%s\n", strerror(errno));
+               ErrPrint("%d\n", errno);
                db_util_close(s_info.handle);
                s_info.handle = NULL;
                return -EIO;
@@ -815,7 +815,7 @@ static inline struct i18n_name *create_i18n_name(xmlChar *lang, xmlChar *name, x
 
        i18n = malloc(sizeof(*i18n));
        if (!i18n) {
-               ErrPrint("Heap: %s\n", strerror(errno));
+               ErrPrint("Heap: %d\n", errno);
                return NULL;
        }