From 013231a41fea414f7a66f55844a96db08a1b5ce0 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Mon, 20 May 2013 20:30:34 +0900 Subject: [PATCH] Don't try to make a connection from discon cb. Change-Id: I10ac77e38f01643ae63d3da5165e169808bd384f --- lib/src/icon.c | 2 +- lib/src/main.c | 35 ++++++++++++++++++++++++++--------- packaging/libshortcut.spec | 2 +- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/lib/src/icon.c b/lib/src/icon.c index c29445b..b4eddce 100644 --- a/lib/src/icon.c +++ b/lib/src/icon.c @@ -264,7 +264,7 @@ 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; } diff --git a/lib/src/main.c b/lib/src/main.c index 0a27aa3..bbba095 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, }; @@ -203,6 +205,24 @@ 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 +231,12 @@ 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; } diff --git a/packaging/libshortcut.spec b/packaging/libshortcut.spec index 54d12f3..d194ff9 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.2 Release: 0 Group: HomeTF/Framework License: Apache License -- 2.7.4