Don't try to make a connection again from discon cb
authorSung-jae Park <nicesj.park@samsung.com>
Mon, 20 May 2013 11:28:44 +0000 (20:28 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Mon, 20 May 2013 11:28:44 +0000 (20:28 +0900)
Change-Id: I7d26a4eb113246e4cea2358bb1268c25b4eaf770

packaging/liblivebox-viewer.spec
src/client.c
src/livebox.c

index 167b453..529589c 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox-viewer
 Summary: Library for developing the application.
-Version: 0.13.1
+Version: 0.13.3
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
index 76a91b1..18cbbec 100644 (file)
 
 static struct info {
        int fd;
+       guint timer_id;
 } s_info = {
        .fd = -1,
+       .timer_id = 0,
 };
 
 static struct packet *master_fault_package(pid_t pid, int handle, const struct packet *packet)
@@ -1312,6 +1314,19 @@ static void master_started_cb(keynode_t *node, void *data)
        }
 }
 
+static gboolean timeout_cb(gpointer data)
+{
+       if (vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL) < 0)
+               ErrPrint("Failed to add vconf for monitoring service state\n");
+       else
+               DbgPrint("vconf event callback 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.fd != handle) {
@@ -1326,12 +1341,18 @@ static int disconnected_cb(int handle, void *data)
 
        lb_delete_all();
 
-       if (vconf_notify_key_changed(VCONFKEY_MASTER_STARTED, master_started_cb, NULL) < 0)
-               ErrPrint("Failed to add vconf for monitoring service state\n");
-       else
-               DbgPrint("vconf event callback is registered\n");
+       /* Try to reconnect after 1 sec later */
+       if (!s_info.timer_id) {
+               DbgPrint("Reconnecting timer is added\n");
+               s_info.timer_id = g_timeout_add(1000, timeout_cb, NULL);
+               if (s_info.timer_id == 0) {
+                       ErrPrint("Unable to add reconnecting timer\n");
+                       return 0;
+               }
+       } else {
+               ErrPrint("Reconnecting timer is already exists\n");
+       }
 
-       master_started_cb(NULL, NULL);
        return 0;
 }
 
index 0ceae6f..19fc458 100644 (file)
@@ -1087,6 +1087,9 @@ EAPI int livebox_click(struct livebox *handler, double x, double y)
        double timestamp;
        int ret;
 
+       timestamp = util_timestamp();
+       DbgPrint("CLICKED: %lf\n", timestamp);
+
        if (!handler) {
                ErrPrint("Handler is NIL\n");
                return LB_STATUS_ERROR_INVALID;
@@ -1103,7 +1106,6 @@ EAPI int livebox_click(struct livebox *handler, double x, double y)
                        ErrPrint("Failed to launch app %s\n", handler->lb.auto_launch);
        }
 
-       timestamp = util_timestamp();
        packet = packet_create_noack("clicked", "sssddd", handler->pkgname, handler->id, "clicked", timestamp, x, y);
        if (!packet) {
                ErrPrint("Failed to build param\n");