summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Roberto de Souza <jose.souza@intel.com>2013-08-16 18:18:07 -0300
committerJosé Roberto de Souza <jose.souza@intel.com>2013-09-19 15:48:25 -0300
commit436efa163a5471f662ef561e5df11abc59b399f7 (patch)
treec9da2e1a260d566f2aa06e7b9dfa46d30382a387
parentab4142e750fa597766a956938cb6a2feea671f42 (diff)
Add elm_app_service/client class
These classes are the implementation of Enlightenment Application spec, proposed by k-s. https://phab.enlightenment.org/w/enlightenmentappspecproposal/ To test play with Message, Phone and Task switcher in elementary_test.
-rw-r--r--src/bin/Makefile.am4
-rw-r--r--src/bin/test.c8
-rw-r--r--src/bin/test_application_server.c211
-rw-r--r--src/bin/test_task_switcher.c408
-rw-r--r--src/lib/Elementary.h.in5
-rw-r--r--src/lib/Makefile.am15
-rw-r--r--src/lib/elm_app_client.c432
-rw-r--r--src/lib/elm_app_client.h3
-rw-r--r--src/lib/elm_app_client_eo.h111
-rw-r--r--src/lib/elm_app_client_view.c425
-rw-r--r--src/lib/elm_app_client_view.h3
-rw-r--r--src/lib/elm_app_client_view_eo.h194
-rw-r--r--src/lib/elm_app_common.c56
-rw-r--r--src/lib/elm_app_common.h17
-rw-r--r--src/lib/elm_app_server.c571
-rw-r--r--src/lib/elm_app_server.h3
-rw-r--r--src/lib/elm_app_server_eet.c312
-rw-r--r--src/lib/elm_app_server_eet.h46
-rw-r--r--src/lib/elm_app_server_eo.h137
-rw-r--r--src/lib/elm_app_server_view.c526
-rw-r--r--src/lib/elm_app_server_view.h3
-rw-r--r--src/lib/elm_app_server_view_eo.h97
22 files changed, 3586 insertions, 1 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index 9677a5080..906905016 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -48,6 +48,7 @@ test_3d.c \
48test_access.c \ 48test_access.c \
49test_actionslider.c \ 49test_actionslider.c \
50test_anim.c \ 50test_anim.c \
51test_application_server.c \
51test_bg.c \ 52test_bg.c \
52test_box.c \ 53test_box.c \
53test_bubble.c \ 54test_bubble.c \
@@ -126,6 +127,7 @@ test_spinner.c \
126test_store.c \ 127test_store.c \
127test_sys_notify.c \ 128test_sys_notify.c \
128test_systray.c \ 129test_systray.c \
130test_task_switcher.c \
129test_table.c \ 131test_table.c \
130test_thumb.c \ 132test_thumb.c \
131test_toolbar.c \ 133test_toolbar.c \
@@ -267,4 +269,4 @@ elementary_testql_LDFLAGS =
267endif 269endif
268 270
269EXTRA_DIST = \ 271EXTRA_DIST = \
270test_factory.c 272test_factory.c \ No newline at end of file
diff --git a/src/bin/test.c b/src/bin/test.c
index 2e69866b8..ad6379872 100644
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -226,6 +226,9 @@ void test_web_mobile(void *data, Evas_Object *obj, void *event_info);
226void test_dnd_genlist_default_anim(void *data, Evas_Object *obj, void *event_info); 226void test_dnd_genlist_default_anim(void *data, Evas_Object *obj, void *event_info);
227void test_dnd_genlist_user_anim(void *data, Evas_Object *obj, void *event_info); 227void test_dnd_genlist_user_anim(void *data, Evas_Object *obj, void *event_info);
228void test_dnd_genlist_gengrid(void *data, Evas_Object *obj, void *event_info); 228void test_dnd_genlist_gengrid(void *data, Evas_Object *obj, void *event_info);
229void test_task_switcher(void *data, Evas_Object *obj, void *event_info);
230void test_application_server_message(void *data, Evas_Object *obj, void *event_info);
231void test_application_server_phone(void *data, Evas_Object *obj, void *event_info);
229 232
230Evas_Object *win, *tbx; // TODO: refactoring 233Evas_Object *win, *tbx; // TODO: refactoring
231void *tt; 234void *tt;
@@ -795,6 +798,11 @@ add_tests:
795 ADD_TEST(NULL, "Miscellaneous", "Accessibility2", test_access2); 798 ADD_TEST(NULL, "Miscellaneous", "Accessibility2", test_access2);
796 ADD_TEST(NULL, "Miscellaneous", "Accessibility3", test_access3); 799 ADD_TEST(NULL, "Miscellaneous", "Accessibility3", test_access3);
797 800
801 //------------------------------//
802 ADD_TEST(NULL, "Application client/server", "Task switcher", test_task_switcher);
803 ADD_TEST(NULL, "Application client/server", "Phone", test_application_server_phone);
804 ADD_TEST(NULL, "Application client/server", "Message", test_application_server_message);
805
798#undef ADD_TEST 806#undef ADD_TEST
799 807
800 if (autorun) 808 if (autorun)
diff --git a/src/bin/test_application_server.c b/src/bin/test_application_server.c
new file mode 100644
index 000000000..dbb34a560
--- /dev/null
+++ b/src/bin/test_application_server.c
@@ -0,0 +1,211 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5#ifndef ELM_LIB_QUICKLAUNCH
6
7typedef struct {
8 Evas_Object *win, *label;
9 Eina_Stringshare *view_name;
10} App_View_Context;
11
12static Elm_App_Server *phone_server = NULL, *msg_server = NULL;
13
14static void _text_update(App_View_Context *ctx, const char *state)
15{
16 char buffer[1024];
17
18 if (!ctx->label)
19 return;
20 snprintf(buffer, sizeof(buffer), "%s - state=%s", ctx->view_name, state);
21 elm_object_text_set(ctx->label, buffer);
22}
23
24static void
25_window_create(App_View_Context *ctx)
26{
27 ctx->win = elm_win_util_standard_add("app_view", ctx->view_name);
28
29 ctx->label = elm_label_add(ctx->win);
30 evas_object_size_hint_weight_set(ctx->label, EVAS_HINT_EXPAND,
31 EVAS_HINT_EXPAND);
32 evas_object_data_set(ctx->win, "label", ctx->label);
33
34 _text_update(ctx, "alive");
35
36 elm_win_resize_object_add(ctx->win, ctx->label);
37 evas_object_show(ctx->label);
38
39 evas_object_resize(ctx->win, 400, 300);
40 evas_object_show(ctx->win);
41}
42
43static Eina_Bool
44_close_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
45{
46 App_View_Context *ctx = data;
47 if (ctx->win)
48 evas_object_del(ctx->win);
49 eo_del(obj);
50 return EINA_TRUE;
51}
52
53static Eina_Bool
54_pause_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
55{
56 App_View_Context *ctx = data;
57 _text_update(ctx, "paused");
58 return EINA_TRUE;
59}
60
61static Eina_Bool
62_resume_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
63{
64 App_View_Context *ctx = data;
65
66 //shallow state
67 if (!ctx->win)
68 {
69 _window_create(ctx);
70 eo_do(obj, elm_app_server_view_window_set(ctx->win));
71 }
72
73 _text_update(ctx, "alive");
74 return EINA_TRUE;
75}
76
77static Eina_Bool
78_view_del_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
79{
80 App_View_Context *ctx = data;
81
82 if (ctx->win)
83 evas_object_del(ctx->win);
84 eo_do(obj, elm_app_server_view_window_set(NULL));
85 eina_stringshare_del(ctx->view_name);
86 free(ctx);
87 return EINA_TRUE;
88}
89
90static Elm_App_Server_View *
91_create_view_cb(Elm_App_Server *app_server, const Eina_Value *args EINA_UNUSED, Eina_Stringshare **error_name, Eina_Stringshare **error_message EINA_UNUSED)
92{
93 Elm_App_Server_View *view;
94 const char *id, *pkg;
95 App_View_Context *ctx;
96
97 ctx = calloc(1, sizeof(App_View_Context));
98 if (!ctx)
99 {
100 *error_name = eina_stringshare_add("No memory available");
101 return NULL;
102 }
103
104 view = eo_add_custom(ELM_APP_SERVER_VIEW_CLASS, app_server,
105 elm_app_server_view_constructor(NULL));
106
107 eo_do(view, elm_app_server_view_id_get(&id));
108 eo_do(app_server, elm_app_server_package_get(&pkg));
109 ctx->view_name = eina_stringshare_printf("%s %s", pkg, id);
110
111 _window_create(ctx);
112
113 eo_do(view, elm_app_server_view_title_set(ctx->view_name),
114 elm_app_server_view_new_events_set(5),
115 elm_app_server_view_window_set(ctx->win),
116 elm_app_server_view_resume(),
117 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_CLOSED, _close_cb, ctx),
118 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_PAUSED, _pause_cb, ctx),
119 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_RESUMED, _resume_cb, ctx),
120 eo_event_callback_add(EO_EV_DEL, _view_del_cb, ctx));
121
122 return view;
123}
124
125static Eina_Bool
126_terminate_cb(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
127{
128 const char *title;
129
130 printf("terminate cb\n");
131 eo_do(obj, elm_app_server_save(),
132 elm_app_server_title_get(&title));
133
134 printf("Closing: %s\n", title);
135 eo_unref(obj);
136 return EINA_TRUE;
137}
138
139Elm_App_Server *
140test_application_server_common(const char *pkg)
141{
142 Eina_Iterator *views_iter;
143 Elm_App_Server_View *view;
144 Elm_App_Server *server;
145
146 server = eo_add_custom(ELM_APP_SERVER_CLASS, NULL,
147 elm_app_server_constructor(pkg, _create_view_cb));
148 eo_do(server, elm_app_server_title_set(pkg),
149 elm_app_server_views_get(&views_iter),
150 eo_event_callback_add(ELM_APP_SERVER_EV_TERMINATE, _terminate_cb, NULL));
151
152 //views create in shallow state
153 EINA_ITERATOR_FOREACH(views_iter, view)
154 {
155 App_View_Context *ctx;
156 const char *id;
157
158 ctx = calloc(1, sizeof(App_View_Context));
159
160 eo_do(view, elm_app_server_view_id_get(&id));
161 ctx->view_name = eina_stringshare_printf("%s %s", pkg, id);
162
163 eo_do(view,
164 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_CLOSED, _close_cb, ctx),
165 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_PAUSED, _pause_cb, ctx),
166 eo_event_callback_add(ELM_APP_SERVER_VIEW_EV_RESUMED, _resume_cb, ctx),
167 eo_event_callback_add(EO_EV_DEL, _view_del_cb, ctx));
168 }
169 eina_iterator_free(views_iter);
170
171 return server;
172}
173
174static Eina_Bool
175_server_del_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
176{
177 Elm_App_Server **server = data;
178 *server = NULL;
179 return EINA_TRUE;
180}
181
182void
183test_application_server_phone(void *data EINA_UNUSED,
184 Evas_Object *obj EINA_UNUSED,
185 void *event_info EINA_UNUSED)
186{
187 if (phone_server)
188 {
189 printf("Phone already running\n");
190 return;
191 }
192 printf("Starting phone\n");
193 phone_server = test_application_server_common("org.enlightenment.phone");
194 eo_do(phone_server, eo_event_callback_add(EO_EV_DEL, _server_del_cb, &phone_server));
195}
196
197void
198test_application_server_message(void *data EINA_UNUSED,
199 Evas_Object *obj EINA_UNUSED,
200 void *event_info EINA_UNUSED)
201{
202 if (msg_server)
203 {
204 printf("Message already running\n");
205 return;
206 }
207 printf("Starting message\n");
208 msg_server = test_application_server_common( "org.enlightenment.message");
209 eo_do(msg_server, eo_event_callback_add(EO_EV_DEL, _server_del_cb, &msg_server));
210}
211#endif
diff --git a/src/bin/test_task_switcher.c b/src/bin/test_task_switcher.c
new file mode 100644
index 000000000..7cb908493
--- /dev/null
+++ b/src/bin/test_task_switcher.c
@@ -0,0 +1,408 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5#include <Eina.h>
6#ifndef ELM_LIB_QUICKLAUNCH
7
8#define APPS_COL 0
9#define VIEWS_COL 1
10#define PROPS_VIEW_COL 2
11
12static Evas_Object *table = NULL;
13static Elm_App_Client *app_selected = NULL;
14static Eina_List *apps_list = NULL;
15
16static void _app_view_clicked(void *data, Evas_Object *obj, void *event_info);
17static void _apps_list_update(void);
18
19static void _btn_close_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
20{
21 Elm_App_Client_View *view = data;
22 eo_do(view, elm_app_client_view_close(NULL, NULL));
23}
24
25static void _btn_pause_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
26{
27 Elm_App_Client_View *view = data;
28 eo_do(view, elm_app_client_view_pause(NULL, NULL));
29}
30
31static void _btn_resume_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
32{
33 Elm_App_Client_View *view = data;
34 eo_do(view, elm_app_client_view_resume(NULL, NULL));
35}
36
37static Eina_Bool
38_app_view_prop_changed_cb(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
39{
40 Elm_App_View_State state;
41
42 eo_do(obj, elm_app_client_view_state_get(&state));
43
44 if (state == ELM_APP_VIEW_STATE_CLOSED)
45 {
46 Evas_Object *props = elm_table_child_get(table, PROPS_VIEW_COL, 0);
47 elm_table_unpack(table, props);
48 evas_object_del(props);
49 }
50 else
51 _app_view_clicked(obj, NULL, NULL);
52
53 return EINA_TRUE;
54}
55
56static void
57_app_view_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
58{
59 Elm_App_Client_View *view = data;
60 Evas_Object *view_props, *close_btn, *resume_btn, *pause_btn;
61 const char *title, *icon;
62 int new_events, window;
63 unsigned short progress;
64 Elm_App_View_State state;
65 char buffer[1024];
66
67 view_props = elm_table_child_get(table, PROPS_VIEW_COL, 0);
68 if (view_props)
69 {
70 Elm_App_Client_View *old_view;
71
72 old_view = evas_object_data_del(view_props, "view");
73 eo_do(old_view,
74 eo_event_callback_del(ELM_APP_CLIENT_VIEW_EV_PROPERTY_CHANGED,
75 _app_view_prop_changed_cb, table));
76 elm_list_clear(view_props);
77 }
78 else
79 {
80 view_props = elm_list_add(table);
81 evas_object_size_hint_align_set(view_props, EVAS_HINT_FILL,
82 EVAS_HINT_FILL);
83 evas_object_show(view_props);
84 elm_table_pack(table, view_props, PROPS_VIEW_COL, 0, 1, 1);
85 }
86
87 evas_object_data_set(view_props, "view", view);
88
89 eo_do(view, elm_app_client_view_title_get(&title),
90 elm_app_client_view_icon_get(&icon),
91 elm_app_client_view_progress_get(&progress),
92 elm_app_client_view_new_events_get(&new_events),
93 elm_app_client_view_window_get(&window),
94 eo_event_callback_add(ELM_APP_CLIENT_VIEW_EV_PROPERTY_CHANGED,
95 _app_view_prop_changed_cb, table));
96
97 snprintf(buffer, sizeof(buffer), "Title=%s", title);
98 elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL);
99
100 snprintf(buffer, sizeof(buffer), "Icon=%s", icon);
101 elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL);
102
103 snprintf(buffer, sizeof(buffer), "Progress=%d", progress);
104 elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL);
105
106 snprintf(buffer, sizeof(buffer), "New events=%d", new_events);
107 elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL);
108
109 snprintf(buffer, sizeof(buffer), "WindowID=%d", window);
110 elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL);
111
112 eo_do(view, elm_app_client_view_state_get(&state));
113 if (state == ELM_APP_VIEW_STATE_LIVE)
114 snprintf(buffer, sizeof(buffer), "State=alive");
115 else if (state == ELM_APP_VIEW_STATE_PAUSED)
116 snprintf(buffer, sizeof(buffer), "State=paused");
117 else if (state == ELM_APP_VIEW_STATE_CLOSED)
118 snprintf(buffer, sizeof(buffer), "State=closed");
119 else if (state == ELM_APP_VIEW_STATE_SHALLOW)
120 snprintf(buffer, sizeof(buffer), "State=shallow");
121 else
122 snprintf(buffer, sizeof(buffer), "State=unknown");
123 elm_list_item_append(view_props, buffer, NULL, NULL, NULL, NULL);
124
125 close_btn = elm_button_add(view_props);
126 elm_object_text_set(close_btn, "Close view");
127 evas_object_smart_callback_add(close_btn, "clicked", _btn_close_cb, view);
128 elm_list_item_append(view_props, NULL, close_btn, NULL, NULL, NULL);
129
130 pause_btn = elm_button_add(view_props);
131 elm_object_text_set(pause_btn, "Pause view");
132 evas_object_smart_callback_add(pause_btn, "clicked", _btn_pause_cb, view);
133 elm_list_item_append(view_props, NULL, pause_btn, NULL, NULL, NULL );
134
135 resume_btn = elm_button_add(view_props);
136 elm_object_text_set(resume_btn, "Resume view");
137 evas_object_smart_callback_add(resume_btn, "clicked", _btn_resume_cb, view);
138 elm_list_item_append(view_props, NULL, resume_btn, NULL, NULL, NULL );
139
140 elm_list_go(view_props);
141}
142
143static void
144_popup_close_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
145{
146 evas_object_del(data);
147}
148
149static void app_client_view_open_cb(void *data EINA_UNUSED, Elm_App_Client_View *view, const char *error, const char *error_message)
150{
151 Evas_Object *popup, *btn_ok;
152 char buf[1024];
153
154 popup = elm_popup_add(table);
155
156 if (view)
157 {
158 _app_view_clicked(view, NULL, NULL);
159 return;
160 }
161
162 snprintf(buf, sizeof(buf), "Some error happen opening view: %s %s", error, error_message);
163 elm_object_part_text_set(popup, "default", buf);
164
165 btn_ok = elm_button_add(popup);
166 elm_object_text_set(btn_ok, "Ok");
167 elm_object_part_content_set(popup, "button1", btn_ok);
168 evas_object_smart_callback_add(btn_ok, "clicked", _popup_close_cb, popup);
169
170 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP);
171 evas_object_show(popup);
172}
173
174static void _popup_btn_open_view_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
175{
176 Evas_Object *popup = data;
177 Eina_Value *args = NULL;//TODO fill with args of popup
178 Elm_App_Client *app = evas_object_data_get(popup, "app");
179
180 eo_do(app, elm_app_client_view_open(args, app_client_view_open_cb, NULL, NULL));
181
182 evas_object_del(popup);
183}
184
185static void
186_app_view_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
187{
188 Elm_App_Client *app = data;
189 Evas_Object *popup, *btn_open, *btn_cancel, *args_box;
190
191 popup = elm_popup_add(table);
192 elm_object_part_text_set(popup, "title,text", "Open a view");
193
194 btn_open = elm_button_add(popup);
195 elm_object_text_set(btn_open, "Open");
196 elm_object_part_content_set(popup, "button1", btn_open);
197 evas_object_smart_callback_add(btn_open, "clicked", _popup_btn_open_view_cb, popup);
198 evas_object_show(btn_open);
199
200 btn_cancel = elm_button_add(popup);
201 elm_object_text_set(btn_cancel, "Cancel");
202 elm_object_part_content_set(popup, "button2", btn_cancel);
203 evas_object_smart_callback_add(btn_cancel, "clicked", _popup_close_cb, popup);
204 evas_object_show(btn_cancel);
205
206 args_box = elm_box_add(popup);
207 elm_object_part_content_set(popup, "default", args_box);
208 elm_object_part_text_set(popup, "default", "TODO: add some entrys to add some parameters to view.");
209
210 evas_object_data_set(popup, "app", app);
211 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP);
212 evas_object_show(popup);
213}
214
215static void _app_close_all_views_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
216{
217 Elm_App_Client *app = data;
218 eo_do(app, elm_app_client_view_all_close());
219}
220
221static void
222_app_terminate_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
223{
224 Elm_App_Client *app = data;
225 eo_do(app, elm_app_client_terminate());
226}
227
228static void
229_app_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
230{
231 Evas_Object *views, *btn_close_all, *btn_terminate, *btn_open_view;
232 Eina_Iterator *views_iter;
233 Elm_App_Client_View *client_view;
234 Elm_App_Client *app = data;
235
236 app_selected = app;
237
238 views = elm_table_child_get(table, VIEWS_COL, 0);
239 if (!views)
240 {
241 views = elm_list_add(table);
242 evas_object_size_hint_align_set(views, EVAS_HINT_FILL, EVAS_HINT_FILL);
243 evas_object_show(views);
244 elm_table_pack(table, views, VIEWS_COL, 0, 1, 1);
245 }
246 else
247 elm_list_clear(views);
248
249 btn_open_view = elm_button_add(views);
250 elm_object_text_set(btn_open_view, "Open a view");
251 evas_object_smart_callback_add(btn_open_view, "clicked", _app_view_open, app);
252 elm_list_item_append(views, NULL, btn_open_view, NULL, NULL, NULL);
253
254 eo_do(app, elm_app_client_views_get(&views_iter));
255 EINA_ITERATOR_FOREACH(views_iter, client_view)
256 {
257 const char *path;
258
259 eo_do(client_view, elm_app_client_view_path_get(&path));
260 elm_list_item_append(views, path, NULL, NULL, _app_view_clicked, client_view);
261 }
262 eina_iterator_free(views_iter);
263
264 btn_close_all = elm_button_add(views);
265 elm_object_text_set(btn_close_all, "Close all views");
266 evas_object_smart_callback_add(btn_close_all, "clicked", _app_close_all_views_cb, app);
267 elm_list_item_append(views, NULL, btn_close_all, NULL, NULL, NULL);
268
269 btn_terminate = elm_button_add(views);
270 elm_object_text_set(btn_terminate, "Terminate application");
271 evas_object_smart_callback_add(btn_terminate, "clicked", _app_terminate_cb, app);
272 elm_list_item_append(views, NULL, btn_terminate, NULL, NULL, NULL);
273
274 elm_list_go(views);
275}
276
277static Eina_Bool
278_view_list_update_cb(void *data EINA_UNUSED, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
279{
280 if (app_selected == obj)
281 _app_clicked(obj, NULL, NULL);
282 return EINA_TRUE;
283}
284
285static void
286_win_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
287{
288 Elm_App_Client *app;
289 EINA_LIST_FREE(apps_list, app)
290 eo_unref(app);
291}
292
293static void
294_app_open(const char *package)
295{
296 Elm_App_Client *app;
297 Eina_List *l;
298
299 EINA_LIST_FOREACH(apps_list, l, app)
300 {
301 const char *app_package;
302
303 eo_do(app, elm_app_client_package_get(&app_package));
304 if (!strcmp(package, app_package))
305 return;
306 }
307
308 app = eo_add_custom(ELM_APP_CLIENT_CLASS, NULL,
309 elm_app_client_constructor(package));
310 eo_do(app,
311 eo_event_callback_add(ELM_APP_CLIENT_EV_VIEW_LIST_LOADED,
312 _view_list_update_cb, table),
313 eo_event_callback_add(ELM_APP_CLIENT_EV_VIEW_CREATED,
314 _view_list_update_cb, table),
315 eo_event_callback_add(ELM_APP_CLIENT_EV_VIEW_DELETED,
316 _view_list_update_cb, table));
317 apps_list = eina_list_append(apps_list, app);
318}
319
320static void
321_btn_app_open_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
322{
323 Evas_Object *entry = data;
324 const char *pkg = elm_object_text_get(entry);
325
326 if (!pkg || !pkg[0])
327 return;
328
329 _app_open(pkg);
330 _apps_list_update();
331}
332
333static void
334_open_custom_app_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
335{
336 elm_list_item_selected_set(event_info, EINA_FALSE);
337 elm_object_focus_set(data, EINA_TRUE);
338}
339
340static void
341_apps_list_update(void)
342{
343 Evas_Object *entry, *btn_open, *apps;
344 Elm_App_Client *app;
345 Eina_List *l;
346
347 apps = elm_table_child_get(table, APPS_COL, 0);
348 elm_list_clear(apps);
349
350 EINA_LIST_FOREACH(apps_list, l, app)
351 {
352 const char *app_package;
353 eo_do(app, elm_app_client_package_get(&app_package));
354 elm_list_item_append(apps, app_package, NULL, NULL, _app_clicked, app);
355 }
356
357 entry = elm_entry_add(apps);
358 elm_entry_single_line_set(entry, EINA_TRUE);
359 evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0.0);
360 evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0.5);
361
362 btn_open = elm_button_add(apps);
363 elm_object_text_set(btn_open, "Open");
364 evas_object_smart_callback_add(btn_open, "clicked", _btn_app_open_cb, entry);
365 elm_list_item_append(apps, NULL, entry, btn_open, _open_custom_app_cb, entry);
366
367 elm_list_go(apps);
368}
369
370void
371test_task_switcher(void *data EINA_UNUSED,
372 Evas_Object *obj EINA_UNUSED,
373 void *event_info EINA_UNUSED)
374{
375 Evas_Object *win, *apps;
376
377 if (apps_list)
378 {
379 printf("Task switcher already open.\n");
380 return;
381 }
382
383 win = elm_win_util_standard_add("task switcher", "Task switcher");
384 elm_win_autodel_set(win, EINA_TRUE);
385
386 evas_object_smart_callback_add(win, "delete,request", _win_del, NULL);
387
388 table = elm_table_add(win);
389 elm_win_resize_object_add(win, table);
390 elm_table_padding_set(table, 0, 0);
391 elm_table_homogeneous_set(table, EINA_TRUE);
392 evas_object_size_hint_weight_set(table, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
393 evas_object_size_hint_align_set(table, EVAS_HINT_FILL, EVAS_HINT_FILL);
394
395 _app_open("org.enlightenment.message");
396 _app_open("org.enlightenment.phone");
397
398 apps = elm_list_add(table);
399 evas_object_size_hint_align_set(apps, EVAS_HINT_FILL, EVAS_HINT_FILL);
400 evas_object_show(apps);
401 elm_table_pack(table, apps, APPS_COL, 0, 1, 1);
402 _apps_list_update();
403
404 evas_object_show(table);
405 evas_object_show(win);
406 evas_object_resize(win, 1024, 768);
407}
408#endif
diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in
index e4ed2898b..fc562c44c 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/Elementary.h.in
@@ -183,6 +183,11 @@ EAPI extern Elm_Version *elm_version;
183#include <elc_naviframe.h> 183#include <elc_naviframe.h>
184#include <elc_popup.h> 184#include <elc_popup.h>
185#include <elm_actionslider.h> 185#include <elm_actionslider.h>
186#include <elm_app_common.h>
187#include <elm_app_server.h>
188#include <elm_app_server_view.h>
189#include <elm_app_client.h>
190#include <elm_app_client_view.h>
186#include <elm_app.h> 191#include <elm_app.h>
187#include <elm_bg.h> 192#include <elm_bg.h>
188#include <elm_box.h> 193#include <elm_box.h>
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index e87794b46..fedc1fc44 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -147,6 +147,15 @@ elm_actionslider.h \
147elm_actionslider_eo.h \ 147elm_actionslider_eo.h \
148elm_actionslider_legacy.h \ 148elm_actionslider_legacy.h \
149elm_actionslider_common.h \ 149elm_actionslider_common.h \
150elm_app_common.h \
151elm_app_server_eo.h \
152elm_app_server_view_eo.h \
153elm_app_server_view.h \
154elm_app_server.h \
155elm_app_client_eo.h \
156elm_app_client.h \
157elm_app_client_view_eo.h \
158elm_app_client_view.h \
150elm_app.h \ 159elm_app.h \
151elm_authors.h \ 160elm_authors.h \
152elm_bg.h \ 161elm_bg.h \
@@ -394,6 +403,12 @@ elc_popup.c \
394elc_scrolled_entry.c \ 403elc_scrolled_entry.c \
395elm_access.c \ 404elm_access.c \
396elm_actionslider.c \ 405elm_actionslider.c \
406elm_app_common.c \
407elm_app_server_eet.c \
408elm_app_server.c \
409elm_app_server_view.c \
410elm_app_client.c \
411elm_app_client_view.c \
397elm_bg.c \ 412elm_bg.c \
398elm_box.c \ 413elm_box.c \
399elm_bubble.c \ 414elm_bubble.c \
diff --git a/src/lib/elm_app_client.c b/src/lib/elm_app_client.c
new file mode 100644
index 000000000..dc4f557cb
--- /dev/null
+++ b/src/lib/elm_app_client.c
@@ -0,0 +1,432 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_priv.h"
7
8EAPI Eo_Op ELM_APP_CLIENT_BASE_ID = EO_NOOP;
9
10#define MY_CLASS ELM_APP_CLIENT_CLASS
11
12#define MY_CLASS_NAME "elm_app_client"
13
14EAPI const Eo_Event_Description _ELM_APP_CLIENT_EV_VIEW_CREATED =
15 EO_EVENT_DESCRIPTION("view,created",
16 "Called when a view of this application is created.");
17
18EAPI const Eo_Event_Description _ELM_APP_CLIENT_EV_VIEW_DELETED =
19 EO_EVENT_DESCRIPTION("view,deleted",
20 "Called when a view of this application is deleted.");
21
22EAPI const Eo_Event_Description _ELM_APP_CLIENT_EV_VIEW_LIST_LOADED =
23 EO_EVENT_DESCRIPTION("view_list,loaded",
24 "Called when list of view is loaded.");
25
26EAPI const Eo_Event_Description _ELM_APP_CLIENT_EV_TERMINATED =
27 EO_EVENT_DESCRIPTION("application,terminated",
28 "Called when application is terminated.");
29
30typedef struct
31{
32 Eldbus_Proxy *app_proxy;
33 Eina_Hash *views;
34} Elm_App_Client_Data;
35
36static void
37_sub_path_process(Elm_App_Client *eo, Eldbus_Message_Iter *obj_iter, Elm_App_Client_Data *data, Eina_Bool loading_list)
38{
39 const char *obj_path;
40 Eldbus_Message_Iter *array_iface, *iface;
41
42 eldbus_message_iter_arguments_get(obj_iter, "oa{sa{sv}}", &obj_path, &array_iface);
43 while (eldbus_message_iter_get_and_next(array_iface, '{', &iface))
44 {
45 const char *iface_name;
46 Eldbus_Message_Iter *array_props;
47 Elm_App_Client_View *view;
48
49 eldbus_message_iter_arguments_get(iface, "sa{sv}", &iface_name,
50 &array_props);
51 if (strcmp(iface_name, "org.enlightenment.ApplicationView1"))
52 continue;
53
54 view = eina_hash_find(data->views, obj_path);
55 if (view)
56 continue;
57
58 view = eo_add_custom(ELM_APP_CLIENT_VIEW_CLASS, eo,
59 elm_app_client_view_constructor(obj_path));
60 eina_hash_add(data->views, obj_path, view);
61 if (!loading_list)
62 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_EV_VIEW_CREATED, view, NULL));
63 }
64}
65
66static void
67_objects_get(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
68{
69 Eo *eo = data;
70 Elm_App_Client_Data *cdata = eo_data_scope_get(eo, MY_CLASS);
71 Eldbus_Message_Iter *array_path, *path;
72
73 if (eldbus_message_error_get(msg, NULL, NULL))
74 return;
75
76 if (!eldbus_message_arguments_get(msg, "a{oa{sa{sv}}}", &array_path))
77 return;
78 while (eldbus_message_iter_get_and_next(array_path, '{', &path))
79 _sub_path_process(eo, path, cdata, EINA_TRUE);
80
81 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_EV_VIEW_LIST_LOADED,
82 NULL, NULL));
83}
84
85static void _iface_add(void *data, const Eldbus_Message *msg)
86{
87 Eo *eo = data;
88 Elm_App_Client_Data *cdata = eo_data_scope_get(eo, MY_CLASS);
89 Eldbus_Message_Iter *main_iter;
90
91 main_iter = eldbus_message_iter_get(msg);
92 _sub_path_process(eo, main_iter, cdata, EINA_FALSE);
93}
94
95static void
96_iface_del(void *data, const Eldbus_Message *msg)
97{
98 Eo *eo = data;
99 Elm_App_Client_Data *cdata = eo_data_scope_get(eo, MY_CLASS);
100 const char *path, *iface;
101 Eldbus_Message_Iter *array_iface;
102
103 if (!eldbus_message_arguments_get(msg, "oas", &path, &array_iface))
104 return;
105 while (eldbus_message_iter_get_and_next(array_iface, 's', &iface))
106 {
107 Elm_App_Client_View *view;
108 Elm_App_View_State view_state;
109
110 if (strcmp(iface, "org.enlightenment.ApplicationView1"))
111 continue;
112
113 view = eina_hash_find(cdata->views, path);
114 if (!view)
115 continue;
116
117 eo_do(view, elm_app_client_view_state_get(&view_state));
118 if (view_state != ELM_APP_VIEW_STATE_CLOSED)
119 {
120 elm_app_client_view_internal_state_set(view,
121 ELM_APP_VIEW_STATE_SHALLOW);
122 continue;
123 }
124
125 eina_hash_del(cdata->views, path, NULL);
126 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_EV_VIEW_DELETED,
127 view, NULL));
128 eo_del(view);
129 }
130}
131
132static void
133_pkg_name_owner_changed_cb(void *data, const char *bus EINA_UNUSED, const char *old_id EINA_UNUSED, const char *new_id)
134{
135 Elm_App_Client *eo = data;
136 Elm_App_Client_Data *cdata = eo_data_scope_get(eo, MY_CLASS);
137 Eina_Iterator *iter;
138 Elm_App_Client_View *view;
139 Eina_List *views_list = NULL;
140
141 if (!new_id || (new_id[0] == '\0'))
142 return;
143
144 iter = eina_hash_iterator_data_new(cdata->views);
145 EINA_ITERATOR_FOREACH(iter, view)
146 views_list = eina_list_append(views_list, view);
147 eina_iterator_free(iter);
148
149 /*
150 * remove all views that are closed of the views hash
151 * views not closed, only set they to SHALLOW
152 */
153 EINA_LIST_FREE(views_list, view)
154 {
155 Elm_App_View_State view_state;
156 const char *path;
157
158 eo_do(view, elm_app_client_view_state_get(&view_state),
159 elm_app_client_view_path_get(&path));
160 if (view_state != ELM_APP_VIEW_STATE_CLOSED)
161 {
162 elm_app_client_view_internal_state_set(view,
163 ELM_APP_VIEW_STATE_SHALLOW);
164 continue;
165 }
166
167 eina_hash_del(cdata->views, path, NULL);
168 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_EV_VIEW_DELETED,
169 view, NULL));
170 eo_del(view);
171 }
172}
173
174static void
175_app_client_constructor(Eo *eo, void *_pd, va_list *list)
176{
177 Elm_App_Client_Data *data = _pd;
178 const char *pkg = va_arg(*list, const char *);
179 Eldbus_Connection *conn;
180 Eldbus_Object *obj;
181 char *path;
182
183 EINA_SAFETY_ON_NULL_GOTO(pkg, error);
184
185 eo_do_super(eo, MY_CLASS, eo_constructor());
186
187 data->views = eina_hash_string_small_new(NULL);
188
189 path = _dbus_package_to_path(pkg);
190
191 eldbus_init();
192 conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
193 obj = eldbus_object_get(conn, pkg, path);
194 data->app_proxy = eldbus_proxy_get(obj, "org.enlightenment.Application1");
195 eldbus_object_managed_objects_get(obj, _objects_get, eo);
196 eldbus_object_manager_interfaces_added(obj, _iface_add, eo);
197 eldbus_object_manager_interfaces_removed(obj, _iface_del, eo);
198 eldbus_name_owner_changed_callback_add(conn, pkg, _pkg_name_owner_changed_cb,
199 eo, EINA_FALSE);
200
201 free(path);
202
203 return;
204error:
205 eo_error_set(eo);
206}
207
208static void
209_create_view_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
210{
211 Elm_App_Client_Open_View_Cb cb = eldbus_pending_data_del(pending, "user_cb");
212 void *user_data = eldbus_pending_data_del(pending, "user_data");
213 const char *error_name, *error_message, *view_path;
214 Elm_App_Client *eo = data;
215 Elm_App_Client_View *view;
216 Elm_App_Client_Data *cdata = eo_data_scope_get(eo, MY_CLASS);
217
218 if (eldbus_message_error_get(msg, &error_name, &error_message))
219 {
220 if (!cb)
221 return;
222 if (error_name && !strcmp(error_name, ELDBUS_ERROR_PENDING_CANCELED))
223 cb(user_data, NULL, ELM_APP_CLIENT_VIEW_OPEN_CANCELED, NULL);
224 else if (error_name && !strcmp(error_name, ELDBUS_ERROR_PENDING_TIMEOUT))
225 cb(user_data, NULL, ELM_APP_CLIENT_VIEW_OPEN_TIMEOUT, error_message);
226 else
227 cb(user_data, NULL, error_name, error_message);
228 return;
229 }
230
231 if (!eldbus_message_arguments_get(msg, "o", &view_path))
232 {
233 if (cb)
234 cb(user_data, NULL, "Unknow error", NULL);
235 return;
236 }
237
238 /**
239 * Because a IntefaceAdd signal could arrive first
240 */
241 view = eina_hash_find(cdata->views, view_path);
242 if (!view)
243 {
244 view = eo_add_custom(ELM_APP_CLIENT_VIEW_CLASS, eo,
245 elm_app_client_view_constructor(view_path));
246 eina_hash_add(cdata->views, view_path, view);
247 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_EV_VIEW_CREATED,
248 view, NULL));
249 }
250
251 if (!view)
252 {
253 if (cb)
254 cb(user_data, NULL, ELM_APP_CLEINT_VIEW_OPEN_ERROR, NULL);
255 return;
256 }
257 if (cb)
258 cb(user_data, view, NULL, NULL);
259}
260
261static void
262_view_open(Eo *eo, void *_pd, va_list *list)
263{
264 Elm_App_Client_Data *data = _pd;
265 Eina_Value *args = va_arg(*list, Eina_Value *);
266 Elm_App_Client_Open_View_Cb cb = va_arg(*list, Elm_App_Client_Open_View_Cb);
267 const void *user_data = va_arg(*list, const void *);
268 Elm_App_Client_Pending **view_open_pending = va_arg(*list, Elm_App_Client_Pending**);
269 Eldbus_Message *msg;
270 Eldbus_Pending *pending;
271
272 msg = eldbus_proxy_method_call_new(data->app_proxy, "CreateView");
273
274 if (args)
275 {
276 if (!eldbus_message_from_eina_value("a{sv}", msg, args))
277 {
278 eldbus_message_unref(msg);
279 //TODO test to find out what type eina_value must be
280 ERR("Eina_Value of args don't have a structure of a{sv}");
281 return;
282 }
283 }
284 else
285 {
286 Eldbus_Message_Iter *main_iter = eldbus_message_iter_get(msg);
287 Eldbus_Message_Iter *array;
288
289 eldbus_message_iter_arguments_append(main_iter, "a{sv}", &array);
290 eldbus_message_iter_container_close(main_iter, array);
291 }
292
293 pending = eldbus_proxy_send(data->app_proxy, msg, _create_view_cb, eo, -1);
294 if (user_data)
295 eldbus_pending_data_set(pending, "user_data", user_data);
296 if (cb)
297 eldbus_pending_data_set(pending, "user_cb", cb);
298
299 if (view_open_pending)
300 *view_open_pending = pending;
301}
302
303static void
304_views_get(Eo *eo EINA_UNUSED, void *_pd, va_list *list)
305{
306 Elm_App_Client_Data *data = _pd;
307 Eina_Iterator **view_iter = va_arg(*list, Eina_Iterator **);
308
309 *view_iter = eina_hash_iterator_data_new(data->views);
310}
311
312static void
313_all_close(Eo *eo EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
314{
315 Elm_App_Client_Data *data = _pd;
316 eldbus_proxy_call(data->app_proxy, "CloseAllViews", NULL, NULL, -1, "");
317}
318
319static void
320_terminate(Eo *eo EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
321{
322 Elm_App_Client_Data *data = _pd;
323 eldbus_proxy_call(data->app_proxy, "Terminate", NULL, NULL, -1, "");
324}
325
326static void
327_package_get(Eo *eo EINA_UNUSED, void *_pd, va_list *list)
328{
329 Elm_App_Client_Data *data = _pd;
330 Eldbus_Object *obj;
331 const char **package = va_arg(*list, const char **);
332
333 obj = eldbus_proxy_object_get(data->app_proxy);
334 *package = eldbus_object_bus_name_get(obj);
335}
336
337static void
338_view_open_cancel(Eo *eo EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
339{
340 Elm_App_Client_Pending *pending = va_arg(*list, Elm_App_Client_Pending *);
341 eldbus_pending_cancel(pending);
342}
343
344static void
345_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
346{
347 eo_error_set(obj);
348 ERR("Only custom constructor can be used with '%s' class", MY_CLASS_NAME);
349}
350
351static void
352_destructor(Eo *eo, void *_pd, va_list *list EINA_UNUSED)
353{
354 Elm_App_Client_Data *data = _pd;
355 Eldbus_Object *obj;
356 Eldbus_Connection *conn;
357 Eina_Iterator *iter;
358 Elm_App_Client_View *view;
359
360 iter = eina_hash_iterator_data_new(data->views);
361 EINA_ITERATOR_FOREACH(iter, view)
362 eo_del(view);
363 eina_iterator_free(iter);
364 eina_hash_free(data->views);
365
366 obj = eldbus_proxy_object_get(data->app_proxy);
367 conn = eldbus_object_connection_get(obj);
368 eldbus_name_owner_changed_callback_del(conn, eldbus_object_bus_name_get(obj),
369 _pkg_name_owner_changed_cb, eo);
370 eldbus_proxy_unref(data->app_proxy);
371 eldbus_object_unref(obj);
372 eldbus_connection_unref(conn);
373 eldbus_shutdown();
374
375 eo_do_super(eo, MY_CLASS, eo_destructor());
376}
377
378static void
379_class_constructor(Eo_Class *klass)
380{
381 const Eo_Op_Func_Description func_desc[] = {
382 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
383 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
384 EO_OP_FUNC(ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_CONSTRUCTOR), _app_client_constructor),
385 EO_OP_FUNC(ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_VIEW_OPEN), _view_open),
386 EO_OP_FUNC(ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_VIEWS_GET), _views_get),
387 EO_OP_FUNC(ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_VIEWS_ALL_CLOSE), _all_close),
388 EO_OP_FUNC(ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_TERMINATE), _terminate),
389 EO_OP_FUNC(ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_PACKAGE_GET), _package_get),
390 EO_OP_FUNC(ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_VIEW_OPEN_CANCEL), _view_open_cancel),
391 EO_OP_FUNC_SENTINEL
392 };
393 eo_class_funcs_set(klass, func_desc);
394}
395
396static const Eo_Op_Description op_desc[] = {
397 EO_OP_DESCRIPTION(ELM_APP_CLIENT_SUB_ID_CONSTRUCTOR,
398 "Constructor of elm_app_client."),
399 EO_OP_DESCRIPTION(ELM_APP_CLIENT_SUB_ID_VIEW_OPEN, "Open a view."),
400 EO_OP_DESCRIPTION(ELM_APP_CLIENT_SUB_ID_VIEWS_GET,
401 "Return a iterator with all views of application."),
402 EO_OP_DESCRIPTION(ELM_APP_CLIENT_SUB_ID_VIEWS_ALL_CLOSE,
403 "Close all views of application."),
404 EO_OP_DESCRIPTION(ELM_APP_CLIENT_SUB_ID_TERMINATE,
405 "Terminate applicaiton"),
406 EO_OP_DESCRIPTION(ELM_APP_CLIENT_SUB_ID_PACKAGE_GET,
407 "Return the package name of application"),
408 EO_OP_DESCRIPTION(ELM_APP_CLIENT_SUB_ID_VIEW_OPEN_CANCEL,
409 "Cancel view opening."),
410 EO_OP_DESCRIPTION_SENTINEL
411};
412
413static const Eo_Event_Description *event_desc[] = {
414 ELM_APP_CLIENT_EV_VIEW_CREATED,
415 ELM_APP_CLIENT_EV_VIEW_DELETED,
416 ELM_APP_CLIENT_EV_VIEW_LIST_LOADED,
417 ELM_APP_CLIENT_EV_TERMINATED,
418 NULL
419};
420
421static const Eo_Class_Description class_desc = {
422 EO_VERSION,
423 MY_CLASS_NAME,
424 EO_CLASS_TYPE_REGULAR,
425 EO_CLASS_DESCRIPTION_OPS(&ELM_APP_CLIENT_BASE_ID, op_desc, ELM_APP_CLIENT_SUB_ID_LAST),
426 event_desc,
427 sizeof(Elm_App_Client_Data),
428 _class_constructor,
429 NULL
430};
431
432EO_DEFINE_CLASS(elm_app_client_class_get, &class_desc, EO_BASE_CLASS, NULL);
diff --git a/src/lib/elm_app_client.h b/src/lib/elm_app_client.h
new file mode 100644
index 000000000..866933229
--- /dev/null
+++ b/src/lib/elm_app_client.h
@@ -0,0 +1,3 @@
1#ifdef EFL_EO_API_SUPPORT
2#include "elm_app_client_eo.h"
3#endif
diff --git a/src/lib/elm_app_client_eo.h b/src/lib/elm_app_client_eo.h
new file mode 100644
index 000000000..dae6dd8e0
--- /dev/null
+++ b/src/lib/elm_app_client_eo.h
@@ -0,0 +1,111 @@
1#define ELM_APP_CLIENT_CLASS elm_app_client_class_get()
2
3const Eo_Class *elm_app_client_class_get(void) EINA_CONST;
4
5extern EAPI Eo_Op ELM_APP_CLIENT_BASE_ID;
6
7enum
8{
9 ELM_APP_CLIENT_SUB_ID_CONSTRUCTOR,
10 ELM_APP_CLIENT_SUB_ID_VIEW_OPEN,
11 ELM_APP_CLIENT_SUB_ID_VIEWS_GET,
12 ELM_APP_CLIENT_SUB_ID_VIEWS_ALL_CLOSE,
13 ELM_APP_CLIENT_SUB_ID_TERMINATE,
14 ELM_APP_CLIENT_SUB_ID_PACKAGE_GET,
15 ELM_APP_CLIENT_SUB_ID_VIEW_OPEN_CANCEL,
16 ELM_APP_CLIENT_SUB_ID_LAST
17};
18
19typedef Eo Elm_App_Client;
20typedef Eo Elm_App_Client_View;
21
22typedef Eldbus_Pending Elm_App_Client_Pending;
23
24typedef void (*Elm_App_Client_Open_View_Cb)(void *data, Elm_App_Client_View *view, const char *error, const char *error_message);
25
26#define ELM_APP_CLIENT_ID(sub_id) (ELM_APP_CLIENT_BASE_ID + sub_id)
27
28/**
29 * @def elm_app_client_constructor
30 * @since 1.8
31 *
32 * Class constructor of elm_app_client.
33 *
34 * @param[in] package of application
35 */
36#define elm_app_client_constructor(package) ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(const char *, package)
37
38
39/**
40 * @def elm_app_client_view_open
41 * @since 1.8
42 *
43 * Open a application view.
44 *
45 * @param[in] arg an array of<string,data> containing the arguments of view
46 * @param[in] view_open_cb callback to be called when view open
47 * @param[in] data calback user data
48 * @param[out] pending handler to cancel the view opening if it takes to long
49 */
50#define elm_app_client_view_open(args, view_open_cb, data, pending) ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_VIEW_OPEN), EO_TYPECHECK(Eina_Value *, args), EO_TYPECHECK(Elm_App_Client_Open_View_Cb, view_open_cb), EO_TYPECHECK(const void *, data), EO_TYPECHECK(Elm_App_Client_Pending **, pending)
51
52/**
53 * @def elm_app_client_views_get
54 * @since 1.8
55 *
56 * Return a iterator with all views of application.
57 *
58 * @param[out] ret the iterator with all views, must be freed after use
59 */
60#define elm_app_client_views_get(ret) ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_VIEWS_GET), EO_TYPECHECK(Eina_Iterator **, ret)
61
62/**
63 * @def elm_app_client_view_all_close
64 * @since 1.8
65 *
66 * Close all views of application.
67 */
68#define elm_app_client_view_all_close() ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_VIEWS_ALL_CLOSE)
69
70/**
71 * @def elm_app_client_terminate
72 * @since 1.8
73 *
74 * Terminate application.
75 */
76#define elm_app_client_terminate() ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_TERMINATE)
77
78/**
79 * @def elm_app_client_package_get
80 * @since 1.8
81 *
82 * Return the application package.
83 *
84 * @param[out] ret application package
85 */
86#define elm_app_client_package_get(ret) ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_PACKAGE_GET), EO_TYPECHECK(const char **, ret)
87
88/**
89 * @def elm_app_client_view_open_cancel
90 * @since 1.8
91 *
92 * Cancel a pending elm_app_client_view_open().
93 *
94 * @param[in] pending the view open handler.
95 */
96#define elm_app_client_view_open_cancel(pending) ELM_APP_CLIENT_ID(ELM_APP_CLIENT_SUB_ID_VIEW_OPEN_CANCEL), EO_TYPECHECK(Elm_App_Client_Pending **, pending)
97
98/**
99 * Events
100 */
101extern const Eo_Event_Description _ELM_APP_CLIENT_EV_VIEW_CREATED;
102#define ELM_APP_CLIENT_EV_VIEW_CREATED (&(_ELM_APP_CLIENT_EV_VIEW_CREATED))
103
104extern const Eo_Event_Description _ELM_APP_CLIENT_EV_VIEW_DELETED;
105#define ELM_APP_CLIENT_EV_VIEW_DELETED (&(_ELM_APP_CLIENT_EV_VIEW_DELETED))
106
107extern const Eo_Event_Description _ELM_APP_CLIENT_EV_VIEW_LIST_LOADED;
108#define ELM_APP_CLIENT_EV_VIEW_LIST_LOADED (&(_ELM_APP_CLIENT_EV_VIEW_LIST_LOADED))
109
110extern const Eo_Event_Description _ELM_APP_CLIENT_EV_TERMINATED;
111#define ELM_APP_CLIENT_EV_TERMINATED (&(_ELM_APP_CLIENT_EV_TERMINATED))
diff --git a/src/lib/elm_app_client_view.c b/src/lib/elm_app_client_view.c
new file mode 100644
index 000000000..2b8880cc9
--- /dev/null
+++ b/src/lib/elm_app_client_view.c
@@ -0,0 +1,425 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_priv.h"
7
8EAPI Eo_Op ELM_APP_CLIENT_VIEW_BASE_ID = EO_NOOP;
9
10#define MY_CLASS ELM_APP_CLIENT_VIEW_CLASS
11
12#define MY_CLASS_NAME "elm_app_client_view"
13
14EAPI const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_STATE_CHANGED =
15 EO_EVENT_DESCRIPTION("state,changed", "State of view changed.");
16
17EAPI const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_TITLE_CHANGED =
18 EO_EVENT_DESCRIPTION("title,changed", "Title of view changed.");
19
20EAPI const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_ICON_CHANGED =
21 EO_EVENT_DESCRIPTION("icon,changed", "Icon of view changed.");
22
23EAPI const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_ICON_PIXELS_CHANGED =
24 EO_EVENT_DESCRIPTION("icon,pixels,changed", "Icons pixels of view changed.");
25
26EAPI const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_PROGRESS_CHANGED =
27 EO_EVENT_DESCRIPTION("progress,changed", "Progress of view changed.");
28
29EAPI const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_NEW_EVENTS_CHANGED =
30 EO_EVENT_DESCRIPTION("new_events,changed", "New events of view changed.");
31
32EAPI const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_WINDOW_CHANGED =
33 EO_EVENT_DESCRIPTION("window,changed", "Window of view changed.");
34
35EAPI const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_PROPERTY_CHANGED =
36 EO_EVENT_DESCRIPTION("property,changed", "One of view properties changed.");
37
38typedef struct
39{
40 Eldbus_Proxy *view_proxy;
41 Elm_App_View_State state;
42} Elm_App_Client_View_Data;
43
44static const char *_string_prop_get(const Eina_Value *v)
45{
46 const char *str;
47
48 if (!v)
49 return "";
50
51 eina_value_get(v, &str);
52 return str;
53}
54
55static int _int_prop_get(const Eina_Value *v)
56{
57 int num;
58
59 if (!v)
60 return 0;
61
62 eina_value_get(v, &num);
63 return num;
64}
65
66static short _short_prop_get(const Eina_Value *v)
67{
68 short num;
69
70 if (!v)
71 return 0;
72
73 eina_value_get(v, &num);
74 return num;
75}
76
77static void
78_prop_changed(void *user_data, Eldbus_Proxy *proxy EINA_UNUSED, void *event_info)
79{
80 Eldbus_Proxy_Event_Property_Changed *prop_event = event_info;
81 Elm_App_Client_View *eo = user_data;
82 const Eina_Value *v = prop_event->value;
83 Elm_App_Client_View_Data *cdata = eo_data_scope_get(eo, MY_CLASS);
84
85 if (!strcmp(prop_event->name, "Title"))
86 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_VIEW_EV_TITLE_CHANGED,
87 _string_prop_get(v), NULL));
88 else if (!strcmp(prop_event->name, "IconName"))
89 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_VIEW_EV_ICON_CHANGED,
90 _string_prop_get(v), NULL));
91 else if (!strcmp(prop_event->name, "IconPixels"))
92 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_VIEW_EV_ICON_PIXELS_CHANGED,
93 NULL, NULL));
94 else if (!strcmp(prop_event->name, "NewEvents"))
95 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_VIEW_EV_NEW_EVENTS_CHANGED,
96 (void *)(long)_int_prop_get(v), NULL));
97 else if (!strcmp(prop_event->name, "Progress"))
98 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_VIEW_EV_PROGRESS_CHANGED,
99 (void *)(long)_short_prop_get(v), NULL));
100 else if (!strcmp(prop_event->name, "State"))
101 {
102 cdata->state = _string_state_to_id(_string_prop_get(v));
103 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_VIEW_EV_STATE_CHANGED,
104 (void *)(long)cdata->state, NULL));
105 }
106 else if (!strcmp(prop_event->name, "WindowId"))
107 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_VIEW_EV_WINDOW_CHANGED,
108 (void *)(long)_int_prop_get(v), NULL));
109 else
110 return;
111
112 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_VIEW_EV_PROPERTY_CHANGED,
113 prop_event->name, NULL));
114}
115
116static void
117_props_loaded(void *user_data, Eldbus_Proxy *proxy EINA_UNUSED, void *event_info EINA_UNUSED)
118{
119 const Eina_Hash *props = eldbus_proxy_property_local_get_all(proxy);
120 Eina_Iterator *iter;
121 Eina_Hash_Tuple *t;
122
123 iter = eina_hash_iterator_tuple_new(props);
124 EINA_ITERATOR_FOREACH(iter, t)
125 {
126 Eldbus_Proxy_Event_Property_Changed event;
127
128 event.name = t->key;
129 event.proxy = proxy;
130 event.value = t->data;
131
132 _prop_changed(user_data, proxy, &event);
133 }
134 eina_iterator_free(iter);
135}
136
137void
138elm_app_client_view_internal_state_set(Eo *eo, Elm_App_View_State state)
139{
140 Elm_App_Client_View_Data *cdata;
141 Eina_Bool changed = EINA_FALSE;
142
143 EINA_SAFETY_ON_NULL_RETURN(eo);
144 EINA_SAFETY_ON_FALSE_RETURN(eo_isa(eo, ELM_APP_CLIENT_VIEW_CLASS));
145
146 cdata = eo_data_scope_get(eo, MY_CLASS);
147 changed = cdata->state != state;
148 cdata->state = state;
149 if (!changed)
150 return;
151 eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_VIEW_EV_STATE_CHANGED,
152 (void *)(long)cdata->state, NULL));
153}
154
155static void
156_app_client_view_constructor(Eo *eo, void *_pd, va_list *list)
157{
158 Elm_App_Client_View_Data *data = _pd;
159 Elm_App_Client *parent;
160 const char *package, *path = va_arg(*list, const char *);
161 Eldbus_Connection *conn;
162 Eldbus_Object *obj;
163
164 EINA_SAFETY_ON_NULL_GOTO(path, error);
165 eo_do_super(eo, MY_CLASS, eo_constructor());
166
167 parent = eo_parent_get(eo);
168 EINA_SAFETY_ON_TRUE_GOTO((!parent) ||
169 (!eo_isa(parent, ELM_APP_CLIENT_CLASS)), error);
170
171 eo_do(parent, elm_app_client_package_get(&package));
172
173 eldbus_init();
174 conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
175 obj = eldbus_object_get(conn, package, path);
176 data->view_proxy = eldbus_proxy_get(obj,
177 "org.enlightenment.ApplicationView1");
178 eldbus_proxy_properties_monitor(data->view_proxy, EINA_TRUE);
179 eldbus_proxy_event_callback_add(data->view_proxy,
180 ELDBUS_PROXY_EVENT_PROPERTY_CHANGED,
181 _prop_changed, eo);
182 eldbus_proxy_event_callback_add(data->view_proxy,
183 ELDBUS_PROXY_EVENT_PROPERTY_LOADED,
184 _props_loaded, eo);
185
186 return;
187
188error:
189 eo_error_set(eo);
190}
191
192static void
193_dbus_state_set_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
194{
195 Elm_App_Client_View *eo = data;
196 Elm_App_Client_View_Cb cb = eldbus_pending_data_del(pending, "cb");
197 void *user_data = eldbus_pending_data_del(pending, "user_data");
198 const char *error = NULL, *error_message = NULL;
199
200 eldbus_message_error_get(msg, &error, &error_message);
201
202 cb(user_data, eo, error, error_message);
203}
204
205static void
206_dbus_action_do(Eo *eo, Eldbus_Proxy *proxy, const char *action, Elm_App_Client_View_Cb cb, const void *data)
207{
208 Eldbus_Pending *pending;
209
210 if (!cb)
211 {
212 eldbus_proxy_call(proxy, action, NULL, NULL, -1, "");
213 return;
214 }
215
216 pending = eldbus_proxy_call(proxy, action, _dbus_state_set_cb, eo, -1, "");
217 eldbus_pending_data_set(pending, "cb", cb);
218 eldbus_pending_data_set(pending, "user_data", data);
219}
220
221static void
222_resume(Eo *eo, void *_pd, va_list *list)
223{
224 Elm_App_Client_View_Data *data = _pd;
225 Elm_App_Client_View_Cb cb = va_arg(*list, Elm_App_Client_View_Cb);
226 const void *user_data = va_arg(*list, const void *);
227
228 _dbus_action_do(eo, data->view_proxy, "Resume", cb, user_data);
229}
230
231static void
232_pause(Eo *eo, void *_pd, va_list *list)
233{
234 Elm_App_Client_View_Data *data = _pd;
235 Elm_App_Client_View_Cb cb = va_arg(*list, Elm_App_Client_View_Cb);
236 const void *user_data = va_arg(*list, const void *);
237
238 _dbus_action_do(eo, data->view_proxy, "Pause", cb, user_data);
239}
240
241static void
242_close(Eo *eo, void *_pd, va_list *list)
243{
244 Elm_App_Client_View_Data *data = _pd;
245 Elm_App_Client_View_Cb cb = va_arg(*list, Elm_App_Client_View_Cb);
246 const void *user_data = va_arg(*list, const void *);
247
248 _dbus_action_do(eo, data->view_proxy, "Close", cb, user_data);
249}
250
251static void _eo_string_prop_get(void *_pd, va_list *list, const char *prop)
252{
253 Elm_App_Client_View_Data *data = _pd;
254 const char **title = va_arg(*list, const char **);
255 Eina_Value *v;
256
257 v = eldbus_proxy_property_local_get(data->view_proxy, prop);
258 *title = _string_prop_get(v);
259}
260
261static void _title_get(Eo *eo EINA_UNUSED, void *_pd, va_list *list)
262{
263 _eo_string_prop_get(_pd, list, "Title");
264}
265
266static void _icon_get(Eo *eo EINA_UNUSED, void *_pd, va_list *list)
267{
268 _eo_string_prop_get(_pd, list, "IconName");
269}
270
271static void _icon_pixels_get(Eo *eo EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
272{
273 //Elm_App_Client_View_Data *data = _pd;
274 //TODO
275}
276
277static void _progress_get(Eo *eo EINA_UNUSED, void *_pd, va_list *list)
278{
279 Elm_App_Client_View_Data *data = _pd;
280 short *progress = va_arg(*list, short *);
281 Eina_Value *v;
282
283 v = eldbus_proxy_property_local_get(data->view_proxy, "Progress");
284 *progress = _short_prop_get(v);
285}
286
287static void _new_events_get(Eo *eo EINA_UNUSED, void *_pd, va_list *list)
288{
289 Elm_App_Client_View_Data *data = _pd;
290 int *new_events = va_arg(*list, int *);
291 Eina_Value *v;
292
293 v = eldbus_proxy_property_local_get(data->view_proxy, "NewEvents");
294 *new_events = _int_prop_get(v);
295}
296
297static void _state_get(Eo *eo EINA_UNUSED, void *_pd, va_list *list)
298{
299 Elm_App_Client_View_Data *data = _pd;
300 Elm_App_View_State *state = va_arg(*list, Elm_App_View_State *);
301
302 *state = data->state;
303}
304
305static void _window_get(Eo *eo EINA_UNUSED, void *_pd, va_list *list)
306{
307 Elm_App_Client_View_Data *data = _pd;
308 int *window = va_arg(*list, int *);
309 Eina_Value *v;
310
311 v = eldbus_proxy_property_local_get(data->view_proxy, "WindowId");
312 *window = _int_prop_get(v);
313}
314
315static void _path_get(Eo *eo EINA_UNUSED, void *_pd, va_list *list)
316{
317 Elm_App_Client_View_Data *data = _pd;
318 const char **ret = va_arg(*list, const char **);
319 Eldbus_Object *obj;
320
321 obj = eldbus_proxy_object_get(data->view_proxy);
322 *ret = eldbus_object_path_get(obj);
323}
324
325static void _package_get(Eo *eo EINA_UNUSED, void *_pd, va_list *list)
326{
327 Elm_App_Client_View_Data *data = _pd;
328 const char **ret = va_arg(*list, const char **);
329 Eldbus_Object *obj;
330
331 obj = eldbus_proxy_object_get(data->view_proxy);
332 *ret = eldbus_object_bus_name_get(obj);
333}
334
335static void
336_destructor(Eo *eo, void *_pd, va_list *list EINA_UNUSED)
337{
338 Elm_App_Client_View_Data *data = _pd;
339 Eldbus_Object *obj;
340 Eldbus_Connection *conn;
341
342 eldbus_proxy_properties_monitor(data->view_proxy, EINA_FALSE);
343 obj = eldbus_proxy_object_get(data->view_proxy);
344 conn = eldbus_object_connection_get(obj);
345
346 eldbus_proxy_unref(data->view_proxy);
347 eldbus_object_unref(obj);
348 eldbus_connection_unref(conn);
349 eldbus_shutdown();
350
351 eo_do_super(eo, MY_CLASS, eo_destructor());
352}
353
354static void
355_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
356{
357 eo_error_set(obj);
358 ERR("Only custom constructor can be used with '%s' class", MY_CLASS_NAME);
359}
360
361static void
362_class_constructor(Eo_Class *klass)
363{
364 const Eo_Op_Func_Description func_desc[] = {
365 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
366 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
367 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_CONSTRUCTOR), _app_client_view_constructor),
368 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_CLOSE), _close),
369 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_PAUSE), _pause),
370 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_RESUME), _resume),
371 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_TITLE_GET), _title_get),
372 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_ICON_GET), _icon_get),
373 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_ICON_PIXELS_GET), _icon_pixels_get),
374 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_PROGRESS_GET), _progress_get),
375 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_NEW_EVENTS_GET), _new_events_get),
376 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_STATE_GET), _state_get),
377 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_WINDOW_GET), _window_get),
378 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_PATH_GET), _path_get),
379 EO_OP_FUNC(ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_PACKAGE_GET), _package_get),
380 EO_OP_FUNC_SENTINEL
381 };
382 eo_class_funcs_set(klass, func_desc);
383}
384
385static const Eo_Op_Description op_desc[] = {
386 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_CONSTRUCTOR, "Constructor of elm_app_client_view."),
387 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_CLOSE, "Close view."),
388 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_PAUSE, "Pause view."),
389 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_RESUME, "Resume view."),
390 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_TITLE_GET, "Get view title."),
391 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_ICON_GET, "Get view icon."),
392 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_ICON_PIXELS_GET, "Get view icon pixels."),
393 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_PROGRESS_GET, "Get view progress."),
394 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_NEW_EVENTS_GET, "Get view new events."),
395 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_STATE_GET, "Get view state."),
396 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_WINDOW_GET, "Get view window id."),
397 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_PATH_GET, "Get view dbus path."),
398 EO_OP_DESCRIPTION(ELM_APP_CLIENT_VIEW_SUB_ID_PACKAGE_GET, "Get application package."),
399 EO_OP_DESCRIPTION_SENTINEL
400};
401
402static const Eo_Event_Description *event_desc[] = {
403 ELM_APP_CLIENT_VIEW_EV_STATE_CHANGED,
404 ELM_APP_CLIENT_VIEW_EV_TITLE_CHANGED,
405 ELM_APP_CLIENT_VIEW_EV_ICON_CHANGED,
406 ELM_APP_CLIENT_VIEW_EV_ICON_PIXELS_CHANGED,
407 ELM_APP_CLIENT_VIEW_EV_NEW_EVENTS_CHANGED,
408 ELM_APP_CLIENT_VIEW_EV_PROGRESS_CHANGED,
409 ELM_APP_CLIENT_VIEW_EV_WINDOW_CHANGED,
410 ELM_APP_CLIENT_VIEW_EV_PROPERTY_CHANGED,
411 NULL
412};
413
414static const Eo_Class_Description class_desc = {
415 EO_VERSION,
416 MY_CLASS_NAME,
417 EO_CLASS_TYPE_REGULAR,
418 EO_CLASS_DESCRIPTION_OPS(&ELM_APP_CLIENT_VIEW_BASE_ID, op_desc, ELM_APP_CLIENT_VIEW_SUB_ID_LAST),
419 event_desc,
420 sizeof(Elm_App_Client_View_Data),
421 _class_constructor,
422 NULL
423};
424
425EO_DEFINE_CLASS(elm_app_client_view_class_get, &class_desc, EO_BASE_CLASS, NULL);
diff --git a/src/lib/elm_app_client_view.h b/src/lib/elm_app_client_view.h
new file mode 100644
index 000000000..e124359c5
--- /dev/null
+++ b/src/lib/elm_app_client_view.h
@@ -0,0 +1,3 @@
1#ifdef EFL_EO_API_SUPPORT
2#include "elm_app_client_view_eo.h"
3#endif
diff --git a/src/lib/elm_app_client_view_eo.h b/src/lib/elm_app_client_view_eo.h
new file mode 100644
index 000000000..add28996f
--- /dev/null
+++ b/src/lib/elm_app_client_view_eo.h
@@ -0,0 +1,194 @@
1#define ELM_APP_CLIENT_VIEW_CLASS elm_app_client_view_class_get()
2
3const Eo_Class *elm_app_client_view_class_get(void) EINA_CONST;
4
5extern EAPI Eo_Op ELM_APP_CLIENT_VIEW_BASE_ID;
6
7enum
8{
9 ELM_APP_CLIENT_VIEW_SUB_ID_CONSTRUCTOR,
10 ELM_APP_CLIENT_VIEW_SUB_ID_CLOSE,
11 ELM_APP_CLIENT_VIEW_SUB_ID_PAUSE,
12 ELM_APP_CLIENT_VIEW_SUB_ID_RESUME,
13 ELM_APP_CLIENT_VIEW_SUB_ID_TITLE_GET,
14 ELM_APP_CLIENT_VIEW_SUB_ID_ICON_GET,
15 ELM_APP_CLIENT_VIEW_SUB_ID_ICON_PIXELS_GET,
16 ELM_APP_CLIENT_VIEW_SUB_ID_PROGRESS_GET,
17 ELM_APP_CLIENT_VIEW_SUB_ID_NEW_EVENTS_GET,
18 ELM_APP_CLIENT_VIEW_SUB_ID_STATE_GET,
19 ELM_APP_CLIENT_VIEW_SUB_ID_WINDOW_GET,
20 ELM_APP_CLIENT_VIEW_SUB_ID_PATH_GET,
21 ELM_APP_CLIENT_VIEW_SUB_ID_PACKAGE_GET,
22 ELM_APP_CLIENT_VIEW_SUB_ID_LAST
23};
24
25typedef void *(*Elm_App_Client_View_Cb)(void *data, Elm_App_Client_View *view, const char *error, const char *error_message);
26
27#define ELM_APP_CLIENT_VIEW_ID(sub_id) (ELM_APP_CLIENT_VIEW_BASE_ID + sub_id)
28
29/**
30 * @def elm_app_client_view_constructor
31 * @since 1.8
32 *
33 * Class constructor of elm_app_client_view
34 *
35 * @param[out] path DBus path of view
36 *
37 * @note You must supply elm_app_client as parent.
38 */
39#define elm_app_client_view_constructor(path) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(const char *, path)
40
41/**
42 * @def elm_app_client_view_close
43 * @since 1.8
44 *
45 * Close view
46 *
47 * @param[in] cb callback to be called when view was closed
48 * @param[in] data callback user data
49 */
50#define elm_app_client_view_close(cb, data) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_CLOSE), EO_TYPECHECK(Elm_App_Client_View_Cb, cb), EO_TYPECHECK(const void *, data)
51
52/**
53 * @def elm_app_client_view_pause
54 * @since 1.8
55 *
56 * Pause view
57 *
58 * @param[in] cb callback to be called when view was paused
59 * @param[in] data callback user data
60 */
61#define elm_app_client_view_pause(cb, data) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_PAUSE), EO_TYPECHECK(Elm_App_Client_View_Cb, cb), EO_TYPECHECK(const void *, data)
62
63/**
64 * @def elm_app_client_view_resume
65 * @since 1.8
66 *
67 * Resume view
68 *
69 * @param[in] cb callback to be called when view was resumed
70 * @param[in] data callback user data
71 */
72#define elm_app_client_view_resume(cb, data) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_RESUME), EO_TYPECHECK(Elm_App_Client_View_Cb, cb), EO_TYPECHECK(const void *, data)
73
74/**
75 * @def elm_app_client_view_title_get
76 * @since 1.8
77 *
78 * Get title of view
79 *
80 * @param[out] ret title of view
81 */
82#define elm_app_client_view_title_get(ret) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_TITLE_GET), EO_TYPECHECK(const char **, ret)
83
84/**
85 * @def elm_app_client_view_icon_get
86 * @since 1.8
87 *
88 * Get icon path of view
89 *
90 * @param[out] ret icon path of view
91 */
92#define elm_app_client_view_icon_get(ret) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_ICON_GET), EO_TYPECHECK(const char **, ret)
93
94/**
95 * @def elm_app_client_view_icon_pixels_get
96 * @since 1.8
97 *
98 * Get icon pixels of view, view could have a icon in raw format
99 * not saved in disk.
100 *
101 * @param[out] w icon width
102 * @param[out] h icon height
103 * @param[out] has_alpha if icon have alpha channel
104 * @param[out] pixels unsigned char array, with all bytes of icon
105 */
106#define elm_app_client_view_icon_pixels_get(w, h, has_alpha, pixels) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_ICON_PIXELS_GET), EO_TYPECHECK(unsigned int *, h), EO_TYPECHECK(Eina_Bool *, has_alpha), EO_TYPECHECK(const unsigned char **, pixels)
107
108/**
109 * @def elm_app_client_view_progress_get
110 * @since 1.8
111 *
112 * Get progress of view, should be -1 if there nothing in progress or something
113 * between 0-100
114 *
115 * @param[out] progress progress of view
116 */
117#define elm_app_client_view_progress_get(progress) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_PROGRESS_GET), EO_TYPECHECK(unsigned short *, progress)
118
119/**
120 * @def elm_app_client_view_new_events_get
121 * @since 1.8
122 *
123 * Get new events of view
124 *
125 * @param[out] events number of events of view
126 */
127#define elm_app_client_view_new_events_get(events) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_NEW_EVENTS_GET), EO_TYPECHECK(int *, events)
128
129/**
130 * @def elm_app_client_view_state_get
131 * @since 1.8
132 *
133 * Get state of view
134 *
135 * @param[out] state state of view
136 */
137#define elm_app_client_view_state_get(state) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_STATE_GET), EO_TYPECHECK(Elm_App_View_State *, state)
138
139/**
140 * @def elm_app_client_view_window_get
141 * @since 1.8
142 *
143 * Get window of view
144 *
145 * @param[out] window window of view
146 */
147#define elm_app_client_view_window_get(window) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_WINDOW_GET), EO_TYPECHECK(int *, window)
148
149/**
150 * @def elm_app_client_view_path_get
151 * @since 1.8
152 *
153 * Get DBus path of view
154 *
155 * @param[out] ret DBus path of view
156 */
157#define elm_app_client_view_path_get(ret) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_PATH_GET), EO_TYPECHECK(const char **, ret)
158
159/**
160 * @def elm_app_client_view_package_get
161 * @since 1.8
162 *
163 * Get application package
164 *
165 * @param[out] ret Package of application
166 */
167#define elm_app_client_view_package_get(ret) ELM_APP_CLIENT_VIEW_ID(ELM_APP_CLIENT_VIEW_SUB_ID_PACKAGE_GET), EO_TYPECHECK(const char **, ret)
168
169/**
170 * Events
171 */
172extern const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_STATE_CHANGED;
173#define ELM_APP_CLIENT_VIEW_EV_STATE_CHANGED (&(_ELM_APP_CLIENT_VIEW_EV_STATE_CHANGED))
174
175extern const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_TITLE_CHANGED;
176#define ELM_APP_CLIENT_VIEW_EV_TITLE_CHANGED (&(_ELM_APP_CLIENT_VIEW_EV_TITLE_CHANGED))
177
178extern const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_ICON_CHANGED;
179#define ELM_APP_CLIENT_VIEW_EV_ICON_CHANGED (&(_ELM_APP_CLIENT_VIEW_EV_ICON_CHANGED))
180
181extern const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_ICON_PIXELS_CHANGED;
182#define ELM_APP_CLIENT_VIEW_EV_ICON_PIXELS_CHANGED (&(_ELM_APP_CLIENT_VIEW_EV_ICON_PIXELS_CHANGED))
183
184extern const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_NEW_EVENTS_CHANGED;
185#define ELM_APP_CLIENT_VIEW_EV_NEW_EVENTS_CHANGED (&(_ELM_APP_CLIENT_VIEW_EV_NEW_EVENTS_CHANGED))
186
187extern const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_PROGRESS_CHANGED;
188#define ELM_APP_CLIENT_VIEW_EV_PROGRESS_CHANGED (&(_ELM_APP_CLIENT_VIEW_EV_PROGRESS_CHANGED))
189
190extern const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_WINDOW_CHANGED;
191#define ELM_APP_CLIENT_VIEW_EV_WINDOW_CHANGED (&(_ELM_APP_CLIENT_VIEW_EV_WINDOW_CHANGED))
192
193extern const Eo_Event_Description _ELM_APP_CLIENT_VIEW_EV_PROPERTY_CHANGED;
194#define ELM_APP_CLIENT_VIEW_EV_PROPERTY_CHANGED (&(_ELM_APP_CLIENT_VIEW_EV_PROPERTY_CHANGED))
diff --git a/src/lib/elm_app_common.c b/src/lib/elm_app_common.c
new file mode 100644
index 000000000..31537f64f
--- /dev/null
+++ b/src/lib/elm_app_common.c
@@ -0,0 +1,56 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_priv.h"
7
8char *
9_dbus_package_to_path(const char *pkg)
10{
11 Eina_Strbuf *buffer;
12 char *ret;
13
14 buffer = eina_strbuf_new();
15 eina_strbuf_append_char(buffer, '/');
16 for (; *pkg != '\0'; pkg++)
17 {
18 if (*pkg == '.')
19 eina_strbuf_append_char(buffer, '/');
20 else if(isalnum(*pkg))
21 eina_strbuf_append_char(buffer, *pkg);
22 else
23 eina_strbuf_append_printf(buffer, "_%02x", *pkg);
24 }
25
26 ret = eina_strbuf_string_steal(buffer);
27 eina_strbuf_free(buffer);
28
29 return ret;
30}
31
32static const char *_string_states[] = {
33 "unknown",
34 "live",
35 "paused",
36 "closed",
37 "shallow",
38 NULL
39};
40
41Elm_App_View_State _string_state_to_id(const char *state)
42{
43 int i;
44
45 for (i = 0; _string_states[i]; i++)
46 {
47 if (!strcmp(state, _string_states[i]))
48 return i;
49 }
50 return 0;
51}
52
53const char *_state_id_to_string(Elm_App_View_State state)
54{
55 return _string_states[state];
56}
diff --git a/src/lib/elm_app_common.h b/src/lib/elm_app_common.h
new file mode 100644
index 000000000..29b7bb94d
--- /dev/null
+++ b/src/lib/elm_app_common.h
@@ -0,0 +1,17 @@
1typedef enum
2{
3 ELM_APP_VIEW_STATE_UNKNOWN = 0,
4 ELM_APP_VIEW_STATE_LIVE,
5 ELM_APP_VIEW_STATE_PAUSED,
6 ELM_APP_VIEW_STATE_CLOSED,
7 ELM_APP_VIEW_STATE_SHALLOW
8} Elm_App_View_State;
9
10char *_dbus_package_to_path(const char *package);
11
12Elm_App_View_State _string_state_to_id(const char *state);
13
14const char *_state_id_to_string(Elm_App_View_State state);
15
16void elm_app_client_view_internal_state_set(Eo *eo, Elm_App_View_State state);
17
diff --git a/src/lib/elm_app_server.c b/src/lib/elm_app_server.c
new file mode 100644
index 000000000..1fff5b7ed
--- /dev/null
+++ b/src/lib/elm_app_server.c
@@ -0,0 +1,571 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_priv.h"
7#include "elm_app_server_eet.h"
8
9EAPI Eo_Op ELM_APP_SERVER_BASE_ID = EO_NOOP;
10
11#define MY_CLASS ELM_APP_SERVER_CLASS
12
13#define MY_CLASS_NAME "elm_app_server"
14
15EAPI const Eo_Event_Description _ELM_APP_SERVER_EV_TERMINATE =
16 EO_EVENT_DESCRIPTION("terminate",
17 "Called when application must be terminated.");
18
19typedef struct
20{
21 Eldbus_Connection *conn;
22 Eldbus_Service_Interface *iface;
23 Elm_App_Server_Create_View_Cb create_view_cb;
24 Eina_Hash *views;
25
26 int PID;
27 Eina_Stringshare *title;
28 Eina_Stringshare *icon_name;
29 Eina_Stringshare *pkg;
30 struct {
31 unsigned int w, h;
32 Eina_Bool has_alpha;
33 unsigned char *raw;
34 } image_raw;
35} Elm_App_Server_Data;
36
37static Eina_Bool
38_view_del_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
39{
40 Elm_App_Server_Data *cdata = data;
41 eina_hash_del(cdata->views, NULL, obj);
42 return EINA_TRUE;
43}
44
45static Eina_Bool
46_view_append(Elm_App_Server_Data *data, Elm_App_Server_View *view)
47{
48 Eina_Stringshare *view_id;
49
50 eo_do(view, elm_app_server_view_id_get(&view_id));
51
52 if (eina_hash_find(data->views, view_id))
53 {
54 ERR("%p already have a view with id=%s", data->pkg, view_id);
55 eo_del(view);
56 return EINA_FALSE;
57 }
58
59 eina_hash_add(data->views, view_id, view);
60 eo_do(view, eo_event_callback_add(EO_EV_DEL, _view_del_cb, data));
61 return EINA_TRUE;
62}
63
64static Eldbus_Message *
65_method_create_view(const Eldbus_Service_Interface *iface, const Eldbus_Message *message)
66{
67 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
68 Elm_App_Server_Data *data = eo_data_scope_get(eo, MY_CLASS);
69 Eina_Value *args;
70 Eina_Stringshare *error_name, *error_message, *view_path;
71 Elm_App_Server_View *view;
72 Eldbus_Message *reply;
73
74 args = eldbus_message_to_eina_value(message);
75 if (!args)
76 return eldbus_message_error_new(message, ELM_APP_CLEINT_VIEW_OPEN_ERROR, "");
77
78 view = data->create_view_cb(eo, args, &error_name, &error_message);
79 eina_value_free(args);
80
81 if (!view)
82 {
83 reply = eldbus_message_error_new(message, error_name, error_message);
84 eina_stringshare_del(error_name);
85 eina_stringshare_del(error_message);
86 return reply;
87 }
88
89 if (!_view_append(data, view))
90 {
91 reply = eldbus_message_error_new(message,
92 ELM_APP_SERVER_VIEW_CREATE_DUPLICATE,
93 NULL);
94 return reply;
95 }
96 eo_do(view, elm_app_server_view_path_get(&view_path));
97
98 reply = eldbus_message_method_return_new(message);
99 eldbus_message_arguments_append(reply, "o", view_path);
100
101 return reply;
102}
103
104static void
105_close_all_views(Elm_App_Server_Data *data)
106{
107 Eina_Iterator *iter;
108 Elm_App_Server_View *view;
109 Eina_List *view_list = NULL;
110
111 /*
112 * need do this because hash will be modified when called
113 * elm_app_server_view_close()
114 */
115 iter = eina_hash_iterator_data_new(data->views);
116 EINA_ITERATOR_FOREACH(iter, view)
117 view_list = eina_list_append(view_list, view);
118 eina_iterator_free(iter);
119
120 EINA_LIST_FREE(view_list, view)
121 eo_do(view, elm_app_server_view_close());
122}
123
124static Eldbus_Message *
125_method_close_all_views(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *message EINA_UNUSED)
126{
127 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
128 Elm_App_Server_Data *data = eo_data_scope_get(eo, MY_CLASS);
129
130 _close_all_views(data);
131
132 return eldbus_message_method_return_new(message);
133}
134
135static Eldbus_Message *
136_method_terminate(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *message EINA_UNUSED)
137{
138 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
139
140 eo_do(eo, eo_event_callback_call(ELM_APP_SERVER_EV_TERMINATE, NULL, NULL));
141
142 return eldbus_message_method_return_new(message);
143}
144
145static const Eldbus_Method _methods[] = {
146 { "CreateView", ELDBUS_ARGS({"a{sv}", "arguments"}),
147 ELDBUS_ARGS({"o", "view_path"}), _method_create_view, 0 },
148 { "CloseAllViews", NULL, NULL, _method_close_all_views, 0},
149 { "Terminate", NULL, NULL, _method_terminate, 0 },
150 { NULL, NULL, NULL, NULL, 0 }
151};
152
153static Eina_Bool
154_prop_pid_get(const Eldbus_Service_Interface *iface, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
155{
156 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
157 Elm_App_Server_Data *data = eo_data_scope_get(eo, MY_CLASS);
158
159 eldbus_message_iter_basic_append(iter, 'i', data->PID);
160 return EINA_TRUE;
161}
162
163static Eina_Bool
164_prop_title_get(const Eldbus_Service_Interface *iface, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
165{
166 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
167 Elm_App_Server_Data *data = eo_data_scope_get(eo, MY_CLASS);
168
169 eldbus_message_iter_basic_append(iter, 's', data->title);
170 return EINA_TRUE;
171}
172
173static Eina_Bool
174_prop_icon_get(const Eldbus_Service_Interface *iface, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
175{
176 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
177 Elm_App_Server_Data *data = eo_data_scope_get(eo, MY_CLASS);
178
179 eldbus_message_iter_basic_append(iter, 's', data->icon_name);
180 return EINA_TRUE;
181}
182
183/*static Eina_Bool
184_prop_icon_pixels_get(const Eldbus_Service_Interface *iface EINA_UNUSED, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter EINA_UNUSED, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
185{
186 //TODO
187 return EINA_FALSE;
188}*/
189
190static const Eldbus_Property _props[] = {
191 { "PID", "i", _prop_pid_get, NULL, 0 },
192 { "Title", "s", _prop_title_get, NULL, 0 },
193 { "IconName", "s", _prop_icon_get, NULL, 0 },
194 //{ "IconPixels", "(uubay)", _prop_icon_pixels_get, NULL, 0 },
195 { NULL, NULL, NULL, NULL, 0 }
196};
197
198static const Eldbus_Service_Interface_Desc iface_desc = {
199 "org.enlightenment.Application1", _methods, NULL, _props, NULL, NULL
200};
201
202static void
203_app_server_constructor(Eo *obj, void *_pd, va_list *list)
204{
205 Elm_App_Server_Data *data = _pd;
206 const char *pkg = va_arg(*list, const char *);
207 char *path;
208 Elm_App_Server_Views_Eet *views_eet;
209 char buf[PATH_MAX];
210
211 data->create_view_cb = va_arg(*list, Elm_App_Server_Create_View_Cb);
212
213 EINA_SAFETY_ON_NULL_GOTO(data->create_view_cb, error);
214 EINA_SAFETY_ON_TRUE_GOTO(!pkg, error);
215
216 eo_do_super(obj, MY_CLASS, eo_constructor());
217
218 data->views = eina_hash_string_small_new(NULL);
219 data->PID = getpid();
220 data->title = eina_stringshare_add("");
221 data->icon_name = eina_stringshare_add("");
222 data->pkg = eina_stringshare_add(pkg);
223
224 path = _dbus_package_to_path(pkg);
225
226 eldbus_init();
227 data->conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
228 eldbus_name_request(data->conn, pkg, 0, NULL, NULL);
229 data->iface = eldbus_service_interface_register(data->conn,
230 path,
231 &iface_desc);
232 eldbus_service_object_data_set(data->iface, MY_CLASS_NAME, obj);
233 eldbus_service_object_manager_attach(data->iface);
234
235 free(path);
236
237 //Check if there a saved list of views
238 app_server_views_eet_init();
239
240 _elm_config_user_dir_snprintf(buf, sizeof(buf), "apps/%s.eet",
241 data->pkg);
242 views_eet = elm_app_server_views_eet_load(buf);
243 if (views_eet)
244 {
245 Elm_App_Server_View_Props *view_eet_props;
246 Eina_List *l, *views_list;
247
248 views_list = elm_app_server_views_eet_views_entries_list_get(views_eet);
249 if (!views_list)
250 goto free_views_eet;
251
252 EINA_LIST_FOREACH(views_list, l, view_eet_props)
253 {
254 Elm_App_Server_View *view;
255 const char *view_id, *title, *icon_name;
256 int new_events;
257 short progress;
258
259 view_id = elm_app_server_view_props_id_get(view_eet_props);
260
261 if (eina_hash_find(data->views, view_id))
262 continue;
263 title = elm_app_server_view_props_title_get(view_eet_props);
264 icon_name = elm_app_server_view_props_icon_name_get(view_eet_props);
265 new_events = elm_app_server_view_props_new_events_get(view_eet_props);
266 progress = elm_app_server_view_props_progress_get(view_eet_props);
267
268 view = eo_add_custom(ELM_APP_SERVER_VIEW_CLASS, obj,
269 elm_app_server_view_constructor(view_id));
270 if (!view)
271 continue;
272
273 eo_do(view, elm_app_server_view_title_set(title),
274 elm_app_server_view_icon_set(icon_name),
275 elm_app_server_view_progress_set(progress),
276 elm_app_server_view_new_events_set(new_events),
277 eo_event_callback_add(EO_EV_DEL, _view_del_cb, data),
278 elm_app_server_view_shallow());
279
280 eina_hash_add(data->views, view_id, view);
281 }
282
283free_views_eet:
284 elm_app_server_views_eet_free(views_eet);
285 }
286
287 app_server_views_eet_shutdown();
288
289 return;
290
291error:
292 eo_error_set(obj);
293}
294
295static void
296_save(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
297{
298 Elm_App_Server_Data *data = _pd;
299 Eina_Iterator *iter;
300 Elm_App_Server_View *view;
301 Elm_App_Server_Views_Eet *views_eet;
302 char buf[PATH_MAX];
303
304 app_server_views_eet_init();
305
306 views_eet = elm_app_server_views_eet_new(1, NULL);
307
308 iter = eina_hash_iterator_data_new(data->views);
309 EINA_ITERATOR_FOREACH(iter, view)
310 {
311 Elm_App_Server_View_Props *view_props;
312 const char *id, *title, *icon_name;
313 int new_events;
314 short progress;
315
316 eo_do(view, elm_app_server_view_id_get(&id),
317 elm_app_server_view_title_get(&title),
318 elm_app_server_view_icon_get(&icon_name),
319 elm_app_server_view_new_events_get(&new_events),
320 elm_app_server_view_progress_get(&progress),
321 eo_event_callback_call(ELM_APP_SERVER_VIEW_EV_SAVE, NULL, NULL));
322
323 view_props = elm_app_server_view_props_new(id, title, icon_name,
324 new_events, progress);
325 elm_app_server_views_eet_views_entries_add(views_eet, view_props);
326 }
327 eina_iterator_free(iter);
328
329 _elm_config_user_dir_snprintf(buf, sizeof(buf), "apps/");
330 if (!ecore_file_is_dir(buf))
331 ecore_file_mkpath(buf);
332 _elm_config_user_dir_snprintf(buf, sizeof(buf), "apps/%s.eet", data->pkg);
333 elm_app_server_views_eet_save(views_eet, buf);
334 elm_app_server_views_eet_free(views_eet);
335 app_server_views_eet_shutdown();
336}
337
338static void
339_close_all(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
340{
341 Elm_App_Server_Data *data = _pd;
342 _close_all_views(data);
343}
344
345static void
346_view_check(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
347{
348 Elm_App_Server_Data *data = _pd;
349 const char *id = va_arg(*list, const char *);
350 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
351 const char *ptr;
352
353 *ret = EINA_FALSE;
354 EINA_SAFETY_ON_NULL_RETURN(id);
355
356 for (ptr = id; *ptr; ptr++)
357 {
358 if (!isalnum(*ptr))
359 break;
360 }
361
362 if (!eina_hash_find(data->views, id))
363 *ret = EINA_TRUE;
364}
365
366static void
367_title_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
368{
369 Elm_App_Server_Data *data = _pd;
370 const char *title = va_arg(*list, const char *);
371
372 title = title ? title : "";
373
374 if (eina_stringshare_replace(&data->title, title))
375 eldbus_service_property_changed(data->iface, "Title");
376}
377
378static void
379_title_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
380{
381 Elm_App_Server_Data *data = _pd;
382 Eina_Stringshare **ret = va_arg(*list, Eina_Stringshare **);
383
384 *ret = data->title;
385}
386
387static void
388_icon_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
389{
390 Elm_App_Server_Data *data = _pd;
391 const char *icon = va_arg(*list, const char *);
392
393 icon = icon ? icon : "";
394
395 if (eina_stringshare_replace(&data->icon_name, icon))
396 eldbus_service_property_changed(data->iface, "IconName");
397}
398
399static void
400_icon_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
401{
402 Elm_App_Server_Data *data = _pd;
403 Eina_Stringshare **ret = va_arg(*list, Eina_Stringshare **);
404
405 *ret = data->icon_name;
406}
407
408static void
409_icon_pixels_set(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
410{
411 //TODO
412}
413
414static void
415_icon_pixels_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
416{
417 //TODO
418}
419
420static void
421_package_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
422{
423 Elm_App_Server_Data *data = _pd;
424 Eina_Stringshare **ret = va_arg(*list, Eina_Stringshare **);
425
426 *ret = data->pkg;
427}
428
429static void
430_views_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
431{
432 Elm_App_Server_Data *data = _pd;
433 Eina_Iterator **ret = va_arg(*list, Eina_Iterator **);
434
435 *ret = eina_hash_iterator_data_new(data->views);
436}
437
438static void
439_path_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
440{
441 Elm_App_Server_Data *data = _pd;
442 const char **path = va_arg(*list, const char **);
443
444 *path = eldbus_service_object_path_get(data->iface);
445}
446
447static void
448_view_add(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
449{
450 Elm_App_Server_Data *data = _pd;
451 Elm_App_Server_View *view = va_arg(*list, Elm_App_Server_View *);
452 _view_append(data, view);
453}
454
455static void
456_destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
457{
458 Elm_App_Server_Data *data = _pd;
459 Eina_Iterator *iter;
460 Elm_App_Server_View *view;
461
462 iter = eina_hash_iterator_data_new(data->views);
463 EINA_ITERATOR_FOREACH(iter, view)
464 {
465 //do not modify hash when iterating
466 eo_do(view, eo_event_callback_del(EO_EV_DEL, _view_del_cb, data));
467 eo_del(view);
468 }
469 eina_iterator_free(iter);
470 eina_hash_free(data->views);
471
472 eina_stringshare_del(data->title);
473 eina_stringshare_del(data->icon_name);
474 eina_stringshare_del(data->pkg);
475
476 eldbus_service_object_manager_detach(data->iface);
477 eldbus_service_interface_unregister(data->iface);
478 eldbus_connection_unref(data->conn);
479 eldbus_shutdown();
480 eo_do_super(obj, MY_CLASS, eo_destructor());
481}
482
483static void
484_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
485{
486 eo_error_set(obj);
487 ERR("Only custom constructor can be used with '%s' class", MY_CLASS_NAME);
488}
489
490static void
491_class_constructor(Eo_Class *klass)
492{
493 const Eo_Op_Func_Description func_desc[] = {
494 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
495 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
496 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_CONSTRUCTOR),
497 _app_server_constructor),
498 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_SAVE), _save),
499 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_CLOSE_ALL),
500 _close_all),
501 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_VIEW_CHECK),
502 _view_check),
503 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_TITLE_SET),
504 _title_set),
505 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_TITLE_GET),
506 _title_get),
507 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_SET), _icon_set),
508 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_GET), _icon_get),
509 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_PIXELS_SET),
510 _icon_pixels_set),
511 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_PIXELS_GET),
512 _icon_pixels_get),
513 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_PACKAGE_GET),
514 _package_get),
515 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_VIEWS_GET),
516 _views_get),
517 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_PATH_GET), _path_get),
518 EO_OP_FUNC(ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_VIEW_ADD), _view_add),
519 EO_OP_FUNC_SENTINEL
520 };
521 eo_class_funcs_set(klass, func_desc);
522}
523
524static const Eo_Op_Description op_desc[] = {
525 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_CONSTRUCTOR,
526 "Constructor of elm_app_server."),
527 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_SAVE,
528 "Save current state of applications views."),
529 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_CLOSE_ALL, "Close all views."),
530 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_VIEW_CHECK,
531 "Return the view dbus object path if id available."),
532 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_TITLE_SET,
533 "Set title of application."),
534 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_TITLE_GET,
535 "Get title of application."),
536 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_ICON_SET,
537 "Set icon of applicaiton."),
538 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_ICON_GET,
539 "Get icon of applicaiton."),
540 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_ICON_PIXELS_SET,
541 "Set icon to application, using the raw pixels of image."),
542 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_ICON_PIXELS_GET,
543 "Get application raw icon."),
544 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_PACKAGE_GET,
545 "Get application package."),
546 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_VIEWS_GET,
547 "Return iterator with all views of application."),
548 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_PATH_GET,
549 "Get application DBus path."),
550 EO_OP_DESCRIPTION(ELM_APP_SERVER_SUB_ID_VIEW_ADD,
551 "Add a view to application."),
552 EO_OP_DESCRIPTION_SENTINEL
553};
554
555static const Eo_Event_Description *event_desc[] = {
556 ELM_APP_SERVER_EV_TERMINATE,
557 NULL
558};
559
560static const Eo_Class_Description class_desc = {
561 EO_VERSION,
562 MY_CLASS_NAME,
563 EO_CLASS_TYPE_REGULAR,
564 EO_CLASS_DESCRIPTION_OPS(&ELM_APP_SERVER_BASE_ID, op_desc, ELM_APP_SERVER_SUB_ID_LAST),
565 event_desc,
566 sizeof(Elm_App_Server_Data),
567 _class_constructor,
568 NULL
569};
570
571EO_DEFINE_CLASS(elm_app_server_class_get, &class_desc, EO_BASE_CLASS, NULL);
diff --git a/src/lib/elm_app_server.h b/src/lib/elm_app_server.h
new file mode 100644
index 000000000..48ca22116
--- /dev/null
+++ b/src/lib/elm_app_server.h
@@ -0,0 +1,3 @@
1#ifdef EFL_EO_API_SUPPORT
2#include "elm_app_server_eo.h"
3#endif
diff --git a/src/lib/elm_app_server_eet.c b/src/lib/elm_app_server_eet.c
new file mode 100644
index 000000000..350ea58bc
--- /dev/null
+++ b/src/lib/elm_app_server_eet.c
@@ -0,0 +1,312 @@
1#include "elm_app_server_eet.h"
2
3struct _Elm_App_Server_View_Props {
4 const char * id;
5 const char * title;
6 const char * icon_name;
7 int new_events;
8 char progress;
9};
10
11struct _Elm_App_Server_Views_Eet {
12 unsigned int version;
13 Eina_List * views_entries;
14 const char *__eet_filename;
15};
16
17static const char ELM_APP_SERVER_VIEW_PROPS_ENTRY[] = "elm_app_server_view_props";
18static const char ELM_APP_SERVER_VIEWS_EET_ENTRY[] = "elm_app_server_views_eet";
19
20static Eet_Data_Descriptor *_elm_app_server_view_props_descriptor = NULL;
21static Eet_Data_Descriptor *_elm_app_server_views_eet_descriptor = NULL;
22
23static inline void
24_elm_app_server_view_props_init(void)
25{
26 Eet_Data_Descriptor_Class eddc;
27
28 if (_elm_app_server_view_props_descriptor) return;
29
30 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_App_Server_View_Props);
31 _elm_app_server_view_props_descriptor = eet_data_descriptor_stream_new(&eddc);
32
33 EET_DATA_DESCRIPTOR_ADD_BASIC(_elm_app_server_view_props_descriptor, Elm_App_Server_View_Props, "id", id, EET_T_STRING);
34 EET_DATA_DESCRIPTOR_ADD_BASIC(_elm_app_server_view_props_descriptor, Elm_App_Server_View_Props, "title", title, EET_T_STRING);
35 EET_DATA_DESCRIPTOR_ADD_BASIC(_elm_app_server_view_props_descriptor, Elm_App_Server_View_Props, "icon_name", icon_name, EET_T_STRING);
36 EET_DATA_DESCRIPTOR_ADD_BASIC(_elm_app_server_view_props_descriptor, Elm_App_Server_View_Props, "new_events", new_events, EET_T_INT);
37 EET_DATA_DESCRIPTOR_ADD_BASIC(_elm_app_server_view_props_descriptor, Elm_App_Server_View_Props, "progress", progress, EET_T_CHAR);
38}
39
40static inline void
41_elm_app_server_view_props_shutdown(void)
42{
43 if (!_elm_app_server_view_props_descriptor) return;
44 eet_data_descriptor_free(_elm_app_server_view_props_descriptor);
45 _elm_app_server_view_props_descriptor = NULL;
46}
47
48Elm_App_Server_View_Props *
49elm_app_server_view_props_new(const char * id, const char * title, const char * icon_name, int new_events, char progress)
50{
51 Elm_App_Server_View_Props *elm_app_server_view_props = calloc(1, sizeof(Elm_App_Server_View_Props));
52
53 if (!elm_app_server_view_props)
54 {
55 fprintf(stderr, "ERROR: could not calloc Elm_App_Server_View_Props\n");
56 return NULL;
57 }
58
59 elm_app_server_view_props->id = eina_stringshare_add(id ? id : "");
60 elm_app_server_view_props->title = eina_stringshare_add(title ? title : "");
61 elm_app_server_view_props->icon_name = eina_stringshare_add(icon_name ? icon_name : "");
62 elm_app_server_view_props->new_events = new_events;
63 elm_app_server_view_props->progress = progress;
64
65 return elm_app_server_view_props;
66}
67
68void
69elm_app_server_view_props_free(Elm_App_Server_View_Props *elm_app_server_view_props)
70{
71 eina_stringshare_del(elm_app_server_view_props->id);
72 eina_stringshare_del(elm_app_server_view_props->title);
73 eina_stringshare_del(elm_app_server_view_props->icon_name);
74 free(elm_app_server_view_props);
75}
76
77inline const char *
78elm_app_server_view_props_id_get(const Elm_App_Server_View_Props *elm_app_server_view_props)
79{
80 return elm_app_server_view_props->id;
81}
82
83inline void
84elm_app_server_view_props_id_set(Elm_App_Server_View_Props *elm_app_server_view_props, const char *id)
85{
86 EINA_SAFETY_ON_NULL_RETURN(elm_app_server_view_props);
87 eina_stringshare_replace(&(elm_app_server_view_props->id), id);
88}
89
90inline const char *
91elm_app_server_view_props_title_get(const Elm_App_Server_View_Props *elm_app_server_view_props)
92{
93 return elm_app_server_view_props->title;
94}
95
96inline void
97elm_app_server_view_props_title_set(Elm_App_Server_View_Props *elm_app_server_view_props, const char *title)
98{
99 EINA_SAFETY_ON_NULL_RETURN(elm_app_server_view_props);
100 eina_stringshare_replace(&(elm_app_server_view_props->title), title);
101}
102
103inline const char *
104elm_app_server_view_props_icon_name_get(const Elm_App_Server_View_Props *elm_app_server_view_props)
105{
106 return elm_app_server_view_props->icon_name;
107}
108
109inline void
110elm_app_server_view_props_icon_name_set(Elm_App_Server_View_Props *elm_app_server_view_props, const char *icon_name)
111{
112 EINA_SAFETY_ON_NULL_RETURN(elm_app_server_view_props);
113 eina_stringshare_replace(&(elm_app_server_view_props->icon_name), icon_name);
114}
115
116inline int
117elm_app_server_view_props_new_events_get(const Elm_App_Server_View_Props *elm_app_server_view_props)
118{
119 return elm_app_server_view_props->new_events;
120}
121
122inline void
123elm_app_server_view_props_new_events_set(Elm_App_Server_View_Props *elm_app_server_view_props, int new_events)
124{
125 EINA_SAFETY_ON_NULL_RETURN(elm_app_server_view_props);
126 elm_app_server_view_props->new_events = new_events;
127}
128
129inline char
130elm_app_server_view_props_progress_get(const Elm_App_Server_View_Props *elm_app_server_view_props)
131{
132 return elm_app_server_view_props->progress;
133}
134
135inline void
136elm_app_server_view_props_progress_set(Elm_App_Server_View_Props *elm_app_server_view_props, char progress)
137{
138 EINA_SAFETY_ON_NULL_RETURN(elm_app_server_view_props);
139 elm_app_server_view_props->progress = progress;
140}
141
142
143static inline void
144_elm_app_server_views_eet_init(void)
145{
146 Eet_Data_Descriptor_Class eddc;
147
148 if (_elm_app_server_views_eet_descriptor) return;
149
150 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_App_Server_Views_Eet);
151 _elm_app_server_views_eet_descriptor = eet_data_descriptor_stream_new(&eddc);
152
153 EET_DATA_DESCRIPTOR_ADD_BASIC(_elm_app_server_views_eet_descriptor, Elm_App_Server_Views_Eet, "version", version, EET_T_UINT);
154 EET_DATA_DESCRIPTOR_ADD_LIST(_elm_app_server_views_eet_descriptor, Elm_App_Server_Views_Eet, "views_entries", views_entries, _elm_app_server_view_props_descriptor);
155}
156
157static inline void
158_elm_app_server_views_eet_shutdown(void)
159{
160 if (!_elm_app_server_views_eet_descriptor) return;
161 eet_data_descriptor_free(_elm_app_server_views_eet_descriptor);
162 _elm_app_server_views_eet_descriptor = NULL;
163}
164
165Elm_App_Server_Views_Eet *
166elm_app_server_views_eet_new(unsigned int version, Eina_List * views_entries)
167{
168 Elm_App_Server_Views_Eet *elm_app_server_views_eet = calloc(1, sizeof(Elm_App_Server_Views_Eet));
169
170 if (!elm_app_server_views_eet)
171 {
172 fprintf(stderr, "ERROR: could not calloc Elm_App_Server_Views_Eet\n");
173 return NULL;
174 }
175
176 elm_app_server_views_eet->version = version;
177 elm_app_server_views_eet->views_entries = views_entries;
178
179 return elm_app_server_views_eet;
180}
181
182void
183elm_app_server_views_eet_free(Elm_App_Server_Views_Eet *elm_app_server_views_eet)
184{
185 if (elm_app_server_views_eet->views_entries)
186 {
187 Elm_App_Server_View_Props *views_entries_elem;
188 EINA_LIST_FREE(elm_app_server_views_eet->views_entries, views_entries_elem)
189 elm_app_server_view_props_free(views_entries_elem);
190 }
191 free(elm_app_server_views_eet);
192}
193
194inline unsigned int
195elm_app_server_views_eet_version_get(const Elm_App_Server_Views_Eet *elm_app_server_views_eet)
196{
197 return elm_app_server_views_eet->version;
198}
199
200inline void
201elm_app_server_views_eet_version_set(Elm_App_Server_Views_Eet *elm_app_server_views_eet, unsigned int version)
202{
203 EINA_SAFETY_ON_NULL_RETURN(elm_app_server_views_eet);
204 elm_app_server_views_eet->version = version;
205}
206
207inline void
208elm_app_server_views_eet_views_entries_add(Elm_App_Server_Views_Eet *elm_app_server_views_eet, Elm_App_Server_View_Props *elm_app_server_view_props)
209{
210 EINA_SAFETY_ON_NULL_RETURN(elm_app_server_views_eet);
211 elm_app_server_views_eet->views_entries = eina_list_append(elm_app_server_views_eet->views_entries, elm_app_server_view_props);
212}
213
214inline void
215elm_app_server_views_eet_views_entries_del(Elm_App_Server_Views_Eet *elm_app_server_views_eet, Elm_App_Server_View_Props *elm_app_server_view_props)
216{
217 EINA_SAFETY_ON_NULL_RETURN(elm_app_server_views_eet);
218 elm_app_server_views_eet->views_entries = eina_list_remove(elm_app_server_views_eet->views_entries, elm_app_server_view_props);
219}
220
221inline Elm_App_Server_View_Props *
222elm_app_server_views_eet_views_entries_get(const Elm_App_Server_Views_Eet *elm_app_server_views_eet, unsigned int nth)
223{
224 EINA_SAFETY_ON_NULL_RETURN_VAL(elm_app_server_views_eet, NULL);
225 return eina_list_nth(elm_app_server_views_eet->views_entries, nth);
226}
227
228inline unsigned int
229elm_app_server_views_eet_views_entries_count(const Elm_App_Server_Views_Eet *elm_app_server_views_eet)
230{
231 EINA_SAFETY_ON_NULL_RETURN_VAL(elm_app_server_views_eet, 0);
232 return eina_list_count(elm_app_server_views_eet->views_entries);
233}
234
235void
236elm_app_server_views_eet_views_entries_list_clear(Elm_App_Server_Views_Eet *elm_app_server_views_eet)
237{
238 EINA_SAFETY_ON_NULL_RETURN(elm_app_server_views_eet);
239 Elm_App_Server_View_Props *data;
240 EINA_LIST_FREE(elm_app_server_views_eet->views_entries, data) elm_app_server_view_props_free(data);
241}
242
243inline Eina_List *
244elm_app_server_views_eet_views_entries_list_get(const Elm_App_Server_Views_Eet *elm_app_server_views_eet)
245{
246 EINA_SAFETY_ON_NULL_RETURN_VAL(elm_app_server_views_eet, NULL);
247 return elm_app_server_views_eet->views_entries;
248}
249
250inline void
251elm_app_server_views_eet_views_entries_list_set(Elm_App_Server_Views_Eet *elm_app_server_views_eet, Eina_List *list)
252{
253 EINA_SAFETY_ON_NULL_RETURN(elm_app_server_views_eet);
254 elm_app_server_views_eet->views_entries = list;
255}
256
257Elm_App_Server_Views_Eet *
258elm_app_server_views_eet_load(const char *filename)
259{
260 Elm_App_Server_Views_Eet *elm_app_server_views_eet = NULL;
261 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
262 if (!ef)
263 {
264 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
265 return NULL;
266 }
267
268 elm_app_server_views_eet = eet_data_read(ef, _elm_app_server_views_eet_descriptor, ELM_APP_SERVER_VIEWS_EET_ENTRY);
269 if (!elm_app_server_views_eet) goto end;
270 elm_app_server_views_eet->__eet_filename = eina_stringshare_add(filename);
271
272end:
273 eet_close(ef);
274 return elm_app_server_views_eet;
275}
276
277Eina_Bool
278elm_app_server_views_eet_save(Elm_App_Server_Views_Eet *elm_app_server_views_eet, const char *filename)
279{
280 Eet_File *ef;
281 Eina_Bool ret;
282
283 if (filename) eina_stringshare_replace(&(elm_app_server_views_eet->__eet_filename), filename);
284 else if (elm_app_server_views_eet->__eet_filename) filename = elm_app_server_views_eet->__eet_filename;
285 else return EINA_FALSE;
286
287 ef = eet_open(filename, EET_FILE_MODE_READ_WRITE);
288 if (!ef)
289 {
290 fprintf(stderr, "ERROR: could not open '%s' for write\n", filename);
291 return EINA_FALSE;
292 }
293
294 ret = !!eet_data_write(ef, _elm_app_server_views_eet_descriptor, ELM_APP_SERVER_VIEWS_EET_ENTRY, elm_app_server_views_eet, EINA_TRUE);
295 eet_close(ef);
296
297 return ret;
298}
299
300void
301app_server_views_eet_init(void)
302{
303 _elm_app_server_view_props_init();
304 _elm_app_server_views_eet_init();
305}
306
307void
308app_server_views_eet_shutdown(void)
309{
310 _elm_app_server_view_props_shutdown();
311 _elm_app_server_views_eet_shutdown();
312}
diff --git a/src/lib/elm_app_server_eet.h b/src/lib/elm_app_server_eet.h
new file mode 100644
index 000000000..8d35e5c05
--- /dev/null
+++ b/src/lib/elm_app_server_eet.h
@@ -0,0 +1,46 @@
1#ifndef _ELM_APP_SERVER_EET_H_
2#define _ELM_APP_SERVER_EET_H_
3
4#include <Eina.h>
5#include <Eet.h>
6
7typedef struct _Elm_App_Server_View_Props Elm_App_Server_View_Props;
8typedef struct _Elm_App_Server_Views_Eet Elm_App_Server_Views_Eet;
9
10/* Elm_App_Server_View_Props */
11Elm_App_Server_View_Props *elm_app_server_view_props_new(const char * id, const char * title, const char * icon_name, int new_events, char progress);
12void elm_app_server_view_props_free(Elm_App_Server_View_Props *elm_app_server_view_props);
13
14void elm_app_server_view_props_id_set(Elm_App_Server_View_Props *elm_app_server_view_props, const char * id);
15const char * elm_app_server_view_props_id_get(const Elm_App_Server_View_Props *elm_app_server_view_props);
16void elm_app_server_view_props_title_set(Elm_App_Server_View_Props *elm_app_server_view_props, const char * title);
17const char * elm_app_server_view_props_title_get(const Elm_App_Server_View_Props *elm_app_server_view_props);
18void elm_app_server_view_props_icon_name_set(Elm_App_Server_View_Props *elm_app_server_view_props, const char * icon_name);
19const char * elm_app_server_view_props_icon_name_get(const Elm_App_Server_View_Props *elm_app_server_view_props);
20void elm_app_server_view_props_new_events_set(Elm_App_Server_View_Props *elm_app_server_view_props, int new_events);
21int elm_app_server_view_props_new_events_get(const Elm_App_Server_View_Props *elm_app_server_view_props);
22void elm_app_server_view_props_progress_set(Elm_App_Server_View_Props *elm_app_server_view_props, char progress);
23char elm_app_server_view_props_progress_get(const Elm_App_Server_View_Props *elm_app_server_view_props);
24
25/* Elm_App_Server_Views_Eet */
26Elm_App_Server_Views_Eet *elm_app_server_views_eet_new(unsigned int version, Eina_List * views_entries);
27void elm_app_server_views_eet_free(Elm_App_Server_Views_Eet *elm_app_server_views_eet);
28
29void elm_app_server_views_eet_version_set(Elm_App_Server_Views_Eet *elm_app_server_views_eet, unsigned int version);
30unsigned int elm_app_server_views_eet_version_get(const Elm_App_Server_Views_Eet *elm_app_server_views_eet);
31void elm_app_server_views_eet_views_entries_add(Elm_App_Server_Views_Eet *elm_app_server_views_eet, Elm_App_Server_View_Props *elm_app_server_view_props);
32void elm_app_server_views_eet_views_entries_del(Elm_App_Server_Views_Eet *elm_app_server_views_eet, Elm_App_Server_View_Props *elm_app_server_view_props);
33Elm_App_Server_View_Props *elm_app_server_views_eet_views_entries_get(const Elm_App_Server_Views_Eet *elm_app_server_views_eet, unsigned int nth);
34unsigned int elm_app_server_views_eet_views_entries_count(const Elm_App_Server_Views_Eet *elm_app_server_views_eet);
35Eina_List *elm_app_server_views_eet_views_entries_list_get(const Elm_App_Server_Views_Eet *elm_app_server_views_eet);
36void elm_app_server_views_eet_views_entries_list_clear(Elm_App_Server_Views_Eet *elm_app_server_views_eet);
37void elm_app_server_views_eet_views_entries_list_set(Elm_App_Server_Views_Eet *elm_app_server_views_eet, Eina_List *list);
38
39Elm_App_Server_Views_Eet *elm_app_server_views_eet_load(const char *filename);
40Eina_Bool elm_app_server_views_eet_save(Elm_App_Server_Views_Eet *elm_app_server_views_eet, const char *filename);
41
42/* Global initializer / shutdown functions */
43void app_server_views_eet_init(void);
44void app_server_views_eet_shutdown(void);
45
46#endif
diff --git a/src/lib/elm_app_server_eo.h b/src/lib/elm_app_server_eo.h
new file mode 100644
index 000000000..d474f108d
--- /dev/null
+++ b/src/lib/elm_app_server_eo.h
@@ -0,0 +1,137 @@
1#define ELM_APP_SERVER_CLASS elm_app_server_class_get()
2
3const Eo_Class *elm_app_server_class_get(void) EINA_CONST;
4
5extern EAPI Eo_Op ELM_APP_SERVER_BASE_ID;
6
7#define ELM_APP_CLIENT_VIEW_OPEN_CANCELED "org.enlightenment.Application.ViewOpenCanceled"
8#define ELM_APP_CLIENT_VIEW_OPEN_TIMEOUT "org.enlightenment.Application.ViewOpenTimeout"
9#define ELM_APP_CLEINT_VIEW_OPEN_ERROR "org.enlightenment.Application.CouldNotCreateView"
10
11enum
12{
13 ELM_APP_SERVER_SUB_ID_CONSTRUCTOR,
14 ELM_APP_SERVER_SUB_ID_SAVE,
15 ELM_APP_SERVER_SUB_ID_CLOSE_ALL,
16 ELM_APP_SERVER_SUB_ID_VIEW_CHECK,
17 ELM_APP_SERVER_SUB_ID_TITLE_SET,
18 ELM_APP_SERVER_SUB_ID_TITLE_GET,
19 ELM_APP_SERVER_SUB_ID_ICON_SET,
20 ELM_APP_SERVER_SUB_ID_ICON_GET,
21 ELM_APP_SERVER_SUB_ID_ICON_PIXELS_SET,
22 ELM_APP_SERVER_SUB_ID_ICON_PIXELS_GET,
23 ELM_APP_SERVER_SUB_ID_PACKAGE_GET,
24 ELM_APP_SERVER_SUB_ID_VIEWS_GET,
25 ELM_APP_SERVER_SUB_ID_PATH_GET,
26 ELM_APP_SERVER_SUB_ID_VIEW_ADD,
27 ELM_APP_SERVER_SUB_ID_LAST
28};
29
30#define ELM_APP_SERVER_VIEW_CREATE_DUPLICATE "org.enlightenment.Application.ViewDuplicate"
31
32typedef Eo Elm_App_Server;
33typedef Eo Elm_App_Server_View;
34
35typedef Elm_App_Server_View *(*Elm_App_Server_Create_View_Cb)(Elm_App_Server *app, const Eina_Value *args, Eina_Stringshare **error_name, Eina_Stringshare **error_message);
36
37#define ELM_APP_SERVER_ID(sub_id) (ELM_APP_SERVER_BASE_ID + sub_id)
38
39/**
40 * @def elm_app_server_constructor
41 * @since 1.8
42 *
43 * Class constructor of elm_app_server
44 *
45 * @param[in] packageid package of application
46 * @param[in] create_view_cb callback to be called when user whants to
47 * open some application view
48 */
49#define elm_app_server_constructor(packageid, create_view_cb) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(const char *, packageid), EO_TYPECHECK(Elm_App_Server_Create_View_Cb, create_view_cb)
50
51/**
52 * @def elm_app_server_save
53 * @since 1.8
54 *
55 * Save the state of all views
56 */
57#define elm_app_server_save() ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_SAVE)
58
59/**
60 * @def elm_app_server_close_all
61 * @since 1.8
62 *
63 * Close all views of application
64 */
65#define elm_app_server_close_all() ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_CLOSE_ALL)
66
67/**
68 * @def elm_app_server_title_set
69 * @since 1.8
70 *
71 * Set a title to application.
72 *
73 * @param[in] title title of application
74 */
75#define elm_app_server_title_set(title) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_TITLE_SET), EO_TYPECHECK(const char *, title)
76
77/**
78 * @def elm_app_server_title_get
79 * @since 1.8
80 *
81 * Get title of application
82 *
83 * @param[out] ret title of application
84 */
85#define elm_app_server_title_get(ret) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_TITLE_GET), EO_TYPECHECK(Eina_Stringshare **, ret)
86
87#define elm_app_server_icon_set(icon) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_SET), EO_TYPECHECK(const char*, icon)
88
89#define elm_app_server_icon_get(ret) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_GET), EO_TYPECHECK(Eina_Stringshare **, ret)
90
91#define elm_app_server_icon_pixels_set(w, h, has_alpha, pixels) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_PIXELS_SET), EO_TYPECHECK(unsigned int, w), EO_TYPECHECK(unsigned int, h), EO_TYPECHECK(Eina_Bool, has_alpha), EO_TYPECHECK(const unsigned char *, pixels)
92
93#define elm_app_server_icon_pixels_get(w, h, has_alpha, pixels) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_ICON_PIXELS_GET), EO_TYPECHECK(unsigned int *, w), EO_TYPECHECK(unsigned int *, h), EO_TYPECHECK(Eina_Bool *, has_alpha), EO_TYPECHECK(const unsigned char **, pixels)
94
95#define elm_app_server_package_get(ret) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_PACKAGE_GET), EO_TYPECHECK(Eina_Stringshare **, ret)
96
97#define elm_app_server_path_get(ret) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_PATH_GET), EO_TYPECHECK(const char **, ret)
98
99/**
100 * @def elm_app_server_views_get
101 * @since 1.8
102 *
103 * Return a iterator with all views of application
104 *
105 * @param[out] ret Iterator with all views of application, you must free
106 * iterator after use.
107 */
108#define elm_app_server_views_get(ret) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_VIEWS_GET), EO_TYPECHECK(Eina_Iterator **, ret)
109
110/**
111 * @def elm_app_server_view_check
112 * @since 1.8
113 *
114 * If view id is available and unique, return the full DBus object path of view
115 *
116 * @param[in] id view identifier
117 * @param[out] ret EINA_TRUE if id is valid or EINA_FALSE if not
118 */
119#define elm_app_server_view_check(id, ret) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_VIEW_CHECK), EO_TYPECHECK(const char *, id), EO_TYPECHECK(Eina_Bool *, ret)
120
121/**
122 * @def elm_app_server_view_add
123 * @since 1.8
124 *
125 * Add a view to elm_app_server.
126 * This should only be used if the application open a view
127 * that was not requested by create_view_cb.
128 *
129 * @param[in] view elm_app_server_view
130 */
131#define elm_app_server_view_add(view) ELM_APP_SERVER_ID(ELM_APP_SERVER_SUB_ID_VIEW_ADD), EO_TYPECHECK(Elm_App_Server_View *, view)
132
133/**
134 * Events
135 */
136extern const Eo_Event_Description _ELM_APP_SERVER_EV_TERMINATE;
137#define ELM_APP_SERVER_EV_TERMINATE (&(_ELM_APP_SERVER_EV_TERMINATE))
diff --git a/src/lib/elm_app_server_view.c b/src/lib/elm_app_server_view.c
new file mode 100644
index 000000000..e734540bf
--- /dev/null
+++ b/src/lib/elm_app_server_view.c
@@ -0,0 +1,526 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6#include "elm_priv.h"
7
8EAPI Eo_Op ELM_APP_SERVER_VIEW_BASE_ID = EO_NOOP;
9
10#define MY_CLASS ELM_APP_SERVER_VIEW_CLASS
11
12#define MY_CLASS_NAME "elm_app_server_view"
13
14EAPI const Eo_Event_Description _ELM_APP_SERVER_VIEW_EV_RESUMED =
15 EO_EVENT_DESCRIPTION("resume", "Called when view must be resumed");
16
17EAPI const Eo_Event_Description _ELM_APP_SERVER_VIEW_EV_PAUSED =
18 EO_EVENT_DESCRIPTION("paused", "Called when view must be paused");
19
20EAPI const Eo_Event_Description _ELM_APP_SERVER_VIEW_EV_CLOSED =
21 EO_EVENT_DESCRIPTION("closed", "Called when view must be closed");
22
23EAPI const Eo_Event_Description _ELM_APP_SERVER_VIEW_EV_SHALLOW =
24 EO_EVENT_DESCRIPTION("shallow", "Called when view state is set to shallow");
25
26EAPI const Eo_Event_Description _ELM_APP_SERVER_VIEW_EV_SAVE =
27 EO_EVENT_DESCRIPTION("save", "Called when view state should be saved");
28
29typedef struct
30{
31 Eldbus_Connection *conn;
32 Eldbus_Service_Interface *iface;
33
34 Eina_Stringshare *id;
35 Eina_Stringshare *title;
36 Eina_Stringshare *icon_name;
37 int new_events;
38 short progress;
39 Elm_App_View_State state;
40 int window_id;
41 struct {
42 unsigned int w, h;
43 Eina_Bool has_alpha;
44 unsigned char *raw;
45 } image_raw;
46} Elm_App_Server_View_Data;
47
48static void
49_state_set(Elm_App_Server_View_Data *data, Elm_App_View_State state)
50{
51 if (data->state != state)
52 eldbus_service_property_changed(data->iface, "State");
53 data->state = state;
54}
55
56static Eldbus_Message *
57_method_close(const Eldbus_Service_Interface *iface, const Eldbus_Message *message)
58{
59 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
60 Elm_App_Server_View_Data *data = eo_data_scope_get(eo, MY_CLASS);
61
62 _state_set(data, ELM_APP_VIEW_STATE_CLOSED);
63 eo_do(eo, eo_event_callback_call(ELM_APP_SERVER_VIEW_EV_CLOSED, NULL, NULL));
64
65 return eldbus_message_method_return_new(message);
66}
67
68static Eldbus_Message *
69_method_pause(const Eldbus_Service_Interface *iface, const Eldbus_Message *message)
70{
71 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
72 Elm_App_Server_View_Data *data = eo_data_scope_get(eo, MY_CLASS);
73
74 _state_set(data, ELM_APP_VIEW_STATE_PAUSED);
75 eo_do(eo, eo_event_callback_call(ELM_APP_SERVER_VIEW_EV_PAUSED, NULL, NULL));
76
77 return eldbus_message_method_return_new(message);
78}
79
80static Eldbus_Message *
81_method_resume(const Eldbus_Service_Interface *iface, const Eldbus_Message *message)
82{
83 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
84 Elm_App_Server_View_Data *data = eo_data_scope_get(eo, MY_CLASS);
85
86 _state_set(data, ELM_APP_VIEW_STATE_LIVE);
87 eo_do(eo, eo_event_callback_call(ELM_APP_SERVER_VIEW_EV_RESUMED, NULL, NULL));
88
89 return eldbus_message_method_return_new(message);
90}
91
92static const Eldbus_Method _methods[] = {
93 { "Close", NULL, NULL, _method_close, 0 },
94 { "Pause", NULL, NULL, _method_pause, 0 },
95 { "Resume", NULL, NULL, _method_resume, 0 },
96 { NULL, NULL, NULL, NULL, 0 }
97};
98
99static Eina_Bool
100_prop_title_get(const Eldbus_Service_Interface *iface, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
101{
102 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
103 Elm_App_Server_View_Data *data = eo_data_scope_get(eo, MY_CLASS);
104
105 eldbus_message_iter_basic_append(iter, 's', data->title);
106 return EINA_TRUE;
107}
108
109static Eina_Bool
110_prop_icon_get(const Eldbus_Service_Interface *iface, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
111{
112 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
113 Elm_App_Server_View_Data *data = eo_data_scope_get(eo, MY_CLASS);
114
115 eldbus_message_iter_basic_append(iter, 's', data->icon_name);
116 return EINA_TRUE;
117}
118
119/*static Eina_Bool
120_prop_icon_pixels_get(const Eldbus_Service_Interface *iface, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
121{
122 //TODO
123 return EINA_FALSE;
124}*/
125
126static Eina_Bool
127_prop_events_get(const Eldbus_Service_Interface *iface, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
128{
129 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
130 Elm_App_Server_View_Data *data = eo_data_scope_get(eo, MY_CLASS);
131
132 eldbus_message_iter_basic_append(iter, 'i', data->new_events);
133 return EINA_TRUE;
134}
135
136static Eina_Bool
137_prop_progress_get(const Eldbus_Service_Interface *iface, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
138{
139 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
140 Elm_App_Server_View_Data *data = eo_data_scope_get(eo, MY_CLASS);
141
142 eldbus_message_iter_basic_append(iter, 'n', data->progress);
143 return EINA_TRUE;
144}
145
146static Eina_Bool
147_prop_state_get(const Eldbus_Service_Interface *iface, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
148{
149 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
150 Elm_App_Server_View_Data *data = eo_data_scope_get(eo, MY_CLASS);
151
152 eldbus_message_iter_basic_append(iter, 's', _state_id_to_string(data->state));
153 return EINA_TRUE;
154}
155
156static Eina_Bool
157_prop_window_get(const Eldbus_Service_Interface *iface, const char *propname EINA_UNUSED, Eldbus_Message_Iter *iter, const Eldbus_Message *request_msg EINA_UNUSED, Eldbus_Message **error EINA_UNUSED)
158{
159 Eo *eo = eldbus_service_object_data_get(iface, MY_CLASS_NAME);
160 Elm_App_Server_View_Data *data = eo_data_scope_get(eo, MY_CLASS);
161
162 eldbus_message_iter_basic_append(iter, 'i', data->window_id);
163 return EINA_TRUE;
164}
165
166static const Eldbus_Property _props[] = {
167 { "Title", "s", _prop_title_get, NULL, 0 },
168 { "IconName", "s", _prop_icon_get, NULL, 0 },
169 //{ "IconPixels", "(uubay)", _prop_icon_pixels_get, NULL, 0 },
170 { "NewEvents", "i", _prop_events_get, NULL, 0 },
171 { "Progress", "n", _prop_progress_get, NULL, 0 },
172 { "State", "s", _prop_state_get, NULL, 0 },
173 { "WindowId", "i", _prop_window_get, NULL, 0 },
174 { NULL, NULL, NULL, NULL, 0 }
175};
176
177static const Eldbus_Signal _signals[] = {
178 { "Result", ELDBUS_ARGS({"a{sv}", "arguments"}), 0 },
179 { NULL, NULL, 0}
180};
181
182static const Eldbus_Service_Interface_Desc iface_desc = {
183 "org.enlightenment.ApplicationView1", _methods, _signals, _props, NULL, NULL
184};
185
186static void
187_resume(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
188{
189 Elm_App_Server_View_Data *data = _pd;
190
191 _state_set(data, ELM_APP_VIEW_STATE_LIVE);
192 eo_do(obj, eo_event_callback_call(ELM_APP_SERVER_VIEW_EV_RESUMED, NULL, NULL));
193}
194
195static void
196_pause(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
197{
198 Elm_App_Server_View_Data *data = _pd;
199
200 _state_set(data, ELM_APP_VIEW_STATE_PAUSED);
201 eo_do(obj, eo_event_callback_call(ELM_APP_SERVER_VIEW_EV_PAUSED, NULL, NULL));
202}
203
204static void
205_close(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
206{
207 Elm_App_Server_View_Data *data = _pd;
208
209 _state_set(data, ELM_APP_VIEW_STATE_CLOSED);
210 eo_do(obj, eo_event_callback_call(ELM_APP_SERVER_VIEW_EV_CLOSED, NULL, NULL));
211}
212
213static void
214_shallow(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
215{
216 Elm_App_Server_View_Data *data = _pd;
217
218 _state_set(data, ELM_APP_VIEW_STATE_SHALLOW);
219 eo_do(obj, eo_event_callback_call(ELM_APP_SERVER_VIEW_EV_SHALLOW, NULL, NULL));
220}
221
222static void
223_state_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
224{
225 Elm_App_Server_View_Data *data = _pd;
226 Elm_App_View_State *ret = va_arg(*list, Elm_App_View_State *);
227 *ret = data->state;
228}
229
230static void
231_window_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
232{
233 Elm_App_Server_View_Data *data = _pd;
234 Evas_Object *win = va_arg(*list, Evas_Object *);
235 int before = data->window_id;
236
237 data->window_id = elm_win_window_id_get(win);
238
239 if (data->window_id != before)
240 eldbus_service_property_changed(data->iface, "WindowId");
241}
242
243static void
244_title_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
245{
246 Elm_App_Server_View_Data *data = _pd;
247 const char *title = va_arg(*list, const char *);
248
249 title = title ? title : "";
250
251 if (eina_stringshare_replace(&data->title, title))
252 eldbus_service_property_changed(data->iface, "Title");
253}
254
255static void
256_title_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
257{
258 Elm_App_Server_View_Data *data = _pd;
259 const char **ret = va_arg(*list, const char **);
260 *ret = data->title;
261}
262
263static void
264_icon_name_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
265{
266 Elm_App_Server_View_Data *data = _pd;
267 const char *icon = va_arg(*list, const char *);
268
269 icon = icon ? icon : "";
270
271 if (eina_stringshare_replace(&data->icon_name, icon))
272 eldbus_service_property_changed(data->iface, "IconName");
273}
274
275static void
276_icon_name_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
277{
278 Elm_App_Server_View_Data *data = _pd;
279 const char **ret = va_arg(*list, const char **);
280 *ret = data->icon_name;
281}
282
283static void
284_icon_pixels_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
285{
286 Elm_App_Server_View_Data *data = _pd;
287 //TODO
288 eldbus_service_property_changed(data->iface, "IconPixels");
289}
290
291static void
292_icon_pixels_get(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
293{
294 //TODO
295}
296
297static void
298_progress_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
299{
300 Elm_App_Server_View_Data *data = _pd;
301 short progress = va_arg(*list, int);
302
303 if (data->progress != progress)
304 eldbus_service_property_changed(data->iface, "Progress");
305 data->progress = progress;
306}
307
308static void
309_progress_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
310{
311 Elm_App_Server_View_Data *data = _pd;
312 short *ret = va_arg(*list, short *);
313
314 *ret = data->progress;
315}
316
317static void
318_new_events_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
319{
320 Elm_App_Server_View_Data *data = _pd;
321 int events = va_arg(*list, int);
322
323 if (data->new_events != events)
324 eldbus_service_property_changed(data->iface, "NewEvents");
325 data->new_events = events;
326}
327
328static void
329_new_events_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
330{
331 Elm_App_Server_View_Data *data = _pd;
332 int *ret = va_arg(*list, int *);
333
334 *ret = data->new_events;
335}
336
337static void
338_id_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
339{
340 Elm_App_Server_View_Data *data = _pd;
341 Eina_Stringshare **ret = va_arg(*list, Eina_Stringshare **);
342
343 *ret = data->id;
344}
345
346static void
347_path_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
348{
349 Elm_App_Server_View_Data *data = _pd;
350 const char **ret = va_arg(*list, const char **);
351
352 *ret = eldbus_service_object_path_get(data->iface);
353}
354
355static void
356_app_server_view_constructor(Eo *obj, void *_pd, va_list *list)
357{
358 Elm_App_Server_View_Data *data = _pd;
359 Elm_App_Server *server;
360 const char *id = va_arg(*list, const char *), *server_path;
361 char view_path[PATH_MAX];
362
363 eo_do_super(obj, MY_CLASS, eo_constructor());
364
365 server = eo_parent_get(obj);
366 EINA_SAFETY_ON_TRUE_GOTO(!server || !eo_isa(server, ELM_APP_SERVER_CLASS), error);
367
368 if (!id)
369 {
370 int i;
371 for (i = 1; i < 99999; i++)
372 {
373 char buf[64];
374 Eina_Bool valid;
375
376 snprintf(buf, sizeof(buf), "view_%d", i);
377 eo_do(server, elm_app_server_view_check(buf, &valid));
378 if (valid)
379 {
380 data->id = eina_stringshare_add(buf);
381 break;
382 }
383 }
384 }
385 else
386 {
387 Eina_Bool valid;
388 eo_do(server, elm_app_server_view_check(id, &valid));
389 if (valid)
390 data->id = eina_stringshare_add(id);
391 }
392
393 EINA_SAFETY_ON_NULL_GOTO(data->id, error);
394
395 eo_do(server, elm_app_server_path_get(&server_path));
396 snprintf(view_path, sizeof(view_path), "%s/%s", server_path, data->id);
397
398 eldbus_init();
399 data->conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
400 data->iface = eldbus_service_interface_register(data->conn, view_path,
401 &iface_desc);
402 eldbus_service_object_data_set(data->iface, MY_CLASS_NAME, obj);
403
404 data->state = ELM_APP_VIEW_STATE_UNKNOWN;
405 data->title = eina_stringshare_add("");
406 data->icon_name = eina_stringshare_add("");
407
408 return;
409
410error:
411 eo_error_set(obj);
412}
413
414static void
415_destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
416{
417 Elm_App_Server_View_Data *data = _pd;
418
419 eina_stringshare_del(data->title);
420 eina_stringshare_del(data->icon_name);
421
422 eina_stringshare_del(data->id);
423 eldbus_service_object_unregister(data->iface);
424 eldbus_connection_unref(data->conn);
425 eldbus_shutdown();
426
427 eo_do_super(obj, MY_CLASS, eo_destructor());
428}
429
430static void
431_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
432{
433 eo_error_set(obj);
434 ERR("Only custom constructor can be used with '%s' class", MY_CLASS_NAME);
435}
436
437static void
438_class_constructor(Eo_Class *klass)
439{
440 const Eo_Op_Func_Description func_desc[] = {
441 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
442 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
443 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_CONSTRUCTOR), _app_server_view_constructor),
444 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_RESUME), _resume),
445 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_PAUSE), _pause),
446 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_CLOSE), _close),
447 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_SHALLOW), _shallow),
448 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_STATE_GET), _state_get),
449 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_WINDOW_SET), _window_set),
450 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_TITLE_SET), _title_set),
451 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_TITLE_GET), _title_get),
452 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_ICON_NAME_SET), _icon_name_set),
453 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_ICON_NAME_GET), _icon_name_get),
454 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_ICON_PIXELS_SET), _icon_pixels_set),
455 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_ICON_PIXELS_GET), _icon_pixels_get),
456 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_PROGRESS_SET), _progress_set),
457 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_PROGRESS_GET), _progress_get),
458 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_NEW_EVENTS_SET), _new_events_set),
459 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_NEW_EVENTS_GET), _new_events_get),
460 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_ID_GET), _id_get),
461 EO_OP_FUNC(ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_PATH_GET), _path_get),
462 EO_OP_FUNC_SENTINEL
463 };
464 eo_class_funcs_set(klass, func_desc);
465}
466
467static const Eo_Op_Description op_desc[] = {
468 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_CONSTRUCTOR,
469 "Constructor of elm_app_server_view."),
470 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_RESUME, "Resume view."),
471 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_PAUSE, "Pause view."),
472 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_CLOSE, "Close view."),
473 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_SHALLOW,
474 "Shallow view, that means that view is open but dont have a window(X or Wayland)."),
475 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_STATE_GET,
476 "Get state of view."),
477 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_WINDOW_SET,
478 "Set window of view."),
479 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_TITLE_SET,
480 "Set title of view."),
481 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_TITLE_GET,
482 "Get title of view."),
483 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_ICON_NAME_SET,
484 "Set icon name or path of view."),
485 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_ICON_NAME_GET,
486 "Get icon name or path of view."),
487 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_ICON_PIXELS_SET,
488 "Set icon to view, using the raw pixels of image."),
489 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_ICON_PIXELS_GET,
490 "Get raw icon of view."),
491 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_PROGRESS_SET,
492 "Set progress of view."),
493 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_PROGRESS_GET,
494 "Get progress of view."),
495 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_NEW_EVENTS_SET,
496 "Set new events of view."),
497 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_NEW_EVENTS_GET,
498 "Get events of view."),
499 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_ID_GET,
500 "Get view identifier."),
501 EO_OP_DESCRIPTION(ELM_APP_SERVER_VIEW_SUB_ID_PATH_GET,
502 "Get view DBus path."),
503 EO_OP_DESCRIPTION_SENTINEL
504};
505
506static const Eo_Event_Description *event_desc[] = {
507 ELM_APP_SERVER_VIEW_EV_RESUMED,
508 ELM_APP_SERVER_VIEW_EV_PAUSED,
509 ELM_APP_SERVER_VIEW_EV_CLOSED,
510 ELM_APP_SERVER_VIEW_EV_SHALLOW,
511 ELM_APP_SERVER_VIEW_EV_SAVE,
512 NULL
513};
514
515static const Eo_Class_Description class_desc = {
516 EO_VERSION,
517 MY_CLASS_NAME,
518 EO_CLASS_TYPE_REGULAR,
519 EO_CLASS_DESCRIPTION_OPS(&ELM_APP_SERVER_VIEW_BASE_ID, op_desc, ELM_APP_SERVER_VIEW_SUB_ID_LAST),
520 event_desc,
521 sizeof(Elm_App_Server_View_Data),
522 _class_constructor,
523 NULL
524};
525
526EO_DEFINE_CLASS(elm_app_server_view_class_get, &class_desc, EO_BASE_CLASS, NULL);
diff --git a/src/lib/elm_app_server_view.h b/src/lib/elm_app_server_view.h
new file mode 100644
index 000000000..9b6789e68
--- /dev/null
+++ b/src/lib/elm_app_server_view.h
@@ -0,0 +1,3 @@
1#ifdef EFL_EO_API_SUPPORT
2#include "elm_app_server_view_eo.h"
3#endif
diff --git a/src/lib/elm_app_server_view_eo.h b/src/lib/elm_app_server_view_eo.h
new file mode 100644
index 000000000..48ec32ed5
--- /dev/null
+++ b/src/lib/elm_app_server_view_eo.h
@@ -0,0 +1,97 @@
1#define ELM_APP_SERVER_VIEW_CLASS elm_app_server_view_class_get()
2
3const Eo_Class *elm_app_server_view_class_get(void) EINA_CONST;
4
5extern EAPI Eo_Op ELM_APP_SERVER_VIEW_BASE_ID;
6
7enum
8{
9 ELM_APP_SERVER_VIEW_SUB_ID_CONSTRUCTOR,
10 ELM_APP_SERVER_VIEW_SUB_ID_RESUME,
11 ELM_APP_SERVER_VIEW_SUB_ID_PAUSE,
12 ELM_APP_SERVER_VIEW_SUB_ID_CLOSE,
13 ELM_APP_SERVER_VIEW_SUB_ID_SHALLOW,
14 ELM_APP_SERVER_VIEW_SUB_ID_STATE_GET,
15 ELM_APP_SERVER_VIEW_SUB_ID_WINDOW_SET,
16 ELM_APP_SERVER_VIEW_SUB_ID_TITLE_SET,
17 ELM_APP_SERVER_VIEW_SUB_ID_TITLE_GET,
18 ELM_APP_SERVER_VIEW_SUB_ID_ICON_NAME_SET,
19 ELM_APP_SERVER_VIEW_SUB_ID_ICON_NAME_GET,
20 ELM_APP_SERVER_VIEW_SUB_ID_ICON_PIXELS_SET,
21 ELM_APP_SERVER_VIEW_SUB_ID_ICON_PIXELS_GET,
22 ELM_APP_SERVER_VIEW_SUB_ID_PROGRESS_SET,
23 ELM_APP_SERVER_VIEW_SUB_ID_PROGRESS_GET,
24 ELM_APP_SERVER_VIEW_SUB_ID_NEW_EVENTS_SET,
25 ELM_APP_SERVER_VIEW_SUB_ID_NEW_EVENTS_GET,
26 ELM_APP_SERVER_VIEW_SUB_ID_ID_GET,
27 ELM_APP_SERVER_VIEW_SUB_ID_PATH_GET,
28 ELM_APP_SERVER_VIEW_SUB_ID_LAST
29};
30
31#define ELM_APP_SERVER_VIEW_ID(sub_id) (ELM_APP_SERVER_VIEW_BASE_ID + sub_id)
32
33/**
34 * @def elm_app_server_view_constructor
35 * @since 1.8
36 *
37 * Class constructor of elm_app_server_view
38 *
39 * @param[in] id identifier of view
40 *
41 * @note You must supply the elm_app_server as parent.
42 */
43#define elm_app_server_view_constructor(id) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_CONSTRUCTOR), EO_TYPECHECK(const char *, id)
44
45#define elm_app_server_view_resume() ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_RESUME)
46
47#define elm_app_server_view_pause() ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_PAUSE)
48
49#define elm_app_server_view_close() ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_CLOSE)
50
51#define elm_app_server_view_shallow() ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_SHALLOW)
52
53#define elm_app_server_view_state_get(ret) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_STATE_GET), EO_TYPECHECK(Elm_App_View_State *, ret)
54
55#define elm_app_server_view_window_set(win) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_WINDOW_SET), EO_TYPECHECK(Evas_Object *, win)
56
57#define elm_app_server_view_title_set(title) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_TITLE_SET), EO_TYPECHECK(const char *, title)
58
59#define elm_app_server_view_title_get(ret) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_TITLE_GET), EO_TYPECHECK(const char **, ret)
60
61#define elm_app_server_view_icon_set(icon) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_ICON_NAME_SET), EO_TYPECHECK(const char *, icon)
62
63#define elm_app_server_view_icon_get(ret) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_ICON_NAME_GET), EO_TYPECHECK(const char **, ret)
64
65#define elm_app_server_view_icon_pixels_set(w, h, has_alpha, pixels) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_ICON_PIXELS_SET), EO_TYPECHECK(unsigned int, w), EO_TYPE_CHECK(unsigned int, h), EO_TYPE_CHECK(Eina_Bool, has_alpha), EO_TYPE_CHECK(const unsigned char *, pixels)
66
67#define elm_app_server_view_icon_pixels_get(w, h, has_alpha, pixels) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_ICON_PIXELS_GET), EO_TYPECHECK(unsigned int *, w), EO_TYPE_CHECK(unsigned int *, h), EO_TYPE_CHECK(Eina_Bool *, has_alpha), EO_TYPE_CHECK(const unsigned char **, pixels)
68
69#define elm_app_server_view_progress_set(progress) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_PROGRESS_SET), EO_TYPECHECK(short, progress)
70
71#define elm_app_server_view_progress_get(ret) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_PROGRESS_GET), EO_TYPECHECK(short *, ret)
72
73#define elm_app_server_view_new_events_set(events) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_NEW_EVENTS_SET), EO_TYPECHECK(int, events)
74
75#define elm_app_server_view_new_events_get(ret) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_NEW_EVENTS_GET), EO_TYPECHECK(int *, ret)
76
77#define elm_app_server_view_id_get(ret) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_ID_GET), EO_TYPECHECK(Eina_Stringshare **, ret)
78
79#define elm_app_server_view_path_get(ret) ELM_APP_SERVER_VIEW_ID(ELM_APP_SERVER_VIEW_SUB_ID_PATH_GET), EO_TYPECHECK(const char **, ret)
80
81/**
82 * Events
83 */
84extern const Eo_Event_Description _ELM_APP_SERVER_VIEW_EV_RESUMED;
85#define ELM_APP_SERVER_VIEW_EV_RESUMED (&(_ELM_APP_SERVER_VIEW_EV_RESUMED))
86
87extern const Eo_Event_Description _ELM_APP_SERVER_VIEW_EV_PAUSED;
88#define ELM_APP_SERVER_VIEW_EV_PAUSED (&(_ELM_APP_SERVER_VIEW_EV_PAUSED))
89
90extern const Eo_Event_Description _ELM_APP_SERVER_VIEW_EV_CLOSED;
91#define ELM_APP_SERVER_VIEW_EV_CLOSED (&(_ELM_APP_SERVER_VIEW_EV_CLOSED))
92
93extern const Eo_Event_Description _ELM_APP_SERVER_VIEW_EV_SHALLOW;
94#define ELM_APP_SERVER_VIEW_EV_SHALLOW (&(_ELM_APP_SERVER_VIEW_EV_SHALLOW))
95
96extern const Eo_Event_Description _ELM_APP_SERVER_VIEW_EV_SAVE;
97#define ELM_APP_SERVER_VIEW_EV_SAVE (&(_ELM_APP_SERVER_VIEW_EV_SAVE))