imported D-Bus C++ library
git-svn-id: http://dev.openwengo.org/svn/openwengo/wengophone-ng/branches/wengophone-dbus-api/libs/dbus@7382 30a43799-04e7-0310-8b2b-ea0d24f86d0e
This commit is contained in:
commit
acfeb85b87
89 changed files with 92818 additions and 0 deletions
52
examples/server.cpp
Normal file
52
examples/server.cpp
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#include "server.h"
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
class EchoServer :
|
||||
public EchoInterface,
|
||||
public DBus::IntrospectableAdaptor,
|
||||
public DBus::ObjectAdaptor
|
||||
{
|
||||
public:
|
||||
EchoServer( DBus::Connection& conn ) : DBus::ObjectAdaptor(conn, "/org/test/cbus/EchoServer")
|
||||
{}
|
||||
|
||||
DBus::Message Echo( const DBus::CallMessage& msg )
|
||||
{
|
||||
DBus::MessageIter r = msg.r_iter();
|
||||
|
||||
DBus::ReturnMessage ret(msg);
|
||||
DBus::MessageIter w = ret.w_iter();
|
||||
|
||||
const char* string = r.get_string();
|
||||
|
||||
w.append_string(string);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
DBus::BusDispatcher dispatcher;
|
||||
|
||||
void niam( int sig )
|
||||
{
|
||||
dispatcher.leave();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
signal(SIGTERM, niam);
|
||||
signal(SIGINT, niam);
|
||||
|
||||
DBus::default_dispatcher = &dispatcher;
|
||||
|
||||
DBus::Connection conn = DBus::Connection::SessionBus();
|
||||
conn.request_name("org.test.cbus");
|
||||
|
||||
EchoServer server(conn);
|
||||
|
||||
dispatcher.enter();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue