cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=12257053a0f428b88df913ac3a00fdaa5b366ed2

commit 12257053a0f428b88df913ac3a00fdaa5b366ed2
Author: Srivardhan Hebbar <sri.heb...@samsung.com>
Date:   Mon Jun 22 18:55:54 2015 +0200

    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.heb...@samsung.com>
    
    Reviewers: cedric
    
    Subscribers: cedric
    
    Differential Revision: https://phab.enlightenment.org/D2602
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/Makefile_Ecore_Con.am                     |   3 +
 src/lib/ecore_con/Ecore_Con_Eet.h             |   9 +-
 src/lib/ecore_con/Ecore_Con_Eet_Eo.h          |   3 +
 src/lib/ecore_con/Ecore_Con_Eet_Legacy.h      |   3 +
 src/lib/ecore_con/ecore_con_eet.c             | 487 ++++++++++++++++----------
 src/lib/ecore_con/ecore_con_eet_base.eo       |  23 ++
 src/lib/ecore_con/ecore_con_eet_client_obj.eo |   9 +
 src/lib/ecore_con/ecore_con_eet_server_obj.eo |   9 +
 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 = \
        lib/ecore_con/ecore_con_client.eo \
        lib/ecore_con/ecore_con_server.eo \
        lib/ecore_con/ecore_con_connector.eo \
