summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-06-22 18:55:54 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-06-22 18:55:57 +0200
commit12257053a0f428b88df913ac3a00fdaa5b366ed2 (patch)
treee40a1dd22ba17db18e6d3bd8441b45460ad98ec5
parenta3c7a831960e679d36b6c1fa443fc9642c243914 (diff)
ecore_con: eoifying ecore_con_eet.
Summary: This is still work in progress. I've added new file for temporary purpose. Idea is to first eoify everything then change its namespace properly. Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com> Reviewers: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2602 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/Makefile_Ecore_Con.am3
-rw-r--r--src/lib/ecore_con/Ecore_Con_Eet.h9
-rw-r--r--src/lib/ecore_con/Ecore_Con_Eet_Eo.h3
-rw-r--r--src/lib/ecore_con/Ecore_Con_Eet_Legacy.h3
-rw-r--r--src/lib/ecore_con/ecore_con_eet.c487
-rw-r--r--src/lib/ecore_con/ecore_con_eet_base.eo23
-rw-r--r--src/lib/ecore_con/ecore_con_eet_client_obj.eo9
-rw-r--r--src/lib/ecore_con/ecore_con_eet_server_obj.eo9
8 files changed, 358 insertions, 188 deletions
diff --git a/src/Makefile_Ecore_Con.am b/src/Makefile_Ecore_Con.am
index caafdfa..d185cf8 100644
--- a/src/Makefile_Ecore_Con.am
+++ b/src/Makefile_Ecore_Con.am
@@ -6,6 +6,9 @@ ecore_con_eolian_files = \
6 lib/ecore_con/ecore_con_client.eo \ 6 lib/ecore_con/ecore_con_client.eo \
7 lib/ecore_con/ecore_con_server.eo \ 7 lib/ecore_con/ecore_con_server.eo \
8 lib/ecore_con/ecore_con_connector.eo \ 8 lib/ecore_con/ecore_con_connector.eo \
9 lib/ecore_con/ecore_con_eet_base.eo \
10 lib/ecore_con/ecore_con_eet_server_obj.eo \
11 lib/ecore_con/ecore_con_eet_client_obj.eo \
9 lib/ecore_con/efl_network_url.eo 12 lib/ecore_con/efl_network_url.eo
10 13
11ecore_con_eolian_c = $(ecore_con_eolian_files:%.eo=%.eo.c) 14ecore_con_eolian_c = $(ecore_con_eolian_files:%.eo=%.eo.c)
diff --git a/src/lib/ecore_con/Ecore_Con_Eet.h b/src/lib/ecore_con/Ecore_Con_Eet.h
index a6c52bd..a85948c 100644
--- a/src/lib/ecore_con/Ecore_Con_Eet.h
+++ b/src/lib/ecore_con/Ecore_Con_Eet.h
@@ -43,7 +43,7 @@
43 * @{ 43 * @{
44 */ 44 */
45 45
46typedef struct _Ecore_Con_Eet Ecore_Con_Eet; 46typedef Eo Ecore_Con_Eet;
47typedef struct _Ecore_Con_Reply Ecore_Con_Reply; 47typedef struct _Ecore_Con_Reply Ecore_Con_Reply;
48 48
49/** 49/**
@@ -70,6 +70,13 @@ typedef Eina_Bool (*Ecore_Con_Eet_Client_Cb)(void *data, Ecore_Con_Reply *reply,
70 */ 70 */
71typedef Eina_Bool (*Ecore_Con_Eet_Server_Cb)(void *data, Ecore_Con_Reply *reply, Ecore_Con_Server *conn); 71typedef Eina_Bool (*Ecore_Con_Eet_Server_Cb)(void *data, Ecore_Con_Reply *reply, Ecore_Con_Server *conn);
72 72
73#ifndef EFL_NOLEGACY_API_SUPPORT
74#include "Ecore_Con_Eet_Legacy.h"
75#endif
76#ifdef EFL_EO_API_SUPPORT
77#include "Ecore_Con_Eet_Eo.h"
78#endif
79
73/** 80/**
74 * Create a Ecore_Con_Eet server. 81 * Create a Ecore_Con_Eet server.
75 * 82 *
diff --git a/src/lib/ecore_con/Ecore_Con_Eet_Eo.h b/src/lib/ecore_con/Ecore_Con_Eet_Eo.h
new file mode 100644
index 0000000..52b1a4b
--- /dev/null
+++ b/src/lib/ecore_con/Ecore_Con_Eet_Eo.h
@@ -0,0 +1,3 @@
1#include "ecore_con_eet_base.eo.h"
2#include "ecore_con_eet_server_obj.eo.h"
3#include "ecore_con_eet_client_obj.eo.h"
diff --git a/src/lib/ecore_con/Ecore_Con_Eet_Legacy.h b/src/lib/ecore_con/Ecore_Con_Eet_Legacy.h
new file mode 100644
index 0000000..3404728
--- /dev/null
+++ b/src/lib/ecore_con/Ecore_Con_Eet_Legacy.h
@@ -0,0 +1,3 @@
1#include "ecore_con_eet_base.eo.legacy.h"
2#include "ecore_con_eet_client_obj.eo.legacy.h"
3#include "ecore_con_eet_server_obj.eo.legacy.h"
diff --git a/src/lib/ecore_con/ecore_con_eet.c b/src/lib/ecore_con/ecore_con_eet.c
index eb335ce..d2bbd28 100644
--- a/src/lib/ecore_con/ecore_con_eet.c
+++ b/src/lib/ecore_con/ecore_con_eet.c
@@ -21,11 +21,36 @@
21 21
22#define ECORE_CON_EET_RAW_MAGIC 0xDEAD007 22#define ECORE_CON_EET_RAW_MAGIC 0xDEAD007
23 23
24typedef struct _Ecore_Con_Eet_Base_Data Ecore_Con_Eet_Base_Data;
25typedef struct _Ecore_Con_Eet_Server_Obj_Data Ecore_Con_Eet_Server_Obj_Data;
26typedef struct _Ecore_Con_Eet_Client_Obj_Data Ecore_Con_Eet_Client_Obj_Data;
24typedef struct _Ecore_Con_Eet_Data Ecore_Con_Eet_Data; 27typedef struct _Ecore_Con_Eet_Data Ecore_Con_Eet_Data;
25typedef struct _Ecore_Con_Eet_Raw_Data Ecore_Con_Eet_Raw_Data; 28typedef struct _Ecore_Con_Eet_Raw_Data Ecore_Con_Eet_Raw_Data;
26typedef struct _Ecore_Con_Eet_Client Ecore_Con_Eet_Client; 29typedef struct _Ecore_Con_Eet_Client Ecore_Con_Eet_Client;
27typedef struct _Ecore_Con_Eet_Server Ecore_Con_Eet_Server; 30typedef struct _Ecore_Con_Eet_Server Ecore_Con_Eet_Server;
28 31
32struct _Ecore_Con_Eet_Server_Obj_Data
33{
34 Eina_List *connections;
35 Eina_List *client_connect_callbacks;
36 Eina_List *client_disconnect_callbacks;
37
38 Ecore_Event_Handler *handler_add;
39 Ecore_Event_Handler *handler_del;
40 Ecore_Event_Handler *handler_data;
41};
42
43struct _Ecore_Con_Eet_Client_Obj_Data
44{
45 Ecore_Con_Reply *r;
46 Eina_List *server_connect_callbacks;
47 Eina_List *server_disconnect_callbacks;
48
49 Ecore_Event_Handler *handler_add;
50 Ecore_Event_Handler *handler_del;
51 Ecore_Event_Handler *handler_data;
52};
53
29struct _Ecore_Con_Reply 54struct _Ecore_Con_Reply
30{ 55{
31 Ecore_Con_Eet *ece; 56 Ecore_Con_Eet *ece;
@@ -66,39 +91,17 @@ struct _Ecore_Con_Eet_Server
66 const void *data; 91 const void *data;
67}; 92};
68 93
69struct _Ecore_Con_Eet 94struct _Ecore_Con_Eet_Base_Data
70{ 95{
71 Ecore_Con_Server *server; 96 Ecore_Con_Server *server;
72 97
73 Ecore_Event_Handler *handler_add;
74 Ecore_Event_Handler *handler_del;
75 Ecore_Event_Handler *handler_data;
76
77 Eet_Data_Descriptor *edd; 98 Eet_Data_Descriptor *edd;
78 Eet_Data_Descriptor *matching; 99 Eet_Data_Descriptor *matching;
79 100
80 Eina_Hash *data_callbacks; 101 Eina_Hash *data_callbacks;
81 Eina_Hash *raw_data_callbacks; 102 Eina_Hash *raw_data_callbacks;
82 103
83 union
84 {
85 struct
86 {
87 Eina_List *connections;
88 Eina_List *client_connect_callbacks;
89 Eina_List *client_disconnect_callbacks;
90 } server;
91 struct
92 {
93 Ecore_Con_Reply *r;
94 Eina_List *server_connect_callbacks;
95 Eina_List *server_disconnect_callbacks;
96 } client;
97 } u;
98
99 const void *data; 104 const void *data;
100
101 Eina_Bool client : 1;
102}; 105};
103 106
104static void 107static void
@@ -154,7 +157,7 @@ _ecore_con_eet_data_type_set(const char *type, void *data, Eina_Bool unknow EINA
154} 157}
155 158
156static void 159static void
157_ecore_con_eet_data_descriptor_setup(Ecore_Con_Eet *ece) 160_ecore_con_eet_data_descriptor_setup(Ecore_Con_Eet_Base_Data *ece)
158{ 161{
159 Eet_Data_Descriptor_Class eddc; 162 Eet_Data_Descriptor_Class eddc;
160 163
@@ -176,11 +179,12 @@ _ecore_con_eet_read_cb(const void *eet_data, size_t size, void *user_data)
176 Ecore_Con_Reply *n = user_data; 179 Ecore_Con_Reply *n = user_data;
177 Ecore_Con_Eet_Protocol *protocol; 180 Ecore_Con_Eet_Protocol *protocol;
178 Ecore_Con_Eet_Data *cb; 181 Ecore_Con_Eet_Data *cb;
182 Ecore_Con_Eet_Base_Data *ece_data = eo_data_scope_get(n->ece, ECORE_CON_EET_BASE_CLASS);
179 183
180 protocol = eet_data_descriptor_decode(n->ece->edd, eet_data, size); 184 protocol = eet_data_descriptor_decode(ece_data->edd, eet_data, size);
181 if (!protocol) return EINA_TRUE; 185 if (!protocol) return EINA_TRUE;
182 186
183 cb = eina_hash_find(n->ece->data_callbacks, protocol->type); 187 cb = eina_hash_find(ece_data->data_callbacks, protocol->type);
184 if (!cb) return EINA_TRUE; /* Should I report unknow protocol communication ? */ 188 if (!cb) return EINA_TRUE; /* Should I report unknow protocol communication ? */
185 189
186 cb->func((void *)cb->data, n, cb->name, protocol->data); 190 cb->func((void *)cb->data, n, cb->name, protocol->data);
@@ -205,9 +209,11 @@ static Eina_Bool
205_ecore_con_eet_client_write_cb(const void *data, size_t size, void *user_data) 209_ecore_con_eet_client_write_cb(const void *data, size_t size, void *user_data)
206{ 210{
207 Ecore_Con_Reply *n = user_data; 211 Ecore_Con_Reply *n = user_data;
212 Ecore_Con_Eet_Base_Data *ece_data = eo_data_scope_get(n->ece, ECORE_CON_EET_BASE_CLASS);
208 213
209 if (ecore_con_server_send(n->ece->server, data, size) != (int)size) 214 if (ecore_con_server_send(ece_data->server, data, size) != (int)size)
210 return EINA_FALSE; 215 return EINA_FALSE;
216
211 return EINA_TRUE; 217 return EINA_TRUE;
212} 218}
213 219
@@ -216,21 +222,23 @@ _ecore_con_eet_server_connected(void *data, int type EINA_UNUSED, Ecore_Con_Even
216{ 222{
217 Ecore_Con_Eet_Client *ecec; 223 Ecore_Con_Eet_Client *ecec;
218 Eina_List *ll; 224 Eina_List *ll;
219 Ecore_Con_Eet *r = data;
220 Ecore_Con_Reply *n; 225 Ecore_Con_Reply *n;
226 Ecore_Con_Eet *ece_obj = data;
227 Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece_obj, ECORE_CON_EET_BASE_CLASS);
228 Ecore_Con_Eet_Server_Obj_Data *r = eo_data_scope_get(ece_obj, ECORE_CON_EET_SERVER_OBJ_CLASS);
221 229
222 if (ecore_con_client_server_get(ev->client) != r->server) 230 if (ecore_con_client_server_get(ev->client) != base_data->server)
223 return EINA_TRUE; 231 return EINA_TRUE;
224 232
225 n = calloc(1, sizeof (Ecore_Con_Reply)); 233 n = calloc(1, sizeof (Ecore_Con_Reply));
226 if (!n) return EINA_TRUE; 234 if (!n) return EINA_TRUE;
227 235
228 n->client = ev->client; 236 n->client = ev->client;
229 n->ece = r; 237 n->ece = ece_obj;
230 n->econn = eet_connection_new(_ecore_con_eet_read_cb, _ecore_con_eet_server_write_cb, n); 238 n->econn = eet_connection_new(_ecore_con_eet_read_cb, _ecore_con_eet_server_write_cb, n);
231 ecore_con_client_data_set(n->client, n); 239 ecore_con_client_data_set(n->client, n);
232 240
233 EINA_LIST_FOREACH(r->u.server.client_connect_callbacks, ll, ecec) 241 EINA_LIST_FOREACH(r->client_connect_callbacks, ll, ecec)
234 if (!ecec->func((void *)ecec->data, n, n->client)) 242 if (!ecec->func((void *)ecec->data, n, n->client))
235 { 243 {
236 eet_connection_close(n->econn, NULL); 244 eet_connection_close(n->econn, NULL);
@@ -238,7 +246,7 @@ _ecore_con_eet_server_connected(void *data, int type EINA_UNUSED, Ecore_Con_Even
238 return EINA_TRUE; 246 return EINA_TRUE;
239 } 247 }
240 248
241 r->u.server.connections = eina_list_append(r->u.server.connections, n); 249 r->connections = eina_list_append(r->connections, n);
242 250
243 return EINA_TRUE; 251 return EINA_TRUE;
244} 252}
@@ -246,25 +254,27 @@ _ecore_con_eet_server_connected(void *data, int type EINA_UNUSED, Ecore_Con_Even
246static Eina_Bool 254static Eina_Bool
247_ecore_con_eet_server_disconnected(void *data, int type EINA_UNUSED, Ecore_Con_Event_Client_Del *ev) 255_ecore_con_eet_server_disconnected(void *data, int type EINA_UNUSED, Ecore_Con_Event_Client_Del *ev)
248{ 256{
249 Ecore_Con_Eet *r = data; 257 Ecore_Con_Eet *ece_obj = data;
258 Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece_obj, ECORE_CON_EET_BASE_CLASS);
259 Ecore_Con_Eet_Server_Obj_Data *r = eo_data_scope_get(ece_obj, ECORE_CON_EET_SERVER_OBJ_CLASS);
250 Ecore_Con_Reply *n; 260 Ecore_Con_Reply *n;
251 Eina_List *l; 261 Eina_List *l;
252 262
253 if (ecore_con_client_server_get(ev->client) != r->server) 263 if (ecore_con_client_server_get(ev->client) != base_data->server)
254 return EINA_TRUE; 264 return EINA_TRUE;
255 265
256 EINA_LIST_FOREACH(r->u.server.connections, l, n) 266 EINA_LIST_FOREACH(r->connections, l, n)
257 if (n->client == ev->client) 267 if (n->client == ev->client)
258 { 268 {
259 Ecore_Con_Eet_Client *ecec; 269 Ecore_Con_Eet_Client *ecec;
260 Eina_List *ll; 270 Eina_List *ll;
261 271
262 EINA_LIST_FOREACH(r->u.server.client_disconnect_callbacks, ll, ecec) 272 EINA_LIST_FOREACH(r->client_disconnect_callbacks, ll, ecec)
263 ecec->func((void *)ecec->data, n, n->client); 273 ecec->func((void *)ecec->data, n, n->client);
264 274
265 eet_connection_close(n->econn, NULL); 275 eet_connection_close(n->econn, NULL);
266 free(n); 276 free(n);
267 r->u.server.connections = eina_list_remove_list(r->u.server.connections, l); 277 r->connections = eina_list_remove_list(r->connections, l);
268 return EINA_TRUE; 278 return EINA_TRUE;
269 } 279 }
270 280
@@ -317,6 +327,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, unsigned int size)
317 char *buffer = (char *)&tmp[4]; 327 char *buffer = (char *)&tmp[4];
318 char *protocol; 328 char *protocol;
319 char *section; 329 char *section;
330 Ecore_Con_Eet_Base_Data *eceb_data = eo_data_scope_get(n->ece,ECORE_CON_EET_BASE_CLASS);
320 331
321 protocol = buffer; 332 protocol = buffer;
322 section = buffer + protocol_length; 333 section = buffer + protocol_length;
@@ -327,7 +338,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, unsigned int size)
327 size -= protocol_length + section_length; 338 size -= protocol_length + section_length;
328 buffer = section + section_length; 339 buffer = section + section_length;
329 340
330 n->buffer_handler = eina_hash_find(n->ece->raw_data_callbacks, protocol); 341 n->buffer_handler = eina_hash_find(eceb_data->raw_data_callbacks, protocol);
331 n->buffer_section = strdup(section); 342 n->buffer_section = strdup(section);
332 n->buffer_length = data_length; 343 n->buffer_length = data_length;
333 n->buffer_current = 0; 344 n->buffer_current = 0;
@@ -356,7 +367,8 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, unsigned int size)
356static Eina_Bool 367static Eina_Bool
357_ecore_con_eet_server_data(void *data, int type EINA_UNUSED, Ecore_Con_Event_Client_Data *ev) 368_ecore_con_eet_server_data(void *data, int type EINA_UNUSED, Ecore_Con_Event_Client_Data *ev)
358{ 369{
359 Ecore_Con_Eet *r = data; 370 Ecore_Con_Eet *ece_obj = data;
371 Ecore_Con_Eet_Base_Data *r = eo_data_scope_get(ece_obj, ECORE_CON_EET_BASE_CLASS);
360 Ecore_Con_Reply *n; 372 Ecore_Con_Reply *n;
361 373
362 if (ecore_con_client_server_get(ev->client) != r->server) 374 if (ecore_con_client_server_get(ev->client) != r->server)
@@ -375,30 +387,35 @@ static Eina_Bool
375_ecore_con_eet_client_connected(void *data, int type EINA_UNUSED, Ecore_Con_Event_Server_Add *ev) 387_ecore_con_eet_client_connected(void *data, int type EINA_UNUSED, Ecore_Con_Event_Server_Add *ev)
376{ 388{
377 Ecore_Con_Eet_Server *eces; 389 Ecore_Con_Eet_Server *eces;
378 Ecore_Con_Eet *r = data; 390 Ecore_Con_Eet *ece_obj = data;
391 Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece_obj, ECORE_CON_EET_BASE_CLASS);
392 Ecore_Con_Eet_Client_Obj_Data *r = eo_data_scope_get(ece_obj, ECORE_CON_EET_CLIENT_OBJ_CLASS);
379 Ecore_Con_Reply *n; 393 Ecore_Con_Reply *n;
380 Eina_List *ll; 394 Eina_List *ll;
381 395
382 /* Client did connect */ 396 /* Client did connect */
383 if (r->server != ev->server) return EINA_TRUE; 397 if (base_data->server != ev->server) return EINA_TRUE;
384 if (r->u.client.r) return EINA_TRUE; 398 if (r->r) return EINA_TRUE;
385 399
386 n = calloc(1, sizeof (Ecore_Con_Reply)); 400 n = calloc(1, sizeof (Ecore_Con_Reply));
387 if (!n) return EINA_TRUE; 401 if (!n) return EINA_TRUE;
388 402
389 n->client = NULL; 403 n->client = NULL;
390 n->ece = r; 404 n->ece = ece_obj;
391 n->econn = eet_connection_new(_ecore_con_eet_read_cb, _ecore_con_eet_client_write_cb, n); 405 n->econn = eet_connection_new(_ecore_con_eet_read_cb, _ecore_con_eet_client_write_cb, n);
392 406
393 EINA_LIST_FOREACH(r->u.client.server_connect_callbacks, ll, eces) 407 EINA_LIST_FOREACH(r->server_connect_callbacks, ll, eces)
394 if (!eces->func((void *)eces->data, n, n->ece->server)) 408 {
395 { 409 Ecore_Con_Eet_Base_Data *temp = eo_data_scope_get(n->ece, ECORE_CON_EET_BASE_CLASS);
396 eet_connection_close(n->econn, NULL); 410 if (!eces->func((void *)eces->data, n, temp->server))
397 free(n); 411 {
398 return EINA_TRUE; 412 eet_connection_close(n->econn, NULL);
399 } 413 free(n);
414 return EINA_TRUE;
415 }
416 }
400 417
401 r->u.client.r = n; 418 r->r = n;
402 419
403 return EINA_TRUE; 420 return EINA_TRUE;
404} 421}
@@ -406,20 +423,22 @@ _ecore_con_eet_client_connected(void *data, int type EINA_UNUSED, Ecore_Con_Even
406static Eina_Bool 423static Eina_Bool
407_ecore_con_eet_client_disconnected(void *data, int type EINA_UNUSED, Ecore_Con_Event_Server_Del *ev) 424_ecore_con_eet_client_disconnected(void *data, int type EINA_UNUSED, Ecore_Con_Event_Server_Del *ev)
408{ 425{
409 Ecore_Con_Eet *r = data; 426 Ecore_Con_Eet *ece_obj = data;
427 Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece_obj, ECORE_CON_EET_BASE_CLASS);
428 Ecore_Con_Eet_Client_Obj_Data *r = eo_data_scope_get(ece_obj, ECORE_CON_EET_CLIENT_OBJ_CLASS);
410 Ecore_Con_Eet_Server *eces; 429 Ecore_Con_Eet_Server *eces;
411 Eina_List *ll; 430 Eina_List *ll;
412 431
413 if (r->server != ev->server) return EINA_TRUE; 432 if (base_data->server != ev->server) return EINA_TRUE;
414 if (!r->u.client.r) return EINA_TRUE; 433 if (!r->r) return EINA_TRUE;
415 434
416 /* Client disconnected */ 435 /* Client disconnected */
417 EINA_LIST_FOREACH(r->u.client.server_disconnect_callbacks, ll, eces) 436 EINA_LIST_FOREACH(r->server_disconnect_callbacks, ll, eces)
418 eces->func((void *)eces->data, r->u.client.r, r->server); 437 eces->func((void *)eces->data, r->r, base_data->server);
419 438
420 eet_connection_close(r->u.client.r->econn, NULL); 439 eet_connection_close(r->r->econn, NULL);
421 free(r->u.client.r); 440 free(r->r);
422 r->u.client.r = NULL; 441 r->r = NULL;
423 442
424 return EINA_TRUE; 443 return EINA_TRUE;
425} 444}
@@ -427,17 +446,156 @@ _ecore_con_eet_client_disconnected(void *data, int type EINA_UNUSED, Ecore_Con_E
427static Eina_Bool 446static Eina_Bool
428_ecore_con_eet_client_data(void *data, int type EINA_UNUSED, Ecore_Con_Event_Server_Data *ev) 447_ecore_con_eet_client_data(void *data, int type EINA_UNUSED, Ecore_Con_Event_Server_Data *ev)
429{ 448{
430 Ecore_Con_Eet *r = data; 449 Ecore_Con_Eet *ece_obj = data;
450 Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece_obj, ECORE_CON_EET_BASE_CLASS);
451 Ecore_Con_Eet_Client_Obj_Data *r = eo_data_scope_get(ece_obj, ECORE_CON_EET_CLIENT_OBJ_CLASS);
431 452
432 if (r->server != ev->server) return EINA_TRUE; 453 if (base_data->server != ev->server) return EINA_TRUE;
433 if (!r->u.client.r) return EINA_TRUE; 454 if (!r->r) return EINA_TRUE;
434 455
435 /* Got some data */ 456 /* Got some data */
436 _ecore_con_eet_data(r->u.client.r, ev->data, ev->size); 457 _ecore_con_eet_data(r->r, ev->data, ev->size);
437 458
438 return EINA_TRUE; 459 return EINA_TRUE;
439} 460}
440 461
462/*************
463 * Generated API
464 */
465EOLIAN static Eo_Base *
466_ecore_con_eet_server_obj_eo_base_constructor(Eo *obj, Ecore_Con_Eet_Server_Obj_Data *pd EINA_UNUSED)
467{
468 obj = eo_do_super_ret(obj, ECORE_CON_EET_SERVER_OBJ_CLASS, obj, eo_constructor());
469
470 if (!obj) return NULL;
471
472 pd->handler_add = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
473 (Ecore_Event_Handler_Cb)_ecore_con_eet_server_connected, obj);
474 pd->handler_del = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
475 (Ecore_Event_Handler_Cb)_ecore_con_eet_server_disconnected, obj);
476 pd->handler_data = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
477 (Ecore_Event_Handler_Cb)_ecore_con_eet_server_data, obj);
478
479 return obj;
480}
481
482EOLIAN static void
483_ecore_con_eet_server_obj_eo_base_destructor(Eo *obj, Ecore_Con_Eet_Server_Obj_Data *pd EINA_UNUSED)
484{
485 Ecore_Con_Reply *n;
486 Ecore_Con_Eet_Client *c;
487
488 EINA_LIST_FREE(pd->connections, n)
489 {
490 _ecore_con_eet_reply_cleanup(n);
491 eet_connection_close(n->econn, NULL);
492 free(n);
493 }
494 EINA_LIST_FREE(pd->client_connect_callbacks, c)
495 free(c);
496 EINA_LIST_FREE(pd->client_disconnect_callbacks, c)
497 free(c);
498
499 ecore_event_handler_del(pd->handler_add);
500 ecore_event_handler_del(pd->handler_del);
501 ecore_event_handler_del(pd->handler_data);
502
503 eo_do_super(obj, ECORE_CON_EET_SERVER_OBJ_CLASS, eo_destructor());
504}
505
506EOLIAN static Eo_Base *
507_ecore_con_eet_client_obj_eo_base_constructor(Eo *obj, Ecore_Con_Eet_Client_Obj_Data *pd EINA_UNUSED)
508{
509 obj = eo_do_super_ret(obj, ECORE_CON_EET_CLIENT_OBJ_CLASS, obj, eo_constructor());
510
511 if (!obj) return NULL;
512
513 pd->handler_add = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
514 (Ecore_Event_Handler_Cb)_ecore_con_eet_client_connected, obj);
515 pd->handler_del = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
516 (Ecore_Event_Handler_Cb)_ecore_con_eet_client_disconnected, obj);
517 pd->handler_data = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
518 (Ecore_Event_Handler_Cb)_ecore_con_eet_client_data, obj);
519
520 return obj;
521}
522
523EOLIAN static void
524_ecore_con_eet_client_obj_eo_base_destructor(Eo *obj, Ecore_Con_Eet_Client_Obj_Data *pd EINA_UNUSED)
525{
526 Ecore_Con_Eet_Server *s;
527
528 if (pd->r)
529 {
530 _ecore_con_eet_reply_cleanup(pd->r);
531 eet_connection_close(pd->r->econn, NULL);
532 }
533 EINA_LIST_FREE(pd->server_connect_callbacks, s)
534 free(s);
535 EINA_LIST_FREE(pd->server_disconnect_callbacks, s)
536 free(s);
537
538 ecore_event_handler_del(pd->handler_add);
539 ecore_event_handler_del(pd->handler_del);
540 ecore_event_handler_del(pd->handler_data);
541
542 eo_do_super(obj, ECORE_CON_EET_CLIENT_OBJ_CLASS, eo_destructor());
543}
544
545EOLIAN static Eo_Base *
546_ecore_con_eet_base_eo_base_constructor(Eo *obj, Ecore_Con_Eet_Base_Data *pd)
547{
548 obj = eo_do_super_ret(obj, ECORE_CON_EET_BASE_CLASS, obj, eo_constructor());
549
550 if (!obj) return NULL;
551
552 pd->data_callbacks = eina_hash_stringshared_new(_ecore_con_eet_data_free);
553 pd->raw_data_callbacks = eina_hash_string_superfast_new(_ecore_con_eet_raw_data_free);
554
555 _ecore_con_eet_data_descriptor_setup(pd);
556
557 return obj;
558}
559
560EOLIAN static void
561_ecore_con_eet_base_eo_base_destructor(Eo *obj, Ecore_Con_Eet_Base_Data *pd)
562{
563 eo_do_super(obj, ECORE_CON_EET_BASE_CLASS, eo_destructor());
564
565 eet_data_descriptor_free(pd->edd);
566 eet_data_descriptor_free(pd->matching);
567 eina_hash_free(pd->data_callbacks);
568 eina_hash_free(pd->raw_data_callbacks);
569}
570
571EOLIAN static Eo_Base *
572_ecore_con_eet_base_eo_base_finalize(Eo *obj, Ecore_Con_Eet_Base_Data *pd)
573{
574 if (pd->server) return obj;
575
576 eet_data_descriptor_free(pd->edd);
577 eet_data_descriptor_free(pd->matching);
578 eina_hash_free(pd->data_callbacks);
579 eina_hash_free(pd->raw_data_callbacks);
580
581 return NULL;
582}
583
584EOLIAN static void
585_ecore_con_eet_base_server_set(Eo *obj EINA_UNUSED, Ecore_Con_Eet_Base_Data *pd, Ecore_Con_Server *data)
586{
587 if (!eo_isa(data, ECORE_CON_SERVER_CLASS))
588 return;
589
590 pd->server = data;
591}
592
593EOLIAN static Ecore_Con_Server *
594_ecore_con_eet_base_server_get(Eo *obj EINA_UNUSED, Ecore_Con_Eet_Base_Data *pd)
595{
596 return pd->server;
597}
598
441/************** 599/**************
442* Global API * 600* Global API *
443**************/ 601**************/
@@ -445,113 +603,47 @@ _ecore_con_eet_client_data(void *data, int type EINA_UNUSED, Ecore_Con_Event_Ser
445EAPI Ecore_Con_Eet * 603EAPI Ecore_Con_Eet *
446ecore_con_eet_server_new(Ecore_Con_Server *server) 604ecore_con_eet_server_new(Ecore_Con_Server *server)
447{ 605{
448 Ecore_Con_Eet *r; 606 Ecore_Con_Eet *ece_obj;
449 607
450 if (!server) return NULL; 608 if (!server) return NULL;
451 609
452 r = calloc(1, sizeof (Ecore_Con_Eet)); 610 ece_obj = eo_add(ECORE_CON_EET_SERVER_OBJ_CLASS, NULL,
453 if (!r) return NULL; 611 ecore_con_eet_base_server_set(server));
454
455 r->client = EINA_FALSE;
456 r->server = server;
457 r->handler_add = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
458 (Ecore_Event_Handler_Cb)_ecore_con_eet_server_connected, r);
459 r->handler_del = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
460 (Ecore_Event_Handler_Cb)_ecore_con_eet_server_disconnected, r);
461 r->handler_data = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
462 (Ecore_Event_Handler_Cb)_ecore_con_eet_server_data, r);
463 r->data_callbacks = eina_hash_stringshared_new(_ecore_con_eet_data_free);
464 r->raw_data_callbacks = eina_hash_string_superfast_new(_ecore_con_eet_raw_data_free);
465 612
466 _ecore_con_eet_data_descriptor_setup(r); 613 return ece_obj;
467
468 return r;
469} 614}
470 615
471EAPI Ecore_Con_Eet * 616EAPI Ecore_Con_Eet *
472ecore_con_eet_client_new(Ecore_Con_Server *server) 617ecore_con_eet_client_new(Ecore_Con_Server *server)
473{ 618{
474 Ecore_Con_Eet *r; 619 Ecore_Con_Eet *ece_obj;
475 620
476 if (!server) return NULL; 621 if (!server) return NULL;
477 622
478 r = calloc(1, sizeof (Ecore_Con_Eet)); 623 ece_obj = eo_add(ECORE_CON_EET_CLIENT_OBJ_CLASS, NULL,
479 if (!r) return NULL; 624 ecore_con_eet_base_server_set(server));
480
481 r->client = EINA_TRUE;
482 r->server = server;
483 r->handler_add = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
484 (Ecore_Event_Handler_Cb)_ecore_con_eet_client_connected, r);
485 r->handler_del = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
486 (Ecore_Event_Handler_Cb)_ecore_con_eet_client_disconnected, r);
487 r->handler_data = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
488 (Ecore_Event_Handler_Cb)_ecore_con_eet_client_data, r);
489 r->data_callbacks = eina_hash_stringshared_new(_ecore_con_eet_data_free);
490 r->raw_data_callbacks = eina_hash_string_superfast_new(_ecore_con_eet_raw_data_free);
491 625
492 _ecore_con_eet_data_descriptor_setup(r); 626 return ece_obj;
493
494 return r;
495} 627}
496 628
497EAPI void 629EAPI void
498ecore_con_eet_server_free(Ecore_Con_Eet *r) 630ecore_con_eet_server_free(Ecore_Con_Eet *r)
499{ 631{
500 if (!r) return; 632 eo_del(r);
501
502 eet_data_descriptor_free(r->edd);
503 eet_data_descriptor_free(r->matching);
504 eina_hash_free(r->data_callbacks);
505 eina_hash_free(r->raw_data_callbacks);
506
507 if (r->client)
508 {
509 Ecore_Con_Eet_Server *s;
510
511 if (r->u.client.r)
512 {
513 _ecore_con_eet_reply_cleanup(r->u.client.r);
514 eet_connection_close(r->u.client.r->econn, NULL);
515 }
516 EINA_LIST_FREE(r->u.client.server_connect_callbacks, s)
517 free(s);
518 EINA_LIST_FREE(r->u.client.server_disconnect_callbacks, s)
519 free(s);
520 }
521 else
522 {
523 Ecore_Con_Reply *n;
524 Ecore_Con_Eet_Client *c;
525
526 EINA_LIST_FREE(r->u.server.connections, n)
527 {
528 _ecore_con_eet_reply_cleanup(n);
529 eet_connection_close(n->econn, NULL);
530 free(n);
531 }
532 EINA_LIST_FREE(r->u.server.client_connect_callbacks, c)
533 free(c);
534 EINA_LIST_FREE(r->u.server.client_disconnect_callbacks, c)
535 free(c);
536 }
537
538 ecore_event_handler_del(r->handler_add);
539 ecore_event_handler_del(r->handler_del);
540 ecore_event_handler_del(r->handler_data);
541 free(r);
542} 633}
543 634
544EAPI void 635EAPI void
545ecore_con_eet_register(Ecore_Con_Eet *ece, const char *name, Eet_Data_Descriptor *edd) 636ecore_con_eet_register(Ecore_Con_Eet *ece, const char *name, Eet_Data_Descriptor *edd)
546{ 637{
547 if (!ece) return; 638 Ecore_Con_Eet_Base_Data *eceb = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS);
548 639
549 EET_DATA_DESCRIPTOR_ADD_MAPPING(ece->matching, name, edd); 640 EET_DATA_DESCRIPTOR_ADD_MAPPING(eceb->matching, name, edd);
550} 641}
551 642
552EAPI void 643EAPI void
553ecore_con_eet_data_callback_add(Ecore_Con_Eet *ece, const char *name, Ecore_Con_Eet_Data_Cb func, const void *data) 644ecore_con_eet_data_callback_add(Ecore_Con_Eet *ece, const char *name, Ecore_Con_Eet_Data_Cb func, const void *data)
554{ 645{
646 Ecore_Con_Eet_Base_Data *eceb = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS);
555 Ecore_Con_Eet_Data *eced; 647 Ecore_Con_Eet_Data *eced;
556 648
557 if (!ece) return; 649 if (!ece) return;
@@ -563,53 +655,58 @@ ecore_con_eet_data_callback_add(Ecore_Con_Eet *ece, const char *name, Ecore_Con_
563 eced->data = data; 655 eced->data = data;
564 eced->name = eina_stringshare_add(name); 656 eced->name = eina_stringshare_add(name);
565 657
566 eina_hash_direct_add(ece->data_callbacks, eced->name, eced); 658 eina_hash_direct_add(eceb->data_callbacks, eced->name, eced);
567} 659}
568 660
569EAPI void 661EAPI void
570ecore_con_eet_data_callback_del(Ecore_Con_Eet *ece, const char *name) 662ecore_con_eet_data_callback_del(Ecore_Con_Eet *ece, const char *name)
571{ 663{
572 if (!ece) return; 664 Ecore_Con_Eet_Base_Data *eceb = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS);
573 eina_hash_del(ece->data_callbacks, name, NULL); 665
666 if (!eceb) return;
667 eina_hash_del(eceb->data_callbacks, name, NULL);
574} 668}
575 669
576EAPI void 670EAPI void
577ecore_con_eet_raw_data_callback_add(Ecore_Con_Eet *ece, const char *name, Ecore_Con_Eet_Raw_Data_Cb func, const void *data) 671ecore_con_eet_raw_data_callback_add(Ecore_Con_Eet *ece, const char *name, Ecore_Con_Eet_Raw_Data_Cb func, const void *data)
578{ 672{
579 Ecore_Con_Eet_Raw_Data *eced; 673 Ecore_Con_Eet_Base_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS);
580 674 Ecore_Con_Eet_Raw_Data *ecerd;
581 if (!ece) return;
582 675
583 eced = calloc(1, sizeof (Ecore_Con_Eet_Raw_Data)); 676 ecerd = calloc(1, sizeof (Ecore_Con_Eet_Raw_Data));
584 if (!eced) return; 677 if (!ecerd) return;
585 678
586 eced->func = func; 679 ecerd->func = func;
587 eced->data = data; 680 ecerd->data = data;
588 eced->name = eina_stringshare_add(name); 681 ecerd->name = eina_stringshare_add(name);
589 682
590 eina_hash_direct_add(ece->raw_data_callbacks, eced->name, eced); 683 eina_hash_direct_add(eced->raw_data_callbacks, ecerd->name, ecerd);
591} 684}
592 685
593EAPI void 686EAPI void
594ecore_con_eet_raw_data_callback_del(Ecore_Con_Eet *ece, const char *name) 687ecore_con_eet_raw_data_callback_del(Ecore_Con_Eet *ece, const char *name)
595{ 688{
596 if (!ece) return; 689 Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS);
690 Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_CLIENT_OBJ_CLASS);
597 691
598 if (ece->client && ece->u.client.r->buffer_handler && !strcmp(ece->u.client.r->buffer_handler->name, name)) 692 if (eo_isa(ece, ECORE_CON_EET_CLIENT_OBJ_CLASS) &&
693 eced->r->buffer_handler &&
694 !strcmp(eced->r->buffer_handler->name, name))
599 { 695 {
600 ece->u.client.r->buffer_handler = NULL; 696 eced->r->buffer_handler = NULL;
601 free(ece->u.client.r->buffer); 697 free(eced->r->buffer);
602 ece->u.client.r->buffer = (void *)1; 698 eced->r->buffer = (void *)1;
603 } 699 }
604 eina_hash_del(ece->raw_data_callbacks, name, NULL); 700 eina_hash_del(base_data->raw_data_callbacks, name, NULL);
605} 701}
606 702
607EAPI void 703EAPI void
608ecore_con_eet_client_connect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_Client_Cb func, const void *data) 704ecore_con_eet_client_connect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_Client_Cb func, const void *data)
609{ 705{
706 Ecore_Con_Eet_Server_Obj_Data *eces = eo_data_scope_get(ece, ECORE_CON_EET_SERVER_OBJ_CLASS);
610 Ecore_Con_Eet_Client *c; 707 Ecore_Con_Eet_Client *c;
611 708
612 if (!ece || !func) return; 709 if (!eces || !func) return;
613 710
614 c = calloc(1, sizeof (Ecore_Con_Eet_Client)); 711 c = calloc(1, sizeof (Ecore_Con_Eet_Client));
615 if (!c) return; 712 if (!c) return;
@@ -617,21 +714,22 @@ ecore_con_eet_client_connect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_Clie
617 c->func = func; 714 c->func = func;
618 c->data = data; 715 c->data = data;
619 716
620 ece->u.server.client_connect_callbacks = eina_list_append(ece->u.server.client_connect_callbacks, c); 717 eces->client_connect_callbacks = eina_list_append(eces->client_connect_callbacks, c);
621} 718}
622 719
623EAPI void 720EAPI void
624ecore_con_eet_client_connect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_Client_Cb func, const void *data) 721ecore_con_eet_client_connect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_Client_Cb func, const void *data)
625{ 722{
723 Ecore_Con_Eet_Server_Obj_Data *eces = eo_data_scope_get(ece, ECORE_CON_EET_SERVER_OBJ_CLASS);
626 Ecore_Con_Eet_Client *c; 724 Ecore_Con_Eet_Client *c;
627 Eina_List *l; 725 Eina_List *l;
628 726
629 if (!ece || !func) return; 727 if (!eces || !func) return;
630 728
631 EINA_LIST_FOREACH(ece->u.server.client_connect_callbacks, l, c) 729 EINA_LIST_FOREACH(eces->client_connect_callbacks, l, c)
632 if (c->func == func && c->data == data) 730 if (c->func == func && c->data == data)
633 { 731 {
634 ece->u.server.client_connect_callbacks = eina_list_remove_list(ece->u.server.client_connect_callbacks, l); 732 eces->client_connect_callbacks = eina_list_remove_list(eces->client_connect_callbacks, l);
635 free(c); 733 free(c);
636 return; 734 return;
637 } 735 }
@@ -640,9 +738,10 @@ ecore_con_eet_client_connect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_Clie
640EAPI void 738EAPI void
641ecore_con_eet_client_disconnect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_Client_Cb func, const void *data) 739ecore_con_eet_client_disconnect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_Client_Cb func, const void *data)
642{ 740{
741 Ecore_Con_Eet_Server_Obj_Data *eces = eo_data_scope_get(ece, ECORE_CON_EET_SERVER_OBJ_CLASS);
643 Ecore_Con_Eet_Client *c; 742 Ecore_Con_Eet_Client *c;
644 743
645 if (!ece || !func) return; 744 if (!eces || !func) return;
646 745
647 c = calloc(1, sizeof (Ecore_Con_Eet_Client)); 746 c = calloc(1, sizeof (Ecore_Con_Eet_Client));
648 if (!c) return; 747 if (!c) return;
@@ -650,22 +749,22 @@ ecore_con_eet_client_disconnect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_C
650 c->func = func; 749 c->func = func;
651 c->data = data; 750 c->data = data;
652 751
653 ece->u.server.client_disconnect_callbacks = eina_list_append(ece->u.server.client_disconnect_callbacks, c); 752 eces->client_disconnect_callbacks = eina_list_append(eces->client_disconnect_callbacks, c);
654} 753}
655 754
656EAPI void 755EAPI void
657ecore_con_eet_client_disconnect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_Client_Cb func, const void *data) 756ecore_con_eet_client_disconnect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_Client_Cb func, const void *data)
658{ 757{
758 Ecore_Con_Eet_Server_Obj_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_SERVER_OBJ_CLASS);
659 Ecore_Con_Eet_Client *c; 759 Ecore_Con_Eet_Client *c;
660 Eina_List *l; 760 Eina_List *l;
661 761
662 if (!ece || !func) return; 762 if (!eced || !func) return;
663 763
664 EINA_LIST_FOREACH(ece->u.server.client_disconnect_callbacks, l, c) 764 EINA_LIST_FOREACH(eced->client_disconnect_callbacks, l, c)
665 if (c->func == func && c->data == data) 765 if (c->func == func && c->data == data)
666 { 766 {
667 ece->u.server.client_disconnect_callbacks = eina_list_remove_list(ece->u.server.client_disconnect_callbacks, 767 eced->client_disconnect_callbacks = eina_list_remove_list(eced->client_disconnect_callbacks, l);
668 l);
669 free(c); 768 free(c);
670 return; 769 return;
671 } 770 }
@@ -674,9 +773,10 @@ ecore_con_eet_client_disconnect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_C
674EAPI void 773EAPI void
675ecore_con_eet_server_connect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_Server_Cb func, const void *data) 774ecore_con_eet_server_connect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_Server_Cb func, const void *data)
676{ 775{
776 Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_CLIENT_OBJ_CLASS);
677 Ecore_Con_Eet_Server *s; 777 Ecore_Con_Eet_Server *s;
678 778
679 if (!ece || !func) return; 779 if (!eced || !func) return;
680 780
681 s = calloc(1, sizeof (Ecore_Con_Eet_Server)); 781 s = calloc(1, sizeof (Ecore_Con_Eet_Server));
682 if (!s) return; 782 if (!s) return;
@@ -684,21 +784,22 @@ ecore_con_eet_server_connect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_Serv
684 s->func = func; 784 s->func = func;
685 s->data = data; 785 s->data = data;
686 786
687 ece->u.client.server_connect_callbacks = eina_list_append(ece->u.client.server_connect_callbacks, s); 787 eced->server_connect_callbacks = eina_list_append(eced->server_connect_callbacks, s);
688} 788}
689 789
690EAPI void 790EAPI void
691ecore_con_eet_server_connect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_Server_Cb func, const void *data) 791ecore_con_eet_server_connect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_Server_Cb func, const void *data)
692{ 792{
793 Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_CLIENT_OBJ_CLASS);
693 Ecore_Con_Eet_Server *s; 794 Ecore_Con_Eet_Server *s;
694 Eina_List *l; 795 Eina_List *l;
695 796
696 if (!ece || !func) return; 797 if (!eced || !func) return;
697 798
698 EINA_LIST_FOREACH(ece->u.client.server_connect_callbacks, l, s) 799 EINA_LIST_FOREACH(eced->server_connect_callbacks, l, s)
699 if (s->func == func && s->data == data) 800 if (s->func == func && s->data == data)
700 { 801 {
701 ece->u.client.server_connect_callbacks = eina_list_remove_list(ece->u.client.server_connect_callbacks, l); 802 eced->server_connect_callbacks = eina_list_remove_list(eced->server_connect_callbacks, l);
702 free(s); 803 free(s);
703 return; 804 return;
704 } 805 }
@@ -707,9 +808,10 @@ ecore_con_eet_server_connect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_Serv
707EAPI void 808EAPI void
708ecore_con_eet_server_disconnect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_Server_Cb func, const void *data) 809ecore_con_eet_server_disconnect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_Server_Cb func, const void *data)
709{ 810{
811 Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_CLIENT_OBJ_CLASS);
710 Ecore_Con_Eet_Server *s; 812 Ecore_Con_Eet_Server *s;
711 813
712 if (!ece || !func) return; 814 if (!eced || !func) return;
713 815
714 s = calloc(1, sizeof (Ecore_Con_Eet_Server)); 816 s = calloc(1, sizeof (Ecore_Con_Eet_Server));
715 if (!s) return; 817 if (!s) return;
@@ -717,21 +819,22 @@ ecore_con_eet_server_disconnect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_S
717 s->func = func; 819 s->func = func;
718 s->data = data; 820 s->data = data;
719 821
720 ece->u.client.server_disconnect_callbacks = eina_list_append(ece->u.client.server_disconnect_callbacks, s); 822 eced->server_disconnect_callbacks = eina_list_append(eced->server_disconnect_callbacks, s);
721} 823}
722 824
723EAPI void 825EAPI void
724ecore_con_eet_server_disconnect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_Server_Cb func, const void *data) 826ecore_con_eet_server_disconnect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_Server_Cb func, const void *data)
725{ 827{
828 Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_CLIENT_OBJ_CLASS);
726 Ecore_Con_Eet_Server *s; 829 Ecore_Con_Eet_Server *s;
727 Eina_List *l; 830 Eina_List *l;
728 831
729 if (!ece || !func) return; 832 if (!eced || !func) return;
730 833
731 EINA_LIST_FOREACH(ece->u.client.server_disconnect_callbacks, l, s) 834 EINA_LIST_FOREACH(eced->server_disconnect_callbacks, l, s)
732 if (s->func == func && s->data == data) 835 if (s->func == func && s->data == data)
733 { 836 {
734 ece->u.client.server_disconnect_callbacks = eina_list_remove_list(ece->u.client.server_disconnect_callbacks, l); 837 eced->server_disconnect_callbacks = eina_list_remove_list(eced->server_disconnect_callbacks, l);
735 free(s); 838 free(s);
736 return; 839 return;
737 } 840 }
@@ -740,16 +843,18 @@ ecore_con_eet_server_disconnect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_S
740EAPI void 843EAPI void
741ecore_con_eet_data_set(Ecore_Con_Eet *ece, const void *data) 844ecore_con_eet_data_set(Ecore_Con_Eet *ece, const void *data)
742{ 845{
743 if (!ece) return; 846 Ecore_Con_Eet_Base_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS);
847 if (!eced) return;
744 848
745 ece->data = data; 849 eced->data = data;
746} 850}
747 851
748EAPI void * 852EAPI void *
749ecore_con_eet_data_get(Ecore_Con_Eet *ece) 853ecore_con_eet_data_get(Ecore_Con_Eet *ece)
750{ 854{
751 if (!ece) return NULL; 855 Ecore_Con_Eet_Base_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS);
752 return (void *)ece->data; 856 if (!eced) return NULL;
857 return (void *)eced->data;
753} 858}
754 859
755EAPI Ecore_Con_Eet * 860EAPI Ecore_Con_Eet *
@@ -763,13 +868,16 @@ EAPI void
763ecore_con_eet_send(Ecore_Con_Reply *reply, const char *name, void *value) 868ecore_con_eet_send(Ecore_Con_Reply *reply, const char *name, void *value)
764{ 869{
765 Ecore_Con_Eet_Protocol protocol; 870 Ecore_Con_Eet_Protocol protocol;
871 Ecore_Con_Eet_Base_Data *eced;
766 872
767 if (!reply) return; 873 if (!reply) return;
768 874
875 eced = eo_data_scope_get(reply->ece, ECORE_CON_EET_BASE_CLASS);
876
769 protocol.type = name; 877 protocol.type = name;
770 protocol.data = value; 878 protocol.data = value;
771 879
772 eet_connection_send(reply->econn, reply->ece->edd, &protocol, NULL); 880 eet_connection_send(reply->econn, eced->edd, &protocol, NULL);
773} 881}
774 882
775EAPI void 883EAPI void
@@ -779,12 +887,14 @@ ecore_con_eet_raw_send(Ecore_Con_Reply *reply, const char *protocol_name, const
779 unsigned int protocol_length; 887 unsigned int protocol_length;
780 unsigned int section_length; 888 unsigned int section_length;
781 unsigned int size; 889 unsigned int size;
890 Ecore_Con_Eet_Base_Data *ece_obj;
782 char *tmp; 891 char *tmp;
783 892
784 if (!reply) return; 893 if (!reply) return;
785 if (!protocol_name) return; 894 if (!protocol_name) return;
786 if (!section) return; 895 if (!section) return;
787 896
897 ece_obj = eo_data_scope_get(reply->ece, ECORE_CON_EET_BASE_CLASS);
788 protocol_length = strlen(protocol_name) + 1; 898 protocol_length = strlen(protocol_name) + 1;
789 if (protocol_length == 1) return; 899 if (protocol_length == 1) return;
790 section_length = strlen(section) + 1; 900 section_length = strlen(section) + 1;
@@ -807,8 +917,11 @@ ecore_con_eet_raw_send(Ecore_Con_Reply *reply, const char *protocol_name, const
807 } 917 }
808 else 918 else
809 { 919 {
810 ecore_con_server_send(reply->ece->server, tmp, size); 920 ecore_con_server_send(ece_obj->server, tmp, size);
811 ecore_con_server_send(reply->ece->server, value, length); 921 ecore_con_server_send(ece_obj->server, value, length);
812 } 922 }
813} 923}
814 924
925#include "ecore_con_eet_base.eo.c"
926#include "ecore_con_eet_server_obj.eo.c"
927#include "ecore_con_eet_client_obj.eo.c"
diff --git a/src/lib/ecore_con/ecore_con_eet_base.eo b/src/lib/ecore_con/ecore_con_eet_base.eo
new file mode 100644
index 0000000..5b65b8e
--- /dev/null
+++ b/src/lib/ecore_con/ecore_con_eet_base.eo
@@ -0,0 +1,23 @@
1class Ecore.Con.Eet.Base (Eo.Base) {
2 legacy_prefix: null;
3 eo_prefix: ecore_con_eet_base;
4 methods {
5 @property server {
6 /*@
7 * The server object to which we send and receive.
8 */
9 set {
10 }
11 get {
12 }
13 values {
14 data: Ecore_Con_Server*;
15 }
16 }
17 }
18 implements {
19 Eo.Base.constructor;
20 Eo.Base.destructor;
21 Eo.Base.finalize;
22 }
23}
diff --git a/src/lib/ecore_con/ecore_con_eet_client_obj.eo b/src/lib/ecore_con/ecore_con_eet_client_obj.eo
new file mode 100644
index 0000000..7f8f3af
--- /dev/null
+++ b/src/lib/ecore_con/ecore_con_eet_client_obj.eo
@@ -0,0 +1,9 @@
1class Ecore.Con.Eet.Client.Obj (Ecore.Con.Eet.Base) {
2 legacy_prefix: null;
3 eo_prefix: ecore_con_eet_client_obj;
4 implements {
5 Eo.Base.constructor;
6 Eo.Base.destructor;
7 }
8}
9
diff --git a/src/lib/ecore_con/ecore_con_eet_server_obj.eo b/src/lib/ecore_con/ecore_con_eet_server_obj.eo
new file mode 100644
index 0000000..2a5c6ad
--- /dev/null
+++ b/src/lib/ecore_con/ecore_con_eet_server_obj.eo
@@ -0,0 +1,9 @@
1class Ecore.Con.Eet.Server.Obj (Ecore.Con.Eet.Base) {
2 legacy_prefix: null;
3 eo_prefix: ecore_con_eet_server_obj;
4 implements {
5 Eo.Base.constructor;
6 Eo.Base.destructor;
7 }
8}
9