summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-10-22 12:55:12 +0900
committerSung-jae Park <nicesj.park@samsung.com>2013-10-22 12:55:12 +0900
commit502c7807b32ad01020a8b679bd7f4160d9992f6f (patch)
treedc91e6a7469ab49f76742e7d67b4116e320a084a
parent74c1415f9ea0fd90960626b21b91ff86585baf78 (diff)
parent315141ea9cbbfa7d5d668e0d78bed9a869ac64e1 (diff)
downloadshortcut-accepted/tizen_generic.tar.gz
shortcut-accepted/tizen_generic.tar.bz2
shortcut-accepted/tizen_generic.zip
-rw-r--r--lib/CMakeLists.txt1
-rw-r--r--lib/include/shortcut.h12
-rw-r--r--lib/include/shortcut_internal.h16
-rw-r--r--lib/src/dlist.c29
-rw-r--r--lib/src/icon.c139
-rw-r--r--lib/src/main.c103
-rw-r--r--packaging/libshortcut.spec7
-rw-r--r--pkgmgr_shortcut/src/dlist.c26
-rw-r--r--pkgmgr_shortcut/src/service_register.c61
-rw-r--r--test/icon.c2
10 files changed, 290 insertions, 106 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index f02c651..924ab26 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -28,6 +28,7 @@ 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_LIBRARY(${PROJECT_NAME} SHARED
src/main.c
diff --git a/lib/include/shortcut.h b/lib/include/shortcut.h
index b2cd25e..95de869 100644
--- a/lib/include/shortcut.h
+++ b/lib/include/shortcut.h
@@ -29,7 +29,6 @@ extern "C" {
/**
* @defgroup SHORTCUT Add to home (shortcut)
- * @author Sung-jae Park <nicesj.park@samsung.com>
* @version 0.1
* @brief To enhance the Add to home feature. Two types of API set are supported.
* One for the homescreen developers.
@@ -107,7 +106,7 @@ enum shortcut_type {
LIVEBOX_TYPE_EASY_1x1 = 0x30010000,
LIVEBOX_TYPE_EASY_3x1 = 0x30020000,
LIVEBOX_TYPE_EASY_3x3 = 0x30040000,
- LIVEBOX_TYPE_UNKNOWN = 0x1FFF0000,
+ LIVEBOX_TYPE_UNKNOWN = 0x1FFF0000
};
enum shortcut_response {
@@ -122,8 +121,9 @@ enum shortcut_response {
SHORTCUT_ERROR_COMM = SHORTCUT_ERROR | 0x0040, /*!< Connection is not estabilished. or there is a problem of communication */
SHORTCUT_ERROR_MEMORY = SHORTCUT_ERROR | 0x0080, /*!< Memory is not enough to handle new request */
SHORTCUT_ERROR_IO = SHORTCUT_ERROR | 0x0100, /*!< Unable to access file or DB. Check your resource files */
+ SHORTCUT_ERROR_PERMISSION = SHORTCUT_ERROR | 0x0200, /*!< Has no permission to add a shortcut */
- SHORTCUT_STATUS_CARED = 0x08000000, /*!< Shortcut status is already cared. check this using SHORTCUT_STATUS_IS_CARED macro */
+ SHORTCUT_STATUS_CARED = 0x08000000 /*!< Shortcut status is already cared. check this using SHORTCUT_STATUS_IS_CARED macro */
};
#define ADD_TO_HOME_IS_LIVEBOX(type) (!!((type) & 0x10000000))
@@ -306,17 +306,17 @@ extern int add_to_home_remove_livebox(const char *appid, const char *name, resul
* }
*
* // Send the request to the shortcut service
- * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, "/usr/share/.../icon.png", NULL, NULL);
+ * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, "icon, "/usr/share/.../icon.png", NULL, NULL);
* if (ret < 0) {
* ...
* }
*
- * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, "app icon", NULL, NULL);
+ * ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, "text, "app icon", NULL, NULL);
* if (ret < 0) {
* ...
* }
*
- * ret = shortcut_icon_request_send(handle, LB_SIZE_TYPE_1x1, NULL, NULL, "/opt/usr/apps/com.samsung.cluster-home/data/out.png", result_cb, NULL);
+ * ret = shortcut_icon_request_send(handle, LB_SIZE_TYPE_1x1, NULL, NULL, "/opt/usr/apps/org.tizen.cluster-home/data/out.png", result_cb, NULL);
* if (ret < 0) {
* ...
* }
diff --git a/lib/include/shortcut_internal.h b/lib/include/shortcut_internal.h
index 5009ba2..c343603 100644
--- a/lib/include/shortcut_internal.h
+++ b/lib/include/shortcut_internal.h
@@ -15,9 +15,21 @@
*
*/
+#if !defined(SECURE_LOGD)
+#define SECURE_LOGD LOGD
+#endif
+
+#if !defined(SECURE_LOGE)
+#define SECURE_LOGE LOGE
+#endif
+
+#if !defined(SECURE_LOGW)
+#define SECURE_LOGW LOGW
+#endif
+
#if !defined(FLOG)
-#define DbgPrint(format, arg...) LOGD("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
-#define ErrPrint(format, arg...) LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
+#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg)
+#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg)
#else
extern FILE *__file_log_fp;
#define DbgPrint(format, arg...) do { fprintf(__file_log_fp, "[LOG] [%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg); fflush(__file_log_fp); } while (0)
diff --git a/lib/src/dlist.c b/lib/src/dlist.c
index fa3082a..3ae571b 100644
--- a/lib/src/dlist.c
+++ b/lib/src/dlist.c
@@ -45,8 +45,9 @@ struct dlist *dlist_append(struct dlist *list, void *data)
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->next = NULL;
item->data = data;
@@ -71,8 +72,9 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->data = data;
@@ -80,8 +82,9 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
item->prev = item;
item->next = NULL;
} else {
- if (list->prev->next)
+ if (list->prev->next) {
list->prev->next = item;
+ }
item->prev = list->prev;
item->next = list;
@@ -95,16 +98,19 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
{
- if (!list || !l)
+ if (!list || !l) {
return NULL;
+ }
- if (l == list)
+ if (l == list) {
list = l->next;
- else
+ } else {
l->prev->next = l->next;
+ }
- if (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.
@@ -113,8 +119,9 @@ struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
*
* If we didn't care about this, the head element(list) can indicates the invalid element.
*/
- else if (list)
+ else if (list) {
list->prev = l->prev;
+ }
free(l);
return list;
@@ -126,8 +133,9 @@ struct dlist *dlist_find_data(struct dlist *list, void *data)
void *_data;
dlist_foreach(list, l, _data) {
- if (data == _data)
+ if (data == _data) {
return l;
+ }
}
return NULL;
@@ -169,8 +177,9 @@ struct dlist *dlist_nth(struct dlist *l, int nth)
i = 0;
for (n = l; n; n = n->next) {
- if (i == nth)
+ if (i == nth) {
return n;
+ }
i++;
}
diff --git a/lib/src/icon.c b/lib/src/icon.c
index c29445b..45199ce 100644
--- a/lib/src/icon.c
+++ b/lib/src/icon.c
@@ -14,6 +14,7 @@
* limitations under the License.
*
*/
+#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
@@ -22,6 +23,8 @@
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <libgen.h>
+#include <sys/time.h>
+#include <time.h>
#include <dlog.h>
#include <glib.h>
@@ -42,7 +45,6 @@
#define CREATED 0x00BEEF00
#define DESTROYED 0x00DEAD00
-
static struct info {
int fd;
int (*init_cb)(int status, void *data);
@@ -52,6 +54,9 @@ static struct info {
const char *utility_socket;
struct dlist *pending_list;
+#if defined(_USE_ECORE_TIME_GET)
+ clockid_t type;
+#endif
} s_info = {
.fd = -1,
.init_cb = NULL,
@@ -60,6 +65,9 @@ static struct info {
.utility_socket = "/tmp/.utility.service",
.pending_list = NULL,
+#if defined(_USE_ECORE_TIME_GET)
+ .type = CLOCK_MONOTONIC,
+#endif
};
@@ -170,8 +178,9 @@ static inline struct shortcut_icon *shortcut_icon_request_ref(struct shortcut_ic
static int disconnected_cb(int handle, void *data)
{
- if (s_info.fd != handle)
+ if (s_info.fd != handle) {
return 0;
+ }
ErrPrint("Disconnected\n");
s_info.fd = -1;
@@ -205,8 +214,9 @@ static inline int shortcut_icon_desc_save(struct shortcut_desc *handle, const ch
struct block *block;
FILE *fp;
- if (!handle)
+ if (!handle) {
return -EINVAL;
+ }
fp = fopen(filename, "w+t");
if (!fp) {
@@ -252,7 +262,9 @@ static inline int shortcut_icon_desc_save(struct shortcut_desc *handle, const ch
DbgPrint("}\n");
}
- fclose(fp);
+ if (fclose(fp) != 0) {
+ ErrPrint("fclose: %s\n", strerror(errno));
+ }
return 0;
}
@@ -264,8 +276,9 @@ static inline struct block *find_block(struct shortcut_desc *handle, const char
struct dlist *l;
dlist_foreach(handle->block_list, l, block) {
- if (!strcmp(block->part, part) && !strcmp(block->id, id))
+ if (!strcmp(block->part, part) && (!id || !strcmp(block->id, id))) {
return block;
+ }
}
return NULL;
@@ -314,14 +327,17 @@ static inline int shortcut_icon_desc_add_block(struct shortcut_desc *handle, con
{
struct block *block;
- if (!handle || !type)
+ if (!handle || !type) {
return SHORTCUT_ERROR_INVALID;
+ }
- if (!part)
+ if (!part) {
part = "";
+ }
- if (!data)
+ if (!data) {
data = "";
+ }
if (target_id) {
if (strcmp(type, SHORTCUT_ICON_TYPE_SCRIPT)) {
@@ -404,9 +420,18 @@ static inline int shortcut_icon_desc_add_block(struct shortcut_desc *handle, con
block->idx = handle->last_idx++;
handle->block_list = dlist_append(handle->block_list, block);
} else {
- if (strcmp(block->type, type) || strcmp(block->target_id, target_id)) {
- ErrPrint("type or target id is not valid (%s, %s) or (%s, %s)\n",
- block->type, type, block->target_id, target_id);
+ if (strcmp(block->type, type)) {
+ ErrPrint("type is not valid (%s, %s)\n", block->type, type);
+ return -EINVAL;
+ }
+
+ if ((block->target_id && !target_id) || (!block->target_id && target_id)) {
+ ErrPrint("type is not valid (%s, %s)\n", block->type, type);
+ return -EINVAL;
+ }
+
+ if (block->target_id && target_id && strcmp(block->target_id, target_id)) {
+ ErrPrint("type is not valid (%s, %s)\n", block->type, type);
return -EINVAL;
}
@@ -433,8 +458,9 @@ static int icon_request_cb(pid_t pid, int handle, const struct packet *packet, v
}
}
- if (item->result_cb)
+ if (item->result_cb) {
item->result_cb(item->handle, ret, item->data);
+ }
(void)shortcut_icon_request_unref(item->handle);
free(item);
@@ -457,15 +483,17 @@ static inline int make_connection(void)
if (s_info.fd < 0) {
ret = SHORTCUT_ERROR_COMM;
- if (s_info.init_cb)
+ if (s_info.init_cb) {
s_info.init_cb(ret, s_info.cbdata);
+ }
} else {
struct dlist *l;
struct dlist *n;
struct pending_item *pend;
- if (s_info.init_cb)
+ if (s_info.init_cb) {
s_info.init_cb(SHORTCUT_SUCCESS, s_info.cbdata);
+ }
dlist_foreach_safe(s_info.pending_list, l, n, pend) {
s_info.pending_list = dlist_remove(s_info.pending_list, l);
@@ -474,8 +502,9 @@ static inline int make_connection(void)
packet_destroy(pend->packet);
if (ret < 0) {
ErrPrint("ret: %d\n", ret);
- if (pend->item->result_cb)
+ if (pend->item->result_cb) {
pend->item->result_cb(pend->item->handle, ret, pend->item->data);
+ }
free(pend->item);
}
@@ -494,8 +523,9 @@ static void master_started_cb(keynode_t *node, void *user_data)
{
int state = 0;
- if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &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_SUCCESS) {
int ret;
@@ -510,8 +540,9 @@ EAPI int shortcut_icon_service_init(int (*init_cb)(int status, void *data), void
{
int ret;
- if (s_info.fd >= 0)
+ if (s_info.fd >= 0) {
return -EALREADY;
+ }
if (s_info.initialized) {
s_info.initialized = 1;
@@ -522,10 +553,11 @@ EAPI int shortcut_icon_service_init(int (*init_cb)(int status, void *data), void
s_info.cbdata = data;
ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL);
- if (ret < 0)
+ if (ret < 0) {
ErrPrint("Failed to add vconf for service state [%d]\n", ret);
- else
+ } else {
DbgPrint("vconf is registered\n");
+ }
master_started_cb(NULL, NULL);
return 0;
@@ -544,8 +576,9 @@ EAPI int shortcut_icon_service_fini(void)
s_info.initialized = 0;
}
- if (s_info.fd < 0)
+ if (s_info.fd < 0) {
return -EINVAL;
+ }
com_core_packet_client_fini(s_info.fd);
s_info.init_cb = NULL;
@@ -555,8 +588,9 @@ EAPI int shortcut_icon_service_fini(void)
dlist_foreach_safe(s_info.pending_list, l, n, pend) {
s_info.pending_list = dlist_remove(s_info.pending_list, l);
packet_unref(pend->packet);
- if (pend->item->result_cb)
+ if (pend->item->result_cb) {
pend->item->result_cb(pend->item->handle, SHORTCUT_ERROR_COMM, pend->item->data);
+ }
free(pend->item);
free(pend);
}
@@ -651,30 +685,72 @@ EAPI int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type,
return -EINVAL;
}
- if (!layout)
+ if (!layout) {
layout = DEFAULT_ICON_LAYOUT;
+ }
- if (!group)
+ if (!group) {
group = DEFAULT_ICON_GROUP;
+ }
- len = strlen(outfile) + strlen(".desc") + 1;
+ len = strlen(outfile) + strlen(".desc") + 1 + 30; /* 30 == strlen(tv.tv_sec) + strlen(tv.tv_usec) + 10 (reserved) */
filename = malloc(len);
if (!filename) {
ErrPrint("Heap: %s\n", strerror(errno));
return -ENOMEM;
}
- snprintf(filename, len, "%s.desc", outfile);
+#if defined(_USE_ECORE_TIME_GET)
+ struct timespec ts;
+ double tv;
+ do {
+ if (clock_gettime(s_info.type, &ts) == 0) {
+ tv = ts.tv_sec + ts.tv_nsec / 1000000000.0f;
+ break;
+ }
+
+ ErrPrint("%d: %s\n", s_info.type, strerror(errno));
+ if (s_info.type == CLOCK_MONOTONIC) {
+ s_info.type = CLOCK_REALTIME;
+ } else if (s_info.type == CLOCK_REALTIME) {
+ struct timeval _tv;
+ if (gettimeofday(&_tv, NULL) < 0) {
+ ErrPrint("gettimeofday: %s\n", strerror(errno));
+ _tv.tv_sec = rand();
+ _tv.tv_usec = rand();
+ }
+
+ tv = (double)_tv.tv_sec + (double)_tv.tv_usec / 1000000.0f;
+ break;
+ }
+ } while (1);
+ ret = snprintf(filename, len, "%s.%lf.desc", outfile, tv);
+#else
+ struct timeval tv;
+ if (gettimeofday(&tv, NULL) != 0) {
+ ErrPrint("gettimeofday: %s\n", strerror(errno));
+ tv.tv_sec = rand();
+ tv.tv_usec = rand();
+ }
+
+ ret = snprintf(filename, len, "%s.%lu.%lu.desc", outfile, tv.tv_sec, tv.tv_usec);
+#endif
+ if (ret < 0) {
+ ErrPrint("snprintf: %s\n", strerror(errno));
+ goto out;
+ }
ret = shortcut_icon_desc_save(handle->desc, filename);
- if (ret < 0)
+ if (ret < 0) {
goto out;
+ }
item = malloc(sizeof(*item));
if (!item) {
ErrPrint("Heap: %s\n", strerror(errno));
- if (unlink(filename) < 0)
+ if (unlink(filename) < 0) {
ErrPrint("Unlink: %s\n", strerror(errno));
+ }
ret = -ENOMEM;
goto out;
}
@@ -686,8 +762,9 @@ EAPI int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type,
packet = packet_create("icon_create", "sssis", layout, group, filename, size_type, outfile);
if (!packet) {
ErrPrint("Failed to create a packet\n");
- if (unlink(filename) < 0)
+ if (unlink(filename) < 0) {
ErrPrint("Unlink: %s\n", strerror(errno));
+ }
free(item);
(void)shortcut_icon_request_unref(handle);
ret = -EFAULT;
@@ -699,8 +776,9 @@ EAPI int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type,
packet_destroy(packet);
if (ret < 0) {
ErrPrint("ret: %d\n", ret);
- if (unlink(filename) < 0)
+ if (unlink(filename) < 0) {
ErrPrint("Unlink: %s\n", strerror(errno));
+ }
free(item);
(void)shortcut_icon_request_unref(handle);
}
@@ -713,8 +791,9 @@ EAPI int shortcut_icon_request_send(struct shortcut_icon *handle, int size_type,
ErrPrint("Heap: %s\n", strerror(errno));
packet_destroy(packet);
free(item);
- if (unlink(filename) < 0)
+ if (unlink(filename) < 0) {
ErrPrint("Unlink: %s\n", strerror(errno));
+ }
(void)shortcut_icon_request_unref(handle);
ret = -ENOMEM;
goto out;
diff --git a/lib/src/main.c b/lib/src/main.c
index 0a27aa3..60b91b1 100644
--- a/lib/src/main.c
+++ b/lib/src/main.c
@@ -51,6 +51,7 @@ static struct info {
} server_cb;
int initialized;
int db_opened;
+ guint timer_id;
} s_info = {
.server_fd = -1,
.client_fd = -1,
@@ -59,6 +60,7 @@ static struct info {
.handle = NULL,
.initialized = 0,
.db_opened = 0,
+ .timer_id = 0,
};
@@ -85,10 +87,11 @@ static struct packet *remove_shortcut_handler(pid_t pid, int handle, const struc
DbgPrint("appid[%s], name[%s], content_info[%s]\n", appid, name, content_info);
- if (s_info.server_cb.request_cb)
+ 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
+ } else {
ret = SHORTCUT_ERROR_UNSUPPORTED;
+ }
return packet_create_reply(packet, "i", ret);
}
@@ -114,10 +117,11 @@ static struct packet *remove_livebox_handler(pid_t pid, int handle, const struct
DbgPrint("appid[%s], name[%s]\n", appid, name);
- if (s_info.server_cb.request_cb)
+ if (s_info.server_cb.request_cb) {
ret = s_info.server_cb.request_cb(appid, name, LIVEBOX_REMOVE, NULL, NULL, sender_pid, -1.0f, 0, s_info.server_cb.data);
- else
+ } else {
ret = SHORTCUT_ERROR_UNSUPPORTED;
+ }
return packet_create_reply(packet, "i", ret);
}
@@ -135,8 +139,9 @@ static struct packet *add_shortcut_handler(pid_t pid, int handle, const struct p
int ret;
int sender_pid;
- if (!packet)
+ if (!packet) {
return NULL;
+ }
if (packet_get(packet, "ississi", &sender_pid, &appid, &name, &type, &content, &icon, &allow_duplicate) != 7) {
ErrPrint("Invalid packet\n");
@@ -145,10 +150,11 @@ static struct packet *add_shortcut_handler(pid_t pid, int handle, const struct p
DbgPrint("appid[%s], name[%s], type[0x%x], content[%s], icon[%s] allow_duplicate[%d]\n", appid, name, type, content, icon, allow_duplicate);
- if (s_info.server_cb.request_cb)
+ 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
+ } else {
ret = SHORTCUT_ERROR_UNSUPPORTED;
+ }
return packet_create_reply(packet, "i", ret);
}
@@ -167,8 +173,9 @@ static struct packet *add_livebox_handler(pid_t pid, int handle, const struct pa
int ret;
int sender_pid;
- if (!packet)
+ if (!packet) {
return NULL;
+ }
if (packet_get(packet, "ississdi", &sender_pid, &appid, &name, &type, &content, &icon, &period, &allow_duplicate) != 8) {
ErrPrint("Invalid packet\n");
@@ -177,10 +184,11 @@ static struct packet *add_livebox_handler(pid_t pid, int handle, const struct pa
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);
- if (s_info.server_cb.request_cb)
+ 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);
- else
+ } else {
ret = 0;
+ }
return packet_create_reply(packet, "i", ret);
}
@@ -191,8 +199,9 @@ static void master_started_cb(keynode_t *node, void *user_data)
{
int state = 0;
- if (vconf_get_bool(VCONFKEY_MASTER_STARTED, &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_SUCCESS) {
int ret;
@@ -203,6 +212,25 @@ static void master_started_cb(keynode_t *node, void *user_data)
+static gboolean timeout_cb(void *data)
+{
+ int ret;
+
+ ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL);
+ if (ret < 0) {
+ ErrPrint("Failed to add vconf for service state [%d]\n", ret);
+ } else {
+ DbgPrint("vconf is registered\n");
+ }
+
+ master_started_cb(NULL, NULL);
+
+ s_info.timer_id = 0;
+ return FALSE;
+}
+
+
+
static int disconnected_cb(int handle, void *data)
{
if (s_info.client_fd == handle) {
@@ -211,15 +239,13 @@ static int disconnected_cb(int handle, void *data)
}
if (s_info.server_fd == handle) {
- int ret;
- s_info.server_fd = SHORTCUT_ERROR_INVALID;
- ret = vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL);
- if (ret < 0)
- ErrPrint("Failed to add vconf for service state [%d]\n", ret);
- else
- DbgPrint("vconf is registered\n");
-
- master_started_cb(NULL, NULL);
+ if (!s_info.timer_id) {
+ s_info.server_fd = SHORTCUT_ERROR_INVALID;
+ s_info.timer_id = g_timeout_add(1000, timeout_cb, NULL);
+ if (!s_info.timer_id) {
+ ErrPrint("Unable to add timer\n");
+ }
+ }
return 0;
}
@@ -332,10 +358,11 @@ static int shortcut_send_cb(pid_t pid, int handle, const struct packet *packet,
ret = SHORTCUT_ERROR_INVALID;
}
- if (item->result_cb)
+ if (item->result_cb) {
ret = item->result_cb(ret, pid, item->data);
- else
+ } else {
ret = SHORTCUT_SUCCESS;
+ }
free(item);
return ret;
}
@@ -471,6 +498,10 @@ EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, con
struct result_cb_item *item;
int ret;
+ if (ADD_TO_HOME_IS_LIVEBOX(type)) {
+ ErrPrint("Invalid type used for adding a shortcut\n");
+ }
+
if (!s_info.initialized) {
s_info.initialized = 1;
com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL);
@@ -500,17 +531,21 @@ EAPI int add_to_home_shortcut(const char *appid, const char *name, int type, con
item->result_cb = result_cb;
item->data = data;
- if (!appid)
+ if (!appid) {
appid = "";
+ }
- if (!name)
+ if (!name) {
name = "";
+ }
- if (!content)
+ if (!content) {
content = "";
+ }
- if (!icon)
+ if (!icon) {
icon = "";
+ }
packet = packet_create("add_shortcut", "ississi", getpid(), appid, name, type, content, icon, allow_duplicate);
if (!packet) {
@@ -539,6 +574,10 @@ EAPI int add_to_home_livebox(const char *appid, const char *name, int type, cons
struct result_cb_item *item;
int ret;
+ if (!ADD_TO_HOME_IS_LIVEBOX(type)) {
+ ErrPrint("Invalid type is used for adding a livebox\n");
+ }
+
if (!s_info.initialized) {
s_info.initialized = 1;
com_core_add_event_callback(CONNECTOR_DISCONNECTED, disconnected_cb, NULL);
@@ -553,8 +592,9 @@ EAPI int add_to_home_livebox(const char *appid, const char *name, int type, cons
};
s_info.client_fd = com_core_packet_client_init(s_info.socket_file, 0, service_table);
- if (s_info.client_fd < 0)
+ if (s_info.client_fd < 0) {
return SHORTCUT_ERROR_COMM;
+ }
}
item = malloc(sizeof(*item));
@@ -665,15 +705,17 @@ static inline char *cur_locale(void)
break;
}
- if (*ptr == '_')
+ if (*ptr == '_') {
*ptr = '-';
+ }
ptr++;
}
} else {
language = strdup("en-us");
- if (!language)
+ if (!language) {
ErrPrint("Heap: %s\n", strerror(errno));
+ }
}
return language;
@@ -698,8 +740,9 @@ EAPI int shortcut_get_list(const char *appid, int (*cb)(const char *appid, const
int cnt;
char *language;
- if (!s_info.db_opened)
+ if (!s_info.db_opened) {
s_info.db_opened = (open_db() == 0);
+ }
if (!s_info.db_opened) {
ErrPrint("Failed to open a DB\n");
diff --git a/packaging/libshortcut.spec b/packaging/libshortcut.spec
index c91e516..f158e07 100644
--- a/packaging/libshortcut.spec
+++ b/packaging/libshortcut.spec
@@ -1,6 +1,6 @@
Name: libshortcut
Summary: Shortcut add feature supporting library
-Version: 0.6.1
+Version: 0.6.8
Release: 0
Group: HomeTF/Framework
License: Apache License
@@ -36,6 +36,11 @@ Requires: %{name} = %{version}-%{release}
cp %{SOURCE1001} .
%build
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="${CFLAGS} -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="${CXXFLAGS} -DTIZEN_ENGINEER_MODE"
+export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE"
+%endif
%cmake .
make %{?jobs:-j%jobs}
diff --git a/pkgmgr_shortcut/src/dlist.c b/pkgmgr_shortcut/src/dlist.c
index 2b40ff4..1764dfd 100644
--- a/pkgmgr_shortcut/src/dlist.c
+++ b/pkgmgr_shortcut/src/dlist.c
@@ -46,8 +46,9 @@ struct dlist *dlist_append(struct dlist *list, void *data)
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->next = NULL;
item->data = data;
@@ -72,8 +73,9 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
struct dlist *item;
item = malloc(sizeof(*item));
- if (!item)
+ if (!item) {
return NULL;
+ }
item->data = data;
@@ -81,8 +83,9 @@ struct dlist *dlist_prepend(struct dlist *list, void *data)
item->prev = item;
item->next = NULL;
} else {
- if (list->prev->next)
+ if (list->prev->next) {
list->prev->next = item;
+ }
item->prev = list->prev;
item->next = list;
@@ -99,13 +102,15 @@ struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
if (!list || !l)
return NULL;
- if (l == list)
+ if (l == list) {
list = l->next;
- else
+ } else {
l->prev->next = l->next;
+ }
- if (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.
@@ -114,8 +119,9 @@ struct dlist *dlist_remove(struct dlist *list, struct dlist *l)
*
* If we didn't care about this, the head element(list) can indicates the invalid element.
*/
- else if (list)
+ else if (list) {
list->prev = l->prev;
+ }
free(l);
return list;
@@ -127,8 +133,9 @@ struct dlist *dlist_find_data(struct dlist *list, void *data)
void *_data;
dlist_foreach(list, l, _data) {
- if (data == _data)
+ if (data == _data) {
return l;
+ }
}
return NULL;
@@ -170,8 +177,9 @@ struct dlist *dlist_nth(struct dlist *l, int nth)
i = 0;
for (n = l; n; n = n->next) {
- if (i == nth)
+ if (i == nth) {
return n;
+ }
i++;
}
diff --git a/pkgmgr_shortcut/src/service_register.c b/pkgmgr_shortcut/src/service_register.c
index 3f38c06..31b83e7 100644
--- a/pkgmgr_shortcut/src/service_register.c
+++ b/pkgmgr_shortcut/src/service_register.c
@@ -31,9 +31,21 @@
#include "dlist.h"
+#if !defined(SECURE_LOGD)
+#define SECURE_LOGD LOGD
+#endif
+
+#if !defined(SECURE_LOGE)
+#define SECURE_LOGE LOGE
+#endif
+
+#if !defined(SECURE_LOGW)
+#define SECURE_LOGW LOGW
+#endif
+
#if !defined(FLOG)
-#define DbgPrint(format, arg...) LOGD("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
-#define ErrPrint(format, arg...) LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
+#define DbgPrint(format, arg...) SECURE_LOGD("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
+#define ErrPrint(format, arg...) SECURE_LOGE("[%s/%s:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg)
#endif
/* End of a file */
@@ -149,8 +161,9 @@ static inline void db_create_table(void)
return;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
ddl = "CREATE TABLE shortcut_name (id INTEGER, lang TEXT, name TEXT)";
if (sqlite3_exec(s_info.handle, ddl, NULL, NULL, &err) != SQLITE_OK) {
@@ -158,8 +171,9 @@ static inline void db_create_table(void)
return;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
ErrPrint("No changes to DB\n");
+ }
}
static inline int db_remove_record(const char *appid, const char *key, const char *data)
@@ -201,8 +215,9 @@ static inline int db_remove_record(const char *appid, const char *key, const cha
ErrPrint("Failed to execute the DML for %s - %s(%s)\n", appid, key, data);
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
DbgPrint("No changes\n");
+ }
out:
sqlite3_reset(stmt);
@@ -241,8 +256,9 @@ static inline int db_remove_name(int id)
goto out;
}
- if (sqlite3_changes(s_info.handle) == 0)
+ if (sqlite3_changes(s_info.handle) == 0) {
DbgPrint("No changes\n");
+ }
out:
sqlite3_reset(stmt);
@@ -445,16 +461,18 @@ static inline int db_init(void)
return -EINVAL;
}
- if (!stat.st_size)
+ if (!stat.st_size) {
db_create_table();
+ }
return 0;
}
static inline int db_fini(void)
{
- if (!s_info.handle)
+ if (!s_info.handle) {
return 0;
+ }
db_util_close(s_info.handle);
s_info.handle = NULL;
@@ -478,13 +496,15 @@ int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *_appid)
}
if (!s_info.handle) {
- if (db_init() < 0)
+ if (db_init() < 0) {
return -EIO;
+ }
}
for (root = root->children; root; root = root->next) {
- if (!xmlStrcasecmp(root->name, (const xmlChar *)"shortcut-list"))
+ if (!xmlStrcasecmp(root->name, (const xmlChar *)"shortcut-list")) {
break;
+ }
}
if (!root) {
@@ -495,11 +515,13 @@ int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char *_appid)
DbgPrint("AppID: %s\n", _appid);
root = root->children;
for (node = root; node; node = node->next) {
- if (node->type == XML_ELEMENT_NODE)
+ if (node->type == XML_ELEMENT_NODE) {
DbgPrint("Element %s\n", node->name);
+ }
- if (xmlStrcasecmp(node->name, (const xmlChar *)"shortcut"))
+ if (xmlStrcasecmp(node->name, (const xmlChar *)"shortcut")) {
continue;
+ }
if (!xmlHasProp(node, (xmlChar *)"extra_data")
|| !xmlHasProp(node, (xmlChar *)"extra_key")
@@ -585,13 +607,15 @@ int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
}
if (!s_info.handle) {
- if (db_init() < 0)
+ if (db_init() < 0) {
return -EIO;
+ }
}
for (root = root->children; root; root = root->next) {
- if (!xmlStrcasecmp(root->name, (const xmlChar *)"shortcut-list"))
+ if (!xmlStrcasecmp(root->name, (const xmlChar *)"shortcut-list")) {
break;
+ }
}
if (!root) {
@@ -603,11 +627,13 @@ int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
root = root->children; /* Jump to children node */
for (node = root; node; node = node->next) {
- if (node->type == XML_ELEMENT_NODE)
+ if (node->type == XML_ELEMENT_NODE) {
DbgPrint("Element %s\n", node->name);
+ }
- if (xmlStrcasecmp(node->name, (const xmlChar *)"shortcut"))
+ if (xmlStrcasecmp(node->name, (const xmlChar *)"shortcut")) {
continue;
+ }
if (!xmlHasProp(node, (xmlChar *)"extra_key") || !xmlHasProp(node, (xmlChar *)"extra_data")) {
DbgPrint("Invalid element %s\n", node->name);
@@ -696,8 +722,9 @@ int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr docPtr, const char *appid)
} else {
dlist_foreach_safe(i18n_list, l, n, i18n) {
i18n_list = dlist_remove(i18n_list, l);
- if (db_insert_name(id, (char *)i18n->lang, (char *)i18n->name) < 0)
+ if (db_insert_name(id, (char *)i18n->lang, (char *)i18n->name) < 0) {
ErrPrint("Failed to add i18n name: %s(%s)\n", i18n->name, i18n->lang);
+ }
xmlFree(i18n->lang);
xmlFree(i18n->name);
free(i18n);
diff --git a/test/icon.c b/test/icon.c
index 3086729..9267bad 100644
--- a/test/icon.c
+++ b/test/icon.c
@@ -41,7 +41,7 @@ static Eina_Bool test_main(void *data)
}
printf("Test: %d\n", idx);
- ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, "/usr/share/icons/default/small/com.samsung.music-player.png", NULL, NULL);
+ ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, "/usr/share/icons/default/small/org.tizen.music-player.png", NULL, NULL);
printf("NAME set_info: %d\n", ret);
snprintf(filename, sizeof(filename), "App Name %d", idx);