NetworkManager::NetworkManager(QObject* parent) : QObject(parent), m_manager(NULL), m_defaultRoute(NULL), m_invalidDefaultRoute(new NetworkService("/", QVariantMap(), this)), watcher(NULL), m_available(false), m_servicesEnabled(true), m_technologiesEnabled(true) { registerCommonDataTypes(); watcher = new QDBusServiceWatcher("net.connman",QDBusConnection::systemBus(), QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); connect(watcher, SIGNAL(serviceRegistered(QString)), this, SLOT(connectToConnman(QString))); connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(connmanUnregistered(QString))); m_available = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman"); if (m_available) connectToConnman(); else qDebug() << "connman not AVAILABLE"; }
NetworkManager::NetworkManager(QObject* parent) : QObject(parent), m_manager(NULL), m_getPropertiesWatcher(NULL), m_getTechnologiesWatcher(NULL), m_getServicesWatcher(NULL), m_defaultRoute(NULL), watcher(NULL), m_available(false) { registerCommonDataTypes(); watcher = new QDBusServiceWatcher("net.connman",QDBusConnection::systemBus(), QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration, this); connect(watcher, SIGNAL(serviceRegistered(QString)), this, SLOT(connectToConnman(QString))); connect(watcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(connmanUnregistered(QString))); m_available = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman"); if(m_available) connectToConnman(); }
void NetworkManager::getPropertiesReply(QDBusPendingCallWatcher *call) { Q_ASSERT(call); pr_dbg() << "Got reply with manager's properties"; QDBusPendingReply<QVariantMap> reply = *call; if (reply.isError()) { pr_dbg() << "Error getPropertiesReply: " << reply.error().message(); disconnectFromConnman(); // TODO: set up timer to reconnect in a bit QTimer::singleShot(10000,this,SLOT(connectToConnman())); } else { m_propertiesCache = reply.value(); pr_dbg() << "Initial Manager's properties"; pr_dbg() << "\tState: " << m_propertiesCache[State].toString(); pr_dbg() << "\tOfflineMode: " << m_propertiesCache[OfflineMode].toString(); emit stateChanged(m_propertiesCache[State].toString()); connect(m_manager, SIGNAL(PropertyChanged(const QString&, const QDBusVariant&)), this, SLOT(propertyChanged(const QString&, const QDBusVariant&))); } }