+       lib/ecore_con/ecore_con_eet_base.eo \
+       lib/ecore_con/ecore_con_eet_server_obj.eo \
+       lib/ecore_con/ecore_con_eet_client_obj.eo \
        lib/ecore_con/efl_network_url.eo
 
 ecore_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 @@
  * @{
  */
 
-typedef struct _Ecore_Con_Eet Ecore_Con_Eet;
+typedef Eo Ecore_Con_Eet;
 typedef struct _Ecore_Con_Reply Ecore_Con_Reply;
 
 /**
@@ -70,6 +70,13 @@ typedef Eina_Bool (*Ecore_Con_Eet_Client_Cb)(void *data, 
Ecore_Con_Reply *reply,
  */
 typedef Eina_Bool (*Ecore_Con_Eet_Server_Cb)(void *data, Ecore_Con_Reply 
*reply, Ecore_Con_Server *conn);
 
+#ifndef EFL_NOLEGACY_API_SUPPORT
+#include "Ecore_Con_Eet_Legacy.h"
+#endif
+#ifdef EFL_EO_API_SUPPORT
+#include "Ecore_Con_Eet_Eo.h"
+#endif
+
 /**
  * Create a Ecore_Con_Eet server.
  *
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 @@
+#include "ecore_con_eet_base.eo.h"
+#include "ecore_con_eet_server_obj.eo.h"
+#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 @@
+#include "ecore_con_eet_base.eo.legacy.h"
+#include "ecore_con_eet_client_obj.eo.legacy.h"
+#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 @@
 
 #define ECORE_CON_EET_RAW_MAGIC 0xDEAD007
 
+typedef struct _Ecore_Con_Eet_Base_Data Ecore_Con_Eet_Base_Data;
+typedef struct _Ecore_Con_Eet_Server_Obj_Data Ecore_Con_Eet_Server_Obj_Data;
+typedef struct _Ecore_Con_Eet_Client_Obj_Data Ecore_Con_Eet_Client_Obj_Data;
 typedef struct _Ecore_Con_Eet_Data     Ecore_Con_Eet_Data;
 typedef struct _Ecore_Con_Eet_Raw_Data Ecore_Con_Eet_Raw_Data;
 typedef struct _Ecore_Con_Eet_Client   Ecore_Con_Eet_Client;
 typedef struct _Ecore_Con_Eet_Server   Ecore_Con_Eet_Server;
 
+struct _Ecore_Con_Eet_Server_Obj_Data
+{
+   Eina_List *connections;
+   Eina_List *client_connect_callbacks;
+   Eina_List *client_disconnect_callbacks;
+
+   Ecore_Event_Handler *handler_add;
+   Ecore_Event_Handler *handler_del;
+   Ecore_Event_Handler *handler_data;
+};
+
+struct _Ecore_Con_Eet_Client_Obj_Data
+{
+   Ecore_Con_Reply *r;
+   Eina_List       *server_connect_callbacks;
+   Eina_List       *server_disconnect_callbacks;
+
+   Ecore_Event_Handler *handler_add;
+   Ecore_Event_Handler *handler_del;
+   Ecore_Event_Handler *handler_data;
+};
+
 struct _Ecore_Con_Reply
 {
    Ecore_Con_Eet          *ece;
@@ -66,39 +91,17 @@ struct _Ecore_Con_Eet_Server
    const void             *data;
 };
 
-struct _Ecore_Con_Eet
+struct _Ecore_Con_Eet_Base_Data
 {
    Ecore_Con_Server    *server;
 
-   Ecore_Event_Handler *handler_add;
-   Ecore_Event_Handler *handler_del;
-   Ecore_Event_Handler *handler_data;
-
    Eet_Data_Descriptor *edd;
    Eet_Data_Descriptor *matching;
 
    Eina_Hash           *data_callbacks;
    Eina_Hash           *raw_data_callbacks;
 
-   union
-   {
-      struct
-      {
-         Eina_List *connections;
-         Eina_List *client_connect_callbacks;
-         Eina_List *client_disconnect_callbacks;
-      } server;
-      struct
-      {
-         Ecore_Con_Reply *r;
-         Eina_List       *server_connect_callbacks;
-         Eina_List       *server_disconnect_callbacks;
-      } client;
-   } u;
-
    const void *data;
-
-   Eina_Bool   client : 1;
 };
 
 static void
@@ -154,7 +157,7 @@ _ecore_con_eet_data_type_set(const char *type, void *data, 
Eina_Bool unknow EINA
 }
 
 static void
-_ecore_con_eet_data_descriptor_setup(Ecore_Con_Eet *ece)
+_ecore_con_eet_data_descriptor_setup(Ecore_Con_Eet_Base_Data *ece)
 {
    Eet_Data_Descriptor_Class eddc;
 
@@ -176,11 +179,12 @@ _ecore_con_eet_read_cb(const void *eet_data, size_t size, 
void *user_data)
    Ecore_Con_Reply *n = user_data;
    Ecore_Con_Eet_Protocol *protocol;
    Ecore_Con_Eet_Data *cb;
+   Ecore_Con_Eet_Base_Data *ece_data = eo_data_scope_get(n->ece, 
ECORE_CON_EET_BASE_CLASS);
 
-   protocol = eet_data_descriptor_decode(n->ece->edd, eet_data, size);
+   protocol = eet_data_descriptor_decode(ece_data->edd, eet_data, size);
    if (!protocol) return EINA_TRUE;
 
-   cb = eina_hash_find(n->ece->data_callbacks, protocol->type);
+   cb = eina_hash_find(ece_data->data_callbacks, protocol->type);
    if (!cb) return EINA_TRUE;  /* Should I report unknow protocol 
communication ? */
 
    cb->func((void *)cb->data, n, cb->name, protocol->data);
@@ -205,9 +209,11 @@ static Eina_Bool
 _ecore_con_eet_client_write_cb(const void *data, size_t size, void *user_data)
 {
    Ecore_Con_Reply *n = user_data;
+   Ecore_Con_Eet_Base_Data *ece_data = eo_data_scope_get(n->ece, 
ECORE_CON_EET_BASE_CLASS);
 
-   if (ecore_con_server_send(n->ece->server, data, size) != (int)size)
+   if (ecore_con_server_send(ece_data->server, data, size) != (int)size)
      return EINA_FALSE;
+
    return EINA_TRUE;
 }
 
@@ -216,21 +222,23 @@ _ecore_con_eet_server_connected(void *data, int type 
EINA_UNUSED, Ecore_Con_Even
 {
    Ecore_Con_Eet_Client *ecec;
    Eina_List *ll;
-   Ecore_Con_Eet *r = data;
    Ecore_Con_Reply *n;
+   Ecore_Con_Eet *ece_obj = data;
+   Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_BASE_CLASS);
+   Ecore_Con_Eet_Server_Obj_Data *r = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_SERVER_OBJ_CLASS);
 
-   if (ecore_con_client_server_get(ev->client) != r->server)
+   if (ecore_con_client_server_get(ev->client) != base_data->server)
      return EINA_TRUE;
 
    n = calloc(1, sizeof (Ecore_Con_Reply));
    if (!n) return EINA_TRUE;
 
    n->client = ev->client;
-   n->ece = r;
+   n->ece = ece_obj;
    n->econn = eet_connection_new(_ecore_con_eet_read_cb, 
_ecore_con_eet_server_write_cb, n);
    ecore_con_client_data_set(n->client, n);
 
-   EINA_LIST_FOREACH(r->u.server.client_connect_callbacks, ll, ecec)
+   EINA_LIST_FOREACH(r->client_connect_callbacks, ll, ecec)
      if (!ecec->func((void *)ecec->data, n, n->client))
        {
           eet_connection_close(n->econn, NULL);
@@ -238,7 +246,7 @@ _ecore_con_eet_server_connected(void *data, int type 
EINA_UNUSED, Ecore_Con_Even
           return EINA_TRUE;
        }
 
-   r->u.server.connections = eina_list_append(r->u.server.connections, n);
+   r->connections = eina_list_append(r->connections, n);
 
    return EINA_TRUE;
 }
@@ -246,25 +254,27 @@ _ecore_con_eet_server_connected(void *data, int type 
EINA_UNUSED, Ecore_Con_Even
 static Eina_Bool
 _ecore_con_eet_server_disconnected(void *data, int type EINA_UNUSED, 
Ecore_Con_Event_Client_Del *ev)
 {
-   Ecore_Con_Eet *r = data;
+   Ecore_Con_Eet *ece_obj = data;
+   Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_BASE_CLASS);
+   Ecore_Con_Eet_Server_Obj_Data *r = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_SERVER_OBJ_CLASS);
    Ecore_Con_Reply *n;
    Eina_List *l;
 
-   if (ecore_con_client_server_get(ev->client) != r->server)
+   if (ecore_con_client_server_get(ev->client) != base_data->server)
      return EINA_TRUE;
 
-   EINA_LIST_FOREACH(r->u.server.connections, l, n)
+   EINA_LIST_FOREACH(r->connections, l, n)
      if (n->client == ev->client)
        {
           Ecore_Con_Eet_Client *ecec;
           Eina_List *ll;
 
-          EINA_LIST_FOREACH(r->u.server.client_disconnect_callbacks, ll, ecec)
+          EINA_LIST_FOREACH(r->client_disconnect_callbacks, ll, ecec)
             ecec->func((void *)ecec->data, n, n->client);
 
           eet_connection_close(n->econn, NULL);
           free(n);
-          r->u.server.connections = 
eina_list_remove_list(r->u.server.connections, l);
+          r->connections = eina_list_remove_list(r->connections, l);
           return EINA_TRUE;
        }
 
@@ -317,6 +327,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, 
unsigned int size)
                   char *buffer = (char *)&tmp[4];
                   char *protocol;
                   char *section;
