sync from fd.orf

This commit is contained in:
Andreas Volz 2009-11-16 22:14:08 +01:00
parent a2f2b93e36
commit d55e70a385
26 changed files with 186 additions and 159 deletions

View file

@ -72,211 +72,211 @@ private:
struct DXXAPI ErrorFailed : public Error struct DXXAPI ErrorFailed : public Error
{ {
ErrorFailed(const char *msg) ErrorFailed(const char *message)
: Error("org.freedesktop.DBus.Error.Failed", msg) : Error("org.freedesktop.DBus.Error.Failed", message)
{} {}
}; };
struct DXXAPI ErrorNoMemory : public Error struct DXXAPI ErrorNoMemory : public Error
{ {
ErrorNoMemory(const char *msg) ErrorNoMemory(const char *message)
: Error("org.freedesktop.DBus.Error.NoMemory", msg) : Error("org.freedesktop.DBus.Error.NoMemory", message)
{} {}
}; };
struct DXXAPI ErrorServiceUnknown : public Error struct DXXAPI ErrorServiceUnknown : public Error
{ {
ErrorServiceUnknown(const char *msg) ErrorServiceUnknown(const char *message)
: Error("org.freedesktop.DBus.Error.ServiceUnknown", msg) : Error("org.freedesktop.DBus.Error.ServiceUnknown", message)
{} {}
}; };
struct DXXAPI ErrorNameHasNoOwner : public Error struct DXXAPI ErrorNameHasNoOwner : public Error
{ {
ErrorNameHasNoOwner(const char *msg) ErrorNameHasNoOwner(const char *message)
: Error("org.freedesktop.DBus.Error.NameHasNoOwner", msg) : Error("org.freedesktop.DBus.Error.NameHasNoOwner", message)
{} {}
}; };
struct DXXAPI ErrorNoReply : public Error struct DXXAPI ErrorNoReply : public Error
{ {
ErrorNoReply(const char *msg) ErrorNoReply(const char *message)
: Error("org.freedesktop.DBus.Error.NoReply", msg) : Error("org.freedesktop.DBus.Error.NoReply", message)
{} {}
}; };
struct DXXAPI ErrorIOError : public Error struct DXXAPI ErrorIOError : public Error
{ {
ErrorIOError(const char *msg) ErrorIOError(const char *message)
: Error("org.freedesktop.DBus.Error.IOError", msg) : Error("org.freedesktop.DBus.Error.IOError", message)
{} {}
}; };
struct DXXAPI ErrorBadAddress : public Error struct DXXAPI ErrorBadAddress : public Error
{ {
ErrorBadAddress(const char *msg) ErrorBadAddress(const char *message)
: Error("org.freedesktop.DBus.Error.BadAddress", msg) : Error("org.freedesktop.DBus.Error.BadAddress", message)
{} {}
}; };
struct DXXAPI ErrorNotSupported : public Error struct DXXAPI ErrorNotSupported : public Error
{ {
ErrorNotSupported(const char *msg) ErrorNotSupported(const char *message)
: Error("org.freedesktop.DBus.Error.NotSupported", msg) : Error("org.freedesktop.DBus.Error.NotSupported", message)
{} {}
}; };
struct DXXAPI ErrorLimitsExceeded : public Error struct DXXAPI ErrorLimitsExceeded : public Error
{ {
ErrorLimitsExceeded(const char *msg) ErrorLimitsExceeded(const char *message)
: Error("org.freedesktop.DBus.Error.LimitsExceeded", msg) : Error("org.freedesktop.DBus.Error.LimitsExceeded", message)
{} {}
}; };
struct DXXAPI ErrorAccessDenied : public Error struct DXXAPI ErrorAccessDenied : public Error
{ {
ErrorAccessDenied(const char *msg) ErrorAccessDenied(const char *message)
: Error("org.freedesktop.DBus.Error.AccessDenied", msg) : Error("org.freedesktop.DBus.Error.AccessDenied", message)
{} {}
}; };
struct DXXAPI ErrorAuthFailed : public Error struct DXXAPI ErrorAuthFailed : public Error
{ {
ErrorAuthFailed(const char *msg) ErrorAuthFailed(const char *message)
: Error("org.freedesktop.DBus.Error.AuthFailed", msg) : Error("org.freedesktop.DBus.Error.AuthFailed", message)
{} {}
}; };
struct DXXAPI ErrorNoServer : public Error struct DXXAPI ErrorNoServer : public Error
{ {
ErrorNoServer(const char *msg) ErrorNoServer(const char *message)
: Error("org.freedesktop.DBus.Error.NoServer", msg) : Error("org.freedesktop.DBus.Error.NoServer", message)
{} {}
}; };
struct DXXAPI ErrorTimeout : public Error struct DXXAPI ErrorTimeout : public Error
{ {
ErrorTimeout(const char *msg) ErrorTimeout(const char *message)
: Error("org.freedesktop.DBus.Error.Timeout", msg) : Error("org.freedesktop.DBus.Error.Timeout", message)
{} {}
}; };
struct DXXAPI ErrorNoNetwork : public Error struct DXXAPI ErrorNoNetwork : public Error
{ {
ErrorNoNetwork(const char *msg) ErrorNoNetwork(const char *message)
: Error("org.freedesktop.DBus.Error.NoNetwork", msg) : Error("org.freedesktop.DBus.Error.NoNetwork", message)
{} {}
}; };
struct DXXAPI ErrorAddressInUse : public Error struct DXXAPI ErrorAddressInUse : public Error
{ {
ErrorAddressInUse(const char *msg) ErrorAddressInUse(const char *message)
: Error("org.freedesktop.DBus.Error.AddressInUse", msg) : Error("org.freedesktop.DBus.Error.AddressInUse", message)
{} {}
}; };
struct DXXAPI ErrorDisconnected : public Error struct DXXAPI ErrorDisconnected : public Error
{ {
ErrorDisconnected(const char *msg) ErrorDisconnected(const char *message)
: Error("org.freedesktop.DBus.Error.Disconnected", msg) : Error("org.freedesktop.DBus.Error.Disconnected", message)
{} {}
}; };
struct DXXAPI ErrorInvalidArgs : public Error struct DXXAPI ErrorInvalidArgs : public Error
{ {
ErrorInvalidArgs(const char *msg) ErrorInvalidArgs(const char *message)
: Error("org.freedesktop.DBus.Error.InvalidArgs", msg) : Error("org.freedesktop.DBus.Error.InvalidArgs", message)
{} {}
}; };
struct DXXAPI ErrorFileNotFound : public Error struct DXXAPI ErrorFileNotFound : public Error
{ {
ErrorFileNotFound(const char *msg) ErrorFileNotFound(const char *message)
: Error("org.freedesktop.DBus.Error.FileNotFound", msg) : Error("org.freedesktop.DBus.Error.FileNotFound", message)
{} {}
}; };
struct DXXAPI ErrorUnknownMethod : public Error struct DXXAPI ErrorUnknownMethod : public Error
{ {
ErrorUnknownMethod(const char *msg) ErrorUnknownMethod(const char *message)
: Error("org.freedesktop.DBus.Error.UnknownMethod", msg) : Error("org.freedesktop.DBus.Error.UnknownMethod", message)
{} {}
}; };
struct DXXAPI ErrorTimedOut : public Error struct DXXAPI ErrorTimedOut : public Error
{ {
ErrorTimedOut(const char *msg) ErrorTimedOut(const char *message)
: Error("org.freedesktop.DBus.Error.TimedOut", msg) : Error("org.freedesktop.DBus.Error.TimedOut", message)
{} {}
}; };
struct DXXAPI ErrorMatchRuleNotFound : public Error struct DXXAPI ErrorMatchRuleNotFound : public Error
{ {
ErrorMatchRuleNotFound(const char *msg) ErrorMatchRuleNotFound(const char *message)
: Error("org.freedesktop.DBus.Error.MatchRuleNotFound", msg) : Error("org.freedesktop.DBus.Error.MatchRuleNotFound", message)
{} {}
}; };
struct DXXAPI ErrorMatchRuleInvalid : public Error struct DXXAPI ErrorMatchRuleInvalid : public Error
{ {
ErrorMatchRuleInvalid(const char *msg) ErrorMatchRuleInvalid(const char *message)
: Error("org.freedesktop.DBus.Error.MatchRuleInvalid", msg) : Error("org.freedesktop.DBus.Error.MatchRuleInvalid", message)
{} {}
}; };
struct DXXAPI ErrorSpawnExecFailed : public Error struct DXXAPI ErrorSpawnExecFailed : public Error
{ {
ErrorSpawnExecFailed(const char *msg) ErrorSpawnExecFailed(const char *message)
: Error("org.freedesktop.DBus.Error.Spawn.ExecFailed", msg) : Error("org.freedesktop.DBus.Error.Spawn.ExecFailed", message)
{} {}
}; };
struct DXXAPI ErrorSpawnForkFailed : public Error struct DXXAPI ErrorSpawnForkFailed : public Error
{ {
ErrorSpawnForkFailed(const char *msg) ErrorSpawnForkFailed(const char *message)
: Error("org.freedesktop.DBus.Error.Spawn.ForkFailed", msg) : Error("org.freedesktop.DBus.Error.Spawn.ForkFailed", message)
{} {}
}; };
struct DXXAPI ErrorSpawnChildExited : public Error struct DXXAPI ErrorSpawnChildExited : public Error
{ {
ErrorSpawnChildExited(const char *msg) ErrorSpawnChildExited(const char *message)
: Error("org.freedesktop.DBus.Error.Spawn.ChildExited", msg) : Error("org.freedesktop.DBus.Error.Spawn.ChildExited", message)
{} {}
}; };
struct DXXAPI ErrorSpawnChildSignaled : public Error struct DXXAPI ErrorSpawnChildSignaled : public Error
{ {
ErrorSpawnChildSignaled(const char *msg) ErrorSpawnChildSignaled(const char *message)
: Error("org.freedesktop.DBus.Error.Spawn.ChildSignaled", msg) : Error("org.freedesktop.DBus.Error.Spawn.ChildSignaled", message)
{} {}
}; };
struct DXXAPI ErrorSpawnFailed : public Error struct DXXAPI ErrorSpawnFailed : public Error
{ {
ErrorSpawnFailed(const char *msg) ErrorSpawnFailed(const char *message)
: Error("org.freedesktop.DBus.Error.Spawn.Failed", msg) : Error("org.freedesktop.DBus.Error.Spawn.Failed", message)
{} {}
}; };
struct DXXAPI ErrorInvalidSignature : public Error struct DXXAPI ErrorInvalidSignature : public Error
{ {
ErrorInvalidSignature(const char *msg) ErrorInvalidSignature(const char *message)
: Error("org.freedesktop.DBus.Error.InvalidSignature", msg) : Error("org.freedesktop.DBus.Error.InvalidSignature", message)
{} {}
}; };
struct DXXAPI ErrorUnixProcessIdUnknown : public Error struct DXXAPI ErrorUnixProcessIdUnknown : public Error
{ {
ErrorUnixProcessIdUnknown(const char *msg) ErrorUnixProcessIdUnknown(const char *message)
: Error("org.freedesktop.DBus.Error.UnixProcessIdUnknown", msg) : Error("org.freedesktop.DBus.Error.UnixProcessIdUnknown", message)
{} {}
}; };
struct DXXAPI ErrorSELinuxSecurityContextUnknown : public Error struct DXXAPI ErrorSELinuxSecurityContextUnknown : public Error
{ {
ErrorSELinuxSecurityContextUnknown(const char *msg) ErrorSELinuxSecurityContextUnknown(const char *message)
: Error("org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown", msg) : Error("org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown", message)
{} {}
}; };

