From 129b1cdb1df07c8d03922e37e6741169bdae329e Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Tue, 21 Apr 2015 22:25:33 +0900 Subject: [PATCH] Support orientation handling. [model] Redwood,Kiran,B3(Wearable) [binary_type] AP [customer] Docomo/Orange/ATT/Open [issue#] N/A [problem] [cause] [solution] [team] HomeTF [request] [horizontal_expansion] Change-Id: I076a8804d58e1ebfd059f7fe6b73935f04428f6f --- include/so_handler.h | 1 + include/widget.h | 3 ++ src/client.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/widget.c | 38 ++++++++++++++++++++++++ 4 files changed, 124 insertions(+) diff --git a/include/so_handler.h b/include/so_handler.h index d43a912..d546832 100644 --- a/include/so_handler.h +++ b/include/so_handler.h @@ -64,6 +64,7 @@ struct instance { double priority; char *cluster; char *category; + int orientation; }; struct so_item { diff --git a/include/widget.h b/include/widget.h index df00cab..e275bf3 100644 --- a/include/widget.h +++ b/include/widget.h @@ -67,6 +67,8 @@ extern int widget_delete_all(void); extern int widget_viewer_connected(const char *pkgname, const char *id, const char *direct_addr); extern int widget_viewer_disconnected(const char *pkgname, const char *id, const char *direct_addr); +extern int widget_set_orientation(const char *pkgname, const char *id, int orientation); + /** * @brief * Exported API for each widgets @@ -77,5 +79,6 @@ extern int widget_trigger_update_monitor(const char *id, int is_gbar); extern int widget_update_extra_info(const char *id, const char *content, const char *title, const char *icon, const char *name); extern int widget_send_updated(const char *pkgname, const char *id, int idx, int x, int y, int w, int h, int gbar, const char *descfile); extern int widget_send_buffer_updated(const char *pkgname, const char *id, widget_buffer_h handle, int idx, int x, int y, int w, int h, int gbar, const char *descfile); +extern int widget_orientation(const char *filename); /* End of a file */ diff --git a/src/client.c b/src/client.c index 6f77e0e..e36c9dd 100644 --- a/src/client.c +++ b/src/client.c @@ -44,12 +44,80 @@ #include "util.h" #include "conf.h" +struct pre_callback_item { + widget_pre_callback_t cb; + void *data; +}; + static struct info { Ecore_Timer *ping_timer; + Eina_List *widget_pre_callback_list[WIDGET_PRE_CALLBACK_COUNT]; } s_info = { .ping_timer = NULL, + .widget_pre_callback_list = { NULL, }, }; +static void invoke_pre_callback(widget_pre_callback_e type, const char *id) +{ + Eina_List *l; + Eina_List *n; + struct pre_callback_item *item; + + EINA_LIST_FOREACH_SAFE(s_info.widget_pre_callback_list[type], l, n, item) { + item->cb(id, item->data); + } +} + +int widget_provider_app_add_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data) +{ + struct pre_callback_item *item; + Eina_List *l; + + if (!cb || type == WIDGET_PRE_CALLBACK_COUNT) { + return WIDGET_ERROR_INVALID_PARAMETER; + } + + EINA_LIST_FOREACH(s_info.widget_pre_callback_list[type], l, item) { + if (item->cb == cb && item->data == data) { + return WIDGET_ERROR_ALREADY_EXIST; + } + } + + item = malloc(sizeof(*item)); + if (!item) { + ErrPrint("malloc: %d\n", errno); + return WIDGET_ERROR_OUT_OF_MEMORY; + } + + item->cb = cb; + item->data = data; + + s_info.widget_pre_callback_list[type] = eina_list_append(s_info.widget_pre_callback_list[type], item); + return 0; +} + +int widget_provider_app_del_pre_callback(widget_pre_callback_e type, widget_pre_callback_t cb, void *data) +{ + Eina_List *l; + Eina_List *n; + struct pre_callback_item *item; + + if (!cb || type == WIDGET_PRE_CALLBACK_COUNT) { + ErrPrint("Invalid parameter\n"); + return WIDGET_ERROR_INVALID_PARAMETER; + } + + EINA_LIST_FOREACH_SAFE(s_info.widget_pre_callback_list[type], l, n, item) { + if (item->cb == cb && item->data == data) { + s_info.widget_pre_callback_list[type] = eina_list_remove_list(s_info.widget_pre_callback_list[type], l); + free(item); + return WIDGET_ERROR_NONE; + } + } + + return WIDGET_ERROR_NOT_EXIST; +} + static int method_new(struct widget_event_arg *arg, int *width, int *height, double *priority, void *data) { int ret; @@ -82,6 +150,8 @@ static int method_new(struct widget_event_arg *arg, int *width, int *height, dou _arg.skip_need_to_create = arg->info.widget_create.skip_need_to_create; _arg.direct_addr = arg->info.widget_create.direct_addr; + invoke_pre_callback(WIDGET_PRE_CREATE_CALLBACK, arg->id); + ret = widget_create(arg->pkgname, arg->id, &_arg, width, height, priority, @@ -154,6 +224,8 @@ static int method_renew(struct widget_event_arg *arg, void *data) _arg.skip_need_to_create = 1; _arg.direct_addr = arg->info.widget_recreate.direct_addr; + invoke_pre_callback(WIDGET_PRE_CREATE_CALLBACK, arg->id); + ret = widget_create(arg->pkgname, arg->id, &_arg, &w, &h, &priority, @@ -194,6 +266,7 @@ static int method_delete(struct widget_event_arg *arg, void *data) (void)widget_system_event(arg->pkgname, arg->id, WIDGET_SYS_EVENT_DELETED); } + invoke_pre_callback(WIDGET_PRE_DESTROY_CALLBACK, arg->id); ret = widget_destroy(arg->pkgname, arg->id, 0); return ret; } @@ -245,6 +318,8 @@ static int method_resize(struct widget_event_arg *arg, void *data) { int ret; + invoke_pre_callback(WIDGET_PRE_RESIZE_CALLBACK, arg->id); + DbgPrint("pkgname[%s] id[%s] w[%d] h[%d]\n", arg->pkgname, arg->id, arg->info.resize.w, arg->info.resize.h); ret = widget_viewer_resize_widget(arg->pkgname, arg->id, arg->info.resize.w, arg->info.resize.h); @@ -432,6 +507,12 @@ static int method_viewer_disconnected(struct widget_event_arg *arg, void *data) return widget_viewer_disconnected(arg->pkgname, arg->id, arg->info.viewer_disconnected.direct_addr); } +static int method_orientation(struct widget_event_arg *arg, void *data) +{ + invoke_pre_callback(WIDGET_PRE_ORIENTATION_CALLBACK, arg->id); + return widget_set_orientation(arg->pkgname, arg->id, arg->info.orientation.degree); +} + HAPI int client_init(const char *name, const char *abi, const char *accel, int secured) { struct widget_event_table table = { @@ -457,6 +538,7 @@ HAPI int client_init(const char *name, const char *abi, const char *accel, int s .widget_resume = method_widget_resume, .viewer_connected = method_viewer_connected, .viewer_disconnected = method_viewer_disconnected, + .orientation = method_orientation, }; widget_provider_prepare_init(abi, accel, secured); diff --git a/src/widget.c b/src/widget.c index 0aa1c5f..fbed7bd 100644 --- a/src/widget.c +++ b/src/widget.c @@ -2659,4 +2659,42 @@ HAPI int widget_is_all_paused(void) return s_info.state != STATE_RESUMED; } +HAPI int widget_set_orientation(const char *pkgname, const char *id, int orientation) +{ + Eina_List *l; + struct instance *inst; + struct item *item; + + inst = so_find_instance(pkgname, id); + if (!inst) { + ErrPrint("instance %s - %s is not created\n", pkgname, id); + return WIDGET_ERROR_INVALID_PARAMETER; + } + + l = find_item(inst); + if (!l) { + ErrPrint("Instance is not found(%s - %s)\n", pkgname, id); + return WIDGET_ERROR_NOT_EXIST; + } + + inst->orientation = orientation; + + item = eina_list_data_get(l); + return widget_sys_event(inst, item, WIDGET_SYS_EVENT_ORIENTATION_CHANGED); +} + +int widget_provider_app_get_orientation(const char *filename) +{ + Eina_List *l; + struct item *item; + + EINA_LIST_FOREACH(s_info.item_list, l, item) { + if (!strcmp(item->inst->id, filename)) { + return item->inst->orientation; + } + } + + return WIDGET_ERROR_NOT_EXIST; +} + /* End of a file */ -- 2.7.4