Add client pause/resume API
authorSung-jae Park <nicesj.park@samsung.com>
Sat, 23 Feb 2013 09:21:42 +0000 (09:21 +0000)
committerSung-jae Park <nicesj.park@samsung.com>
Sat, 23 Feb 2013 09:21:42 +0000 (09:21 +0000)
Sync with the private repo

Change-Id: Ic0e3c0fec8de5f99cbece342e645900cb277ccb9

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

index b8a6951..cfb3068 100644 (file)
@@ -188,6 +188,18 @@ extern int livebox_init(void *disp);
 extern int livebox_fini(void);
 
 /*!
+ * \brief Client is paused.
+ * \return int
+ */
+extern int livebox_client_paused(void);
+
+/*!
+ * \brief Client is rfesumed.
+ * \return int
+ */
+extern int livebox_client_resumed(void);
+
+/*!
  * \brief Add a new livebox
  * \param[in] pkgname
  * \param[in] content
index 63397dd..f817c32 100644 (file)
@@ -5,7 +5,7 @@ Release: 1
 Group: main/app
 License: Flora License
 Source0: %{name}-%{version}.tar.gz
-BuildRequires: cmake, gettext-tools, coreutils
+BuildRequires: cmake, gettext-tools
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(ail)
index 6b2afd6..0ad95cd 100644 (file)
@@ -34,60 +34,67 @@ static Evas_Object *create_canvas(Evas_Object *parent)
 {
        Evas_Object *canvas;
 
-       canvas = evas_object_image_filled_add(evas_object_evas_get(parent));
+       canvas = evas_object_image_add(evas_object_evas_get(parent));
        if (!canvas)
                return NULL;
 
        evas_object_image_content_hint_set(canvas, EVAS_IMAGE_CONTENT_HINT_DYNAMIC);
-//     evas_object_image_colorspace_set(canvas, EVAS_COLORSPACE_ARGB8888);
-//     evas_object_image_alpha_set(canvas, EINA_TRUE);
+       evas_object_image_colorspace_set(canvas, EVAS_COLORSPACE_ARGB8888);
+       evas_object_image_alpha_set(canvas, EINA_TRUE);
        evas_object_move(canvas, 0, 0);
        return canvas;
 }
 
 static int update_pd_canvas(struct livebox *handle, Evas_Object *image)
 {
+       Evas_Native_Surface surface;
        int w;
        int h;
-       Evas_Native_Surface surface;
 
-       switch (livebox_pd_type(handle)) {
-       case PD_TYPE_BUFFER:
-               evas_object_image_colorspace_set(image, EVAS_COLORSPACE_ARGB8888);
-               evas_object_image_alpha_set(image, EINA_TRUE);
+       DbgPrint("Updated\n");
 
-               livebox_get_pdsize(handle, &w, &h);
-               if (w > 0 && h > 0) {
-                       void *data;
-                       data = livebox_acquire_pdfb(handle);
-                       if (data) {
-                               evas_object_image_size_set(image, w, h);
-                               evas_object_image_data_copy_set(image, data);
-                               livebox_release_pdfb(data);
-                       }
-                       evas_object_resize(image, w, h);
-                       //evas_object_size_hint_min_set(image, w, h);
-                       evas_object_size_hint_max_set(image, w, h);
-               }
-               break;
+       switch (livebox_pd_type(handle)) {
        case PD_TYPE_PIXMAP:
                h = w = 0;
                livebox_get_pdsize(handle, &w, &h);
                if (w <= 0 || h <= 0)
                        break;
 
+               //evas_object_image_size_set(image, w, h);
+
                DbgPrint("Update: %dx%d\n", w, h);
                surface.version = EVAS_NATIVE_SURFACE_VERSION;
                surface.type = EVAS_NATIVE_SURFACE_X11;
                surface.data.x11.pixmap = livebox_pd_pixmap(handle);
-               surface.data.x11.visual = NULL; //ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get());
+               surface.data.x11.visual = ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get());
                evas_object_image_native_surface_set(image, &surface);
 
-               evas_object_image_size_set(image, w, h);
-               evas_object_resize(image, w, h);
+               evas_object_image_data_update_add(image, 0, 0, w, h);
                evas_object_size_hint_max_set(image, w, h);
+               evas_object_resize(image, w, h);
                evas_object_show(image);
                break;
+       case PD_TYPE_BUFFER:
+               livebox_get_pdsize(handle, &w, &h);
+               if (w > 0 && h > 0) {
+                       void *data;
+
+                       data = livebox_acquire_pdfb(handle);
+                       if (data) {
+                               evas_object_image_data_set(image, NULL);
+                               evas_object_image_colorspace_set(canvas, EVAS_COLORSPACE_ARGB8888);
+                               evas_object_image_alpha_set(image, EINA_TRUE);
+                               evas_object_image_size_set(image, w, h);
+                               evas_object_image_smooth_scale_set(image, EINA_TRUE);
+                               evas_object_image_data_copy_set(image, data);
+                               evas_object_image_data_update_add(image, 0, 0, w, h);
+                               livebox_release_pdfb(data);
+                       }
+                       evas_object_resize(image, w, h);
+                       //evas_object_size_hint_min_set(image, w, h);
+                       evas_object_size_hint_max_set(image, w, h);
+               }
+               break;
        case PD_TYPE_TEXT:
        default:
                break;
@@ -104,6 +111,8 @@ static int update_canvas(struct livebox *handle, Evas_Object *image)
        int h;
        int type;
 
+       DbgPrint("Updated\n");
+
        switch (livebox_lb_type(handle)) {
        case LB_TYPE_PIXMAP:
                w = h = 0;
@@ -114,22 +123,22 @@ static int update_canvas(struct livebox *handle, Evas_Object *image)
 
                DbgPrint("Update: %dx%d\n", w, h);
 
+               //evas_object_image_size_set(image, w, h);
+
                surface.version = EVAS_NATIVE_SURFACE_VERSION;
                surface.type = EVAS_NATIVE_SURFACE_X11;
                surface.data.x11.pixmap = livebox_lb_pixmap(handle);
-               surface.data.x11.visual = NULL; //ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get());
+               surface.data.x11.visual = ecore_x_default_visual_get(ecore_x_display_get(), ecore_x_default_screen_get());
                evas_object_image_native_surface_set(image, &surface);
 
-               evas_object_image_size_set(image, w, h);
+               evas_object_image_data_update_add(image, 0, 0, w, h);
+
                evas_object_resize(image, w, h);
                evas_object_size_hint_min_set(image, w, h);
                evas_object_size_hint_max_set(image, w, h);
                evas_object_show(image);
                break;
        case LB_TYPE_BUFFER:
-               evas_object_image_colorspace_set(image, EVAS_COLORSPACE_ARGB8888);
-               evas_object_image_alpha_set(image, EINA_TRUE);
-
                w = h = 0;
                type = livebox_size(handle);
                livebox_service_get_size(type, &w, &h);
@@ -137,8 +146,13 @@ static int update_canvas(struct livebox *handle, Evas_Object *image)
                        void *data;
                        data = livebox_acquire_fb(handle);
                        if (data) {
+                               evas_object_image_data_set(image, NULL);
+                               evas_object_image_colorspace_set(image, EVAS_COLORSPACE_ARGB8888);
+                               evas_object_image_alpha_set(image, EINA_TRUE);
                                evas_object_image_size_set(image, w, h);
+                               evas_object_image_smooth_scale_set(image, EINA_TRUE);
                                evas_object_image_data_copy_set(image, data);
+                               evas_object_image_data_update_add(image, 0, 0, w, h);
                                livebox_release_fb(data);
                        }
                        evas_object_resize(image, w, h);
index e0c79b4..c8b397c 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox-viewer
 Summary: Library for developing the application.
-Version: 0.9.5
+Version: 0.9.7
 Release: 1
 Group: framework/livebox
 License: Flora License
index 265189d..db76c06 100644 (file)
@@ -439,13 +439,21 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa
        int h;
        int is_pd;
 
+       if (!packet) {
+               ErrPrint("Invalid packet\n");
+               ret = -EINVAL;
+               goto out;
+       }
+
        ret = packet_get(packet, "ssiiii", &pkgname, &id, &is_pd, &w, &h, &status);
        if (ret != 6) {
                ErrPrint("Invalid argument\n");
-               ret = EINVAL;
+               ret = -EINVAL;
                goto out;
        }
 
+       DbgPrint("Size is changed: %dx%d (%s)\n", w, h, id);
+
        handler = lb_find_livebox(pkgname, id);
        if (!handler) {
                ErrPrint("Livebox(%s - %s) is not found\n", pkgname, id);
@@ -454,11 +462,13 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa
        }
 
        if (handler->state != CREATE) {
+               ErrPrint("Hander is not created yet\n");
                ret = -EPERM;
                goto out;
        }
 
        if (is_pd) {
+               DbgPrint("PD is resized\n");
                /*!
                 * \NOTE
                 * PD is not able to resized by the client.
@@ -466,20 +476,31 @@ static struct packet *master_size_changed(pid_t pid, int handle, const struct pa
                 * 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)
+               if (status == 0) {
+                       lb_set_pdsize(handler, w, h);
+                       lb_invoke_event_handler(handler, LB_EVENT_PD_SIZE_CHANGED);
+               } else {
                        ErrPrint("This is not possible. PD Size is changed but the return value is not ZERO\n");
+               }
        } else {
-               if (status == 0)
+               DbgPrint("LB is resized\n");
+               if (status == 0) {
+                       DbgPrint("Livebox size is updated (%dx%d)\n", w, h);
                        lb_set_size(handler, w, h);
 
-               if (handler->size_changed_cb) {
-                       handler->size_changed_cb(handler, status, handler->size_cbdata);
+                       if (handler->size_changed_cb) {
+                               DbgPrint("Call the size changed callback\n");
+                               handler->size_changed_cb(handler, status, handler->size_cbdata);
 
-                       handler->size_changed_cb = NULL;
-                       handler->size_cbdata = NULL;
+                               handler->size_changed_cb = NULL;
+                               handler->size_cbdata = NULL;
+                       } else {
+                               DbgPrint("Call the global size changed callback\n");
+                               lb_invoke_event_handler(handler, LB_EVENT_LB_SIZE_CHANGED);
+                               DbgPrint("Size changed callback done\n");
+                       }
                } else {
-                       lb_invoke_event_handler(handler, LB_EVENT_LB_SIZE_CHANGED);
+                       DbgPrint("Livebox size is not changed: %dx%d, %d\n", w, h, status);
                }
        }
 
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 */