Ilya Moiseenko | 656d52d | 2013-10-25 14:19:10 -0700 | [diff] [blame^] | 1 | /* -*- 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 | |
| 11 | NetworkManager::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 | |
| 25 | void NetworkManager::stateChanged(uint state) |
| 26 | { |
| 27 | qDebug() << "State = " << state; |
| 28 | |
| 29 | if(state == NM_STATE_CONNECTED_GLOBAL) |
| 30 | autoconfigDaemon(); |
| 31 | } |
| 32 | |
| 33 | void NetworkManager::autoconfigDaemon() |
| 34 | { |
| 35 | QProcess *process = new QProcess(); |
| 36 | process->start(NDND_AUTOCONFIG_COMMAND); |
| 37 | } |