Add new resized event type.
[platform/framework/web/livebox-viewer.git] / src / client.c
index e84c67b..265189d 100644 (file)
@@ -241,7 +241,7 @@ static struct packet *master_lb_updated(pid_t pid, int handle, const struct pack
 
        if (lb_text_lb(handler)) {
                lb_set_size(handler, lb_w, lb_h);
-               ret = parse_desc(handler, util_uri_to_path(id), 0);
+               ret = parse_desc(handler, livebox_filename(handler), 0);
                /*!
                 * \note
                 * DESC parser will call the "text event callback".
@@ -428,6 +428,65 @@ out:
        return NULL;
 }
 
+static struct packet *master_size_changed(pid_t pid, int handle, const struct packet *packet)
+{
+       struct livebox *handler;
+       const char *pkgname;
+       const char *id;
+       int status;
+       int ret;
+       int w;
+       int h;
+       int is_pd;
+
+       ret = packet_get(packet, "ssiiii", &pkgname, &id, &is_pd, &w, &h, &status);
+       if (ret != 6) {
+               ErrPrint("Invalid argument\n");
+               ret = EINVAL;
+               goto out;
+       }
+
+       handler = lb_find_livebox(pkgname, id);
+       if (!handler) {
+               ErrPrint("Livebox(%s - %s) is not found\n", pkgname, id);
+               ret = -ENOENT;
+               goto out;
+       }
+
+       if (handler->state != CREATE) {
+               ret = -EPERM;
+               goto out;
+       }
+
+       if (is_pd) {
+               /*!
+                * \NOTE
+                * PD is not able to resized by the client.
+                * PD is only can be managed by the provider.
+                * So the PD has no private resized event handler.
+                * Notify it via global event handler.
+                */
+               lb_invoke_event_handler(handler, LB_EVENT_PD_SIZE_CHANGED);
+               if (status != 0)
+                       ErrPrint("This is not possible. PD Size is changed but the return value is not ZERO\n");
+       } else {
+               if (status == 0)
+                       lb_set_size(handler, w, h);
+
+               if (handler->size_changed_cb) {
+                       handler->size_changed_cb(handler, status, handler->size_cbdata);
+
+                       handler->size_changed_cb = NULL;
+                       handler->size_cbdata = NULL;
+               } else {
+                       lb_invoke_event_handler(handler, LB_EVENT_LB_SIZE_CHANGED);
+               }
+       }
+
+out:
+       return NULL;
+}
+
 static struct packet *master_period_changed(pid_t pid, int handle, const struct packet *packet)
 {
        struct livebox *handler;
@@ -544,7 +603,7 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet
        const char *title;
 
        double timestamp;
-       int auto_launch;
+       const char *auto_launch;
        double priority;
        int size_list;
        int user;
@@ -558,7 +617,7 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet
 
        int ret;
 
-       ret = packet_get(packet, "dsssiiiissssidiiiiidsi",
+       ret = packet_get(packet, "dsssiiiisssssdiiiiidsi",
                        &timestamp,
                        &pkgname, &id, &content,
                        &lb_w, &lb_h, &pd_w, &pd_h,
@@ -574,7 +633,7 @@ static struct packet *master_created(pid_t pid, int handle, const struct packet
        ErrPrint("[%lf] pkgname: %s, id: %s, content: %s, "
                "pd_w: %d, pd_h: %d, lb_w: %d, lb_h: %d, "
                "cluster: %s, category: %s, lb_fname: \"%s\", pd_fname: \"%s\", "
-               "auto_launch: %d, priority: %lf, size_list: %d, user: %d, pinup: %d, "
+               "auto_launch: %s, priority: %lf, size_list: %d, user: %d, pinup: %d, "
                "lb_type: %d, pd_type: %d, period: %lf, title: [%s], is_pinned_up: %d\n",
                timestamp, pkgname, id, content,
                pd_w, pd_h, lb_w, lb_h,
@@ -765,6 +824,10 @@ static struct method s_table[] = {
                .handler = master_period_changed,
        },
        {
+               .cmd = "size_changed",
+               .handler = master_size_changed,
+       },
+       {
                .cmd = "pinup",
                .handler = master_pinup,
        },