Add new resized event type.
[platform/framework/web/livebox-viewer.git] / src / livebox.c
index 055778b..798aab9 100644 (file)
@@ -110,6 +110,11 @@ static inline void default_pd_destroyed_cb(struct livebox *handler, int ret, voi
        DbgPrint("Default PD destroyed event handler: %d\n", ret);
 }
 
+static inline void default_lb_size_changed_cb(struct livebox *handler, int ret, void *data)
+{
+       DbgPrint("Default LB size changed event handler: %d\n", ret);
+}
+
 static inline __attribute__((always_inline)) struct cb_info *create_cb_info(ret_cb_t cb, void *data)
 {
        struct cb_info *info;
@@ -157,9 +162,12 @@ static void resize_cb(struct livebox *handler, const struct packet *result, void
         * So the user can only get the resized value(result) from the first update event
         * after this request.
         */
-
-       if (cb)
+       if (ret == 0) {
+               handler->size_changed_cb = cb;
+               handler->size_cbdata = cbdata;
+       } else {
                cb(handler, ret, cbdata);
+       }
 }
 
 static void text_signal_cb(struct livebox *handler, const struct packet *result, void *data)
@@ -589,6 +597,11 @@ 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);
 
@@ -877,6 +890,9 @@ EAPI int livebox_resize(struct livebox *handler, int type, ret_cb_t cb, void *da
                return -EFAULT;
        }
 
+       if (!cb)
+               cb = default_lb_size_changed_cb;
+
        return master_rpc_async_request(handler, packet, 0, resize_cb, create_cb_info(cb, data));
 }
 
@@ -1957,6 +1973,27 @@ EAPI int livebox_unsubscribe_group(const char *cluster, const char *category)
        return master_rpc_request_only(NULL, packet);
 }
 
+EAPI int livebox_refresh(struct livebox *handler)
+{
+       struct packet *packet;
+
+       if (!handler) {
+               ErrPrint("Hnalder is NIL\n");
+               return -EINVAL;
+       }
+
+       if (handler->state != CREATE || !handler->id)
+               return -EINVAL;
+
+       packet = packet_create_noack("update", "ss", handler->pkgname, handler->id);
+       if (!packet) {
+               ErrPrint("Failed to create a packet\n");
+               return -EFAULT;
+       }
+
+       return master_rpc_request_only(handler, packet);
+}
+
 EAPI int livebox_refresh_group(const char *cluster, const char *category)
 {
        struct packet *packet;