summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Volz <andreas@optolix.mittelerde>2008-08-14 23:59:23 +0200
committerAndreas Volz <andreas@optolix.mittelerde>2008-08-14 23:59:23 +0200
commitc1970e2352896a254b852ecd0579c3560353a32c (patch)
tree232020ea019daae5f5e280899b5748e0767d06a1 /src
parent7e098eaf9eb13e159436686699098ea04737a8c8 (diff)
parentf0a9278511c37b253c6b2a5de1d1320d2398d80d (diff)
downloaddbus-c++-c1970e2352896a254b852ecd0579c3560353a32c.tar.gz
Merge branch 'master' of git://anongit.freedesktop.org/git/dbus/dbus-c++
Merge branch 'master' of git://anongit.freedesktop.org/git/dbus/dbus-c++ Conflicts: include/dbus-c++/connection.h include/dbus-c++/dispatcher.h include/dbus-c++/pendingcall.h src/dispatcher.cpp
Diffstat (limited to 'src')
-rw-r--r--src/connection.cpp104
-rw-r--r--src/connection_p.h16
-rw-r--r--src/debug.cpp4
-rw-r--r--src/dispatcher.cpp64
-rw-r--r--src/dispatcher_p.h12
-rw-r--r--src/error.cpp14
-rw-r--r--src/eventloop-integration.cpp48
-rw-r--r--src/eventloop.cpp34
-rw-r--r--src/glib-integration.cpp71
-rw-r--r--src/interface.cpp52
-rw-r--r--src/internalerror.h8
-rw-r--r--src/introspection.cpp36
-rw-r--r--src/message.cpp192
-rw-r--r--src/message_p.h4
-rw-r--r--src/object.cpp102
-rw-r--r--src/pendingcall.cpp36
-rw-r--r--src/pendingcall_p.h8
-rw-r--r--src/property.cpp32
-rw-r--r--src/server.cpp20
-rw-r--r--src/server_p.h8
-rw-r--r--src/types.cpp14
21 files changed, 443 insertions, 436 deletions
diff --git a/src/connection.cpp b/src/connection.cpp
index 16d951f..4620594 100644
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -44,19 +44,19 @@
using namespace DBus;
-Connection::Private::Private( DBusConnection* c, Server::Private* s )
+Connection::Private::Private(DBusConnection *c, Server::Private *s)
: conn(c) , dispatcher(0), server(s)
{
init();
}
-Connection::Private::Private( DBusBusType type )
+Connection::Private::Private(DBusBusType type)
{
InternalError e;
conn = dbus_bus_get_private(type, e);
- if(e) throw Error(e);
+ if (e) throw Error(e);
init();
}
@@ -67,11 +67,11 @@ Connection::Private::~Private()
detach_server();
- if(dbus_connection_get_is_connected(conn))
+ if (dbus_connection_get_is_connected(conn))
{
std::vector<std::string>::iterator i = names.begin();
- while(i != names.end())
+ while (i != names.end())
{
debug_log("%s: releasing bus name %s", dbus_bus_get_unique_name(conn), i->c_str());
dbus_bus_release_name(conn, i->c_str(), NULL);
@@ -87,7 +87,7 @@ void Connection::Private::init()
dbus_connection_ref(conn);
dbus_connection_ref(conn); //todo: the library has to own another reference
- disconn_filter = new Callback<Connection::Private, bool, const Message&>(
+ disconn_filter = new Callback<Connection::Private, bool, const Message &>(
this, &Connection::Private::disconn_filter_function
);
@@ -99,17 +99,17 @@ void Connection::Private::init()
void Connection::Private::detach_server()
{
-/* Server::Private* tmp = server;
+/* Server::Private *tmp = server;
server = NULL;
- if(tmp)
+ if (tmp)
{
ConnectionList::iterator i;
- for(i = tmp->connections.begin(); i != tmp->connections.end(); ++i)
+ for (i = tmp->connections.begin(); i != tmp->connections.end(); ++i)
{
- if(i->_pvt.get() == this)
+ if (i->_pvt.get() == this)
{
tmp->connections.erase(i);
break;
@@ -122,7 +122,7 @@ bool Connection::Private::do_dispatch()
{
debug_log("dispatching on %p", conn);
- if(!dbus_connection_get_is_connected(conn))
+ if (!dbus_connection_get_is_connected(conn))
{
debug_log("connection terminated");
@@ -134,11 +134,11 @@ bool Connection::Private::do_dispatch()
return dbus_connection_dispatch(conn) != DBUS_DISPATCH_DATA_REMAINS;
}
-void Connection::Private::dispatch_status_stub( DBusConnection* dc, DBusDispatchStatus status, void* data )
+void Connection::Private::dispatch_status_stub(DBusConnection *dc, DBusDispatchStatus status, void *data)
{
- Private* p = static_cast<Private*>(data);
+ Private *p = static_cast<Private *>(data);
- switch(status)
+ switch (status)
{
case DBUS_DISPATCH_DATA_REMAINS:
debug_log("some dispatching to do on %p", dc);
@@ -155,9 +155,9 @@ void Connection::Private::dispatch_status_stub( DBusConnection* dc, DBusDispatch
}
}
-DBusHandlerResult Connection::Private::message_filter_stub( DBusConnection* conn, 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);
Message msg = Message(new Message::Private(dmsg));
@@ -166,9 +166,9 @@ DBusHandlerResult Connection::Private::message_filter_stub( DBusConnection* conn
: DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
-bool Connection::Private::disconn_filter_function( const Message& msg )
+bool Connection::Private::disconn_filter_function(const Message &msg)
{
- if(msg.is_signal(DBUS_INTERFACE_LOCAL,"Disconnected"))
+ if (msg.is_signal(DBUS_INTERFACE_LOCAL,"Disconnected"))
{
debug_log("%p disconnected by local bus", conn);
dbus_connection_close(conn);
@@ -193,14 +193,14 @@ Connection Connection::ActivationBus()
return Connection(new Private(DBUS_BUS_STARTER));
}
-Connection::Connection( const char* address, bool priv )
+Connection::Connection(const char *address, bool priv)
{
InternalError e;
- DBusConnection* conn = priv
+ DBusConnection *conn = priv
? dbus_connection_open_private(address, e)
: dbus_connection_open(address, e);
- if(e) throw Error(e);
+ if (e) throw Error(e);
_pvt = new Private(conn);
@@ -209,13 +209,13 @@ Connection::Connection( const char* address, bool priv )
debug_log("connected to %s", address);
}
-Connection::Connection( Connection::Private* p )
+Connection::Connection(Connection::Private *p)
: _pvt(p)
{
setup(default_dispatcher);
}
-Connection::Connection( const Connection& c )
+Connection::Connection(const Connection &c)
: _pvt(c._pvt)
{
dbus_connection_ref(_pvt->conn);
@@ -226,15 +226,15 @@ Connection::~Connection()
dbus_connection_unref(_pvt->conn);
}
-Dispatcher* Connection::setup( Dispatcher* dispatcher )
+Dispatcher *Connection::setup(Dispatcher *dispatcher)
{
debug_log("registering stubs for connection %p", _pvt->conn);
- if(!dispatcher) dispatcher = default_dispatcher;
+ if (!dispatcher) dispatcher = default_dispatcher;
- if(!dispatcher) throw ErrorFailed("no default dispatcher set for new connection");
+ if (!dispatcher) throw ErrorFailed("no default dispatcher set for new connection");
- Dispatcher* prev = _pvt->dispatcher;
+ Dispatcher *prev = _pvt->dispatcher;
_pvt->dispatcher = dispatcher;
@@ -261,7 +261,7 @@ Dispatcher* Connection::setup( Dispatcher* dispatcher )
return prev;
}
-bool Connection::operator == ( const Connection& c ) const
+bool Connection::operator == (const Connection &c) const
{
return _pvt->conn == c._pvt->conn;
}
@@ -272,7 +272,7 @@ bool Connection::register_bus()
bool r = dbus_bus_register(_pvt->conn, e);
- if(e) throw (e);
+ if (e) throw (e);
return r;
}
@@ -288,17 +288,17 @@ void Connection::disconnect()
dbus_connection_close(_pvt->conn);
}
-void Connection::exit_on_disconnect( bool exit )
+void Connection::exit_on_disconnect(bool exit)
{
dbus_connection_set_exit_on_disconnect(_pvt->conn, exit);
}
-bool Connection::unique_name( const char* n )
+bool Connection::unique_name(const char *n)
{
return dbus_bus_set_unique_name(_pvt->conn, n);
}
-const char* Connection::unique_name() const
+const char *Connection::unique_name() const
{
return dbus_bus_get_unique_name(_pvt->conn);
}
@@ -308,7 +308,7 @@ void Connection::flush()
dbus_connection_flush(_pvt->conn);
}
-void Connection::add_match( const char* rule )
+void Connection::add_match(const char *rule)
{
InternalError e;
@@ -316,10 +316,10 @@ void Connection::add_match( const char* rule )
debug_log("%s: added match rule %s", unique_name(), rule);
- if(e) throw Error(e);
+ if (e) throw Error(e);
}
-void Connection::remove_match( const char* rule )
+void Connection::remove_match(const char *rule)
{
InternalError e;
@@ -327,50 +327,50 @@ void Connection::remove_match( const char* rule )
debug_log("%s: removed match rule %s", unique_name(), rule);
- if(e) throw Error(e);
+ if (e) throw Error(e);
}
-bool Connection::add_filter( MessageSlot& s )
+bool Connection::add_filter(MessageSlot &s)
{
debug_log("%s: adding filter", unique_name());
return dbus_connection_add_filter(_pvt->conn, Private::message_filter_stub, &s, NULL);
}
-void Connection::remove_filter( MessageSlot& s )
+void Connection::remove_filter(MessageSlot &s)
{
debug_log("%s: removing filter", unique_name());
dbus_connection_remove_filter(_pvt->conn, Private::message_filter_stub, &s);
}
-bool Connection::send( const Message& msg, unsigned int* serial )
+bool Connection::send(const Message &msg, unsigned int *serial)
{
return dbus_connection_send(_pvt->conn, msg._pvt->msg, serial);
}
-Message Connection::send_blocking( Message& msg, int timeout )
+Message Connection::send_blocking(Message &msg, int timeout)
{
- DBusMessage* reply;
+ DBusMessage *reply;
InternalError e;
reply = dbus_connection_send_with_reply_and_block(_pvt->conn, msg._pvt->msg, timeout, e);
- if(e) throw Error(e);
+ if (e) throw Error(e);
return Message(new Message::Private(reply), false);
}
-PendingCall Connection::send_async( Message& msg, int timeout )
+PendingCall Connection::send_async(Message &msg, int timeout)
{
- DBusPendingCall* pending;
+ DBusPendingCall *pending;
- if(!dbus_connection_send_with_reply(_pvt->conn, msg._pvt->msg, &pending, timeout))
+ if (!dbus_connection_send_with_reply(_pvt->conn, msg._pvt->msg, &pending, timeout))
{
throw ErrorNoMemory("Unable to start asynchronous call");
}
return PendingCall(new PendingCall::Private(pending));
}
-void Connection::request_name( const char* name, int flags )
+void Connection::request_name(const char *name, int flags)
{
InternalError e;
@@ -378,11 +378,11 @@ void Connection::request_name( const char* name, int flags )
dbus_bus_request_name(_pvt->conn, name, flags, e); //we deliberately don't check return value
- if(e) throw Error(e);
+ if (e) throw Error(e);
// this->remove_match("destination");
- if(name)
+ if (name)
{
_pvt->names.push_back(name);
std::string match = "destination='" + _pvt->names.back() + "'";
@@ -390,13 +390,13 @@ void Connection::request_name( const char* name, int flags )
}
}
-bool Connection::has_name( const char* name )
+bool Connection::has_name(const char *name)
{
InternalError e;
bool b = dbus_bus_name_has_owner(_pvt->conn, name, e);
- if(e) throw Error(e);
+ if (e) throw Error(e);
return b;
}
@@ -406,13 +406,13 @@ const std::vector<std::string>& Connection::names()
return _pvt->names;
}
-bool Connection::start_service( const char* name, unsigned long flags )
+bool Connection::start_service(const char *name, unsigned long flags)
{
InternalError e;
bool b = dbus_bus_start_service_by_name(_pvt->conn, name, flags, NULL, e);
- if(e) throw Error(e);
+ if (e) throw Error(e);
return b;
}
diff --git a/src/connection_p.h b/src/connection_p.h
index 3b9b665..65d6c71 100644
--- a/src/connection_p.h
+++ b/src/connection_p.h
@@ -43,30 +43,30 @@ namespace DBus {
struct DXXAPILOCAL Connection::Private
{
- DBusConnection* conn;
+ DBusConnection * conn;
std::vector<std::string> names;
- Dispatcher* dispatcher;
+ Dispatcher *dispatcher;
bool do_dispatch();
MessageSlot disconn_filter;
- bool disconn_filter_function( const Message& );
+ bool disconn_filter_function(const Message &);
- Server::Private* server;
+ Server::Private *server;
void detach_server();
- Private( DBusConnection*, Server::Private* = NULL );
+ Private(DBusConnection *, Server::Private * = NULL);
- Private( DBusBusType );
+ Private(DBusBusType);
~Private();
void init();
- static void dispatch_status_stub( DBusConnection*, DBusDispatchStatus, void* );
+ static void dispatch_status_stub(DBusConnection *, DBusDispatchStatus, void *);
- static DBusHandlerResult message_filter_stub( DBusConnection*, DBusMessage*, void* );
+ static DBusHandlerResult message_filter_stub(DBusConnection *, DBusMessage *, void *);
};
} /* namespace DBus */
diff --git a/src/debug.cpp b/src/debug.cpp
index e83369b..95d8083 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -32,13 +32,13 @@
#include <cstdio>
#include <stdlib.h>
-static void _debug_log_default(const char* format, ...)
+static void _debug_log_default(const char *format, ...)
{
#ifdef DEBUG
static int debug_env = getenv("DBUSXX_VERBOSE") ? 1 : 0;
- if(debug_env)
+ if (debug_env)
{
va_list args;
va_start(args, format);
diff --git a/src/dispatcher.cpp b/src/dispatcher.cpp
index 58aacca..0e1619a 100644
--- a/src/dispatcher.cpp
+++ b/src/dispatcher.cpp
@@ -34,38 +34,38 @@
#include "server_p.h"
#include "connection_p.h"
-DBus::Dispatcher* DBus::default_dispatcher = NULL;
+DBus::Dispatcher *DBus::default_dispatcher = NULL;
using namespace DBus;
-Timeout::Timeout( Timeout::Internal* i )
+Timeout::Timeout(Timeout::Internal *i)
: _int(i)
{
- dbus_timeout_set_data((DBusTimeout*)i, this, NULL);
+ dbus_timeout_set_data((DBusTimeout *)i, this, NULL);
}
int Timeout::interval() const
{
- return dbus_timeout_get_interval((DBusTimeout*)_int);
+ return dbus_timeout_get_interval((DBusTimeout *)_int);
}
bool Timeout::enabled() const
{
- return dbus_timeout_get_enabled((DBusTimeout*)_int);
+ return dbus_timeout_get_enabled((DBusTimeout *)_int);
}
bool Timeout::handle()
{
- return dbus_timeout_handle((DBusTimeout*)_int);
+ return dbus_timeout_handle((DBusTimeout *)_int);
}
/*
*/
-Watch::Watch( Watch::Internal* i )
+Watch::Watch(Watch::Internal *i)
: _int(i)
{
- dbus_watch_set_data((DBusWatch*)i, this, NULL);
+ dbus_watch_set_data((DBusWatch *)i, this, NULL);
}
int Watch::descriptor() const
@@ -79,77 +79,77 @@ int Watch::descriptor() const
int Watch::flags() const
{
- return dbus_watch_get_flags((DBusWatch*)_int);
+ return dbus_watch_get_flags((DBusWatch *)_int);
}
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);
}
/*
*/
-dbus_bool_t Dispatcher::Private::on_add_watch( DBusWatch* watch, void* data )
+dbus_bool_t Dispatcher::Private::on_add_watch(DBusWatch *watch, void *data)
{
- Dispatcher* d = static_cast<Dispatcher*>(data);
+ Dispatcher *d = static_cast<Dispatcher *>(data);
- Watch::Internal* w = reinterpret_cast<Watch::Internal*>(watch);
+ Watch::Internal *w = reinterpret_cast<Watch::Internal *>(watch);
d->add_watch(w);
return true;
}
-void Dispatcher::Private::on_rem_watch( DBusWatch* watch, void* data )
+void Dispatcher::Private::on_rem_watch(DBusWatch *watch, void *data)
{
- Dispatcher* d = static_cast<Dispatcher*>(data);
+ Dispatcher *d = static_cast<Dispatcher *>(data);
- Watch* w = static_cast<Watch*>(dbus_watch_get_data(watch));
+ Watch *w = static_cast<Watch *>(dbus_watch_get_data(watch));
d->rem_watch(w);
}
-void Dispatcher::Private::on_toggle_watch( DBusWatch* watch, void* data )
+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));
w->toggle();
}
-dbus_bool_t Dispatcher::Private::on_add_timeout( DBusTimeout* timeout, void* data )
+dbus_bool_t Dispatcher::Private::on_add_timeout(DBusTimeout *timeout, void *data)
{
- Dispatcher* d = static_cast<Dispatcher*>(data);
+ Dispatcher *d = static_cast<Dispatcher *>(data);
- Timeout::Internal* t = reinterpret_cast<Timeout::Internal*>(timeout);
+ Timeout::Internal *t = reinterpret_cast<Timeout::Internal *>(timeout);
d->add_timeout(t);
return true;
}
-void Dispatcher::Private::on_rem_timeout( DBusTimeout* timeout, void* data )
+void Dispatcher::Private::on_rem_timeout(DBusTimeout *timeout, void *data)
{
- Dispatcher* d = static_cast<Dispatcher*>(data);
+ Dispatcher *d = static_cast<Dispatcher *>(data);
- Timeout* t = static_cast<Timeout*>(dbus_timeout_get_data(timeout));
+ Timeout *t = static_cast<Timeout *>(dbus_timeout_get_data(timeout));
d->rem_timeout(t);
}
-void Dispatcher::Private::on_toggle_timeout( DBusTimeout* timeout, void* data )
+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));
t->toggle();
}
-void Dispatcher::queue_connection( Connection::Private* cp )
+void Dispatcher::queue_connection(Connection::Private *cp)
{
_mutex_p.lock();
_pending_queue.push_back(cp);
@@ -160,19 +160,19 @@ void Dispatcher::dispatch_pending()
{
_mutex_p.lock();
- while(_pending_queue.size() > 0)
+ while (_pending_queue.size() > 0)
{
Connection::PrivatePList::iterator i, j;
i = _pending_queue.begin();
- while(i != _pending_queue.end())
+ while (i != _pending_queue.end())
{
j = i;
++j;
- if((*i)->do_dispatch())
+ if ((*i)->do_dispatch())
_pending_queue.erase(i);
i = j;
diff --git a/src/dispatcher_p.h b/src/dispatcher_p.h
index ac4c9ff..5f25782 100644
--- a/src/dispatcher_p.h
+++ b/src/dispatcher_p.h
@@ -40,17 +40,17 @@ namespace DBus {
struct DXXAPILOCAL Dispatcher::Private
{
- static dbus_bool_t on_add_watch( DBusWatch* watch, void* data );
+ static dbus_bool_t on_add_watch(DBusWatch *watch, void *data);
- static void on_rem_watch( DBusWatch* watch, void* data );
+ static void on_rem_watch(DBusWatch *watch, void *data);
- static void on_toggle_watch( DBusWatch* watch, void* data );
+ static void on_toggle_watch(DBusWatch *watch, void *data);
- static dbus_bool_t on_add_timeout( DBusTimeout* timeout, void* data );
+ static dbus_bool_t on_add_timeout(DBusTimeout *timeout, void *data);
- static void on_rem_timeout( DBusTimeout* timeout, void* data );
+ static void on_rem_timeout(DBusTimeout *timeout, void *data);
- static void on_toggle_timeout( DBusTimeout* timeout, void* data );
+ static void on_toggle_timeout(DBusTimeout *timeout, void *data);
};
} /* namespace DBus */
diff --git a/src/error.cpp b/src/error.cpp
index c08c697..dc17d00 100644
--- a/src/error.cpp
+++ b/src/error.cpp
@@ -43,17 +43,17 @@ Error::Error()
: _int(new InternalError)
{}
-Error::Error(InternalError& i)
+Error::Error(InternalError &i)
: _int(new InternalError(i))
{}
-Error::Error( const char* name, const char* message )
+Error::Error(const char *name, const char *message)
: _int(new InternalError)
{
set(name, message);
}
-Error::Error( Message& m )
+Error::Error(Message &m)
: _int(new InternalError)
{
dbus_set_error_from_message(&(_int->error), m._pvt->msg);
@@ -63,12 +63,12 @@ Error::~Error() throw()
{
}
-const char* Error::name() const
+const char *Error::name() const
{
return _int->error.name;
}
-const char* Error::message() const
+const char *Error::message() const
{
return _int->error.message;
}
@@ -78,12 +78,12 @@ bool Error::is_set() const
return *(_int);
}
-void Error::set( const char* name, const char* message )
+void Error::set(const char *name, const char *message)
{
dbus_set_error_const(&(_int->error), name, message);
}
-const char* Error::what() const throw()
+const char *Error::what() const throw()
{
return _int->error.message;
}
diff --git a/src/eventloop-integration.cpp b/src/eventloop-integration.cpp
index b3ef2bb..5cdc79a 100644
--- a/src/eventloop-integration.cpp
+++ b/src/eventloop-integration.cpp
@@ -35,7 +35,7 @@
using namespace DBus;
-BusTimeout::BusTimeout( Timeout::Internal* ti, BusDispatcher* bd )
+BusTimeout::BusTimeout(Timeout::Internal *ti, BusDispatcher *bd)
: Timeout(ti), DefaultTimeout(Timeout::interval(), true, bd)
{
DefaultTimeout::enabled(Timeout::enabled());
@@ -48,14 +48,14 @@ void BusTimeout::toggle()
DefaultTimeout::enabled(Timeout::enabled());
}
-BusWatch::BusWatch( Watch::Internal* wi, BusDispatcher* bd )
+BusWatch::BusWatch(Watch::Internal *wi, BusDispatcher *bd)
: Watch(wi), DefaultWatch(Watch::descriptor(), 0, bd)
{
int flags = POLLHUP | POLLERR;
- if(Watch::flags() & DBUS_WATCH_READABLE)
+ if (Watch::flags() & DBUS_WATCH_READABLE)
flags |= POLLIN;
- if(Watch::flags() & DBUS_WATCH_WRITABLE)
+ if (Watch::flags() & DBUS_WATCH_WRITABLE)
flags |= POLLOUT;
DefaultWatch::flags(flags);
@@ -75,7 +75,7 @@ void BusDispatcher::enter()
_running = true;
- while(_running)
+ while (_running)
{
do_iteration();
}
@@ -94,72 +94,72 @@ void BusDispatcher::do_iteration()
dispatch();
}
-Timeout* BusDispatcher::add_timeout( Timeout::Internal* ti )
+Timeout *BusDispatcher::add_timeout(Timeout::Internal *ti)
{
- BusTimeout* bt = new BusTimeout(ti, this);
+ BusTimeout *bt = new BusTimeout(ti, this);
- bt->expired = new Callback<BusDispatcher, void, DefaultTimeout&>(this, &BusDispatcher::timeout_expired);
+ bt->expired = new Callback<BusDispatcher, void, DefaultTimeout &>(this, &BusDispatcher::timeout_expired);
bt->data(bt);
- debug_log("added timeout %p (%s)", bt, ((Timeout*)bt)->enabled() ? "on":"off");
+ debug_log("added timeout %p (%s)", bt, ((Timeout *)bt)->enabled() ? "on":"off");
return bt;
}
-void BusDispatcher::rem_timeout( Timeout* t )
+void BusDispatcher::rem_timeout(Timeout *t)
{
debug_log("removed timeout %p", t);
delete t;
}
-Watch* BusDispatcher::add_watch( Watch::Internal* wi )
+Watch *BusDispatcher::add_watch(Watch::Internal *wi)
{
- BusWatch* bw = new BusWatch(wi, this);
+ BusWatch *bw = new BusWatch(wi, this);
- bw->ready = new Callback<BusDispatcher, void, DefaultWatch&>(this, &BusDispatcher::watch_ready);
+ bw->ready = new Callback<BusDispatcher, void, DefaultWatch &>(this, &BusDispatcher::watch_ready);
bw->data(bw);
debug_log("added watch %p (%s) fd=%d flags=%d",
- bw, ((Watch*)bw)->enabled() ? "on":"off", ((Watch*)bw)->descriptor(), ((Watch*)bw)->flags()
+ bw, ((Watch *)bw)->enabled() ? "on":"off", ((Watch *)bw)->descriptor(), ((Watch *)bw)->flags()
);
return bw;
}
-void BusDispatcher::rem_watch( Watch* w )
+void BusDispatcher::rem_watch(Watch *w)
{
debug_log("removed watch %p", w);
delete w;
}
-void BusDispatcher::timeout_expired( DefaultTimeout& et )
+void BusDispatcher::timeout_expired(DefaultTimeout &et)
{
debug_log("timeout %p expired", &et);
- BusTimeout* timeout = reinterpret_cast<BusTimeout*>(et.data());
+ BusTimeout *timeout = reinterpret_cast<BusTimeout *>(et.data());
timeout->handle();
}
-void BusDispatcher::watch_ready( DefaultWatch& ew )
+void BusDispatcher::watch_ready(DefaultWatch &ew)
{
- BusWatch* watch = reinterpret_cast<BusWatch*>(ew.data());
+ BusWatch *watch = reinterpret_cast<BusWatch *>(ew.data());
debug_log("watch %p ready, flags=%d state=%d",
- watch, ((Watch*)watch)->flags(), watch->state()
+ watch, ((Watch *)watch)->flags(), watch->state()
);
int flags = 0;
- if(watch->state() & POLLIN)
+ if (watch->state() & POLLIN)
flags |= DBUS_WATCH_READABLE;
- if(watch->state() & POLLOUT)
+ if (watch->state() & POLLOUT)
flags |= DBUS_WATCH_WRITABLE;
- if(watch->state() & POLLHUP)
+ if (watch->state() & POLLHUP)
flags |= DBUS_WATCH_HANGUP;
- if(watch->state() & POLLERR)
+ if (watch->state() & POLLERR)
flags |= DBUS_WATCH_ERROR;
watch->handle(flags);
diff --git a/src/eventloop.cpp b/src/eventloop.cpp
index 94cdee5..5112231 100644
--- a/src/eventloop.cpp
+++ b/src/eventloop.cpp
@@ -36,12 +36,12 @@
using namespace DBus;
-static double millis( timeval tv )
+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)
{
timeval now;
@@ -61,7 +61,7 @@ DefaultTimeout::~DefaultTimeout()
_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)
{
_disp->_mutex_w.lock();
@@ -125,7 +125,7 @@ DefaultMainLoop::~DefaultMainLoop()
_mutex_w.lock();
DefaultWatches::iterator wi = _watches.begin();
- while(wi != _watches.end())
+ while (wi != _watches.end())
{
DefaultWatches::iterator wmp = wi;
++wmp;
@@ -139,7 +139,7 @@ DefaultMainLoop::~DefaultMainLoop()
_mutex_t.lock();
DefaultTimeouts::iterator ti = _timeouts.begin();
- while(ti != _timeouts.end())
+ while (ti != _timeouts.end())
{
DefaultTimeouts::iterator tmp = ti;
++tmp;
@@ -161,9 +161,9 @@ void DefaultMainLoop::dispatch()
DefaultWatches::iterator wi = _watches.begin();
- for(nfd = 0; wi != _watches.end(); ++wi)
+ for (nfd = 0; wi != _watches.end(); ++wi)
{
- if((*wi)->enabled())
+ if ((*wi)->enabled())
{
fds[nfd].fd = (*wi)->descriptor();
fds[nfd].events = (*wi)->flags();
@@ -180,9 +180,9 @@ void DefaultMainLoop::dispatch()
_mutex_t.lock();
- for(ti = _timeouts.begin(); ti != _timeouts.end(); ++ti)
+ for (ti = _timeouts.begin(); ti != _timeouts.end(); ++ti)
{
- if((*ti)->enabled() && (*ti)->interval() < wait_min)
+ if ((*ti)->enabled() && (*ti)->interval() < wait_min)
wait_min = (*ti)->interval();
}
@@ -199,16 +199,16 @@ void DefaultMainLoop::dispatch()
ti = _timeouts.begin();
- while(ti != _timeouts.end())
+ while (ti != _timeouts.end())
{
DefaultTimeouts::iterator tmp = ti;
++tmp;
- if((*ti)->enabled() && now_millis >= (*ti)->_expiration)
+ if ((*ti)->enabled() && now_millis >= (*ti)->_expiration)
{
(*ti)->expired(*(*ti));
- if((*ti)->_repeat)
+ if ((*ti)->_repeat)
{
(*ti)->_expiration = now_millis + (*ti)->_interval;
}
@@ -222,18 +222,18 @@ void DefaultMainLoop::dispatch()
_mutex_w.lock();
- for(int j = 0; j < nfd; ++j)
+ for (int j = 0; j < nfd; ++j)
{
DefaultWatches::iterator wi;
- for(wi = _watches.begin(); wi != _watches.end();)
+ for (wi = _watches.begin(); wi != _watches.end();)
{
DefaultWatches::iterator tmp = wi;
++tmp;
- if((*wi)->enabled() && (*wi)->_fd == fds[j].fd)
+ if ((*wi)->enabled() && (*wi)->_fd == fds[j].fd)
{
- if(fds[j].revents)
+ if (fds[j].revents)
{
(*wi)->_state = fds[j].revents;
diff --git a/src/glib-integration.cpp b/src/glib-integration.cpp
index 840aa52..c82c77a 100644
--- a/src/glib-integration.cpp
+++ b/src/glib-integration.cpp
@@ -31,8 +31,8 @@
using namespace DBus;
-Glib::BusTimeout::BusTimeout( Timeout::Internal* ti, GMainContext* ctx )
-: Timeout(ti), _ctx(ctx)
+Glib::BusTimeout::BusTimeout(Timeout::Internal *ti, GMainContext *ctx, int priority)
+: Timeout(ti), _ctx(ctx), _priority(priority)
{
_enable();
}
@@ -46,13 +46,13 @@ void Glib::BusTimeout::toggle()
{
debug_log("glib: timeout %p toggled (%s)", this, Timeout::enabled() ? "on":"off");
- if(Timeout::enabled()) _enable();
+ if (Timeout::enabled()) _enable();
else _disable();
}
-gboolean Glib::BusTimeout::timeout_handler( gpointer data )
+gboolean Glib::BusTimeout::timeout_handler(gpointer data)
{
- Glib::BusTimeout* t = reinterpret_cast<Glib::BusTimeout*>(data);
+ Glib::BusTimeout *t = reinterpret_cast<Glib::BusTimeout *>(data);
t->handle();
@@ -62,6 +62,7 @@ gboolean Glib::BusTimeout::timeout_handler( gpointer data )
void Glib::BusTimeout::_enable()
{
_source = g_timeout_source_new(Timeout::interval());
+ g_source_set_priority(_source, _priority);
g_source_set_callback(_source, timeout_handler, this, NULL);
g_source_attach(_source, _ctx);
}
@@ -77,7 +78,7 @@ struct BusSource
GPollFD poll;
};
-static gboolean watch_prepare( GSource *source, gint *timeout )
+static gboolean watch_prepare(GSource *source, gint *timeout)
{
// debug_log("glib: watch_prepare");
@@ -85,15 +86,15 @@ static gboolean watch_prepare( GSource *source, gint *timeout )
return FALSE;
}
-static gboolean watch_check( GSource *source )
+static gboolean watch_check(GSource *source)
{
// debug_log("glib: watch_check");
- BusSource* io = (BusSource*)source;
+ BusSource *io = (BusSource *)source;
return io->poll.revents ? TRUE : FALSE;
}
-static gboolean watch_dispatch( GSource *source, GSourceFunc callback, gpointer data )
+static gboolean watch_dispatch(GSource *source, GSourceFunc callback, gpointer data)
{
debug_log("glib: watch_dispatch");
@@ -109,8 +110,8 @@ static GSourceFuncs watch_funcs = {
NULL
};
-Glib::BusWatch::BusWatch( Watch::Internal* wi, GMainContext* ctx )
-: Watch(wi), _ctx(ctx)
+Glib::BusWatch::BusWatch(Watch::Internal *wi, GMainContext *ctx, int priority)
+: Watch(wi), _ctx(ctx), _priority(priority)
{
_enable();
}
@@ -124,24 +125,24 @@ void Glib::BusWatch::toggle()
{
debug_log("glib: watch %p toggled (%s)", this, Watch::enabled() ? "on":"off");
- if(Watch::enabled()) _enable();
+ if (Watch::enabled()) _enable();
else _disable();
}
-gboolean Glib::BusWatch::watch_handler( gpointer data )
+gboolean Glib::BusWatch::watch_handler(gpointer data)
{
- Glib::BusWatch* w = reinterpret_cast<Glib::BusWatch*>(data);
+ Glib::BusWatch *w = reinterpret_cast<Glib::BusWatch *>(data);
- BusSource* io = (BusSource*)(w->_source);
+ BusSource *io = (BusSource *)(w->_source);
int flags = 0;
- if(io->poll.revents & G_IO_IN)
+ if (io->poll.revents &G_IO_IN)
flags |= DBUS_WATCH_READABLE;
- if(io->poll.revents & G_IO_OUT)
+ if (io->poll.revents &G_IO_OUT)
flags |= DBUS_WATCH_WRITABLE;
- if(io->poll.revents & G_IO_ERR)
+ if (io->poll.revents &G_IO_ERR)
flags |= DBUS_WATCH_ERROR;
- if(io->poll.revents & G_IO_HUP)
+ if (io->poll.revents &G_IO_HUP)
flags |= DBUS_WATCH_HANGUP;
w->handle(flags);
@@ -152,21 +153,22 @@ gboolean Glib::BusWatch::watch_handler( gpointer data )
void Glib::BusWatch::_enable()
{
_source = g_source_new(&watch_funcs, sizeof(BusSource));
+ g_source_set_priority(_source, _priority);
g_source_set_callback(_source, watch_handler, this, NULL);
int flags = Watch::flags();
int condition = 0;
- if(flags & DBUS_WATCH_READABLE)
+ if (flags &DBUS_WATCH_READABLE)
condition |= G_IO_IN;
-// if(flags & DBUS_WATCH_WRITABLE)
+// if (flags &DBUS_WATCH_WRITABLE)
// condition |= G_IO_OUT;
- if(flags & DBUS_WATCH_ERROR)
+ if (flags &DBUS_WATCH_ERROR)
condition |= G_IO_ERR;
- if(flags & DBUS_WATCH_HANGUP)
+ if (flags &DBUS_WATCH_HANGUP)
condition |= G_IO_HUP;
- GPollFD* poll = &(((BusSource*)_source)->poll);
+ GPollFD *poll = &(((BusSource *)_source)->poll);
poll->fd = Watch::descriptor();
poll->events = condition;
poll->revents = 0;
@@ -177,35 +179,35 @@ void Glib::BusWatch::_enable()
void Glib::BusWatch::_disable()
{
- GPollFD* poll = &(((BusSource*)_source)->poll);
+ GPollFD *poll = &(((BusSource *)_source)->poll);
g_source_remove_poll(_source, poll);
g_source_destroy(_source);
}
-void Glib::BusDispatcher::attach( GMainContext* ctx )
+void Glib::BusDispatcher::attach(GMainContext *ctx)
{
_ctx = ctx ? ctx : g_main_context_default();
}
-Timeout* Glib::BusDispatcher::add_timeout( Timeout::Internal* wi )
+Timeout *Glib::BusDispatcher::add_timeout(Timeout::Internal *wi)
{
- Timeout* t = new Glib::BusTimeout(wi, _ctx);
+ Timeout *t = new Glib::BusTimeout(wi, _ctx, _priority);
debug_log("glib: added timeout %p (%s)", t, t->enabled() ? "on":"off");
return t;
}
-void Glib::BusDispatcher::rem_timeout( Timeout* t )
+void Glib::BusDispatcher::rem_timeout(Timeout *t)
{
debug_log("glib: removed timeout %p", t);
delete t;
}
-Watch* Glib::BusDispatcher::add_watch( Watch::Internal* wi )
+Watch *Glib::BusDispatcher::add_watch(Watch::Internal *wi)
{
- Watch* w = new Glib::BusWatch(wi, _ctx);
+ Watch *w = new Glib::BusWatch(wi, _ctx, _priority);
debug_log("glib: added watch %p (%s) fd=%d flags=%d",
w, w->enabled() ? "on":"off", w->descriptor(), w->flags()
@@ -213,9 +215,14 @@ Watch* Glib::BusDispatcher::add_watch( Watch::Internal* wi )
return w;
}
-void Glib::BusDispatcher::rem_watch( Watch* w )
+void Glib::BusDispatcher::rem_watch(Watch *w)
{
debug_log("glib: removed watch %p", w);
delete w;
}
+
+void Glib::BusDispatcher::set_priority(int priority)
+{
+ _priority = priority;
+}
diff --git a/src/interface.cpp b/src/interface.cpp
index e765523..63bc443 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -33,21 +33,21 @@
using namespace DBus;
-Interface::Interface( const std::string& name )
+Interface::Interface(const std::string &name)
: _name(name)
{}
Interface::~Interface()
{}
-InterfaceAdaptor* AdaptorBase::find_interface( const std::string& name )
+InterfaceAdaptor *AdaptorBase::find_interface(const std::string &name)
{
InterfaceAdaptorTable::const_iterator ii = _interfaces.find(name);
return ii != _interfaces.end() ? ii->second : NULL;
}
-InterfaceAdaptor::InterfaceAdaptor( const std::string& name )
+InterfaceAdaptor::InterfaceAdaptor(const std::string &name)
: Interface(name)
{
debug_log("adding interface %s", name.c_str());
@@ -55,14 +55,14 @@ InterfaceAdaptor::InterfaceAdaptor( const std::string& name )
_interfaces[name] = this;
}
-Message InterfaceAdaptor::dispatch_method( const CallMessage& msg )
+Message InterfaceAdaptor::dispatch_method(const CallMessage &msg)
{
- const char* name = msg.member();
+ const char *name = msg.member();
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
{
@@ -70,21 +70,21 @@ Message InterfaceAdaptor::dispatch_method( const CallMessage& msg )
}
}
-void InterfaceAdaptor::emit_signal( const SignalMessage& sig )
+void InterfaceAdaptor::emit_signal(const SignalMessage &sig)
{
- SignalMessage& sig2 = const_cast<SignalMessage&>(sig);
+ SignalMessage &sig2 = const_cast<SignalMessage &>(sig);
- sig2.interface( name().c_str() );
+ sig2.interface(name().c_str());
_emit_signal(sig2);
}
-Variant* InterfaceAdaptor::get_property( const std::string& name )
+Variant *InterfaceAdaptor::get_property(const std::string &name)
{
PropertyTable::iterator pti = _properties.find(name);
- if( pti != _properties.end() )
+ if (pti != _properties.end())
{
- if( !pti->second.read )
+ if (!pti->second.read)
throw ErrorAccessDenied("property is not readable");
return &(pti->second.value);
@@ -92,18 +92,18 @@ Variant* InterfaceAdaptor::get_property( const std::string& name )
return NULL;
}
-void InterfaceAdaptor::set_property( const std::string& name, Variant& value )
+void InterfaceAdaptor::set_property(const std::string &name, Variant &value)
{
PropertyTable::iterator pti = _properties.find(name);
- if( pti != _properties.end() )
+ if (pti != _properties.end())
{
- if( !pti->second.write )
+ if (!pti->second.write)
throw ErrorAccessDenied("property is not writeable");
Signature sig = value.signature();
- if( pti->second.sig != sig )
+ if (pti->second.sig != sig)
throw ErrorInvalidSignature("property expects a different type");
pti->second.value = value;
@@ -112,14 +112,14 @@ void InterfaceAdaptor::set_property( const std::string& name, Variant& value )
throw ErrorFailed("requested property not found");
}
-InterfaceProxy* ProxyBase::find_interface( const std::string& name )
+InterfaceProxy *ProxyBase::find_interface(const std::string &name)
{
InterfaceProxyTable::const_iterator ii = _interfaces.find(name);
return ii != _interfaces.end() ? ii->second : NULL;
}
-InterfaceProxy::InterfaceProxy( const std::string& name )
+InterfaceProxy::InterfaceProxy(const std::string &name)
: Interface(name)
{
debug_log("adding interface %s", name.c_str());
@@ -127,14 +127,14 @@ InterfaceProxy::InterfaceProxy( const std::string& name )
_interfaces[name] = this;
}
-bool InterfaceProxy::dispatch_signal( const SignalMessage& msg )
+bool InterfaceProxy::dispatch_signal(const SignalMessage &msg)
{
- const char* name = msg.member();
+ const char *name = msg.member();
SignalTable::iterator si = _signals.find(name);
- if( si != _signals.end() )
+ if (si != _signals.end())
{
- si->second.call( msg );
+ si->second.call(msg);
// Here we always return false because there might be
// another InterfaceProxy listening for the same signal.
// This way we instruct libdbus-1 to go on dispatching
@@ -147,10 +147,10 @@ bool InterfaceProxy::dispatch_signal( const SignalMessage& msg )
}
}
-Message InterfaceProxy::invoke_method( const CallMessage& call )
+Message InterfaceProxy::invoke_method(const CallMessage &call)
{
- CallMessage& call2 = const_cast<CallMessage&>(call);
+ CallMessage &call2 = const_cast<CallMessage &>(call);
- call2.interface( name().c_str() );
+ call2.interface(name().c_str());
return _invoke_method(call2);
}
diff --git a/src/internalerror.h b/src/internalerror.h
index 7a6bbe0..9636c6b 100644
--- a/src/internalerror.h
+++ b/src/internalerror.h
@@ -45,16 +45,16 @@ struct DXXAPI InternalError
dbus_error_init(&error);
}
- explicit InternalError( DBusError* e )
+ explicit InternalError(DBusError *e)
{
dbus_error_init(&error);
dbus_move_error(e, &error);
}
- InternalError(const InternalError& ie)
+ InternalError(const InternalError &ie)
{
dbus_error_init(&error);
- dbus_move_error(const_cast<DBusError*>(&(ie.error)), &error);
+ dbus_move_error(const_cast<DBusError *>(&(ie.error)), &error);
}
~InternalError()
@@ -62,7 +62,7 @@ struct DXXAPI InternalError
dbus_error_free(&error);
}
- operator DBusError*()
+ operator DBusError *()
{
return &error;
}
diff --git a/src/introspection.cpp b/src/introspection.cpp
index 7137964..eb17218 100644
--- a/src/introspection.cpp
+++ b/src/introspection.cpp
@@ -36,7 +36,7 @@
using namespace DBus;
-static const char* introspectable_name = "org.freedesktop.DBus.Introspectable";
+static const char *introspectable_name = "org.freedesktop.DBus.Introspectable";
IntrospectableAdaptor::IntrospectableAdaptor()
: InterfaceAdaptor(introspectable_name)
@@ -44,7 +44,7 @@ IntrospectableAdaptor::IntrospectableAdaptor()
register_method(IntrospectableAdaptor, Introspect, Introspect);
}
-Message IntrospectableAdaptor::Introspect( const CallMessage& call )
+Message IntrospectableAdaptor::Introspect(const CallMessage &call)
{
debug_log("requested introspection data");
@@ -58,37 +58,37 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
InterfaceAdaptorTable::const_iterator iti;
- for(iti = _interfaces.begin(); iti != _interfaces.end(); ++iti)
+ for (iti = _interfaces.begin(); iti != _interfaces.end(); ++iti)
{
debug_log("introspecting interface %s", iti->first.c_str());
- IntrospectedInterface* const intro = iti->second->introspect();
- if(intro)
+ IntrospectedInterface *const intro = iti->second->introspect();
+ if (intro)
{
xml << "\n\t<interface name=\"" << intro->name << "\">";
- for(const IntrospectedProperty* p = intro->properties; p->name; ++p)
+ for (const IntrospectedProperty *p = intro->properties; p->name; ++p)
{
std::string access;
- if(p->read) access += "read";
- if(p->write) access += "write";
+ if (p->read) access += "read";
+ if (p->write) access += "write";
xml << "\n\t\t<property name=\"" << p->name << "\""
<< " type=\"" << p->type << "\""
<< " access=\"" << access << "\"/>";
}
- for(const IntrospectedMethod* m = intro->methods; m->args; ++m)
+ for (const IntrospectedMethod *m = intro->methods; m->args; ++m)
{
xml << "\n\t\t<method name=\"" << m->name << "\">";
- for(const IntrospectedArgument* a = m->args; a->type; ++a)
+ for (const IntrospectedArgument *a = m->args; a->type; ++a)
{
xml << "\n\t\t\t<arg direction=\"" << (a->in ? "in" : "out") << "\""
<< " type=\"" << a->type << "\"";
- if(a->name) xml << " name=\"" << a->name << "\"";
+ if (a->name) xml << " name=\"" << a->name << "\"";
xml << "/>";
}
@@ -96,15 +96,15 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
xml << "\n\t\t</method>";
}
- for(const IntrospectedMethod* m = intro->signals; m->args; ++m)
+ for (const IntrospectedMethod *m = intro->signals; m->args; ++m)
{
xml << "\n\t\t<signal name=\"" << m->name << "\">";
- for(const IntrospectedArgument* a = m->args; a->type; ++a)
+ for (const IntrospectedArgument *a = m->args; a->type; ++a)
{
xml << "<arg type=\"" << a->type << "\"";
- if(a->name) xml << " name=\"" << a->name << "\"";
+ if (a->name) xml << " name=\"" << a->name << "\"";
xml << "/>";
}
@@ -118,7 +118,7 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
const ObjectPathList nodes = ObjectAdaptor::child_nodes_from_prefix(path + '/');
ObjectPathList::const_iterator oni;
- for(oni = nodes.begin(); oni != nodes.end(); ++oni)
+ for (oni = nodes.begin(); oni != nodes.end(); ++oni)
{
xml << "\n\t<node name=\"" << (*oni) << "\"/>";
}
@@ -128,7 +128,7 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
ObjectAdaptorPList::const_iterator oci;
- for(oci = children.begin(); oci != children.end(); ++oci)
+ for (oci = children.begin(); oci != children.end(); ++oci)
{
std::string name = (*oci)->path().substr(path.length()+1);
name.substr(name.find('/'));
@@ -145,7 +145,7 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call )
return reply;
}
-IntrospectedInterface* const IntrospectableAdaptor::introspect() const
+IntrospectedInterface *const IntrospectableAdaptor::introspect() const
{
static IntrospectedArgument Introspect_args[] =
{
@@ -188,7 +188,7 @@ std::string IntrospectableProxy::Introspect()
DBus::Message ret = invoke_method(call);
DBus::MessageIter ri = ret.reader();
- const char* str = ri.get_string();
+ const char *str = ri.get_string();
return str;
}
diff --git a/src/message.cpp b/src/message.cpp
index 1c4fb9c..bf48405 100644
--- a/src/message.cpp
+++ b/src/message.cpp
@@ -41,7 +41,7 @@ using namespace DBus;
int MessageIter::type()
{
- return dbus_message_iter_get_arg_type((DBusMessageIter*)&_iter);
+ return dbus_message_iter_get_arg_type((DBusMessageIter *)&_iter);
}
bool MessageIter::at_end()
@@ -51,12 +51,12 @@ bool MessageIter::at_end()
bool MessageIter::has_next()
{
- return dbus_message_iter_has_next((DBusMessageIter*)&_iter);
+ return dbus_message_iter_has_next((DBusMessageIter *)&_iter);
}
-MessageIter& MessageIter::operator ++()
+MessageIter &MessageIter::operator ++()
{
- dbus_message_iter_next((DBusMessageIter*)&_iter);
+ dbus_message_iter_next((DBusMessageIter *)&_iter);
return (*this);
}
@@ -67,20 +67,20 @@ MessageIter MessageIter::operator ++(int)
return copy;
}
-bool MessageIter::append_basic( int type_id, void* value )
+bool MessageIter::append_basic(int type_id, void *value)
{
- return dbus_message_iter_append_basic((DBusMessageIter*)&_iter, type_id, value);
+ return dbus_message_iter_append_basic((DBusMessageIter *)&_iter, type_id, value);
}
-void MessageIter::get_basic( int type_id, void* ptr )
+void MessageIter::get_basic(int type_id, void *ptr)
{
- if(type() != type_id)
+ if (type() != type_id)
throw ErrorInvalidArgs("type mismatch");
- dbus_message_iter_get_basic((DBusMessageIter*)_iter, ptr);
+ dbus_message_iter_get_basic((DBusMessageIter *)_iter, ptr);
}
-bool MessageIter::append_byte( unsigned char b )
+bool MessageIter::append_byte(unsigned char b)
{
return append_basic(DBUS_TYPE_BYTE, &b);
}
@@ -92,7 +92,7 @@ unsigned char MessageIter::get_byte()
return b;
}
-bool MessageIter::append_bool( bool b )
+bool MessageIter::append_bool(bool b)
{
dbus_bool_t db = b;
return append_basic(DBUS_TYPE_BOOLEAN, &db);
@@ -105,7 +105,7 @@ bool MessageIter::get_bool()
return (bool)db;
}
-bool MessageIter::append_int16( signed short i )
+bool MessageIter::append_int16(signed short i)
{
return append_basic(DBUS_TYPE_INT16, &i);
}
@@ -117,7 +117,7 @@ signed short MessageIter::get_int16()
return i;
}
-bool MessageIter::append_uint16( unsigned short u )
+bool MessageIter::append_uint16(unsigned short u)
{
return append_basic(DBUS_TYPE_UINT16, &u);
}
@@ -129,7 +129,7 @@ unsigned short MessageIter::get_uint16()
return u;
}
-bool MessageIter::append_int32( signed int i )
+bool MessageIter::append_int32(signed int i)
{
return append_basic(DBUS_TYPE_INT32, &i);
}
@@ -141,7 +141,7 @@ signed int MessageIter::get_int32()
return i;
}
-bool MessageIter::append_uint32( unsigned int u )
+bool MessageIter::append_uint32(unsigned int u)
{
return append_basic(DBUS_TYPE_UINT32, &u);
}
@@ -160,7 +160,7 @@ signed long long MessageIter::get_int64()
return i;
}
-bool MessageIter::append_int64( signed long long i )
+bool MessageIter::append_int64(signed long long i)
{
return append_basic(DBUS_TYPE_INT64, &i);
}
@@ -172,7 +172,7 @@ unsigned long long MessageIter::get_uint64()
return u;
}
-bool MessageIter::append_uint64( unsigned long long u )
+bool MessageIter::append_uint64(unsigned long long u)
{
return append_basic(DBUS_TYPE_UINT64, &u);
}
@@ -184,43 +184,43 @@ double MessageIter::get_double()
return d;
}
-bool MessageIter::append_double( double d )
+bool MessageIter::append_double(double d)
{
return append_basic(DBUS_TYPE_DOUBLE, &d);
}
-bool MessageIter::append_string( const char* chars )
+bool MessageIter::append_string(const char *chars)
{
return append_basic(DBUS_TYPE_STRING, &chars);
}
-const char* MessageIter::get_string()
+const char *MessageIter::get_string()
{
- char* chars;
+ char *chars;
get_basic(DBUS_TYPE_STRING, &chars);
return chars;
}
-bool MessageIter::append_path( const char* chars )
+bool MessageIter::append_path(const char *chars)
{
return append_basic(DBUS_TYPE_OBJECT_PATH, &chars);
}
-const char* MessageIter::get_path()
+const char *MessageIter::get_path()
{
- char* chars;
+ char *chars;
get_basic(DBUS_TYPE_OBJECT_PATH, &chars);
return chars;
}
-bool MessageIter::append_signature( const char* chars )
+bool MessageIter::append_signature(const char *chars)
{
return append_basic(DBUS_TYPE_SIGNATURE, &chars);
}
-const char* MessageIter::get_signature()
+const char *MessageIter::get_signature()
{
- char* chars;
+ char *chars;
get_basic(DBUS_TYPE_SIGNATURE, &chars);
return chars;
}
@@ -228,56 +228,56 @@ const char* MessageIter::get_signature()
MessageIter MessageIter::recurse()
{
MessageIter iter(msg());
- dbus_message_iter_recurse((DBusMessageIter*)&_iter, (DBusMessageIter*)&(iter._iter));
+ dbus_message_iter_recurse((DBusMessageIter *)&_iter, (DBusMessageIter *)&(iter._iter));
return iter;
}
-char* MessageIter::signature() const
+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()
{
- return dbus_message_iter_get_element_type((DBusMessageIter*)&_iter);
+ return dbus_message_iter_get_element_type((DBusMessageIter *)&_iter);
}
-int MessageIter::get_array( void* ptr )
+int MessageIter::get_array(void *ptr)
{
int length;
- dbus_message_iter_get_fixed_array((DBusMessageIter*)&_iter, ptr, &length);
+ dbus_message_iter_get_fixed_array((DBusMessageIter *)&_iter, ptr, &length);
return length;
}
bool MessageIter::is_array()
{
- return dbus_message_iter_get_arg_type((DBusMessageIter*)&_iter) == DBUS_TYPE_ARRAY;
+ return dbus_message_iter_get_arg_type((DBusMessageIter *)&_iter) == DBUS_TYPE_ARRAY;
}
bool MessageIter::is_dict()
{
- return is_array() && dbus_message_iter_get_element_type((DBusMessageIter*)_iter) == DBUS_TYPE_DICT_ENTRY;
+ return is_array() && dbus_message_iter_get_element_type((DBusMessageIter *)_iter) == DBUS_TYPE_DICT_ENTRY;
}
-MessageIter MessageIter::new_array( const char* sig )
+MessageIter MessageIter::new_array(const char *sig)
{
MessageIter arr(msg());
dbus_message_iter_open_container(
- (DBusMessageIter*)&_iter, DBUS_TYPE_ARRAY, sig, (DBusMessageIter*)&(arr._iter)
+ (DBusMessageIter *)&_iter, DBUS_TYPE_ARRAY, sig, (DBusMessageIter *)&(arr._iter)
);
return arr;
}
-MessageIter MessageIter::new_variant( const char* sig )
+MessageIter MessageIter::new_variant(const char *sig)
{
MessageIter var(msg());
dbus_message_iter_open_container(
- (DBusMessageIter*)_iter, DBUS_TYPE_VARIANT, sig, (DBusMessageIter*)&(var._iter)
+ (DBusMessageIter *)_iter, DBUS_TYPE_VARIANT, sig, (DBusMessageIter *)&(var._iter)
);
return var;
}
@@ -286,7 +286,7 @@ MessageIter MessageIter::new_struct()
{
MessageIter stu(msg());
dbus_message_iter_open_container(
- (DBusMessageIter*)_iter, DBUS_TYPE_STRUCT, NULL, (DBusMessageIter*)&(stu._iter)
+ (DBusMessageIter *)_iter, DBUS_TYPE_STRUCT, NULL, (DBusMessageIter *)&(stu._iter)
);
return stu;
}
@@ -295,19 +295,19 @@ MessageIter MessageIter::new_dict_entry()
{
MessageIter ent(msg());
dbus_message_iter_open_container(
- (DBusMessageIter*)_iter, DBUS_TYPE_DICT_ENTRY, NULL, (DBusMessageIter*)&(ent._iter)
+ (DBusMessageIter *)_iter, DBUS_TYPE_DICT_ENTRY, NULL, (DBusMessageIter *)&(ent._iter)
);
return ent;
}
-void MessageIter::close_container( MessageIter& container )
+void MessageIter::close_container(MessageIter &container)
{
- dbus_message_iter_close_container((DBusMessageIter*)&_iter, (DBusMessageIter*)&(container._iter));
+ dbus_message_iter_close_container((DBusMessageIter *)&_iter, (DBusMessageIter *)&(container._iter));
}
static bool is_basic_type(int typecode)
{
- switch(typecode)
+ switch (typecode)
{
case 'y':
case 'b':
@@ -327,11 +327,11 @@ static bool is_basic_type(int typecode)
}
}
-void MessageIter::copy_data( MessageIter& to )
+void MessageIter::copy_data(MessageIter &to)
{
- for(MessageIter& from = *this; !from.at_end(); ++from)
+ for (MessageIter &from = *this; !from.at_end(); ++from)
{
- if(is_basic_type(from.type()))
+ if (is_basic_type(from.type()))
{
debug_log("copying basic type: %c", from.type());
@@ -342,17 +342,17 @@ void MessageIter::copy_data( MessageIter& to )
else
{
MessageIter from_container = from.recurse();
- char* sig = from_container.signature();
+ char *sig = from_container.signature();
debug_log("copying compound type: %c[%s]", from.type(), sig);
MessageIter to_container (to.msg());
dbus_message_iter_open_container
(
- (DBusMessageIter*)&(to._iter),
+ (DBusMessageIter *)&(to._iter),
from.type(),
from.type() == DBUS_TYPE_VARIANT ? NULL : sig,
- (DBusMessageIter*)&(to_container._iter)
+ (DBusMessageIter *)&(to_container._iter)
);
from_container.copy_data(to_container);
@@ -370,13 +370,13 @@ Message::Message()
{
}
-Message::Message( Message::Private* p, bool incref )
+Message::Message(Message::Private *p, bool incref)
: _pvt(p)
{
- if(_pvt->msg && incref) dbus_message_ref(_pvt->msg);
+ if (_pvt->msg && incref) dbus_message_ref(_pvt->msg);
}
-Message::Message( const Message& m )
+Message::Message(const Message &m)
: _pvt(m._pvt)
{
dbus_message_ref(_pvt->msg);
@@ -387,9 +387,9 @@ Message::~Message()
dbus_message_unref(_pvt->msg);
}
-Message& Message::operator = ( const Message& m )
+Message &Message::operator = (const Message &m)
{
- if(&m != this)
+ if (&m != this)
{
dbus_message_unref(_pvt->msg);
_pvt = m._pvt;
@@ -400,11 +400,11 @@ Message& Message::operator = ( const Message& m )
Message Message::copy()
{
- Private* pvt = new Private(dbus_message_copy(_pvt->msg));
+ Private *pvt = new Private(dbus_message_copy(_pvt->msg));
return Message(pvt);
}
-bool Message::append( int first_type, ... )
+bool Message::append(int first_type, ...)
{
va_list vl;
va_start(vl, first_type);
@@ -435,27 +435,27 @@ int Message::reply_serial() const
return dbus_message_get_reply_serial(_pvt->msg);
}
-bool Message::reply_serial( int s )
+bool Message::reply_serial(int s)
{
return dbus_message_set_reply_serial(_pvt->msg, s);
}
-const char* Message::sender() const
+const char *Message::sender() const
{
return dbus_message_get_sender(_pvt->msg);
}
-bool Message::sender( const char* s )
+bool Message::sender(const char *s)
{
return dbus_message_set_sender(_pvt->msg, s);
}
-const char* Message::destination() const
+const char *Message::destination() const
{
return dbus_message_get_destination(_pvt->msg);
}
-bool Message::destination( const char* s )
+bool Message::destination(const char *s)
{
return dbus_message_set_destination(_pvt->msg, s);
}
@@ -465,7 +465,7 @@ bool Message::is_error() const
return type() == DBUS_MESSAGE_TYPE_ERROR;
}
-bool Message::is_signal( const char* interface, const char* member ) const
+bool Message::is_signal(const char *interface, const char *member) const
{
return dbus_message_is_signal(_pvt->msg, interface, member);
}
@@ -473,14 +473,14 @@ bool Message::is_signal( const char* interface, const char* member ) const
MessageIter Message::writer()
{
MessageIter iter(*this);
- dbus_message_iter_init_append(_pvt->msg, (DBusMessageIter*)&(iter._iter));
+ dbus_message_iter_init_append(_pvt->msg, (DBusMessageIter *)&(iter._iter));
return iter;
}
MessageIter Message::reader() const
{
- MessageIter iter(const_cast<Message&>(*this));
- dbus_message_iter_init(_pvt->msg, (DBusMessageIter*)&(iter._iter));
+ MessageIter iter(const_cast<Message &>(*this));
+ dbus_message_iter_init(_pvt->msg, (DBusMessageIter *)&(iter._iter));
return iter;
}
@@ -492,22 +492,22 @@ ErrorMessage::ErrorMessage()
_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);
}
-bool ErrorMessage::operator == ( const ErrorMessage& m ) const
+bool ErrorMessage::operator == (const ErrorMessage &m) const
{
return dbus_message_is_error(_pvt->msg, m.name());
}
-const char* ErrorMessage::name() const
+const char *ErrorMessage::name() const
{
return dbus_message_get_error_name(_pvt->msg);
}
-bool ErrorMessage::name( const char* n )
+bool ErrorMessage::name(const char *n)
{
return dbus_message_set_error_name(_pvt->msg, n);
}
@@ -515,55 +515,55 @@ bool ErrorMessage::name( const char* n )
/*
*/
-SignalMessage::SignalMessage( const char* name )
+SignalMessage::SignalMessage(const char *name)
{
_pvt->msg = dbus_message_new(DBUS_MESSAGE_TYPE_SIGNAL);
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);
}
-bool SignalMessage::operator == ( const SignalMessage& m ) const
+bool SignalMessage::operator == (const SignalMessage &m) const
{
return dbus_message_is_signal(_pvt->msg, m.interface(), m.member());
}
-const char* SignalMessage::interface() const
+const char *SignalMessage::interface() const
{
return dbus_message_get_interface(_pvt->msg);
}
-bool SignalMessage::interface( const char* i )
+bool SignalMessage::interface(const char *i)
{
return dbus_message_set_interface(_pvt->msg, i);
}
-const char* SignalMessage::member() const
+const char *SignalMessage::member() const
{
return dbus_message_get_member(_pvt->msg);
}
-bool SignalMessage::member( const char* m )
+bool SignalMessage::member(const char *m)
{
return dbus_message_set_member(_pvt->msg, m);
}
-const char* SignalMessage::path() const
+const char *SignalMessage::path() const
{
return dbus_message_get_path(_pvt->msg);
}
-char** SignalMessage::path_split() const
+char ** SignalMessage::path_split() const
{
- char** p;
+ char ** p;
dbus_message_get_path_decomposed(_pvt->msg, &p); //todo: return as a std::vector ?
return p;
}
-bool SignalMessage::path( const char* p )
+bool SignalMessage::path(const char *p)
{
return dbus_message_set_path(_pvt->msg, p);
}
@@ -576,54 +576,54 @@ CallMessage::CallMessage()
_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);
}
-bool CallMessage::operator == ( const CallMessage& m ) const
+bool CallMessage::operator == (const CallMessage &m) const
{
return dbus_message_is_method_call(_pvt->msg, m.interface(), m.member());
}
-const char* CallMessage::interface() const
+const char *CallMessage::interface() const
{
return dbus_message_get_interface(_pvt->msg);
}
-bool CallMessage::interface( const char* i )
+bool CallMessage::interface(const char *i)
{
return dbus_message_set_interface(_pvt->msg, i);
}
-const char* CallMessage::member() const
+const char *CallMessage::member() const
{
return dbus_message_get_member(_pvt->msg);
}
-bool CallMessage::member( const char* m )
+bool CallMessage::member(const char *m)
{
return dbus_message_set_member(_pvt->msg, m);
}
-const char* CallMessage::path() const
+const char *CallMessage::path() const
{
return dbus_message_get_path(_pvt->msg);
}
-char** CallMessage::path_split() const
+char ** CallMessage::path_split() const
{
- char** p;
+ char ** p;
dbus_message_get_path_decomposed(_pvt->msg, &p);
return p;
}
-bool CallMessage::path( const char* p )
+bool CallMessage::path(const char *p)
{
return dbus_message_set_path(_pvt->msg, p);
}
-const char* CallMessage::signature() const
+const char *CallMessage::signature() const
{
return dbus_message_get_signature(_pvt->msg);
}
@@ -631,12 +631,12 @@ const char* CallMessage::signature() const
/*
*/
-ReturnMessage::ReturnMessage( const CallMessage& callee )
+ReturnMessage::ReturnMessage(const CallMessage &callee)
{
_pvt = new Private(dbus_message_new_method_return(callee._pvt->msg));
}
-const char* ReturnMessage::signature() const
+const char *ReturnMessage::signature() const
{
return dbus_message_get_signature(_pvt->msg);
}
diff --git a/src/message_p.h b/src/message_p.h
index 404847b..830e63d 100644
--- a/src/message_p.h
+++ b/src/message_p.h
@@ -39,12 +39,12 @@ namespace DBus {
struct DXXAPILOCAL Message::Private
{
- DBusMessage* msg;
+ DBusMessage *msg;
Private() : msg(0)
{}
- Private( DBusMessage* m ) : msg(m)
+ Private(DBusMessage *m) : msg(m)
{}
};
diff --git a/src/object.cpp b/src/object.cpp
index cf4be24..13b7052 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -40,8 +40,8 @@
using namespace DBus;
-Object::Object( Connection& conn, const Path& path, const char* service )
-: _conn(conn), _path(path), _service(service ? service : "")
+Object::Object(Connection &conn, const Path &path, const char *service)
+: _conn(conn), _path(path), _service(service ? service : "")
{
}
@@ -51,8 +51,8 @@ Object::~Object()
struct ObjectAdaptor::Private
{
- static void unregister_function_stub( DBusConnection*, void* );
- static DBusHandlerResult message_function_stub( DBusConnection*, DBusMessage*, void* );
+ static void unregister_function_stub(DBusConnection *, void *);
+ static DBusHandlerResult message_function_stub(DBusConnection *, DBusMessage *, void *);
};
static DBusObjectPathVTable _vtable =
@@ -62,16 +62,16 @@ static DBusObjectPathVTable _vtable =
NULL, NULL, NULL, NULL
};
-void ObjectAdaptor::Private::unregister_function_stub( DBusConnection* conn, void* data )
+void ObjectAdaptor::Private::unregister_function_stub(DBusConnection *conn, void *data)
{
//TODO: what do we have to do here ?
}
-DBusHandlerResult ObjectAdaptor::Private::message_function_stub( DBusConnection*, DBusMessage* dmsg, void* data )
+DBusHandlerResult ObjectAdaptor::Private::message_function_stub(DBusConnection *, DBusMessage *dmsg, void *data)
{
- ObjectAdaptor* o = static_cast<ObjectAdaptor*>(data);
+ ObjectAdaptor *o = static_cast<ObjectAdaptor *>(data);
- if( o )
+ if (o)
{
Message msg(new Message::Private(dmsg));
@@ -92,20 +92,20 @@ DBusHandlerResult ObjectAdaptor::Private::message_function_stub( DBusConnection*
}
}
-typedef std::map<Path, ObjectAdaptor*> ObjectAdaptorTable;
+typedef std::map<Path, ObjectAdaptor *> ObjectAdaptorTable;
static ObjectAdaptorTable _adaptor_table;
-ObjectAdaptor* ObjectAdaptor::from_path( const Path& path )
+ObjectAdaptor *ObjectAdaptor::from_path(const Path &path)
{
ObjectAdaptorTable::iterator ati = _adaptor_table.find(path);
- if(ati != _adaptor_table.end())
+ if (ati != _adaptor_table.end())
return ati->second;
return NULL;
}
-ObjectAdaptorPList ObjectAdaptor::from_path_prefix( const std::string& prefix )
+ObjectAdaptorPList ObjectAdaptor::from_path_prefix(const std::string &prefix)
{
ObjectAdaptorPList ali;
@@ -113,9 +113,9 @@ ObjectAdaptorPList ObjectAdaptor::from_path_prefix( const std::string& prefix )
size_t plen = prefix.length();
- while(ati != _adaptor_table.end())
+ while (ati != _adaptor_table.end())
{
- if(!strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
+ if (!strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
ali.push_back(ati->second);
++ati;
@@ -124,7 +124,7 @@ ObjectAdaptorPList ObjectAdaptor::from_path_prefix( const std::string& prefix )
return ali;
}
-ObjectPathList ObjectAdaptor::child_nodes_from_prefix( const std::string& prefix )
+ObjectPathList ObjectAdaptor::child_nodes_from_prefix(const std::string &prefix)
{
ObjectPathList ali;
@@ -132,9 +132,9 @@ ObjectPathList ObjectAdaptor::child_nodes_from_prefix( const std::string& prefix
size_t plen = prefix.length();
- while(ati != _adaptor_table.end())
+ while (ati != _adaptor_table.end())
{
- if(!strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
+ if (!strncmp(ati->second->path().c_str(), prefix.c_str(), plen))
{
std::string p = ati->second->path().substr(plen);
p = p.substr(0,p.find('/'));
@@ -149,8 +149,8 @@ ObjectPathList ObjectAdaptor::child_nodes_from_prefix( const std::string& prefix
return ali;
}
-ObjectAdaptor::ObjectAdaptor( Connection& conn, const Path& path )
-: Object(conn, path, conn.unique_name())
+ObjectAdaptor::ObjectAdaptor(Connection &conn, const Path &path)
+: Object(conn, path, conn.unique_name())
{
register_obj();
}
@@ -164,7 +164,7 @@ void ObjectAdaptor::register_obj()
{
debug_log("registering local object %s", path().c_str());
- if(!dbus_connection_register_object_path(conn()._pvt->conn, path().c_str(), &_vtable, this))
+ if (!dbus_connection_register_object_path(conn()._pvt->conn, path().c_str(), &_vtable, this))
{
throw ErrorNoMemory("unable to register object path");
}
@@ -181,7 +181,7 @@ void ObjectAdaptor::unregister_obj()
dbus_connection_unregister_object_path(conn()._pvt->conn, path().c_str());
}
-void ObjectAdaptor::_emit_signal( SignalMessage& sig )
+void ObjectAdaptor::_emit_signal(SignalMessage &sig)
{
sig.path(path().c_str());
@@ -190,35 +190,35 @@ void ObjectAdaptor::_emit_signal( SignalMessage& sig )
struct ReturnLaterError
{
- const Tag* tag;
+ const Tag *tag;
};
-bool ObjectAdaptor::handle_message( const Message& msg )
+bool ObjectAdaptor::handle_message(const Message &msg)
{
- switch( msg.type() )
+ switch (msg.type())
{
case DBUS_MESSAGE_TYPE_METHOD_CALL:
{
- const CallMessage& cmsg = reinterpret_cast<const CallMessage&>(msg);
- const char* member = cmsg.member();
- const char* interface = cmsg.interface();
+ const CallMessage &cmsg = reinterpret_cast<const CallMessage &>(msg);
+ const char *member = cmsg.member();
+ const char *interface = cmsg.interface();
debug_log(" invoking method %s.%s", interface, member);
- InterfaceAdaptor* ii = find_interface(interface);
- if( ii )
+ InterfaceAdaptor *ii = find_interface(interface);
+ if (ii)
{
try
{
Message ret = ii->dispatch_method(cmsg);
conn().send(ret);
}
- catch(Error& e)
+ catch(Error &e)
{
ErrorMessage em(cmsg, e.name(), e.message());
conn().send(em);
}
- catch(ReturnLaterError& rle)
+ catch(ReturnLaterError &rle)
{
_continuations[rle.tag] = new Continuation(conn(), cmsg, rle.tag);
}
@@ -236,13 +236,13 @@ bool ObjectAdaptor::handle_message( const Message& msg )
}
}
-void ObjectAdaptor::return_later( const Tag* tag )
+void ObjectAdaptor::return_later(const Tag *tag)
{
ReturnLaterError rle = { tag };
throw rle;
}
-void ObjectAdaptor::return_now( Continuation* ret )
+void ObjectAdaptor::return_now(Continuation *ret)
{
ret->_conn.send(ret->_return);
@@ -253,7 +253,7 @@ void ObjectAdaptor::return_now( Continuation* ret )
_continuations.erase(di);
}
-void ObjectAdaptor::return_error( Continuation* ret, const Error error )
+void ObjectAdaptor::return_error(Continuation *ret, const Error error)
{
ret->_conn.send(ErrorMessage(ret->_call, error.name(), error.message()));
@@ -264,14 +264,14 @@ void ObjectAdaptor::return_error( Continuation* ret, const Error error )
_continuations.erase(di);
}
-ObjectAdaptor::Continuation* ObjectAdaptor::find_continuation( const Tag* tag )
+ObjectAdaptor::Continuation *ObjectAdaptor::find_continuation(const Tag *tag)
{
ContinuationMap::iterator di = _continuations.find(tag);
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)
{
_writer = _return.writer(); //todo: verify
@@ -280,8 +280,8 @@ ObjectAdaptor::Continuation::Continuation( Connection& conn, const CallMessage&
/*
*/
-ObjectProxy::ObjectProxy( Connection& conn, const Path& path, const char* service )
-: Object(conn, path, service)
+ObjectProxy::ObjectProxy(Connection &conn, const Path &path, const char *service)
+: Object(conn, path, service)
{
register_obj();
}
@@ -295,12 +295,12 @@ void ObjectProxy::register_obj()
{
debug_log("registering remote object %s", path().c_str());
- _filtered = new Callback<ObjectProxy, bool, const Message&>(this, &ObjectProxy::handle_message);
+ _filtered = new Callback<ObjectProxy, bool, const Message &>(this, &ObjectProxy::handle_message);
conn().add_filter(_filtered);
InterfaceProxyTable::const_iterator ii = _interfaces.begin();
- while( ii != _interfaces.end() )
+ while (ii != _interfaces.end())
{
std::string im = "type='signal',interface='"+ii->first+"',path='"+path()+"'";
conn().add_match(im.c_str());
@@ -313,7 +313,7 @@ void ObjectProxy::unregister_obj()
debug_log("unregistering remote object %s", path().c_str());
InterfaceProxyTable::const_iterator ii = _interfaces.begin();
- while( ii != _interfaces.end() )
+ while (ii != _interfaces.end())
{
std::string im = "type='signal',interface='"+ii->first+"',path='"+path()+"'";
conn().remove_match(im.c_str());
@@ -322,7 +322,7 @@ void ObjectProxy::unregister_obj()
conn().remove_filter(_filtered);
}
-Message ObjectProxy::_invoke_method( CallMessage& call )
+Message ObjectProxy::_invoke_method(CallMessage &call)
{
call.path(path().c_str());
call.destination(service().c_str());
@@ -330,24 +330,24 @@ Message ObjectProxy::_invoke_method( CallMessage& call )
return conn().send_blocking(call);
}
-bool ObjectProxy::handle_message( const Message& msg )
+bool ObjectProxy::handle_message(const Message &msg)
{
- switch( msg.type() )
+ switch (msg.type())
{
case DBUS_MESSAGE_TYPE_SIGNAL:
{
- const SignalMessage& smsg = reinterpret_cast<const SignalMessage&>(msg);
- const char* interface = smsg.interface();
- const char* member = smsg.member();
- const char* objpath = smsg.path();
+ const SignalMessage &smsg = reinterpret_cast<const SignalMessage &>(msg);
+ const char *interface = smsg.interface();
+ const char *member = smsg.member();
+ const char *objpath = smsg.path();
- if( objpath != path() ) return false;
+ if (objpath != path()) return false;
debug_log("filtered signal %s(in %s) from %s to object %s",
member, interface, msg.sender(), objpath);
- InterfaceProxy* ii = find_interface(interface);
- if( ii )
+ InterfaceProxy *ii = find_interface(interface);
+ if (ii)
{
return ii->dispatch_signal(smsg);
}
diff --git a/src/pendingcall.cpp b/src/pendingcall.cpp
index 482bcfd..dd14dbd 100644
--- a/src/pendingcall.cpp
+++ b/src/pendingcall.cpp
@@ -36,10 +36,10 @@
using namespace DBus;
-PendingCall::Private::Private( DBusPendingCall* dpc )
+PendingCall::Private::Private(DBusPendingCall *dpc)
: call(dpc), dataslot(-1)
{
- if(!dbus_pending_call_allocate_data_slot(&dataslot))
+ if (!dbus_pending_call_allocate_data_slot(&dataslot))
{
throw ErrorNoMemory("Unable to allocate data slot");
}
@@ -47,30 +47,30 @@ PendingCall::Private::Private( DBusPendingCall* dpc )
PendingCall::Private::~Private()
{
- if(dataslot != -1)
+ if (dataslot != -1)
{
dbus_pending_call_allocate_data_slot(&dataslot);
}
}
-void PendingCall::Private::notify_stub( DBusPendingCall* dpc, 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);
PendingCall pc(pvt);
pvt->slot(pc);
}
-PendingCall::PendingCall( PendingCall::Private* p )
+PendingCall::PendingCall(PendingCall::Private *p)
: _pvt(p)
{
- if(!dbus_pending_call_set_notify(_pvt->call, Private::notify_stub, p, NULL))
+ if (!dbus_pending_call_set_notify(_pvt->call, Private::notify_stub, p, NULL))
{
throw ErrorNoMemory("Unable to initialize pending call");
}
}
-PendingCall::PendingCall( const PendingCall& c )
+PendingCall::PendingCall(const PendingCall &c)
: _pvt(c._pvt)
{
dbus_pending_call_ref(_pvt->call);
@@ -81,9 +81,9 @@ PendingCall::~PendingCall()
dbus_pending_call_unref(_pvt->call);
}
-PendingCall& PendingCall::operator = ( const PendingCall& c )
+PendingCall &PendingCall::operator = (const PendingCall &c)
{
- if(&c != this)
+ if (&c != this)
{
dbus_pending_call_unref(_pvt->call);
_pvt = c._pvt;
@@ -107,37 +107,37 @@ void PendingCall::block()
dbus_pending_call_block(_pvt->call);
}
-void PendingCall::data( void* p )
+void PendingCall::data(void *p)
{
- if(!dbus_pending_call_set_data(_pvt->call, _pvt->dataslot, p, NULL))
+ if (!dbus_pending_call_set_data(_pvt->call, _pvt->dataslot, p, NULL))
{
throw ErrorNoMemory("Unable to initialize data slot");
}
}
-void* PendingCall::data()
+void *PendingCall::data()
{
return dbus_pending_call_get_data(_pvt->call, _pvt->dataslot);
}
-Slot<void, PendingCall&>& PendingCall::slot()
+Slot<void, PendingCall &>& PendingCall::slot()
{
return _pvt->slot;
}
Message PendingCall::steal_reply()
{
- DBusMessage* dmsg = dbus_pending_call_steal_reply(_pvt->call);
- if(!dmsg)
+ DBusMessage *dmsg = dbus_pending_call_steal_reply(_pvt->call);
+ if (!dmsg)
{
dbus_bool_t callComplete = dbus_pending_call_get_completed(_pvt->call);
- if(callComplete)
+ if (callComplete)
throw ErrorNoReply("No reply available");
else
throw ErrorNoReply("Call not complete");
}
- return Message( new Message::Private(dmsg) );
+ return Message(new Message::Private(dmsg));
}
diff --git a/src/pendingcall_p.h b/src/pendingcall_p.h
index 90efdf1..dea4cbf 100644
--- a/src/pendingcall_p.h
+++ b/src/pendingcall_p.h
@@ -39,15 +39,15 @@ namespace DBus {
struct DXXAPILOCAL PendingCall::Private
{
- DBusPendingCall* call;
+ DBusPendingCall *call;
int dataslot;
- Slot<void, PendingCall&> slot;
+ Slot<void, PendingCall &> slot;
- Private( DBusPendingCall* );
+ Private(DBusPendingCall *);
~Private();
- static void notify_stub( DBusPendingCall* dpc, void* data );
+ static void notify_stub(DBusPendingCall *dpc, void *data);
};
} /* namespace DBus */
diff --git a/src/property.cpp b/src/property.cpp
index 6c17d44..69ba352 100644
--- a/src/property.cpp
+++ b/src/property.cpp
@@ -33,7 +33,7 @@
using namespace DBus;
-static const char* properties_name = "org.freedesktop.DBus.Properties";
+static const char *properties_name = "org.freedesktop.DBus.Properties";
PropertiesAdaptor::PropertiesAdaptor()
: InterfaceAdaptor(properties_name)
@@ -42,25 +42,25 @@ PropertiesAdaptor::PropertiesAdaptor()
register_method(PropertiesAdaptor, Set, Set);
}
-Message PropertiesAdaptor::Get( const CallMessage& call )
+Message PropertiesAdaptor::Get(const CallMessage &call)
{
MessageIter ri = call.reader();
- String iface_name;
- String property_name;
+ std::string iface_name;
+ std::string property_name;
ri >> iface_name >> property_name;
debug_log("requesting property %s on interface %s", property_name.c_str(), iface_name.c_str());
- InterfaceAdaptor* interface = (InterfaceAdaptor*) find_interface(iface_name);
+ InterfaceAdaptor *interface = (InterfaceAdaptor *) find_interface(iface_name);
- if(!interface)
+ if (!interface)
throw ErrorFailed("requested interface not found");
- Variant* value = interface->get_property(property_name);
+ Variant *value = interface->get_property(property_name);
- if(!value)
+ if (!value)
throw ErrorFailed("requested property not found");
on_get_property(*interface, property_name, *value);
@@ -73,19 +73,19 @@ Message PropertiesAdaptor::Get( const CallMessage& call )
return reply;
}
-Message PropertiesAdaptor::Set( const CallMessage& call )
+Message PropertiesAdaptor::Set(const CallMessage &call)
{
MessageIter ri = call.reader();
- String iface_name;
- String property_name;
+ std::string iface_name;
+ std::string property_name;
Variant value;
ri >> iface_name >> property_name >> value;
- InterfaceAdaptor* interface = (InterfaceAdaptor*) find_interface(iface_name);
+ InterfaceAdaptor *interface = (InterfaceAdaptor *) find_interface(iface_name);
- if(!interface)
+ if (!interface)
throw ErrorFailed("requested interface not found");
on_set_property(*interface, property_name, value);
@@ -97,7 +97,7 @@ Message PropertiesAdaptor::Set( const CallMessage& call )
return reply;
}
-IntrospectedInterface* const PropertiesAdaptor::introspect() const
+IntrospectedInterface *const PropertiesAdaptor::introspect() const
{
static IntrospectedArgument Get_args[] =
{
@@ -142,14 +142,14 @@ PropertiesProxy::PropertiesProxy()
{
}
-Variant PropertiesProxy::Get( const String& iface, const String& property )
+Variant PropertiesProxy::Get(const std::string &iface, const std::string &property)
{
//todo
Variant v;
return v;
}
-void PropertiesProxy::Set( const String& iface, const String& property, const Variant& value )
+void PropertiesProxy::Set(const std::string &iface, const std::string &property, const Variant &value)
{
//todo
}
diff --git a/src/server.cpp b/src/server.cpp
index 1882d70..2493b74 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -36,7 +36,7 @@
using namespace DBus;
-Server::Private::Private( DBusServer* s )
+Server::Private::Private(DBusServer *s)
: server(s)
{
}
@@ -45,9 +45,9 @@ Server::Private::~Private()
{
}
-void Server::Private::on_new_conn_cb( DBusServer* server, 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);
Connection nc (new Connection::Private(conn, s->_pvt.get()));
@@ -58,12 +58,12 @@ void Server::Private::on_new_conn_cb( DBusServer* server, DBusConnection* conn,
debug_log("incoming connection 0x%08x", conn);
}
-Server::Server( const char* address )
+Server::Server(const char *address)
{
InternalError e;
- DBusServer* server = dbus_server_listen(address, e);
+ DBusServer *server = dbus_server_listen(address, e);
- if(e) throw Error(e);
+ if (e) throw Error(e);
debug_log("server 0x%08x listening on %s", server, address);
@@ -74,7 +74,7 @@ Server::Server( const char* address )
setup(default_dispatcher);
}
/*
-Server::Server( const Server& s )
+Server::Server(const Server &s)
: _pvt(s._pvt)
{
dbus_server_ref(_pvt->server);
@@ -85,11 +85,11 @@ Server::~Server()
dbus_server_unref(_pvt->server);
}
-Dispatcher* Server::setup( Dispatcher* dispatcher )
+Dispatcher *Server::setup(Dispatcher *dispatcher)
{
debug_log("registering stubs for server %p", _pvt->server);
- Dispatcher* prev = _pvt->dispatcher;
+ Dispatcher *prev = _pvt->dispatcher;
dbus_server_set_watch_functions(
_pvt->server,
@@ -114,7 +114,7 @@ Dispatcher* Server::setup( Dispatcher* dispatcher )
return prev;
}
-bool Server::operator == ( const Server& s ) const
+bool Server::operator == (const Server &s) const
{
return _pvt->server == s._pvt->server;
}
diff --git a/src/server_p.h b/src/server_p.h
index 8c83750..b510712 100644
--- a/src/server_p.h
+++ b/src/server_p.h
@@ -40,17 +40,17 @@ namespace DBus {
struct DXXAPILOCAL Server::Private
{
- DBusServer* server;
+ DBusServer *server;
- Dispatcher* dispatcher;
+ Dispatcher *dispatcher;
ConnectionList connections;
- Private( DBusServer* );
+ Private(DBusServer *);
~Private();
- static void on_new_conn_cb( DBusServer* server, DBusConnection* conn, void* data );
+ static void on_new_conn_cb(DBusServer *server, DBusConnection *conn, void *data);
};
} /* namespace DBus */
diff --git a/src/types.cpp b/src/types.cpp
index b2c3543..f902b61 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -42,7 +42,7 @@ Variant::Variant()
{
}
-Variant::Variant( MessageIter& it )
+Variant::Variant(MessageIter &it)
: _msg(CallMessage())
{
MessageIter vi = it.recurse();
@@ -50,9 +50,9 @@ Variant::Variant( MessageIter& it )
vi.copy_data(mi);
}
-Variant& Variant::operator = ( const Variant& v )
+Variant &Variant::operator = (const Variant &v)
{
- if(&v != this)
+ if (&v != this)
{
_msg = v._msg;
}
@@ -67,7 +67,7 @@ void Variant::clear()
const Signature Variant::signature() const
{
- char* sigbuf = reader().signature();
+ char *sigbuf = reader().signature();
Signature signature = sigbuf;
@@ -76,7 +76,7 @@ const Signature Variant::signature() const
return signature;
}
-MessageIter& operator << ( MessageIter& iter, const Variant& val )
+MessageIter &operator << (MessageIter &iter, const Variant &val)
{
const Signature sig = val.signature();
@@ -90,9 +90,9 @@ MessageIter& operator << ( MessageIter& iter, const Variant& val )
return iter;
}
-MessageIter& operator >> ( MessageIter& iter, Variant& val )
+MessageIter &operator >> (MessageIter &iter, Variant &val)
{
- if(iter.type() != DBUS_TYPE_VARIANT)
+ if (iter.type() != DBUS_TYPE_VARIANT)
throw ErrorInvalidArgs("variant type expected");
val.clear();