Add event type for handling the close PD request
authorSung-jae Park <nicesj.park@samsung.com>
Sat, 7 Dec 2013 06:14:34 +0000 (15:14 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Sat, 7 Dec 2013 06:14:34 +0000 (15:14 +0900)
Change-Id: I9cca9baf5186d2877f2618da3db68600baeccf68

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

index 60a6f98..73619c7 100644 (file)
@@ -194,6 +194,8 @@ enum livebox_event_type { /*!< livebox_event_handler_set Event list */
 
        LB_EVENT_UPDATE_MODE_CHANGED, /*!< Livebox Update mode is changed */
 
+       LB_EVENT_REQUEST_CLOSE_PD, /*!< Livebox requests to close the PD */
+
        LB_EVENT_IGNORED /*!< Request is ignored */
 };
 
index 977603e..c2305be 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox-viewer
 Summary: Library for developing the application.
-Version: 0.15.0
+Version: 0.16.0
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
index fc0851f..8ce8114 100644 (file)
@@ -423,6 +423,37 @@ out:
        return NULL;
 }
 
+static struct packet *master_request_close_pd(pid_t pid, int handle, const struct packet *packet)
+{
+       struct livebox *handler;
+       const char *pkgname;
+       const char *id;
+       int ret;
+       int reason;
+
+       ret = packet_get(packet, "ssi", &pkgname, &id, &reason);
+       if (ret != 3) {
+               ErrPrint("Invalid argument\n");
+               goto out;
+       }
+
+       handler = lb_find_livebox(pkgname, id);
+       if (!handler) {
+               ErrPrint("Instance[%s] is not exists\n", id);
+               goto out;
+       }
+
+       if (handler->state != CREATE) {
+               ErrPrint("[%s] is not created\n", id);
+               goto out;
+       }
+
+       DbgPrint("Reason: %d\n", reason);
+       lb_invoke_event_handler(handler, LB_EVENT_REQUEST_CLOSE_PD);
+out:
+       return NULL;
+}
+
 static struct packet *master_access_status(pid_t pid, int handle, const struct packet *packet)
 {
        struct livebox *handler;
@@ -1323,6 +1354,10 @@ static struct method s_table[] = {
                .cmd = "key_status",
                .handler = master_key_status,
        },
+       {
+               .cmd = "close_pd",
+               .handler = master_request_close_pd,
+       },
 
        {
                .cmd = NULL,