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
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 */
#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;
_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,
_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,
(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;
}
{
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);
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 = {
.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);
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 */