diff --git a/examples/glib/dbus-browser.h b/examples/glib/dbus-browser.h index a409129..4a434a2 100644 --- a/examples/glib/dbus-browser.h +++ b/examples/glib/dbus-browser.h @@ -1,9 +1,9 @@ #ifndef __DEMO_DBUS_BROWSER_H #define __DEMO_DBUS_BROWSER_H -#include #include #include +#include #include "dbus-glue.h" diff --git a/examples/glib/dbus-browser.h.collision b/examples/glib/dbus-browser.h.collision deleted file mode 100644 index 4a434a2..0000000 --- a/examples/glib/dbus-browser.h.collision +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef __DEMO_DBUS_BROWSER_H -#define __DEMO_DBUS_BROWSER_H - -#include -#include -#include - -#include "dbus-glue.h" - -class DBusInspector - : public DBus::IntrospectableProxy, - public DBus::ObjectProxy -{ -public: - - DBusInspector(DBus::Connection &conn, const char *path, const char *service) - : DBus::ObjectProxy(conn, path, service) - {} -}; - -class DBusBrowser - : public org::freedesktop::DBus_proxy, - public DBus::IntrospectableProxy, - public DBus::ObjectProxy, - public Gtk::Window -{ -public: - - DBusBrowser(::DBus::Connection &); - -private: - - void NameOwnerChanged(const std::string &, const std::string &, const std::string &); - - void NameLost(const std::string &); - - void NameAcquired(const std::string &); - - void on_select_busname(); - - void _inspect_append(Gtk::TreeModel::Row *, const std::string &, const std::string &); - -private: - - class InspectRecord : public Gtk::TreeModel::ColumnRecord - { - public: - - InspectRecord() - { - add(name); - } - - Gtk::TreeModelColumn name; - }; - - Gtk::VBox _vbox; - Gtk::ScrolledWindow _sc_tree; - Gtk::ComboBoxText _cb_busnames; - Gtk::TreeView _tv_inspect; - Glib::RefPtr _tm_inspect; - InspectRecord _records; -}; - -#endif//__DEMO_DBUS_BROWSER_H diff --git a/include/dbus-c++/dispatcher.h b/include/dbus-c++/dispatcher.h index b38361e..b5b5536 100644 --- a/include/dbus-c++/dispatcher.h +++ b/include/dbus-c++/dispatcher.h @@ -188,7 +188,6 @@ extern DXXAPI Dispatcher *default_dispatcher; /* classes for multithreading support */ -#if 0 class DXXAPI Mutex { public: @@ -244,11 +243,9 @@ typedef void (*CondVarWaitFn)(CondVar *cv, Mutex *mx); typedef bool (*CondVarWaitTimeoutFn)(CondVar *cv, Mutex *mx, int timeout); typedef void (*CondVarWakeOneFn)(CondVar *cv); typedef void (*CondVarWakeAllFn)(CondVar *cv); -#endif void DXXAPI _init_threading(); -#if 0 void DXXAPI _init_threading( MutexNewFn, MutexFreeFn, MutexLockFn, MutexUnlockFn, CondVarNewFn, CondVarFreeFn, CondVarWaitFn, CondVarWaitTimeoutFn, CondVarWakeOneFn, CondVarWakeAllFn @@ -315,7 +312,6 @@ struct Threading cv->wake_all(); } }; -#endif } /* namespace DBus */ diff --git a/include/dbus-c++/dispatcher.h.threading b/include/dbus-c++/dispatcher.h.threading deleted file mode 100644 index b5b5536..0000000 --- a/include/dbus-c++/dispatcher.h.threading +++ /dev/null @@ -1,318 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_DISPATCHER_H -#define __DBUSXX_DISPATCHER_H - -#include "api.h" -#include "connection.h" -#include "eventloop.h" - -namespace DBus -{ - -class DXXAPI Timeout -{ -public: - - class Internal; - - Timeout(Internal *i); - - virtual ~Timeout() {} - - /*! - * \brief Gets the timeout interval. - * - * The handle() should be called each time this interval elapses, - * starting after it elapses once. - * - * The interval may change during the life of the timeout; if so, the timeout - * will be disabled and re-enabled (calling the "timeout toggled function") to - * notify you of the change. - * - * return The interval in miliseconds. - */ - int interval() const; - - bool enabled() const; - - /*! - * \brief Calls the timeout handler for this timeout. - * - * This function should be called when the timeout occurs. - * - * If this function returns FALSE, then there wasn't enough memory to handle - * the timeout. Typically just letting the timeout fire again next time it - * naturally times out is an adequate response to that problem, but you could - * try to do more if you wanted. - * - * return false If there wasn't enough memory. - */ - bool handle(); - - virtual void toggle() = 0; - -private: - - DXXAPILOCAL Timeout(const Timeout &); - -private: - - Internal *_int; -}; - -class DXXAPI Watch -{ -public: - - class Internal; - - Watch(Internal *i); - - virtual ~Watch() {} - - /*! - * \brief A main loop could poll this descriptor to integrate dbus-c++. - * - * This function calls dbus_watch_get_socket() on win32 and - * dbus_watch_get_unix_fd() on all other systems. (see dbus documentation) - * - * @return The file descriptor. - */ - int descriptor() const; - - /*! - * \brief Gets flags from DBusWatchFlags indicating what conditions should be - * monitored on the file descriptor. - * - * The flags returned will only contain DBUS_WATCH_READABLE and DBUS_WATCH_WRITABLE, - * never DBUS_WATCH_HANGUP or DBUS_WATCH_ERROR; all watches implicitly include - * a watch for hangups, errors, and other exceptional conditions. - * - * @return The conditions to watch. - */ - int flags() const; - - bool enabled() const; - - /*! - * \brief Called to notify the D-Bus library when a previously-added watch - * is ready for reading or writing, or has an exception such as a hangup. - * - * If this function returns FALSE, then the file descriptor may still be - * ready for reading or writing, but more memory is needed in order to do the - * reading or writing. If you ignore the FALSE return, your application may - * spin in a busy loop on the file descriptor until memory becomes available, - * but nothing more catastrophic should happen. - * - * dbus_watch_handle() cannot be called during the DBusAddWatchFunction, as the - * connection will not be ready to handle that watch yet. - * - * It is not allowed to reference a DBusWatch after it has been passed to remove_function. - * - * @param flags The poll condition using DBusWatchFlags values. - * @return false If there wasn't enough memory. - */ - bool handle(int flags); - - virtual void toggle() = 0; - -private: - - DXXAPILOCAL Watch(const Watch &); - -private: - - Internal *_int; -}; - -class DXXAPI Dispatcher -{ -public: - - virtual ~Dispatcher() - {} - - void queue_connection(Connection::Private *); - - void dispatch_pending(); - bool has_something_to_dispatch(); - - virtual void enter() = 0; - - virtual void leave() = 0; - - virtual Timeout *add_timeout(Timeout::Internal *) = 0; - - virtual void rem_timeout(Timeout *) = 0; - - virtual Watch *add_watch(Watch::Internal *) = 0; - - virtual void rem_watch(Watch *) = 0; - - struct Private; - -private: - void dispatch_pending(Connection::PrivatePList &pending_queue); - - DefaultMutex _mutex_p; - DefaultMutex _mutex_p_copy; - - Connection::PrivatePList _pending_queue; -}; - -extern DXXAPI Dispatcher *default_dispatcher; - -/* classes for multithreading support -*/ - -class DXXAPI Mutex -{ -public: - - virtual ~Mutex() {} - - virtual void lock() = 0; - - virtual void unlock() = 0; - - struct Internal; - -protected: - - Internal *_int; -}; - -class DXXAPI CondVar -{ -public: - - virtual ~CondVar() {} - - virtual void wait(Mutex *) = 0; - - virtual bool wait_timeout(Mutex *, int timeout) = 0; - - virtual void wake_one() = 0; - - virtual void wake_all() = 0; - - struct Internal; - -protected: - - Internal *_int; -}; - -typedef Mutex *(*MutexNewFn)(); -typedef void (*MutexUnlockFn)(Mutex *mx); - -#ifndef DBUS_HAS_RECURSIVE_MUTEX -typedef bool (*MutexFreeFn)(Mutex *mx); -typedef bool (*MutexLockFn)(Mutex *mx); -#else -typedef void (*MutexFreeFn)(Mutex *mx); -typedef void (*MutexLockFn)(Mutex *mx); -#endif//DBUS_HAS_RECURSIVE_MUTEX - -typedef CondVar *(*CondVarNewFn)(); -typedef void (*CondVarFreeFn)(CondVar *cv); -typedef void (*CondVarWaitFn)(CondVar *cv, Mutex *mx); -typedef bool (*CondVarWaitTimeoutFn)(CondVar *cv, Mutex *mx, int timeout); -typedef void (*CondVarWakeOneFn)(CondVar *cv); -typedef void (*CondVarWakeAllFn)(CondVar *cv); - -void DXXAPI _init_threading(); - -void DXXAPI _init_threading( - MutexNewFn, MutexFreeFn, MutexLockFn, MutexUnlockFn, - CondVarNewFn, CondVarFreeFn, CondVarWaitFn, CondVarWaitTimeoutFn, CondVarWakeOneFn, CondVarWakeAllFn -); - -template -struct Threading -{ - static void init() - { - _init_threading( - mutex_new, mutex_free, mutex_lock, mutex_unlock, - condvar_new, condvar_free, condvar_wait, condvar_wait_timeout, condvar_wake_one, condvar_wake_all - ); - } - - static Mutex *mutex_new() - { - return new Mx; - } - - static void mutex_free(Mutex *mx) - { - delete mx; - } - - static void mutex_lock(Mutex *mx) - { - mx->lock(); - } - - static void mutex_unlock(Mutex *mx) - { - mx->unlock(); - } - - static CondVar *condvar_new() - { - return new Cv; - } - - static void condvar_free(CondVar *cv) - { - delete cv; - } - - static void condvar_wait(CondVar *cv, Mutex *mx) - { - cv->wait(mx); - } - - static bool condvar_wait_timeout(CondVar *cv, Mutex *mx, int timeout) - { - return cv->wait_timeout(mx, timeout); - } - - static void condvar_wake_one(CondVar *cv) - { - cv->wake_one(); - } - - static void condvar_wake_all(CondVar *cv) - { - cv->wake_all(); - } -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_DISPATCHER_H diff --git a/include/dbus-c++/eventloop-integration.h b/include/dbus-c++/eventloop-integration.h index 3e44304..1b0302e 100644 --- a/include/dbus-c++/eventloop-integration.h +++ b/include/dbus-c++/eventloop-integration.h @@ -26,7 +26,6 @@ #define __DBUSXX_EVENTLOOP_INTEGRATION_H #include -#include #include "api.h" #include "dispatcher.h" #include "util.h" diff --git a/include/dbus-c++/eventloop-integration.h.gcc47 b/include/dbus-c++/eventloop-integration.h.gcc47 deleted file mode 100644 index 1b0302e..0000000 --- a/include/dbus-c++/eventloop-integration.h.gcc47 +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - - -#ifndef __DBUSXX_EVENTLOOP_INTEGRATION_H -#define __DBUSXX_EVENTLOOP_INTEGRATION_H - -#include -#include "api.h" -#include "dispatcher.h" -#include "util.h" -#include "eventloop.h" - -namespace DBus -{ - -/* - * Glue between the event loop and the DBus library - */ - -class BusDispatcher; -class Pipe; - -class DXXAPI BusTimeout : public Timeout, public DefaultTimeout -{ - BusTimeout(Timeout::Internal *, BusDispatcher *); - - void toggle(); - - friend class BusDispatcher; -}; - -class DXXAPI BusWatch : public Watch, public DefaultWatch -{ - BusWatch(Watch::Internal *, BusDispatcher *); - - void toggle(); - - friend class BusDispatcher; -}; - -class DXXAPI BusDispatcher : public Dispatcher, public DefaultMainLoop -{ -public: - BusDispatcher(); - - ~BusDispatcher() {} - - virtual void enter(); - - virtual void leave(); - - virtual Pipe *add_pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data); - - virtual void del_pipe(Pipe *pipe); - - virtual void do_iteration(); - - virtual Timeout *add_timeout(Timeout::Internal *); - - virtual void rem_timeout(Timeout *); - - virtual Watch *add_watch(Watch::Internal *); - - virtual void rem_watch(Watch *); - - void watch_ready(DefaultWatch &); - - void timeout_expired(DefaultTimeout &); - -private: - bool _running; - int _pipe[2]; - std::list pipe_list; -}; - -} /* namespace DBus */ - -#endif//__DBUSXX_EVENTLOOP_INTEGRATION_H diff --git a/src/Makefile.am b/src/Makefile.am index 2926d57..802fcfc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,7 +29,7 @@ libdbus_c___1_la_CXXFLAGS = \ -Wno-unused-parameter libdbus_c___1_la_LIBADD = \ - $(dbus_LIBS) $(xml_LIBS) + $(dbus_LIBS) AM_CPPFLAGS = \ $(dbus_CFLAGS) \ diff --git a/src/Makefile.am.linkfix b/src/Makefile.am.linkfix deleted file mode 100644 index 802fcfc..0000000 --- a/src/Makefile.am.linkfix +++ /dev/null @@ -1,70 +0,0 @@ -lib_LTLIBRARIES = \ - libdbus-c++-1.la - -libdbus_c___1_la_SOURCES = \ - connection.cpp \ - connection_p.h \ - debug.cpp \ - dispatcher.cpp \ - dispatcher_p.h \ - error.cpp \ - eventloop.cpp \ - eventloop-integration.cpp \ - interface.cpp \ - internalerror.h \ - introspection.cpp \ - message.cpp \ - message_p.h \ - object.cpp \ - pendingcall.cpp \ - pendingcall_p.h \ - pipe.cpp \ - property.cpp \ - server.cpp \ - server_p.h \ - types.cpp - -libdbus_c___1_la_CXXFLAGS = \ - -I$(top_srcdir)/include \ - -Wno-unused-parameter - -libdbus_c___1_la_LIBADD = \ - $(dbus_LIBS) - -AM_CPPFLAGS = \ - $(dbus_CFLAGS) \ - $(glib_CFLAGS) \ - $(ecore_CFLAGS) - -SUBDIRS = \ - integration - -HEADER_DIR = $(top_srcdir)/include/dbus-c++ -libdbus_c___1_HEADERS = \ - $(HEADER_DIR)/api.h \ - $(HEADER_DIR)/connection.h \ - $(HEADER_DIR)/dbus.h \ - $(HEADER_DIR)/debug.h \ - $(HEADER_DIR)/dispatcher.h \ - $(HEADER_DIR)/error.h \ - $(HEADER_DIR)/eventloop.h \ - $(HEADER_DIR)/eventloop-integration.h \ - $(HEADER_DIR)/interface.h \ - $(HEADER_DIR)/introspection.h \ - $(HEADER_DIR)/message.h \ - $(HEADER_DIR)/object.h \ - $(HEADER_DIR)/pendingcall.h \ - $(HEADER_DIR)/pipe.h \ - $(HEADER_DIR)/property.h \ - $(HEADER_DIR)/refptr_impl.h \ - $(HEADER_DIR)/server.h \ - $(HEADER_DIR)/types.h \ - $(HEADER_DIR)/util.h - -libdbus_c___1dir=$(includedir)/dbus-c++-1/dbus-c++/ - -EXTRA_DIST = \ - $(libdbus_c___1_HEADERS) - -## File created by the gnome-build tools - diff --git a/src/dispatcher.cpp b/src/dispatcher.cpp index e691aba..bc07d71 100644 --- a/src/dispatcher.cpp +++ b/src/dispatcher.cpp @@ -253,7 +253,6 @@ void DBus::_init_threading() #endif//DBUS_HAS_THREADS_INIT_DEFAULT } -#if 0 void DBus::_init_threading( MutexNewFn m1, MutexFreeFn m2, @@ -319,4 +318,3 @@ void DBus::_init_threading( #endif//DBUS_HAS_RECURSIVE_MUTEX dbus_threads_init(&functions); } -#endif diff --git a/src/dispatcher.cpp.threading b/src/dispatcher.cpp.threading deleted file mode 100644 index bc07d71..0000000 --- a/src/dispatcher.cpp.threading +++ /dev/null @@ -1,320 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include - -#include "dispatcher_p.h" -#include "server_p.h" -#include "connection_p.h" - -DBus::Dispatcher *DBus::default_dispatcher = NULL; - -using namespace DBus; - -Timeout::Timeout(Timeout::Internal *i) - : _int(i) -{ - dbus_timeout_set_data((DBusTimeout *)i, this, NULL); -} - -int Timeout::interval() const -{ - return dbus_timeout_get_interval((DBusTimeout *)_int); -} - -bool Timeout::enabled() const -{ - return dbus_timeout_get_enabled((DBusTimeout *)_int); -} - -bool Timeout::handle() -{ - return dbus_timeout_handle((DBusTimeout *)_int); -} - -/* -*/ - -Watch::Watch(Watch::Internal *i) - : _int(i) -{ - dbus_watch_set_data((DBusWatch *)i, this, NULL); -} - -int Watch::descriptor() const -{ -#if HAVE_WIN32 - return dbus_watch_get_socket((DBusWatch *)_int); -#else - // check dbus version and use dbus_watch_get_unix_fd() only in dbus >= 1.1.1 -#if (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MINOR == 1 && DBUS_VERSION_MICRO >= 1) || \ - (DBUS_VERSION_MAJOR == 1 && DBUS_VERSION_MAJOR > 1) || \ - (DBUS_VERSION_MAJOR > 1) - return dbus_watch_get_unix_fd((DBusWatch *)_int); -#else - return dbus_watch_get_fd((DBusWatch *)_int); -#endif -#endif -} - -int Watch::flags() const -{ - return dbus_watch_get_flags((DBusWatch *)_int); -} - -bool Watch::enabled() const -{ - return dbus_watch_get_enabled((DBusWatch *)_int); -} - -bool Watch::handle(int flags) -{ - return dbus_watch_handle((DBusWatch *)_int, flags); -} - -/* -*/ - -dbus_bool_t Dispatcher::Private::on_add_watch(DBusWatch *watch, void *data) -{ - Dispatcher *d = static_cast(data); - - Watch::Internal *w = reinterpret_cast(watch); - - d->add_watch(w); - - return true; -} - -void Dispatcher::Private::on_rem_watch(DBusWatch *watch, void *data) -{ - Dispatcher *d = static_cast(data); - - Watch *w = static_cast(dbus_watch_get_data(watch)); - - d->rem_watch(w); -} - -void Dispatcher::Private::on_toggle_watch(DBusWatch *watch, void *data) -{ - Watch *w = static_cast(dbus_watch_get_data(watch)); - - w->toggle(); -} - -dbus_bool_t Dispatcher::Private::on_add_timeout(DBusTimeout *timeout, void *data) -{ - Dispatcher *d = static_cast(data); - - Timeout::Internal *t = reinterpret_cast(timeout); - - d->add_timeout(t); - - return true; -} - -void Dispatcher::Private::on_rem_timeout(DBusTimeout *timeout, void *data) -{ - Dispatcher *d = static_cast(data); - - Timeout *t = static_cast(dbus_timeout_get_data(timeout)); - - d->rem_timeout(t); -} - -void Dispatcher::Private::on_toggle_timeout(DBusTimeout *timeout, void *data) -{ - Timeout *t = static_cast(dbus_timeout_get_data(timeout)); - - t->toggle(); -} - -void Dispatcher::queue_connection(Connection::Private *cp) -{ - _mutex_p.lock(); - _pending_queue.push_back(cp); - _mutex_p.unlock(); -} - - -bool Dispatcher::has_something_to_dispatch() -{ - _mutex_p.lock(); - bool has_something = false; - for (Connection::PrivatePList::iterator it = _pending_queue.begin(); - it != _pending_queue.end() && !has_something; - ++it) - { - has_something = (*it)->has_something_to_dispatch(); - } - - _mutex_p.unlock(); - return has_something; -} - - -void Dispatcher::dispatch_pending() -{ - while (1) - { - _mutex_p.lock(); - if (_pending_queue.empty()) - { - _mutex_p.unlock(); - break; - } - - Connection::PrivatePList pending_queue_copy(_pending_queue); - _mutex_p.unlock(); - - size_t copy_elem_num(pending_queue_copy.size()); - - dispatch_pending(pending_queue_copy); - - //only push_back on list is mandatory! - _mutex_p.lock(); - - Connection::PrivatePList::iterator i, j; - i = _pending_queue.begin(); - size_t counter = 0; - while (counter < copy_elem_num && i != _pending_queue.end()) - { - j = i; - ++j; - _pending_queue.erase(i); - i = j; - ++counter; - } - - _mutex_p.unlock(); - } -} - -void Dispatcher::dispatch_pending(Connection::PrivatePList &pending_queue) -{ - // SEEME: dbus-glib is dispatching only one message at a time to not starve the loop/other things... - - _mutex_p_copy.lock(); - while (pending_queue.size() > 0) - { - Connection::PrivatePList::iterator i, j; - - i = pending_queue.begin(); - - while (i != pending_queue.end()) - { - j = i; - - ++j; - - if ((*i)->do_dispatch()) - pending_queue.erase(i); - else - debug_log("dispatch_pending_private: do_dispatch error"); - - i = j; - } - } - _mutex_p_copy.unlock(); -} - -void DBus::_init_threading() -{ -#ifdef DBUS_HAS_THREADS_INIT_DEFAULT - dbus_threads_init_default(); -#else - debug_log("Thread support is not enabled! Your D-Bus version is too old!"); -#endif//DBUS_HAS_THREADS_INIT_DEFAULT -} - -void DBus::_init_threading( - MutexNewFn m1, - MutexFreeFn m2, - MutexLockFn m3, - MutexUnlockFn m4, - CondVarNewFn c1, - CondVarFreeFn c2, - CondVarWaitFn c3, - CondVarWaitTimeoutFn c4, - CondVarWakeOneFn c5, - CondVarWakeAllFn c6 -) -{ -#ifndef DBUS_HAS_RECURSIVE_MUTEX - DBusThreadFunctions functions = - { - DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK | - DBUS_THREAD_FUNCTIONS_MUTEX_FREE_MASK | - DBUS_THREAD_FUNCTIONS_MUTEX_LOCK_MASK | - DBUS_THREAD_FUNCTIONS_MUTEX_UNLOCK_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK, - (DBusMutexNewFunction) m1, - (DBusMutexFreeFunction) m2, - (DBusMutexLockFunction) m3, - (DBusMutexUnlockFunction) m4, - (DBusCondVarNewFunction) c1, - (DBusCondVarFreeFunction) c2, - (DBusCondVarWaitFunction) c3, - (DBusCondVarWaitTimeoutFunction) c4, - (DBusCondVarWakeOneFunction) c5, - (DBusCondVarWakeAllFunction) c6 - }; -#else - DBusThreadFunctions functions = - { - DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_NEW_MASK | - DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_FREE_MASK | - DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_LOCK_MASK | - DBUS_THREAD_FUNCTIONS_RECURSIVE_MUTEX_UNLOCK_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_NEW_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_FREE_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAIT_TIMEOUT_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ONE_MASK | - DBUS_THREAD_FUNCTIONS_CONDVAR_WAKE_ALL_MASK, - 0, 0, 0, 0, - (DBusCondVarNewFunction) c1, - (DBusCondVarFreeFunction) c2, - (DBusCondVarWaitFunction) c3, - (DBusCondVarWaitTimeoutFunction) c4, - (DBusCondVarWakeOneFunction) c5, - (DBusCondVarWakeAllFunction) c6, - (DBusRecursiveMutexNewFunction) m1, - (DBusRecursiveMutexFreeFunction) m2, - (DBusRecursiveMutexLockFunction) m3, - (DBusRecursiveMutexUnlockFunction) m4 - }; -#endif//DBUS_HAS_RECURSIVE_MUTEX - dbus_threads_init(&functions); -} diff --git a/src/pipe.cpp b/src/pipe.cpp index b0a9539..01211b3 100644 --- a/src/pipe.cpp +++ b/src/pipe.cpp @@ -83,5 +83,5 @@ ssize_t Pipe::read(void *buffer, unsigned int &nbytes) void Pipe::signal() { // TODO: ignoring return of read/write generates warning; maybe relevant for eventloop work... - ::write(_fd_write, "", 1); + ::write(_fd_write, '\0', 1); } diff --git a/src/pipe.cpp.writechar b/src/pipe.cpp.writechar deleted file mode 100644 index 01211b3..0000000 --- a/src/pipe.cpp.writechar +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * D-Bus++ - C++ bindings for D-Bus - * - * Copyright (C) 2005-2007 Paolo Durante - * - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -/* Project */ -#include -#include -#include - -/* STD */ -#include -#include -#include -#include -#include - -using namespace DBus; -using namespace std; - -Pipe::Pipe(void(*handler)(const void *data, void *buffer, unsigned int nbyte), const void *data) : - _handler(handler), - _fd_write(0), - _fd_read(0), - _data(data) -{ - int fd[2]; - - if (pipe(fd) == 0) - { - _fd_read = fd[0]; - _fd_write = fd[1]; - fcntl(_fd_read, F_SETFL, O_NONBLOCK); - } - else - { - throw Error("PipeError:errno", toString(errno).c_str()); - } -} - -void Pipe::write(const void *buffer, unsigned int nbytes) -{ - // TODO: ignoring return of read/write generates warning; maybe relevant for eventloop work... - // first write the size into the pipe... - ::write(_fd_write, static_cast (&nbytes), sizeof(nbytes)); - - // ...then write the real data - ::write(_fd_write, buffer, nbytes); -} - -ssize_t Pipe::read(void *buffer, unsigned int &nbytes) -{ - // TODO: ignoring return of read/write generates warning; maybe relevant for eventloop work... - // first read the size from the pipe... - ::read(_fd_read, &nbytes, sizeof(nbytes)); - - //ssize_t size = 0; - return ::read(_fd_read, buffer, nbytes); -} - -void Pipe::signal() -{ - // TODO: ignoring return of read/write generates warning; maybe relevant for eventloop work... - ::write(_fd_write, '\0', 1); -}