void NetworkTechnology::init(const QString &path) { m_path = path; if (m_technology) { delete m_technology; m_technology = 0; // TODO: After resetting the path iterate through old properties, compare their values // with new ones and emit corresponding signals if changed. m_propertiesCache.clear(); } m_technology = new Technology("net.connman", path, QDBusConnection::systemBus(), this); if (!m_technology->isValid()) { pr_dbg() << "Invalid technology: " << path; throw -1; // FIXME } if (m_propertiesCache.isEmpty()) { QDBusReply<QVariantMap> reply; reply = m_technology->GetProperties(); m_propertiesCache = reply.value(); } emit poweredChanged(powered()); emit connectedChanged(connected()); connect(m_technology, SIGNAL(PropertyChanged(const QString&, const QDBusVariant&)), this, SLOT(propertyChanged(const QString&, const QDBusVariant&))); }
void NetworkTechnology::propertyChanged(const QString &name, const QDBusVariant &value) { QVariant tmp = value.variant(); Q_ASSERT(m_technology); m_propertiesCache[name] = tmp; if (name == Powered) { emit poweredChanged(tmp.toBool()); } else if (name == Connected) { emit connectedChanged(tmp.toBool()); } else if (name == IdleTimeout) { emit idleTimeoutChanged(tmp.toUInt()); } else if (name == Tethering) { emit tetheringChanged(tmp.toBool()); } else if (name == TetheringIdentifier) { emit tetheringIdChanged(tmp.toString()); } else if (name == TetheringPassphrase) { emit tetheringPassphraseChanged(tmp.toString()); } }
void TechnologyModel::doUpdateTechnologies() { NetworkTechnology *newTech = m_manager->getTechnology(m_techname); if (m_tech == newTech) return; bool oldPowered = false; bool oldConnected = false; if (m_tech) { oldPowered = m_tech->powered(); oldConnected = m_tech->connected(); disconnect(m_tech, SIGNAL(poweredChanged(bool)), this, SLOT(changedPower(bool))); disconnect(m_tech, SIGNAL(connectedChanged(bool)), this, SLOT(changedConnected(bool))); disconnect(m_tech, SIGNAL(scanFinished()), this, SLOT(finishedScan())); } if (m_scanning) { m_scanning = false; Q_EMIT scanningChanged(m_scanning); } m_tech = newTech; if (m_tech) { connect(m_tech, SIGNAL(poweredChanged(bool)), this, SLOT(changedPower(bool))); connect(m_tech, SIGNAL(connectedChanged(bool)), this, SLOT(changedConnected(bool))); connect(m_tech, SIGNAL(scanFinished()), this, SLOT(finishedScan())); bool b = m_tech->powered(); if (b != oldPowered) Q_EMIT poweredChanged(b); b = m_tech->connected(); if (b != oldConnected) Q_EMIT connectedChanged(b); } else { if (oldPowered)