summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorSrivardhan Hebbar <sri.hebbar@samsung.com>2015-06-29 14:21:13 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-06-29 14:56:23 +0200
commit947edc84717a5780993e91e00ee971c88d224f48 (patch)
tree22d124356d09d3c494c992f3c92686cab6359061 /src/lib/ecore_con
parent739eb4bd0d241aa607766fa1278aa1acd6dbfb92 (diff)
ecore_con: eoify ecore_con_eet functions.
Summary: Depends on D2602 Made all functions eo. Reviewers: cedric Reviewed By: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D2695 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/Ecore_Con_Eet.h2
-rw-r--r--src/lib/ecore_con/ecore_con_eet.c228
-rw-r--r--src/lib/ecore_con/ecore_con_eet_base.eo80
3 files changed, 208 insertions, 102 deletions
diff --git a/src/lib/ecore_con/Ecore_Con_Eet.h b/src/lib/ecore_con/Ecore_Con_Eet.h
index a85948cf09..0257b7f68e 100644
--- a/src/lib/ecore_con/Ecore_Con_Eet.h
+++ b/src/lib/ecore_con/Ecore_Con_Eet.h
@@ -254,7 +254,7 @@ EAPI void ecore_con_eet_data_set(Ecore_Con_Eet *ece, const void *data);
254 * @param ece An Ecore_Con_Eet object. 254 * @param ece An Ecore_Con_Eet object.
255 * @return The data attached to the Ecore_Con_Eet object. 255 * @return The data attached to the Ecore_Con_Eet object.
256 */ 256 */
257EAPI void *ecore_con_eet_data_get(Ecore_Con_Eet *ece); 257EAPI const void *ecore_con_eet_data_get(Ecore_Con_Eet *ece);
258 258
259/** 259/**
260 * Get the Ecore_Con_Eet object corresponding to the Ecore_Con_Reply object. 260 * Get the Ecore_Con_Eet object corresponding to the Ecore_Con_Reply object.
diff --git a/src/lib/ecore_con/ecore_con_eet.c b/src/lib/ecore_con/ecore_con_eet.c
index d2bbd28122..0783c2ce47 100644
--- a/src/lib/ecore_con/ecore_con_eet.c
+++ b/src/lib/ecore_con/ecore_con_eet.c
@@ -20,6 +20,7 @@
20#include "Ecore_Con_Eet.h" 20#include "Ecore_Con_Eet.h"
21 21
22#define ECORE_CON_EET_RAW_MAGIC 0xDEAD007 22#define ECORE_CON_EET_RAW_MAGIC 0xDEAD007
23#define ECORE_CON_EET_DATA_KEY "ecore_con_eet_data_key"
23 24
24typedef struct _Ecore_Con_Eet_Base_Data Ecore_Con_Eet_Base_Data; 25typedef 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_Server_Obj_Data Ecore_Con_Eet_Server_Obj_Data;
@@ -100,8 +101,6 @@ struct _Ecore_Con_Eet_Base_Data
100 101
101 Eina_Hash *data_callbacks; 102 Eina_Hash *data_callbacks;
102 Eina_Hash *raw_data_callbacks; 103 Eina_Hash *raw_data_callbacks;
103
104 const void *data;
105}; 104};
106 105
107static void 106static void
@@ -462,6 +461,118 @@ _ecore_con_eet_client_data(void *data, int type EINA_UNUSED, Ecore_Con_Event_Ser
462/************* 461/*************
463 * Generated API 462 * Generated API
464 */ 463 */
464
465EOLIAN static void
466_ecore_con_eet_base_data_callback_set(Eo *obj EINA_UNUSED, Ecore_Con_Eet_Base_Data *pd, const char *name, Ecore_Con_Eet_Data_Cb func, const void *data)
467{
468 Ecore_Con_Eet_Data *eced;
469
470 eced = calloc(1, sizeof (Ecore_Con_Eet_Data));
471 if (!eced) return;
472
473 eced->func = func;
474 eced->data = data;
475 eced->name = eina_stringshare_add(name);
476
477 eina_hash_direct_add(pd->data_callbacks, eced->name, eced);
478}
479
480EOLIAN static void
481_ecore_con_eet_base_raw_data_callback_set(Eo *obj EINA_UNUSED, Ecore_Con_Eet_Base_Data *pd, const char *name, Ecore_Con_Eet_Raw_Data_Cb func, const void *data)
482{
483 Ecore_Con_Eet_Raw_Data *ecerd;
484
485 ecerd = calloc(1, sizeof (Ecore_Con_Eet_Raw_Data));
486 if (!ecerd) return;
487
488 ecerd->func = func;
489 ecerd->data = data;
490 ecerd->name = eina_stringshare_add(name);
491
492 eina_hash_direct_add(pd->raw_data_callbacks, ecerd->name, ecerd);
493}
494
495EOLIAN static void
496_ecore_con_eet_base_data_callback_del(Eo *obj EINA_UNUSED, Ecore_Con_Eet_Base_Data *pd, const char *name)
497{
498 eina_hash_del(pd->data_callbacks, name, NULL);
499}
500
501EOLIAN static void
502_ecore_con_eet_base_raw_data_callback_del(Eo *obj, Ecore_Con_Eet_Base_Data *pd, const char *name)
503{
504 Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(obj, ECORE_CON_EET_CLIENT_OBJ_CLASS);
505
506 if (eo_isa(obj, ECORE_CON_EET_CLIENT_OBJ_CLASS) &&
507 eced->r->buffer_handler &&
508 !strcmp(eced->r->buffer_handler->name, name))
509 {
510 eced->r->buffer_handler = NULL;
511 free(eced->r->buffer);
512 eced->r->buffer = (void *)1;
513 }
514 eina_hash_del(pd->raw_data_callbacks, name, NULL);
515}
516
517EOLIAN static void
518_ecore_con_eet_base_send(Eo *obj EINA_UNUSED, Ecore_Con_Eet_Base_Data *pd, Ecore_Con_Reply *reply, const char *name, void *value)
519{
520 Ecore_Con_Eet_Protocol protocol;
521
522 if (!reply) return;
523
524 protocol.type = name;
525 protocol.data = value;
526
527 eet_connection_send(reply->econn, pd->edd, &protocol, NULL);
528}
529
530EOLIAN static void
531_ecore_con_eet_base_raw_send(Eo *obj EINA_UNUSED, Ecore_Con_Eet_Base_Data *pd, Ecore_Con_Reply *reply, const char *protocol_name, const char *section, void *value, unsigned int length)
532{
533 unsigned int protocol[4];
534 unsigned int protocol_length;
535 unsigned int section_length;
536 unsigned int size;
537 char *tmp;
538
539 if (!reply) return;
540 if (!protocol_name) return;
541 if (!section) return;
542
543 protocol_length = strlen(protocol_name) + 1;
544 if (protocol_length == 1) return;
545 section_length = strlen(section) + 1;
546
547 protocol[0] = htonl(ECORE_CON_EET_RAW_MAGIC);
548 protocol[1] = htonl(protocol_length);
549 protocol[2] = htonl(section_length);
550 protocol[3] = htonl(length);
551
552 size = sizeof (protocol) + protocol_length + section_length;
553 tmp = alloca(size);
554 memcpy(tmp, protocol, sizeof (protocol));
555 memcpy(tmp + sizeof (protocol), protocol_name, protocol_length);
556 memcpy(tmp + sizeof (protocol) + protocol_length, section, section_length);
557
558 if (reply->client)
559 {
560 ecore_con_client_send(reply->client, tmp, size);
561 ecore_con_client_send(reply->client, value, length);
562 }
563 else
564 {
565 ecore_con_server_send(pd->server, tmp, size);
566 ecore_con_server_send(pd->server, value, length);
567 }
568}
569
570EOLIAN static void
571_ecore_con_eet_base_register(Eo *obj EINA_UNUSED, Ecore_Con_Eet_Base_Data *pd, const char *name, Eet_Data_Descriptor *edd)
572{
573 EET_DATA_DESCRIPTOR_ADD_MAPPING(pd->matching, name, edd);
574}
575
465EOLIAN static Eo_Base * 576EOLIAN static Eo_Base *
466_ecore_con_eet_server_obj_eo_base_constructor(Eo *obj, Ecore_Con_Eet_Server_Obj_Data *pd EINA_UNUSED) 577_ecore_con_eet_server_obj_eo_base_constructor(Eo *obj, Ecore_Con_Eet_Server_Obj_Data *pd EINA_UNUSED)
467{ 578{
@@ -635,69 +746,31 @@ ecore_con_eet_server_free(Ecore_Con_Eet *r)
635EAPI void 746EAPI void
636ecore_con_eet_register(Ecore_Con_Eet *ece, const char *name, Eet_Data_Descriptor *edd) 747ecore_con_eet_register(Ecore_Con_Eet *ece, const char *name, Eet_Data_Descriptor *edd)
637{ 748{
638 Ecore_Con_Eet_Base_Data *eceb = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS); 749 eo_do(ece, ecore_con_eet_base_register(name, edd));
639
640 EET_DATA_DESCRIPTOR_ADD_MAPPING(eceb->matching, name, edd);
641} 750}
642 751
643EAPI void 752EAPI void
644ecore_con_eet_data_callback_add(Ecore_Con_Eet *ece, const char *name, Ecore_Con_Eet_Data_Cb func, const void *data) 753ecore_con_eet_data_callback_add(Ecore_Con_Eet *ece, const char *name, Ecore_Con_Eet_Data_Cb func, const void *data)
645{ 754{
646 Ecore_Con_Eet_Base_Data *eceb = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS); 755 eo_do(ece, ecore_con_eet_base_data_callback_set(name, func, data));
647 Ecore_Con_Eet_Data *eced;
648
649 if (!ece) return;
650
651 eced = calloc(1, sizeof (Ecore_Con_Eet_Data));
652 if (!eced) return;
653
654 eced->func = func;
655 eced->data = data;
656 eced->name = eina_stringshare_add(name);
657
658 eina_hash_direct_add(eceb->data_callbacks, eced->name, eced);
659} 756}
660 757
661EAPI void 758EAPI void
662ecore_con_eet_data_callback_del(Ecore_Con_Eet *ece, const char *name) 759ecore_con_eet_data_callback_del(Ecore_Con_Eet *ece, const char *name)
663{ 760{
664 Ecore_Con_Eet_Base_Data *eceb = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS); 761 eo_do(ece, ecore_con_eet_base_data_callback_del(name));
665
666 if (!eceb) return;
667 eina_hash_del(eceb->data_callbacks, name, NULL);
668} 762}
669 763
670EAPI void 764EAPI void
671ecore_con_eet_raw_data_callback_add(Ecore_Con_Eet *ece, const char *name, Ecore_Con_Eet_Raw_Data_Cb func, const void *data) 765ecore_con_eet_raw_data_callback_add(Ecore_Con_Eet *ece, const char *name, Ecore_Con_Eet_Raw_Data_Cb func, const void *data)
672{ 766{
673 Ecore_Con_Eet_Base_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS); 767 eo_do(ece, ecore_con_eet_base_raw_data_callback_set(name, func, data));
674 Ecore_Con_Eet_Raw_Data *ecerd;
675
676 ecerd = calloc(1, sizeof (Ecore_Con_Eet_Raw_Data));
677 if (!ecerd) return;
678
679 ecerd->func = func;
680 ecerd->data = data;
681 ecerd->name = eina_stringshare_add(name);
682
683 eina_hash_direct_add(eced->raw_data_callbacks, ecerd->name, ecerd);
684} 768}
685 769
686EAPI void 770EAPI void
687ecore_con_eet_raw_data_callback_del(Ecore_Con_Eet *ece, const char *name) 771ecore_con_eet_raw_data_callback_del(Ecore_Con_Eet *ece, const char *name)
688{ 772{
689 Ecore_Con_Eet_Base_Data *base_data = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS); 773 eo_do(ece, ecore_con_eet_base_raw_data_callback_del(name));
690 Ecore_Con_Eet_Client_Obj_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_CLIENT_OBJ_CLASS);
691
692 if (eo_isa(ece, ECORE_CON_EET_CLIENT_OBJ_CLASS) &&
693 eced->r->buffer_handler &&
694 !strcmp(eced->r->buffer_handler->name, name))
695 {
696 eced->r->buffer_handler = NULL;
697 free(eced->r->buffer);
698 eced->r->buffer = (void *)1;
699 }
700 eina_hash_del(base_data->raw_data_callbacks, name, NULL);
701} 774}
702 775
703EAPI void 776EAPI void
@@ -843,18 +916,15 @@ ecore_con_eet_server_disconnect_callback_del(Ecore_Con_Eet *ece, Ecore_Con_Eet_S
843EAPI void 916EAPI void
844ecore_con_eet_data_set(Ecore_Con_Eet *ece, const void *data) 917ecore_con_eet_data_set(Ecore_Con_Eet *ece, const void *data)
845{ 918{
846 Ecore_Con_Eet_Base_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS); 919 eo_do(ece,eo_key_data_set(ECORE_CON_EET_DATA_KEY, data));
847 if (!eced) return;
848
849 eced->data = data;
850} 920}
851 921
852EAPI void * 922EAPI const void *
853ecore_con_eet_data_get(Ecore_Con_Eet *ece) 923ecore_con_eet_data_get(Ecore_Con_Eet *ece)
854{ 924{
855 Ecore_Con_Eet_Base_Data *eced = eo_data_scope_get(ece, ECORE_CON_EET_BASE_CLASS); 925 const void *temp;
856 if (!eced) return NULL; 926
857 return (void *)eced->data; 927 return eo_do_ret(ece, temp, eo_key_data_get(ECORE_CON_EET_DATA_KEY));
858} 928}
859 929
860EAPI Ecore_Con_Eet * 930EAPI Ecore_Con_Eet *
@@ -867,59 +937,15 @@ ecore_con_eet_reply(Ecore_Con_Reply *reply)
867EAPI void 937EAPI void
868ecore_con_eet_send(Ecore_Con_Reply *reply, const char *name, void *value) 938ecore_con_eet_send(Ecore_Con_Reply *reply, const char *name, void *value)
869{ 939{
870 Ecore_Con_Eet_Protocol protocol; 940 eo_do(reply->ece, ecore_con_eet_base_send(reply, name, value));
871 Ecore_Con_Eet_Base_Data *eced;
872
873 if (!reply) return;
874
875 eced = eo_data_scope_get(reply->ece, ECORE_CON_EET_BASE_CLASS);
876
877 protocol.type = name;
878 protocol.data = value;
879
880 eet_connection_send(reply->econn, eced->edd, &protocol, NULL);
881} 941}
882 942
883EAPI void 943EAPI void
884ecore_con_eet_raw_send(Ecore_Con_Reply *reply, const char *protocol_name, const char *section, void *value, unsigned int length) 944ecore_con_eet_raw_send(Ecore_Con_Reply *reply, const char *protocol_name, const char *section, void *value, unsigned int length)
885{ 945{
886 unsigned int protocol[4]; 946 eo_do(reply->ece,
887 unsigned int protocol_length; 947 ecore_con_eet_base_raw_send(reply, protocol_name, section, value,
888 unsigned int section_length; 948 length));
889 unsigned int size;
890 Ecore_Con_Eet_Base_Data *ece_obj;
891 char *tmp;
892
893 if (!reply) return;
894 if (!protocol_name) return;
895 if (!section) return;
896
897 ece_obj = eo_data_scope_get(reply->ece, ECORE_CON_EET_BASE_CLASS);
898 protocol_length = strlen(protocol_name) + 1;
899 if (protocol_length == 1) return;
900 section_length = strlen(section) + 1;
901
902 protocol[0] = htonl(ECORE_CON_EET_RAW_MAGIC);
903 protocol[1] = htonl(protocol_length);
904 protocol[2] = htonl(section_length);
905 protocol[3] = htonl(length);
906
907 size = sizeof (protocol) + protocol_length + section_length;
908 tmp = alloca(size);
909 memcpy(tmp, protocol, sizeof (protocol));
910 memcpy(tmp + sizeof (protocol), protocol_name, protocol_length);
911 memcpy(tmp + sizeof (protocol) + protocol_length, section, section_length);
912
913 if (reply->client)
914 {
915 ecore_con_client_send(reply->client, tmp, size);
916 ecore_con_client_send(reply->client, value, length);
917 }
918 else
919 {
920 ecore_con_server_send(ece_obj->server, tmp, size);
921 ecore_con_server_send(ece_obj->server, value, length);
922 }
923} 949}
924 950
925#include "ecore_con_eet_base.eo.c" 951#include "ecore_con_eet_base.eo.c"
diff --git a/src/lib/ecore_con/ecore_con_eet_base.eo b/src/lib/ecore_con/ecore_con_eet_base.eo
index 5b65b8efe8..9902a051f3 100644
--- a/src/lib/ecore_con/ecore_con_eet_base.eo
+++ b/src/lib/ecore_con/ecore_con_eet_base.eo
@@ -14,6 +14,86 @@ class Ecore.Con.Eet.Base (Eo.Base) {
14 data: Ecore_Con_Server*; 14 data: Ecore_Con_Server*;
15 } 15 }
16 } 16 }
17 @property data_callback {
18 /*@
19 * A callback function which should be called when data is
20 * received by ecore_con_eet_object.
21 */
22 set {
23 }
24 values {
25 name: const (char) *; /*@ The name of the eet stream. */
26 func: Ecore_Con_Eet_Data_Cb; /*@ The callback function. */
27 data: const (void) *; /*@ The data (if any) that should be
28 * passed to callback function. */
29 }
30 }
31 @property raw_data_callback {
32 /*@
33 * A callback function which should be calledn when raw data
34 * is received by ecore_con_eet_object.
35 */
36 set {
37 }
38 values {
39 name: const (char) *; /*@ The name of the eet stream. */
40 func: Ecore_Con_Eet_Raw_Data_Cb; /*@ The callback function. */
41 data: const (void) *; /* The data (if any) that should be
42 * passed to callback function. */
43 }
44 }
45 data_callback_del {
46 /*@
47 * Function to delete the @data_callback.
48 */
49 params {
50 name: const (char) *; /*@ The name of the eet stream. */
51 }
52 }
53 raw_data_callback_del {
54 /*@
55 * Function to delete the @raw_data_callback.
56 */
57 params {
58 name: const (char) *; /*@ The name of the eet stream. */
59 }
60 }
61 register {
62 /*@
63 * Function to register a @Eet_Data_Descriptor to the
64 * ecore_con_eet object.
65 */
66 legacy: ecore_con_eet;
67 params {
68 name: const (char) *; /*@ The name of the eet stream. */
69 edd: Eet_Data_Descriptor *; /*@ The Eet_Data_Descriptor that
70 * is to be registered. */
71 }
72 }
73 send {
74 /*@
75 * Function to send data.
76 */
77 params {
78 reply: Ecore_Con_Reply *; /*@ Contains the ecore_con_eet object
79 to which the data has to be sent. */
80 name: const (char) *; /*@ The name of the eet stream. */
81 value: void *; /*@ Actual data */
82 }
83 }
84 raw_send {
85 /*@
86 * Function to send raw data.
87 */
88 params {
89 reply: Ecore_Con_Reply *; /*@ Contains the ecore_con_eet object
90 to which the data has to be sent. */
91 protocol_name: const (char) *; /*@ The name of the eet stream. */
92 section: const (char) *; /*@ Name of section in the eet descriptor. */
93 value: void *; /*@ The value of the section. */
94 length: uint; /*@ The length of the data that is being sent. */
95 }
96 }
17 } 97 }
18 implements { 98 implements {
19 Eo.Base.constructor; 99 Eo.Base.constructor;