View file

@ -60,8 +60,17 @@ class DXXAPI BusDispatcher : public Dispatcher, public DefaultMainLoop
{ {
public: public:
int _pipe[2];
BusDispatcher() : _running(false) BusDispatcher() : _running(false)
{} {
//pipe to create a new fd used to unlock a dispatcher at any
// moment (used by leave function)
pipe(_pipe);
_fdunlock[0] = _pipe[0];
_fdunlock[1] = _pipe[1];
}
~BusDispatcher() ~BusDispatcher()
{} {}

View file

@ -149,6 +149,7 @@ public:
virtual void dispatch(); virtual void dispatch();
int _fdunlock[2];
private: private:
DefaultMutex _mutex_t; DefaultMutex _mutex_t;

View file

@ -143,7 +143,7 @@ public:
void set_property(const std::string &name, Variant &value); void set_property(const std::string &name, Variant &value);
virtual const IntrospectedInterface * introspect() const virtual IntrospectedInterface *const introspect() const
{ {
return NULL; return NULL;
} }

View file

@ -69,7 +69,7 @@ public:
protected: protected:
const IntrospectedInterface * introspect() const; IntrospectedInterface *const introspect() const;
}; };
class DXXAPI IntrospectableProxy : public InterfaceProxy class DXXAPI IntrospectableProxy : public InterfaceProxy

