40Timeout::Timeout(Timeout::Internal *i)
43 dbus_timeout_set_data((DBusTimeout *)i,
this, NULL);
46int Timeout::interval()
const
48 return dbus_timeout_get_interval((DBusTimeout *)
_int);
53 return dbus_timeout_get_enabled((DBusTimeout *)
_int);
58 return dbus_timeout_handle((DBusTimeout *)
_int);
67 dbus_watch_set_data((DBusWatch *)i,
this, NULL);
73 return dbus_watch_get_socket((DBusWatch *)
_int);
76#if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR == 1 && DBUS_VERSION_MICRO >= 1) || \
77 (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MAJOR > 1) || \
78 (DBUS_VERSION_MAJOR > 1)
79 return dbus_watch_get_unix_fd((DBusWatch *)
_int);
81 return dbus_watch_get_fd((DBusWatch *)
_int);
88 return dbus_watch_get_flags((DBusWatch *)
_int);
93 return dbus_watch_get_enabled((DBusWatch *)
_int);
98 return dbus_watch_handle((DBusWatch *)
_int,
flags);
104dbus_bool_t Dispatcher::Private::on_add_watch(DBusWatch *watch,
void *data)
108 Watch::Internal *w =
reinterpret_cast<Watch::Internal *
>(watch);
115void Dispatcher::Private::on_rem_watch(DBusWatch *watch,
void *data)
119 Watch *w =
static_cast<Watch *
>(dbus_watch_get_data(watch));
124void Dispatcher::Private::on_toggle_watch(DBusWatch *watch,
void *data)
126 Watch *w =
static_cast<Watch *
>(dbus_watch_get_data(watch));
131dbus_bool_t Dispatcher::Private::on_add_timeout(DBusTimeout *timeout,
void *data)
135 Timeout::Internal *t =
reinterpret_cast<Timeout::Internal *
>(timeout);
142void Dispatcher::Private::on_rem_timeout(DBusTimeout *timeout,
void *data)
146 Timeout *t =
static_cast<Timeout *
>(dbus_timeout_get_data(timeout));
151void Dispatcher::Private::on_toggle_timeout(DBusTimeout *timeout,
void *data)
153 Timeout *t =
static_cast<Timeout *
>(dbus_timeout_get_data(timeout));
169 bool has_something =
false;
170 for (Connection::PrivatePList::iterator it =
_pending_queue.begin();
174 has_something = (*it)->has_something_to_dispatch();
178 return has_something;
196 size_t copy_elem_num(pending_queue_copy.size());
203 Connection::PrivatePList::iterator i, j;
224 while (pending_queue.size() > 0)
226 Connection::PrivatePList::iterator i, j;
228 i = pending_queue.begin();
230 while (i != pending_queue.end())
236 if ((*i)->do_dispatch())
237 pending_queue.erase(i);
239 debug_log(
"dispatch_pending_private: do_dispatch error");
249#ifdef DBUS_HAS_THREADS_INIT_DEFAULT
250 dbus_threads_init_default();
252 debug_log(
"Thread support is not enabled! Your D-Bus version is too old!");
269#ifndef DBUS_HAS_RECURSIVE_MUTEX
270 DBusThreadFunctions functions =
272 DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK |
273 DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK |
274 DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK |
275 DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK |
276 DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK |
277 DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK |
278 DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK |
279 DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK |
280 DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK |
281 DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK,
282 (DBusMutexNewFunction) m1,
283 (DBusMutexFreeFunction) m2,
284 (DBusMutexLockFunction) m3,
285 (DBusMutexUnlockFunction) m4,
286 (DBusCondVarNewFunction) c1,
287 (DBusCondVarFreeFunction) c2,
288 (DBusCondVarWaitFunction) c3,
289 (DBusCondVarWaitTimeoutFunction) c4,
290 (DBusCondVarWakeOneFunction) c5,
291 (DBusCondVarWakeAllFunction) c6
294 DBusThreadFunctions functions =
296 DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK |
297 DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK |
298 DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK |
299 DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK |
300 DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK |
301 DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK |
302 DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK |
303 DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK |
304 DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK |
305 DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK,
307 (DBusCondVarNewFunction) c1,
308 (DBusCondVarFreeFunction) c2,
309 (DBusCondVarWaitFunction) c3,
310 (DBusCondVarWaitTimeoutFunction) c4,
311 (DBusCondVarWakeOneFunction) c5,
312 (DBusCondVarWakeAllFunction) c6,
313 (DBusRecursiveMutexNewFunction) m1,
314 (DBusRecursiveMutexFreeFunction) m2,
315 (DBusRecursiveMutexLockFunction) m3,
316 (DBusRecursiveMutexUnlockFunction) m4
319 dbus_threads_init(&functions);
bool handle()
Calls the timeout handler for this timeout.
int flags() const
Gets flags from DBusWatchFlags indicating what conditions should be monitored on the file descriptor.
bool handle(int flags)
Called to notify the D-Bus library when a previously-added watch is ready for reading or writing,...
int descriptor() const
A main loop could poll this descriptor to integrate dbus-c++.
void(* CondVarFreeFn)(CondVar *cv)
void DXXAPI _init_threading()
CondVar *(* CondVarNewFn)()
bool(* CondVarWaitTimeoutFn)(CondVar *cv, Mutex *mx, int timeout)
DXXAPI Dispatcher * default_dispatcher
void(* MutexUnlockFn)(Mutex *mx)
bool(* MutexLockFn)(Mutex *mx)
void(* CondVarWakeAllFn)(CondVar *cv)
void(* CondVarWakeOneFn)(CondVar *cv)
void(* CondVarWaitFn)(CondVar *cv, Mutex *mx)
DXXAPI LogFunction debug_log
bool(* MutexFreeFn)(Mutex *mx)
Private(DBusConnection *, Server::Private *=NULL)
std::list< Private * > PrivatePList
virtual Watch * add_watch(Watch::Internal *)=0
DefaultMutex _mutex_p_copy
virtual Timeout * add_timeout(Timeout::Internal *)=0
virtual void rem_timeout(Timeout *)=0
void queue_connection(Connection::Private *)
virtual void rem_watch(Watch *)=0
bool has_something_to_dispatch()
Connection::PrivatePList _pending_queue