summaryrefslogtreecommitdiff
path: root/examples/echo/echo-server.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/echo/echo-server.cpp')
-rw-r--r--examples/echo/echo-server.cpp58
1 files changed, 29 insertions, 29 deletions
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;
}