Export new APIs 11/15711/3 accepted/tizen/generic accepted/tizen_ivi_panda accepted/tizen_mobile tizen_ivi_panda accepted/tizen/generic/20140226.073647 accepted/tizen/ivi/panda/20140403.014813 accepted/tizen/mobile/20140227.072320 submit/tizen/20140226.002927 submit/tizen_ivi_panda/20140403.011923
authorSung-jae Park <nicesj.park@samsung.com>
Mon, 27 Jan 2014 12:20:22 +0000 (21:20 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Tue, 28 Jan 2014 01:43:47 +0000 (10:43 +0900)
to send a request to freeze/release the scroller.
to update the extra information.
such as alternative icon/name infomration.
to update content/title(accessibility) information direcly.

Change-Id: I51ae1f807fd279414ae3d9e3183cad8e0b90d70c

include/livebox.h
packaging/liblivebox.spec
src/livebox.c
src/virtual_window.c

index 0a112a7..275d174 100644 (file)
@@ -701,6 +701,10 @@ extern Evas_Object *livebox_get_evas_object(const char *id);
  * \see
  */
 extern int livebox_request_close_pd(const char *pkgname, const char *id, int reason);
+
+extern int livebox_freeze_scroller(const char *pkgname, const char *id);
+extern int livebox_release_scroller(const char *pkgname, const char *id);
+
 /*!
  * \}
  */
index 64a0e7b..cfc2263 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox
 Summary: Library for the development of a livebox 
-Version: 0.6.2
+Version: 0.6.3
 Release: 1
 Group: HomeTF/Livebox
 License: Flora
index 6613942..84536d6 100644 (file)
@@ -45,10 +45,12 @@ static struct info {
        const char *(*find_pkgname)(const char *filename);
        int (*request_update_by_id)(const char *uri);
        int (*trigger_update_monitor)(const char *id, int is_pd);
+       int (*update_extra_info)(const char *id, const char *content, const char *title, const char *icon, const char *name);
 } s_info = {
        .find_pkgname = NULL,
        .request_update_by_id = NULL,
        .trigger_update_monitor = NULL,
+       .update_extra_info = NULL,
 };
 
 struct block {
@@ -80,6 +82,11 @@ struct livebox_buffer_data {
        int (*handler_NEW)(struct livebox_buffer *, struct buffer_event_data *, void *);
        int (*handler)(struct livebox_buffer *, enum buffer_event, double, double, double, void *);
        void *cbdata;
+
+       char *content;
+       char *title;
+       char *icon;
+       char *name;
 };
 
 PUBLIC const int DONE = 0x00;
@@ -100,6 +107,22 @@ PUBLIC const int LB_SYS_EVENT_PAUSED = 0x0100;
 PUBLIC const int LB_SYS_EVENT_RESUMED = 0x0200;
 PUBLIC const int LB_SYS_EVENT_MMC_STATUS_CHANGED = 0x0400;
 
+static char *id_to_uri(const char *id)
+{
+       char *uri;
+       int uri_len;
+
+       uri_len = strlen(id) + strlen(FILE_SCHEMA) + 1;
+
+       uri = malloc(uri_len);
+       if (!uri) {
+               return NULL;
+       }
+
+       snprintf(uri, uri_len, FILE_SCHEMA "%s", id);
+       return uri;
+}
+
 PUBLIC struct livebox_desc *livebox_desc_open(const char *filename, int for_pd)
 {
        struct livebox_desc *handle;
@@ -639,7 +662,6 @@ PUBLIC struct livebox_buffer *livebox_acquire_buffer_NEW(const char *filename, i
        const char *pkgname;
        struct livebox_buffer *handle;
        char *uri;
-       int uri_len;
 
        if (!filename || !width || !height) {
                ErrPrint("Invalid argument: %p(%dx%d)\n", filename, width, height);
@@ -657,15 +679,13 @@ PUBLIC struct livebox_buffer *livebox_acquire_buffer_NEW(const char *filename, i
        user_data->handler = NULL;
        user_data->cbdata = data;
 
-       uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1;
-       uri = malloc(uri_len);
+       uri = id_to_uri(filename);
        if (!uri) {
                ErrPrint("Heap: %s\n", strerror(errno));
                free(user_data);
                return NULL;
        }
 
-       snprintf(uri, uri_len, FILE_SCHEMA "%s", filename);
        if (!s_info.find_pkgname) {
                s_info.find_pkgname = dlsym(RTLD_DEFAULT, "livebox_find_pkgname");
                if (!s_info.find_pkgname) {
@@ -707,7 +727,6 @@ PUBLIC struct livebox_buffer *livebox_acquire_buffer(const char *filename, int i
        const char *pkgname;
        struct livebox_buffer *handle;
        char *uri;
-       int uri_len;
 
        if (!filename || !width || !height) {
                ErrPrint("Invalid argument: %p(%dx%d)\n", filename, width, height);
@@ -725,15 +744,13 @@ PUBLIC struct livebox_buffer *livebox_acquire_buffer(const char *filename, int i
        user_data->handler_NEW = NULL;
        user_data->cbdata = data;
 
-       uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1;
-       uri = malloc(uri_len);
+       uri = id_to_uri(filename);
        if (!uri) {
                ErrPrint("Heap: %s\n", strerror(errno));
                free(user_data);
                return NULL;
        }
 
-       snprintf(uri, uri_len, FILE_SCHEMA "%s", filename);
        if (!s_info.find_pkgname) {
                s_info.find_pkgname = dlsym(RTLD_DEFAULT, "livebox_find_pkgname");
                if (!s_info.find_pkgname) {
@@ -766,7 +783,6 @@ PUBLIC struct livebox_buffer *livebox_acquire_buffer(const char *filename, int i
 
 PUBLIC int livebox_request_update(const char *filename)
 {
-       int uri_len;
        char *uri;
        int ret;
 
@@ -775,14 +791,12 @@ PUBLIC int livebox_request_update(const char *filename)
                return LB_STATUS_ERROR_INVALID;
        }
 
-       uri_len = strlen(filename) + strlen(FILE_SCHEMA) + 1;
-       uri = malloc(uri_len);
+       uri = id_to_uri(filename);
        if (!uri) {
                ErrPrint("Heap: %s\n", strerror(errno));
                return LB_STATUS_ERROR_MEMORY;
        }
 
-       snprintf(uri, uri_len, FILE_SCHEMA "%s", filename);
        if (!s_info.request_update_by_id) {
                s_info.request_update_by_id = dlsym(RTLD_DEFAULT, "livebox_request_update_by_id");
                if (!s_info.request_update_by_id) {
@@ -811,6 +825,10 @@ PUBLIC int livebox_release_buffer(struct livebox_buffer *handle)
 
        user_data = provider_buffer_user_data(handle);
        if (user_data) {
+               free(user_data->content);
+               free(user_data->title);
+               free(user_data->icon);
+               free(user_data->name);
                free(user_data);
                provider_buffer_set_user_data(handle, NULL);
        }
@@ -829,6 +847,10 @@ PUBLIC int livebox_release_buffer_NEW(struct livebox_buffer *handle)
 
        user_data = provider_buffer_user_data(handle);
        if (user_data) {
+               free(user_data->content);
+               free(user_data->title);
+               free(user_data->icon);
+               free(user_data->name);
                free(user_data);
                provider_buffer_set_user_data(handle, NULL);
        }
@@ -866,7 +888,7 @@ PUBLIC void *livebox_ref_buffer(struct livebox_buffer *handle)
        data = provider_buffer_ref(handle);
        if (data && !ret && w > 0 && h > 0 && size > 0) {
                memset(data, 0, w * h * size);
-               provider_buffer_sync(handle);
+               (void)provider_buffer_sync(handle);
        }
 
        DbgPrint("Ref buffer %ds%d(%d)\n", w, h, size);
@@ -916,9 +938,9 @@ PUBLIC int livebox_sync_buffer(struct livebox_buffer *handle)
                return LB_STATUS_ERROR_INVALID;
        }
 
-       provider_buffer_sync(handle);
+       (void)provider_buffer_sync(handle);
 
-       if (user_data->is_pd) {
+       if (user_data->is_pd == 1) {
                if (provider_send_desc_updated(pkgname, id, NULL) < 0) {
                        ErrPrint("Failed to send PD updated (%s)\n", id);
                }
@@ -931,7 +953,7 @@ PUBLIC int livebox_sync_buffer(struct livebox_buffer *handle)
                        ErrPrint("Failed to get size (%s)\n", id);
                }
 
-               if (provider_send_updated(pkgname, id, w, h, -1.0f, NULL, NULL) < 0) {
+               if (provider_send_updated_NEW(pkgname, id, w, h, -1.0f, user_data->content, user_data->title, user_data->icon, user_data->name) < 0) {
                        ErrPrint("Failed to send updated (%s)\n", id);
                }
        }
@@ -1079,7 +1101,7 @@ PUBLIC int livebox_buffer_post_render(struct livebox_buffer *handle)
                        ErrPrint("Failed to get size (%s)\n", id);
                }
 
-               if (provider_send_updated(pkgname, id, w, h, -1.0f, NULL, NULL) < 0) {
+               if (provider_send_updated_NEW(pkgname, id, w, h, -1.0f, user_data->content, user_data->title, user_data->icon, user_data->name) < 0) {
                        ErrPrint("Failed to send updated (%s)\n", id);
                }
        }
@@ -1112,13 +1134,11 @@ PUBLIC int livebox_request_close_pd(const char *pkgname, const char *id, int rea
        }
 
        if (strncmp(id, FILE_SCHEMA, schema_len)) {
-               schema_len += strlen(id);
-               uri = malloc(schema_len + 1);
+               uri = id_to_uri(id);
                if (!uri) {
                        ErrPrint("Heap: %s\n", strerror(errno));
                        return LB_STATUS_ERROR_MEMORY;
                }
-               snprintf(uri, schema_len + 1, FILE_SCHEMA "%s", id);
        } else {
                uri = strdup(id);
                if (!uri) {
@@ -1132,4 +1152,144 @@ PUBLIC int livebox_request_close_pd(const char *pkgname, const char *id, int rea
        return ret;
 }
 
+PUBLIC int livebox_freeze_scroller(const char *pkgname, const char *id)
+{
+       char *uri;
+       int ret;
+
+       uri = id_to_uri(id);
+       if (!uri) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               return LB_STATUS_ERROR_MEMORY;
+       }
+
+       ret = provider_send_hold_scroll(pkgname, uri, 1);
+       free(uri);
+       return ret;
+}
+
+PUBLIC int livebox_release_scroller(const char *pkgname, const char *id)
+{
+       char *uri;
+       int ret;
+
+       uri = id_to_uri(id);
+       if (!uri) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               return LB_STATUS_ERROR_MEMORY;
+       }
+
+       ret = provider_send_hold_scroll(pkgname, uri, 0);
+       free(uri);
+       return ret;
+}
+
+PUBLIC int livebox_set_extra_info(const char *id, const char *content, const char *title, const char *icon, const char *name)
+{
+       struct livebox_buffer *handle;
+       const char *pkgname;
+       char *uri;
+
+       uri = id_to_uri(id);
+       if (!uri) {
+               ErrPrint("Heap: %s\n", strerror(errno));
+               return LB_STATUS_ERROR_MEMORY;
+       }
+
+       pkgname = s_info.find_pkgname(uri);
+       if (!pkgname) {
+               ErrPrint("Failed to find a package (%s)\n", uri);
+               free(uri);
+               return LB_STATUS_ERROR_INVALID;
+       }
+
+       handle = provider_buffer_find_buffer(TYPE_LB, pkgname, uri);
+       free(uri);
+       if (handle) {
+               struct livebox_buffer_data *user_data;
+
+               user_data = provider_buffer_user_data(handle);
+               if (!user_data) {
+                       ErrPrint("User data is not available\n");
+                       return LB_STATUS_ERROR_FAULT;
+               }
+
+               if (content && strlen(content)) {
+                       char *_content;
+
+                       _content = strdup(content);
+                       if (_content) {
+                               if (user_data->content) {
+                                       free(user_data->content);
+                                       user_data->content = NULL;
+                               }
+
+                               user_data->content = _content;
+                       } else {
+                               ErrPrint("Heap: %s\n", strerror(errno));
+                       }
+               }
+
+               if (title && strlen(title)) {
+                       char *_title;
+
+                       _title = strdup(title);
+                       if (_title) {
+                               if (user_data->title) {
+                                       free(user_data->title);
+                                       user_data->title = NULL;
+                               }
+
+                               user_data->title = _title;
+                       } else {
+                               ErrPrint("Heap: %s\n", strerror(errno));
+                       }
+               }
+
+               if (icon && strlen(icon)) {
+                       char *_icon;
+
+                       _icon = strdup(icon);
+                       if (_icon) {
+                               if (user_data->icon) {
+                                       free(user_data->icon);
+                                       user_data->icon = NULL;
+                               }
+
+                               user_data->icon = _icon;
+                       } else {
+                               ErrPrint("Heap: %s\n", strerror(errno));
+                       }
+               }
+
+               if (name && strlen(name)) {
+                       char *_name;
+
+                       _name = strdup(name);
+                       if (_name) {
+                               if (user_data->name) {
+                                       free(user_data->name);
+                                       user_data->name = NULL;
+                               }
+
+                               user_data->name = _name;
+                       } else {
+                               ErrPrint("Heap: %s\n", strerror(errno));
+                       }
+               }
+
+               return LB_STATUS_SUCCESS;
+       }
+
+       if (!s_info.update_extra_info) {
+               s_info.update_extra_info = dlsym(RTLD_DEFAULT, "livebox_update_extra_info");
+               if (!s_info.update_extra_info) {
+                       ErrPrint("Failed to find a \"livebox_update_extra_info\"\n");
+                       return LB_STATUS_ERROR_INVALID;
+               }
+       }
+
+       return s_info.update_extra_info(id, content, title, icon, name);
+}
+
 /* End of a file */
index 8716fd6..4bda67e 100644 (file)
@@ -53,7 +53,6 @@ static int event_handler_cb(struct livebox_buffer *handler, struct buffer_event_
        Evas_Object *parent_elm;
        const char *key_name;
        const char *key_string;
-       const char *compose;
        KeySym *key_symbol;
 
 
@@ -243,7 +242,6 @@ static int event_handler_cb(struct livebox_buffer *handler, struct buffer_event_
                        key_string = XKeysymToString(*key_symbol);
                        key_name = XKeysymToString(*key_symbol);
                        DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
-                       compose = NULL;
                        XFree(key_symbol);
                }
                ret = LB_KEY_STATUS_ERROR;
@@ -260,7 +258,6 @@ static int event_handler_cb(struct livebox_buffer *handler, struct buffer_event_
                        key_string = XKeysymToString(*key_symbol);
                        key_name = XKeysymToString(*key_symbol);
                        DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
-                       compose = NULL;
                        XFree(key_symbol);
                }
                ret = LB_KEY_STATUS_ERROR;
@@ -277,7 +274,6 @@ static int event_handler_cb(struct livebox_buffer *handler, struct buffer_event_
                        key_string = XKeysymToString(*key_symbol);
                        key_name = XKeysymToString(*key_symbol);
                        DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
-                       compose = NULL;
                        XFree(key_symbol);
                }
                ret = LB_KEY_STATUS_ERROR;
@@ -294,7 +290,6 @@ static int event_handler_cb(struct livebox_buffer *handler, struct buffer_event_
                        key_string = XKeysymToString(*key_symbol);
                        key_name = XKeysymToString(*key_symbol);
                        DbgPrint("Key symbol: %s, name: %s\n", key_string, key_name);
-                       compose = NULL;
                        XFree(key_symbol);
                }
                ret = LB_KEY_STATUS_ERROR;