Commit 807ae2af authored by Julien Bonjean's avatar Julien Bonjean

[#1671] NetworkManager support: first shot

parent c5f62c09
......@@ -17,7 +17,8 @@ libdbus_la_SOURCES = \
callmanager.cpp \
configurationmanager.cpp \
instance.cpp \
dbusmanagerimpl.cpp
dbusmanagerimpl.cpp \
networkmanager.cpp
libdbus_la_CXXFLAGS = -DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\"
......@@ -29,6 +30,8 @@ noinst_HEADERS = \
instance.h \
dbusmanager.h \
dbusmanagerimpl.h \
networkmanager_proxy.h \
networkmanager.h \
$(BUILT_SOURCES)
# Dbus service file
......
......@@ -23,6 +23,7 @@
#include "callmanager.h"
#include "configurationmanager.h"
#include "networkmanager.h"
const char* DBusManagerImpl::SERVER_NAME = "org.sflphone.SFLphone";
......@@ -32,12 +33,15 @@ DBusManagerImpl::exec()
DBus::default_dispatcher = &_dispatcher;
DBus::Connection conn = DBus::Connection::SessionBus();
conn.request_name (SERVER_NAME);
DBus::Connection sessionConnection = DBus::Connection::SessionBus();
DBus::Connection systemConnection = DBus::Connection::SystemBus();
sessionConnection.request_name (SERVER_NAME);
_callManager = new CallManager (conn);
_configurationManager = new ConfigurationManager (conn);
_instanceManager = new Instance (conn);
_callManager = new CallManager (sessionConnection);
_configurationManager = new ConfigurationManager (sessionConnection);
_instanceManager = new Instance (sessionConnection);
_networkManager = new NetworkManager(systemConnection, "/org/freedesktop/NetworkManager", "");
// Register accounts
Manager::instance().initRegisterAccounts(); //getEvents();
......
......@@ -24,6 +24,7 @@
class ConfigurationManager;
class CallManager;
class NetworkManager;
class DBusManagerImpl {
public:
......@@ -38,6 +39,7 @@ class DBusManagerImpl {
ConfigurationManager* _configurationManager;
Instance* _instanceManager;
DBus::BusDispatcher _dispatcher;
NetworkManager* _networkManager;
};
#endif
#include "networkmanager.h"
#include <iostream>
using namespace std;
const string NetworkManager::statesString[5] = {"unknown", "asleep", "connecting", "connected", "disconnected"};
string NetworkManager::stateAsString(const uint32_t& state)
{
return statesString[state];
}
void NetworkManager::StateChanged(const uint32_t& state)
{
std::cout << "state changed: " << stateAsString(state) << std::endl;
}
NetworkManager::NetworkManager(DBus::Connection& connection, const DBus::Path& path, const char* destination): DBus::ObjectProxy (connection, path, destination)
{
}
#ifndef NETWORKMANAGER_H
#define NETWORKMANAGER_H
#include "networkmanager_proxy.h"
using namespace std;
class NetworkManager
: public org::freedesktop::NetworkManager_proxy,
public DBus::IntrospectableProxy,
public DBus::ObjectProxy
{
public:
NetworkManager(DBus::Connection&, const DBus::Path&, const char*);
void StateChanged(const uint32_t& state);
string stateAsString(const uint32_t& state);
typedef enum NMState
{
NM_STATE_UNKNOWN = 0,
NM_STATE_ASLEEP,
NM_STATE_CONNECTING,
NM_STATE_CONNECTED,
NM_STATE_DISCONNECTED
} NMState;
static const string statesString[5];
};
#endif
#ifndef __dbusxx__networkmanager_proxy_h__PROXY_MARSHAL_H
#define __dbusxx__networkmanager_proxy_h__PROXY_MARSHAL_H
#include <dbus-c++/dbus.h>
#include <cassert>
#include <iostream>
namespace org {
namespace freedesktop {
class NetworkManager_proxy
: public ::DBus::InterfaceProxy
{
public:
NetworkManager_proxy()
: ::DBus::InterfaceProxy("org.freedesktop.NetworkManager")
{
connect_signal(NetworkManager_proxy, StateChanged, _StateChanged_stub);
}
public:
/* properties exported by this interface */
public:
/* methods exported by this interface,
* this functions will invoke the corresponding methods on the remote objects
*/
/*
std::vector< ::DBus::Path > GetDevices()
{
::DBus::CallMessage call;
call.member("GetDevices");
::DBus::Message ret = invoke_method (call);
::DBus::MessageIter ri = ret.reader();
std::vector< ::DBus::Path > argout;
ri >> argout;
return argout;
}
*/
public:
/* signal handlers for this interface
*/
virtual void StateChanged(const uint32_t& argin0) = 0;
private:
/* unmarshalers (to unpack the DBus message before calling the actual signal handler)
*/
void _StateChanged_stub(const ::DBus::SignalMessage &sig)
{
::DBus::MessageIter ri = sig.reader();
uint32_t arg0;
ri >> arg0;
StateChanged(arg0);
}
};
} }
#endif //__dbusxx__networkmanager_proxy_h__PROXY_MARSHAL_H
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.freedesktop.NetworkManager">
<method name="GetDevices">
<arg name="devices" type="ao" direction="out"/>
</method>
<signal name="StateChanged">
<arg type="u"/>
</signal>
</interface>
</node>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment