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})
+++ /dev/null
-/*
- * 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 */
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.
*/
#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));
/**
* @}
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
* @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.
*
* 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;
*
* 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);
/**
#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 */
+++ /dev/null
-/*
- * 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 */
int errno;
+static inline int make_connection(void);
+
static struct info {
const char *dbfile;
sqlite3 *handle;
.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;
const char *content;
const char *icon;
int allow_duplicate;
- int ret;
+ int ret = SHORTCUT_ERROR_NONE;
int sender_pid;
if (!packet) {
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);
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;
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)
{
return 0;
}
-
-
static inline int make_connection(void)
{
int ret;
.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) {
dup_pkgname = strdup(pkgname);
if (!dup_pkgname)
- ErrPrint("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %d\n", errno);
return dup_pkgname;
}
}
-
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;
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) {
}
-
-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;
if (appid) {
free(appid);
}
- ErrPrint("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %d\n", errno);
return SHORTCUT_ERROR_OUT_OF_MEMORY;
}
}
-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();
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);
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
*/
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;
}
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);
return ret;
}
-
-
static inline char *cur_locale(void)
{
char *language;
} 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;
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
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,
'
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
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
const char *dbfile;
sqlite3 *handle;
} s_info = {
- .dbfile = "/usr/dbspace/.shortcut_service.db",
+ .dbfile = DB_PATH,
.handle = NULL,
};
}
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;
i18n = malloc(sizeof(*i18n));
if (!i18n) {
- ErrPrint("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %d\n", errno);
return NULL;
}