View file

@ -137,7 +137,7 @@ public:
private: private:
DXXAPILOCAL MessageIter(Message &m) : _msg(&m) {} DXXAPILOCAL MessageIter(Message &msg) : _msg(&msg) {}
DXXAPILOCAL bool append_basic(int type_id, void *value); DXXAPILOCAL bool append_basic(int type_id, void *value);

View file

@ -82,7 +82,7 @@ protected:
virtual void on_set_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, const Variant &/*value*/) virtual void on_set_property(InterfaceAdaptor &/*interface*/, const std::string &/*property*/, const Variant &/*value*/)
{} {}
const IntrospectedInterface *introspect() const; IntrospectedInterface *const introspect() const;
}; };
class DXXAPI PropertiesProxy : public InterfaceProxy class DXXAPI PropertiesProxy : public InterfaceProxy

View file

@ -59,7 +59,7 @@ public:
protected: protected:
Server(const Server &) Server(const Server &s)
{} {}
virtual void on_new_connection(Connection &c) = 0; virtual void on_new_connection(Connection &c) = 0;

View file

@ -55,11 +55,11 @@ public:
unref(); unref();
} }
RefCnt &operator = (const RefCnt &rc) RefCnt &operator = (const RefCnt &ref)
{ {
rc.ref(); ref.ref();
unref(); unref();
__ref = rc.__ref; __ref = ref.__ref;
return *this; return *this;
} }

View file

