dbus-cplusplus/examples/ecore/dbus_ecore.cpp
Andreas Volz 1c8e43e6d6 - NO FUNCTIONAL CODE CHANGES!!!!
- changed code formating from tabs to spaces and others
- used astyle with this option:
  --style=ansi --indent=spaces=2 -M --pad-oper --unpad-paren --pad-header --align-pointer=name --lineend=linux
2011-11-28 12:44:11 +01:00

71 lines
1.3 KiB
C++

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "dbus_ecore.h"
#include <xml.h>
#include <iostream>
#include <vector>
using namespace std;
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)
{
typedef std::vector< std::string > Names;
Names names = ListNames();
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)
{
cout << name << ": " << old_owner << " -> " << new_owner << endl;
}
void DBusBrowser::NameLost(const std::string &name)
{
cout << name << " lost" << endl;
}
void DBusBrowser::NameAcquired(const std::string &name)
{
cout << name << " acquired" << endl;
}
DBus::Ecore::BusDispatcher dispatcher;
void niam(int sig)
{
ecore_main_loop_quit();
}
int main(int argc, char *argv[])
{
signal(SIGTERM, niam);
signal(SIGINT, niam);
ecore_init();
DBus::default_dispatcher = &dispatcher;
DBus::Connection conn = DBus::Connection::SessionBus();
DBusBrowser browser(conn);
ecore_main_loop_begin();
ecore_shutdown();
return 0;
}