+                  Ecore_Con_Eet_Base_Data *eceb_data = 
eo_data_scope_get(n->ece,ECORE_CON_EET_BASE_CLASS);
 
                   protocol = buffer;
                   section = buffer + protocol_length;
@@ -327,7 +338,7 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, 
unsigned int size)
                        size -= protocol_length + section_length;
                        buffer = section + section_length;
 
-                       n->buffer_handler = 
eina_hash_find(n->ece->raw_data_callbacks, protocol);
+                       n->buffer_handler = 
eina_hash_find(eceb_data->raw_data_callbacks, protocol);
                        n->buffer_section = strdup(section);
                        n->buffer_length = data_length;
                        n->buffer_current = 0;
@@ -356,7 +367,8 @@ _ecore_con_eet_data(Ecore_Con_Reply *n, void *data, 
unsigned int size)
 static Eina_Bool
 _ecore_con_eet_server_data(void *data, int type EINA_UNUSED, 
Ecore_Con_Event_Client_Data *ev)
 {
-   Ecore_Con_Eet *r = data;
+   Ecore_Con_Eet *ece_obj = data;
+   Ecore_Con_Eet_Base_Data *r = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_BASE_CLASS);
    Ecore_Con_Reply *n;
 
    if (ecore_con_client_server_get(ev->client) != r->server)
@@ -375,30 +387,35 @@ static Eina_Bool
 _ecore_con_eet_client_connected(void *data, int type EINA_UNUSED, 
Ecore_Con_Event_Server_Add *ev)
 {
    Ecore_Con_Eet_Server *eces;
-   Ecore_Con_Eet *r = data;
+   Ecore_Con_Eet *ece_obj = data;
+   Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_BASE_CLASS);
+   Ecore_Con_Eet_Client_Obj_Data *r = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_CLIENT_OBJ_CLASS);
    Ecore_Con_Reply *n;
    Eina_List *ll;
 
    /* Client did connect */
-   if (r->server != ev->server) return EINA_TRUE;
-   if (r->u.client.r) return EINA_TRUE;
+   if (base_data->server != ev->server) return EINA_TRUE;
+   if (r->r) return EINA_TRUE;
 
    n = calloc(1, sizeof (Ecore_Con_Reply));
    if (!n) return EINA_TRUE;
 
    n->client = NULL;
-   n->ece = r;
+   n->ece = ece_obj;
    n->econn = eet_connection_new(_ecore_con_eet_read_cb, 
_ecore_con_eet_client_write_cb, n);
 
-   EINA_LIST_FOREACH(r->u.client.server_connect_callbacks, ll, eces)
-     if (!eces->func((void *)eces->data, n, n->ece->server))
-       {
-          eet_connection_close(n->econn, NULL);
-          free(n);
-          return EINA_TRUE;
-       }
+   EINA_LIST_FOREACH(r->server_connect_callbacks, ll, eces)
+     {
+        Ecore_Con_Eet_Base_Data *temp = eo_data_scope_get(n->ece, 
ECORE_CON_EET_BASE_CLASS);
+        if (!eces->func((void *)eces->data, n, temp->server))
+          {
+             eet_connection_close(n->econn, NULL);
+             free(n);
+             return EINA_TRUE;
+          }
+     }
 
-   r->u.client.r = n;
+   r->r = n;
 
    return EINA_TRUE;
 }
@@ -406,20 +423,22 @@ _ecore_con_eet_client_connected(void *data, int type 
EINA_UNUSED, Ecore_Con_Even
 static Eina_Bool
 _ecore_con_eet_client_disconnected(void *data, int type EINA_UNUSED, 
Ecore_Con_Event_Server_Del *ev)
 {
-   Ecore_Con_Eet *r = data;
+   Ecore_Con_Eet *ece_obj = data;
+   Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_BASE_CLASS);
+   Ecore_Con_Eet_Client_Obj_Data *r = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_CLIENT_OBJ_CLASS);
    Ecore_Con_Eet_Server *eces;
    Eina_List *ll;
 
-   if (r->server != ev->server) return EINA_TRUE;
-   if (!r->u.client.r) return EINA_TRUE;
+   if (base_data->server != ev->server) return EINA_TRUE;
+   if (!r->r) return EINA_TRUE;
 
    /* Client disconnected */
-   EINA_LIST_FOREACH(r->u.client.server_disconnect_callbacks, ll, eces)
-     eces->func((void *)eces->data, r->u.client.r, r->server);
+   EINA_LIST_FOREACH(r->server_disconnect_callbacks, ll, eces)
+     eces->func((void *)eces->data, r->r, base_data->server);
 
-   eet_connection_close(r->u.client.r->econn, NULL);
-   free(r->u.client.r);
-   r->u.client.r = NULL;
+   eet_connection_close(r->r->econn, NULL);
+   free(r->r);
+   r->r = NULL;
 
    return EINA_TRUE;
 }
