diff options
author | davemds <dave@gurumeditation.it> | 2014-08-23 17:34:37 +0200 |
---|---|---|
committer | davemds <dave@gurumeditation.it> | 2014-08-23 17:34:37 +0200 |
commit | 1de3ffccd6bd3ff33e6c45fcdc1c181ae904341d (patch) | |
tree | 474e3b734166a2d025482c99e1334d9ad0842720 | |
parent | 6d5a1d1169aa01a549cd8c28d97fc92ba904461c (diff) |
Simplify: no need to keep a local copy of the watch state
-rw-r--r-- | efl/dbus_mainloop/e_dbus.c | 25 | ||||
-rw-r--r-- | efl/dbus_mainloop/e_dbus.h | 2 |
2 files changed, 13 insertions, 14 deletions
diff --git a/efl/dbus_mainloop/e_dbus.c b/efl/dbus_mainloop/e_dbus.c index ff9d9d4..730f309 100644 --- a/efl/dbus_mainloop/e_dbus.c +++ b/efl/dbus_mainloop/e_dbus.c | |||
@@ -154,7 +154,7 @@ e_dbus_fd_handler(void *data, Ecore_Fd_Handler *fd_handler) | |||
154 | 154 | ||
155 | hd = data; | 155 | hd = data; |
156 | 156 | ||
157 | if (!hd->enabled) | 157 | if (!dbus_watch_get_enabled(hd->watch)) |
158 | { | 158 | { |
159 | e_dbus_fd_handler_del(hd); | 159 | e_dbus_fd_handler_del(hd); |
160 | return ECORE_CALLBACK_CANCEL; | 160 | return ECORE_CALLBACK_CANCEL; |
@@ -183,9 +183,12 @@ e_dbus_fd_handler_add(E_DBus_Handler_Data *hd) | |||
183 | Ecore_Fd_Handler_Flags eflags; | 183 | Ecore_Fd_Handler_Flags eflags; |
184 | Eina_List *l; | 184 | Eina_List *l; |
185 | Ecore_Fd_Handler *fdh; | 185 | Ecore_Fd_Handler *fdh; |
186 | int fd; | ||
186 | 187 | ||
187 | DDBG(" FD handler add"); | 188 | DDBG(" FD handler add"); |
188 | if (hd->fd_handler) return; | 189 | if (hd->fd_handler) return; |
190 | |||
191 | fd = dbus_watch_get_unix_fd(hd->watch); | ||
189 | dflags = dbus_watch_get_flags(hd->watch); | 192 | dflags = dbus_watch_get_flags(hd->watch); |
190 | eflags = ECORE_FD_ERROR; | 193 | eflags = ECORE_FD_ERROR; |
191 | if (dflags & DBUS_WATCH_READABLE) eflags |= ECORE_FD_READ; | 194 | if (dflags & DBUS_WATCH_READABLE) eflags |= ECORE_FD_READ; |
@@ -193,11 +196,11 @@ e_dbus_fd_handler_add(E_DBus_Handler_Data *hd) | |||
193 | 196 | ||
194 | EINA_LIST_FOREACH(hd->cd->fd_handlers, l, fdh) | 197 | EINA_LIST_FOREACH(hd->cd->fd_handlers, l, fdh) |
195 | { | 198 | { |
196 | if (ecore_main_fd_handler_fd_get(fdh) == hd->fd) return; | 199 | if (ecore_main_fd_handler_fd_get(fdh) == fd) return; |
197 | } | 200 | } |
198 | 201 | ||
199 | DDBG(" FD handler add on fd:%d (flags: %d)", hd->fd, dflags); | 202 | DDBG(" FD handler add on fd:%d (flags: %d)", fd, dflags); |
200 | hd->fd_handler = ecore_main_fd_handler_add(hd->fd, | 203 | hd->fd_handler = ecore_main_fd_handler_add(fd, |
201 | eflags, | 204 | eflags, |
202 | e_dbus_fd_handler, | 205 | e_dbus_fd_handler, |
203 | hd, | 206 | hd, |
@@ -232,10 +235,8 @@ e_dbus_handler_data_add(E_DBus_Connection *cd, DBusWatch *watch) | |||
232 | hd->cd = cd; | 235 | hd->cd = cd; |
233 | hd->watch = watch; | 236 | hd->watch = watch; |
234 | 237 | ||
235 | hd->enabled = dbus_watch_get_enabled(watch); | 238 | if (dbus_watch_get_enabled(watch)) |
236 | hd->fd = dbus_watch_get_unix_fd(hd->watch); | 239 | e_dbus_fd_handler_add(hd); |
237 | |||
238 | if (hd->enabled) e_dbus_fd_handler_add(hd); | ||
239 | } | 240 | } |
240 | 241 | ||
241 | 242 | ||
@@ -277,10 +278,10 @@ cb_watch_toggle(DBusWatch *watch, void *data) | |||
277 | hd = dbus_watch_get_data(watch); | 278 | hd = dbus_watch_get_data(watch); |
278 | if (!hd) return; | 279 | if (!hd) return; |
279 | 280 | ||
280 | hd->enabled = dbus_watch_get_enabled(watch); | 281 | if (dbus_watch_get_enabled(watch)) |
281 | 282 | e_dbus_fd_handler_add(hd); | |
282 | if (hd->enabled) e_dbus_fd_handler_add(hd); | 283 | else |
283 | else e_dbus_fd_handler_del(hd); | 284 | e_dbus_fd_handler_del(hd); |
284 | } | 285 | } |
285 | 286 | ||
286 | 287 | ||
diff --git a/efl/dbus_mainloop/e_dbus.h b/efl/dbus_mainloop/e_dbus.h index 1d6e5ae..dff55fb 100644 --- a/efl/dbus_mainloop/e_dbus.h +++ b/efl/dbus_mainloop/e_dbus.h | |||
@@ -47,11 +47,9 @@ struct E_DBus_Connection | |||
47 | 47 | ||
48 | struct E_DBus_Handler_Data | 48 | struct E_DBus_Handler_Data |
49 | { | 49 | { |
50 | int fd; | ||
51 | Ecore_Fd_Handler *fd_handler; | 50 | Ecore_Fd_Handler *fd_handler; |
52 | E_DBus_Connection *cd; | 51 | E_DBus_Connection *cd; |
53 | DBusWatch *watch; | 52 | DBusWatch *watch; |
54 | int enabled; | ||
55 | }; | 53 | }; |
56 | 54 | ||
57 | struct E_DBus_Timeout_Data | 55 | struct E_DBus_Timeout_Data |