@ -152,7 +152,7 @@ void Connection::Private::dispatch_status_stub(DBusConnection *dc, DBusDispatchS
} }
} }
DBusHandlerResult Connection::Private::message_filter_stub(DBusConnection *, DBusMessage *dmsg, void *data) DBusHandlerResult Connection::Private::message_filter_stub(DBusConnection *conn, DBusMessage *dmsg, void *data)
{ {
MessageSlot *slot = static_cast<MessageSlot *>(data); MessageSlot *slot = static_cast<MessageSlot *>(data);

View file

@ -48,8 +48,6 @@ static void _debug_log_default(const char *format, ...)
va_end(args); va_end(args);
} }
#else
(void)format;
#endif//DEBUG #endif//DEBUG
} }

View file

@ -86,9 +86,9 @@ bool Watch::enabled() const
return dbus_watch_get_enabled((DBusWatch *)_int); return dbus_watch_get_enabled((DBusWatch *)_int);
} }
bool Watch::handle(int flags_) bool Watch::handle(int flags)
{ {
return dbus_watch_handle((DBusWatch *)_int, flags_); return dbus_watch_handle((DBusWatch *)_int, flags);
} }
/* /*
@ -114,7 +114,7 @@ void Dispatcher::Private::on_rem_watch(DBusWatch *watch, void *data)
d->rem_watch(w); d->rem_watch(w);
} }
void Dispatcher::Private::on_toggle_watch(DBusWatch *watch, void *) void Dispatcher::Private::on_toggle_watch(DBusWatch *watch, void *data)
{ {
Watch *w = static_cast<Watch *>(dbus_watch_get_data(watch)); Watch *w = static_cast<Watch *>(dbus_watch_get_data(watch));
@ -141,7 +141,7 @@ void Dispatcher::Private::on_rem_timeout(DBusTimeout *timeout, void *data)
d->rem_timeout(t); d->rem_timeout(t);
} }
void Dispatcher::Private::on_toggle_timeout(DBusTimeout *timeout, void *) void Dispatcher::Private::on_toggle_timeout(DBusTimeout *timeout, void *data)
{ {
Timeout *t = static_cast<Timeout *>(dbus_timeout_get_data(timeout)); Timeout *t = static_cast<Timeout *>(dbus_timeout_get_data(timeout));
@ -266,8 +266,7 @@ void DBus::_init_threading(
(DBusRecursiveMutexNewFunction) m1, (DBusRecursiveMutexNewFunction) m1,
(DBusRecursiveMutexFreeFunction) m2, (DBusRecursiveMutexFreeFunction) m2,
(DBusRecursiveMutexLockFunction) m3, (DBusRecursiveMutexLockFunction) m3,
(DBusRecursiveMutexUnlockFunction) m4, (DBusRecursiveMutexUnlockFunction) m4
0, 0, 0, 0
}; };
#endif//DBUS_HAS_RECURSIVE_MUTEX #endif//DBUS_HAS_RECURSIVE_MUTEX
dbus_threads_init(&functions); dbus_threads_init(&functions);

View file

@ -46,10 +46,10 @@ Error::Error(InternalError &i)
: _int(new InternalError(i)) : _int(new InternalError(i))
{} {}
Error::Error(const char *n, const char *msg) Error::Error(const char *name, const char *message)
: _int(new InternalError) : _int(new InternalError)
{ {
set(n, msg); set(name, message);
} }
Error::Error(Message &m) Error::Error(Message &m)
@ -77,9 +77,9 @@ bool Error::is_set() const
return *(_int); return *(_int);
} }
void Error::set(const char *n, const char *msg) void Error::set(const char *name, const char *message)
{ {
dbus_set_error_const(&(_int->error), n, msg); dbus_set_error_const(&(_int->error), name, message);
} }
const char *Error::what() const throw() const char *Error::what() const throw()

View file

@ -25,6 +25,8 @@
#include <config.h> #include <config.h>
#endif #endif
#include <string.h>
#include <dbus-c++/eventloop-integration.h> #include <dbus-c++/eventloop-integration.h>
#include <dbus-c++/debug.h> #include <dbus-c++/debug.h>
@ -85,6 +87,9 @@ void BusDispatcher::enter()
void BusDispatcher::leave() void BusDispatcher::leave()
{ {
_running = false; _running = false;
write(_fdunlock[1],"exit",strlen("exit"));
close(_fdunlock[1]);
close(_fdunlock[0]);
} }
void BusDispatcher::do_iteration() void BusDispatcher::do_iteration()

View file

@ -40,13 +40,13 @@ static double millis(timeval tv)
return (tv.tv_sec *1000.0 + tv.tv_usec/1000.0); return (tv.tv_sec *1000.0 + tv.tv_usec/1000.0);
} }
DefaultTimeout::DefaultTimeout(int interval_, bool repeat_, DefaultMainLoop *ed) DefaultTimeout::DefaultTimeout(int interval, bool repeat, DefaultMainLoop *ed)
: _enabled(true), _interval(interval_), _repeat(repeat_), _expiration(0), _data(0), _disp(ed) : _enabled(true), _interval(interval), _repeat(repeat), _expiration(0), _data(0), _disp(ed)
{ {
timeval now; timeval now;
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
_expiration = millis(now) + interval_; _expiration = millis(now) + interval;
_disp->_mutex_t.lock(); _disp->_mutex_t.lock();
_disp->_timeouts.push_back(this); _disp->_timeouts.push_back(this);
@ -60,8 +60,8 @@ DefaultTimeout::~DefaultTimeout()
_disp->_mutex_t.unlock(); _disp->_mutex_t.unlock();
} }
DefaultWatch::DefaultWatch(int fd, int flags_, DefaultMainLoop *ed) DefaultWatch::DefaultWatch(int fd, int flags, DefaultMainLoop *ed)
: _enabled(true), _fd(fd), _flags(flags_), _state(0), _data(0), _disp(ed) : _enabled(true), _fd(fd), _flags(flags), _state(0), _data(0), _disp(ed)
{ {
_disp->_mutex_w.lock(); _disp->_mutex_w.lock();
_disp->_watches.push_back(this); _disp->_watches.push_back(this);
@ -136,6 +136,11 @@ void DefaultMainLoop::dispatch()
int nfd = _watches.size(); int nfd = _watches.size();
if(_fdunlock)
{
nfd=nfd+2;
}
pollfd fds[nfd]; pollfd fds[nfd];
DefaultWatches::iterator wi = _watches.begin(); DefaultWatches::iterator wi = _watches.begin();
@ -151,6 +156,18 @@ void DefaultMainLoop::dispatch()
++nfd; ++nfd;
} }
} }
if(_fdunlock){
fds[nfd].fd = _fdunlock[0];
fds[nfd].events = POLLIN | POLLOUT | POLLPRI ;
fds[nfd].revents = 0;
nfd++;
fds[nfd].fd = _fdunlock[1];
fds[nfd].events = POLLIN | POLLOUT | POLLPRI ;
fds[nfd].revents = 0;
}
_mutex_w.unlock(); _mutex_w.unlock();
int wait_min = 10000; int wait_min = 10000;

View file

@ -31,7 +31,7 @@
using namespace DBus; using namespace DBus;
Glib::BusTimeout::BusTimeout(Timeout::Internal *ti, GMainContext *ctx, int priority) Glib::BusTimeout::BusTimeout(Timeout::Internal *ti, GMainContext *ctx, int priority)
: Timeout(ti), _source(NULL), _ctx(ctx), _priority(priority) : Timeout(ti), _ctx(ctx), _priority(priority), _source(NULL)
{ {
if (Timeout::enabled()) if (Timeout::enabled())
_enable(); _enable();
@ -85,7 +85,7 @@ struct BusSource
GPollFD poll; GPollFD poll;
}; };
static gboolean watch_prepare(GSource *, gint *timeout) static gboolean watch_prepare(GSource *source, gint *timeout)
{ {
//debug_log("glib: watch_prepare"); //debug_log("glib: watch_prepare");
@ -101,7 +101,7 @@ static gboolean watch_check(GSource *source)
return io->poll.revents ? TRUE : FALSE; return io->poll.revents ? TRUE : FALSE;
} }
static gboolean watch_dispatch(GSource *, GSourceFunc callback, gpointer data) static gboolean watch_dispatch(GSource *source, GSourceFunc callback, gpointer data)
{ {
debug_log("glib: watch_dispatch"); debug_log("glib: watch_dispatch");
@ -113,13 +113,11 @@ static GSourceFuncs watch_funcs = {
watch_prepare, watch_prepare,
watch_check, watch_check,
watch_dispatch, watch_dispatch,
NULL, NULL
NULL,
NULL
}; };
Glib::BusWatch::BusWatch(Watch::Internal *wi, GMainContext *ctx, int priority) Glib::BusWatch::BusWatch(Watch::Internal *wi, GMainContext *ctx, int priority)
: Watch(wi), _source(NULL), _ctx(ctx), _priority(priority) : Watch(wi), _ctx(ctx), _priority(priority), _source(NULL)
{ {
if (Watch::enabled()) if (Watch::enabled())
_enable(); _enable();
@ -167,16 +165,16 @@ void Glib::BusWatch::_enable()
g_source_set_priority(_source, _priority); g_source_set_priority(_source, _priority);
g_source_set_callback(_source, watch_handler, this, NULL); g_source_set_callback(_source, watch_handler, this, NULL);
int flags_ = Watch::flags(); int flags = Watch::flags();
int condition = 0; int condition = 0;
if (flags_ &DBUS_WATCH_READABLE) if (flags &DBUS_WATCH_READABLE)
condition |= G_IO_IN; condition |= G_IO_IN;
if (flags_ &DBUS_WATCH_WRITABLE) if (flags &DBUS_WATCH_WRITABLE)
condition |= G_IO_OUT; condition |= G_IO_OUT;
if (flags_ &DBUS_WATCH_ERROR) if (flags &DBUS_WATCH_ERROR)
condition |= G_IO_ERR; condition |= G_IO_ERR;
if (flags_ &DBUS_WATCH_HANGUP) if (flags &DBUS_WATCH_HANGUP)
condition |= G_IO_HUP; condition |= G_IO_HUP;
GPollFD *poll = &(((BusSource *)_source)->poll); GPollFD *poll = &(((BusSource *)_source)->poll);
@ -219,15 +217,15 @@ static gboolean dispatcher_prepare(GSource *source, gint *timeout)
return dispatcher->has_something_to_dispatch()? TRUE:FALSE; return dispatcher->has_something_to_dispatch()? TRUE:FALSE;
} }
static gboolean dispatcher_check(GSource *) static gboolean dispatcher_check(GSource *source)
{ {
return FALSE; return FALSE;
} }
static gboolean static gboolean
dispatcher_dispatch(GSource *source, dispatcher_dispatch(GSource *source,
GSourceFunc, GSourceFunc callback,
gpointer) gpointer user_data)
{ {
Dispatcher *dispatcher = ((DispatcherSource*)source)->dispatcher; Dispatcher *dispatcher = ((DispatcherSource*)source)->dispatcher;
@ -239,9 +237,7 @@ static const GSourceFuncs dispatcher_funcs = {
dispatcher_prepare, dispatcher_prepare,
dispatcher_check, dispatcher_check,
dispatcher_dispatch, dispatcher_dispatch,
NULL, NULL
NULL,
NULL
}; };
Glib::BusDispatcher::BusDispatcher() Glib::BusDispatcher::BusDispatcher()

View file

@ -32,40 +32,40 @@
using namespace DBus; using namespace DBus;
Interface::Interface(const std::string &n) Interface::Interface(const std::string &name)
: _name(n) : _name(name)
{} {}
Interface::~Interface() Interface::~Interface()
{} {}
InterfaceAdaptor *AdaptorBase::find_interface(const std::string &n) InterfaceAdaptor *AdaptorBase::find_interface(const std::string &name)
{ {
InterfaceAdaptorTable::const_iterator ii = _interfaces.find(n); InterfaceAdaptorTable::const_iterator ii = _interfaces.find(name);
return ii != _interfaces.end() ? ii->second : NULL; return ii != _interfaces.end() ? ii->second : NULL;
} }
InterfaceAdaptor::InterfaceAdaptor(const std::string &n) InterfaceAdaptor::InterfaceAdaptor(const std::string &name)
: Interface(n) : Interface(name)
{ {
debug_log("adding interface %s", n.c_str()); debug_log("adding interface %s", name.c_str());
_interfaces[n] = this; _interfaces[name] = this;
} }
Message InterfaceAdaptor::dispatch_method(const CallMessage &msg) Message InterfaceAdaptor::dispatch_method(const CallMessage &msg)
{ {
const char *n = msg.member(); const char *name = msg.member();
MethodTable::iterator mi = _methods.find(n); MethodTable::iterator mi = _methods.find(name);
if (mi != _methods.end()) if (mi != _methods.end())
{ {
return mi->second.call(msg); return mi->second.call(msg);
} }
else else
{ {
return ErrorMessage(msg, DBUS_ERROR_UNKNOWN_METHOD, n); return ErrorMessage(msg, DBUS_ERROR_UNKNOWN_METHOD, name);
} }
} }
@ -79,9 +79,9 @@ void InterfaceAdaptor::emit_signal(const SignalMessage &sig)
_emit_signal(sig2); _emit_signal(sig2);
} }
Variant *InterfaceAdaptor::get_property(const std::string &n) Variant *InterfaceAdaptor::get_property(const std::string &name)
{ {
PropertyTable::iterator pti = _properties.find(n); PropertyTable::iterator pti = _properties.find(name);
if (pti != _properties.end()) if (pti != _properties.end())
{ {
@ -93,9 +93,9 @@ Variant *InterfaceAdaptor::get_property(const std::string &n)
return NULL; return NULL;
} }
void InterfaceAdaptor::set_property(const std::string &n, Variant &value) void InterfaceAdaptor::set_property(const std::string &name, Variant &value)
{ {
PropertyTable::iterator pti = _properties.find(n); PropertyTable::iterator pti = _properties.find(name);
if (pti != _properties.end()) if (pti != _properties.end())
{ {
@ -113,26 +113,26 @@ void InterfaceAdaptor::set_property(const std::string &n, Variant &value)
throw ErrorFailed("requested property not found"); throw ErrorFailed("requested property not found");
} }
InterfaceProxy *ProxyBase::find_interface(const std::string &n) InterfaceProxy *ProxyBase::find_interface(const std::string &name)
{ {
InterfaceProxyTable::const_iterator ii = _interfaces.find(n); InterfaceProxyTable::const_iterator ii = _interfaces.find(name);
return ii != _interfaces.end() ? ii->second : NULL; return ii != _interfaces.end() ? ii->second : NULL;
} }
InterfaceProxy::InterfaceProxy(const std::string &n) InterfaceProxy::InterfaceProxy(const std::string &name)
: Interface(n) : Interface(name)
{ {
debug_log("adding interface %s", n.c_str()); debug_log("adding interface %s", name.c_str());
_interfaces[n] = this; _interfaces[name] = this;
} }
bool InterfaceProxy::dispatch_signal(const SignalMessage &msg) bool InterfaceProxy::dispatch_signal(const SignalMessage &msg)
{ {
const char *n = msg.member(); const char *name = msg.member();
SignalTable::iterator si = _signals.find(n); SignalTable::iterator si = _signals.find(name);
if (si != _signals.end()) if (si != _signals.end())
{ {
si->second.call(msg); si->second.call(msg);

View file

@ -61,7 +61,7 @@ Message IntrospectableAdaptor::Introspect(const CallMessage &call)
{ {
debug_log("introspecting interface %s", iti->first.c_str()); debug_log("introspecting interface %s", iti->first.c_str());
const IntrospectedInterface * intro = iti->second->introspect(); IntrospectedInterface *const intro = iti->second->introspect();
if (intro) if (intro)
{ {
xml << "\n\t<interface name=\"" << intro->name << "\">"; xml << "\n\t<interface name=\"" << intro->name << "\">";
@ -144,7 +144,7 @@ Message IntrospectableAdaptor::Introspect(const CallMessage &call)
return reply; return reply;
} }
const IntrospectedInterface * IntrospectableAdaptor::introspect() const IntrospectedInterface *const IntrospectableAdaptor::introspect() const
{ {
static IntrospectedArgument Introspect_args[] = static IntrospectedArgument Introspect_args[] =
{ {

View file

@ -236,9 +236,9 @@ char *MessageIter::signature() const
return dbus_message_iter_get_signature((DBusMessageIter *)&_iter); return dbus_message_iter_get_signature((DBusMessageIter *)&_iter);
} }
bool MessageIter::append_array(char type_, const void *ptr, size_t length) bool MessageIter::append_array(char type, const void *ptr, size_t length)
{ {
return dbus_message_iter_append_fixed_array((DBusMessageIter *)&_iter, type_, &ptr, length); return dbus_message_iter_append_fixed_array((DBusMessageIter *)&_iter, type, &ptr, length);
} }
int MessageIter::array_type() int MessageIter::array_type()
@ -491,9 +491,9 @@ ErrorMessage::ErrorMessage()
_pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_ERROR); _pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_ERROR);
} }
ErrorMessage::ErrorMessage(const Message &to_reply, const char *name_, const char *message) ErrorMessage::ErrorMessage(const Message &to_reply, const char *name, const char *message)
{ {
_pvt->msg = dbus_message_new_error(to_reply._pvt->msg, name_, message); _pvt->msg = dbus_message_new_error(to_reply._pvt->msg, name, message);
} }
bool ErrorMessage::operator == (const ErrorMessage &m) const bool ErrorMessage::operator == (const ErrorMessage &m) const
@ -520,9 +520,9 @@ SignalMessage::SignalMessage(const char *name)
member(name); member(name);
} }
SignalMessage::SignalMessage(const char *path_, const char *interface_, const char *name) SignalMessage::SignalMessage(const char *path, const char *interface, const char *name)
{ {
_pvt->msg = dbus_message_new_signal(path_, interface_, name); _pvt->msg = dbus_message_new_signal(path, interface, name);
} }
bool SignalMessage::operator == (const SignalMessage &m) const bool SignalMessage::operator == (const SignalMessage &m) const
@ -575,9 +575,9 @@ CallMessage::CallMessage()
_pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL); _pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_CALL);
} }
CallMessage::CallMessage(const char *dest, const char *path_, const char *iface, const char *method) CallMessage::CallMessage(const char *dest, const char *path, const char *iface, const char *method)
{ {
_pvt->msg = dbus_message_new_method_call(dest, path_, iface, method); _pvt->msg = dbus_message_new_method_call(dest, path, iface, method);
} }
bool CallMessage::operator == (const CallMessage &m) const bool CallMessage::operator == (const CallMessage &m) const

View file

@ -39,8 +39,8 @@
using namespace DBus; using namespace DBus;
Object::Object(Connection &conn_, const Path &path_, const char *service_) Object::Object(Connection &conn, const Path &path, const char *service)
: _conn(conn_), _path(path_), _service(service_ ? service_ : "") : _conn(conn), _path(path), _service(service ? service : "")
{ {
} }
@ -61,7 +61,7 @@ static DBusObjectPathVTable _vtable =
NULL, NULL, NULL, NULL NULL, NULL, NULL, NULL
}; };
void ObjectAdaptor::Private::unregister_function_stub(DBusConnection *, void *) void ObjectAdaptor::Private::unregister_function_stub(DBusConnection *conn, void *data)
{ {
//TODO: what do we have to do here ? //TODO: what do we have to do here ?
} }
@ -148,8 +148,8 @@ ObjectPathList ObjectAdaptor::child_nodes_from_prefix(const std::string &prefix)
return ali; return ali;
} }
ObjectAdaptor::ObjectAdaptor(Connection &conn_, const Path &path_) ObjectAdaptor::ObjectAdaptor(Connection &conn, const Path &path)
: Object(conn_, path_, conn_.unique_name()) : Object(conn, path, conn.unique_name())
{ {
register_obj(); register_obj();
} }
@ -270,8 +270,8 @@ ObjectAdaptor::Continuation *ObjectAdaptor::find_continuation(const Tag *tag)
return di != _continuations.end() ? di->second : NULL; return di != _continuations.end() ? di->second : NULL;
} }
ObjectAdaptor::Continuation::Continuation(Connection &conn, const CallMessage &call, const Tag *tag_) ObjectAdaptor::Continuation::Continuation(Connection &conn, const CallMessage &call, const Tag *tag)
: _conn(conn), _call(call), _return(_call), _tag(tag_) : _conn(conn), _call(call), _return(_call), _tag(tag)
{ {
_writer = _return.writer(); //todo: verify _writer = _return.writer(); //todo: verify
} }
@ -279,8 +279,8 @@ ObjectAdaptor::Continuation::Continuation(Connection &conn, const CallMessage &c
/* /*
*/ */
ObjectProxy::ObjectProxy(Connection &conn_, const Path &path_, const char *service_) ObjectProxy::ObjectProxy(Connection &conn, const Path &path, const char *service)
: Object(conn_, path_, service_) : Object(conn, path, service)
{ {
register_obj(); register_obj();
} }