@@ -427,17 +446,156 @@ _ecore_con_eet_client_disconnected(void *data, int type 
EINA_UNUSED, Ecore_Con_E
 static Eina_Bool
 _ecore_con_eet_client_data(void *data, int type EINA_UNUSED, 
Ecore_Con_Event_Server_Data *ev)
 {
-   Ecore_Con_Eet *r = data;
+   Ecore_Con_Eet *ece_obj = data;
+   Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_BASE_CLASS);
+   Ecore_Con_Eet_Client_Obj_Data *r = eo_data_scope_get(ece_obj, 
ECORE_CON_EET_CLIENT_OBJ_CLASS);
 
-   if (r->server != ev->server) return EINA_TRUE;
-   if (!r->u.client.r) return EINA_TRUE;
+   if (base_data->server != ev->server) return EINA_TRUE;
+   if (!r->r) return EINA_TRUE;
 
    /* Got some data */
-   _ecore_con_eet_data(r->u.client.r, ev->data, ev->size);
+   _ecore_con_eet_data(r->r, ev->data, ev->size);
 
    return EINA_TRUE;
 }
 
+/*************
+ * Generated API
+ */
+EOLIAN static Eo_Base *
+_ecore_con_eet_server_obj_eo_base_constructor(Eo *obj, 
Ecore_Con_Eet_Server_Obj_Data *pd EINA_UNUSED)
+{
+   obj = eo_do_super_ret(obj, ECORE_CON_EET_SERVER_OBJ_CLASS, obj, 
eo_constructor());
+
+   if (!obj) return NULL;
+
+   pd->handler_add = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
+                                             
(Ecore_Event_Handler_Cb)_ecore_con_eet_server_connected, obj);
+   pd->handler_del = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
+                                             
(Ecore_Event_Handler_Cb)_ecore_con_eet_server_disconnected, obj);
+   pd->handler_data = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
+                                              
(Ecore_Event_Handler_Cb)_ecore_con_eet_server_data, obj);
+
+   return obj;
+}
+
+EOLIAN static void
+_ecore_con_eet_server_obj_eo_base_destructor(Eo *obj, 
Ecore_Con_Eet_Server_Obj_Data *pd EINA_UNUSED)
+{
+   Ecore_Con_Reply *n;
+   Ecore_Con_Eet_Client *c;
+
+   EINA_LIST_FREE(pd->connections, n)
+     {
+        _ecore_con_eet_reply_cleanup(n);
+        eet_connection_close(n->econn, NULL);
+        free(n);
+     }
+   EINA_LIST_FREE(pd->client_connect_callbacks, c)
+     free(c);
+   EINA_LIST_FREE(pd->client_disconnect_callbacks, c)
+     free(c);
+
+   ecore_event_handler_del(pd->handler_add);
+   ecore_event_handler_del(pd->handler_del);
+   ecore_event_handler_del(pd->handler_data);
+
+   eo_do_super(obj, ECORE_CON_EET_SERVER_OBJ_CLASS, eo_destructor());
+}
+
+EOLIAN static Eo_Base *
+_ecore_con_eet_client_obj_eo_base_constructor(Eo *obj, 
Ecore_Con_Eet_Client_Obj_Data *pd EINA_UNUSED)
+{
+   obj = eo_do_super_ret(obj, ECORE_CON_EET_CLIENT_OBJ_CLASS, obj, 
eo_constructor());
+
+   if (!obj) return NULL;
+
+   pd->handler_add = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
+                                             
(Ecore_Event_Handler_Cb)_ecore_con_eet_client_connected, obj);
+   pd->handler_del = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
+                                             
(Ecore_Event_Handler_Cb)_ecore_con_eet_client_disconnected, obj);
+   pd->handler_data = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
+                                              
(Ecore_Event_Handler_Cb)_ecore_con_eet_client_data, obj);
+
+   return obj;
+}
+
+EOLIAN static void
+_ecore_con_eet_client_obj_eo_base_destructor(Eo *obj, 
Ecore_Con_Eet_Client_Obj_Data *pd EINA_UNUSED)
+{
+   Ecore_Con_Eet_Server *s;
+
+   if (pd->r)
+     {
+        _ecore_con_eet_reply_cleanup(pd->r);
+        eet_connection_close(pd->r->econn, NULL);
+     }
+   EINA_LIST_FREE(pd->server_connect_callbacks, s)
+     free(s);
+   EINA_LIST_FREE(pd->server_disconnect_callbacks, s)
+     free(s);
+
+   ecore_event_handler_del(pd->handler_add);
+   ecore_event_handler_del(pd->handler_del);
+   ecore_event_handler_del(pd->handler_data);
+
+   eo_do_super(obj, ECORE_CON_EET_CLIENT_OBJ_CLASS, eo_destructor());
+}
+
+EOLIAN static Eo_Base *
+_ecore_con_eet_base_eo_base_constructor(Eo *obj, Ecore_Con_Eet_Base_Data *pd)
+{
+   obj = eo_do_super_ret(obj, ECORE_CON_EET_BASE_CLASS, obj, eo_constructor());
+
+   if (!obj) return NULL;
+
+   pd->data_callbacks = eina_hash_stringshared_new(_ecore_con_eet_data_free);
+   pd->raw_data_callbacks = 
eina_hash_string_superfast_new(_ecore_con_eet_raw_data_free);
+
+   _ecore_con_eet_data_descriptor_setup(pd);
+
+   return obj;
+}
+
+EOLIAN static void
+_ecore_con_eet_base_eo_base_destructor(Eo *obj, Ecore_Con_Eet_Base_Data *pd)
+{
+   eo_do_super(obj, ECORE_CON_EET_BASE_CLASS, eo_destructor());
+
+   eet_data_descriptor_free(pd->edd);
+   eet_data_descriptor_free(pd->matching);
+   eina_hash_free(pd->data_callbacks);
+   eina_hash_free(pd->raw_data_callbacks);
+}
+
+EOLIAN static Eo_Base *
+_ecore_con_eet_base_eo_base_finalize(Eo *obj, Ecore_Con_Eet_Base_Data *pd)
+{
+   if (pd->server) return obj;
+
+   eet_data_descriptor_free(pd->edd);
+   eet_data_descriptor_free(pd->matching);
+   eina_hash_free(pd->data_callbacks);
+   eina_hash_free(pd->raw_data_callbacks);
+
+   return NULL;
+}
+
+EOLIAN static void
+_ecore_con_eet_base_server_set(Eo *obj EINA_UNUSED, Ecore_Con_Eet_Base_Data 
*pd, Ecore_Con_Server *data)
+{
+   if (!eo_isa(data, ECORE_CON_SERVER_CLASS))
+     return;
+
+   pd->server = data;
+}
+
+EOLIAN static Ecore_Con_Server *
+_ecore_con_eet_base_server_get(Eo *obj EINA_UNUSED, Ecore_Con_Eet_Base_Data 
*pd)
+{
+   return pd->server;
+}
+
 /**************
 * Global API *
 **************/
