summaryrefslogtreecommitdiff
path: root/src/lib/eldbus/eldbus_model_signal.c
diff options
context:
space:
mode:
authorGuilherme Lepsch <lepsch@expertisesolutions.com.br>2015-01-09 14:20:14 -0200
committerCedric BAIL <cedric@osg.samsung.com>2015-12-10 12:02:30 -0800
commit10fa1b5b4b2454437c00a9b8931bb3f9ddb9e99c (patch)
treeb4238f5f83b55463ad2e88e97dc968f2a607a668 /src/lib/eldbus/eldbus_model_signal.c
parent48b22214493958fc852f101009b0e8a88aa77e05 (diff)
eldbus: add efl.model implementation.
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib/eldbus/eldbus_model_signal.c')
-rw-r--r--src/lib/eldbus/eldbus_model_signal.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/lib/eldbus/eldbus_model_signal.c b/src/lib/eldbus/eldbus_model_signal.c
new file mode 100644
index 0000000000..4ef32bb906
--- /dev/null
+++ b/src/lib/eldbus/eldbus_model_signal.c
@@ -0,0 +1,106 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include "eldbus_model_arguments_private.h"
6#include "eldbus_model_signal_private.h"
7#include "eldbus_model_private.h"
8
9#include <Eina.h>
10
11#define MY_CLASS ELDBUS_MODEL_SIGNAL_CLASS
12#define MY_CLASS_NAME "Eldbus_Model_Signal"
13
14static void _eldbus_model_signal_handler_cb(void *, const Eldbus_Message *);
15static void _eldbus_model_signal_callback_add(Eldbus_Model_Signal_Data *);
16static void _eldbus_model_signal_callback_del(Eldbus_Model_Signal_Data *);
17
18static Eo_Base*
19_eldbus_model_signal_eo_base_constructor(Eo *obj, Eldbus_Model_Signal_Data *pd)
20{
21 eo_do_super(obj, MY_CLASS, eo_constructor());
22
23 pd->obj = obj;
24 pd->handler = NULL;
25 pd->signal = NULL;
26 return obj;
27}
28
29static void
30_eldbus_model_signal_constructor(Eo *obj EINA_UNUSED,
31 Eldbus_Model_Signal_Data *pd,
32 Eldbus_Proxy *proxy,
33 const Eldbus_Introspection_Signal *signal)
34{
35 EINA_SAFETY_ON_NULL_RETURN(proxy);
36 EINA_SAFETY_ON_NULL_RETURN(signal);
37
38 eo_do_super(obj, MY_CLASS, eldbus_model_arguments_constructor(proxy, signal->name, signal->arguments));
39
40 pd->signal = signal;
41}
42
43static void
44_eldbus_model_signal_eo_base_destructor(Eo *obj, Eldbus_Model_Signal_Data *pd)
45{
46 _eldbus_model_signal_callback_del(pd);
47
48 eo_do_super(obj, MY_CLASS, eo_destructor());
49}
50
51static void
52_eldbus_model_signal_efl_model_base_properties_load(Eo *obj, Eldbus_Model_Signal_Data *pd)
53{
54 Eldbus_Model_Arguments_Data *args_data = eo_data_scope_get(pd->obj, ELDBUS_MODEL_ARGUMENTS_CLASS);
55 EINA_SAFETY_ON_NULL_RETURN(args_data);
56
57 if (args_data->load.status & EFL_MODEL_LOAD_STATUS_LOADED_PROPERTIES)
58 return;
59
60 _eldbus_model_signal_callback_add(pd);
61
62 eo_do_super(obj, MY_CLASS, efl_model_properties_load());
63}
64
65static void
66_eldbus_model_signal_efl_model_base_unload(Eo *obj EINA_UNUSED, Eldbus_Model_Signal_Data *pd)
67{
68 _eldbus_model_signal_callback_del(pd);
69 eo_do_super(obj, MY_CLASS, efl_model_unload());
70}
71
72static void
73_eldbus_model_signal_callback_add(Eldbus_Model_Signal_Data *pd)
74{
75 EINA_SAFETY_ON_NULL_RETURN(pd);
76 EINA_SAFETY_ON_FALSE_RETURN(NULL == pd->handler);
77
78 Eldbus_Model_Arguments_Data *args_data = eo_data_scope_get(pd->obj, ELDBUS_MODEL_ARGUMENTS_CLASS);
79 EINA_SAFETY_ON_NULL_RETURN(args_data);
80
81 pd->handler = eldbus_proxy_signal_handler_add(args_data->proxy, pd->signal->name, _eldbus_model_signal_handler_cb, pd);
82}
83
84static void
85_eldbus_model_signal_callback_del(Eldbus_Model_Signal_Data *pd)
86{
87 EINA_SAFETY_ON_NULL_RETURN(pd);
88
89 if (pd->handler)
90 {
91 eldbus_signal_handler_unref(pd->handler);
92 pd->handler = NULL;
93 }
94}
95
96static void
97_eldbus_model_signal_handler_cb(void *data, const Eldbus_Message *msg)
98{
99 Eldbus_Model_Signal_Data *pd = (Eldbus_Model_Signal_Data*)data;
100
101 Eldbus_Model_Arguments_Data *args_data = eo_data_scope_get(pd->obj, ELDBUS_MODEL_ARGUMENTS_CLASS);
102
103 eldbus_model_arguments_process_arguments(args_data, msg, NULL);
104}
105
106#include "eldbus_model_signal.eo.c"