blob: 22e63d2a01c9bb7e41ac91f6f446672eb0a7f17d [file] [log] [blame]
Ilya Moiseenko656d52d2013-10-25 14:19:10 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * @copyright See LICENCE for copyright and license information.
4 *
5 * @author Ilya Moiseenko <iliamo@ucla.edu>
6 */
7
8#include "network-manager.h"
9#include <QProcess>
10
11NetworkManager::NetworkManager()
12{
13 if (!QDBusConnection::systemBus().isConnected())
14 {
15 qDebug() << "Cannot connect to the D-Bus session bus.\n";
16 return;
17 }
18
19 QDBusConnection::systemBus().connect("org.freedesktop.NetworkManager",
20 "/org/freedesktop/NetworkManager",
21 "org.freedesktop.NetworkManager",
22 "StateChanged", this, SLOT(stateChanged(uint)));
23}
24
25void NetworkManager::stateChanged(uint state)
26{
27 qDebug() << "State = " << state;
28
29 if(state == NM_STATE_CONNECTED_GLOBAL)
30 autoconfigDaemon();
31}
32
33void NetworkManager::autoconfigDaemon()
34{
35 QProcess *process = new QProcess();
36 process->start(NDND_AUTOCONFIG_COMMAND);
37}