summaryrefslogtreecommitdiff
path: root/examples/echo_ecore
diff options
context:
space:
mode:
Diffstat (limited to 'examples/echo_ecore')
-rw-r--r--examples/echo_ecore/echo-client.cpp118
-rw-r--r--examples/echo_ecore/echo-client.h6
-rw-r--r--examples/echo_ecore/echo-server.cpp58
-rw-r--r--examples/echo_ecore/echo-server.h16
4 files changed, 99 insertions, 99 deletions
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