Commit c3023d51 authored by Emmanuel Milou's avatar Emmanuel Milou

[#2403] make indent

parent 76fa379a
......@@ -42,13 +42,11 @@
using namespace DBus;
Connection::Private::Private (DBusConnection *c, Server::Private *s)
: conn (c) , dispatcher (0), server (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);
......@@ -58,8 +56,7 @@ Connection::Private::Private (DBusBusType type)
init();
}
Connection::Private::~Private()
{
Connection::Private::~Private() {
debug_log ("terminating connection 0x%08x", conn);
detach_server();
......@@ -79,8 +76,7 @@ Connection::Private::~Private()
dbus_connection_unref (conn);
}
void Connection::Private::init()
{
void Connection::Private::init() {
dbus_connection_ref (conn);
dbus_connection_ref (conn); //todo: the library has to own another reference
......@@ -94,8 +90,7 @@ void Connection::Private::init()
dbus_connection_set_exit_on_disconnect (conn, false); //why was this set to true??
}
void Connection::Private::detach_server()
{
void Connection::Private::detach_server() {
/* Server::Private *tmp = server;
server = NULL;
......@@ -115,8 +110,7 @@ void Connection::Private::detach_server()
}*/
}
bool Connection::Private::do_dispatch()
{
bool Connection::Private::do_dispatch() {
debug_log ("dispatching on %p", conn);
if (!dbus_connection_get_is_connected (conn)) {
......@@ -130,8 +124,7 @@ 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);
switch (status) {
......@@ -151,8 +144,7 @@ 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);
Message msg = Message (new Message::Private (dmsg));
......@@ -162,8 +154,7 @@ 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")) {
debug_log ("%p disconnected by local bus", conn);
dbus_connection_close (conn);
......@@ -174,34 +165,28 @@ bool Connection::Private::disconn_filter_function (const Message &msg)
return false;
}
DBusDispatchStatus Connection::Private::dispatch_status()
{
DBusDispatchStatus Connection::Private::dispatch_status() {
return dbus_connection_get_dispatch_status (conn);
}
bool Connection::Private::has_something_to_dispatch()
{
bool Connection::Private::has_something_to_dispatch() {
return dispatch_status() == DBUS_DISPATCH_DATA_REMAINS;
}
Connection Connection::SystemBus()
{
Connection Connection::SystemBus() {
return Connection (new Private (DBUS_BUS_SYSTEM));
}
Connection Connection::SessionBus()
{
Connection Connection::SessionBus() {
return Connection (new Private (DBUS_BUS_SESSION));
}
Connection Connection::ActivationBus()
{
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
? dbus_connection_open_private (address, e)
......@@ -217,24 +202,20 @@ Connection::Connection (const char *address, bool priv)
}
Connection::Connection (Connection::Private *p)
: _pvt (p)
{
: _pvt (p) {
setup (default_dispatcher);
}
Connection::Connection (const Connection &c)
: _pvt (c._pvt)
{
: _pvt (c._pvt) {
dbus_connection_ref (_pvt->conn);
}
Connection::~Connection()
{
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;
......@@ -268,13 +249,11 @@ 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;
}
bool Connection::register_bus()
{
bool Connection::register_bus() {
InternalError e;
bool r = dbus_bus_register (_pvt->conn, e);
......@@ -284,39 +263,32 @@ bool Connection::register_bus()
return r;
}
bool Connection::connected() const
{
bool Connection::connected() const {
return dbus_connection_get_is_connected (_pvt->conn);
}
void Connection::disconnect()
{
void Connection::disconnect() {
// dbus_connection_disconnect(_pvt->conn); // disappeared in 0.9x
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);
}
void Connection::flush()
{
void Connection::flush() {
dbus_connection_flush (_pvt->conn);
}
void Connection::add_match (const char *rule)
{
void Connection::add_match (const char *rule) {
InternalError e;
dbus_bus_add_match (_pvt->conn, rule, e);
......@@ -326,8 +298,7 @@ void Connection::add_match (const char *rule)
if (e) throw Error (e);
}
void Connection::remove_match (const char *rule)
{
void Connection::remove_match (const char *rule) {
InternalError e;
dbus_bus_remove_match (_pvt->conn, rule, e);
......@@ -337,25 +308,21 @@ void Connection::remove_match (const char *rule)
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;
InternalError e;
......@@ -366,8 +333,7 @@ Message Connection::send_blocking (Message &msg, int timeout)
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;
if (!dbus_connection_send_with_reply (_pvt->conn, msg._pvt->msg, &pending, timeout)) {
......@@ -377,8 +343,7 @@ PendingCall Connection::send_async (Message &msg, int timeout)
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;
debug_log ("%s: registering bus name %s", unique_name(), name);
......@@ -396,8 +361,7 @@ void Connection::request_name (const char *name, int flags)
}
}
unsigned long Connection::sender_unix_uid (const char *sender)
{
unsigned long Connection::sender_unix_uid (const char *sender) {
InternalError e;
unsigned long ul = dbus_bus_get_unix_user (_pvt->conn, sender, e);
......@@ -407,8 +371,7 @@ unsigned long Connection::sender_unix_uid (const char *sender)
return ul;
}
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);
......@@ -418,13 +381,11 @@ bool Connection::has_name (const char *name)
return b;
}
const std::vector<std::string>& Connection::names()
{
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);
......
......@@ -31,8 +31,7 @@
#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;
......
......@@ -38,23 +38,19 @@ DBus::Dispatcher *DBus::default_dispatcher = NULL;
using namespace DBus;
Timeout::Timeout (Timeout::Internal *i)
: _int (i)
{
: _int (i) {
dbus_timeout_set_data ( (DBusTimeout *) i, this, NULL);
}
int Timeout::interval() const
{
int Timeout::interval() const {
return dbus_timeout_get_interval ( (DBusTimeout *) _int);
}
bool Timeout::enabled() const
{
bool Timeout::enabled() const {
return dbus_timeout_get_enabled ( (DBusTimeout *) _int);
}
bool Timeout::handle()
{
bool Timeout::handle() {
return dbus_timeout_handle ( (DBusTimeout *) _int);
}
......@@ -62,13 +58,11 @@ bool Timeout::handle()
*/
Watch::Watch (Watch::Internal *i)
: _int (i)
{
: _int (i) {
dbus_watch_set_data ( (DBusWatch *) i, this, NULL);
}
int Watch::descriptor() const
{
int Watch::descriptor() const {
#if HAVE_WIN32
return dbus_watch_get_socket ( (DBusWatch*) _int);
#else
......@@ -76,26 +70,22 @@ int Watch::descriptor() const
#endif
}
int Watch::flags() const
{
int Watch::flags() const {
return dbus_watch_get_flags ( (DBusWatch *) _int);
}
bool Watch::enabled() const
{
bool Watch::enabled() const {
return dbus_watch_get_enabled ( (DBusWatch *) _int);
}
bool Watch::handle (int flags)
{
bool Watch::handle (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);
Watch::Internal *w = reinterpret_cast<Watch::Internal *> (watch);
......@@ -105,8 +95,7 @@ dbus_bool_t Dispatcher::Private::on_add_watch (DBusWatch *watch, void *data)
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);
Watch *w = static_cast<Watch *> (dbus_watch_get_data (watch));
......@@ -114,15 +103,13 @@ void Dispatcher::Private::on_rem_watch (DBusWatch *watch, void *data)
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));
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);
Timeout::Internal *t = reinterpret_cast<Timeout::Internal *> (timeout);
......@@ -132,8 +119,7 @@ dbus_bool_t Dispatcher::Private::on_add_timeout (DBusTimeout *timeout, void *dat
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);
Timeout *t = static_cast<Timeout *> (dbus_timeout_get_data (timeout));
......@@ -141,23 +127,20 @@ void Dispatcher::Private::on_rem_timeout (DBusTimeout *timeout, void *data)
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));
t->toggle();
}
void Dispatcher::queue_connection (Connection::Private *cp)
{
void Dispatcher::queue_connection (Connection::Private *cp) {
_mutex_p.lock();
_pending_queue.push_back (cp);
_mutex_p.unlock();
}
bool Dispatcher::has_something_to_dispatch()
{
bool Dispatcher::has_something_to_dispatch() {
_mutex_p.lock();
bool has_something = false;
......@@ -173,8 +156,7 @@ bool Dispatcher::has_something_to_dispatch()
}
void Dispatcher::dispatch_pending()
{
void Dispatcher::dispatch_pending() {
_mutex_p.lock();
// SEEME: dbus-glib is dispatching only one message at a time to not starve the loop/other things...
......@@ -199,8 +181,7 @@ void Dispatcher::dispatch_pending()
_mutex_p.unlock();
}
void DBus::_init_threading()
{
void DBus::_init_threading() {
#ifdef DBUS_HAS_THREADS_INIT_DEFAULT
dbus_threads_init_default();
#else
......@@ -219,8 +200,7 @@ void DBus::_init_threading (
CondVarWaitTimeoutFn c4,
CondVarWakeOneFn c5,
CondVarWakeAllFn c6
)
{
) {
#ifndef DBUS_HAS_RECURSIVE_MUTEX
DBusThreadFunctions functions = {
DBUS_THREAD_FUNCTIONS_MUTEX_NEW_MASK |
......
......@@ -32,26 +32,22 @@
using namespace DBus;
Ecore::BusTimeout::BusTimeout (Timeout::Internal* ti)
: Timeout (ti)
{
: Timeout (ti) {
_enable();
}
Ecore::BusTimeout::~BusTimeout()
{
Ecore::BusTimeout::~BusTimeout() {
_disable();
}
void Ecore::BusTimeout::toggle()
{
void Ecore::BusTimeout::toggle() {
debug_log ("ecore: timeout %p toggled (%s)", this, Timeout::enabled() ? "on":"off");
if (Timeout::enabled()) _enable();
else _disable();
}
int Ecore::BusTimeout::timeout_handler (void *data)
{
int Ecore::BusTimeout::timeout_handler (void *data) {
Ecore::BusTimeout* t = reinterpret_cast<Ecore::BusTimeout*> (data);
debug_log ("Ecore::BusTimeout::timeout_handler( void *data )");
......@@ -61,37 +57,32 @@ int Ecore::BusTimeout::timeout_handler (void *data)
return 1; // 1 -> reshedule in ecore for next timer interval
}
void Ecore::BusTimeout::_enable()
{
void Ecore::BusTimeout::_enable() {
debug_log ("Ecore::BusTimeout::_enable()");
_etimer = ecore_timer_add ( ( (double) Timeout::interval()) /1000, timeout_handler, this);
}
void Ecore::BusTimeout::_disable()
{
void Ecore::BusTimeout::_disable() {
debug_log ("Ecore::BusTimeout::_disable()");
ecore_timer_del (_etimer);
}
static bool watch_prepare (int *timeout)
{
static bool watch_prepare (int *timeout) {
debug_log ("ecore: watch_prepare");
*timeout = -1;
return false;
}
static bool watch_check()
{
static bool watch_check() {
debug_log ("ecore: watch_check");
return true;
}
static bool watch_dispatch (void *data)
{
static bool watch_dispatch (void *data) {
debug_log ("ecore: watch_dispatch");
bool cb = true;
......@@ -100,26 +91,22 @@ static bool watch_dispatch (void *data)
}
Ecore::BusWatch::BusWatch (Watch::Internal* wi)
: Watch (wi)
{
: Watch (wi) {
_enable();
}
Ecore::BusWatch::~BusWatch()
{
Ecore::BusWatch::~BusWatch() {
_disable();
}
void Ecore::BusWatch::toggle()
{
void Ecore::BusWatch::toggle() {
debug_log ("ecore: watch %p toggled (%s)", this, Watch::enabled() ? "on":"off");
if (Watch::enabled()) _enable();
else _disable();
}
int Ecore::BusWatch::watch_handler_read (void *data, Ecore_Fd_Handler *fdh)
{
int Ecore::BusWatch::watch_handler_read (void *data, Ecore_Fd_Handler *fdh) {
Ecore::BusWatch* w = reinterpret_cast<Ecore::BusWatch*> (data);
debug_log ("ecore: watch_handler_read");
......@@ -133,8 +120,7 @@ int Ecore::BusWatch::watch_handler_read (void *data, Ecore_Fd_Handler *fdh)
return 1;
}
int Ecore::BusWatch::watch_handler_error (void *data, Ecore_Fd_Handler *fdh)
{
int Ecore::BusWatch::watch_handler_error (void *data, Ecore_Fd_Handler *fdh) {
Ecore::BusWatch* w = reinterpret_cast<Ecore::BusWatch*> (data);
debug_log ("ecore: watch_handler_error");
......@@ -146,8 +132,7 @@ int Ecore::BusWatch::watch_handler_error (void *data, Ecore_Fd_Handler *fdh)
return 1;
}
void Ecore::BusWatch::_enable()
{
void Ecore::BusWatch::_enable() {
debug_log ("Ecore::BusWatch::_enable()");
int flags = Watch::flags();
......@@ -169,18 +154,15 @@ void Ecore::BusWatch::_enable()
ecore_main_fd_handler_active_set (fd_handler_error, ECORE_FD_ERROR);
}
void Ecore::BusWatch::_disable()
{
void Ecore::BusWatch::_disable() {
ecore_main_fd_handler_del (fd_handler_read);
ecore_main_fd_handler_del (fd_handler_error);
}
void Ecore::BusDispatcher::attach()
{
void Ecore::BusDispatcher::attach() {
}
Timeout* Ecore::BusDispatcher::add_timeout (Timeout::Internal* wi)
{
Timeout* Ecore::BusDispatcher::add_timeout (Timeout::Internal* wi) {
Timeout* t = new Ecore::BusTimeout (wi);
debug_log ("ecore: added timeout %p (%s)", t, t->enabled() ? "on":"off");
......@@ -188,15 +170,13 @@ Timeout* Ecore::BusDispatcher::add_timeout (Timeout::Internal* wi)
return t;
}
void Ecore::BusDispatcher::rem_timeout (Timeout* t)
{
void Ecore::BusDispatcher::rem_timeout (Timeout* t) {
debug_log ("ecore: removed timeout %p", t);
delete t;
}
Watch* Ecore::BusDispatcher::add_watch (Watch::Internal* wi)
{
Watch* Ecore::BusDispatcher::add_watch (Watch::Internal* wi) {
Watch* w = new Ecore::BusWatch (wi);
debug_log ("ecore: added watch %p (%s) fd=%d flags=%d",
......@@ -205,8 +185,7 @@ Watch* Ecore::BusDispatcher::add_watch (Watch::Internal* wi)
return w;
}
void Ecore::BusDispatcher::rem_watch (Watch* w)
{
void Ecore::BusDispatcher::rem_watch (Watch* w) {
debug_log ("ecore: removed watch %p", w);
delete w;
......
......@@ -39,51 +39,41 @@ using namespace DBus;
*/
Error::Error()
: _int (new InternalError)
{}
: _int (new InternalError) {}
Error::Error (InternalError &i)
: _int (new InternalError (i))
{}
: _int (new InternalError (i)) {}
Error::Error (const char *name, const char *message)
: _int (new InternalError)