@@ -445,113 +603,47 @@ _ecore_con_eet_client_data(void *data, int type 
EINA_UNUSED, Ecore_Con_Event_Ser
 EAPI Ecore_Con_Eet *
 ecore_con_eet_server_new(Ecore_Con_Server *server)
 {
-   Ecore_Con_Eet *r;
+   Ecore_Con_Eet *ece_obj;
 
    if (!server) return NULL;
 
-   r = calloc(1, sizeof (Ecore_Con_Eet));
-   if (!r) return NULL;
-
-   r->client = EINA_FALSE;
-   r->server = server;
-   r->handler_add = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
-                                            
(Ecore_Event_Handler_Cb)_ecore_con_eet_server_connected, r);
-   r->handler_del = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
-                                            
(Ecore_Event_Handler_Cb)_ecore_con_eet_server_disconnected, r);
-   r->handler_data = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA,
-                                             
(Ecore_Event_Handler_Cb)_ecore_con_eet_server_data, r);
-   r->data_callbacks = eina_hash_stringshared_new(_ecore_con_eet_data_free);
-   r->raw_data_callbacks = 
eina_hash_string_superfast_new(_ecore_con_eet_raw_data_free);
+   ece_obj = eo_add(ECORE_CON_EET_SERVER_OBJ_CLASS, NULL,
+                    ecore_con_eet_base_server_set(server));
 
-   _ecore_con_eet_data_descriptor_setup(r);
-
-   return r;
+   return ece_obj;
 }
 
 EAPI Ecore_Con_Eet *
 ecore_con_eet_client_new(Ecore_Con_Server *server)
 {
-   Ecore_Con_Eet *r;
+   Ecore_Con_Eet *ece_obj;
 
    if (!server) return NULL;
 
-   r = calloc(1, sizeof (Ecore_Con_Eet));
-   if (!r) return NULL;
-
-   r->client = EINA_TRUE;
-   r->server = server;
-   r->handler_add = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD,
-                                            
(Ecore_Event_Handler_Cb)_ecore_con_eet_client_connected, r);
-   r->handler_del = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL,
-                                            
(Ecore_Event_Handler_Cb)_ecore_con_eet_client_disconnected, r);
-   r->handler_data = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
-                                             
(Ecore_Event_Handler_Cb)_ecore_con_eet_client_data, r);
-   r->data_callbacks = eina_hash_stringshared_new(_ecore_con_eet_data_free);
-   r->raw_data_callbacks = 
eina_hash_string_superfast_new(_ecore_con_eet_raw_data_free);
+   ece_obj = eo_add(ECORE_CON_EET_CLIENT_OBJ_CLASS, NULL,
+                    ecore_con_eet_base_server_set(server));
 
