forked from enlightenment/efl
This removes EO APIs related to an unmaintained client/server model for applications. The reasons for this removal are the following: - unused - no support in E - relies on dbus as the sole transport layer - unmaintained since the original patches - only EO API (iow: beta, never released API) I've also never seen the test cases (in elementary_test) actually work. According to Gustavo (k-s), the original author of this feature is not involved in EFL at the moment, and unlikely to be in the near future. Note that terminology has in the past used those APIs when it was still using some beta EO APIs. This code is now long gone, removed in terminology commit 3ffcbadd6f9881472db6 (2014/12/13, for version 0.8.0) If someone wants to step in and maintain the implementation, protocol and (EO) API, then feel free to revert this patch and revive the feature. But it will need to be more solid than this implementation.devs/vitorsousa/failing_future_all
parent
c0a41034cd
commit
7c2259adc8
27 changed files with 0 additions and 3010 deletions
@ -1,200 +0,0 @@ |
||||
#ifdef HAVE_CONFIG_H |
||||
# include "elementary_config.h" |
||||
#endif |
||||
#include <Elementary.h> |
||||
|
||||
typedef struct { |
||||
Evas_Object *win, *label; |
||||
Eina_Stringshare *view_name; |
||||
} App_View_Context; |
||||
|
||||
static Elm_App_Server *phone_server = NULL, *msg_server = NULL; |
||||
|
||||
static void _text_update(App_View_Context *ctx, const char *state) |
||||
{ |
||||
char buffer[1024]; |
||||
|
||||
if (!ctx->label) |
||||
return; |
||||
snprintf(buffer, sizeof(buffer), "%s - state=%s", ctx->view_name, state); |
||||
elm_object_text_set(ctx->label, buffer); |
||||
} |
||||
|
||||
static void |
||||
_window_create(App_View_Context *ctx) |
||||
{ |
||||
ctx->win = elm_win_util_standard_add("app_view", ctx->view_name); |
||||
|
||||
ctx->label = elm_label_add(ctx->win); |
||||
evas_object_size_hint_weight_set(ctx->label, EVAS_HINT_EXPAND, |
||||
EVAS_HINT_EXPAND); |
||||
evas_object_data_set(ctx->win, "label", ctx->label); |
||||
|
||||
_text_update(ctx, "alive"); |
||||
|
||||
elm_win_resize_object_add(ctx->win, ctx->label); |
||||
evas_object_show(ctx->label); |
||||
|
||||
evas_object_resize(ctx->win, 400, 300); |
||||
evas_object_show(ctx->win); |
||||
} |
||||
|
||||
static void |
||||
_close_cb(void *data, const Efl_Event *event) |
||||
{ |
||||
App_View_Context *ctx = data; |
||||
if (ctx->win) |
||||
evas_object_del(ctx->win); |
||||
efl_del(event->object); |
||||
} |
||||
|
||||
static void |
||||
_pause_cb(void *data, const Efl_Event *event EINA_UNUSED) |
||||
{ |
||||
App_View_Context *ctx = data; |
||||
_text_update(ctx, "paused"); |
||||
} |
||||
|
||||
static void |
||||
_resume_cb(void *data, const Efl_Event *event) |
||||
{ |
||||
App_View_Context *ctx = data; |
||||
|
||||
//shallow state
|
||||
if (!ctx->win) |
||||
{ |
||||
_window_create(ctx); |
||||
elm_app_server_view_window_set(event->object, ctx->win); |
||||
} |
||||
|
||||
_text_update(ctx, "alive"); |
||||
} |
||||
|
||||
static void |
||||
_view_del_cb(void *data, const Efl_Event *event) |
||||
{ |
||||
App_View_Context *ctx = data; |
||||
|
||||
if (ctx->win) |
||||
evas_object_del(ctx->win); |
||||
elm_app_server_view_window_set(event->object, NULL); |
||||
eina_stringshare_del(ctx->view_name); |
||||
free(ctx); |
||||
} |
||||
|
||||
static Elm_App_Server_View * |
||||
_create_view_cb(Elm_App_Server *app_server, const Eina_Value *args EINA_UNUSED, Eina_Stringshare **error_name, Eina_Stringshare **error_message EINA_UNUSED) |
||||
{ |
||||
Elm_App_Server_View *view; |
||||
const char *id = NULL, *pkg = NULL; |
||||
App_View_Context *ctx; |
||||
|
||||
ctx = calloc(1, sizeof(App_View_Context)); |
||||
if (!ctx) |
||||
{ |
||||
*error_name = eina_stringshare_add("No memory available"); |
||||
return NULL; |
||||
} |
||||
|
||||
view = efl_add(ELM_APP_SERVER_VIEW_CLASS, app_server, elm_app_server_view_id_set(efl_added, NULL)); |
||||
|
||||
id = elm_app_server_view_id_get(view); |
||||
pkg = elm_app_server_package_get(app_server); |
||||
ctx->view_name = eina_stringshare_printf("%s %s", pkg, id); |
||||
|
||||
_window_create(ctx); |
||||
|
||||
elm_app_server_view_title_set(view, ctx->view_name); |
||||
elm_app_server_view_new_events_set(view, 5); |
||||
elm_app_server_view_window_set(view, ctx->win); |
||||
elm_app_server_view_resume(view); |
||||
efl_event_callback_add(view, ELM_APP_SERVER_VIEW_EVENT_CLOSED, _close_cb, ctx); |
||||
efl_event_callback_add(view, ELM_APP_SERVER_VIEW_EVENT_PAUSED, _pause_cb, ctx); |
||||
efl_event_callback_add(view, ELM_APP_SERVER_VIEW_EVENT_RESUMED, _resume_cb, ctx); |
||||
efl_event_callback_add(view, EFL_EVENT_DEL, _view_del_cb, ctx); |
||||
|
||||
return view; |
||||
} |
||||
|
||||
static void |
||||
_terminate_cb(void *data EINA_UNUSED, const Efl_Event *event) |
||||
{ |
||||
const char *title = NULL; |
||||
|
||||
printf("terminate cb\n"); |
||||
elm_app_server_save(event->object); |
||||
title = elm_app_server_title_get(event->object); |
||||
|
||||
printf("Closing: %s\n", title); |
||||
efl_unref(event->object); |
||||
} |
||||
|
||||
Elm_App_Server * |
||||
test_application_server_common(const char *pkg) |
||||
{ |
||||
Eina_Iterator *views_iter = NULL; |
||||
Elm_App_Server_View *view; |
||||
Elm_App_Server *server; |
||||
|
||||
server = efl_add(ELM_APP_SERVER_CLASS, NULL, elm_app_server_constructor(efl_added, pkg, _create_view_cb)); |
||||
elm_app_server_title_set(server, pkg); |
||||
views_iter = elm_app_server_views_get(server); |
||||
efl_event_callback_add(server, ELM_APP_SERVER_EVENT_TERMINATE, _terminate_cb, NULL); |
||||
|
||||
//views create in shallow state
|
||||
EINA_ITERATOR_FOREACH(views_iter, view) |
||||
{ |
||||
App_View_Context *ctx; |
||||
const char *id = NULL; |
||||
|
||||
ctx = calloc(1, sizeof(App_View_Context)); |
||||
|
||||
id = elm_app_server_view_id_get(view); |
||||
ctx->view_name = eina_stringshare_printf("%s %s", pkg, id); |
||||
|
||||
efl_event_callback_add(view, ELM_APP_SERVER_VIEW_EVENT_CLOSED, _close_cb, ctx); |
||||
efl_event_callback_add(view, ELM_APP_SERVER_VIEW_EVENT_PAUSED, _pause_cb, ctx); |
||||
efl_event_callback_add(view, ELM_APP_SERVER_VIEW_EVENT_RESUMED, _resume_cb, ctx); |
||||
efl_event_callback_add(view, EFL_EVENT_DEL, _view_del_cb, ctx); |
||||
} |
||||
eina_iterator_free(views_iter); |
||||
|
||||
return server; |
||||
} |
||||
|
||||
static void |
||||
_server_del_cb(void *data, const Efl_Event *event EINA_UNUSED) |
||||
{ |
||||
Elm_App_Server **server = data; |
||||
*server = NULL; |
||||
} |
||||
|
||||
void |
||||
test_application_server_phone(void *data EINA_UNUSED, |
||||
Evas_Object *obj EINA_UNUSED, |
||||
void *event_info EINA_UNUSED) |
||||
{ |
||||
if (phone_server) |
||||
{ |
||||
printf("Phone already running\n"); |
||||
return; |
||||
} |
||||
printf("Starting phone\n"); |
||||
phone_server = test_application_server_common("org.enlightenment.phone"); |
||||
efl_event_callback_add(phone_server, EFL_EVENT_DEL, _server_del_cb, &phone_server); |
||||
} |
||||
|
||||
void |
||||
test_application_server_message(void *data EINA_UNUSED, |
||||
Evas_Object *obj EINA_UNUSED, |
||||
void *event_info EINA_UNUSED) |
||||
{ |
||||
if (msg_server) |
||||
{ |
||||
printf("Message already running\n"); |
||||
return; |
||||
} |
||||
printf("Starting message\n"); |
||||
msg_server = test_application_server_common( "org.enlightenment.message"); |
||||
efl_event_callback_add(msg_server, EFL_EVENT_DEL, _server_del_cb, &msg_server); |
||||
} |
@ -1,397 +0,0 @@ |
||||
#ifdef HAVE_CONFIG_H |
||||
# include "elementary_config.h" |
||||
#endif |
||||
#include <Elementary.h> |
||||
#include <Eina.h> |
||||
|
||||
#define APPS_COL 0 |
||||
#define VIEWS_COL 1 |
||||
#define PROPS_VIEW_COL 2 |
||||
|
||||
static Evas_Object *table = NULL; |
||||
static Elm_App_Client *app_selected = NULL; |
||||
static Eina_List *apps_list = NULL; |
||||
|
||||
static void _app_view_clicked(void *data, Evas_Object *obj, void *event_info); |
||||
static void _apps_list_update(void); |
||||
|
||||
static void _btn_close_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
Elm_App_Client_View *view = data; |
||||
elm_app_client_view_close(view, NULL, NULL); |
||||
} |
||||
|
||||
static void _btn_pause_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
Elm_App_Client_View *view = data; |
||||
elm_app_client_view_pause(view, NULL, NULL); |
||||
} |
||||
|
||||
static void _btn_resume_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
Elm_App_Client_View *view = data; |
||||
elm_app_client_view_resume(view, NULL, NULL); |
||||
} |
||||
|
||||
static void |
||||
_app_view_prop_changed_cb(void *data EINA_UNUSED, const Efl_Event *event) |
||||
{ |
||||
Elm_App_View_State state = ELM_APP_VIEW_STATE_UNKNOWN; |
||||
|
||||
state = elm_app_client_view_state_get(event->object); |
||||
|
||||
if (state == ELM_APP_VIEW_STATE_CLOSED) |
||||
{ |
||||
Evas_Object *props = elm_table_child_get(table, PROPS_VIEW_COL, 0); |
||||
elm_table_unpack(table, props); |
||||
evas_object_del(props); |
||||
} |
||||
else |
||||
_app_view_clicked(event->object, NULL, NULL); |
||||
} |
||||
|
||||
static void |
||||
_app_view_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
Elm_App_Client_View *view = data; |
||||
Evas_Object *view_props, *close_btn, *resume_btn, *pause_btn; |
||||
const char *title = NULL, *icon = NULL; |
||||
int new_events = 0, window = 0; |
||||
unsigned short progress = 0; |
||||
Elm_App_View_State state = ELM_APP_VIEW_STATE_UNKNOWN; |
||||
char buffer[1024]; |
||||
|
||||
view_props = elm_table_child_get(table, PROPS_VIEW_COL, 0); |
||||
if (view_props) |
||||
{ |
||||
Elm_App_Client_View *old_view; |
||||
|
||||
old_view = evas_object_data_del(view_props, "view"); |
||||
efl_event_callback_del(old_view, ELM_APP_CLIENT_VIEW_EVENT_PROPERTY_CHANGED, _app_view_prop_changed_cb, table); |
||||
elm_list_clear(view_props); |
||||
} |
||||
else |
||||
{ |
||||
view_props = elm_list_add(table); |
||||
evas_object_size_hint_align_set(view_props, EVAS_HINT_FILL, |
||||
EVAS_HINT_FILL); |
||||
evas_object_show(view_props); |
||||
elm_table_pack(table, view_props, PROPS_VIEW_COL, 0, 1, 1); |
||||
} |
||||
|
||||
evas_object_data_set(view_props, "view", view); |
||||
|
||||
title = elm_app_client_view_title_get(view); |
||||
icon = elm_app_client_view_icon_get(view); |
||||
progress = elm_app_client_view_progress_get(view); |
||||
new_events = elm_app_client_view_new_events_get(view); |
||||
window = elm_app_client_view_window_get(view); |
||||
efl_event_callback_add(view, ELM_APP_CLIENT_VIEW_EVENT_PROPERTY_CHANGED, _app_view_prop_changed_cb, table); |
||||
|
||||
snprintf(buffer, sizeof(buffer), "Title=%s", title); |
||||
elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL); |
||||
|
||||
snprintf(buffer, sizeof(buffer), "Icon=%s", icon); |
||||
elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL); |
||||
|
||||
snprintf(buffer, sizeof(buffer), "Progress=%d", progress); |
||||
elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL); |
||||
|
||||
snprintf(buffer, sizeof(buffer), "New events=%d", new_events); |
||||
elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL); |
||||
|
||||
snprintf(buffer, sizeof(buffer), "WindowID=%d", window); |
||||
elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL); |
||||
|
||||
state = elm_app_client_view_state_get(view); |
||||
if (state == ELM_APP_VIEW_STATE_LIVE) |
||||
snprintf(buffer, sizeof(buffer), "State=alive"); |
||||
else if (state == ELM_APP_VIEW_STATE_PAUSED) |
||||
snprintf(buffer, sizeof(buffer), "State=paused"); |
||||
else if (state == ELM_APP_VIEW_STATE_CLOSED) |
||||
snprintf(buffer, sizeof(buffer), "State=closed"); |
||||
else if (state == ELM_APP_VIEW_STATE_SHALLOW) |
||||
snprintf(buffer, sizeof(buffer), "State=shallow"); |
||||
else |
||||
snprintf(buffer, sizeof(buffer), "State=unknown"); |
||||
elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL); |
||||
|
||||
close_btn = elm_button_add(view_props); |
||||
elm_object_text_set(close_btn, "Close view"); |
||||
evas_object_smart_callback_add(close_btn, "clicked", _btn_close_cb, view); |
||||
elm_list_item_append(view_props, NULL, close_btn, NULL, NULL, NULL); |
||||
|
||||
pause_btn = elm_button_add(view_props); |
||||
elm_object_text_set(pause_btn, "Pause view"); |
||||
evas_object_smart_callback_add(pause_btn, "clicked", _btn_pause_cb, view); |
||||
elm_list_item_append(view_props, NULL, pause_btn, NULL, NULL, NULL ); |
||||
|
||||
resume_btn = elm_button_add(view_props); |
||||
elm_object_text_set(resume_btn, "Resume view"); |
||||
evas_object_smart_callback_add(resume_btn, "clicked", _btn_resume_cb, view); |
||||
elm_list_item_append(view_props, NULL, resume_btn, NULL, NULL, NULL ); |
||||
|
||||
elm_list_go(view_props); |
||||
} |
||||
|
||||
static void |
||||
_popup_close_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
evas_object_del(data); |
||||
} |
||||
|
||||
static void app_client_view_open_cb(void *data EINA_UNUSED, Elm_App_Client_View *view, const char *error, const char *error_message) |
||||
{ |
||||
Evas_Object *popup, *btn_ok; |
||||
char buf[1024]; |
||||
|
||||
popup = elm_popup_add(table); |
||||
|
||||
if (view) |
||||
{ |
||||
_app_view_clicked(view, NULL, NULL); |
||||
return; |
||||
} |
||||
|
||||
snprintf(buf, sizeof(buf), "Some error happen opening view: %s %s", error, error_message); |
||||
elm_object_part_text_set(popup, "default", buf); |
||||
|
||||
btn_ok = elm_button_add(popup); |
||||
elm_object_text_set(btn_ok, "Ok"); |
||||
elm_object_part_content_set(popup, "button1", btn_ok); |
||||
evas_object_smart_callback_add(btn_ok, "clicked", _popup_close_cb, popup); |
||||
|
||||
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP); |
||||
evas_object_show(popup); |
||||
} |
||||
|
||||
static void _popup_btn_open_view_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
Evas_Object *popup = data; |
||||
Eina_Value *args = NULL;//TODO fill with args of popup
|
||||
Elm_App_Client *app = evas_object_data_get(popup, "app"); |
||||
|
||||
elm_app_client_view_open(app, args, app_client_view_open_cb, NULL); |
||||
|
||||
evas_object_del(popup); |
||||
} |
||||
|
||||
static void |
||||
_app_view_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
Elm_App_Client *app = data; |
||||
Evas_Object *popup, *btn_open, *btn_cancel, *args_box; |
||||
|
||||
popup = elm_popup_add(table); |
||||
elm_object_part_text_set(popup, "title,text", "Open a view"); |
||||
|
||||
btn_open = elm_button_add(popup); |
||||
elm_object_text_set(btn_open, "Open"); |
||||
elm_object_part_content_set(popup, "button1", btn_open); |
||||
evas_object_smart_callback_add(btn_open, "clicked", _popup_btn_open_view_cb, popup); |
||||
evas_object_show(btn_open); |
||||
|
||||
btn_cancel = elm_button_add(popup); |
||||
elm_object_text_set(btn_cancel, "Cancel"); |
||||
elm_object_part_content_set(popup, "button2", btn_cancel); |
||||
evas_object_smart_callback_add(btn_cancel, "clicked", _popup_close_cb, popup); |
||||
evas_object_show(btn_cancel); |
||||
|
||||
args_box = elm_box_add(popup); |
||||
elm_object_part_content_set(popup, "default", args_box); |
||||
elm_object_part_text_set(popup, "default", "TODO: add some entrys to add some parameters to view."); |
||||
|
||||
evas_object_data_set(popup, "app", app); |
||||
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP); |
||||
evas_object_show(popup); |
||||
} |
||||
|
||||
static void _app_close_all_views_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
Elm_App_Client *app = data; |
||||
elm_app_client_view_all_close(app); |
||||
} |
||||
|
||||
static void |
||||
_app_terminate_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
Elm_App_Client *app = data; |
||||
elm_app_client_terminate(app); |
||||
} |
||||
|
||||
static void |
||||
_app_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
Evas_Object *views, *btn_close_all, *btn_terminate, *btn_open_view; |
||||
Eina_Iterator *views_iter = NULL; |
||||
Elm_App_Client_View *client_view; |
||||
Elm_App_Client *app = data; |
||||
|
||||
app_selected = app; |
||||
|
||||
views = elm_table_child_get(table, VIEWS_COL, 0); |
||||
if (!views) |
||||
{ |
||||
views = elm_list_add(table); |
||||
evas_object_size_hint_align_set(views, EVAS_HINT_FILL, EVAS_HINT_FILL); |
||||
evas_object_show(views); |
||||
elm_table_pack(table, views, VIEWS_COL, 0, 1, 1); |
||||
} |
||||
else |
||||
elm_list_clear(views); |
||||
|
||||
btn_open_view = elm_button_add(views); |
||||
elm_object_text_set(btn_open_view, "Open a view"); |
||||
evas_object_smart_callback_add(btn_open_view, "clicked", _app_view_open, app); |
||||
elm_list_item_append(views, NULL, btn_open_view, NULL, NULL, NULL); |
||||
|
||||
views_iter = elm_app_client_views_get(app); |
||||
EINA_ITERATOR_FOREACH(views_iter, client_view) |
||||
{ |
||||
const char *path = NULL; |
||||
|
||||
path = elm_app_client_view_path_get(client_view); |
||||
elm_list_item_append(views, path, NULL, NULL, _app_view_clicked, client_view); |
||||
} |
||||
eina_iterator_free(views_iter); |
||||
|
||||
btn_close_all = elm_button_add(views); |
||||
elm_object_text_set(btn_close_all, "Close all views"); |
||||
evas_object_smart_callback_add(btn_close_all, "clicked", _app_close_all_views_cb, app); |
||||
elm_list_item_append(views, NULL, btn_close_all, NULL, NULL, NULL); |
||||
|
||||
btn_terminate = elm_button_add(views); |
||||
elm_object_text_set(btn_terminate, "Terminate application"); |
||||
evas_object_smart_callback_add(btn_terminate, "clicked", _app_terminate_cb, app); |
||||
elm_list_item_append(views, NULL, btn_terminate, NULL, NULL, NULL); |
||||
|
||||
elm_list_go(views); |
||||
} |
||||
|
||||
static void |
||||
_view_list_update_cb(void *data EINA_UNUSED, const Efl_Event *event) |
||||
{ |
||||
if (app_selected == event->object) |
||||
_app_clicked(event->object, NULL, NULL); |
||||
} |
||||
|
||||
static void |
||||
_win_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) |
||||
{ |
||||
Elm_App_Client *app; |
||||
EINA_LIST_FREE(apps_list, app) |
||||
efl_del(app); |
||||
} |
||||
|
||||
static void |
||||
_app_open(const char *package) |
||||
{ |
||||
Elm_App_Client *app; |
||||
Eina_List *l; |
||||
|
||||
EINA_LIST_FOREACH(apps_list, l, app) |
||||
{ |
||||
const char *app_package = NULL; |
||||
|
||||
app_package = elm_app_client_package_get(app); |
||||
if (!app_package) |
||||
return; |
||||
if (!strcmp(package, app_package)) |
||||
return; |
||||
} |
||||
|
||||
app = efl_add(ELM_APP_CLIENT_CLASS, NULL, elm_app_client_constructor(efl_added, package)); |
||||
efl_event_callback_add(app, ELM_APP_CLIENT_EVENT_VIEW_LIST_LOADED, _view_list_update_cb, table); |
||||
efl_event_callback_add(app, ELM_APP_CLIENT_EVENT_VIEW_CREATED, _view_list_update_cb, table); |
||||
efl_event_callback_add(app, ELM_APP_CLIENT_EVENT_VIEW_DELETED, _view_list_update_cb, table); |
||||
apps_list = eina_list_append(apps_list, app); |
||||
} |
||||
|
||||
static void |
||||
_btn_app_open_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
Evas_Object *entry = data; |
||||
const char *pkg = elm_object_text_get(entry); |
||||
|
||||
if (!pkg || !pkg[0]) |
||||
return; |
||||
|
||||
_app_open(pkg); |
||||
_apps_list_update(); |
||||
} |
||||
|
||||
static void |
||||
_open_custom_app_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info) |
||||
{ |
||||
elm_list_item_selected_set(event_info, EINA_FALSE); |
||||
elm_object_focus_set(data, EINA_TRUE); |
||||
} |
||||
|
||||
static void |
||||
_apps_list_update(void) |
||||
{ |
||||
Evas_Object *entry, *btn_open, *apps; |
||||
Elm_App_Client *app; |
||||
Eina_List *l; |
||||
|
||||
apps = elm_table_child_get(table, APPS_COL, 0); |
||||
elm_list_clear(apps); |
||||
|
||||
EINA_LIST_FOREACH(apps_list, l, app) |
||||
{ |
||||
const char *app_package = NULL; |
||||
app_package = elm_app_client_package_get(app); |
||||
elm_list_item_append(apps, app_package, NULL, NULL, _app_clicked, app); |
||||
} |
||||
|
||||
entry = elm_entry_add(apps); |
||||
elm_entry_single_line_set(entry, EINA_TRUE); |
||||
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0); |
||||
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0.5); |
||||
|
||||
btn_open = elm_button_add(apps); |
||||
elm_object_text_set(btn_open, "Open"); |
||||
evas_object_smart_callback_add(btn_open, "clicked", _btn_app_open_cb, entry); |
||||
elm_list_item_append(apps, NULL, entry, btn_open, _open_custom_app_cb, entry); |
||||
|
||||
elm_list_go(apps); |
||||
} |
||||
|
||||
void |
||||
test_task_switcher(void *data EINA_UNUSED, |
||||
Evas_Object *obj EINA_UNUSED, |
||||
void *event_info EINA_UNUSED) |
||||
{ |
||||
Evas_Object *win, *apps; |
||||
|
||||
if (apps_list) |
||||
{ |
||||
printf("Task switcher already open.\n"); |
||||
return; |
||||
} |
||||
|
||||
win = elm_win_util_standard_add("task switcher", "Task switcher"); |
||||
elm_win_autodel_set(win, EINA_TRUE); |
||||
|
||||
evas_object_smart_callback_add(win, "delete,request", _win_del, NULL); |
||||
|
||||
table = elm_table_add(win); |
||||
elm_win_resize_object_add(win, table); |
||||
elm_table_padding_set(table, 0, 0); |
||||
elm_table_homogeneous_set(table, EINA_TRUE); |
||||
evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); |
||||
evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL); |
||||
|
||||
_app_open("org.enlightenment.message"); |
||||
_app_open("org.enlightenment.phone"); |
||||
|
||||
apps = elm_list_add(table); |
||||
evas_object_size_hint_align_set(apps, EVAS_HINT_FILL, EVAS_HINT_FILL); |
||||
evas_object_show(apps); |
||||
elm_table_pack(table, apps, APPS_COL, 0, 1, 1); |
||||
_apps_list_update(); |
||||
|
||||
evas_object_show(table); |
||||
evas_object_resize(win, 1024, 768); |
||||
evas_object_show(win); |
||||
} |
@ -1,334 +0,0 @@ |
||||
#ifdef HAVE_CONFIG_H |
||||
# include "elementary_config.h" |
||||
#endif |
||||
|
||||
#include <Elementary.h> |
||||
#include "elm_priv.h" |
||||
|
||||
#define MY_CLASS ELM_APP_CLIENT_CLASS |
||||
|
||||
#define MY_CLASS_NAME "Elm_App_Client" |
||||
|
||||
typedef struct |
||||
{ |
||||
Eldbus_Proxy *app_proxy; |
||||
Eina_Hash *views; |
||||
} Elm_App_Client_Data; |
||||
|
||||
static void |
||||
_sub_path_process(Elm_App_Client *eo, Eldbus_Message_Iter *obj_iter, Elm_App_Client_Data *data, Eina_Bool loading_list) |
||||
{ |
||||
const char *obj_path; |
||||
Eldbus_Message_Iter *array_iface, *iface; |
||||
|
||||
if (!eldbus_message_iter_arguments_get(obj_iter, "oa{sa{sv}}", &obj_path, &array_iface)) |
||||
return; |
||||
while (eldbus_message_iter_get_and_next(array_iface, '{', &iface)) |
||||
{ |
||||
const char *iface_name; |
||||
Eldbus_Message_Iter *array_props; |
||||
Elm_App_Client_View *view; |
||||
|
||||
if (!eldbus_message_iter_arguments_get(iface, "sa{sv}", &iface_name, |
||||
&array_props)) |
||||
continue; |
||||
if (strcmp(iface_name, "org.enlightenment.ApplicationView1")) |
||||
continue; |
||||
|
||||
view = eina_hash_find(data->views, obj_path); |
||||
if (view) |
||||
continue; |
||||
|
||||
view = efl_add(ELM_APP_CLIENT_VIEW_CLASS, eo, elm_app_client_view_path_set(efl_added, obj_path)); |
||||
eina_hash_add(data->views, obj_path, view); |
||||
if (!loading_list) |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_EVENT_VIEW_CREATED, view); |
||||
} |
||||
} |
||||
|
||||
static void |
||||
_objects_get(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) |
||||
{ |
||||
Eo *eo = data; |
||||
Elm_App_Client_Data *cdata = efl_data_scope_get(eo, MY_CLASS); |
||||
Eldbus_Message_Iter *array_path, *path; |
||||
|
||||
if (eldbus_message_error_get(msg, NULL, NULL)) |
||||
return; |
||||
|
||||
if (!eldbus_message_arguments_get(msg, "a{oa{sa{sv}}}", &array_path)) |
||||
return; |
||||
while (eldbus_message_iter_get_and_next(array_path, '{', &path)) |
||||
_sub_path_process(eo, path, cdata, EINA_TRUE); |
||||
|
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_EVENT_VIEW_LIST_LOADED, NULL); |
||||
} |
||||
|
||||
static void _iface_add(void *data, const Eldbus_Message *msg) |
||||
{ |
||||
Eo *eo = data; |
||||
Elm_App_Client_Data *cdata = efl_data_scope_get(eo, MY_CLASS); |
||||
Eldbus_Message_Iter *main_iter; |
||||
|
||||
main_iter = eldbus_message_iter_get(msg); |
||||
_sub_path_process(eo, main_iter, cdata, EINA_FALSE); |
||||
} |
||||
|
||||
static void |
||||
_iface_del(void *data, const Eldbus_Message *msg) |
||||
{ |
||||
Eo *eo = data; |
||||
Elm_App_Client_Data *cdata = efl_data_scope_get(eo, MY_CLASS); |
||||
const char *path, *iface; |
||||
Eldbus_Message_Iter *array_iface; |
||||
|
||||
if (!eldbus_message_arguments_get(msg, "oas", &path, &array_iface)) |
||||
return; |
||||
while (eldbus_message_iter_get_and_next(array_iface, 's', &iface)) |
||||
{ |
||||
Elm_App_Client_View *view; |
||||
Elm_App_View_State view_state = ELM_APP_VIEW_STATE_UNKNOWN; |
||||
|
||||
if (strcmp(iface, "org.enlightenment.ApplicationView1")) |
||||
continue; |
||||
|
||||
view = eina_hash_find(cdata->views, path); |
||||
if (!view) |
||||
continue; |
||||
|
||||
view_state = elm_app_client_view_state_get(view); |
||||
if (view_state != ELM_APP_VIEW_STATE_CLOSED) |
||||
{ |
||||
elm_app_client_view_internal_state_set(view, |
||||
ELM_APP_VIEW_STATE_SHALLOW); |
||||
continue; |
||||
} |
||||
|
||||
eina_hash_del(cdata->views, path, NULL); |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_EVENT_VIEW_DELETED, view); |
||||
efl_del(view); |
||||
} |
||||
} |
||||
|
||||
static void |
||||
_pkg_name_owner_changed_cb(void *data, const char *bus EINA_UNUSED, const char *old_id EINA_UNUSED, const char *new_id) |
||||
{ |
||||
Elm_App_Client *eo = data; |
||||
Elm_App_Client_Data *cdata = efl_data_scope_get(eo, MY_CLASS); |
||||
Eina_Iterator *iter; |
||||
Elm_App_Client_View *view; |
||||
Eina_List *views_list = NULL; |
||||
|
||||
if (!new_id || (new_id[0] == '\0')) |
||||
return; |
||||
|
||||
iter = eina_hash_iterator_data_new(cdata->views); |
||||
EINA_ITERATOR_FOREACH(iter, view) |
||||
views_list = eina_list_append(views_list, view); |
||||
eina_iterator_free(iter); |
||||
|
||||
/*
|
||||
* remove all views that are closed of the views hash |
||||
* views not closed, only set they to SHALLOW |
||||
*/ |
||||
EINA_LIST_FREE(views_list, view) |
||||
{ |
||||
Elm_App_View_State view_state = ELM_APP_VIEW_STATE_UNKNOWN; |
||||
const char *path = NULL; |
||||
|
||||
view_state = elm_app_client_view_state_get(view); |
||||
path = elm_app_client_view_path_get(view); |
||||
if (view_state != ELM_APP_VIEW_STATE_CLOSED) |
||||
{ |
||||
elm_app_client_view_internal_state_set(view, |
||||
ELM_APP_VIEW_STATE_SHALLOW); |
||||
continue; |
||||
} |
||||
|
||||
eina_hash_del(cdata->views, path, NULL); |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_EVENT_VIEW_DELETED, view); |
||||
efl_del(view); |
||||
} |
||||
} |
||||
|
||||
EOLIAN static void |
||||
_elm_app_client_constructor(Eo *eo, Elm_App_Client_Data *data, const char *pkg) |
||||
{ |
||||
Eldbus_Connection *conn; |
||||
Eldbus_Object *obj; |
||||
char *path; |
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(pkg); |
||||
|
||||
data->views = eina_hash_string_small_new(NULL); |
||||
|
||||
path = _dbus_package_to_path(pkg); |
||||
|
||||
eldbus_init(); |
||||
conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); |
||||
obj = eldbus_object_get(conn, pkg, path); |
||||
data->app_proxy = eldbus_proxy_get(obj, "org.enlightenment.Application1"); |
||||
eldbus_object_managed_objects_get(obj, _objects_get, eo); |
||||
eldbus_object_manager_interfaces_added(obj, _iface_add, eo); |
||||
eldbus_object_manager_interfaces_removed(obj, _iface_del, eo); |
||||
eldbus_name_owner_changed_callback_add(conn, pkg, _pkg_name_owner_changed_cb, |
||||
eo, EINA_FALSE); |
||||
|
||||
free(path); |
||||
} |
||||
|
||||
static void |
||||
_create_view_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending) |
||||
{ |
||||
Elm_App_Client_Open_View_Cb cb = eldbus_pending_data_del(pending, "user_cb"); |
||||
void *user_data = eldbus_pending_data_del(pending, "user_data"); |
||||
const char *error_name, *error_message, *view_path; |
||||
Elm_App_Client *eo = data; |
||||
Elm_App_Client_View *view; |
||||
Elm_App_Client_Data *cdata = efl_data_scope_get(eo, MY_CLASS); |
||||
|
||||
if (eldbus_message_error_get(msg, &error_name, &error_message)) |
||||
{ |
||||
if (!cb) |
||||
return; |
||||
if (error_name && !strcmp(error_name, ELDBUS_ERROR_PENDING_CANCELED)) |
||||
cb(user_data, NULL, ELM_APP_CLIENT_VIEW_OPEN_CANCELED, NULL); |
||||
else if (error_name && !strcmp(error_name, ELDBUS_ERROR_PENDING_TIMEOUT)) |
||||
cb(user_data, NULL, ELM_APP_CLIENT_VIEW_OPEN_TIMEOUT, error_message); |
||||
else |
||||
cb(user_data, NULL, error_name, error_message); |
||||
return; |
||||
} |
||||
|
||||
if (!eldbus_message_arguments_get(msg, "o", &view_path)) |
||||
{ |
||||
if (cb) |
||||
cb(user_data, NULL, "Unknow error", NULL); |
||||
return; |
||||
} |
||||
|
||||
/**
|
||||
* Because a IntefaceAdd signal could arrive first |
||||
*/ |
||||
view = eina_hash_find(cdata->views, view_path); |
||||
if (!view) |
||||
{ |
||||
view = efl_add(ELM_APP_CLIENT_VIEW_CLASS, eo, elm_app_client_view_path_set(efl_added, view_path)); |
||||
eina_hash_add(cdata->views, view_path, view); |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_EVENT_VIEW_CREATED, view); |
||||
} |
||||
|
||||
if (!view) |
||||
{ |
||||
if (cb) |
||||
cb(user_data, NULL, ELM_APP_CLEINT_VIEW_OPEN_ERROR, NULL); |
||||
return; |
||||
} |
||||
if (cb) |
||||
cb(user_data, view, NULL, NULL); |
||||
} |
||||
|
||||
EOLIAN static Elm_App_Client_Pending * |
||||
_elm_app_client_view_open(Eo *eo, Elm_App_Client_Data *data, Eina_Value *args, Elm_App_Client_Open_View_Cb cb, const void *user_data) |
||||
{ |
||||
Eldbus_Message *msg; |
||||
Eldbus_Pending *pending; |
||||
|
||||
msg = eldbus_proxy_method_call_new(data->app_proxy, "CreateView"); |
||||
|
||||
if (args) |
||||
{ |
||||
if (!eldbus_message_from_eina_value("a{sv}", msg, args)) |
||||
{ |
||||
eldbus_message_unref(msg); |
||||
//TODO test to find out what type eina_value must be
|
||||
ERR("Eina_Value of args don't have a structure of a{sv}"); |
||||
return NULL; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
Eldbus_Message_Iter *main_iter = eldbus_message_iter_get(msg); |
||||
Eldbus_Message_Iter *array; |
||||
|
||||
eldbus_message_iter_arguments_append(main_iter, "a{sv}", &array); |
||||
eldbus_message_iter_container_close(main_iter, array); |
||||
} |
||||
|
||||
pending = eldbus_proxy_send(data->app_proxy, msg, _create_view_cb, eo, -1); |
||||
if (user_data) |
||||
eldbus_pending_data_set(pending, "user_data", user_data); |
||||
if (cb) |
||||
eldbus_pending_data_set(pending, "user_cb", cb); |
||||
|
||||
return pending; |
||||
} |
||||
|
||||
EOLIAN static Eina_Iterator* |
||||
_elm_app_client_views_get(Eo *eo EINA_UNUSED, Elm_App_Client_Data *data) |
||||
{ |
||||
return eina_hash_iterator_data_new(data->views); |
||||
} |
||||
|
||||
static void |
||||
_elm_app_client_view_all_close(Eo *obj EINA_UNUSED, Elm_App_Client_Data *data) |
||||
{ |
||||
eldbus_proxy_call(data->app_proxy, "CloseAllViews", NULL, NULL, -1, ""); |
||||
} |
||||
|
||||
EOLIAN static void |
||||
_elm_app_client_terminate(Eo *eo EINA_UNUSED, Elm_App_Client_Data *data) |
||||
{ |
||||
eldbus_proxy_call(data->app_proxy, "Terminate", NULL, NULL, -1, ""); |
||||
} |
||||
|
||||
EOLIAN static const char* |
||||
_elm_app_client_package_get(Eo *eo EINA_UNUSED, Elm_App_Client_Data *data) |
||||
{ |
||||
Eldbus_Object *obj; |
||||
|
||||
obj = eldbus_proxy_object_get(data->app_proxy); |
||||
return eldbus_object_bus_name_get(obj); |
||||
} |
||||
|
||||
EOLIAN static void |
||||
_elm_app_client_view_open_cancel(Eo *eo EINA_UNUSED, Elm_App_Client_Data *_pd EINA_UNUSED, Elm_App_Client_Pending *pending) |
||||
{ |
||||
eldbus_pending_cancel(pending); |
||||
} |
||||
|
||||
EOLIAN static Eo * |
||||
_elm_app_client_efl_object_finalize(Eo *obj, Elm_App_Client_Data *data) |
||||
{ |
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data->views, NULL); |
||||
|
||||
return efl_finalize(efl_super(obj, MY_CLASS)); |
||||
} |
||||
|
||||
EOLIAN static void |
||||
_elm_app_client_efl_object_destructor(Eo *eo, Elm_App_Client_Data *data) |
||||
{ |
||||
Eldbus_Object *obj; |
||||
Eldbus_Connection *conn; |
||||
Eina_Iterator *iter; |
||||
Elm_App_Client_View *view; |
||||
|
||||
iter = eina_hash_iterator_data_new(data->views); |
||||
EINA_ITERATOR_FOREACH(iter, view) |
||||
efl_del(view); |
||||
eina_iterator_free(iter); |
||||
eina_hash_free(data->views); |
||||
|
||||
obj = eldbus_proxy_object_get(data->app_proxy); |
||||
conn = eldbus_object_connection_get(obj); |
||||
eldbus_name_owner_changed_callback_del(conn, eldbus_object_bus_name_get(obj), |
||||
_pkg_name_owner_changed_cb, eo); |
||||
eldbus_proxy_unref(data->app_proxy); |
||||
eldbus_object_unref(obj); |
||||
eldbus_connection_unref(conn); |
||||
eldbus_shutdown(); |
||||
|
||||
efl_destructor(efl_super(eo, MY_CLASS)); |
||||
} |
||||
|
||||
#include "elm_app_client.eo.c" |
@ -1,68 +0,0 @@ |
||||
import eina_types; |
||||
|
||||
type Elm_App_Client_Open_View_Cb: __undefined_type; |
||||
type Elm_App_Client_Pending: __undefined_type; |
||||
|
||||
class Elm.App.Client (Efl.Object) |
||||
{ |
||||
methods { |
||||
@property views { |
||||
get { |
||||
[[Return a iterator with all views of application.]] |
||||
} |
||||
values { |
||||
ret: free(own(iterator<Elm.App.Client.View>), eina_iterator_free); [[The iterator with all views, must be freed after use.]] |
||||
} |
||||
} |
||||
@property package { |
||||
get { |
||||
[[Return the application package.]] |
||||
} |
||||
values { |
||||
ret: string; [[application package]] |
||||
} |
||||
} |
||||
constructor { |
||||
[[Class constructor of elm_app_client.]] |
||||
legacy: null; |
||||
params { |
||||
@in package: string; [[Package of application]] |
||||
} |
||||
} |
||||
view_all_close { |
||||
[[Close all views of application.]] |
||||
} |
||||
terminate { |
||||
[[Terminate application.]] |
||||
} |
||||
view_open { |
||||
[[Open an application view.]] |
||||
params { |
||||
@in args: generic_value * @optional; [[an array of.]] |
||||
@in view_open_cb: Elm_App_Client_Open_View_Cb @optional; [[callback to be called when view open]] |
||||
@in data: const(void_ptr) @optional; [[callback user data]] |
||||
} |
||||
return: Elm_App_Client_Pending *; [[handler to cancel the view opening if it takes to long ]] |
||||
} |
||||
view_open_cancel { |
||||
[[Cancel a pending elm_app_client_view_open().]] |
||||
params { |
||||
@in pending: Elm_App_Client_Pending *; [[the view open handler]] |
||||
} |
||||
} |
||||
} |
||||
implements { |
||||
Efl.Object.destructor; |
||||
Efl.Object.finalize; |
||||
} |
||||
constructors { |
||||
.constructor; |
||||
} |
||||
events { |
||||
view,created; [[Called when a view of this application is created.]] |
||||
view,deleted; [[Called when a view of this application is deleted.]] |
||||
view_list,loaded; [[Called when list of view is loaded.]] |
||||
application,terminated; [[Called when application is terminated.]] |
||||
} |
||||
|
||||
} |
@ -1,3 +0,0 @@ |
||||
#ifdef EFL_EO_API_SUPPORT |
||||
#include "elm_app_client_eo.h" |
||||
#endif |
@ -1,11 +0,0 @@ |
||||
typedef Eo Elm_App_Client; |
||||
#define _ELM_APP_CLIENT_EO_CLASS_TYPE |
||||
|
||||
typedef Eo Elm_App_Client_View; |
||||
#define _ELM_APP_CLIENT_VIEW_EO_CLASS_TYPE |
||||
|
||||
typedef Eldbus_Pending Elm_App_Client_Pending; |
||||
|
||||
typedef void (*Elm_App_Client_Open_View_Cb)(void *data, Elm_App_Client_View *view, const char *error, const char *error_message); |
||||
|
||||
#include "elm_app_client.eo.h" |
@ -1,315 +0,0 @@ |
||||
#ifdef HAVE_CONFIG_H |
||||
# include "elementary_config.h" |
||||
#endif |
||||
|
||||
#include <Elementary.h> |
||||
#include "elm_priv.h" |
||||
|
||||
#define MY_CLASS ELM_APP_CLIENT_VIEW_CLASS |
||||
|
||||
#define MY_CLASS_NAME "Elm_App_Client_View" |
||||
|
||||
typedef struct |
||||
{ |
||||
Eldbus_Proxy *view_proxy; |
||||
Elm_App_View_State state; |
||||
Eina_Stringshare *path; |
||||
} Elm_App_Client_View_Data; |
||||
|
||||
static const char *_string_prop_get(const Eina_Value *v) |
||||
{ |
||||
const char *str; |
||||
|
||||
if (!v) |
||||
return ""; |
||||
|
||||
eina_value_get(v, &str); |
||||
return str; |
||||
} |
||||
|
||||
static int _int_prop_get(const Eina_Value *v) |
||||
{ |
||||
int num; |
||||
|
||||
if (!v) |
||||
return 0; |
||||
|
||||
eina_value_get(v, &num); |
||||
return num; |
||||
} |
||||
|
||||
static short _short_prop_get(const Eina_Value *v) |
||||
{ |
||||
short num; |
||||
|
||||
if (!v) |
||||
return 0; |
||||
|
||||
eina_value_get(v, &num); |
||||
return num; |
||||
} |
||||
|
||||
static void |
||||
_prop_changed(void *user_data, Eldbus_Proxy *proxy EINA_UNUSED, void *event_info) |
||||
{ |
||||
Eldbus_Proxy_Event_Property_Changed *prop_event = event_info; |
||||
Elm_App_Client_View *eo = user_data; |
||||
const Eina_Value *v = prop_event->value; |
||||
Elm_App_Client_View_Data *cdata = efl_data_scope_get(eo, MY_CLASS); |
||||
|
||||
if (!strcmp(prop_event->name, "Title")) |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_VIEW_EVENT_TITLE_CHANGED, (void *) _string_prop_get(v)); |
||||
else if (!strcmp(prop_event->name, "IconName")) |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_VIEW_EVENT_ICON_CHANGED, (void *) _string_prop_get(v)); |
||||
else if (!strcmp(prop_event->name, "IconPixels")) |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_VIEW_EVENT_ICON_PIXELS_CHANGED, NULL); |
||||
else if (!strcmp(prop_event->name, "NewEvents")) |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_VIEW_EVENT_NEW_EVENTS_CHANGED, (void *)(uintptr_t)_int_prop_get(v)); |
||||
else if (!strcmp(prop_event->name, "Progress")) |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_VIEW_EVENT_PROGRESS_CHANGED, (void *)(uintptr_t)_short_prop_get(v)); |
||||
else if (!strcmp(prop_event->name, "State")) |
||||
{ |
||||
cdata->state = _string_state_to_id(_string_prop_get(v)); |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_VIEW_EVENT_STATE_CHANGED, (void *)(uintptr_t)cdata->state); |
||||
} |
||||
else if (!strcmp(prop_event->name, "WindowId")) |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_VIEW_EVENT_WINDOW_CHANGED, (void *)(uintptr_t)_int_prop_get(v)); |
||||
else |
||||
return; |
||||
|
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_VIEW_EVENT_PROPERTY_CHANGED, (void *) prop_event->name); |
||||
} |
||||
|
||||
static void |
||||
_props_loaded(void *user_data, Eldbus_Proxy *proxy EINA_UNUSED, void *event_info EINA_UNUSED) |
||||
{ |
||||
const Eina_Hash *props = eldbus_proxy_property_local_get_all(proxy); |
||||
Eina_Iterator *iter; |
||||
Eina_Hash_Tuple *t; |
||||
|
||||
iter = eina_hash_iterator_tuple_new(props); |
||||
EINA_ITERATOR_FOREACH(iter, t) |
||||
{ |
||||
Eldbus_Proxy_Event_Property_Changed event; |
||||
|
||||
event.name = t->key; |
||||
event.proxy = proxy; |
||||
event.value = t->data; |
||||
|
||||
_prop_changed(user_data, proxy, &event); |
||||
} |
||||
eina_iterator_free(iter); |
||||
} |
||||
|
||||
void |
||||
elm_app_client_view_internal_state_set(Eo *eo, Elm_App_View_State state) |
||||
{ |
||||
Elm_App_Client_View_Data *cdata; |
||||
Eina_Bool changed = EINA_FALSE; |
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN(eo); |
||||
EINA_SAFETY_ON_FALSE_RETURN(efl_isa(eo, ELM_APP_CLIENT_VIEW_CLASS)); |
||||
|
||||
cdata = efl_data_scope_get(eo, MY_CLASS); |
||||
changed = cdata->state != state; |
||||
cdata->state = state; |
||||
if (!changed) |
||||
return; |
||||
efl_event_callback_legacy_call(eo, ELM_APP_CLIENT_VIEW_EVENT_STATE_CHANGED, (void *)(uintptr_t)cdata->state); |
||||
} |
||||
|
||||
EOLIAN static Eo * |
||||
_elm_app_client_view_efl_object_finalize(Eo *eo, Elm_App_Client_View_Data *data) |
||||
{ |
||||
Elm_App_Client *parent = NULL; |
||||
const char *package = data->path; |
||||
Eldbus_Connection *conn; |
||||
Eldbus_Object *obj; |
||||
|
||||
parent = efl_parent_get(eo); |
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL((!parent) || |
||||
(!efl_isa(parent, ELM_APP_CLIENT_CLASS)), NULL); |
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(data->path, NULL); |
||||
|
||||
package = elm_app_client_package_get(parent); |
||||
|
||||
eldbus_init(); |
||||
conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); |
||||
obj = eldbus_object_get(conn, package, data->path); |
||||
data->view_proxy = eldbus_proxy_get(obj, |
||||
"org.enlightenment.ApplicationView1"); |
||||
eldbus_proxy_properties_monitor(data->view_proxy, EINA_TRUE); |
||||
eldbus_proxy_event_callback_add(data->view_proxy, |
||||
ELDBUS_PROXY_EVENT_PROPERTY_CHANGED, |
||||
_prop_changed, eo); |
||||
eldbus_proxy_event_callback_add(data->view_proxy, |
||||
ELDBUS_PROXY_EVENT_PROPERTY_LOADED, |
||||
_props_loaded, eo); |
||||
|
||||
return efl_finalize(efl_super(eo, MY_CLASS)); |
||||
} |
||||
|
||||
static void |
||||
_dbus_state_set_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending) |
||||
{ |
||||
Elm_App_Client_View *eo = data; |
||||
Elm_App_Client_View_Cb cb = eldbus_pending_data_del(pending, "cb"); |
||||
void *user_data = eldbus_pending_data_del(pending, "user_data"); |
||||
const char *error = NULL, *error_message = NULL; |
||||
|
||||
if (!cb) return; |
||||
|
||||
if (!eldbus_message_error_get(msg, &error, &error_message)) |
||||
error_message = NULL; |
||||
|
||||
cb(user_data, eo, error, error_message); |
||||
} |
||||
|
||||
static void |
||||
_dbus_action_do(Eo *eo, Eldbus_Proxy *proxy, const char *action, Elm_App_Client_View_Cb cb, const void *data) |
||||
{ |
||||
Eldbus_Pending *pending; |
||||
|
||||
if (!cb) |
||||
{ |
||||
eldbus_proxy_call(proxy, action, NULL, NULL, -1, ""); |
||||
return; |
||||
} |