Update the deleted event handler.
authorSung-jae Park <nicesj.park@samsung.com>
Sun, 4 Nov 2012 11:50:18 +0000 (20:50 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Sun, 4 Nov 2012 14:39:17 +0000 (23:39 +0900)
Change-Id: I8f3834092c31408a0cb0e871440c417490f42543

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

index ead03aa..b8fcc6b 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox-viewer
 Summary: Library for the development of a livebox viewer
-Version: 0.7.0
+Version: 0.7.1
 Release: 1
 Group: main/app
 License: Samsung Proprietary License
index 3be6a17..44a44a5 100644 (file)
@@ -104,11 +104,9 @@ static struct packet *master_deleted(pid_t pid, int handle, const struct packet
        const char *id;
        double timestamp;
        struct livebox *handler;
-       int ret;
 
        if (packet_get(packet, "ssd", &pkgname, &id, &timestamp) != 3) {
                ErrPrint("Invalid arguemnt\n");
-               ret = -EINVAL;
                goto out;
        }
 
@@ -119,7 +117,6 @@ static struct packet *master_deleted(pid_t pid, int handle, const struct packet
                 * This can be happens only if the user delete a livebox
                 * right after create it before receive created event.
                 */
-               ret = -ENOENT;
                goto out;
        }
 
@@ -135,38 +132,42 @@ static struct packet *master_deleted(pid_t pid, int handle, const struct packet
                }
        }
 
-       if (!handler->id) {
+       if (handler->created_cb) {
                /*!
                 * \note
-                * This is not possible,
-                * master_deleted can only be called after creating an instance.
+                *
+                * "if (handler->id == NULL)"
+                *
+                * The instance is not created yet.
+                * But the master forcely destroy it and send destroyed event to this
+                * without the created event.
+                *
+                * It could be destroyed when a slave has critical error(fault)
+                * before creating an instance successfully.
                 */
-               CRITICAL_LOG("Livebox is not created yet (%s - %s)\n", pkgname, id);
-               return NULL;
-       }
+               if (handler->created_cb == handler->deleted_cb) {
+                       if (handler->created_cbdata != handler->deleted_cbdata)
+                               DbgPrint("cb is same but cbdata is different (%s - %s)\n", pkgname, id);
 
-       ret = 0;
-
-       if (handler->created_cb && handler->created_cb == handler->deleted_cb) {
-               if (handler->created_cbdata != handler->deleted_cbdata)
-                       CRITICAL_LOG("cb is same but cbdata is different (%s - %s)\n", pkgname, id);
+                       handler->deleted_cb = NULL;
+                       handler->deleted_cbdata = NULL;
+               }
 
                DbgPrint("Call the created cb with -ECANCELED\n");
                handler->created_cb(handler, -ECANCELED, handler->created_cbdata);
-
                handler->created_cb = NULL;
                handler->created_cbdata = NULL;
-               handler->deleted_cb = NULL;
-               handler->deleted_cbdata = NULL;
-       } else if (handler->deleted_cb) {
-               DbgPrint("Call the deleted cb\n");
-               handler->deleted_cb(handler, ret, handler->deleted_cbdata);
-
-               handler->deleted_cb = NULL;
-               handler->deleted_cbdata = NULL;
-       } else {
-               DbgPrint("Call the lb,deleted\n");
-               lb_invoke_event_handler(handler, LB_EVENT_DELETED);
+       } else if (handler->id) {
+               if (handler->deleted_cb) {
+                       DbgPrint("Call the deleted cb\n");
+                       handler->deleted_cb(handler, 0, handler->deleted_cbdata);
+
+                       handler->deleted_cb = NULL;
+                       handler->deleted_cbdata = NULL;
+               } else {
+                       DbgPrint("Call the lb,deleted\n");
+                       lb_invoke_event_handler(handler, LB_EVENT_DELETED);
+               }
        }
 
        DbgPrint("[%p] %s(%s) is deleted\n", handler, pkgname, id);