Time to get rid of the horrible coding style
This commit is contained in:
parent
534ee610d8
commit
efc594f888
53 changed files with 1137 additions and 1136 deletions
|
@ -38,19 +38,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();
|
||||
}
|
||||
|
@ -61,11 +61,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);
|
||||
|
@ -81,7 +81,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
|
||||
);
|
||||
|
||||
|
@ -93,17 +93,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;
|
||||
|
@ -116,7 +116,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");
|
||||
|
||||
|
@ -128,11 +128,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);
|
||||
|
@ -149,9 +149,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));
|
||||
|
||||
|
@ -160,9 +160,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);
|
||||
|
@ -187,14 +187,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);
|
||||
|
||||
|
@ -203,13 +203,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);
|
||||
|
@ -220,15 +220,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;
|
||||
|
||||
|
@ -255,7 +255,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;
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ bool Connection::register_bus()
|
|||
|
||||
bool r = dbus_bus_register(_pvt->conn, e);
|
||||
|
||||
if(e) throw (e);
|
||||
if (e) throw (e);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -282,17 +282,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);
|
||||
}
|
||||
|
@ -302,7 +302,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;
|
||||
|
||||
|
@ -310,10 +310,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;
|
||||
|
||||
|
@ -321,50 +321,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;
|
||||
|
||||
|
@ -372,11 +372,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() + "'";
|
||||
|
@ -384,13 +384,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;
|
||||
}
|
||||
|
@ -400,13 +400,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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue