29 #include <dbus/dbus.h>
34 :
Timeout(ti), _ctx(ctx), _priority(priority), _source(NULL)
68 g_source_set_priority(_source, _priority);
69 g_source_set_callback(_source, timeout_handler,
this, NULL);
70 g_source_attach(_source, _ctx);
77 g_source_destroy(_source);
101 return io->
poll.revents ? TRUE : FALSE;
104 static gboolean
watch_dispatch(GSource *source, GSourceFunc callback, gpointer data)
108 gboolean cb = callback(data);
121 :
Watch(wi), _ctx(ctx), _priority(priority), _source(NULL)
147 if (io->
poll.revents & G_IO_IN)
148 flags |= DBUS_WATCH_READABLE;
149 if (io->
poll.revents & G_IO_OUT)
150 flags |= DBUS_WATCH_WRITABLE;
151 if (io->
poll.revents & G_IO_ERR)
152 flags |= DBUS_WATCH_ERROR;
153 if (io->
poll.revents & G_IO_HUP)
154 flags |= DBUS_WATCH_HANGUP;
166 g_source_set_priority(_source, _priority);
167 g_source_set_callback(_source, watch_handler,
this, NULL);
172 if (flags & DBUS_WATCH_READABLE)
173 condition |= G_IO_IN;
174 if (flags & DBUS_WATCH_WRITABLE)
175 condition |= G_IO_OUT;
176 if (flags & DBUS_WATCH_ERROR)
177 condition |= G_IO_ERR;
178 if (flags & DBUS_WATCH_HANGUP)
179 condition |= G_IO_HUP;
181 GPollFD *poll = &(((
BusSource *)_source)->poll);
183 poll->events = condition;
186 g_source_add_poll(_source, poll);
187 g_source_attach(_source, _ctx);
194 GPollFD *poll = &(((
BusSource *)_source)->poll);
195 g_source_remove_poll(_source, poll);
196 g_source_destroy(_source);
228 GSourceFunc callback,
246 : _ctx(NULL), _priority(G_PRIORITY_DEFAULT), _source(NULL)
254 GSource *temp = _source;
257 g_source_destroy(temp);
258 g_source_unref(temp);
262 g_main_context_unref(_ctx);
267 g_assert(_ctx == NULL);
269 _ctx = ctx ? ctx : g_main_context_default();
270 g_main_context_ref(_ctx);
277 g_source_attach(_source, _ctx);
291 debug_log(
"glib: removed timeout %p", t);
300 debug_log(
"glib: added watch %p (%s) fd=%d flags=%d",
315 _priority = priority;