-   _ecore_con_eet_data_descriptor_setup(r);
-
-   return r;
+   return ece_obj;
 }
 
 EAPI void
 ecore_con_eet_server_free(Ecore_Con_Eet *r)
 {
-   if (!r) return;
-
-   eet_data_descriptor_free(r->edd);
-   eet_data_descriptor_free(r->matching);
-   eina_hash_free(r->data_callbacks);
-   eina_hash_free(r->raw_data_callbacks);
-
-   if (r->client)
-     {
-        Ecore_Con_Eet_Server *s;
-
-        if (r->u.client.r)
-          {
-             _ecore_con_eet_reply_cleanup(r->u.client.r);
-             eet_connection_close(r->u.client.r->econn, NULL);
-          }
-        EINA_LIST_FREE(r->u.client.server_connect_callbacks, s)
-          free(s);
-        EINA_LIST_FREE(r->u.client.server_disconnect_callbacks, s)
-          free(s);
-     }
-   else
-     {
-        Ecore_Con_Reply *n;
-        Ecore_Con_Eet_Client *c;
-
-        EINA_LIST_FREE(r->u.server.connections, n)
-          {
-             _ecore_con_eet_reply_cleanup(n);
-             eet_connection_close(n->econn, NULL);
-             free(n);
-          }
-        EINA_LIST_FREE(r->u.server.client_connect_callbacks, c)
-          free(c);
-        EINA_LIST_FREE(r->u.server.client_disconnect_callbacks, c)
-          free(c);
-     }
-
-   ecore_event_handler_del(r->handler_add);
-   ecore_event_handler_del(r->handler_del);
-   ecore_event_handler_del(r->handler_data);
-   free(r);
+   eo_del(r);
 }
 
 EAPI void
 ecore_con_eet_register(Ecore_Con_Eet *ece, const char *name, 
Eet_Data_Descriptor *edd)
 {
-   if (!ece) return;
+   Ecore_Con_Eet_Base_Data *eceb = eo_data_scope_get(ece, 
ECORE_CON_EET_BASE_CLASS);
 
-   EET_DATA_DESCRIPTOR_ADD_MAPPING(ece->matching, name, edd);
+   EET_DATA_DESCRIPTOR_ADD_MAPPING(eceb->matching, name, edd);
 }
 
 EAPI void
 ecore_con_eet_data_callback_add(Ecore_Con_Eet *ece, const char *name, 
Ecore_Con_Eet_Data_Cb func, const void *data)
 {
+   Ecore_Con_Eet_Base_Data *eceb = eo_data_scope_get(ece, 
ECORE_CON_EET_BASE_CLASS);
    Ecore_Con_Eet_Data *eced;
 
    if (!ece) return;
@@ -563,53 +655,58 @@ ecore_con_eet_data_callback_add(Ecore_Con_Eet *ece, const 
char *name, Ecore_Con_
    eced->data = data;
    eced->name = eina_stringshare_add(name);
 
-   eina_hash_direct_add(ece->data_callbacks, eced->name, eced);
+   eina_hash_direct_add(eceb->data_callbacks, eced->name, eced);
 }
 
 EAPI void
 ecore_con_eet_data_callback_del(Ecore_Con_Eet *ece, const char *name)
 {
-   if (!ece) return;
-   eina_hash_del(ece->data_callbacks, name, NULL);
+   Ecore_Con_Eet_Base_Data *eceb = eo_data_scope_get(ece, 
ECORE_CON_EET_BASE_CLASS);
+
+   if (!eceb) return;
+   eina_hash_del(eceb->data_callbacks, name, NULL);
 }
 
 EAPI void
 ecore_con_eet_raw_data_callback_add(Ecore_Con_Eet *ece, const char *name, 
Ecore_Con_Eet_Raw_Data_Cb func, const void *data)
 {
-   Ecore_Con_Eet_Raw_Data *eced;
-
-   if (!ece) return;
+   Ecore_Con_Eet_Base_Data *eced = eo_data_scope_get(ece, 
ECORE_CON_EET_BASE_CLASS);
+   Ecore_Con_Eet_Raw_Data *ecerd;
 
-   eced = calloc(1, sizeof (Ecore_Con_Eet_Raw_Data));
-   if (!eced) return;
+   ecerd = calloc(1, sizeof (Ecore_Con_Eet_Raw_Data));
+   if (!ecerd) return;
 
-   eced->func = func;
-   eced->data = data;
-   eced->name = eina_stringshare_add(name);
+   ecerd->func = func;
+   ecerd->data = data;
+   ecerd->name = eina_stringshare_add(name);
 
-   eina_hash_direct_add(ece->raw_data_callbacks, eced->name, eced);
+   eina_hash_direct_add(eced->raw_data_callbacks, ecerd->name, ecerd);
 }
 
 EAPI void
 ecore_con_eet_raw_data_callback_del(Ecore_Con_Eet *ece, const char *name)
 {
-   if (!ece) return;
+   Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece, 
ECORE_CON_EET_BASE_CLASS);
+   Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, 
ECORE_CON_EET_CLIENT_OBJ_CLASS);
 
-   if (ece->client && ece->u.client.r->buffer_handler && 
!strcmp(ece->u.client.r->buffer_handler->name, name))
+   if (eo_isa(ece, ECORE_CON_EET_CLIENT_OBJ_CLASS) &&
+       eced->r->buffer_handler &&
+       !strcmp(eced->r->buffer_handler->name, name))
      {
-        ece->u.client.r->buffer_handler = NULL;
-        free(ece->u.client.r->buffer);
-        ece->u.client.r->buffer = (void *)1;
+        eced->r->buffer_handler = NULL;
+        free(eced->r->buffer);
+        eced->r->buffer = (void *)1;
      }
