summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2014-08-23 15:56:09 +0200
committerdavemds <dave@gurumeditation.it>2014-08-23 15:56:09 +0200
commite5d3ea2e96556ebb4e7f0ef227a67323951f1dd6 (patch)
tree33e6134a692fab026554b01f02850529b4f01c61
parent4a337ccc10559ebc694ad65b30579b2cb2a5fccd (diff)
just move some functions around for readability
-rw-r--r--efl/dbus_mainloop/e_dbus.c187
1 files changed, 92 insertions, 95 deletions
diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c
index fb0204e..d133a54 100644
--- a/efl/dbus_mainloop/e_dbus.c
+++ b/efl/dbus_mainloop/e_dbus.c
@@ -38,6 +38,97 @@ static int _edbus_init_count = 0;
38 38
39 39
40static void 40static void
41e_dbus_message_free(void *data, void *message)
42{
43 dbus_message_unref(message);
44}
45
46static DBusHandlerResult
47e_dbus_filter(DBusConnection *conn, DBusMessage *message, void *user_data)
48{
49 E_DBus_Connection *cd = user_data;
50 DBG("-----------------");
51 DBG("Message!");
52
53 DBG("type: %s", dbus_message_type_to_string(dbus_message_get_type(message)));
54 DBG("path: %s", dbus_message_get_path(message));
55 DBG("interface: %s", dbus_message_get_interface(message));
56 DBG("member: %s", dbus_message_get_member(message));
57 DBG("sender: %s", dbus_message_get_sender(message));
58
59 switch (dbus_message_get_type(message))
60 {
61 case DBUS_MESSAGE_TYPE_METHOD_CALL:
62 DBG("signature: %s", dbus_message_get_signature(message));
63 break;
64 case DBUS_MESSAGE_TYPE_METHOD_RETURN:
65 DBG("reply serial %d", dbus_message_get_reply_serial(message));
66 break;
67 case DBUS_MESSAGE_TYPE_ERROR:
68 DBG("error: %s", dbus_message_get_error_name(message));
69 break;
70 case DBUS_MESSAGE_TYPE_SIGNAL:
71 dbus_message_ref(message);
72 if (cd->signal_dispatcher) cd->signal_dispatcher(cd, message);
73 ecore_event_add(E_DBUS_EVENT_SIGNAL, message, e_dbus_message_free, NULL);
74 break;
75 default:
76 break;
77 }
78 DBG("-----------------");
79
80 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
81}
82
83static Eina_Bool
84e_dbus_idler(void *data)
85{
86 E_DBus_Connection *cd;
87 cd = data;
88
89 if (DBUS_DISPATCH_COMPLETE == dbus_connection_get_dispatch_status(cd->conn))
90 {
91 DBG("done dispatching!");
92 cd->idler = NULL;
93 return ECORE_CALLBACK_CANCEL;
94 }
95 e_dbus_idler_active++;
96 dbus_connection_ref(cd->conn);
97 DBG("dispatch()");
98 dbus_connection_dispatch(cd->conn);
99 dbus_connection_unref(cd->conn);
100 e_dbus_idler_active--;
101 // e_dbus_signal_handlers_clean(cd); // TODO XXX
102 if (!e_dbus_idler_active && close_connection)
103 {
104 do
105 {
106 e_dbus_connection_close(cd);
107 } while (--close_connection);
108 }
109 return ECORE_CALLBACK_RENEW;
110}
111
112static void
113cb_dispatch_status(DBusConnection *conn, DBusDispatchStatus new_status, void *data)
114{
115 E_DBus_Connection *cd;
116
117 DBG("dispatch status: %d!", new_status);
118 cd = data;
119
120 if (new_status == DBUS_DISPATCH_DATA_REMAINS && !cd->idler)
121 cd->idler = ecore_idler_add(e_dbus_idler, cd);
122 else if (new_status != DBUS_DISPATCH_DATA_REMAINS && cd->idler)
123 {
124 ecore_idler_del(cd->idler);
125 cd->idler = NULL;
126 }
127}
128
129
130/* ecore fd handler */
131static void
41e_dbus_fd_handler_del(E_DBus_Handler_Data *hd) 132e_dbus_fd_handler_del(E_DBus_Handler_Data *hd)
42{ 133{
43 if (!hd->fd_handler) return; 134 if (!hd->fd_handler) return;
@@ -132,104 +223,12 @@ e_dbus_connection_data_watch_add(E_DBus_Connection *cd, DBusWatch *watch)
132 hd->watch = watch; 223 hd->watch = watch;
133 224
134 hd->enabled = dbus_watch_get_enabled(watch); 225 hd->enabled = dbus_watch_get_enabled(watch);
135// #if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR == 1 && DBUS_VERSION_MICRO>= 1) || (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR > 1) || (DBUS_VERSION_MAJOR > 1)
136 hd->fd = dbus_watch_get_unix_fd(hd->watch); 226 hd->fd = dbus_watch_get_unix_fd(hd->watch);
137// #else 227
138 // hd->fd = dbus_watch_get_fd(hd->watch);
139// #endif
140 DBG("watch add (enabled: %d)", hd->enabled); 228 DBG("watch add (enabled: %d)", hd->enabled);
141 if (hd->enabled) e_dbus_fd_handler_add(hd); 229 if (hd->enabled) e_dbus_fd_handler_add(hd);
142} 230}
143 231
144static void
145e_dbus_message_free(void *data, void *message)
146{
147 dbus_message_unref(message);
148}
149
150static DBusHandlerResult
151e_dbus_filter(DBusConnection *conn, DBusMessage *message, void *user_data)
152{
153 E_DBus_Connection *cd = user_data;
154 DBG("-----------------");
155 DBG("Message!");
156
157 DBG("type: %s", dbus_message_type_to_string(dbus_message_get_type(message)));
158 DBG("path: %s", dbus_message_get_path(message));
159 DBG("interface: %s", dbus_message_get_interface(message));
160 DBG("member: %s", dbus_message_get_member(message));
161 DBG("sender: %s", dbus_message_get_sender(message));
162
163 switch (dbus_message_get_type(message))
164 {
165 case DBUS_MESSAGE_TYPE_METHOD_CALL:
166 DBG("signature: %s", dbus_message_get_signature(message));
167 break;
168 case DBUS_MESSAGE_TYPE_METHOD_RETURN:
169 DBG("reply serial %d", dbus_message_get_reply_serial(message));
170 break;
171 case DBUS_MESSAGE_TYPE_ERROR:
172 DBG("error: %s", dbus_message_get_error_name(message));
173 break;
174 case DBUS_MESSAGE_TYPE_SIGNAL:
175 dbus_message_ref(message);
176 if (cd->signal_dispatcher) cd->signal_dispatcher(cd, message);
177 ecore_event_add(E_DBUS_EVENT_SIGNAL, message, e_dbus_message_free, NULL);
178 break;
179 default:
180 break;
181 }
182 DBG("-----------------");
183
184 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
185}
186
187static Eina_Bool
188e_dbus_idler(void *data)
189{
190 E_DBus_Connection *cd;
191 cd = data;
192
193 if (DBUS_DISPATCH_COMPLETE == dbus_connection_get_dispatch_status(cd->conn))
194 {
195 DBG("done dispatching!");
196 cd->idler = NULL;
197 return ECORE_CALLBACK_CANCEL;
198 }
199 e_dbus_idler_active++;
200 dbus_connection_ref(cd->conn);
201 DBG("dispatch()");
202 dbus_connection_dispatch(cd->conn);
203 dbus_connection_unref(cd->conn);
204 e_dbus_idler_active--;
205 // e_dbus_signal_handlers_clean(cd); // TODO XXX
206 if (!e_dbus_idler_active && close_connection)
207 {
208 do
209 {
210 e_dbus_connection_close(cd);
211 } while (--close_connection);
212 }
213 return ECORE_CALLBACK_RENEW;
214}
215
216static void
217cb_dispatch_status(DBusConnection *conn, DBusDispatchStatus new_status, void *data)
218{
219 E_DBus_Connection *cd;
220
221 DBG("dispatch status: %d!", new_status);
222 cd = data;
223
224 if (new_status == DBUS_DISPATCH_DATA_REMAINS && !cd->idler)
225 cd->idler = ecore_idler_add(e_dbus_idler, cd);
226 else if (new_status != DBUS_DISPATCH_DATA_REMAINS && cd->idler)
227 {
228 ecore_idler_del(cd->idler);
229 cd->idler = NULL;
230 }
231}
232
233 232
234/* watch */ 233/* watch */
235static dbus_bool_t 234static dbus_bool_t
@@ -445,7 +444,6 @@ e_dbus_init(void)
445 } 444 }
446 445
447 E_DBUS_EVENT_SIGNAL = ecore_event_type_new(); 446 E_DBUS_EVENT_SIGNAL = ecore_event_type_new();
448 // e_dbus_object_init();
449 447
450 return _edbus_init_count; 448 return _edbus_init_count;
451} 449}
@@ -461,7 +459,6 @@ e_dbus_shutdown(void)
461 if (--_edbus_init_count) 459 if (--_edbus_init_count)
462 return _edbus_init_count; 460 return _edbus_init_count;
463 461
464 // e_dbus_object_shutdown();
465 ecore_shutdown(); 462 ecore_shutdown();
466 eina_log_domain_unregister(_e_dbus_log_dom); 463 eina_log_domain_unregister(_e_dbus_log_dom);
467 _e_dbus_log_dom = -1; 464 _e_dbus_log_dom = -1;