Add client pause/resume API
[platform/framework/web/livebox-viewer.git] / src / livebox.c
index 798aab9..6ca3adc 100644 (file)
@@ -163,9 +163,11 @@ static void resize_cb(struct livebox *handler, const struct packet *result, void
         * after this request.
         */
        if (ret == 0) {
+               DbgPrint("Resize request is done, prepare the size changed event\n");
                handler->size_changed_cb = cb;
                handler->size_cbdata = cbdata;
        } else {
+               DbgPrint("Resize request is failed: %d\n", ret);
                cb(handler, ret, cbdata);
        }
 }
@@ -597,11 +599,6 @@ EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *cont
                return NULL;
        }
 
-       if (livebox_service_is_enabled(pkgname) == 0) {
-               DbgPrint("Livebox [%s] is disabled package\n", pkgname);
-               return NULL;
-       }
-
        if (type != LB_SIZE_TYPE_UNKNOWN)
                livebox_service_get_size(type, &width, &height);
 
@@ -618,6 +615,13 @@ EAPI struct livebox *livebox_add_with_size(const char *pkgname, const char *cont
                return NULL;
        }
 
+       if (livebox_service_is_enabled(handler->pkgname) == 0) {
+               DbgPrint("Livebox [%s](%s) is disabled package\n", handler->pkgname, pkgname);
+               free(handler->pkgname);
+               free(handler);
+               return NULL;
+       }
+
        if (content) {
                handler->content = strdup(content);
                if (!handler->content) {
@@ -725,6 +729,9 @@ EAPI int livebox_set_period(struct livebox *handler, double period, ret_cb_t cb,
                return -EALREADY;
        }
 
+       if (handler->period_changed_cb)
+               DbgPrint("Already requested\n");
+
        packet = packet_create("set_period", "ssd", handler->pkgname, handler->id, period);
        if (!packet) {
                ErrPrint("Failed to build a packet %s\n", handler->pkgname);
@@ -884,6 +891,9 @@ EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *da
                return -EALREADY;
        }
 
+       if (handler->size_changed_cb)
+               DbgPrint("Already pended\n");
+
        packet = packet_create("resize", "ssii", handler->pkgname, handler->id, w, h);
        if (!packet) {
                ErrPrint("Failed to build param\n");
@@ -1287,6 +1297,9 @@ EAPI int livebox_set_group(struct livebox *handler, const char *cluster, const c
                return -EALREADY;
        }
 
+       if (handler->group_changed_cb)
+               DbgPrint("Already sent\n");
+
        packet = packet_create("change_group", "ssss", handler->pkgname, handler->id, cluster, category);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
@@ -1800,6 +1813,9 @@ EAPI int livebox_set_pinup(struct livebox *handler, int flag, ret_cb_t cb, void
                return -EALREADY;
        }
 
+       if (handler->pinup_cb)
+               DbgPrint("Already sent\n");
+
        packet = packet_create("pinup_changed", "ssi", handler->pkgname, handler->id, flag);
        if (!packet) {
                ErrPrint("Failed to build a param\n");
@@ -2518,4 +2534,30 @@ int lb_send_delete(struct livebox *handler, ret_cb_t cb, void *data)
        return master_rpc_async_request(handler, packet, 0, del_ret_cb, create_cb_info(cb, data));
 }
 
+EAPI int livebox_client_paused(void)
+{
+       struct packet *packet;
+
+       packet = packet_create_noack("client_paused", "d", util_timestamp());
+       if (!packet) {
+               ErrPrint("Failed to create a pause packet\n");
+               return -EFAULT;
+       }
+
+       return master_rpc_request_only(NULL, packet);
+}
+
+EAPI int livebox_client_resumed(void)
+{
+       struct packet *packet;
+
+       packet = packet_create_noack("client_resumed", "d", util_timestamp());
+       if (!packet) {
+               ErrPrint("Failed to create a resume packet\n");
+               return -EFAULT;
+       }
+
+       return master_rpc_request_only(NULL, packet);
+}
+
 /* End of a file */