-   eina_hash_del(ece->raw_data_callbacks, name, NULL);
+   eina_hash_del(base_data->raw_data_callbacks, name, NULL);
 }
 
 EAPI void
 ecore_con_eet_client_connect_callback_add(Ecore_Con_Eet *ece, 
Ecore_Con_Eet_Client_Cb func, const void *data)
 {
+   Ecore_Con_Eet_Server_Obj_Data *eces = eo_data_scope_get(ece, 
ECORE_CON_EET_SERVER_OBJ_CLASS);
    Ecore_Con_Eet_Client *c;
 
-   if (!ece || !func) return;
+   if (!eces || !func) return;
 
    c = calloc(1, sizeof (Ecore_Con_Eet_Client));
    if (!c) return;
@@ -617,21 +714,22 @@ ecore_con_eet_client_connect_callback_add(Ecore_Con_Eet 
*ece, Ecore_Con_Eet_Clie
    c->func = func;
    c->data = data;
 
-   ece->u.server.client_connect_callbacks = 
eina_list_append(ece->u.server.client_connect_callbacks, c);
+   eces->client_connect_callbacks = 
eina_list_append(eces->client_connect_callbacks, c);
 }
 
 EAPI void
 ecore_con_eet_client_connect_callback_del(Ecore_Con_Eet *ece, 
Ecore_Con_Eet_Client_Cb func, const void *data)
 {
+   Ecore_Con_Eet_Server_Obj_Data *eces = eo_data_scope_get(ece, 
ECORE_CON_EET_SERVER_OBJ_CLASS);
    Ecore_Con_Eet_Client *c;
    Eina_List *l;
 
-   if (!ece || !func) return;
+   if (!eces || !func) return;
 
-   EINA_LIST_FOREACH(ece->u.server.client_connect_callbacks, l, c)
+   EINA_LIST_FOREACH(eces->client_connect_callbacks, l, c)
      if (c->func == func && c->data == data)
        {
-          ece->u.server.client_connect_callbacks = 
eina_list_remove_list(ece->u.server.client_connect_callbacks, l);
+          eces->client_connect_callbacks = 
eina_list_remove_list(eces->client_connect_callbacks, l);
           free(c);
           return;
        }
@@ -640,9 +738,10 @@ ecore_con_eet_client_connect_callback_del(Ecore_Con_Eet 
*ece, Ecore_Con_Eet_Clie
 EAPI void
 ecore_con_eet_client_disconnect_callback_add(Ecore_Con_Eet *ece, 
Ecore_Con_Eet_Client_Cb func, const void *data)
 {
+   Ecore_Con_Eet_Server_Obj_Data *eces = eo_data_scope_get(ece, 
ECORE_CON_EET_SERVER_OBJ_CLASS);
    Ecore_Con_Eet_Client *c;
 
-   if (!ece || !func) return;
+   if (!eces || !func) return;
 
    c = calloc(1, sizeof (Ecore_Con_Eet_Client));
    if (!c) return;
@@ -650,22 +749,22 @@ 
ecore_con_eet_client_disconnect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_C
    c->func = func;
    c->data = data;
 
-   ece->u.server.client_disconnect_callbacks = 
eina_list_append(ece->u.server.client_disconnect_callbacks, c);
+   eces->client_disconnect_callbacks = 
eina_list_append(eces->client_disconnect_callbacks, c);
 }
 
 EAPI void
 ecore_con_eet_client_disconnect_callback_del(Ecore_Con_Eet *ece, 
Ecore_Con_Eet_Client_Cb func, const void *data)
 {
+   Ecore_Con_Eet_Server_Obj_Data *eced = eo_data_scope_get(ece, 
ECORE_CON_EET_SERVER_OBJ_CLASS);
    Ecore_Con_Eet_Client *c;
    Eina_List *l;
 
-   if (!ece || !func) return;
+   if (!eced || !func) return;
 
-   EINA_LIST_FOREACH(ece->u.server.client_disconnect_callbacks, l, c)
+   EINA_LIST_FOREACH(eced->client_disconnect_callbacks, l, c)
      if (c->func == func && c->data == data)
        {
-          ece->u.server.client_disconnect_callbacks = 
eina_list_remove_list(ece->u.server.client_disconnect_callbacks,
-                                                                            l);
+          eced->client_disconnect_callbacks = 
eina_list_remove_list(eced->client_disconnect_callbacks, l);
           free(c);
           return;
        }
@@ -674,9 +773,10 @@ ecore_con_eet_client_disconnect_callback_del(Ecore_Con_Eet 
*ece, Ecore_Con_Eet_C
 EAPI void
 ecore_con_eet_server_connect_callback_add(Ecore_Con_Eet *ece, 
Ecore_Con_Eet_Server_Cb func, const void *data)
 {
+   Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, 
ECORE_CON_EET_CLIENT_OBJ_CLASS);
    Ecore_Con_Eet_Server *s;
 
-   if (!ece || !func) return;
+   if (!eced || !func) return;
 
    s = calloc(1, sizeof (Ecore_Con_Eet_Server));
    if (!s) return;
@@ -684,21 +784,22 @@ ecore_con_eet_server_connect_callback_add(Ecore_Con_Eet 
*ece, Ecore_Con_Eet_Serv
    s->func = func;
    s->data = data;
 
-   ece->u.client.server_connect_callbacks = 
eina_list_append(ece->u.client.server_connect_callbacks, s);
+   eced->server_connect_callbacks = 
eina_list_append(eced->server_connect_callbacks, s);
 }
 
 EAPI void
 ecore_con_eet_server_connect_callback_del(Ecore_Con_Eet *ece, 
Ecore_Con_Eet_Server_Cb func, const void *data)
 {
+   Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, 
ECORE_CON_EET_CLIENT_OBJ_CLASS);
    Ecore_Con_Eet_Server *s;
    Eina_List *l;
 
-   if (!ece || !func) return;
+   if (!eced || !func) return;
 
-   EINA_LIST_FOREACH(ece->u.client.server_connect_callbacks, l, s)
+   EINA_LIST_FOREACH(eced->server_connect_callbacks, l, s)
      if (s->func == func && s->data == data)
        {
-          ece->u.client.server_connect_callbacks = 
eina_list_remove_list(ece->u.client.server_connect_callbacks, l);
+          eced->server_connect_callbacks = 
eina_list_remove_list(eced->server_connect_callbacks, l);
           free(s);
           return;
        }
@@ -707,9 +808,10 @@ ecore_con_eet_server_connect_callback_del(Ecore_Con_Eet 
*ece, Ecore_Con_Eet_Serv
 EAPI void
 ecore_con_eet_server_disconnect_callback_add(Ecore_Con_Eet *ece, 
Ecore_Con_Eet_Server_Cb func, const void *data)
 {
+   Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, 
ECORE_CON_EET_CLIENT_OBJ_CLASS);
    Ecore_Con_Eet_Server *s;
 
-   if (!ece || !func) return;
+   if (!eced || !func) return;
 
    s = calloc(1, sizeof (Ecore_Con_Eet_Server));
    if (!s) return;
@@ -717,21 +819,22 @@ 
ecore_con_eet_server_disconnect_callback_add(Ecore_Con_Eet *ece, Ecore_Con_Eet_S
    s->func = func;
    s->data = data;
 
-   ece->u.client.server_disconnect_callbacks = 
eina_list_append(ece->u.client.server_disconnect_callbacks, s);
+   eced->server_disconnect_callbacks = 
eina_list_append(eced->server_disconnect_callbacks, s);
 }
 
 EAPI void
 ecore_con_eet_server_disconnect_callback_del(Ecore_Con_Eet *ece, 
Ecore_Con_Eet_Server_Cb func, const void *data)
 {
+   Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, 
ECORE_CON_EET_CLIENT_OBJ_CLASS);
    Ecore_Con_Eet_Server *s;
    Eina_List *l;
 
-   if (!ece || !func) return;
+   if (!eced || !func) return;
 
-   EINA_LIST_FOREACH(ece->u.client.server_disconnect_callbacks, l, s)
+   EINA_LIST_FOREACH(eced->server_disconnect_callbacks, l, s)
      if (s->func == func && s->data == data)
        {
-          ece->u.client.server_disconnect_callbacks = 
eina_list_remove_list(ece->u.client.server_disconnect_callbacks, l);
+          eced->server_disconnect_callbacks = 
eina_list_remove_list(eced->server_disconnect_callbacks, l);
           free(s);
           return;
        }
@@ -740,16 +843,18 @@ 
ecore_con_eet_server_disconnect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_S
 EAPI void
 ecore_con_eet_data_set(Ecore_Con_Eet *ece, const void *data)
 {
-   if (!ece) return;
+   Ecore_Con_Eet_Base_Data *eced = eo_data_scope_get(ece, 
ECORE_CON_EET_BASE_CLASS);
+   if (!eced) return;
 
-   ece->data = data;
+   eced->data = data;
 }
 
 EAPI void *
 ecore_con_eet_data_get(Ecore_Con_Eet *ece)
 {
-   if (!ece) return NULL;
-   return (void *)ece->data;
+   Ecore_Con_Eet_Base_Data *eced = eo_data_scope_get(ece, 
ECORE_CON_EET_BASE_CLASS);
+   if (!eced) return NULL;
+   return (void *)eced->data;
 }
 
 EAPI Ecore_Con_Eet *
@@ -763,13 +868,16 @@ EAPI void
 ecore_con_eet_send(Ecore_Con_Reply *reply, const char *name, void *value)
 {
    Ecore_Con_Eet_Protocol protocol;
+   Ecore_Con_Eet_Base_Data *eced;
 
    if (!reply) return;
 
+   eced = eo_data_scope_get(reply->ece, ECORE_CON_EET_BASE_CLASS);
+
    protocol.type = name;
    protocol.data = value;
 
-   eet_connection_send(reply->econn, reply->ece->edd, &protocol, NULL);
+   eet_connection_send(reply->econn, eced->edd, &protocol, NULL);
 }
 
 EAPI void
@@ -779,12 +887,14 @@ ecore_con_eet_raw_send(Ecore_Con_Reply *reply, const char 
*protocol_name, const
    unsigned int protocol_length;
    unsigned int section_length;
    unsigned int size;
+   Ecore_Con_Eet_Base_Data *ece_obj;
    char *tmp;
 
    if (!reply) return;
    if (!protocol_name) return;
    if (!section) return;
 
+   ece_obj = eo_data_scope_get(reply->ece, ECORE_CON_EET_BASE_CLASS);
    protocol_length = strlen(protocol_name) + 1;
    if (protocol_length == 1) return;
    section_length = strlen(section) + 1;
@@ -807,8 +917,11 @@ ecore_con_eet_raw_send(Ecore_Con_Reply *reply, const char 
*protocol_name, const
      }
    else
      {
-        ecore_con_server_send(reply->ece->server, tmp, size);
-        ecore_con_server_send(reply->ece->server, value, length);
+        ecore_con_server_send(ece_obj->server, tmp, size);
+        ecore_con_server_send(ece_obj->server, value, length);
      }
 }
 
+#include "ecore_con_eet_base.eo.c"
+#include "ecore_con_eet_server_obj.eo.c"
+#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 @@
+class Ecore.Con.Eet.Base (Eo.Base) {
+   legacy_prefix: null;
+   eo_prefix: ecore_con_eet_base;
+   methods {
+      @property server {
+         /*@
+          * The server object to which we send and receive.
+          */
+         set {
+         }
+         get {
+         }
+         values {
+            data: Ecore_Con_Server*;
+         }
+      }
+   }
+   implements {
+      Eo.Base.constructor;
+      Eo.Base.destructor;
+      Eo.Base.finalize;
+   }
+}
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 @@
+class Ecore.Con.Eet.Client.Obj (Ecore.Con.Eet.Base) {
+   legacy_prefix: null;
+   eo_prefix: ecore_con_eet_client_obj;
+   implements {
+        Eo.Base.constructor;
+        Eo.Base.destructor;
+   }
+}
+
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 @@
+class Ecore.Con.Eet.Server.Obj (Ecore.Con.Eet.Base) {
+   legacy_prefix: null;
+   eo_prefix: ecore_con_eet_server_obj;
+   implements {
+        Eo.Base.constructor;
+        Eo.Base.destructor;
+   }
+}
+

-- 


Reply via email to