From 534ee610d8e16f26c5fca5224fc080b9211dd75b Mon Sep 17 00:00:00 2001 From: pd Date: Fri, 1 Aug 2008 18:24:09 +0200 Subject: [PATCH 1/3] Allow changing the priority of a GMainContext (Eric Jonas) --- include/dbus-c++/glib-integration.h | 12 +++++++++--- src/glib-integration.cpp | 19 +++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/dbus-c++/glib-integration.h b/include/dbus-c++/glib-integration.h index a60e3f8..e76dfbd 100644 --- a/include/dbus-c++/glib-integration.h +++ b/include/dbus-c++/glib-integration.h @@ -44,7 +44,7 @@ class DXXAPI BusTimeout : public Timeout { private: - BusTimeout( Timeout::Internal*, GMainContext* ); + BusTimeout( Timeout::Internal*, GMainContext*, int ); ~BusTimeout(); @@ -60,6 +60,7 @@ private: GSource* _source; GMainContext* _ctx; + int _priority; friend class BusDispatcher; }; @@ -68,7 +69,7 @@ class DXXAPI BusWatch : public Watch { private: - BusWatch( Watch::Internal*, GMainContext* ); + BusWatch( Watch::Internal*, GMainContext*, int ); ~BusWatch(); @@ -84,6 +85,7 @@ private: GSource* _source; GMainContext* _ctx; + int _priority; friend class BusDispatcher; }; @@ -91,7 +93,8 @@ friend class BusDispatcher; class DXXAPI BusDispatcher : public Dispatcher { public: - BusDispatcher() : _ctx(NULL) {} + + BusDispatcher() : _ctx(NULL), _priority(G_PRIORITY_DEFAULT) {} void attach( GMainContext* ); @@ -107,9 +110,12 @@ public: void rem_watch( Watch* ); + void set_priority( int priority ); + private: GMainContext* _ctx; + int _priority; }; } /* namespace Glib */ diff --git a/src/glib-integration.cpp b/src/glib-integration.cpp index 42c31ea..5583995 100644 --- a/src/glib-integration.cpp +++ b/src/glib-integration.cpp @@ -28,8 +28,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(); } @@ -59,6 +59,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); } @@ -106,8 +107,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(); } @@ -149,6 +150,7 @@ 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(); @@ -186,7 +188,7 @@ void Glib::BusDispatcher::attach( GMainContext* ctx ) 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"); @@ -202,7 +204,7 @@ void Glib::BusDispatcher::rem_timeout( Timeout* t ) 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() @@ -216,3 +218,8 @@ void Glib::BusDispatcher::rem_watch( Watch* w ) delete w; } + +void Glib::BusDispatcher::set_priority(int priority) +{ + _priority = priority; +} From efc594f888a993338fa26366a30e09763d28fca1 Mon Sep 17 00:00:00 2001 From: pd Date: Fri, 1 Aug 2008 18:31:43 +0200 Subject: [PATCH 2/3] Time to get rid of the horrible coding style --- examples/echo/echo-client.cpp | 22 +- examples/echo/echo-client.h | 4 +- examples/echo/echo-server.cpp | 23 +- examples/echo/echo-server.h | 10 +- examples/glib/dbus-browser.cpp | 34 +-- examples/glib/dbus-browser.h | 12 +- examples/hal/hal-listen.cpp | 18 +- examples/hal/hal-listen.h | 12 +- examples/properties/props-server.cpp | 12 +- examples/properties/props-server.h | 4 +- include/dbus-c++/connection.h | 40 +-- include/dbus-c++/debug.h | 2 +- include/dbus-c++/dispatcher.h | 82 +++--- include/dbus-c++/error.h | 74 ++--- include/dbus-c++/eventloop-integration.h | 16 +- include/dbus-c++/eventloop.h | 36 +-- include/dbus-c++/glib-integration.h | 30 +- include/dbus-c++/interface.h | 50 ++-- include/dbus-c++/introspection.h | 24 +- include/dbus-c++/message.h | 130 ++++----- include/dbus-c++/object.h | 70 ++--- include/dbus-c++/pendingcall.h | 12 +- include/dbus-c++/property.h | 20 +- include/dbus-c++/refptr_impl.h | 4 +- include/dbus-c++/server.h | 10 +- include/dbus-c++/types.h | 108 ++++---- include/dbus-c++/util.h | 70 ++--- src/connection.cpp | 104 +++---- src/connection_p.h | 16 +- src/debug.cpp | 4 +- src/dispatcher.cpp | 66 ++--- src/dispatcher_p.h | 12 +- src/error.cpp | 14 +- src/eventloop-integration.cpp | 48 ++-- src/eventloop.cpp | 34 +-- src/glib-integration.cpp | 60 ++-- src/interface.cpp | 52 ++-- src/internalerror.h | 8 +- src/introspection.cpp | 36 +-- src/message.cpp | 192 ++++++------- src/message_p.h | 4 +- src/object.cpp | 102 +++---- src/pendingcall.cpp | 36 +-- src/pendingcall_p.h | 8 +- src/property.cpp | 24 +- src/server.cpp | 20 +- src/server_p.h | 8 +- src/types.cpp | 14 +- tools/introspect.cpp | 12 +- tools/introspect.h | 2 +- tools/xml.cpp | 102 +++---- tools/xml.h | 34 +-- tools/xml2cpp.cpp | 332 +++++++++++------------ 53 files changed, 1137 insertions(+), 1136 deletions(-) diff --git a/examples/echo/echo-client.cpp b/examples/echo/echo-client.cpp index 1155365..2872066 100644 --- a/examples/echo/echo-client.cpp +++ b/examples/echo/echo-client.cpp @@ -9,15 +9,15 @@ using namespace std; -static const char* ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo"; -static const char* ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo"; +static const char *ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo"; +static const char *ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo"; -EchoClient::EchoClient( DBus::Connection& connection, const char* path, const char* name ) +EchoClient::EchoClient(DBus::Connection &connection, const char *path, const char *name) : DBus::ObjectProxy(connection, path, name) { } -void EchoClient::Echoed( const DBus::Variant& value ) +void EchoClient::Echoed(const DBus::Variant &value) { cout << "!"; } @@ -26,13 +26,13 @@ void EchoClient::Echoed( const DBus::Variant& value ) * For some strange reason, libdbus frequently dies with an OOM */ -static const int THREADS = 16; +static const int THREADS = 3; static bool spin = true; -void* greeter_thread( void* arg ) +void *greeter_thread(void *arg) { - DBus::Connection* conn = reinterpret_cast(arg); + DBus::Connection *conn = reinterpret_cast(arg); EchoClient client(*conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME); @@ -40,7 +40,7 @@ void* greeter_thread( void* arg ) snprintf(idstr, sizeof(idstr), "%lu", pthread_self()); - for(int i = 0; i < 100 && spin; ++i) + for (int i = 0; i < 30 && spin; ++i) { cout << client.Hello(idstr) << endl; } @@ -52,7 +52,7 @@ void* greeter_thread( void* arg ) DBus::BusDispatcher dispatcher; -void niam( int sig ) +void niam(int sig) { spin = false; @@ -76,7 +76,7 @@ int main() pthread_t threads[THREADS]; - for(int i = 0; i < THREADS; ++i) + for (int i = 0; i < THREADS; ++i) { pthread_create(threads+i, NULL, greeter_thread, &conn); } @@ -85,7 +85,7 @@ int main() cout << "terminating" << endl; - for(int i = 0; i < THREADS; ++i) + for (int i = 0; i < THREADS; ++i) { pthread_join(threads[i], NULL); } diff --git a/examples/echo/echo-client.h b/examples/echo/echo-client.h index 0f88e80..abfb620 100644 --- a/examples/echo/echo-client.h +++ b/examples/echo/echo-client.h @@ -11,9 +11,9 @@ class EchoClient { public: - EchoClient( DBus::Connection& connection, const char* path, const char* name ); + EchoClient(DBus::Connection &connection, const char *path, const char *name); - void Echoed( const DBus::Variant& value ); + void Echoed(const DBus::Variant &value); }; #endif//__DEMO_ECHO_CLIENT_H diff --git a/examples/echo/echo-server.cpp b/examples/echo/echo-server.cpp index 0ec43df..a96fca3 100644 --- a/examples/echo/echo-server.cpp +++ b/examples/echo/echo-server.cpp @@ -5,10 +5,10 @@ #include #include -static const char* ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo"; -static const char* ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo"; +static const char *ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo"; +static const char *ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo"; -EchoServer::EchoServer( DBus::Connection& connection ) +EchoServer::EchoServer(DBus::Connection &connection) : DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH) { } @@ -18,23 +18,24 @@ DBus::Int32 EchoServer::Random() return rand(); } -DBus::String EchoServer::Hello( const DBus::String& name ) +DBus::String EchoServer::Hello(const DBus::String &name) { + sleep (10); return "Hello " + name + "!"; } -DBus::Variant EchoServer::Echo( const DBus::Variant& value ) +DBus::Variant EchoServer::Echo(const DBus::Variant &value) { this->Echoed(value); return value; } -std::vector< DBus::Byte > EchoServer::Cat( const DBus::String & file ) +std::vector< DBus::Byte > EchoServer::Cat(const DBus::String &file) { - FILE* handle = fopen(file.c_str(), "rb"); + FILE *handle = fopen(file.c_str(), "rb"); - if(!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found"); + if (!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found"); DBus::Byte buff[1024]; @@ -45,11 +46,11 @@ std::vector< DBus::Byte > EchoServer::Cat( const DBus::String & file ) return std::vector< DBus::Byte > (buff, buff + nread); } -DBus::Int32 EchoServer::Sum( const std::vector& ints ) +DBus::Int32 EchoServer::Sum(const std::vector& ints) { DBus::Int32 sum = 0; - for(size_t i = 0; i < ints.size(); ++i) sum += ints[i]; + for (size_t i = 0; i < ints.size(); ++i) sum += ints[i]; return sum; } @@ -69,7 +70,7 @@ std::map< DBus::String, DBus::String > EchoServer::Info() DBus::BusDispatcher dispatcher; -void niam( int sig ) +void niam(int sig) { dispatcher.leave(); } diff --git a/examples/echo/echo-server.h b/examples/echo/echo-server.h index 989d84c..58a0e92 100644 --- a/examples/echo/echo-server.h +++ b/examples/echo/echo-server.h @@ -11,17 +11,17 @@ class EchoServer { public: - EchoServer( DBus::Connection& connection ); + EchoServer(DBus::Connection &connection); DBus::Int32 Random(); - DBus::String Hello( const DBus::String & name ); + DBus::String Hello(const DBus::String &name); - DBus::Variant Echo( const DBus::Variant & value ); + DBus::Variant Echo(const DBus::Variant &value); - std::vector< DBus::Byte > Cat( const DBus::String & file ); + std::vector< DBus::Byte > Cat(const DBus::String &file); - DBus::Int32 Sum( const std::vector & ints ); + DBus::Int32 Sum(const std::vector & ints); std::map< DBus::String, DBus::String > Info(); }; diff --git a/examples/glib/dbus-browser.cpp b/examples/glib/dbus-browser.cpp index cd74d70..bc32d22 100644 --- a/examples/glib/dbus-browser.cpp +++ b/examples/glib/dbus-browser.cpp @@ -5,10 +5,10 @@ using namespace std; -static const char* DBUS_SERVER_NAME = "org.freedesktop.DBus"; -static const char* DBUS_SERVER_PATH = "/org/freedesktop/DBus"; +static const char *DBUS_SERVER_NAME = "org.freedesktop.DBus"; +static const char *DBUS_SERVER_PATH = "/org/freedesktop/DBus"; -DBusBrowser::DBusBrowser( ::DBus::Connection& conn ) +DBusBrowser::DBusBrowser(::DBus::Connection &conn) : ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME) { set_title("D-Bus Browser"); @@ -19,12 +19,12 @@ DBusBrowser::DBusBrowser( ::DBus::Connection& conn ) Names names = ListNames(); - for(Names::iterator it = names.begin(); it != names.end(); ++it) + for (Names::iterator it = names.begin(); it != names.end(); ++it) { _cb_busnames.append_text(*it); } - _cb_busnames.signal_changed().connect( sigc::mem_fun(*this, &DBusBrowser::on_select_busname) ); + _cb_busnames.signal_changed().connect(sigc::mem_fun(*this, &DBusBrowser::on_select_busname)); _tm_inspect = Gtk::TreeStore::create(_records); _tv_inspect.set_model(_tm_inspect); @@ -42,17 +42,17 @@ DBusBrowser::DBusBrowser( ::DBus::Connection& conn ) } void DBusBrowser::NameOwnerChanged( - const ::DBus::String& name, const ::DBus::String& old_owner, const ::DBus::String& new_owner ) + const ::DBus::String &name, const ::DBus::String &old_owner, const ::DBus::String &new_owner) { cout << name << ": " << old_owner << " -> " << new_owner << endl; } -void DBusBrowser::NameLost( const ::DBus::String& name ) +void DBusBrowser::NameLost(const ::DBus::String &name) { cout << name << " lost" << endl; } -void DBusBrowser::NameAcquired( const ::DBus::String& name ) +void DBusBrowser::NameAcquired(const ::DBus::String &name) { cout << name << " acquired" << endl; } @@ -60,24 +60,24 @@ void DBusBrowser::NameAcquired( const ::DBus::String& name ) void DBusBrowser::on_select_busname() { Glib::ustring busname = _cb_busnames.get_active_text(); - if(busname.empty()) return; + if (busname.empty()) return; _tm_inspect->clear(); _inspect_append(NULL, "", busname); } -void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string& buspath, const std::string& busname ) +void DBusBrowser::_inspect_append(Gtk::TreeModel::Row *row, const std::string &buspath, const std::string &busname) { DBusInspector inspector(conn(), buspath.empty() ? "/" : buspath.c_str(), busname.c_str()); ::DBus::Xml::Document doc(inspector.Introspect()); - ::DBus::Xml::Node& root = *(doc.root); + ::DBus::Xml::Node &root = *(doc.root); ::DBus::Xml::Nodes ifaces = root["interface"]; - for(::DBus::Xml::Nodes::iterator ii = ifaces.begin(); ii != ifaces.end(); ++ii) + for (::DBus::Xml::Nodes::iterator ii = ifaces.begin(); ii != ifaces.end(); ++ii) { - ::DBus::Xml::Node& iface = **ii; + ::DBus::Xml::Node &iface = **ii; Gtk::TreeModel::Row i_row = row ? *(_tm_inspect->append(row->children())) @@ -86,7 +86,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string& ::DBus::Xml::Nodes methods = iface["method"]; - for(::DBus::Xml::Nodes::iterator im = methods.begin(); im != methods.end(); ++im) + for (::DBus::Xml::Nodes::iterator im = methods.begin(); im != methods.end(); ++im) { Gtk::TreeModel::Row m_row = *(_tm_inspect->append(i_row.children())); m_row[_records.name] = "method: " + (*im)->get("name"); @@ -94,7 +94,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string& ::DBus::Xml::Nodes signals = iface["signal"]; - for(::DBus::Xml::Nodes::iterator is = signals.begin(); is != signals.end(); ++is) + for (::DBus::Xml::Nodes::iterator is = signals.begin(); is != signals.end(); ++is) { Gtk::TreeModel::Row s_row = *(_tm_inspect->append(i_row.children())); s_row[_records.name] = "signal: " + (*is)->get("name"); @@ -103,7 +103,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string& ::DBus::Xml::Nodes nodes = root["node"]; - for(::DBus::Xml::Nodes::iterator in = nodes.begin(); in != nodes.end(); ++in) + for (::DBus::Xml::Nodes::iterator in = nodes.begin(); in != nodes.end(); ++in) { std::string name = (*in)->get("name"); @@ -118,7 +118,7 @@ void DBusBrowser::_inspect_append( Gtk::TreeModel::Row* row, const std::string& DBus::Glib::BusDispatcher dispatcher; -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { Gtk::Main kit(argc, argv); diff --git a/examples/glib/dbus-browser.h b/examples/glib/dbus-browser.h index 10c9b3d..e246c07 100644 --- a/examples/glib/dbus-browser.h +++ b/examples/glib/dbus-browser.h @@ -13,7 +13,7 @@ class DBusInspector { public: - DBusInspector( DBus::Connection& conn, const char* path, const char* service ) + DBusInspector(DBus::Connection &conn, const char *path, const char *service) : DBus::ObjectProxy(conn, path, service) {} }; @@ -26,19 +26,19 @@ class DBusBrowser { public: - DBusBrowser( ::DBus::Connection& ); + DBusBrowser(::DBus::Connection &); private: - void NameOwnerChanged( const ::DBus::String&, const ::DBus::String&, const ::DBus::String& ); + void NameOwnerChanged(const ::DBus::String &, const ::DBus::String &, const ::DBus::String &); - void NameLost( const ::DBus::String& ); + void NameLost(const ::DBus::String &); - void NameAcquired( const ::DBus::String& ); + void NameAcquired(const ::DBus::String &); void on_select_busname(); - void _inspect_append( Gtk::TreeModel::Row*, const std::string&, const std::string& ); + void _inspect_append(Gtk::TreeModel::Row *, const std::string &, const std::string &); private: diff --git a/examples/hal/hal-listen.cpp b/examples/hal/hal-listen.cpp index d36eb2a..d544e28 100644 --- a/examples/hal/hal-listen.cpp +++ b/examples/hal/hal-listen.cpp @@ -3,7 +3,7 @@ #include #include -HalManagerProxy::HalManagerProxy( DBus::Connection& connection ) +HalManagerProxy::HalManagerProxy(DBus::Connection &connection) : DBus::InterfaceProxy("org.freedesktop.Hal.Manager"), DBus::ObjectProxy(connection, "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal") { @@ -13,7 +13,7 @@ HalManagerProxy::HalManagerProxy( DBus::Connection& connection ) std::vector< DBus::String > devices = GetAllDevices(); std::vector< DBus::String >::iterator it; - for(it = devices.begin(); it != devices.end(); ++it) + for (it = devices.begin(); it != devices.end(); ++it) { DBus::Path udi = *it; @@ -37,7 +37,7 @@ std::vector< DBus::String > HalManagerProxy::GetAllDevices() return udis; } -void HalManagerProxy::DeviceAddedCb( const DBus::SignalMessage& sig ) +void HalManagerProxy::DeviceAddedCb(const DBus::SignalMessage &sig) { DBus::MessageIter it = sig.reader(); DBus::String devname; @@ -50,7 +50,7 @@ void HalManagerProxy::DeviceAddedCb( const DBus::SignalMessage& sig ) std::cout << "added device " << udi << std::endl; } -void HalManagerProxy::DeviceRemovedCb( const DBus::SignalMessage& sig ) +void HalManagerProxy::DeviceRemovedCb(const DBus::SignalMessage &sig) { DBus::MessageIter it = sig.reader(); DBus::String devname; @@ -62,7 +62,7 @@ void HalManagerProxy::DeviceRemovedCb( const DBus::SignalMessage& sig ) _devices.erase(devname); } -HalDeviceProxy::HalDeviceProxy( DBus::Connection& connection, DBus::Path& udi ) +HalDeviceProxy::HalDeviceProxy(DBus::Connection &connection, DBus::Path &udi) : DBus::InterfaceProxy("org.freedesktop.Hal.Device"), DBus::ObjectProxy(connection, udi, "org.freedesktop.Hal") { @@ -70,7 +70,7 @@ HalDeviceProxy::HalDeviceProxy( DBus::Connection& connection, DBus::Path& udi ) connect_signal(HalDeviceProxy, Condition, ConditionCb); } -void HalDeviceProxy::PropertyModifiedCb( const DBus::SignalMessage& sig ) +void HalDeviceProxy::PropertyModifiedCb(const DBus::SignalMessage &sig) { typedef DBus::Struct< DBus::String, DBus::Bool, DBus::Bool > HalProperty; @@ -81,7 +81,7 @@ void HalDeviceProxy::PropertyModifiedCb( const DBus::SignalMessage& sig ) DBus::MessageIter arr = it.recurse(); - for(int i = 0; i < number; ++i, ++arr) + for (int i = 0; i < number; ++i, ++arr) { HalProperty hp; @@ -91,7 +91,7 @@ void HalDeviceProxy::PropertyModifiedCb( const DBus::SignalMessage& sig ) } } -void HalDeviceProxy::ConditionCb( const DBus::SignalMessage& sig ) +void HalDeviceProxy::ConditionCb(const DBus::SignalMessage &sig) { DBus::MessageIter it = sig.reader(); DBus::String condition; @@ -103,7 +103,7 @@ void HalDeviceProxy::ConditionCb( const DBus::SignalMessage& sig ) DBus::BusDispatcher dispatcher; -void niam( int sig ) +void niam(int sig) { dispatcher.leave(); } diff --git a/examples/hal/hal-listen.h b/examples/hal/hal-listen.h index 8401fbf..9797433 100644 --- a/examples/hal/hal-listen.h +++ b/examples/hal/hal-listen.h @@ -13,15 +13,15 @@ class HalManagerProxy { public: - HalManagerProxy( DBus::Connection& connection ); + HalManagerProxy(DBus::Connection &connection); std::vector< DBus::String > GetAllDevices(); private: - void DeviceAddedCb( const DBus::SignalMessage& sig ); + void DeviceAddedCb(const DBus::SignalMessage &sig); - void DeviceRemovedCb( const DBus::SignalMessage& sig ); + void DeviceRemovedCb(const DBus::SignalMessage &sig); std::map< DBus::String, DBus::RefPtr< HalDeviceProxy > > _devices; }; @@ -32,13 +32,13 @@ class HalDeviceProxy { public: - HalDeviceProxy( DBus::Connection& connection, DBus::Path& udi ); + HalDeviceProxy(DBus::Connection &connection, DBus::Path &udi); private: - void PropertyModifiedCb( const DBus::SignalMessage& sig ); + void PropertyModifiedCb(const DBus::SignalMessage &sig); - void ConditionCb( const DBus::SignalMessage& sig ); + void ConditionCb(const DBus::SignalMessage &sig); }; #endif//__DEMO_HAL_LISTEN_H diff --git a/examples/properties/props-server.cpp b/examples/properties/props-server.cpp index 6a4495f..990e6fe 100644 --- a/examples/properties/props-server.cpp +++ b/examples/properties/props-server.cpp @@ -1,10 +1,10 @@ #include "props-server.h" #include -static const char* PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties"; -static const char* PROPS_SERVER_PATH = "/org/freedesktop/DBus/Examples/Properties"; +static const char *PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties"; +static const char *PROPS_SERVER_PATH = "/org/freedesktop/DBus/Examples/Properties"; -PropsServer::PropsServer( DBus::Connection& connection ) +PropsServer::PropsServer(DBus::Connection &connection) : DBus::ObjectAdaptor(connection, PROPS_SERVER_PATH) { Version = 1; @@ -12,9 +12,9 @@ PropsServer::PropsServer( DBus::Connection& connection ) } void PropsServer::on_set_property - ( DBus::InterfaceAdaptor& interface, const DBus::String& property, const DBus::Variant& value ) + (DBus::InterfaceAdaptor &interface, const DBus::String &property, const DBus::Variant &value) { - if(property == "Message") + if (property == "Message") { DBus::String msg = value; this->MessageChanged(msg); @@ -23,7 +23,7 @@ void PropsServer::on_set_property DBus::BusDispatcher dispatcher; -void niam( int sig ) +void niam(int sig) { dispatcher.leave(); } diff --git a/examples/properties/props-server.h b/examples/properties/props-server.h index 93d13ee..6d32161 100644 --- a/examples/properties/props-server.h +++ b/examples/properties/props-server.h @@ -12,10 +12,10 @@ class PropsServer { public: - PropsServer( DBus::Connection& connection ); + PropsServer(DBus::Connection &connection); void on_set_property - ( DBus::InterfaceAdaptor& interface, const DBus::String& property, const DBus::Variant& value ); + (DBus::InterfaceAdaptor &interface, const DBus::String &property, const DBus::Variant &value); }; #endif//__DEMO_PROPS_SERVER_H diff --git a/include/dbus-c++/connection.h b/include/dbus-c++/connection.h index 62d4941..c2bc4ed 100644 --- a/include/dbus-c++/connection.h +++ b/include/dbus-c++/connection.h @@ -41,7 +41,7 @@ namespace DBus { class Connection; -typedef Slot MessageSlot; +typedef Slot MessageSlot; typedef std::list ConnectionList; @@ -60,31 +60,31 @@ public: struct Private; - typedef std::list PrivatePList; + typedef std::list PrivatePList; - Connection( Private* ); + Connection(Private *); - Connection( const char* address, bool priv = true ); + Connection(const char *address, bool priv = true); - Connection( const Connection& c ); + Connection(const Connection &c); virtual ~Connection(); - Dispatcher* setup( Dispatcher* ); + Dispatcher *setup(Dispatcher *); - bool operator == ( const Connection& ) const; + bool operator == (const Connection &) const; - void add_match( const char* rule ); + void add_match(const char *rule); - void remove_match( const char* rule ); + void remove_match(const char *rule); - bool add_filter( MessageSlot& ); + bool add_filter(MessageSlot &); - void remove_filter( MessageSlot& ); + void remove_filter(MessageSlot &); - bool unique_name( const char* n ); + bool unique_name(const char *n); - const char* unique_name() const; + const char *unique_name() const; bool register_bus(); @@ -92,21 +92,21 @@ public: void disconnect(); - void exit_on_disconnect( bool exit ); + void exit_on_disconnect(bool exit); void flush(); - bool send( const Message&, unsigned int* serial = NULL ); + bool send(const Message &, unsigned int *serial = NULL); - Message send_blocking( Message& msg, int timeout = -1); + Message send_blocking(Message &msg, int timeout = -1); - PendingCall send_async( Message& msg, int timeout ); + PendingCall send_async(Message &msg, int timeout); - void request_name( const char* name, int flags = 0 ); + void request_name(const char *name, int flags = 0); - bool has_name( const char* name ); + bool has_name(const char *name); - bool start_service( const char* name, unsigned long flags ); + bool start_service(const char *name, unsigned long flags); const std::vector& names(); diff --git a/include/dbus-c++/debug.h b/include/dbus-c++/debug.h index 0096987..6b871f6 100644 --- a/include/dbus-c++/debug.h +++ b/include/dbus-c++/debug.h @@ -33,7 +33,7 @@ namespace DBus { -typedef void (*LogFunction)(const char* format, ...); +typedef void (*LogFunction)(const char *format, ...); extern DXXAPI LogFunction debug_log; diff --git a/include/dbus-c++/dispatcher.h b/include/dbus-c++/dispatcher.h index 1d331cf..c6f4d12 100644 --- a/include/dbus-c++/dispatcher.h +++ b/include/dbus-c++/dispatcher.h @@ -41,7 +41,7 @@ public: class Internal; - Timeout( Internal* i ); + Timeout(Internal *i); virtual ~Timeout(){} @@ -55,11 +55,11 @@ public: private: - DXXAPILOCAL Timeout( const Timeout& ); + DXXAPILOCAL Timeout(const Timeout &); private: - Internal* _int; + Internal *_int; }; class DXXAPI Watch @@ -68,7 +68,7 @@ public: class Internal; - Watch( Internal* i ); + Watch(Internal *i); virtual ~Watch(){} @@ -78,17 +78,17 @@ public: bool enabled() const; - bool handle( int flags ); + bool handle(int flags); virtual void toggle() = 0; private: - DXXAPILOCAL Watch( const Watch& ); + DXXAPILOCAL Watch(const Watch &); private: - Internal* _int; + Internal *_int; }; class DXXAPI Dispatcher @@ -98,7 +98,7 @@ public: virtual ~Dispatcher() {} - void queue_connection( Connection::Private* ); + void queue_connection(Connection::Private *); void dispatch_pending(); @@ -106,13 +106,13 @@ public: virtual void leave() = 0; - virtual Timeout* add_timeout( Timeout::Internal* ) = 0; + virtual Timeout *add_timeout(Timeout::Internal *) = 0; - virtual void rem_timeout( Timeout* ) = 0; + virtual void rem_timeout(Timeout *) = 0; - virtual Watch* add_watch( Watch::Internal* ) = 0; + virtual Watch *add_watch(Watch::Internal *) = 0; - virtual void rem_watch( Watch* ) = 0; + virtual void rem_watch(Watch *) = 0; struct Private; @@ -122,7 +122,7 @@ private: Connection::PrivatePList _pending_queue; }; -extern DXXAPI Dispatcher* default_dispatcher; +extern DXXAPI Dispatcher *default_dispatcher; /* classes for multithreading support */ @@ -141,7 +141,7 @@ public: protected: - Internal* _int; + Internal *_int; }; class DXXAPI CondVar @@ -150,9 +150,9 @@ public: virtual ~CondVar() {} - virtual void wait( Mutex* ) = 0; + virtual void wait(Mutex *) = 0; - virtual bool wait_timeout( Mutex*, int timeout ) = 0; + virtual bool wait_timeout(Mutex *, int timeout) = 0; virtual void wake_one() = 0; @@ -162,27 +162,27 @@ public: protected: - Internal* _int; + Internal *_int; }; #ifndef DBUS_HAS_RECURSIVE_MUTEX -typedef Mutex* (*MutexNewFn)(); -typedef bool (*MutexFreeFn)( Mutex* mx ); -typedef bool (*MutexLockFn)( Mutex* mx ); -typedef void (*MutexUnlockFn)( Mutex* mx ); +typedef Mutex *(*MutexNewFn)(); +typedef bool (*MutexFreeFn)(Mutex *mx); +typedef bool (*MutexLockFn)(Mutex *mx); +typedef void (*MutexUnlockFn)(Mutex *mx); #else -typedef Mutex* (*MutexNewFn)(); -typedef void (*MutexFreeFn)( Mutex* mx ); -typedef void (*MutexLockFn)( Mutex* mx ); -typedef void (*MutexUnlockFn)( Mutex* mx ); +typedef Mutex *(*MutexNewFn)(); +typedef void (*MutexFreeFn)(Mutex *mx); +typedef void (*MutexLockFn)(Mutex *mx); +typedef void (*MutexUnlockFn)(Mutex *mx); #endif//DBUS_HAS_RECURSIVE_MUTEX -typedef CondVar* (*CondVarNewFn)(); -typedef void (*CondVarFreeFn)( CondVar* cv ); -typedef void (*CondVarWaitFn)( CondVar* cv, Mutex* mx ); -typedef bool (*CondVarWaitTimeoutFn)( CondVar* cv, Mutex* mx, int timeout ); -typedef void (*CondVarWakeOneFn)( CondVar* cv ); -typedef void (*CondVarWakeAllFn)( CondVar* cv ); +typedef CondVar *(*CondVarNewFn)(); +typedef void (*CondVarFreeFn)(CondVar *cv); +typedef void (*CondVarWaitFn)(CondVar *cv, Mutex *mx); +typedef bool (*CondVarWaitTimeoutFn)(CondVar *cv, Mutex *mx, int timeout); +typedef void (*CondVarWakeOneFn)(CondVar *cv); +typedef void (*CondVarWakeAllFn)(CondVar *cv); #ifdef DBUS_HAS_THREADS_INIT_DEFAULT void DXXAPI _init_threading(); @@ -204,52 +204,52 @@ struct Threading ); } - static Mutex* mutex_new() + static Mutex *mutex_new() { return new Mx; } - static void mutex_free( Mutex* mx ) + static void mutex_free(Mutex *mx) { delete mx; } - static void mutex_lock( Mutex* mx ) + static void mutex_lock(Mutex *mx) { mx->lock(); } - static void mutex_unlock( Mutex* mx ) + static void mutex_unlock(Mutex *mx) { mx->unlock(); } - static CondVar* condvar_new() + static CondVar *condvar_new() { return new Cv; } - static void condvar_free( CondVar* cv ) + static void condvar_free(CondVar *cv) { delete cv; } - static void condvar_wait( CondVar* cv, Mutex* mx ) + static void condvar_wait(CondVar *cv, Mutex *mx) { cv->wait(mx); } - static bool condvar_wait_timeout( CondVar* cv, Mutex* mx, int timeout ) + static bool condvar_wait_timeout(CondVar *cv, Mutex *mx, int timeout) { return cv->wait_timeout(mx, timeout); } - static void condvar_wake_one( CondVar* cv ) + static void condvar_wake_one(CondVar *cv) { cv->wake_one(); } - static void condvar_wake_all( CondVar* cv ) + static void condvar_wake_all(CondVar *cv) { cv->wake_all(); } diff --git a/include/dbus-c++/error.h b/include/dbus-c++/error.h index 21540cd..9339e5e 100644 --- a/include/dbus-c++/error.h +++ b/include/dbus-c++/error.h @@ -45,21 +45,21 @@ public: Error(); - Error( InternalError& ); + Error(InternalError &); - Error( const char* name, const char* message ); + Error(const char *name, const char *message); - Error( Message& ); + Error(Message &); ~Error() throw(); - const char* what() const throw(); + const char *what() const throw(); - const char* name() const; + const char *name() const; - const char* message() const; + const char *message() const; - void set( const char* name, const char* message ); + void set(const char *name, const char *message); // parameters MUST be static strings bool is_set() const; @@ -76,210 +76,210 @@ private: struct DXXAPI ErrorFailed : public Error { - ErrorFailed( const char* message ) + ErrorFailed(const char *message) : Error("org.freedesktop.DBus.Error.Failed", message) {} }; struct DXXAPI ErrorNoMemory : public Error { - ErrorNoMemory( const char* message ) + ErrorNoMemory(const char *message) : Error("org.freedesktop.DBus.Error.NoMemory", message) {} }; struct DXXAPI ErrorServiceUnknown : public Error { - ErrorServiceUnknown( const char* message ) + ErrorServiceUnknown(const char *message) : Error("org.freedesktop.DBus.Error.ServiceUnknown", message) {} }; struct DXXAPI ErrorNameHasNoOwner : public Error { - ErrorNameHasNoOwner( const char* message ) + ErrorNameHasNoOwner(const char *message) : Error("org.freedesktop.DBus.Error.NameHasNoOwner", message) {} }; struct DXXAPI ErrorNoReply : public Error { - ErrorNoReply( const char* message ) + ErrorNoReply(const char *message) : Error("org.freedesktop.DBus.Error.NoReply", message) {} }; struct DXXAPI ErrorIOError : public Error { - ErrorIOError( const char* message ) + ErrorIOError(const char *message) : Error("org.freedesktop.DBus.Error.IOError", message) {} }; struct DXXAPI ErrorBadAddress : public Error { - ErrorBadAddress( const char* message ) + ErrorBadAddress(const char *message) : Error("org.freedesktop.DBus.Error.BadAddress", message) {} }; struct DXXAPI ErrorNotSupported : public Error { - ErrorNotSupported( const char* message ) + ErrorNotSupported(const char *message) : Error("org.freedesktop.DBus.Error.NotSupported", message) {} }; struct DXXAPI ErrorLimitsExceeded : public Error { - ErrorLimitsExceeded( const char* message ) + ErrorLimitsExceeded(const char *message) : Error("org.freedesktop.DBus.Error.LimitsExceeded", message) {} }; struct DXXAPI ErrorAccessDenied : public Error { - ErrorAccessDenied( const char* message ) + ErrorAccessDenied(const char *message) : Error("org.freedesktop.DBus.Error.AccessDenied", message) {} }; struct DXXAPI ErrorAuthFailed : public Error { - ErrorAuthFailed( const char* message ) + ErrorAuthFailed(const char *message) : Error("org.freedesktop.DBus.Error.AuthFailed", message) {} }; struct DXXAPI ErrorNoServer : public Error { - ErrorNoServer( const char* message ) + ErrorNoServer(const char *message) : Error("org.freedesktop.DBus.Error.NoServer", message) {} }; struct DXXAPI ErrorTimeout : public Error { - ErrorTimeout( const char* message ) + ErrorTimeout(const char *message) : Error("org.freedesktop.DBus.Error.Timeout", message) {} }; struct DXXAPI ErrorNoNetwork : public Error { - ErrorNoNetwork( const char* message ) + ErrorNoNetwork(const char *message) : Error("org.freedesktop.DBus.Error.NoNetwork", message) {} }; struct DXXAPI ErrorAddressInUse : public Error { - ErrorAddressInUse( const char* message ) + ErrorAddressInUse(const char *message) : Error("org.freedesktop.DBus.Error.AddressInUse", message) {} }; struct DXXAPI ErrorDisconnected : public Error { - ErrorDisconnected( const char* message ) + ErrorDisconnected(const char *message) : Error("org.freedesktop.DBus.Error.Disconnected", message) {} }; struct DXXAPI ErrorInvalidArgs : public Error { - ErrorInvalidArgs( const char* message ) + ErrorInvalidArgs(const char *message) : Error("org.freedesktop.DBus.Error.InvalidArgs", message) {} }; struct DXXAPI ErrorFileNotFound : public Error { - ErrorFileNotFound( const char* message ) + ErrorFileNotFound(const char *message) : Error("org.freedesktop.DBus.Error.FileNotFound", message) {} }; struct DXXAPI ErrorUnknownMethod : public Error { - ErrorUnknownMethod( const char* message ) + ErrorUnknownMethod(const char *message) : Error("org.freedesktop.DBus.Error.UnknownMethod", message) {} }; struct DXXAPI ErrorTimedOut : public Error { - ErrorTimedOut( const char* message ) + ErrorTimedOut(const char *message) : Error("org.freedesktop.DBus.Error.TimedOut", message) {} }; struct DXXAPI ErrorMatchRuleNotFound : public Error { - ErrorMatchRuleNotFound( const char* message ) + ErrorMatchRuleNotFound(const char *message) : Error("org.freedesktop.DBus.Error.MatchRuleNotFound", message) {} }; struct DXXAPI ErrorMatchRuleInvalid : public Error { - ErrorMatchRuleInvalid( const char* message ) + ErrorMatchRuleInvalid(const char *message) : Error("org.freedesktop.DBus.Error.MatchRuleInvalid", message) {} }; struct DXXAPI ErrorSpawnExecFailed : public Error { - ErrorSpawnExecFailed( const char* message ) + ErrorSpawnExecFailed(const char *message) : Error("org.freedesktop.DBus.Error.Spawn.ExecFailed", message) {} }; struct DXXAPI ErrorSpawnForkFailed : public Error { - ErrorSpawnForkFailed( const char* message ) + ErrorSpawnForkFailed(const char *message) : Error("org.freedesktop.DBus.Error.Spawn.ForkFailed", message) {} }; struct DXXAPI ErrorSpawnChildExited : public Error { - ErrorSpawnChildExited( const char* message ) + ErrorSpawnChildExited(const char *message) : Error("org.freedesktop.DBus.Error.Spawn.ChildExited", message) {} }; struct DXXAPI ErrorSpawnChildSignaled : public Error { - ErrorSpawnChildSignaled( const char* message ) + ErrorSpawnChildSignaled(const char *message) : Error("org.freedesktop.DBus.Error.Spawn.ChildSignaled", message) {} }; struct DXXAPI ErrorSpawnFailed : public Error { - ErrorSpawnFailed( const char* message ) + ErrorSpawnFailed(const char *message) : Error("org.freedesktop.DBus.Error.Spawn.Failed", message) {} }; struct DXXAPI ErrorInvalidSignature : public Error { - ErrorInvalidSignature( const char* message ) + ErrorInvalidSignature(const char *message) : Error("org.freedesktop.DBus.Error.InvalidSignature", message) {} }; struct DXXAPI ErrorUnixProcessIdUnknown : public Error { - ErrorUnixProcessIdUnknown( const char* message ) + ErrorUnixProcessIdUnknown(const char *message) : Error("org.freedesktop.DBus.Error.UnixProcessIdUnknown", message) {} }; struct DXXAPI ErrorSELinuxSecurityContextUnknown : public Error { - ErrorSELinuxSecurityContextUnknown( const char* message ) + ErrorSELinuxSecurityContextUnknown(const char *message) : Error("org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown", message) {} }; diff --git a/include/dbus-c++/eventloop-integration.h b/include/dbus-c++/eventloop-integration.h index 01895a8..4a5289e 100644 --- a/include/dbus-c++/eventloop-integration.h +++ b/include/dbus-c++/eventloop-integration.h @@ -44,7 +44,7 @@ class BusDispatcher; class DXXAPI BusTimeout : public Timeout, public DefaultTimeout { - BusTimeout( Timeout::Internal*, BusDispatcher* ); + BusTimeout(Timeout::Internal *, BusDispatcher *); void toggle(); @@ -53,7 +53,7 @@ friend class BusDispatcher; class DXXAPI BusWatch : public Watch, public DefaultWatch { - BusWatch( Watch::Internal*, BusDispatcher* ); + BusWatch(Watch::Internal *, BusDispatcher *); void toggle(); @@ -76,17 +76,17 @@ public: virtual void do_iteration(); - virtual Timeout* add_timeout( Timeout::Internal* ); + virtual Timeout *add_timeout(Timeout::Internal *); - virtual void rem_timeout( Timeout* ); + virtual void rem_timeout(Timeout *); - virtual Watch* add_watch( Watch::Internal* ); + virtual Watch *add_watch(Watch::Internal *); - virtual void rem_watch( Watch* ); + virtual void rem_watch(Watch *); - void watch_ready( DefaultWatch& ); + void watch_ready(DefaultWatch &); - void timeout_expired( DefaultTimeout& ); + void timeout_expired(DefaultTimeout &); private: diff --git a/include/dbus-c++/eventloop.h b/include/dbus-c++/eventloop.h index 4ee9bc5..f2a4cae 100644 --- a/include/dbus-c++/eventloop.h +++ b/include/dbus-c++/eventloop.h @@ -41,10 +41,10 @@ namespace DBus { /* - * these Default* classes implement a very simple event loop which + * these Default *classes implement a very simple event loop which * is used here as the default main loop, if you want to hook - * a different one use the Bus* classes in eventloop-integration.h - * or the Glib::Bus* classes as a reference + * a different one use the Bus *classes in eventloop-integration.h + * or the Glib::Bus *classes as a reference */ class DefaultMainLoop; @@ -53,7 +53,7 @@ class DXXAPI DefaultTimeout { public: - DefaultTimeout( int interval, bool repeat, DefaultMainLoop* ); + DefaultTimeout(int interval, bool repeat, DefaultMainLoop *); virtual ~DefaultTimeout(); @@ -66,10 +66,10 @@ public: bool repeat(){ return _repeat; } void repeat(bool r){ _repeat = r; } - void* data(){ return _data; } - void data(void* d){ _data = d; } + void *data(){ return _data; } + void data(void *d){ _data = d; } - Slot expired; + Slot expired; private: @@ -80,20 +80,20 @@ private: double _expiration; - void* _data; + void *_data; - DefaultMainLoop* _disp; + DefaultMainLoop *_disp; friend class DefaultMainLoop; }; -typedef std::list< DefaultTimeout* > DefaultTimeouts; +typedef std::list< DefaultTimeout *> DefaultTimeouts; class DXXAPI DefaultWatch { public: - DefaultWatch( int fd, int flags, DefaultMainLoop* ); + DefaultWatch(int fd, int flags, DefaultMainLoop *); virtual ~DefaultWatch(); @@ -103,14 +103,14 @@ public: int descriptor(){ return _fd; } int flags(){ return _flags; } - void flags( int f ){ _flags = f; } + void flags(int f){ _flags = f; } int state(){ return _state; } - void* data(){ return _data; } - void data(void* d){ _data = d; } + void *data(){ return _data; } + void data(void *d){ _data = d; } - Slot ready; + Slot ready; private: @@ -120,14 +120,14 @@ private: int _flags; int _state; - void* _data; + void *_data; - DefaultMainLoop* _disp; + DefaultMainLoop *_disp; friend class DefaultMainLoop; }; -typedef std::list< DefaultWatch* > DefaultWatches; +typedef std::list< DefaultWatch *> DefaultWatches; class DXXAPI DefaultMutex { diff --git a/include/dbus-c++/glib-integration.h b/include/dbus-c++/glib-integration.h index e76dfbd..82f8178 100644 --- a/include/dbus-c++/glib-integration.h +++ b/include/dbus-c++/glib-integration.h @@ -44,13 +44,13 @@ class DXXAPI BusTimeout : public Timeout { private: - BusTimeout( Timeout::Internal*, GMainContext*, int ); + BusTimeout(Timeout::Internal *, GMainContext *, int); ~BusTimeout(); void toggle(); - static gboolean timeout_handler( gpointer ); + static gboolean timeout_handler(gpointer); void _enable(); @@ -58,8 +58,8 @@ private: private: - GSource* _source; - GMainContext* _ctx; + GSource *_source; + GMainContext *_ctx; int _priority; friend class BusDispatcher; @@ -69,13 +69,13 @@ class DXXAPI BusWatch : public Watch { private: - BusWatch( Watch::Internal*, GMainContext*, int ); + BusWatch(Watch::Internal *, GMainContext *, int); ~BusWatch(); void toggle(); - static gboolean watch_handler( gpointer ); + static gboolean watch_handler(gpointer); void _enable(); @@ -83,8 +83,8 @@ private: private: - GSource* _source; - GMainContext* _ctx; + GSource *_source; + GMainContext *_ctx; int _priority; friend class BusDispatcher; @@ -96,25 +96,25 @@ public: BusDispatcher() : _ctx(NULL), _priority(G_PRIORITY_DEFAULT) {} - void attach( GMainContext* ); + void attach(GMainContext *); void enter() {} void leave() {} - Timeout* add_timeout( Timeout::Internal* ); + Timeout *add_timeout(Timeout::Internal *); - void rem_timeout( Timeout* ); + void rem_timeout(Timeout *); - Watch* add_watch( Watch::Internal* ); + Watch *add_watch(Watch::Internal *); - void rem_watch( Watch* ); + void rem_watch(Watch *); - void set_priority( int priority ); + void set_priority(int priority); private: - GMainContext* _ctx; + GMainContext *_ctx; int _priority; }; diff --git a/include/dbus-c++/interface.h b/include/dbus-c++/interface.h index ea10d57..00da7c2 100644 --- a/include/dbus-c++/interface.h +++ b/include/dbus-c++/interface.h @@ -56,22 +56,22 @@ class ObjectAdaptor; class InterfaceAdaptor; class SignalMessage; -typedef std::map InterfaceAdaptorTable; +typedef std::map InterfaceAdaptorTable; class DXXAPI AdaptorBase { public: - virtual const ObjectAdaptor* object() const = 0 ; + virtual const ObjectAdaptor *object() const = 0 ; protected: - InterfaceAdaptor* find_interface( const std::string& name ); + InterfaceAdaptor *find_interface(const std::string &name); virtual ~AdaptorBase() {} - virtual void _emit_signal( SignalMessage& ) = 0; + virtual void _emit_signal(SignalMessage &) = 0; InterfaceAdaptorTable _interfaces; }; @@ -83,22 +83,22 @@ class ObjectProxy; class InterfaceProxy; class CallMessage; -typedef std::map InterfaceProxyTable; +typedef std::map InterfaceProxyTable; class DXXAPI ProxyBase { public: - virtual const ObjectProxy* object() const = 0 ; + virtual const ObjectProxy *object() const = 0 ; protected: - InterfaceProxy* find_interface( const std::string& name ); + InterfaceProxy *find_interface(const std::string &name); virtual ~ProxyBase() {} - virtual Message _invoke_method( CallMessage& ) = 0; + virtual Message _invoke_method(CallMessage &) = 0; InterfaceProxyTable _interfaces; }; @@ -107,11 +107,11 @@ class DXXAPI Interface { public: - Interface( const std::string& name ); + Interface(const std::string &name); virtual ~Interface(); - inline const std::string& name() const; + inline const std::string &name() const; private: @@ -121,7 +121,7 @@ private: /* */ -const std::string& Interface::name() const +const std::string &Interface::name() const { return _name; } @@ -129,23 +129,23 @@ const std::string& Interface::name() const /* */ -typedef std::map< std::string, Slot > MethodTable; +typedef std::map< std::string, Slot > MethodTable; class DXXAPI InterfaceAdaptor : public Interface, public virtual AdaptorBase { public: - InterfaceAdaptor( const std::string& name ); + InterfaceAdaptor(const std::string &name); - Message dispatch_method( const CallMessage& ); + Message dispatch_method(const CallMessage &); - void emit_signal( const SignalMessage& ); + void emit_signal(const SignalMessage &); - Variant* get_property( const std::string& name ); + Variant *get_property(const std::string &name); - void set_property( const std::string& name, Variant& value ); + void set_property(const std::string &name, Variant &value); - virtual IntrospectedInterface* const introspect() const + virtual IntrospectedInterface *const introspect() const { return NULL; } @@ -159,17 +159,17 @@ protected: /* */ -typedef std::map< std::string, Slot > SignalTable; +typedef std::map< std::string, Slot > SignalTable; class DXXAPI InterfaceProxy : public Interface, public virtual ProxyBase { public: - InterfaceProxy( const std::string& name ); + InterfaceProxy(const std::string &name); - Message invoke_method( const CallMessage& ); + Message invoke_method(const CallMessage &); - bool dispatch_signal( const SignalMessage& ); + bool dispatch_signal(const SignalMessage &); protected: @@ -178,17 +178,17 @@ protected: # define register_method(interface, method, callback) \ InterfaceAdaptor::_methods[ #method ] = \ - new ::DBus::Callback< interface, ::DBus::Message, const ::DBus::CallMessage& >(this, & interface :: callback ); + new ::DBus::Callback< interface, ::DBus::Message, const ::DBus::CallMessage &>(this, & interface :: callback); # define bind_property(variable, type, can_read, can_write) \ InterfaceAdaptor::_properties[ #variable ].read = can_read; \ InterfaceAdaptor::_properties[ #variable ].write = can_write; \ InterfaceAdaptor::_properties[ #variable ].sig = type; \ - variable.bind( InterfaceAdaptor::_properties[ #variable ] ); + variable.bind(InterfaceAdaptor::_properties[ #variable ]); # define connect_signal(interface, signal, callback) \ InterfaceProxy::_signals[ #signal ] = \ - new ::DBus::Callback< interface, void, const ::DBus::SignalMessage& >(this, & interface :: callback ); + new ::DBus::Callback< interface, void, const ::DBus::SignalMessage &>(this, & interface :: callback); } /* namespace DBus */ diff --git a/include/dbus-c++/introspection.h b/include/dbus-c++/introspection.h index baae4a0..8bb4ee9 100644 --- a/include/dbus-c++/introspection.h +++ b/include/dbus-c++/introspection.h @@ -36,31 +36,31 @@ namespace DBus { struct DXXAPI IntrospectedArgument { - const char* name; - const char* type; + const char *name; + const char *type; const bool in; }; struct DXXAPI IntrospectedMethod { - const char* name; - const IntrospectedArgument* args; + const char *name; + const IntrospectedArgument *args; }; struct DXXAPI IntrospectedProperty { - const char* name; - const char* type; + const char *name; + const char *type; const bool read; const bool write; }; struct DXXAPI IntrospectedInterface { - const char* name; - const IntrospectedMethod* methods; - const IntrospectedMethod* signals; - const IntrospectedProperty* properties; + const char *name; + const IntrospectedMethod *methods; + const IntrospectedMethod *signals; + const IntrospectedProperty *properties; }; class DXXAPI IntrospectableAdaptor : public InterfaceAdaptor @@ -69,11 +69,11 @@ public: IntrospectableAdaptor(); - Message Introspect( const CallMessage& ); + Message Introspect(const CallMessage &); protected: - IntrospectedInterface* const introspect() const; + IntrospectedInterface *const introspect() const; }; class DXXAPI IntrospectableProxy : public InterfaceProxy diff --git a/include/dbus-c++/message.h b/include/dbus-c++/message.h index a10fbd0..3b27fdd 100644 --- a/include/dbus-c++/message.h +++ b/include/dbus-c++/message.h @@ -56,104 +56,104 @@ public: bool has_next(); - MessageIter& operator ++(); + MessageIter &operator ++(); MessageIter operator ++(int); - bool append_byte( unsigned char byte ); + bool append_byte(unsigned char byte); unsigned char get_byte(); - bool append_bool( bool b ); + bool append_bool(bool b); bool get_bool(); - bool append_int16( signed short i ); + bool append_int16(signed short i); signed short get_int16(); - bool append_uint16( unsigned short u ); + bool append_uint16(unsigned short u); unsigned short get_uint16(); - bool append_int32( signed int i ); + bool append_int32(signed int i); signed int get_int32(); - bool append_uint32( unsigned int u ); + bool append_uint32(unsigned int u); unsigned int get_uint32(); - bool append_int64( signed long long i ); + bool append_int64(signed long long i); signed long long get_int64(); - bool append_uint64( unsigned long long i ); + bool append_uint64(unsigned long long i); unsigned long long get_uint64(); - bool append_double( double d ); + bool append_double(double d); double get_double(); - bool append_string( const char* chars ); + bool append_string(const char *chars); - const char* get_string(); + const char *get_string(); - bool append_path( const char* chars ); + bool append_path(const char *chars); - const char* get_path(); + const char *get_path(); - bool append_signature( const char* chars ); + bool append_signature(const char *chars); - const char* get_signature(); + const char *get_signature(); - char* signature() const; //returned string must be manually free()'d + char *signature() const; //returned string must be manually free()'d MessageIter recurse(); - bool append_array( char type, const void* ptr, size_t length ); + bool append_array(char type, const void *ptr, size_t length); int array_type(); - int get_array( void* ptr ); + int get_array(void *ptr); bool is_array(); bool is_dict(); - MessageIter new_array( const char* sig ); + MessageIter new_array(const char *sig); - MessageIter new_variant( const char* sig ); + MessageIter new_variant(const char *sig); MessageIter new_struct(); MessageIter new_dict_entry(); - void close_container( MessageIter& container ); + void close_container(MessageIter &container); - void copy_data( MessageIter& to ); + void copy_data(MessageIter &to); - Message& msg() const + Message &msg() const { return *_msg; } private: - DXXAPILOCAL MessageIter(Message& msg) : _msg(&msg) {} + DXXAPILOCAL MessageIter(Message &msg) : _msg(&msg) {} - DXXAPILOCAL bool append_basic( int type_id, void* value ); + DXXAPILOCAL bool append_basic(int type_id, void *value); - DXXAPILOCAL void get_basic( int type_id, void* ptr ); + DXXAPILOCAL void get_basic(int type_id, void *ptr); private: /* I'm sorry, but don't want to include dbus.h in the public api */ - unsigned char _iter[sizeof(void*)*3+sizeof(int)*11]; + unsigned char _iter[sizeof(void *)*3+sizeof(int)*11]; - Message* _msg; + Message *_msg; friend class Message; }; @@ -164,13 +164,13 @@ public: struct Private; - Message( Private*, bool incref = true ); + Message(Private *, bool incref = true); - Message( const Message& m ); + Message(const Message &m); ~Message(); - Message& operator = ( const Message& m ); + Message &operator = (const Message &m); Message copy(); @@ -180,25 +180,25 @@ public: int reply_serial() const; - bool reply_serial( int ); + bool reply_serial(int); - const char* sender() const; + const char *sender() const; - bool sender( const char* s ); + bool sender(const char *s); - const char* destination() const; + const char *destination() const; - bool destination( const char* s ); + bool destination(const char *s); bool is_error() const; - bool is_signal( const char* interface, const char* member ) const; + bool is_signal(const char *interface, const char *member) const; MessageIter reader() const; MessageIter writer(); - bool append( int first_type, ... ); + bool append(int first_type, ...); void terminate(); @@ -228,13 +228,13 @@ public: ErrorMessage(); - ErrorMessage( const Message&, const char* name, const char* message ); + ErrorMessage(const Message &, const char *name, const char *message); - const char* name() const; + const char *name() const; - bool name( const char* n ); + bool name(const char *n); - bool operator == ( const ErrorMessage& ) const; + bool operator == (const ErrorMessage &) const; }; /* @@ -244,25 +244,25 @@ class DXXAPI SignalMessage : public Message { public: - SignalMessage( const char* name ); + SignalMessage(const char *name); - SignalMessage( const char* path, const char* interface, const char* name ); + SignalMessage(const char *path, const char *interface, const char *name); - const char* interface() const; + const char *interface() const; - bool interface( const char* i ); + bool interface(const char *i); - const char* member() const; + const char *member() const; - bool member( const char* m ); + bool member(const char *m); - const char* path() const; + const char *path() const; - char** path_split() const; + char ** path_split() const; - bool path( const char* p ); + bool path(const char *p); - bool operator == ( const SignalMessage& ) const; + bool operator == (const SignalMessage &) const; }; /* @@ -274,25 +274,25 @@ public: CallMessage(); - CallMessage( const char* dest, const char* path, const char* iface, const char* method ); + CallMessage(const char *dest, const char *path, const char *iface, const char *method); - const char* interface() const; + const char *interface() const; - bool interface( const char* i ); + bool interface(const char *i); - const char* member() const; + const char *member() const; - bool member( const char* m ); + bool member(const char *m); - const char* path() const; + const char *path() const; - char** path_split() const; + char ** path_split() const; - bool path( const char* p ); + bool path(const char *p); - const char* signature() const; + const char *signature() const; - bool operator == ( const CallMessage& ) const; + bool operator == (const CallMessage &) const; }; /* @@ -302,9 +302,9 @@ class DXXAPI ReturnMessage : public Message { public: - ReturnMessage( const CallMessage& callee ); + ReturnMessage(const CallMessage &callee); - const char* signature() const; + const char *signature() const; }; } /* namespace DBus */ diff --git a/include/dbus-c++/object.h b/include/dbus-c++/object.h index f597a42..a7ed84d 100644 --- a/include/dbus-c++/object.h +++ b/include/dbus-c++/object.h @@ -44,21 +44,21 @@ class DXXAPI Object { protected: - Object( Connection& conn, const Path& path, const char* service ); + Object(Connection &conn, const Path &path, const char *service); public: virtual ~Object(); - inline const DBus::Path& path() const; + inline const DBus::Path &path() const; - inline const std::string& service() const; + inline const std::string &service() const; - inline Connection& conn(); + inline Connection &conn(); private: - DXXAPILOCAL virtual bool handle_message( const Message& ) = 0; + DXXAPILOCAL virtual bool handle_message(const Message &) = 0; DXXAPILOCAL virtual void register_obj() = 0; DXXAPILOCAL virtual void unregister_obj() = 0; @@ -72,17 +72,17 @@ private: /* */ -Connection& Object::conn() +Connection &Object::conn() { return _conn; } -const DBus::Path& Object::path() const +const DBus::Path &Object::path() const { return _path; } -const std::string& Object::service() const +const std::string &Object::service() const { return _service; } @@ -103,26 +103,26 @@ public: class ObjectAdaptor; -typedef std::list ObjectAdaptorPList; +typedef std::list ObjectAdaptorPList; typedef std::list ObjectPathList; class DXXAPI ObjectAdaptor : public Object, public virtual AdaptorBase { public: - static ObjectAdaptor* from_path( const Path& path ); + static ObjectAdaptor *from_path(const Path &path); - static ObjectAdaptorPList from_path_prefix( const std::string& prefix ); + static ObjectAdaptorPList from_path_prefix(const std::string &prefix); - static ObjectPathList child_nodes_from_prefix( const std::string& prefix ); + static ObjectPathList child_nodes_from_prefix(const std::string &prefix); struct Private; - ObjectAdaptor( Connection& conn, const Path& path ); + ObjectAdaptor(Connection &conn, const Path &path); ~ObjectAdaptor(); - inline const ObjectAdaptor* object() const; + inline const ObjectAdaptor *object() const; protected: @@ -130,57 +130,57 @@ protected: { public: - inline MessageIter& writer(); + inline MessageIter &writer(); - inline Tag* tag(); + inline Tag *tag(); private: - Continuation( Connection& conn, const CallMessage& call, const Tag* tag ); + Continuation(Connection &conn, const CallMessage &call, const Tag *tag); Connection _conn; CallMessage _call; MessageIter _writer; ReturnMessage _return; - const Tag* _tag; + const Tag *_tag; friend class ObjectAdaptor; }; - void return_later( const Tag* tag ); + void return_later(const Tag *tag); - void return_now( Continuation* ret ); + void return_now(Continuation *ret); - void return_error( Continuation* ret, const Error error ); + void return_error(Continuation *ret, const Error error); - Continuation* find_continuation( const Tag* tag ); + Continuation *find_continuation(const Tag *tag); private: - void _emit_signal( SignalMessage& ); + void _emit_signal(SignalMessage &); - bool handle_message( const Message& ); + bool handle_message(const Message &); void register_obj(); void unregister_obj(); - typedef std::map ContinuationMap; + typedef std::map ContinuationMap; ContinuationMap _continuations; friend struct Private; }; -const ObjectAdaptor* ObjectAdaptor::object() const +const ObjectAdaptor *ObjectAdaptor::object() const { return this; } -Tag* ObjectAdaptor::Continuation::tag() +Tag *ObjectAdaptor::Continuation::tag() { - return const_cast(_tag); + return const_cast(_tag); } -MessageIter& ObjectAdaptor::Continuation::writer() +MessageIter &ObjectAdaptor::Continuation::writer() { return _writer; } @@ -190,23 +190,23 @@ MessageIter& ObjectAdaptor::Continuation::writer() class ObjectProxy; -typedef std::list ObjectProxyPList; +typedef std::list ObjectProxyPList; class DXXAPI ObjectProxy : public Object, public virtual ProxyBase { public: - ObjectProxy( Connection& conn, const Path& path, const char* service = "" ); + ObjectProxy(Connection &conn, const Path &path, const char *service = ""); ~ObjectProxy(); - inline const ObjectProxy* object() const; + inline const ObjectProxy *object() const; private: - Message _invoke_method( CallMessage& ); + Message _invoke_method(CallMessage &); - bool handle_message( const Message& ); + bool handle_message(const Message &); void register_obj(); void unregister_obj(); @@ -216,7 +216,7 @@ private: MessageSlot _filtered; }; -const ObjectProxy* ObjectProxy::object() const +const ObjectProxy *ObjectProxy::object() const { return this; } diff --git a/include/dbus-c++/pendingcall.h b/include/dbus-c++/pendingcall.h index f7d0da6..1ba2856 100644 --- a/include/dbus-c++/pendingcall.h +++ b/include/dbus-c++/pendingcall.h @@ -43,13 +43,13 @@ public: struct Private; - PendingCall( Private* ); + PendingCall(Private *); - PendingCall( const PendingCall& ); + PendingCall(const PendingCall &); virtual ~PendingCall(); - PendingCall& operator = ( const PendingCall& ); + PendingCall &operator = (const PendingCall &); bool completed(); @@ -57,11 +57,11 @@ public: void block(); - void data( void* ); + void data(void *); - void* data(); + void *data(); - Slot& slot(); + Slot& slot(); Message steal_reply(); diff --git a/include/dbus-c++/property.h b/include/dbus-c++/property.h index d074167..b8c047a 100644 --- a/include/dbus-c++/property.h +++ b/include/dbus-c++/property.h @@ -43,7 +43,7 @@ public: PropertyAdaptor() : _data(0) {} - void bind( PropertyData& data ) + void bind(PropertyData &data) { _data = &data; } @@ -53,7 +53,7 @@ public: return (T)_data->value; } - PropertyAdaptor& operator = ( const T& t ) + PropertyAdaptor &operator = (const T &t) { _data->value.clear(); MessageIter wi = _data->value.writer(); @@ -63,7 +63,7 @@ public: private: - PropertyData* _data; + PropertyData *_data; }; struct IntrospectedInterface; @@ -74,19 +74,19 @@ public: PropertiesAdaptor(); - Message Get( const CallMessage& ); + Message Get(const CallMessage &); - Message Set( const CallMessage& ); + Message Set(const CallMessage &); protected: - virtual void on_get_property( InterfaceAdaptor& interface, const String& property, Variant& value ) + virtual void on_get_property(InterfaceAdaptor &interface, const String &property, Variant &value) {} - virtual void on_set_property( InterfaceAdaptor& interface, const String& property, const Variant& value ) + virtual void on_set_property(InterfaceAdaptor &interface, const String &property, const Variant &value) {} - IntrospectedInterface* const introspect() const; + IntrospectedInterface *const introspect() const; }; class DXXAPI PropertiesProxy : public InterfaceProxy @@ -95,9 +95,9 @@ public: PropertiesProxy(); - Variant Get( const String& interface, const String& property ); + Variant Get(const String &interface, const String &property); - void Set( const String& interface, const String& property, const Variant& value ); + void Set(const String &interface, const String &property, const Variant &value); }; } /* namespace DBus */ diff --git a/include/dbus-c++/refptr_impl.h b/include/dbus-c++/refptr_impl.h index 363f065..d35d834 100644 --- a/include/dbus-c++/refptr_impl.h +++ b/include/dbus-c++/refptr_impl.h @@ -35,14 +35,14 @@ namespace DBus { template -RefPtrI::RefPtrI( T* ptr ) +RefPtrI::RefPtrI(T *ptr) : __ptr(ptr) {} template RefPtrI::~RefPtrI() { - if(__cnt.one()) delete __ptr; + if (__cnt.one()) delete __ptr; } } /* namespace DBus */ diff --git a/include/dbus-c++/server.h b/include/dbus-c++/server.h index 4259e30..590452b 100644 --- a/include/dbus-c++/server.h +++ b/include/dbus-c++/server.h @@ -47,15 +47,15 @@ class DXXAPI Server { public: - Server( const char* address ); + Server(const char *address); - Dispatcher* setup( Dispatcher* ); + Dispatcher *setup(Dispatcher *); virtual ~Server(); bool listening() const; - bool operator == ( const Server& ) const; + bool operator == (const Server &) const; void disconnect(); @@ -63,10 +63,10 @@ public: protected: - Server( const Server& s ) + Server(const Server &s) {} - virtual void on_new_connection( Connection& c ) = 0; + virtual void on_new_connection(Connection &c) = 0; private: diff --git a/include/dbus-c++/types.h b/include/dbus-c++/types.h index aad9703..c783f4e 100644 --- a/include/dbus-c++/types.h +++ b/include/dbus-c++/types.h @@ -54,9 +54,9 @@ typedef std::string String; struct DXXAPI Path : public std::string { Path() {} - Path( const std::string& s ) : std::string(s) {} - Path( const char* c ) : std::string(c) {} - Path& operator = ( std::string& s ) + Path(const std::string &s) : std::string(s) {} + Path(const char *c) : std::string(c) {} + Path &operator = (std::string &s) { std::string::operator = (s); return *this; @@ -66,9 +66,9 @@ struct DXXAPI Path : public std::string struct DXXAPI Signature : public std::string { Signature() {} - Signature( const std::string& s ) : std::string(s) {} - Signature( const char* c ) : std::string(c) {} - Signature& operator = ( std::string& s ) + Signature(const std::string &s) : std::string(s) {} + Signature(const char *c) : std::string(c) {} + Signature &operator = (std::string &s) { std::string::operator = (s); return *this; @@ -83,9 +83,9 @@ public: Variant(); - Variant( MessageIter& it ); + Variant(MessageIter &it); - Variant& operator = ( const Variant& v ); + Variant &operator = (const Variant &v); const Signature signature() const; @@ -131,7 +131,7 @@ struct Struct }; template -inline bool dict_has_key( const std::map& map, const K& key ) +inline bool dict_has_key(const std::map& map, const K &key) { return map.find(key) != map.end(); } @@ -198,91 +198,91 @@ struct type< Struct > } /* namespace DBus */ -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Invalid& ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Invalid &) { return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Byte& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Byte &val) { iter.append_byte(val); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Bool& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Bool &val) { iter.append_bool(val); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int16& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Int16& val) { iter.append_int16(val); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt16& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::UInt16& val) { iter.append_uint16(val); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int32& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Int32& val) { iter.append_int32(val); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt32& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::UInt32& val) { iter.append_uint32(val); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Int64& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Int64& val) { iter.append_int64(val); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::UInt64& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::UInt64& val) { iter.append_uint64(val); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Double& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Double &val) { iter.append_double(val); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::String& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::String &val) { iter.append_string(val.c_str()); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Path& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Path &val) { iter.append_path(val.c_str()); return iter; } -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Signature& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Signature &val) { iter.append_signature(val.c_str()); return iter; } template -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vector& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vector& val) { const std::string sig = DBus::type::sig(); DBus::MessageIter ait = iter.new_array(sig.c_str()); typename std::vector::const_iterator vit; - for(vit = val.begin(); vit != val.end(); ++vit) + for (vit = val.begin(); vit != val.end(); ++vit) { ait << *vit; } @@ -292,7 +292,7 @@ inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vect } template<> -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vector& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vector& val) { DBus::MessageIter ait = iter.new_array("y"); ait.append_array('y', &val.front(), val.size()); @@ -301,13 +301,13 @@ inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::vect } template -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const std::map& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::map& val) { const std::string sig = "{" + DBus::type::sig() + DBus::type::sig() + "}"; DBus::MessageIter ait = iter.new_array(sig.c_str()); typename std::map::const_iterator mit; - for(mit = val.begin(); mit != val.end(); ++mit) + for (mit = val.begin(); mit != val.end(); ++mit) { DBus::MessageIter eit = ait.new_dict_entry(); @@ -330,7 +330,7 @@ template < typename T7, typename T8 > -inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Struct& val ) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Struct& val) { /* const std::string sig = DBus::type::sig() + DBus::type::sig() + DBus::type::sig() + DBus::type::sig() + @@ -345,97 +345,97 @@ inline DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Str return iter; } -extern DXXAPI DBus::MessageIter& operator << ( DBus::MessageIter& iter, const DBus::Variant& val ); +extern DXXAPI DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Variant &val); /* */ -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Invalid& ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Invalid &) { return iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Byte& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Byte &val) { val = iter.get_byte(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Bool& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Bool &val) { val = iter.get_bool(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int16& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Int16& val) { val = iter.get_int16(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt16& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::UInt16& val) { val = iter.get_uint16(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int32& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Int32& val) { val = iter.get_int32(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt32& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::UInt32& val) { val = iter.get_uint32(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Int64& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Int64& val) { val = iter.get_int64(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::UInt64& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::UInt64& val) { val = iter.get_uint64(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Double& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Double &val) { val = iter.get_double(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::String& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::String &val) { val = iter.get_string(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Path& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Path &val) { val = iter.get_path(); return ++iter; } -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Signature& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Signature &val) { val = iter.get_signature(); return ++iter; } template -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector& val) { - if(!iter.is_array()) + if (!iter.is_array()) throw DBus::ErrorInvalidArgs("array expected"); DBus::MessageIter ait = iter.recurse(); - while(!ait.at_end()) + while (!ait.at_end()) { E elem; @@ -447,17 +447,17 @@ inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector& } template<> -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector& val) { - if(!iter.is_array()) + if (!iter.is_array()) throw DBus::ErrorInvalidArgs("array expected"); - if(iter.array_type() != 'y') + if (iter.array_type() != 'y') throw DBus::ErrorInvalidArgs("byte-array expected"); DBus::MessageIter ait = iter.recurse(); - DBus::Byte* array; + DBus::Byte *array; size_t length = ait.get_array(&array); val.insert(val.end(), array, array+length); @@ -466,14 +466,14 @@ inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::vector -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, std::map& val ) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::map& val) { - if(!iter.is_dict()) + if (!iter.is_dict()) throw DBus::ErrorInvalidArgs("dictionary value expected"); DBus::MessageIter mit = iter.recurse(); - while(!mit.at_end()) + while (!mit.at_end()) { K key; V value; @@ -499,7 +499,7 @@ template < typename T7, typename T8 > -inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Struct& val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Struct& val) { DBus::MessageIter sit = iter.recurse(); @@ -508,7 +508,7 @@ inline DBus::MessageIter& operator >> ( DBus::MessageIter& iter, DBus::Struct> ( DBus::MessageIter& iter, DBus::Variant& val ); +extern DXXAPI DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Variant &val); #endif//__DBUSXX_TYPES_H diff --git a/include/dbus-c++/util.h b/include/dbus-c++/util.h index 9f2807a..071ad30 100644 --- a/include/dbus-c++/util.h +++ b/include/dbus-c++/util.h @@ -48,7 +48,7 @@ public: (*__ref) = 1; } - RefCnt( const RefCnt& rc ) + RefCnt(const RefCnt &rc) { __ref = rc.__ref; ref(); @@ -59,7 +59,7 @@ public: unref(); } - RefCnt& operator = ( const RefCnt& ref ) + RefCnt &operator = (const RefCnt &ref) { ref.ref(); unref(); @@ -87,12 +87,12 @@ private: { -- (*__ref); - if( (*__ref) < 0 ) + if ((*__ref) < 0) { debug_log("%p: refcount dropped below zero!", __ref); } - if( noref() ) + if (noref()) { delete __ref; } @@ -112,15 +112,15 @@ class RefPtrI // RefPtr to incomplete type { public: - RefPtrI( T* ptr = 0 ); + RefPtrI(T *ptr = 0); ~RefPtrI(); - RefPtrI& operator = ( const RefPtrI& ref ) + RefPtrI &operator = (const RefPtrI &ref) { - if( this != &ref ) + if (this != &ref) { - if(__cnt.one()) delete __ptr; + if (__cnt.one()) delete __ptr; __ptr = ref.__ptr; __cnt = ref.__cnt; @@ -128,28 +128,28 @@ public: return *this; } - T& operator *() const + T &operator *() const { return *__ptr; } - T* operator ->() const + T *operator ->() const { - if(__cnt.noref()) return 0; + if (__cnt.noref()) return 0; return __ptr; } - T* get() const + T *get() const { - if(__cnt.noref()) return 0; + if (__cnt.noref()) return 0; return __ptr; } private: - T* __ptr; + T *__ptr; RefCnt __cnt; }; @@ -158,20 +158,20 @@ class RefPtr { public: - RefPtr( T* ptr = 0) + RefPtr(T *ptr = 0) : __ptr(ptr) {} ~RefPtr() { - if(__cnt.one()) delete __ptr; + if (__cnt.one()) delete __ptr; } - RefPtr& operator = ( const RefPtr& ref ) + RefPtr &operator = (const RefPtr &ref) { - if( this != &ref ) + if (this != &ref) { - if(__cnt.one()) delete __ptr; + if (__cnt.one()) delete __ptr; __ptr = ref.__ptr; __cnt = ref.__cnt; @@ -179,28 +179,28 @@ public: return *this; } - T& operator *() const + T &operator *() const { return *__ptr; } - T* operator ->() const + T *operator ->() const { - if(__cnt.noref()) return 0; + if (__cnt.noref()) return 0; return __ptr; } - T* get() const + T *get() const { - if(__cnt.noref()) return 0; + if (__cnt.noref()) return 0; return __ptr; } private: - T* __ptr; + T *__ptr; RefCnt __cnt; }; @@ -213,7 +213,7 @@ class Callback_Base { public: - virtual R call( P param ) const = 0; + virtual R call(P param) const = 0; virtual ~Callback_Base() {} @@ -224,21 +224,21 @@ class Slot { public: - Slot& operator = ( Callback_Base* s ) + Slot &operator = (Callback_Base* s) { _cb = s; return *this; } - R operator()( P param ) const + R operator()(P param) const { - /*if(_cb.get())*/ return _cb->call(param); + /*if (_cb.get())*/ return _cb->call(param); } - R call( P param ) const + R call(P param) const { - /*if(_cb.get())*/ return _cb->call(param); + /*if (_cb.get())*/ return _cb->call(param); } bool empty() @@ -258,18 +258,18 @@ public: typedef R (C::*M)(P); - Callback( C* c, M m ) + Callback(C *c, M m) : _c(c), _m(m) {} - R call( P param ) const + R call(P param) const { - /*if(_c)*/ return (_c->*_m)(param); + /*if (_c)*/ return (_c->*_m)(param); } private: - C* _c; M _m; + C *_c; M _m; }; } /* namespace DBus */ diff --git a/src/connection.cpp b/src/connection.cpp index bf43a99..08f573a 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -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::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( + disconn_filter = new Callback( 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(data); + Private *p = static_cast(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(data); + MessageSlot *slot = static_cast(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& 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 eec96e3..2164382 100644 --- a/src/connection_p.h +++ b/src/connection_p.h @@ -42,30 +42,30 @@ namespace DBus { struct DXXAPILOCAL Connection::Private { - DBusConnection* conn; + DBusConnection * conn; std::vector 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 69d2d08..4ca2c78 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -28,13 +28,13 @@ #include #include -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 bed88f8..68c4412 100644 --- a/src/dispatcher.cpp +++ b/src/dispatcher.cpp @@ -30,118 +30,118 @@ #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 { - return dbus_watch_get_fd((DBusWatch*)_int); + return dbus_watch_get_fd((DBusWatch *)_int); } 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(data); + Dispatcher *d = static_cast(data); - Watch::Internal* w = reinterpret_cast(watch); + Watch::Internal *w = reinterpret_cast(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(data); + Dispatcher *d = static_cast(data); - Watch* w = static_cast(dbus_watch_get_data(watch)); + Watch *w = static_cast(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(dbus_watch_get_data(watch)); + Watch *w = static_cast(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(data); + Dispatcher *d = static_cast(data); - Timeout::Internal* t = reinterpret_cast(timeout); + Timeout::Internal *t = reinterpret_cast(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(data); + Dispatcher *d = static_cast(data); - Timeout* t = static_cast(dbus_timeout_get_data(timeout)); + Timeout *t = static_cast(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(dbus_timeout_get_data(timeout)); + Timeout *t = static_cast(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); @@ -152,19 +152,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 be2dea7..ece33b7 100644 --- a/src/dispatcher_p.h +++ b/src/dispatcher_p.h @@ -39,17 +39,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 9225117..23f7bec 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -39,17 +39,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); @@ -59,12 +59,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; } @@ -74,12 +74,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 b9a4b12..ca72ca8 100644 --- a/src/eventloop-integration.cpp +++ b/src/eventloop-integration.cpp @@ -31,7 +31,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()); @@ -44,14 +44,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); @@ -71,7 +71,7 @@ void BusDispatcher::enter() _running = true; - while(_running) + while (_running) { do_iteration(); } @@ -90,72 +90,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(this, &BusDispatcher::timeout_expired); + bt->expired = new Callback(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(this, &BusDispatcher::watch_ready); + bw->ready = new Callback(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(et.data()); + BusTimeout *timeout = reinterpret_cast(et.data()); timeout->handle(); } -void BusDispatcher::watch_ready( DefaultWatch& ew ) +void BusDispatcher::watch_ready(DefaultWatch &ew) { - BusWatch* watch = reinterpret_cast(ew.data()); + BusWatch *watch = reinterpret_cast(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 ae09bca..c6f95ef 100644 --- a/src/eventloop.cpp +++ b/src/eventloop.cpp @@ -32,12 +32,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; @@ -57,7 +57,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(); @@ -121,7 +121,7 @@ DefaultMainLoop::~DefaultMainLoop() _mutex_w.lock(); DefaultWatches::iterator wi = _watches.begin(); - while(wi != _watches.end()) + while (wi != _watches.end()) { DefaultWatches::iterator wmp = wi; ++wmp; @@ -135,7 +135,7 @@ DefaultMainLoop::~DefaultMainLoop() _mutex_t.lock(); DefaultTimeouts::iterator ti = _timeouts.begin(); - while(ti != _timeouts.end()) + while (ti != _timeouts.end()) { DefaultTimeouts::iterator tmp = ti; ++tmp; @@ -157,9 +157,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(); @@ -176,9 +176,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(); } @@ -195,16 +195,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; } @@ -218,18 +218,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 5583995..bde3c7a 100644 --- a/src/glib-integration.cpp +++ b/src/glib-integration.cpp @@ -28,7 +28,7 @@ using namespace DBus; -Glib::BusTimeout::BusTimeout( Timeout::Internal* ti, GMainContext* ctx, int priority ) +Glib::BusTimeout::BusTimeout(Timeout::Internal *ti, GMainContext *ctx, int priority) : Timeout(ti), _ctx(ctx), _priority(priority) { _enable(); @@ -43,13 +43,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(data); + Glib::BusTimeout *t = reinterpret_cast(data); t->handle(); @@ -75,7 +75,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"); @@ -83,15 +83,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"); @@ -107,7 +107,7 @@ static GSourceFuncs watch_funcs = { NULL }; -Glib::BusWatch::BusWatch( Watch::Internal* wi, GMainContext* ctx, int priority ) +Glib::BusWatch::BusWatch(Watch::Internal *wi, GMainContext *ctx, int priority) : Watch(wi), _ctx(ctx), _priority(priority) { _enable(); @@ -122,24 +122,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(data); + Glib::BusWatch *w = reinterpret_cast(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); @@ -156,16 +156,16 @@ void Glib::BusWatch::_enable() 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; @@ -176,35 +176,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, _priority); + 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, _priority); + 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() @@ -212,7 +212,7 @@ 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); diff --git a/src/interface.cpp b/src/interface.cpp index 57a24fa..89a4573 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -29,21 +29,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()); @@ -51,14 +51,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 { @@ -66,21 +66,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(sig); + SignalMessage &sig2 = const_cast(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); @@ -88,18 +88,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; @@ -108,14 +108,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()); @@ -123,14 +123,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 @@ -143,10 +143,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(call); + CallMessage &call2 = const_cast(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 0f287e1..1cc1fca 100644 --- a/src/internalerror.h +++ b/src/internalerror.h @@ -44,16 +44,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(&(ie.error)), &error); + dbus_move_error(const_cast(&(ie.error)), &error); } ~InternalError() @@ -61,7 +61,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 f9da790..88b61a1 100644 --- a/src/introspection.cpp +++ b/src/introspection.cpp @@ -32,7 +32,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) @@ -40,7 +40,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"); @@ -54,37 +54,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\tname << "\">"; - 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\tname << "\"" << " 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\tname << "\">"; - for(const IntrospectedArgument* a = m->args; a->type; ++a) + for (const IntrospectedArgument *a = m->args; a->type; ++a) { xml << "\n\t\t\tin ? "in" : "out") << "\"" << " type=\"" << a->type << "\""; - if(a->name) xml << " name=\"" << a->name << "\""; + if (a->name) xml << " name=\"" << a->name << "\""; xml << "/>"; } @@ -92,15 +92,15 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call ) xml << "\n\t\t"; } - for(const IntrospectedMethod* m = intro->signals; m->args; ++m) + for (const IntrospectedMethod *m = intro->signals; m->args; ++m) { xml << "\n\t\tname << "\">"; - for(const IntrospectedArgument* a = m->args; a->type; ++a) + for (const IntrospectedArgument *a = m->args; a->type; ++a) { xml << "type << "\""; - if(a->name) xml << " name=\"" << a->name << "\""; + if (a->name) xml << " name=\"" << a->name << "\""; xml << "/>"; } @@ -114,7 +114,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"; } @@ -124,7 +124,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('/')); @@ -141,7 +141,7 @@ Message IntrospectableAdaptor::Introspect( const CallMessage& call ) return reply; } -IntrospectedInterface* const IntrospectableAdaptor::introspect() const +IntrospectedInterface *const IntrospectableAdaptor::introspect() const { static IntrospectedArgument Introspect_args[] = { @@ -184,7 +184,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 cb96694..119bff8 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -37,7 +37,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() @@ -47,12 +47,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); } @@ -63,20 +63,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); } @@ -88,7 +88,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); @@ -101,7 +101,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); } @@ -113,7 +113,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); } @@ -125,7 +125,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); } @@ -137,7 +137,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); } @@ -156,7 +156,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); } @@ -168,7 +168,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); } @@ -180,43 +180,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; } @@ -224,56 +224,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; } @@ -282,7 +282,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; } @@ -291,19 +291,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': @@ -323,11 +323,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()); @@ -338,17 +338,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); @@ -366,13 +366,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); @@ -383,9 +383,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; @@ -396,11 +396,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); @@ -431,27 +431,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); } @@ -461,7 +461,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); } @@ -469,14 +469,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(*this)); - dbus_message_iter_init(_pvt->msg, (DBusMessageIter*)&(iter._iter)); + MessageIter iter(const_cast(*this)); + dbus_message_iter_init(_pvt->msg, (DBusMessageIter *)&(iter._iter)); return iter; } @@ -488,22 +488,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); } @@ -511,55 +511,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); } @@ -572,54 +572,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); } @@ -627,12 +627,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 c080d01..af421bc 100644 --- a/src/message_p.h +++ b/src/message_p.h @@ -38,12 +38,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 b18d9cc..8bf22a8 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -36,8 +36,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 : "") { } @@ -47,8 +47,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 = @@ -58,16 +58,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(data); + ObjectAdaptor *o = static_cast(data); - if( o ) + if (o) { Message msg(new Message::Private(dmsg)); @@ -88,20 +88,20 @@ DBusHandlerResult ObjectAdaptor::Private::message_function_stub( DBusConnection* } } -typedef std::map ObjectAdaptorTable; +typedef std::map 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; @@ -109,9 +109,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; @@ -120,7 +120,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; @@ -128,9 +128,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('/')); @@ -145,8 +145,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(); } @@ -160,7 +160,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"); } @@ -177,7 +177,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()); @@ -186,35 +186,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(msg); - const char* member = cmsg.member(); - const char* interface = cmsg.interface(); + const CallMessage &cmsg = reinterpret_cast(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); } @@ -232,13 +232,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); @@ -249,7 +249,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())); @@ -260,14 +260,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 @@ -276,8 +276,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(); } @@ -291,12 +291,12 @@ void ObjectProxy::register_obj() { debug_log("registering remote object %s", path().c_str()); - _filtered = new Callback(this, &ObjectProxy::handle_message); + _filtered = new Callback(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()); @@ -309,7 +309,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()); @@ -318,7 +318,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()); @@ -326,24 +326,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(msg); - const char* interface = smsg.interface(); - const char* member = smsg.member(); - const char* objpath = smsg.path(); + const SignalMessage &smsg = reinterpret_cast(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 4696983..e55c174 100644 --- a/src/pendingcall.cpp +++ b/src/pendingcall.cpp @@ -32,10 +32,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"); } @@ -43,30 +43,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(data); + PendingCall::Private *pvt = static_cast(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); @@ -77,9 +77,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; @@ -103,37 +103,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& PendingCall::slot() +Slot& 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 0c5e7bc..1768b52 100644 --- a/src/pendingcall_p.h +++ b/src/pendingcall_p.h @@ -38,15 +38,15 @@ namespace DBus { struct DXXAPILOCAL PendingCall::Private { - DBusPendingCall* call; + DBusPendingCall *call; int dataslot; - Slot slot; + Slot 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 bd196cd..b80c1da 100644 --- a/src/property.cpp +++ b/src/property.cpp @@ -28,7 +28,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) @@ -37,7 +37,7 @@ PropertiesAdaptor::PropertiesAdaptor() register_method(PropertiesAdaptor, Set, Set); } -Message PropertiesAdaptor::Get( const CallMessage& call ) +Message PropertiesAdaptor::Get(const CallMessage &call) { MessageIter ri = call.reader(); @@ -48,14 +48,14 @@ Message PropertiesAdaptor::Get( const CallMessage& call ) 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); @@ -68,7 +68,7 @@ Message PropertiesAdaptor::Get( const CallMessage& call ) return reply; } -Message PropertiesAdaptor::Set( const CallMessage& call ) +Message PropertiesAdaptor::Set(const CallMessage &call) { MessageIter ri = call.reader(); @@ -78,9 +78,9 @@ Message PropertiesAdaptor::Set( const CallMessage& call ) 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); @@ -92,7 +92,7 @@ Message PropertiesAdaptor::Set( const CallMessage& call ) return reply; } -IntrospectedInterface* const PropertiesAdaptor::introspect() const +IntrospectedInterface *const PropertiesAdaptor::introspect() const { static IntrospectedArgument Get_args[] = { @@ -137,14 +137,14 @@ PropertiesProxy::PropertiesProxy() { } -Variant PropertiesProxy::Get( const String& iface, const String& property ) +Variant PropertiesProxy::Get(const String &iface, const String &property) { //todo Variant v; return v; } -void PropertiesProxy::Set( const String& iface, const String& property, const Variant& value ) +void PropertiesProxy::Set(const String &iface, const String &property, const Variant &value) { //todo } diff --git a/src/server.cpp b/src/server.cpp index b45845d..eae46d6 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -32,7 +32,7 @@ using namespace DBus; -Server::Private::Private( DBusServer* s ) +Server::Private::Private(DBusServer *s) : server(s) { } @@ -41,9 +41,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(data); + Server *s = static_cast(data); Connection nc (new Connection::Private(conn, s->_pvt.get())); @@ -54,12 +54,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); @@ -70,7 +70,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); @@ -81,11 +81,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, @@ -110,7 +110,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 7eb4608..6264ebf 100644 --- a/src/server_p.h +++ b/src/server_p.h @@ -39,17 +39,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 de91655..a144f78 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -38,7 +38,7 @@ Variant::Variant() { } -Variant::Variant( MessageIter& it ) +Variant::Variant(MessageIter &it) : _msg(CallMessage()) { MessageIter vi = it.recurse(); @@ -46,9 +46,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; } @@ -63,7 +63,7 @@ void Variant::clear() const Signature Variant::signature() const { - char* sigbuf = reader().signature(); + char *sigbuf = reader().signature(); Signature signature = sigbuf; @@ -72,7 +72,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(); @@ -86,9 +86,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(); diff --git a/tools/introspect.cpp b/tools/introspect.cpp index d25d8c6..8ce9f3a 100644 --- a/tools/introspect.cpp +++ b/tools/introspect.cpp @@ -29,10 +29,10 @@ DBus::BusDispatcher dispatcher; static bool systembus; -static char* path; -static char* service; +static char *path; +static char *service; -void niam( int sig ) +void niam(int sig) { DBus::Connection conn = systembus ? DBus::Connection::SystemBus() : DBus::Connection::SessionBus(); @@ -43,19 +43,19 @@ void niam( int sig ) dispatcher.leave(); } -int main( int argc, char** argv ) +int main(int argc, char ** argv) { signal(SIGTERM, niam); signal(SIGINT, niam); signal(SIGALRM, niam); - if(argc == 1) + if (argc == 1) { std::cerr << std::endl << "Usage: " << argv[0] << " [--system] []" << std::endl << std::endl; } else { - if(strcmp(argv[1], "--system")) + if (strcmp(argv[1], "--system")) { systembus = false; path = argv[1]; diff --git a/tools/introspect.h b/tools/introspect.h index 3633611..1c6e326 100644 --- a/tools/introspect.h +++ b/tools/introspect.h @@ -36,7 +36,7 @@ class IntrospectedObject : public DBus::IntrospectableProxy, public DBus::Object { public: - IntrospectedObject( DBus::Connection& conn, const char* path, const char* service ) + IntrospectedObject(DBus::Connection &conn, const char *path, const char *service) : DBus::ObjectProxy(conn, path, service) {} }; diff --git a/tools/xml.cpp b/tools/xml.cpp index 69b403e..68ae5a6 100644 --- a/tools/xml.cpp +++ b/tools/xml.cpp @@ -28,7 +28,7 @@ #include -std::istream& operator >> ( std::istream& in, DBus::Xml::Document& doc ) +std::istream &operator >> (std::istream &in, DBus::Xml::Document &doc) { std::stringbuf xmlbuf; in.get(xmlbuf, '\0'); @@ -37,7 +37,7 @@ std::istream& operator >> ( std::istream& in, DBus::Xml::Document& doc ) return in; } -std::ostream& operator << ( std::ostream& out, const DBus::Xml::Document& doc ) +std::ostream &operator << (std::ostream &out, const DBus::Xml::Document &doc) { return out << doc.to_xml(); } @@ -45,7 +45,7 @@ std::ostream& operator << ( std::ostream& out, const DBus::Xml::Document& doc ) using namespace DBus; using namespace DBus::Xml; -Error::Error( const char* error, int line, int column ) +Error::Error(const char *error, int line, int column) { std::ostringstream estream; @@ -54,11 +54,11 @@ Error::Error( const char* error, int line, int column ) _error = estream.str(); } -Node::Node( const char* n, const char** a ) +Node::Node(const char *n, const char ** a) : name(n) { - if(a) - for(int i = 0; a[i]; i += 2) + if (a) + for (int i = 0; a[i]; i += 2) { _attrs[a[i]] = a[i+1]; @@ -66,11 +66,11 @@ Node::Node( const char* n, const char** a ) } } -Nodes Nodes::operator[]( const std::string& key ) +Nodes Nodes::operator[](const std::string &key) { Nodes result; - for(iterator i = begin(); i != end(); ++i) + for (iterator i = begin(); i != end(); ++i) { Nodes part = (**i)[key]; @@ -79,43 +79,43 @@ Nodes Nodes::operator[]( const std::string& key ) return result; } -Nodes Nodes::select( const std::string& attr, const std::string& value ) +Nodes Nodes::select(const std::string &attr, const std::string &value) { Nodes result; - for(iterator i = begin(); i != end(); ++i) + for (iterator i = begin(); i != end(); ++i) { - if((*i)->get(attr) == value) + if ((*i)->get(attr) == value) result.insert(result.end(), *i); } return result; } -Nodes Node::operator[]( const std::string& key ) +Nodes Node::operator[](const std::string &key) { Nodes result; - if(key.length() == 0) return result; + if (key.length() == 0) return result; - for(Children::iterator i = children.begin(); i != children.end(); ++i) + for (Children::iterator i = children.begin(); i != children.end(); ++i) { - if(i->name == key) + if (i->name == key) result.push_back(&(*i)); } return result; } -std::string Node::get( const std::string& attribute ) +std::string Node::get(const std::string &attribute) { - if(_attrs.find(attribute) != _attrs.end()) + if (_attrs.find(attribute) != _attrs.end()) return _attrs[attribute]; else return ""; } -void Node::set( const std::string& attribute, std::string value ) +void Node::set(const std::string &attribute, std::string value) { - if(value.length()) + if (value.length()) _attrs[attribute] = value; else _attrs.erase(value); @@ -131,17 +131,17 @@ std::string Node::to_xml() const return xml; } -void Node::_raw_xml( std::string& xml, int& depth ) const +void Node::_raw_xml(std::string &xml, int &depth) const { - xml.append(depth*2, ' '); + xml.append(depth *2, ' '); xml.append("<"+name); - for(Attributes::const_iterator i = _attrs.begin(); i != _attrs.end(); ++i) + for (Attributes::const_iterator i = _attrs.begin(); i != _attrs.end(); ++i) { xml.append(" "+i->first+"=\""+i->second+"\""); } - if(cdata.length() == 0 && children.size() == 0) + if (cdata.length() == 0 && children.size() == 0) { xml.append("/>\n"); } @@ -149,23 +149,23 @@ void Node::_raw_xml( std::string& xml, int& depth ) const { xml.append(">"); - if(cdata.length()) + if (cdata.length()) { xml.append(cdata); } - if(children.size()) + if (children.size()) { xml.append("\n"); depth++; - for(Children::const_iterator i = children.begin(); i != children.end(); ++i) + for (Children::const_iterator i = children.begin(); i != children.end(); ++i) { i->_raw_xml(xml, depth); } depth--; - xml.append(depth*2, ' '); + xml.append(depth *2, ' '); } xml.append("\n"); } @@ -176,7 +176,7 @@ Document::Document() { } -Document::Document( const std::string& xml ) +Document::Document(const std::string &xml) : root(0), _depth(0) { from_xml(xml); @@ -190,15 +190,15 @@ Document::~Document() struct Document::Expat { static void start_doctype_decl_handler( - void* data, const XML_Char* name, const XML_Char* sysid, const XML_Char* pubid, int has_internal_subset + void *data, const XML_Char *name, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset ); - static void end_doctype_decl_handler( void* data ); - static void start_element_handler( void *data, const XML_Char *name, const XML_Char **atts ); - static void character_data_handler( void *data, const XML_Char* chars, int len ); - static void end_element_handler( void *data, const XML_Char *name ); + static void end_doctype_decl_handler(void *data); + static void start_element_handler(void *data, const XML_Char *name, const XML_Char **atts); + static void character_data_handler(void *data, const XML_Char *chars, int len); + static void end_element_handler(void *data, const XML_Char *name); }; -void Document::from_xml( const std::string& xml ) +void Document::from_xml(const std::string &xml) { _depth = 0; delete root; @@ -227,9 +227,9 @@ void Document::from_xml( const std::string& xml ) XML_Status status = XML_Parse(parser, xml.c_str(), xml.length(), true); - if(status == XML_STATUS_ERROR) + if (status == XML_STATUS_ERROR) { - const char* error = XML_ErrorString(XML_GetErrorCode(parser)); + const char *error = XML_ErrorString(XML_GetErrorCode(parser)); int line = XML_GetCurrentLineNumber(parser); int column = XML_GetCurrentColumnNumber(parser); @@ -249,30 +249,30 @@ std::string Document::to_xml() const } void Document::Expat::start_doctype_decl_handler( - void* data, const XML_Char* name, const XML_Char* sysid, const XML_Char* pubid, int has_internal_subset + void *data, const XML_Char *name, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset ) { } -void Document::Expat::end_doctype_decl_handler( void* data ) +void Document::Expat::end_doctype_decl_handler(void *data) { } -void Document::Expat::start_element_handler( void *data, const XML_Char *name, const XML_Char **atts ) +void Document::Expat::start_element_handler(void *data, const XML_Char *name, const XML_Char **atts) { - Document* doc = (Document*)data; + Document *doc = (Document *)data; //debug_log("xml:%d -> %s", doc->_depth, name); - if(!doc->root) + if (!doc->root) { doc->root = new Node(name, atts); } else { - Node::Children* cld = &(doc->root->children); + Node::Children *cld = &(doc->root->children); - for(int i = 1; i < doc->_depth; ++i) + for (int i = 1; i < doc->_depth; ++i) { cld = &(cld->back().children); } @@ -283,13 +283,13 @@ void Document::Expat::start_element_handler( void *data, const XML_Char *name, c doc->_depth++; } -void Document::Expat::character_data_handler( void *data, const XML_Char* chars, int len ) +void Document::Expat::character_data_handler(void *data, const XML_Char *chars, int len) { - Document* doc = (Document*)data; + Document *doc = (Document *)data; - Node* nod = doc->root; + Node *nod = doc->root; - for(int i = 1; i < doc->_depth; ++i) + for (int i = 1; i < doc->_depth; ++i) { nod = &(nod->children.back()); } @@ -298,15 +298,15 @@ void Document::Expat::character_data_handler( void *data, const XML_Char* chars, x = 0; y = len-1; - while(isspace(chars[y]) && y > 0) --y; - while(isspace(chars[x]) && x < y) ++x; + while (isspace(chars[y]) && y > 0) --y; + while (isspace(chars[x]) && x < y) ++x; nod->cdata = std::string(chars, x, y+1); } -void Document::Expat::end_element_handler( void *data, const XML_Char *name ) +void Document::Expat::end_element_handler(void *data, const XML_Char *name) { - Document* doc = (Document*)data; + Document *doc = (Document *)data; //debug_log("xml:%d <- %s", doc->_depth, name); diff --git a/tools/xml.h b/tools/xml.h index 79574c0..6a8e69c 100644 --- a/tools/xml.h +++ b/tools/xml.h @@ -44,12 +44,12 @@ class Error : public std::exception { public: - Error( const char* error, int line, int column ); + Error(const char *error, int line, int column); ~Error() throw() {} - const char* what() const throw() + const char *what() const throw() { return _error.c_str(); } @@ -61,13 +61,13 @@ private: class Node; -class Nodes : public std::vector +class Nodes : public std::vector { public: - Nodes operator[]( const std::string& key ); + Nodes operator[](const std::string &key); - Nodes select( const std::string& attr, const std::string& value ); + Nodes select(const std::string &attr, const std::string &value); }; class Node @@ -82,21 +82,21 @@ public: std::string cdata; Children children; - Node( std::string& n, Attributes& a ) + Node(std::string &n, Attributes &a) : name(n), _attrs(a) {} - Node( const char* n, const char** a = NULL ); + Node(const char *n, const char ** a = NULL); - Nodes operator[]( const std::string& key ); + Nodes operator[](const std::string &key); - std::string get( const std::string& attribute ); + std::string get(const std::string &attribute); - void set( const std::string& attribute, std::string value ); + void set(const std::string &attribute, std::string value); std::string to_xml() const; - Node& add( Node child ) + Node &add(Node child) { children.push_back(child); return children.back(); @@ -104,7 +104,7 @@ public: private: - void _raw_xml( std::string& xml, int& depth ) const; + void _raw_xml(std::string &xml, int &depth) const; Attributes _attrs; }; @@ -115,15 +115,15 @@ public: struct Expat; - Node* root; + Node *root; Document(); - Document( const std::string& xml ); + Document(const std::string &xml); ~Document(); - void from_xml( const std::string& xml ); + void from_xml(const std::string &xml); std::string to_xml() const; @@ -136,7 +136,7 @@ private: } /* namespace DBus */ -std::istream& operator >> ( std::istream&, DBus::Xml::Document& ); -std::ostream& operator << ( std::ostream&, DBus::Xml::Document& ); +std::istream &operator >> (std::istream &, DBus::Xml::Document &); +std::ostream &operator << (std::ostream &, DBus::Xml::Document &); #endif//__DBUSXX_XML_H diff --git a/tools/xml2cpp.cpp b/tools/xml2cpp.cpp index 144d9ff..3a7fbdf 100644 --- a/tools/xml2cpp.cpp +++ b/tools/xml2cpp.cpp @@ -37,55 +37,55 @@ using namespace std; using namespace DBus; -static const char* tab = " "; +static const char *tab = " "; -static const char* header = "\n\ +static const char *header = "\n\ /*\n\ * This file was automatically generated by dbusxx-xml2cpp; DO NOT EDIT!\n\ */\n\ \n\ "; -static const char* dbus_includes = "\n\ +static const char *dbus_includes = "\n\ #include \n\ \n\ "; typedef map TypeCache; -void usage( const char* argv0 ) +void usage(const char *argv0) { cerr << endl << "Usage: " << argv0 << " [ --proxy= ] [ --adaptor= ]" << endl << endl; exit(-1); } -void underscorize( string& str ) +void underscorize(string &str) { - for(unsigned int i = 0; i < str.length(); ++i) + for (unsigned int i = 0; i < str.length(); ++i) { - if(!isalpha(str[i]) && !isdigit(str[i])) str[i] = '_'; + if (!isalpha(str[i]) && !isdigit(str[i])) str[i] = '_'; } } -string stub_name( string name ) +string stub_name(string name) { underscorize(name); return "_" + name + "_stub"; } -int char_to_atomic_type( char t ) +int char_to_atomic_type(char t) { - if(strchr("ybnqiuxtdsgavre", t)) + if (strchr("ybnqiuxtdsgavre", t)) return t; return DBUS_TYPE_INVALID; } -const char* atomic_type_to_string( char t ) +const char *atomic_type_to_string(char t) { - static struct { char type; const char* name; } atos[] = + static struct { char type; const char *name; } atos[] = { { 'y', "::DBus::Byte" }, { 'b', "::DBus::Bool" }, @@ -104,34 +104,34 @@ const char* atomic_type_to_string( char t ) }; int i; - for(i = 0; atos[i].type; ++i) + for (i = 0; atos[i].type; ++i) { - if(atos[i].type == t) break; + if (atos[i].type == t) break; } return atos[i].name; } -bool is_atomic_type( const string& type ) +bool is_atomic_type(const string &type) { return type.length() == 1 && char_to_atomic_type(type[0]) != DBUS_TYPE_INVALID; } -void _parse_signature( const string& signature, string& type, unsigned int& i ) +void _parse_signature(const string &signature, string &type, unsigned int &i) { - for(; i < signature.length(); ++i) + for (; i < signature.length(); ++i) { - switch(signature[i]) + switch (signature[i]) { case 'a': { - switch(signature[++i]) + switch (signature[++i]) { case '{': { type += "std::map< "; - const char* atom = atomic_type_to_string(signature[++i]); - if(!atom) + const char *atom = atomic_type_to_string(signature[++i]); + if (!atom) { cerr << "invalid signature" << endl; exit(-1); @@ -157,7 +157,7 @@ void _parse_signature( const string& signature, string& type, unsigned int& i ) ++i; _parse_signature(signature, type, i); type += " >"; - if(signature[i+1]) + if (signature[i+1]) { type += ", "; } @@ -170,15 +170,15 @@ void _parse_signature( const string& signature, string& type, unsigned int& i ) } default: { - const char* atom = atomic_type_to_string(signature[i]); - if(!atom) + const char *atom = atomic_type_to_string(signature[i]); + if (!atom) { cerr << "invalid signature" << endl; exit(-1); } type += atom; - if(signature[i+1] != ')' && signature[i+1] != '}' && i+1 < signature.length()) + if (signature[i+1] != ')' && signature[i+1] != '}' && i+1 < signature.length()) { type += ", "; } @@ -188,7 +188,7 @@ void _parse_signature( const string& signature, string& type, unsigned int& i ) } } -string signature_to_type( const string& signature ) +string signature_to_type(const string &signature) { string type; unsigned int i = 0; @@ -196,12 +196,12 @@ string signature_to_type( const string& signature ) return type; } -void generate_proxy( Xml::Document& doc, const char* filename ) +void generate_proxy(Xml::Document &doc, const char *filename) { cerr << "writing " << filename << endl; ofstream file(filename); - if(file.bad()) + if (file.bad()) { cerr << "unable to write file " << filename << endl; exit(-1); @@ -218,12 +218,12 @@ void generate_proxy( Xml::Document& doc, const char* filename ) file << dbus_includes; - Xml::Node& root = *(doc.root); + Xml::Node &root = *(doc.root); Xml::Nodes interfaces = root["interface"]; - for(Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i) + for (Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i) { - Xml::Node& iface = **i; + Xml::Node &iface = **i; Xml::Nodes methods = iface["method"]; Xml::Nodes signals = iface["signal"]; Xml::Nodes properties = iface["property"]; @@ -232,7 +232,7 @@ void generate_proxy( Xml::Document& doc, const char* filename ) ms.insert(ms.end(), signals.begin(), signals.end()); string ifacename = iface.get("name"); - if(ifacename == "org.freedesktop.DBus.Introspectable" + if (ifacename == "org.freedesktop.DBus.Introspectable" ||ifacename == "org.freedesktop.DBus.Properties") { cerr << "skipping interface " << ifacename << endl; @@ -243,7 +243,7 @@ void generate_proxy( Xml::Document& doc, const char* filename ) string nspace; unsigned int nspaces = 0; - while(ss.str().find('.', ss.tellg()) != string::npos) + while (ss.str().find('.', ss.tellg()) != string::npos) { getline(ss, nspace, '.'); @@ -268,9 +268,9 @@ void generate_proxy( Xml::Document& doc, const char* filename ) << tab << ": ::DBus::InterfaceProxy(\"" << ifacename << "\")" << endl << tab << "{" << endl; - for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) + for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) { - Xml::Node& signal = **si; + Xml::Node &signal = **si; string marshname = "_" + signal.get("name") + "_stub"; @@ -288,75 +288,75 @@ void generate_proxy( Xml::Document& doc, const char* filename ) << tab << " * this functions will invoke the corresponding methods on the remote objects" << endl << tab << " */" << endl; - for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) + for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) { - Xml::Node& method = **mi; + Xml::Node &method = **mi; Xml::Nodes args = method["arg"]; Xml::Nodes args_in = args.select("direction","in"); Xml::Nodes args_out = args.select("direction","out"); - if(args_out.size() == 0 || args_out.size() > 1 ) + if (args_out.size() == 0 || args_out.size() > 1) { file << tab << "void "; } - else if(args_out.size() == 1) + else if (args_out.size() == 1) { file << tab << signature_to_type(args_out.front()->get("type")) << " "; } - file << method.get("name") << "( "; + file << method.get("name") << "("; unsigned int i = 0; - for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) + for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) { - Xml::Node& arg = **ai; + Xml::Node &arg = **ai; file << "const " << signature_to_type(arg.get("type")) << "& "; string arg_name = arg.get("name"); - if(arg_name.length()) + if (arg_name.length()) file << arg_name; else file << "argin" << i; - if((i+1 != args_in.size() || args_out.size() > 1)) + if ((i+1 != args_in.size() || args_out.size() > 1)) file << ", "; } - if(args_out.size() > 1) + if (args_out.size() > 1) { unsigned int i = 0; - for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) + for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) { - Xml::Node& arg = **ao; + Xml::Node &arg = **ao; file << signature_to_type(arg.get("type")) << "&"; string arg_name = arg.get("name"); - if(arg_name.length()) + if (arg_name.length()) file << " " << arg_name; else file << " argout" << i; - if(i+1 != args_out.size()) + if (i+1 != args_out.size()) file << ", "; } } - file << " )" << endl; + file << ")" << endl; file << tab << "{" << endl << tab << tab << "::DBus::CallMessage call;" << endl; - if(args_in.size() > 0) + if (args_in.size() > 0) { file << tab << tab << "::DBus::MessageIter wi = call.writer();" << endl << endl; } unsigned int j = 0; - for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++j) + for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++j) { - Xml::Node& arg = **ai; + Xml::Node &arg = **ai; string arg_name = arg.get("name"); - if(arg_name.length()) + if (arg_name.length()) file << tab << tab << "wi << " << arg_name << ";" << endl; else file << tab << tab << "wi << argin" << j << ";" << endl; @@ -366,27 +366,27 @@ void generate_proxy( Xml::Document& doc, const char* filename ) << tab << tab << "::DBus::Message ret = invoke_method(call);" << endl; - if(args_out.size() > 0) + if (args_out.size() > 0) { file << tab << tab << "::DBus::MessageIter ri = ret.reader();" << endl << endl; } - if(args_out.size() == 1) + if (args_out.size() == 1) { file << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout;" << endl; file << tab << tab << "ri >> argout;" << endl; file << tab << tab << "return argout;" << endl; } - else if(args_out.size() > 1) + else if (args_out.size() > 1) { unsigned int i = 0; - for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) + for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) { - Xml::Node& arg = **ao; + Xml::Node &arg = **ao; string arg_name = arg.get("name"); - if(arg_name.length()) + if (arg_name.length()) file << tab << tab << "ri >> " << arg.get("name") << ";" << endl; else file << tab << tab << "ri >> argout" << i << ";" << endl; @@ -403,29 +403,29 @@ void generate_proxy( Xml::Document& doc, const char* filename ) << tab << "/* signal handlers for this interface" << endl << tab << " */" << endl; - for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) + for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) { - Xml::Node& signal = **si; + Xml::Node &signal = **si; Xml::Nodes args = signal["arg"]; - file << tab << "virtual void " << signal.get("name") << "( "; + file << tab << "virtual void " << signal.get("name") << "("; unsigned int i = 0; - for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i) + for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i) { - Xml::Node& arg = **ai; + Xml::Node &arg = **ai; file << "const " << signature_to_type(arg.get("type")) << "& "; string arg_name = arg.get("name"); - if(arg_name.length()) + if (arg_name.length()) file << arg_name; else file << "argin" << i; - if((ai+1 != args.end())) + if ((ai+1 != args.end())) file << ", "; } - file << " ) = 0;" << endl; + file << ") = 0;" << endl; } file << endl @@ -434,28 +434,28 @@ void generate_proxy( Xml::Document& doc, const char* filename ) << tab << "/* unmarshalers (to unpack the DBus message before calling the actual signal handler)" << endl << tab << " */" << endl; - for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) + for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) { - Xml::Node& signal = **si; + Xml::Node &signal = **si; Xml::Nodes args = signal["arg"]; - file << tab << "void " << stub_name(signal.get("name")) << "( const ::DBus::SignalMessage& sig )" << endl + file << tab << "void " << stub_name(signal.get("name")) << "(const ::DBus::SignalMessage &sig)" << endl << tab << "{" << endl; - if(args.size() > 0) + if (args.size() > 0) { file << tab << tab << "::DBus::MessageIter ri = sig.reader();" << endl << endl; } unsigned int i = 0; - for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i) + for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i) { - Xml::Node& arg = **ai; + Xml::Node &arg = **ai; file << tab << tab << signature_to_type(arg.get("type")) << " " ; string arg_name = arg.get("name"); - if(arg_name.length()) + if (arg_name.length()) file << arg_name << ";" << " ri >> " << arg_name << ";" << endl; else file << "arg" << i << ";" << " ri >> " << "arg" << i << ";" << endl; @@ -464,17 +464,17 @@ void generate_proxy( Xml::Document& doc, const char* filename ) file << tab << tab << signal.get("name") << "("; unsigned int j = 0; - for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++j) + for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++j) { - Xml::Node& arg = **ai; + Xml::Node &arg = **ai; string arg_name = arg.get("name"); - if(arg_name.length()) + if (arg_name.length()) file << arg_name; else file << "arg" << j; - if(ai+1 != args.end()) + if (ai+1 != args.end()) file << ", "; } @@ -487,7 +487,7 @@ void generate_proxy( Xml::Document& doc, const char* filename ) file << "};" << endl << endl; - for(unsigned int i = 0; i < nspaces; ++i) + for (unsigned int i = 0; i < nspaces; ++i) { file << "} "; } @@ -499,12 +499,12 @@ void generate_proxy( Xml::Document& doc, const char* filename ) file.close(); } -void generate_adaptor( Xml::Document& doc, const char* filename ) +void generate_adaptor(Xml::Document &doc, const char *filename) { cerr << "writing " << filename << endl; ofstream file(filename); - if(file.bad()) + if (file.bad()) { cerr << "unable to write file " << filename << endl; exit(-1); @@ -521,12 +521,12 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) file << dbus_includes; - Xml::Node& root = *(doc.root); + Xml::Node &root = *(doc.root); Xml::Nodes interfaces = root["interface"]; - for(Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i) + for (Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i) { - Xml::Node& iface = **i; + Xml::Node &iface = **i; Xml::Nodes methods = iface["method"]; Xml::Nodes signals = iface["signal"]; Xml::Nodes properties = iface["property"]; @@ -535,7 +535,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) ms.insert(ms.end(), signals.begin(), signals.end()); string ifacename = iface.get("name"); - if(ifacename == "org.freedesktop.DBus.Introspectable" + if (ifacename == "org.freedesktop.DBus.Introspectable" ||ifacename == "org.freedesktop.DBus.Properties") { cerr << "skipping interface " << ifacename << endl; @@ -546,7 +546,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) string nspace; unsigned int nspaces = 0; - while(ss.str().find('.', ss.tellg()) != string::npos) + while (ss.str().find('.', ss.tellg()) != string::npos) { getline(ss, nspace, '.'); @@ -571,26 +571,26 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) << tab << ": ::DBus::InterfaceAdaptor(\"" << ifacename << "\")" << endl << tab << "{" << endl; - for(Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) + for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) { - Xml::Node& property = **pi; + Xml::Node &property = **pi; file << tab << tab << "bind_property(" << property.get("name") << ", " << "\"" << property.get("type") << "\", " - << ( property.get("access").find("read") != string::npos + << (property.get("access").find("read") != string::npos ? "true" - : "false" ) + : "false") << ", " - << ( property.get("access").find("write") != string::npos + << (property.get("access").find("write") != string::npos ? "true" - : "false" ) + : "false") << ");" << endl; } - for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) + for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) { - Xml::Node& method = **mi; + Xml::Node &method = **mi; file << tab << tab << "register_method(" << ifaceclass << ", " << method.get("name") << ", "<< stub_name(method.get("name")) @@ -600,24 +600,24 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) file << tab << "}" << endl << endl; - file << tab << "::DBus::IntrospectedInterface* const introspect() const " << endl + file << tab << "::DBus::IntrospectedInterface *const introspect() const " << endl << tab << "{" << endl; - for(Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi) + for (Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi) { - Xml::Node& method = **mi; + Xml::Node &method = **mi; Xml::Nodes args = method["arg"]; file << tab << tab << "static ::DBus::IntrospectedArgument " << method.get("name") << "_args[] = " << endl << tab << tab << "{" << endl; - for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai) + for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai) { - Xml::Node& arg = **ai; + Xml::Node &arg = **ai; file << tab << tab << tab << "{ "; - if(arg.get("name").length()) + if (arg.get("name").length()) { file << "\"" << arg.get("name") << "\", "; } @@ -626,7 +626,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) file << "0, "; } file << "\"" << arg.get("type") << "\", " - << ( arg.get("direction") == "in" ? "true" : "false" ) + << (arg.get("direction") == "in" ? "true" : "false") << " }," << endl; } file << tab << tab << tab << "{ 0, 0, 0 }" << endl @@ -636,9 +636,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) file << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_methods[] = " << endl << tab << tab << "{" << endl; - for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) + for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) { - Xml::Node& method = **mi; + Xml::Node &method = **mi; file << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl; } @@ -649,9 +649,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) file << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_signals[] = " << endl << tab << tab << "{" << endl; - for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) + for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) { - Xml::Node& method = **si; + Xml::Node &method = **si; file << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl; } @@ -662,20 +662,20 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) file << tab << tab << "static ::DBus::IntrospectedProperty " << ifaceclass << "_properties[] = " << endl << tab << tab << "{" << endl; - for(Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) + for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) { - Xml::Node& property = **pi; + Xml::Node &property = **pi; file << tab << tab << tab << "{ " << "\"" << property.get("name") << "\", " << "\"" << property.get("type") << "\", " - << ( property.get("access").find("read") != string::npos + << (property.get("access").find("read") != string::npos ? "true" - : "false" ) + : "false") << ", " - << ( property.get("access").find("write") != string::npos + << (property.get("access").find("write") != string::npos ? "true" - : "false" ) + : "false") << " }," << endl; } @@ -700,9 +700,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) << tab << " * property() and property(value) to get and set a particular property" << endl << tab << " */" << endl; - for(Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) + for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) { - Xml::Node& property = **pi; + Xml::Node &property = **pi; string name = property.get("name"); string type = property.get("type"); string type_name = signature_to_type(type); @@ -718,57 +718,57 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) << tab << " * you will have to implement them in your ObjectAdaptor" << endl << tab << " */" << endl; - for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) + for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) { - Xml::Node& method = **mi; + Xml::Node &method = **mi; Xml::Nodes args = method["arg"]; Xml::Nodes args_in = args.select("direction","in"); Xml::Nodes args_out = args.select("direction","out"); file << tab << "virtual "; - if(args_out.size() == 0 || args_out.size() > 1 ) + if (args_out.size() == 0 || args_out.size() > 1) { file << "void "; } - else if(args_out.size() == 1) + else if (args_out.size() == 1) { file << signature_to_type(args_out.front()->get("type")) << " "; } - file << method.get("name") << "( "; + file << method.get("name") << "("; unsigned int i = 0; - for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) + for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) { - Xml::Node& arg = **ai; + Xml::Node &arg = **ai; file << "const " << signature_to_type(arg.get("type")) << "& "; string arg_name = arg.get("name"); - if(arg_name.length()) + if (arg_name.length()) file << arg_name; - if((i+1 != args_in.size() || args_out.size() > 1)) + if ((i+1 != args_in.size() || args_out.size() > 1)) file << ", "; } - if(args_out.size() > 1) + if (args_out.size() > 1) { unsigned int i = 0; - for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) + for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) { - Xml::Node& arg = **ao; + Xml::Node &arg = **ao; file << signature_to_type(arg.get("type")) << "&"; string arg_name = arg.get("name"); - if(arg_name.length()) + if (arg_name.length()) file << " " << arg_name; - if(i+1 != args_out.size()) + if (i+1 != args_out.size()) file << ", "; } } - file << " ) = 0;" << endl; + file << ") = 0;" << endl; } file << endl @@ -777,34 +777,34 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) << tab << "/* signal emitters for this interface" << endl << tab << " */" << endl; - for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) + for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) { - Xml::Node& signal = **si; + Xml::Node &signal = **si; Xml::Nodes args = signal["arg"]; - file << tab << "void " << signal.get("name") << "( "; + file << tab << "void " << signal.get("name") << "("; unsigned int i = 0; - for(Xml::Nodes::iterator a = args.begin(); a != args.end(); ++a, ++i) + for (Xml::Nodes::iterator a = args.begin(); a != args.end(); ++a, ++i) { - Xml::Node& arg = **a; + Xml::Node &arg = **a; file << "const " << signature_to_type(arg.get("type")) << "& arg" << i+1; - if(i+1 != args.size()) + if (i+1 != args.size()) file << ", "; } - file << " )" << endl + file << ")" << endl << tab << "{" << endl << tab << tab << "::DBus::SignalMessage sig(\"" << signal.get("name") <<"\");" << endl;; - if(args.size() > 0) + if (args.size() > 0) { file << tab << tab << "::DBus::MessageIter wi = sig.writer();" << endl; - for(unsigned int i = 0; i < args.size(); ++i) + for (unsigned int i = 0; i < args.size(); ++i) { file << tab << tab << "wi << arg" << i+1 << ";" << endl; } @@ -820,40 +820,40 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) << tab << "/* unmarshalers (to unpack the DBus message before calling the actual interface method)" << endl << tab << " */" << endl; - for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) + for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) { - Xml::Node& method = **mi; + Xml::Node &method = **mi; Xml::Nodes args = method["arg"]; Xml::Nodes args_in = args.select("direction","in"); Xml::Nodes args_out = args.select("direction","out"); - file << tab << "::DBus::Message " << stub_name(method.get("name")) << "( const ::DBus::CallMessage& call )" << endl + file << tab << "::DBus::Message " << stub_name(method.get("name")) << "(const ::DBus::CallMessage &call)" << endl << tab << "{" << endl << tab << tab << "::DBus::MessageIter ri = call.reader();" << endl << endl; unsigned int i = 1; - for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) + for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) { - Xml::Node& arg = **ai; + Xml::Node &arg = **ai; file << tab << tab << signature_to_type(arg.get("type")) << " argin" << i << ";" << " ri >> argin" << i << ";" << endl; } - if(args_out.size() == 0) + if (args_out.size() == 0) { file << tab << tab; } - else if(args_out.size() == 1) + else if (args_out.size() == 1) { file << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout1 = "; } else { unsigned int i = 1; - for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) + for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i) { - Xml::Node& arg = **ao; + Xml::Node &arg = **ao; file << tab << tab << signature_to_type(arg.get("type")) << " argout" << i << ";" << endl; } file << tab << tab; @@ -861,20 +861,20 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) file << method.get("name") << "("; - for(unsigned int i = 0; i < args_in.size(); ++i) + for (unsigned int i = 0; i < args_in.size(); ++i) { file << "argin" << i+1; - if((i+1 != args_in.size() || args_out.size() > 1)) + if ((i+1 != args_in.size() || args_out.size() > 1)) file << ", "; } - if(args_out.size() > 1) - for(unsigned int i = 0; i < args_out.size(); ++i) + if (args_out.size() > 1) + for (unsigned int i = 0; i < args_out.size(); ++i) { file << "argout" << i+1; - if(i+1 != args_out.size()) + if (i+1 != args_out.size()) file << ", "; } @@ -882,11 +882,11 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) file << tab << tab << "::DBus::ReturnMessage reply(call);" << endl; - if(args_out.size() > 0) + if (args_out.size() > 0) { file << tab << tab << "::DBus::MessageIter wi = reply.writer();" << endl; - for(unsigned int i = 0; i < args_out.size(); ++i) + for (unsigned int i = 0; i < args_out.size(); ++i) { file << tab << tab << "wi << argout" << i+1 << ";" << endl; } @@ -900,7 +900,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) file << "};" << endl << endl; - for(unsigned int i = 0; i < nspaces; ++i) + for (unsigned int i = 0; i < nspaces; ++i) { file << "} "; } @@ -912,9 +912,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename ) file.close(); } -int main( int argc, char** argv ) +int main(int argc, char ** argv) { - if(argc < 2) + if (argc < 2) { usage(argv[0]); } @@ -928,26 +928,26 @@ int main( int argc, char** argv ) adaptor_mode = false; adaptor = 0; - for(int a = 1; a < argc; ++a) + for (int a = 1; a < argc; ++a) { - if(!strncmp(argv[a], "--proxy=", 8)) + if (!strncmp(argv[a], "--proxy=", 8)) { proxy_mode = true; proxy = argv[a] +8; } else - if(!strncmp(argv[a], "--adaptor=", 10)) + if (!strncmp(argv[a], "--adaptor=", 10)) { adaptor_mode = true; adaptor = argv[a] +10; } } - if(!proxy_mode && !adaptor_mode) usage(argv[0]); + if (!proxy_mode && !adaptor_mode) usage(argv[0]); ifstream xmlfile(argv[1]); - if(xmlfile.bad()) + if (xmlfile.bad()) { cerr << "unable to open file " << argv[1] << endl; return -1; @@ -960,20 +960,20 @@ int main( int argc, char** argv ) xmlfile >> doc; //cout << doc.to_xml(); } - catch(Xml::Error& e) + catch(Xml::Error &e) { cerr << "error parsing " << argv[1] << ": " << e.what() << endl; return -1; } - if(!doc.root) + if (!doc.root) { cerr << "empty document" << endl; return -1; } - if(proxy_mode) generate_proxy(doc, proxy); - if(adaptor_mode) generate_adaptor(doc, adaptor); + if (proxy_mode) generate_proxy(doc, proxy); + if (adaptor_mode) generate_adaptor(doc, adaptor); return 0; } From f0a9278511c37b253c6b2a5de1d1320d2398d80d Mon Sep 17 00:00:00 2001 From: pd Date: Sat, 9 Aug 2008 01:16:45 +0200 Subject: [PATCH 3/3] Use standard types instead of typedefs wherever possible --- examples/echo/echo-server.cpp | 18 +++---- examples/echo/echo-server.h | 10 ++-- examples/glib/dbus-browser.cpp | 8 +-- examples/glib/dbus-browser.h | 6 +-- examples/hal/hal-listen.cpp | 18 +++---- examples/hal/hal-listen.h | 4 +- examples/properties/props-server.cpp | 4 +- examples/properties/props-server.h | 2 +- include/dbus-c++/property.h | 8 +-- include/dbus-c++/types.h | 80 ++++++++++++---------------- src/property.cpp | 12 ++--- tools/xml2cpp.cpp | 20 +++---- 12 files changed, 90 insertions(+), 100 deletions(-) diff --git a/examples/echo/echo-server.cpp b/examples/echo/echo-server.cpp index a96fca3..77e9616 100644 --- a/examples/echo/echo-server.cpp +++ b/examples/echo/echo-server.cpp @@ -13,12 +13,12 @@ EchoServer::EchoServer(DBus::Connection &connection) { } -DBus::Int32 EchoServer::Random() +int32_t EchoServer::Random() { return rand(); } -DBus::String EchoServer::Hello(const DBus::String &name) +std::string EchoServer::Hello(const std::string &name) { sleep (10); return "Hello " + name + "!"; @@ -31,33 +31,33 @@ DBus::Variant EchoServer::Echo(const DBus::Variant &value) return value; } -std::vector< DBus::Byte > EchoServer::Cat(const DBus::String &file) +std::vector< uint8_t > EchoServer::Cat(const std::string &file) { FILE *handle = fopen(file.c_str(), "rb"); if (!handle) throw DBus::Error("org.freedesktop.DBus.EchoDemo.ErrorFileNotFound", "file not found"); - DBus::Byte buff[1024]; + uint8_t buff[1024]; size_t nread = fread(buff, 1, sizeof(buff), handle); fclose(handle); - return std::vector< DBus::Byte > (buff, buff + nread); + return std::vector< uint8_t > (buff, buff + nread); } -DBus::Int32 EchoServer::Sum(const std::vector& ints) +int32_t EchoServer::Sum(const std::vector& ints) { - DBus::Int32 sum = 0; + int32_t sum = 0; for (size_t i = 0; i < ints.size(); ++i) sum += ints[i]; return sum; } -std::map< DBus::String, DBus::String > EchoServer::Info() +std::map< std::string, std::string > EchoServer::Info() { - std::map< DBus::String, DBus::String > info; + std::map< std::string, std::string > info; char hostname[HOST_NAME_MAX]; gethostname(hostname, sizeof(hostname)); diff --git a/examples/echo/echo-server.h b/examples/echo/echo-server.h index 58a0e92..94d597e 100644 --- a/examples/echo/echo-server.h +++ b/examples/echo/echo-server.h @@ -13,17 +13,17 @@ public: EchoServer(DBus::Connection &connection); - DBus::Int32 Random(); + int32_t Random(); - DBus::String Hello(const DBus::String &name); + std::string Hello(const std::string &name); DBus::Variant Echo(const DBus::Variant &value); - std::vector< DBus::Byte > Cat(const DBus::String &file); + std::vector< uint8_t > Cat(const std::string &file); - DBus::Int32 Sum(const std::vector & ints); + int32_t Sum(const std::vector & ints); - std::map< DBus::String, DBus::String > Info(); + std::map< std::string, std::string > Info(); }; #endif//__DEMO_ECHO_SERVER_H diff --git a/examples/glib/dbus-browser.cpp b/examples/glib/dbus-browser.cpp index bc32d22..382d07f 100644 --- a/examples/glib/dbus-browser.cpp +++ b/examples/glib/dbus-browser.cpp @@ -15,7 +15,7 @@ DBusBrowser::DBusBrowser(::DBus::Connection &conn) set_border_width(5); set_default_size(400, 500); - typedef std::vector< ::DBus::String > Names; + typedef std::vector< std::string > Names; Names names = ListNames(); @@ -42,17 +42,17 @@ DBusBrowser::DBusBrowser(::DBus::Connection &conn) } void DBusBrowser::NameOwnerChanged( - const ::DBus::String &name, const ::DBus::String &old_owner, const ::DBus::String &new_owner) + const std::string &name, const std::string &old_owner, const std::string &new_owner) { cout << name << ": " << old_owner << " -> " << new_owner << endl; } -void DBusBrowser::NameLost(const ::DBus::String &name) +void DBusBrowser::NameLost(const std::string &name) { cout << name << " lost" << endl; } -void DBusBrowser::NameAcquired(const ::DBus::String &name) +void DBusBrowser::NameAcquired(const std::string &name) { cout << name << " acquired" << endl; } diff --git a/examples/glib/dbus-browser.h b/examples/glib/dbus-browser.h index e246c07..4e95980 100644 --- a/examples/glib/dbus-browser.h +++ b/examples/glib/dbus-browser.h @@ -30,11 +30,11 @@ public: private: - void NameOwnerChanged(const ::DBus::String &, const ::DBus::String &, const ::DBus::String &); + void NameOwnerChanged(const std::string &, const std::string &, const std::string &); - void NameLost(const ::DBus::String &); + void NameLost(const std::string &); - void NameAcquired(const ::DBus::String &); + void NameAcquired(const std::string &); void on_select_busname(); diff --git a/examples/hal/hal-listen.cpp b/examples/hal/hal-listen.cpp index d544e28..11e18de 100644 --- a/examples/hal/hal-listen.cpp +++ b/examples/hal/hal-listen.cpp @@ -10,9 +10,9 @@ HalManagerProxy::HalManagerProxy(DBus::Connection &connection) connect_signal(HalManagerProxy, DeviceAdded, DeviceAddedCb); connect_signal(HalManagerProxy, DeviceRemoved, DeviceRemovedCb); - std::vector< DBus::String > devices = GetAllDevices(); + std::vector< std::string > devices = GetAllDevices(); - std::vector< DBus::String >::iterator it; + std::vector< std::string >::iterator it; for (it = devices.begin(); it != devices.end(); ++it) { DBus::Path udi = *it; @@ -23,9 +23,9 @@ HalManagerProxy::HalManagerProxy(DBus::Connection &connection) } } -std::vector< DBus::String > HalManagerProxy::GetAllDevices() +std::vector< std::string > HalManagerProxy::GetAllDevices() { - std::vector< DBus::String > udis; + std::vector< std::string > udis; DBus::CallMessage call; call.member("GetAllDevices"); @@ -40,7 +40,7 @@ std::vector< DBus::String > HalManagerProxy::GetAllDevices() void HalManagerProxy::DeviceAddedCb(const DBus::SignalMessage &sig) { DBus::MessageIter it = sig.reader(); - DBus::String devname; + std::string devname; it >> devname; @@ -53,7 +53,7 @@ void HalManagerProxy::DeviceAddedCb(const DBus::SignalMessage &sig) void HalManagerProxy::DeviceRemovedCb(const DBus::SignalMessage &sig) { DBus::MessageIter it = sig.reader(); - DBus::String devname; + std::string devname; it >> devname; @@ -72,10 +72,10 @@ HalDeviceProxy::HalDeviceProxy(DBus::Connection &connection, DBus::Path &udi) void HalDeviceProxy::PropertyModifiedCb(const DBus::SignalMessage &sig) { - typedef DBus::Struct< DBus::String, DBus::Bool, DBus::Bool > HalProperty; + typedef DBus::Struct< std::string, bool, bool > HalProperty; DBus::MessageIter it = sig.reader(); - DBus::Int32 number; + int32_t number; it >> number; @@ -94,7 +94,7 @@ void HalDeviceProxy::PropertyModifiedCb(const DBus::SignalMessage &sig) void HalDeviceProxy::ConditionCb(const DBus::SignalMessage &sig) { DBus::MessageIter it = sig.reader(); - DBus::String condition; + std::string condition; it >> condition; diff --git a/examples/hal/hal-listen.h b/examples/hal/hal-listen.h index 9797433..12862e6 100644 --- a/examples/hal/hal-listen.h +++ b/examples/hal/hal-listen.h @@ -15,7 +15,7 @@ public: HalManagerProxy(DBus::Connection &connection); - std::vector< DBus::String > GetAllDevices(); + std::vector< std::string > GetAllDevices(); private: @@ -23,7 +23,7 @@ private: void DeviceRemovedCb(const DBus::SignalMessage &sig); - std::map< DBus::String, DBus::RefPtr< HalDeviceProxy > > _devices; + std::map< std::string, DBus::RefPtr< HalDeviceProxy > > _devices; }; class HalDeviceProxy diff --git a/examples/properties/props-server.cpp b/examples/properties/props-server.cpp index 990e6fe..f782489 100644 --- a/examples/properties/props-server.cpp +++ b/examples/properties/props-server.cpp @@ -12,11 +12,11 @@ PropsServer::PropsServer(DBus::Connection &connection) } void PropsServer::on_set_property - (DBus::InterfaceAdaptor &interface, const DBus::String &property, const DBus::Variant &value) + (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value) { if (property == "Message") { - DBus::String msg = value; + std::string msg = value; this->MessageChanged(msg); } } diff --git a/examples/properties/props-server.h b/examples/properties/props-server.h index 6d32161..cf9ba83 100644 --- a/examples/properties/props-server.h +++ b/examples/properties/props-server.h @@ -15,7 +15,7 @@ public: PropsServer(DBus::Connection &connection); void on_set_property - (DBus::InterfaceAdaptor &interface, const DBus::String &property, const DBus::Variant &value); + (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value); }; #endif//__DEMO_PROPS_SERVER_H diff --git a/include/dbus-c++/property.h b/include/dbus-c++/property.h index b8c047a..7bb3b38 100644 --- a/include/dbus-c++/property.h +++ b/include/dbus-c++/property.h @@ -80,10 +80,10 @@ public: protected: - virtual void on_get_property(InterfaceAdaptor &interface, const String &property, Variant &value) + virtual void on_get_property(InterfaceAdaptor &interface, const std::string &property, Variant &value) {} - virtual void on_set_property(InterfaceAdaptor &interface, const String &property, const Variant &value) + virtual void on_set_property(InterfaceAdaptor &interface, const std::string &property, const Variant &value) {} IntrospectedInterface *const introspect() const; @@ -95,9 +95,9 @@ public: PropertiesProxy(); - Variant Get(const String &interface, const String &property); + Variant Get(const std::string &interface, const std::string &property); - void Set(const String &interface, const String &property, const Variant &value); + void Set(const std::string &interface, const std::string &property, const Variant &value); }; } /* namespace DBus */ diff --git a/include/dbus-c++/types.h b/include/dbus-c++/types.h index c783f4e..a2b6b83 100644 --- a/include/dbus-c++/types.h +++ b/include/dbus-c++/types.h @@ -29,6 +29,7 @@ #include #endif +#include #include #include #include @@ -40,17 +41,6 @@ namespace DBus { -typedef unsigned char Byte; -typedef bool Bool; -typedef signed short Int16; -typedef unsigned short UInt16; -typedef signed int Int32; -typedef unsigned int UInt32; -typedef signed long long Int64; -typedef unsigned long long UInt64; -typedef double Double; -typedef std::string String; - struct DXXAPI Path : public std::string { Path() {} @@ -146,17 +136,17 @@ struct type } }; -template <> struct type { static std::string sig(){ return "v"; } }; -template <> struct type { static std::string sig(){ return "y"; } }; -template <> struct type { static std::string sig(){ return "b"; } }; -template <> struct type { static std::string sig(){ return "n"; } }; -template <> struct type { static std::string sig(){ return "q"; } }; -template <> struct type { static std::string sig(){ return "i"; } }; -template <> struct type { static std::string sig(){ return "u"; } }; -template <> struct type { static std::string sig(){ return "x"; } }; -template <> struct type { static std::string sig(){ return "t"; } }; -template <> struct type { static std::string sig(){ return "d"; } }; -template <> struct type { static std::string sig(){ return "s"; } }; +template <> struct type { static std::string sig(){ return "v"; } }; +template <> struct type { static std::string sig(){ return "y"; } }; +template <> struct type { static std::string sig(){ return "b"; } }; +template <> struct type { static std::string sig(){ return "n"; } }; +template <> struct type { static std::string sig(){ return "q"; } }; +template <> struct type { static std::string sig(){ return "i"; } }; +template <> struct type { static std::string sig(){ return "u"; } }; +template <> struct type { static std::string sig(){ return "x"; } }; +template <> struct type { static std::string sig(){ return "t"; } }; +template <> struct type { static std::string sig(){ return "d"; } }; +template <> struct type { static std::string sig(){ return "s"; } }; template <> struct type { static std::string sig(){ return "o"; } }; template <> struct type { static std::string sig(){ return "g"; } }; template <> struct type { static std::string sig(){ return ""; } }; @@ -203,61 +193,61 @@ inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Inva return iter; } -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Byte &val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint8_t &val) { iter.append_byte(val); return iter; } -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Bool &val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const bool &val) { iter.append_bool(val); return iter; } -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Int16& val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int16_t& val) { iter.append_int16(val); return iter; } -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::UInt16& val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint16_t& val) { iter.append_uint16(val); return iter; } -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Int32& val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int32_t& val) { iter.append_int32(val); return iter; } -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::UInt32& val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint32_t& val) { iter.append_uint32(val); return iter; } -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Int64& val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const int64_t& val) { iter.append_int64(val); return iter; } -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::UInt64& val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const uint64_t& val) { iter.append_uint64(val); return iter; } -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::Double &val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const double &val) { iter.append_double(val); return iter; } -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const DBus::String &val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::string &val) { iter.append_string(val.c_str()); return iter; @@ -292,7 +282,7 @@ inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vecto } template<> -inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vector& val) +inline DBus::MessageIter &operator << (DBus::MessageIter &iter, const std::vector& val) { DBus::MessageIter ait = iter.new_array("y"); ait.append_array('y', &val.front(), val.size()); @@ -355,61 +345,61 @@ inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Invalid &) return iter; } -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Byte &val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint8_t &val) { val = iter.get_byte(); return ++iter; } -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Bool &val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, bool &val) { val = iter.get_bool(); return ++iter; } -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Int16& val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int16_t& val) { val = iter.get_int16(); return ++iter; } -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::UInt16& val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint16_t& val) { val = iter.get_uint16(); return ++iter; } -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Int32& val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int32_t& val) { val = iter.get_int32(); return ++iter; } -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::UInt32& val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint32_t& val) { val = iter.get_uint32(); return ++iter; } -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Int64& val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, int64_t& val) { val = iter.get_int64(); return ++iter; } -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::UInt64& val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, uint64_t& val) { val = iter.get_uint64(); return ++iter; } -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::Double &val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, double &val) { val = iter.get_double(); return ++iter; } -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, DBus::String &val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::string &val) { val = iter.get_string(); return ++iter; @@ -447,7 +437,7 @@ inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector& } template<> -inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector& val) +inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector& val) { if (!iter.is_array()) throw DBus::ErrorInvalidArgs("array expected"); @@ -457,7 +447,7 @@ inline DBus::MessageIter &operator >> (DBus::MessageIter &iter, std::vector> iface_name >> property_name; @@ -72,8 +72,8 @@ 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; @@ -137,14 +137,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/tools/xml2cpp.cpp b/tools/xml2cpp.cpp index 3a7fbdf..25a32d2 100644 --- a/tools/xml2cpp.cpp +++ b/tools/xml2cpp.cpp @@ -87,16 +87,16 @@ const char *atomic_type_to_string(char t) { static struct { char type; const char *name; } atos[] = { - { 'y', "::DBus::Byte" }, - { 'b', "::DBus::Bool" }, - { 'n', "::DBus::Int16" }, - { 'q', "::DBus::UInt16" }, - { 'i', "::DBus::Int32" }, - { 'u', "::DBus::UInt32" }, - { 'x', "::DBus::Int64" }, - { 't', "::DBus::UInt64" }, - { 'd', "::DBus::Double" }, - { 's', "::DBus::String" }, + { 'y', "uint8_t" }, + { 'b', "bool" }, + { 'n', "int16_t" }, + { 'q', "uint16_t" }, + { 'i', "int32_t" }, + { 'u', "uint32_t" }, + { 'x', "int64_t" }, + { 't', "uint64_t" }, + { 'd', "double" }, + { 's', "std::string" }, { 'o', "::DBus::Path" }, { 'g', "::DBus::Signature" }, { 'v', "::DBus::Variant" },