View file

@ -52,7 +52,7 @@ PendingCall::Private::~Private()
} }
} }
void PendingCall::Private::notify_stub(DBusPendingCall *, void *data) void PendingCall::Private::notify_stub(DBusPendingCall *dpc, void *data)
{ {
PendingCall::Private *pvt = static_cast<PendingCall::Private *>(data); PendingCall::Private *pvt = static_cast<PendingCall::Private *>(data);

View file

@ -96,7 +96,7 @@ Message PropertiesAdaptor::Set(const CallMessage &call)
return reply; return reply;
} }
const IntrospectedInterface *PropertiesAdaptor::introspect() const IntrospectedInterface *const PropertiesAdaptor::introspect() const
{ {
static IntrospectedArgument Get_args[] = static IntrospectedArgument Get_args[] =
{ {
@ -141,14 +141,14 @@ PropertiesProxy::PropertiesProxy()
{ {
} }
Variant PropertiesProxy::Get(const std::string &/*iface*/, const std::string &/*property*/) Variant PropertiesProxy::Get(const std::string &iface, const std::string &property)
{ {
//todo //todo
Variant v; Variant v;
return v; return v;
} }
void PropertiesProxy::Set(const std::string &/*iface*/, const std::string &/*property*/, const Variant &/*value*/) void PropertiesProxy::Set(const std::string &iface, const std::string &property, const Variant &value)
{ {
//todo //todo
} }

View file

@ -44,7 +44,7 @@ Server::Private::~Private()
{ {
} }
void Server::Private::on_new_conn_cb(DBusServer *, DBusConnection *conn, void *data) void Server::Private::on_new_conn_cb(DBusServer *server, DBusConnection *conn, void *data)
{ {
Server *s = static_cast<Server *>(data); Server *s = static_cast<Server *>(data);

View file

@ -68,11 +68,11 @@ const Signature Variant::signature() const
{ {
char *sigbuf = reader().signature(); char *sigbuf = reader().signature();
Signature sig = sigbuf; Signature signature = sigbuf;
free(sigbuf); free(sigbuf);
return sig; return signature;
} }
MessageIter &operator << (MessageIter &iter, const Variant &val) MessageIter &operator << (MessageIter &iter, const Variant &val)

View file

@ -145,7 +145,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
body << tab << "}" << endl body << tab << "}" << endl
<< endl; << endl;
body << tab << "const ::DBus::IntrospectedInterface *introspect() const " << endl body << tab << "::DBus::IntrospectedInterface *const introspect() const " << endl
<< tab << "{" << endl; << tab << "{" << endl;
// generate the introspect arguments // generate the introspect arguments

View file

@ -1,6 +1,6 @@
/* /*
* *
* D-->Bus++ - C++ bindings for D-Bus * D-Bus++ - C++ bindings for D-Bus
* *
* Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com>
* *
@ -30,7 +30,6 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>
#include <algorithm>
#include "xml2cpp.h" #include "xml2cpp.h"
#include "generate_adaptor.h" #include "generate_adaptor.h"
@ -54,13 +53,16 @@ void usage(const char *argv0)
return t; return t;
return DBUS_TYPE_INVALID; return DBUS_TYPE_INVALID;
} }*/
bool is_atomic_type(const string &type)
/*bool is_atomic_type(const string &type)
{ {
return type.length() == 1 && char_to_atomic_type(type[0]) != DBUS_TYPE_INVALID; return type.length() == 1 && char_to_atomic_type(type[0]) != DBUS_TYPE_INVALID;
}*/ }*/
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
if (argc < 2) if (argc < 2)