diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/echo/echo-client.cpp | 114 | ||||
-rw-r--r-- | examples/echo/echo-client.h | 6 | ||||
-rw-r--r-- | examples/echo/echo-server.cpp | 58 | ||||
-rw-r--r-- | examples/echo/echo-server.h | 16 | ||||
-rw-r--r-- | examples/echo_ecore/echo-client.cpp | 118 | ||||
-rw-r--r-- | examples/echo_ecore/echo-client.h | 6 | ||||
-rw-r--r-- | examples/echo_ecore/echo-server.cpp | 58 | ||||
-rw-r--r-- | examples/echo_ecore/echo-server.h | 16 | ||||
-rw-r--r-- | examples/ecore/dbus_ecore.cpp | 46 | ||||
-rw-r--r-- | examples/ecore/dbus_ecore.h | 10 | ||||
-rw-r--r-- | examples/glib/dbus-browser.cpp | 144 | ||||
-rw-r--r-- | examples/glib/dbus-browser.h | 49 | ||||
-rw-r--r-- | examples/hal/hal-listen.cpp | 114 | ||||
-rw-r--r-- | examples/hal/hal-listen.h | 20 | ||||
-rw-r--r-- | examples/properties/propsgs-client.cpp | 60 | ||||
-rw-r--r-- | examples/properties/propsgs-client.h | 10 | ||||
-rw-r--r-- | examples/properties/propsgs-server.cpp | 54 | ||||
-rw-r--r-- | examples/properties/propsgs-server.h | 8 |
18 files changed, 455 insertions, 452 deletions
diff --git a/examples/echo/echo-client.cpp b/examples/echo/echo-client.cpp index 10c9a78..84a7d6a 100644 --- a/examples/echo/echo-client.cpp +++ b/examples/echo/echo-client.cpp @@ -15,13 +15,13 @@ 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) -: DBus::ObjectProxy(connection, path, name) + : DBus::ObjectProxy(connection, path, name) { } void EchoClient::Echoed(const DBus::Variant &value) { - cout << "!"; + cout << "!"; } static const size_t THREADS = 3; @@ -37,96 +37,96 @@ DBus::DefaultTimeout *timeout; void *greeter_thread(void *arg) { - char idstr[16]; - size_t i = (size_t) arg; + char idstr[16]; + size_t i = (size_t) arg; - snprintf(idstr, sizeof(idstr), "%lu", pthread_self()); + snprintf(idstr, sizeof(idstr), "%lu", pthread_self()); - thread_pipe_list[i]->write (idstr, strlen (idstr) + 1); + thread_pipe_list[i]->write(idstr, strlen(idstr) + 1); - cout << idstr << " done (" << i << ")" << endl; + cout << idstr << " done (" << i << ")" << endl; - return NULL; + return NULL; } void niam(int sig) { - spin = false; + spin = false; - dispatcher.leave(); + dispatcher.leave(); } -void handler1 (const void *data, void *buffer, unsigned int nbyte) +void handler1(const void *data, void *buffer, unsigned int nbyte) { - char *str = (char*) buffer; - cout << "buffer1: " << str << ", size: " << nbyte << endl; - for (int i = 0; i < 30 && spin; ++i) - { - cout << "call1: " << g_client->Hello (str) << endl; - } + char *str = (char *) buffer; + cout << "buffer1: " << str << ", size: " << nbyte << endl; + for (int i = 0; i < 30 && spin; ++i) + { + cout << "call1: " << g_client->Hello(str) << endl; + } } -void handler2 (const void *data, void *buffer, unsigned int nbyte) +void handler2(const void *data, void *buffer, unsigned int nbyte) { - char *str = (char*) buffer; - cout << "buffer2: " << str << ", size: " << nbyte <<endl; - for (int i = 0; i < 30 && spin; ++i) - { - cout << "call2: " << g_client->Hello (str) << endl; - } + char *str = (char *) buffer; + cout << "buffer2: " << str << ", size: " << nbyte << endl; + for (int i = 0; i < 30 && spin; ++i) + { + cout << "call2: " << g_client->Hello(str) << endl; + } } -void handler3 (const void *data, void *buffer, unsigned int nbyte) +void handler3(const void *data, void *buffer, unsigned int nbyte) { - char *str = (char*) buffer; - cout << "buffer3: " << str << ", size: " << nbyte <<endl; - for (int i = 0; i < 30 && spin; ++i) - { - cout << "call3: " << g_client->Hello (str) << endl; - } + char *str = (char *) buffer; + cout << "buffer3: " << str << ", size: " << nbyte << endl; + for (int i = 0; i < 30 && spin; ++i) + { + cout << "call3: " << g_client->Hello(str) << endl; + } } int main() { - size_t i; + size_t i; - signal(SIGTERM, niam); - signal(SIGINT, niam); + signal(SIGTERM, niam); + signal(SIGINT, niam); - DBus::_init_threading(); + DBus::_init_threading(); DBus::default_dispatcher = &dispatcher; // increase DBus-C++ frequency new DBus::DefaultTimeout(100, false, &dispatcher); - DBus::Connection conn = DBus::Connection::SessionBus(); + DBus::Connection conn = DBus::Connection::SessionBus(); - EchoClient client (conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME); - g_client = &client; + EchoClient client(conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME); + g_client = &client; - pthread_t threads[THREADS]; + pthread_t threads[THREADS]; - thread_pipe_list[0] = dispatcher.add_pipe (handler1, NULL); - thread_pipe_list[1] = dispatcher.add_pipe (handler2, NULL); - thread_pipe_list[2] = dispatcher.add_pipe (handler3, NULL); - for (i = 0; i < THREADS; ++i) - { - pthread_create(threads+i, NULL, greeter_thread, (void*) i); - } - - dispatcher.enter(); + thread_pipe_list[0] = dispatcher.add_pipe(handler1, NULL); + thread_pipe_list[1] = dispatcher.add_pipe(handler2, NULL); + thread_pipe_list[2] = dispatcher.add_pipe(handler3, NULL); + for (i = 0; i < THREADS; ++i) + { + pthread_create(threads + i, NULL, greeter_thread, (void *) i); + } - cout << "terminating" << endl; + dispatcher.enter(); - for (i = 0; i < THREADS; ++i) - { - pthread_join(threads[i], NULL); - } + cout << "terminating" << endl; - dispatcher.del_pipe (thread_pipe_list[0]); - dispatcher.del_pipe (thread_pipe_list[1]); - dispatcher.del_pipe (thread_pipe_list[2]); + for (i = 0; i < THREADS; ++i) + { + pthread_join(threads[i], NULL); + } - return 0; + dispatcher.del_pipe(thread_pipe_list[0]); + dispatcher.del_pipe(thread_pipe_list[1]); + dispatcher.del_pipe(thread_pipe_list[2]); + + return 0; } diff --git a/examples/echo/echo-client.h b/examples/echo/echo-client.h index 54401ec..16b0d4f 100644 --- a/examples/echo/echo-client.h +++ b/examples/echo/echo-client.h @@ -5,15 +5,15 @@ #include "echo-client-glue.h" class EchoClient -: public org::freedesktop::DBus::EchoDemo_proxy, + : public org::freedesktop::DBus::EchoDemo_proxy, public DBus::IntrospectableProxy, public DBus::ObjectProxy { 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 cbcd517..4f17046 100644 --- a/examples/echo/echo-server.cpp +++ b/examples/echo/echo-server.cpp @@ -13,61 +13,61 @@ 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) -: DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH) + : DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH) { } int32_t EchoServer::Random() { - return rand(); + return rand(); } std::string EchoServer::Hello(const std::string &name) { - return "Hello " + name + "!"; + return "Hello " + name + "!"; } DBus::Variant EchoServer::Echo(const DBus::Variant &value) { - this->Echoed(value); + this->Echoed(value); - return value; + return value; } std::vector< uint8_t > EchoServer::Cat(const std::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"); - uint8_t buff[1024]; + uint8_t buff[1024]; - size_t nread = fread(buff, 1, sizeof(buff), handle); + size_t nread = fread(buff, 1, sizeof(buff), handle); - fclose(handle); + fclose(handle); - return std::vector< uint8_t > (buff, buff + nread); + return std::vector< uint8_t > (buff, buff + nread); } int32_t EchoServer::Sum(const std::vector<int32_t>& ints) { - int32_t sum = 0; + int32_t 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; + return sum; } std::map< std::string, std::string > EchoServer::Info() { - std::map< std::string, std::string > info; - char hostname[HOST_NAME_MAX]; + std::map< std::string, std::string > info; + char hostname[HOST_NAME_MAX]; - gethostname(hostname, sizeof(hostname)); - info["hostname"] = hostname; - info["username"] = getlogin(); + gethostname(hostname, sizeof(hostname)); + info["hostname"] = hostname; + info["username"] = getlogin(); - return info; + return info; } @@ -75,22 +75,22 @@ DBus::BusDispatcher dispatcher; void niam(int sig) { - dispatcher.leave(); + dispatcher.leave(); } int main() { - signal(SIGTERM, niam); - signal(SIGINT, niam); + signal(SIGTERM, niam); + signal(SIGINT, niam); - DBus::default_dispatcher = &dispatcher; + DBus::default_dispatcher = &dispatcher; - DBus::Connection conn = DBus::Connection::SessionBus(); - conn.request_name(ECHO_SERVER_NAME); + DBus::Connection conn = DBus::Connection::SessionBus(); + conn.request_name(ECHO_SERVER_NAME); - EchoServer server(conn); + EchoServer server(conn); - dispatcher.enter(); + dispatcher.enter(); - return 0; + return 0; } diff --git a/examples/echo/echo-server.h b/examples/echo/echo-server.h index 3f0be58..8f853fb 100644 --- a/examples/echo/echo-server.h +++ b/examples/echo/echo-server.h @@ -5,25 +5,25 @@ #include "echo-server-glue.h" class EchoServer -: public org::freedesktop::DBus::EchoDemo_adaptor, + : public org::freedesktop::DBus::EchoDemo_adaptor, public DBus::IntrospectableAdaptor, public DBus::ObjectAdaptor { public: - EchoServer(DBus::Connection &connection); + EchoServer(DBus::Connection &connection); - int32_t Random(); + int32_t Random(); - std::string Hello(const std::string &name); + std::string Hello(const std::string &name); - DBus::Variant Echo(const DBus::Variant &value); + DBus::Variant Echo(const DBus::Variant &value); - std::vector< uint8_t > Cat(const std::string &file); + std::vector< uint8_t > Cat(const std::string &file); - int32_t Sum(const std::vector<int32_t> & ints); + int32_t Sum(const std::vector<int32_t> & ints); - std::map< std::string, std::string > Info(); + std::map< std::string, std::string > Info(); }; #endif//__DEMO_ECHO_SERVER_H diff --git a/examples/echo_ecore/echo-client.cpp b/examples/echo_ecore/echo-client.cpp index 12c91bc..4279a8b 100644 --- a/examples/echo_ecore/echo-client.cpp +++ b/examples/echo_ecore/echo-client.cpp @@ -15,13 +15,13 @@ 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) -: DBus::ObjectProxy(connection, path, name) + : DBus::ObjectProxy(connection, path, name) { } void EchoClient::Echoed(const DBus::Variant &value) { - cout << "!"; + cout << "!"; } /* @@ -41,101 +41,101 @@ DBus::Ecore::BusDispatcher dispatcher; void *greeter_thread(void *arg) { - char idstr[16]; - size_t i = (size_t) arg; + char idstr[16]; + size_t i = (size_t) arg; - snprintf(idstr, sizeof(idstr), "%lu", pthread_self()); + snprintf(idstr, sizeof(idstr), "%lu", pthread_self()); - thread_pipe_list[i]->write (idstr, strlen (idstr) + 1); + thread_pipe_list[i]->write(idstr, strlen(idstr) + 1); - cout << idstr << " done (" << i << ")" << endl; + cout << idstr << " done (" << i << ")" << endl; - return NULL; + return NULL; } void niam(int sig) { - spin = false; + spin = false; - ecore_main_loop_quit(); + ecore_main_loop_quit(); } -void handler1 (const void *data, void *buffer, unsigned int nbyte) +void handler1(const void *data, void *buffer, unsigned int nbyte) { - char *str = (char*) buffer; - cout << "buffer1: " << str << ", size: " << nbyte << endl; - for (int i = 0; i < 30 && spin; ++i) - { - cout << "call1: " << g_client->Hello (str) << endl; - } + char *str = (char *) buffer; + cout << "buffer1: " << str << ", size: " << nbyte << endl; + for (int i = 0; i < 30 && spin; ++i) + { + cout << "call1: " << g_client->Hello(str) << endl; + } } -void handler2 (const void *data, void *buffer, unsigned int nbyte) +void handler2(const void *data, void *buffer, unsigned int nbyte) { - char *str = (char*) buffer; - cout << "buffer2: " << str << ", size: " << nbyte <<endl; - for (int i = 0; i < 30 && spin; ++i) - { - cout << "call2: " << g_client->Hello (str) << endl; - } + char *str = (char *) buffer; + cout << "buffer2: " << str << ", size: " << nbyte << endl; + for (int i = 0; i < 30 && spin; ++i) + { + cout << "call2: " << g_client->Hello(str) << endl; + } } -void handler3 (const void *data, void *buffer, unsigned int nbyte) +void handler3(const void *data, void *buffer, unsigned int nbyte) { - char *str = (char*) buffer; - cout << "buffer3: " << str << ", size: " << nbyte <<endl; - for (int i = 0; i < 30 && spin; ++i) - { - cout << "call3: " << g_client->Hello (str) << endl; - } + char *str = (char *) buffer; + cout << "buffer3: " << str << ", size: " << nbyte << endl; + for (int i = 0; i < 30 && spin; ++i) + { + cout << "call3: " << g_client->Hello(str) << endl; + } } int main() { - size_t i; + size_t i; - signal(SIGTERM, niam); - signal(SIGINT, niam); + signal(SIGTERM, niam); + signal(SIGINT, niam); ecore_init(); - - //DBus::_init_threading(); + + //DBus::_init_threading(); DBus::default_dispatcher = &dispatcher; // increase DBus-C++ frequency //new DBus::DefaultTimeout(100, false, &dispatcher); - DBus::Connection conn = DBus::Connection::SessionBus(); + DBus::Connection conn = DBus::Connection::SessionBus(); + + EchoClient client(conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME); + g_client = &client; - EchoClient client (conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME); - g_client = &client; + pthread_t threads[THREADS]; - pthread_t threads[THREADS]; + /* thread_pipe_list[0] = dispatcher.add_pipe (handler1, NULL); + thread_pipe_list[1] = dispatcher.add_pipe (handler2, NULL); + thread_pipe_list[2] = dispatcher.add_pipe (handler3, NULL);*/ + for (i = 0; i < THREADS; ++i) + { + //pthread_create(threads+i, NULL, greeter_thread, (void*) i); + } -/* thread_pipe_list[0] = dispatcher.add_pipe (handler1, NULL); - thread_pipe_list[1] = dispatcher.add_pipe (handler2, NULL); - thread_pipe_list[2] = dispatcher.add_pipe (handler3, NULL);*/ - for (i = 0; i < THREADS; ++i) - { - //pthread_create(threads+i, NULL, greeter_thread, (void*) i); - } - - //dispatcher.enter(); + //dispatcher.enter(); - cout << "terminating" << endl; + cout << "terminating" << endl; - for (i = 0; i < THREADS; ++i) - { - pthread_join(threads[i], NULL); - } + for (i = 0; i < THREADS; ++i) + { + pthread_join(threads[i], NULL); + } - /*dispatcher.del_pipe (thread_pipe_list[0]); - dispatcher.del_pipe (thread_pipe_list[1]); - dispatcher.del_pipe (thread_pipe_list[2]);*/ + /*dispatcher.del_pipe (thread_pipe_list[0]); + dispatcher.del_pipe (thread_pipe_list[1]); + dispatcher.del_pipe (thread_pipe_list[2]);*/ ecore_main_loop_begin(); ecore_shutdown(); - - return 0; + + return 0; } diff --git a/examples/echo_ecore/echo-client.h b/examples/echo_ecore/echo-client.h index 47c7374..d46093d 100644 --- a/examples/echo_ecore/echo-client.h +++ b/examples/echo_ecore/echo-client.h @@ -8,15 +8,15 @@ #include "echo-client-glue.h" class EchoClient -: public org::freedesktop::DBus::EchoDemo_proxy, + : public org::freedesktop::DBus::EchoDemo_proxy, public DBus::IntrospectableProxy, public DBus::ObjectProxy { 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_ecore/echo-server.cpp b/examples/echo_ecore/echo-server.cpp index 3964e85..94bbd81 100644 --- a/examples/echo_ecore/echo-server.cpp +++ b/examples/echo_ecore/echo-server.cpp @@ -13,61 +13,61 @@ 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) -: DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH) + : DBus::ObjectAdaptor(connection, ECHO_SERVER_PATH) { } int32_t EchoServer::Random() { - return rand(); + return rand(); } std::string EchoServer::Hello(const std::string &name) { - return "Hello " + name + "!"; + return "Hello " + name + "!"; } DBus::Variant EchoServer::Echo(const DBus::Variant &value) { - this->Echoed(value); + this->Echoed(value); - return value; + return value; } std::vector< uint8_t > EchoServer::Cat(const std::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"); - uint8_t buff[1024]; + uint8_t buff[1024]; - size_t nread = fread(buff, 1, sizeof(buff), handle); + size_t nread = fread(buff, 1, sizeof(buff), handle); - fclose(handle); + fclose(handle); - return std::vector< uint8_t > (buff, buff + nread); + return std::vector< uint8_t > (buff, buff + nread); } int32_t EchoServer::Sum(const std::vector<int32_t>& ints) { - int32_t sum = 0; + int32_t 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; + return sum; } std::map< std::string, std::string > EchoServer::Info() { - std::map< std::string, std::string > info; - char hostname[HOST_NAME_MAX]; + std::map< std::string, std::string > info; + char hostname[HOST_NAME_MAX]; - gethostname(hostname, sizeof(hostname)); - info["hostname"] = hostname; - info["username"] = getlogin(); + gethostname(hostname, sizeof(hostname)); + info["hostname"] = hostname; + info["username"] = getlogin(); - return info; + return info; } DBus::Ecore::BusDispatcher dispatcher; @@ -75,25 +75,25 @@ DBus::Ecore::BusDispatcher dispatcher; void niam(int sig) { - ecore_main_loop_quit(); + ecore_main_loop_quit(); } int main() { - signal(SIGTERM, niam); - signal(SIGINT, niam); + signal(SIGTERM, niam); + signal(SIGINT, niam); ecore_init(); - DBus::default_dispatcher = &dispatcher; + DBus::default_dispatcher = &dispatcher; - DBus::Connection conn = DBus::Connection::SessionBus(); - conn.request_name(ECHO_SERVER_NAME); + DBus::Connection conn = DBus::Connection::SessionBus(); + conn.request_name(ECHO_SERVER_NAME); + + EchoServer server(conn); - EchoServer server(conn); - ecore_main_loop_begin(); ecore_shutdown(); - return 0; + return 0; } diff --git a/examples/echo_ecore/echo-server.h b/examples/echo_ecore/echo-server.h index ca370ce..afe8057 100644 --- a/examples/echo_ecore/echo-server.h +++ b/examples/echo_ecore/echo-server.h @@ -8,25 +8,25 @@ #include "echo-server-glue.h" class EchoServer -: public org::freedesktop::DBus::EchoDemo_adaptor, + : public org::freedesktop::DBus::EchoDemo_adaptor, public DBus::IntrospectableAdaptor, public DBus::ObjectAdaptor { public: - EchoServer(DBus::Connection &connection); + EchoServer(DBus::Connection &connection); - int32_t Random(); + int32_t Random(); - std::string Hello(const std::string &name); + std::string Hello(const std::string &name); - DBus::Variant Echo(const DBus::Variant &value); + DBus::Variant Echo(const DBus::Variant &value); - std::vector< uint8_t > Cat(const std::string &file); + std::vector< uint8_t > Cat(const std::string &file); - int32_t Sum(const std::vector<int32_t> & ints); + int32_t Sum(const std::vector<int32_t> & ints); - std::map< std::string, std::string > Info(); + std::map< std::string, std::string > Info(); }; #endif//__DEMO_ECHO_SERVER_H diff --git a/examples/ecore/dbus_ecore.cpp b/examples/ecore/dbus_ecore.cpp index f0686dc..c97e22c 100644 --- a/examples/ecore/dbus_ecore.cpp +++ b/examples/ecore/dbus_ecore.cpp @@ -10,62 +10,62 @@ 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"; typedef vector <string> Names; -DBusBrowser::DBusBrowser( ::DBus::Connection& conn ) -: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME) +DBusBrowser::DBusBrowser(::DBus::Connection &conn) + : ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME) { typedef std::vector< std::string > Names; - Names names = ListNames(); + Names names = ListNames(); - for(Names::iterator it = names.begin(); it != names.end(); ++it) - { + for (Names::iterator it = names.begin(); it != names.end(); ++it) + { cout << *it << endl; - } + } } void DBusBrowser::NameOwnerChanged( - const std::string& name, const std::string& old_owner, const std::string& new_owner ) + const std::string &name, const std::string &old_owner, const std::string &new_owner) { - cout << name << ": " << old_owner << " -> " << new_owner << endl; + cout << name << ": " << old_owner << " -> " << new_owner << endl; } -void DBusBrowser::NameLost( const std::string& name ) +void DBusBrowser::NameLost(const std::string &name) { - cout << name << " lost" << endl; + cout << name << " lost" << endl; } -void DBusBrowser::NameAcquired( const std::string& name ) +void DBusBrowser::NameAcquired(const std::string &name) { - cout << name << " acquired" << endl; + cout << name << " acquired" << endl; } DBus::Ecore::BusDispatcher dispatcher; -void niam( int sig ) +void niam(int sig) { - ecore_main_loop_quit(); + ecore_main_loop_quit(); } -int main(int argc, char* argv[]) +int main(int argc, char *argv[]) { signal(SIGTERM, niam); signal(SIGINT, niam); - - ecore_init(); - DBus::default_dispatcher = &dispatcher; + ecore_init(); - DBus::Connection conn = DBus::Connection::SessionBus(); + DBus::default_dispatcher = &dispatcher; - DBusBrowser browser(conn); + DBus::Connection conn = DBus::Connection::SessionBus(); + + DBusBrowser browser(conn); ecore_main_loop_begin(); ecore_shutdown(); - return 0; + return 0; } diff --git a/examples/ecore/dbus_ecore.h b/examples/ecore/dbus_ecore.h index d00d6ea..130091d 100644 --- a/examples/ecore/dbus_ecore.h +++ b/examples/ecore/dbus_ecore.h @@ -8,21 +8,21 @@ #include "dbus_ecore-glue.h" class DBusBrowser -: public org::freedesktop::DBus_proxy, + : public org::freedesktop::DBus_proxy, public DBus::IntrospectableProxy, public DBus::ObjectProxy { public: - DBusBrowser( ::DBus::Connection& conn ); + DBusBrowser(::DBus::Connection &conn); private: - void NameOwnerChanged( const std::string&, const std::string&, const std::string& ); + void NameOwnerChanged(const std::string &, const std::string &, const std::string &); - void NameLost( const std::string& ); + void NameLost(const std::string &); - void NameAcquired( const std::string& ); + void NameAcquired(const std::string &); private: diff --git a/examples/glib/dbus-browser.cpp b/examples/glib/dbus-browser.cpp index 94a3936..0ccec23 100644 --- a/examples/glib/dbus-browser.cpp +++ b/examples/glib/dbus-browser.cpp @@ -9,131 +9,131 @@ static const char *DBUS_SERVER_NAME = "org.freedesktop.DBus"; static const char *DBUS_SERVER_PATH = "/org/freedesktop/DBus"; DBusBrowser::DBusBrowser(::DBus::Connection &conn) -: ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME) + : ::DBus::ObjectProxy(conn, DBUS_SERVER_PATH, DBUS_SERVER_NAME) { - set_title("D-Bus Browser"); - set_border_width(5); - set_default_size(400, 500); + set_title("D-Bus Browser"); + set_border_width(5); + set_default_size(400, 500); - typedef std::vector< std::string > Names; + typedef std::vector< std::string > Names; - Names names = ListNames(); + Names names = ListNames(); - for (Names::iterator it = names.begin(); it != names.end(); ++it) - { - _cb_busnames.append_text(*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); - _tv_inspect.append_column("Node", _records.name); + _tm_inspect = Gtk::TreeStore::create(_records); + _tv_inspect.set_model(_tm_inspect); + _tv_inspect.append_column("Node", _records.name); - _sc_tree.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); - _sc_tree.add(_tv_inspect); + _sc_tree.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); + _sc_tree.add(_tv_inspect); - _vbox.pack_start(_cb_busnames, Gtk::PACK_SHRINK); - _vbox.pack_start(_sc_tree); + _vbox.pack_start(_cb_busnames, Gtk::PACK_SHRINK); + _vbox.pack_start(_sc_tree); - add(_vbox); + add(_vbox); - show_all_children(); + show_all_children(); } void DBusBrowser::NameOwnerChanged( - const std::string &name, const std::string &old_owner, const std::string &new_owner) + const std::string &name, const std::string &old_owner, const std::string &new_owner) { - cout << name << ": " << old_owner << " -> " << new_owner << endl; + cout << name << ": " << old_owner << " -> " << new_owner << endl; } void DBusBrowser::NameLost(const std::string &name) { - cout << name << " lost" << endl; + cout << name << " lost" << endl; } void DBusBrowser::NameAcquired(const std::string &name) { - cout << name << " acquired" << endl; + cout << name << " acquired" << endl; } void DBusBrowser::on_select_busname() { - Glib::ustring busname = _cb_busnames.get_active_text(); - if (busname.empty()) return; + Glib::ustring busname = _cb_busnames.get_active_text(); + if (busname.empty()) return; - _tm_inspect->clear(); - _inspect_append(NULL, "", busname); + _tm_inspect->clear(); + _inspect_append(NULL, "", 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()); + 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::Document doc(inspector.Introspect()); + ::DBus::Xml::Node &root = *(doc.root); - ::DBus::Xml::Nodes ifaces = root["interface"]; + ::DBus::Xml::Nodes ifaces = root["interface"]; - for (::DBus::Xml::Nodes::iterator ii = ifaces.begin(); ii != ifaces.end(); ++ii) - { - ::DBus::Xml::Node &iface = **ii; + for (::DBus::Xml::Nodes::iterator ii = ifaces.begin(); ii != ifaces.end(); ++ii) + { + ::DBus::Xml::Node &iface = **ii; - Gtk::TreeModel::Row i_row = row - ? *(_tm_inspect->append(row->children())) - : *(_tm_inspect->append()); - i_row[_records.name] = "interface: " + iface.get("name"); + Gtk::TreeModel::Row i_row = row + ? *(_tm_inspect->append(row->children())) + : *(_tm_inspect->append()); + i_row[_records.name] = "interface: " + iface.get("name"); - ::DBus::Xml::Nodes methods = iface["method"]; + ::DBus::Xml::Nodes methods = iface["method"]; - 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"); - } + 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"); + } - ::DBus::Xml::Nodes signals = iface["signal"]; + ::DBus::Xml::Nodes signals = iface["signal"]; - 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"); - } - } + 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"); + } + } - ::DBus::Xml::Nodes nodes = root["node"]; + ::DBus::Xml::Nodes nodes = root["node"]; - for (::DBus::Xml::Nodes::iterator in = nodes.begin(); in != nodes.end(); ++in) - { - std::string name = (*in)->get("name"); + for (::DBus::Xml::Nodes::iterator in = nodes.begin(); in != nodes.end(); ++in) + { + std::string name = (*in)->get("name"); - Gtk::TreeModel::Row n_row = row - ? *(_tm_inspect->append(row->children())) - : *(_tm_inspect->append()); - n_row[_records.name] = name; + Gtk::TreeModel::Row n_row = row + ? *(_tm_inspect->append(row->children())) + : *(_tm_inspect->append()); + n_row[_records.name] = name; - _inspect_append(&n_row, buspath + "/" + name, busname); - } + _inspect_append(&n_row, buspath + "/" + name, busname); + } } DBus::Glib::BusDispatcher dispatcher; int main(int argc, char *argv[]) { - Gtk::Main kit(argc, argv); + Gtk::Main kit(argc, argv); - DBus::default_dispatcher = &dispatcher; + DBus::default_dispatcher = &dispatcher; - dispatcher.attach(NULL); + dispatcher.attach(NULL); - // activate one of both for either system or session bus - // TODO: choose in the GUI - DBus::Connection conn = DBus::Connection::SessionBus(); - //DBus::Connection conn = DBus::Connection::SystemBus(); + // activate one of both for either system or session bus + // TODO: choose in the GUI + DBus::Connection conn = DBus::Connection::SessionBus(); + //DBus::Connection conn = DBus::Connection::SystemBus(); - DBusBrowser browser(conn); + DBusBrowser browser(conn); - Gtk::Main::run(browser); + Gtk::Main::run(browser); - return 0; + return 0; } diff --git a/examples/glib/dbus-browser.h b/examples/glib/dbus-browser.h index 9bbefbf..4a434a2 100644 --- a/examples/glib/dbus-browser.h +++ b/examples/glib/dbus-browser.h @@ -8,55 +8,58 @@ #include "dbus-glue.h" class DBusInspector -: public DBus::IntrospectableProxy, + : public DBus::IntrospectableProxy, public DBus::ObjectProxy { public: - DBusInspector(DBus::Connection &conn, const char *path, const char *service) - : DBus::ObjectProxy(conn, path, service) - {} + DBusInspector(DBus::Connection &conn, const char *path, const char *service) + : DBus::ObjectProxy(conn, path, service) + {} }; class DBusBrowser -: public org::freedesktop::DBus_proxy, + : public org::freedesktop::DBus_proxy, public DBus::IntrospectableProxy, public DBus::ObjectProxy, public Gtk::Window { public: - DBusBrowser(::DBus::Connection &); + DBusBrowser(::DBus::Connection &); private: - void NameOwnerChanged(const std::string &, const std::string &, const std::string &); + void NameOwnerChanged(const std::string &, const std::string &, const std::string &); - void NameLost(const std::string &); + void NameLost(const std::string &); - void NameAcquired(const std::string &); + void NameAcquired(const std::string &); - void on_select_busname(); + 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: - class InspectRecord : public Gtk::TreeModel::ColumnRecord - { - public: + class InspectRecord : public Gtk::TreeModel::ColumnRecord + { + public: - InspectRecord() { add(name); } + InspectRecord() + { + add(name); + } - Gtk::TreeModelColumn<Glib::ustring> name; - }; + Gtk::TreeModelColumn<Glib::ustring> name; + }; - Gtk::VBox _vbox; - Gtk::ScrolledWindow _sc_tree; - Gtk::ComboBoxText _cb_busnames; - Gtk::TreeView _tv_inspect; - Glib::RefPtr<Gtk::TreeStore> _tm_inspect; - InspectRecord _records; + Gtk::VBox _vbox; + Gtk::ScrolledWindow _sc_tree; + Gtk::ComboBoxText _cb_busnames; + Gtk::TreeView _tv_inspect; + Glib::RefPtr<Gtk::TreeStore> _tm_inspect; + InspectRecord _records; }; #endif//__DEMO_DBUS_BROWSER_H diff --git a/examples/hal/hal-listen.cpp b/examples/hal/hal-listen.cpp index 1939f8a..bb70b1a 100644 --- a/examples/hal/hal-listen.cpp +++ b/examples/hal/hal-listen.cpp @@ -8,122 +8,122 @@ #include <iostream> HalManagerProxy::HalManagerProxy(DBus::Connection &connection) -: DBus::InterfaceProxy("org.freedesktop.Hal.Manager"), - DBus::ObjectProxy(connection, "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal") + : DBus::InterfaceProxy("org.freedesktop.Hal.Manager"), + DBus::ObjectProxy(connection, "/org/freedesktop/Hal/Manager", "org.freedesktop.Hal") { - connect_signal(HalManagerProxy, DeviceAdded, DeviceAddedCb); - connect_signal(HalManagerProxy, DeviceRemoved, DeviceRemovedCb); + connect_signal(HalManagerProxy, DeviceAdded, DeviceAddedCb); + connect_signal(HalManagerProxy, DeviceRemoved, DeviceRemovedCb); - std::vector< std::string > devices = GetAllDevices(); + std::vector< std::string > devices = GetAllDevices(); - std::vector< std::string >::iterator it; - for (it = devices.begin(); it != devices.end(); ++it) - { - DBus::Path udi = *it; + std::vector< std::string >::iterator it; + for (it = devices.begin(); it != devices.end(); ++it) + { + DBus::Path udi = *it; - std::cout << "found device " << udi << std::endl; + std::cout << "found device " << udi << std::endl; - _devices[udi] = new HalDeviceProxy(connection, udi); - } + _devices[udi] = new HalDeviceProxy(connection, udi); + } } std::vector< std::string > HalManagerProxy::GetAllDevices() { - std::vector< std::string > udis; - DBus::CallMessage call; + std::vector< std::string > udis; + DBus::CallMessage call; - call.member("GetAllDevices"); + call.member("GetAllDevices"); - DBus::Message reply = invoke_method(call); - DBus::MessageIter it = reply.reader(); + DBus::Message reply = invoke_method(call); + DBus::MessageIter it = reply.reader(); - it >> udis; - return udis; + it >> udis; + return udis; } void HalManagerProxy::DeviceAddedCb(const DBus::SignalMessage &sig) { - DBus::MessageIter it = sig.reader(); - std::string devname; + DBus::MessageIter it = sig.reader(); + std::string devname; - it >> devname; + it >> devname; - DBus::Path udi(devname); + DBus::Path udi(devname); - _devices[devname] = new HalDeviceProxy(conn(), udi); - std::cout << "added device " << udi << std::endl; + _devices[devname] = new HalDeviceProxy(conn(), udi); + std::cout << "added device " << udi << std::endl; } void HalManagerProxy::DeviceRemovedCb(const DBus::SignalMessage &sig) { - DBus::MessageIter it = sig.reader(); - std::string devname; + DBus::MessageIter it = sig.reader(); + std::string devname; - it >> devname; + it >> devname; - std::cout << "removed device " << devname << std::endl; + std::cout << "removed device " << devname << std::endl; - _devices.erase(devname); + _devices.erase(devname); } HalDeviceProxy::HalDeviceProxy(DBus::Connection &connection, DBus::Path &udi) -: DBus::InterfaceProxy("org.freedesktop.Hal.Device"), - DBus::ObjectProxy(connection, udi, "org.freedesktop.Hal") + : DBus::InterfaceProxy("org.freedesktop.Hal.Device"), + DBus::ObjectProxy(connection, udi, "org.freedesktop.Hal") { - connect_signal(HalDeviceProxy, PropertyModified, PropertyModifiedCb); - connect_signal(HalDeviceProxy, Condition, ConditionCb); + connect_signal(HalDeviceProxy, PropertyModified, PropertyModifiedCb); + connect_signal(HalDeviceProxy, Condition, ConditionCb); } void HalDeviceProxy::PropertyModifiedCb(const DBus::SignalMessage &sig) { - typedef DBus::Struct< std::string, bool, bool > HalProperty; + typedef DBus::Struct< std::string, bool, bool > HalProperty; - DBus::MessageIter it = sig.reader(); - int32_t number; + DBus::MessageIter it = sig.reader(); + int32_t number; - it >> number; + it >> number; - DBus::MessageIter arr = it.recurse(); + DBus::MessageIter arr = it.recurse(); - for (int i = 0; i < number; ++i, ++arr) - { - HalProperty hp; + for (int i = 0; i < number; ++i, ++arr) + { + HalProperty hp; - arr >> hp; + arr >> hp; - std::cout << "modified property " << hp._1 << " in " << path() << std::endl; - } + std::cout << "modified property " << hp._1 << " in " << path() << std::endl; + } } void HalDeviceProxy::ConditionCb(const DBus::SignalMessage &sig) { - DBus::MessageIter it = sig.reader(); - std::string condition; + DBus::MessageIter it = sig.reader(); + std::string condition; - it >> condition; + it >> condition; - std::cout << "encountered condition " << condition << " in " << path() << std::endl; + std::cout << "encountered condition " << condition << " in " << path() << std::endl; } DBus::BusDispatcher dispatcher; void niam(int sig) { - dispatcher.leave(); + dispatcher.leave(); } int main() { - signal(SIGTERM, niam); - signal(SIGINT, niam); + signal(SIGTERM, niam); + signal(SIGINT, niam); - DBus::default_dispatcher = &dispatcher; + DBus::default_dispatcher = &dispatcher; - DBus::Connection conn = DBus::Connection::SystemBus(); + DBus::Connection conn = DBus::Connection::SystemBus(); - HalManagerProxy hal(conn); + HalManagerProxy hal(conn); - dispatcher.enter(); + dispatcher.enter(); - return 0; + return 0; } diff --git a/examples/hal/hal-listen.h b/examples/hal/hal-listen.h index 12862e6..85c8cca 100644 --- a/examples/hal/hal-listen.h +++ b/examples/hal/hal-listen.h @@ -8,37 +8,37 @@ class HalDeviceProxy; class HalManagerProxy -: public DBus::InterfaceProxy, + : public DBus::InterfaceProxy, public DBus::ObjectProxy { public: - HalManagerProxy(DBus::Connection &connection); + HalManagerProxy(DBus::Connection &connection); - std::vector< std::string > GetAllDevices(); + std::vector< std::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< std::string, DBus::RefPtr< HalDeviceProxy > > _devices; + std::map< std::string, DBus::RefPtr< HalDeviceProxy > > _devices; }; class HalDeviceProxy -: public DBus::InterfaceProxy, + : public DBus::InterfaceProxy, public DBus::ObjectProxy { 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/propsgs-client.cpp b/examples/properties/propsgs-client.cpp index d4b51f4..01eb403 100644 --- a/examples/properties/propsgs-client.cpp +++ b/examples/properties/propsgs-client.cpp @@ -9,64 +9,64 @@ static const char *PROPS_SERVER_NAME = "org.freedesktop.DBus.Examples.Properties static const char *PROPS_SERVER_PATH = "/org/freedesktop/DBus/Examples/Properties"; PropsClient::PropsClient(DBus::Connection &connection, const char *path, const char *name) -: DBus::ObjectProxy(connection, path, name) + : DBus::ObjectProxy(connection, path, name) { } -void PropsClient::MessageChanged(const std::string& message) +void PropsClient::MessageChanged(const std::string &message) { - std::cout << "MessageChanged signal, new value: " << message << "\n"; + std::cout << "MessageChanged signal, new value: " << message << "\n"; }; -void PropsClient::DataChanged(const double& data) +void PropsClient::DataChanged(const double &data) { - std::cout << "DataChanged signal, new value:" << data << "\n"; + std::cout << "DataChanged signal, new value:" << data << "\n"; }; -void *test_property_proxy(void * input) +void *test_property_proxy(void *input) { - PropsClient *client = static_cast<PropsClient*>(input); + PropsClient *client = static_cast<PropsClient *>(input); - std::cout << "read property 'Version', value:" << client->Version() << "\n"; + std::cout << "read property 'Version', value:" << client->Version() << "\n"; - std::cout << "read property 'Message', value:" << client->Message() << "\n"; - - client->Message("message set by property access"); - std::cout << "wrote property 'Message'\n"; - - std::cout << "read property 'Message', value:" << client->Message() << "\n"; - - client->Data(1.1); - std::cout << "wrote property 'Data'\n"; + std::cout << "read property 'Message', value:" << client->Message() << "\n"; - return NULL; + client->Message("message set by property access"); + std::cout << "wrote property 'Message'\n"; + + std::cout << "read property 'Message', value:" << client->Message() << "\n"; + + client->Data(1.1); + std::cout << "wrote property 'Data'\n"; + + return NULL; } DBus::BusDispatcher dispatcher; void niam(int sig) { - dispatcher.leave(); - pthread_exit(NULL); + dispatcher.leave(); + pthread_exit(NULL); } int main() { - signal(SIGTERM, niam); - signal(SIGINT, niam); + signal(SIGTERM, niam); + signal(SIGINT, niam); - DBus::default_dispatcher = &dispatcher; + DBus::default_dispatcher = &dispatcher; - DBus::_init_threading(); + DBus::_init_threading(); - DBus::Connection conn = DBus::Connection::SessionBus(); + DBus::Connection conn = DBus::Connection::SessionBus(); - PropsClient client (conn, PROPS_SERVER_PATH, PROPS_SERVER_NAME); + PropsClient client(conn, PROPS_SERVER_PATH, PROPS_SERVER_NAME); - pthread_t thread; - pthread_create(&thread, NULL, test_property_proxy, &client); + pthread_t thread; + pthread_create(&thread, NULL, test_property_proxy, &client); - dispatcher.enter(); + dispatcher.enter(); - return 0; + return 0; } diff --git a/examples/properties/propsgs-client.h b/examples/properties/propsgs-client.h index 99b70c5..a09b21d 100644 --- a/examples/properties/propsgs-client.h +++ b/examples/properties/propsgs-client.h @@ -5,18 +5,18 @@ #include "propsgs-glue-proxy.h" class PropsClient -: public org::freedesktop::DBus::PropsGSDemo_proxy, + : public org::freedesktop::DBus::PropsGSDemo_proxy, public DBus::IntrospectableProxy, public DBus::PropertiesProxy, public DBus::ObjectProxy { public: - PropsClient(DBus::Connection &connection, const char *path, const char *name); - - void MessageChanged(const std::string& message); + PropsClient(DBus::Connection &connection, const char *path, const char *name); - void DataChanged(const double& data); + void MessageChanged(const std::string &message); + + void DataChanged(const double &data); }; #endif//__DEMO_PROPS_SERVER_H diff --git a/examples/properties/propsgs-server.cpp b/examples/properties/propsgs-server.cpp index c3ff23f..56ba248 100644 --- a/examples/properties/propsgs-server.cpp +++ b/examples/properties/propsgs-server.cpp @@ -6,51 +6,51 @@ 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) -: DBus::ObjectAdaptor(connection, PROPS_SERVER_PATH) + : DBus::ObjectAdaptor(connection, PROPS_SERVER_PATH) { - Version = 1; - Message = "default message"; + Version = 1; + Message = "default message"; } void PropsServer::on_set_property - (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value) +(DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value) { - if (property == "Message") - { - std::cout << "'Message' has been changed\n"; - - std::string msg = value; - this->MessageChanged(msg); - } - if (property == "Data") - { - std::cout << "'Data' has been changed\n"; - - double data = value; - this->DataChanged(data); - } + if (property == "Message") + { + std::cout << "'Message' has been changed\n"; + + std::string msg = value; + this->MessageChanged(msg); + } + if (property == "Data") + { + std::cout << "'Data' has been changed\n"; + + double data = value; + this->DataChanged(data); + } } DBus::BusDispatcher dispatcher; void niam(int sig) { - dispatcher.leave(); + dispatcher.leave(); } int main() { - signal(SIGTERM, niam); - signal(SIGINT, niam); + signal(SIGTERM, niam); + signal(SIGINT, niam); - DBus::default_dispatcher = &dispatcher; + DBus::default_dispatcher = &dispatcher; - DBus::Connection conn = DBus::Connection::SessionBus(); - conn.request_name(PROPS_SERVER_NAME); + DBus::Connection conn = DBus::Connection::SessionBus(); + conn.request_name(PROPS_SERVER_NAME); - PropsServer server(conn); + PropsServer server(conn); - dispatcher.enter(); + dispatcher.enter(); - return 0; + return 0; } diff --git a/examples/properties/propsgs-server.h b/examples/properties/propsgs-server.h index a3169d6..3c2df1a 100644 --- a/examples/properties/propsgs-server.h +++ b/examples/properties/propsgs-server.h @@ -5,17 +5,17 @@ #include "propsgs-glue-adaptor.h" class PropsServer -: public org::freedesktop::DBus::PropsGSDemo_adaptor, + : public org::freedesktop::DBus::PropsGSDemo_adaptor, public DBus::IntrospectableAdaptor, public DBus::PropertiesAdaptor, public DBus::ObjectAdaptor { public: - PropsServer(DBus::Connection &connection); + PropsServer(DBus::Connection &connection); - void on_set_property - (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value); + void on_set_property + (DBus::InterfaceAdaptor &interface, const std::string &property, const DBus::Variant &value); }; #endif//__DEMO_PROPS_SERVER_H |