qDebug() << p.name() <<": isvalid->" <<p.isValid() << " type->"<< p.type() << " roaming->" << p.isRoamingAvailable() << "identifier->" << p.identifier() << " purpose->" << p.purpose() << " state->" << p.state(); } void tst_QNetworkConfigurationManager::allConfigurations() { QNetworkConfigurationManager manager; QList<QNetworkConfiguration> preScanConfigs = manager.allConfigurations(); foreach(QNetworkConfiguration c, preScanConfigs) { QVERIFY2(c.type()!=QNetworkConfiguration::UserChoice, "allConfiguration must not return UserChoice configs"); } QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); //initiate scans QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete QList<QNetworkConfiguration> configs = manager.allConfigurations(); int all = configs.count(); qDebug() << "All configurations:" << all; QVERIFY(all); foreach(QNetworkConfiguration p, configs) { QVERIFY(p.isValid()); printConfigurationDetails(p); QVERIFY(p.type() != QNetworkConfiguration::Invalid); QVERIFY(p.type() != QNetworkConfiguration::UserChoice); }
/*! Constructs a QNetworkConfigurationManager with the given \a parent. */ QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent ) : QObject(parent) { QNetworkConfigurationManagerPrivate* priv = connManager(); connect(priv, SIGNAL(configurationAdded(const QNetworkConfiguration&)), this, SIGNAL(configurationAdded(const QNetworkConfiguration&))); connect(priv, SIGNAL(configurationRemoved(const QNetworkConfiguration&)), this, SIGNAL(configurationRemoved(const QNetworkConfiguration&))); connect(&(priv->impl), SIGNAL(updateCompleted()), this, SIGNAL(updateCompleted())); connect(&(priv->impl), SIGNAL(onlineStateChanged(bool)), this, SIGNAL(onlineStateChanged(bool))); connect(priv, SIGNAL(configurationChanged(const QNetworkConfiguration&)), this, SIGNAL(configurationChanged(const QNetworkConfiguration&))); }
AsemanNetworkManager::AsemanNetworkManager(QObject *parent) : QObject(parent) { p = new AsemanNetworkCheckerPrivate; p->network = new QNetworkConfigurationManager(this); p->defaultItem = new AsemanNetworkManagerItem(this); p->updateTimer = new QTimer(this); p->updateTimer->setInterval(1000); p->updateTimer->start(); p->lastConfig = p->network->defaultConfiguration(); connect(p->network, SIGNAL(configurationAdded(QNetworkConfiguration)), SLOT(configureAdded(QNetworkConfiguration))); connect(p->network, SIGNAL(configurationChanged(QNetworkConfiguration)), this, SLOT(configureChanged(QNetworkConfiguration))); connect(p->network, SIGNAL(configurationRemoved(QNetworkConfiguration)), SLOT(configureRemoved(QNetworkConfiguration))); connect(p->network, SIGNAL(updateCompleted()), SLOT(updateCheck())); connect(p->updateTimer, SIGNAL(timeout()), SLOT(updateCheck())); foreach(const QNetworkConfiguration &config, p->network->allConfigurations()) configureAdded(config); updateCheck(); }
void QConnmanEngine::initialize() { QMutexLocker locker(&mutex); connect(ofonoManager,SIGNAL(modemChanged()),this,SLOT(changedModem())); ofonoNetwork = new QOfonoNetworkRegistrationInterface(ofonoManager->currentModem(),this); ofonoContextManager = new QOfonoDataConnectionManagerInterface(ofonoManager->currentModem(),this); connect(ofonoContextManager,SIGNAL(roamingAllowedChanged(bool)),this,SLOT(reEvaluateCellular())); connect(connmanManager,SIGNAL(servicesChanged(ConnmanMapList, QList<QDBusObjectPath>)), this, SLOT(updateServices(ConnmanMapList, QList<QDBusObjectPath>))); connect(connmanManager,SIGNAL(servicesReady(QStringList)),this,SLOT(servicesReady(QStringList))); connect(connmanManager,SIGNAL(scanFinished()),this,SLOT(finishedScan())); foreach (const QString &servPath, connmanManager->getServices()) { addServiceConfiguration(servPath); } Q_EMIT updateCompleted(); QSettings confFile(QStringLiteral("nemomobile"),QStringLiteral("connectionagent")); inotifyFileDescriptor = ::inotify_init(); inotifyWatcher = ::inotify_add_watch(inotifyFileDescriptor, QFile::encodeName(confFile.fileName()), IN_MODIFY); if (inotifyWatcher > 0) { QSocketNotifier *notifier = new QSocketNotifier(inotifyFileDescriptor, QSocketNotifier::Read, this); connect(notifier, SIGNAL(activated(int)), this, SLOT(inotifyActivated())); }
BearerMonitor::BearerMonitor(QWidget *parent) : QWidget(parent) { setupUi(this); #ifdef MAEMO_UI newSessionButton->hide(); deleteSessionButton->hide(); #else delete tabWidget->currentWidget(); sessionGroup->hide(); #endif updateConfigurations(); onlineStateChanged(!manager.allConfigurations(QNetworkConfiguration::Active).isEmpty()); QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration(); for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) { QTreeWidgetItem *item = treeWidget->topLevelItem(i); if (item->data(0, Qt::UserRole).toString() == defaultConfiguration.identifier()) { treeWidget->setCurrentItem(item); showConfigurationFor(item); break; } } connect(&manager, SIGNAL(onlineStateChanged(bool)), this ,SLOT(onlineStateChanged(bool))); connect(&manager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), this, SLOT(configurationAdded(const QNetworkConfiguration&))); connect(&manager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)), this, SLOT(configurationRemoved(const QNetworkConfiguration&))); connect(&manager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), this, SLOT(configurationChanged(const QNetworkConfiguration))); connect(&manager, SIGNAL(updateCompleted()), this, SLOT(updateConfigurations())); #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) connect(registerButton, SIGNAL(clicked()), this, SLOT(registerNetwork())); connect(unregisterButton, SIGNAL(clicked()), this, SLOT(unregisterNetwork())); #else // Q_OS_WIN && !Q_OS_WINRT nlaGroup->hide(); #endif connect(treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(createSessionFor(QTreeWidgetItem*))); connect(treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(showConfigurationFor(QTreeWidgetItem*))); connect(newSessionButton, SIGNAL(clicked()), this, SLOT(createNewSession())); #ifndef MAEMO_UI connect(deleteSessionButton, SIGNAL(clicked()), this, SLOT(deleteSession())); #endif connect(scanButton, SIGNAL(clicked()), this, SLOT(performScan())); // Just in case update all configurations so that all // configurations are up to date. manager.updateConfigurations(); }
void QServiceDiscovery::initializeNetworkSession() { // now begin the process of opening the network link m_networkConfigManager = new QNetworkConfigurationManager(this); connect(m_networkConfigManager, SIGNAL(updateCompleted()), this, SLOT(openNetworkSession())); m_networkConfigManager->updateConfigurations(); m_networkConfigTimer->start(); // update the connections cyclically }
void QNativeWifiEngine::requestUpdate() { QMutexLocker locker(&mutex); if (!available()) { locker.unlock(); emit updateCompleted(); return; } // enumerate interfaces WLAN_INTERFACE_INFO_LIST *interfaceList; DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); #endif locker.unlock(); emit updateCompleted(); return; } bool requested = false; for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { result = local_WlanScan(handle, &interfaceList->InterfaceInfo[i].InterfaceGuid, 0, 0, 0); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanScan failed with error %ld\n", __FUNCTION__, result); #endif } else { requested = true; } } local_WlanFreeMemory(interfaceList); if (!requested) { locker.unlock(); emit updateCompleted(); } }
void QIcdEngine::initialize() { QMutexLocker locker(&mutex); if (!ensureDBusConnection()) { locker.unlock(); emit updateCompleted(); locker.relock(); } }
void tst_QNetworkConfiguration::comparison() { //test copy constructor and assignment operator //compare invalid connection points QNetworkConfiguration pt1; QVERIFY(!pt1.isValid()); QVERIFY(pt1.type() == QNetworkConfiguration::Invalid); QNetworkConfiguration pt2(pt1); QVERIFY(pt1==pt2); QVERIFY(!(pt1!=pt2)); QVERIFY(pt1.name() == pt2.name()); QVERIFY(pt1.isValid() == pt2.isValid()); QVERIFY(pt1.type() == pt2.type()); QVERIFY(pt1.state() == pt2.state()); QVERIFY(pt1.purpose() == pt2.purpose()); QNetworkConfiguration pt3; pt3 = pt1; QVERIFY(pt1==pt3); QVERIFY(!(pt1!=pt3)); QVERIFY(pt1.name() == pt3.name()); QVERIFY(pt1.isValid() == pt3.isValid()); QVERIFY(pt1.type() == pt3.type()); QVERIFY(pt1.state() == pt3.state()); QVERIFY(pt1.purpose() == pt3.purpose()); //test case must run on machine that has valid connection points QNetworkConfigurationManager manager; QList<QNetworkConfiguration> preScanConfigs = manager.allConfigurations(); QSignalSpy spy(&manager, SIGNAL(updateCompleted())); manager.updateConfigurations(); //initiate scans QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete QList<QNetworkConfiguration> configs = manager.allConfigurations(QNetworkConfiguration::Discovered); QVERIFY(configs.count()); QNetworkConfiguration defaultConfig = manager.defaultConfiguration(); QVERIFY(defaultConfig.isValid()); QVERIFY(defaultConfig.type() != QNetworkConfiguration::Invalid); QVERIFY(!defaultConfig.name().isEmpty()); pt3 = defaultConfig; QVERIFY(defaultConfig==pt3); QVERIFY(!(defaultConfig!=pt3)); QVERIFY(defaultConfig.name() == pt3.name()); QVERIFY(defaultConfig.isValid() == pt3.isValid()); QVERIFY(defaultConfig.type() == pt3.type()); QVERIFY(defaultConfig.state() == pt3.state()); QVERIFY(defaultConfig.purpose() == pt3.purpose()); }
/*! Constructor. */ ConnectionManager::ConnectionManager(QObject *parent) : QObject(parent), mNetworkSession(0), mNetworkConfMgr(0), mState(NotConnected) { // Initialize own IP to localhost. mMyIp.setAddress(QHostAddress::LocalHost); mNetworkConfMgr = new QNetworkConfigurationManager(this); connect(mNetworkConfMgr, SIGNAL(updateCompleted()), this, SLOT(openNewNetworkSession())); }
void DmapClient::updateFinished() { QByteArray array = updateReply->readAll(); DmapStatement statement(array.data(), array.data() + (array.size() - 1), 1); QString name("musr"); QString inside("mupd"); DmapStatement *session = statement.findUniqueValue(name, inside); rid = DmapStatement::byteToInt<quint32>(session->getData()); updateReply->deleteLater(); emit updateCompleted(); }
DownloadManager::DownloadManager(QObject *parent) : QObject(parent) , _pManager(NULL) , _pReply(NULL) , _pFile(NULL) , _configManager() , _nDownloadTotal(0) , _bAcceptRanges(false) , _nDownloadSize(0) , _nDownloadSizeAtPause(0) , _downloading(false) { _pManager = new QNetworkAccessManager(this); connect(&_configManager, SIGNAL(updateCompleted()), this, SLOT(configurationUpdated())); }
BearerEx::BearerEx(QWidget* parent) : QMainWindow(parent) { setupUi(this); createMenus(); connect(&m_NetworkConfigurationManager, SIGNAL(updateCompleted()), this, SLOT(configurationsUpdateCompleted())); connect(&m_NetworkConfigurationManager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), this, SLOT(configurationAdded(const QNetworkConfiguration&))); connect(&m_NetworkConfigurationManager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)), this, SLOT(configurationRemoved(const QNetworkConfiguration&))); connect(&m_NetworkConfigurationManager, SIGNAL(onlineStateChanged(bool)), this, SLOT(onlineStateChanged(bool))); connect(&m_NetworkConfigurationManager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), this, SLOT(configurationChanged(const QNetworkConfiguration&))); showConfigurations(); }
/*! Constructs a QNetworkConfigurationManager with the given \a parent. */ QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent ) : QObject(parent) { QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate(); connect(priv, SIGNAL(configurationAdded(QNetworkConfiguration)), this, SIGNAL(configurationAdded(QNetworkConfiguration))); connect(priv, SIGNAL(configurationRemoved(QNetworkConfiguration)), this, SIGNAL(configurationRemoved(QNetworkConfiguration))); connect(priv, SIGNAL(configurationUpdateComplete()), this, SIGNAL(updateCompleted())); connect(priv, SIGNAL(onlineStateChanged(bool)), this, SIGNAL(onlineStateChanged(bool))); connect(priv, SIGNAL(configurationChanged(QNetworkConfiguration)), this, SIGNAL(configurationChanged(QNetworkConfiguration))); priv->enablePolling(); }
void QConnmanEngine::initialize() { QMutexLocker locker(&mutex); connect(ofonoManager,SIGNAL(modemChanged()),this,SLOT(changedModem())); ofonoNetwork = new QOfonoNetworkRegistrationInterface(ofonoManager->currentModem(),this); ofonoContextManager = new QOfonoDataConnectionManagerInterface(ofonoManager->currentModem(),this); connect(ofonoContextManager,SIGNAL(roamingAllowedChanged(bool)),this,SLOT(reEvaluateCellular())); connect(connmanManager,SIGNAL(servicesChanged(ConnmanMapList,QList<QDBusObjectPath>)), this, SLOT(updateServices(ConnmanMapList,QList<QDBusObjectPath>))); connect(connmanManager,SIGNAL(servicesReady(QStringList)),this,SLOT(servicesReady(QStringList))); connect(connmanManager,SIGNAL(scanFinished()),this,SLOT(finishedScan())); foreach (const QString &servPath, connmanManager->getServices()) { addServiceConfiguration(servPath); } Q_EMIT updateCompleted(); }
void QBBEngine::doRequestUpdate() { qBearerDebug() << Q_FUNC_INFO << "entered method"; netstatus_interface_list_t interfaceList; if ((netstatus_get_interfaces(&interfaceList)) != BPS_SUCCESS) { qBearerDebug() << Q_FUNC_INFO << "cannot retrieve interface list"; return; } const QScopedPointer<netstatus_interface_list_t, NetstatusInterfaceListCleanupHelper> holder(&interfaceList); QSet<QString> currentConfigurations; for (int i = 0; i < interfaceList.num_interfaces; i++) { const char *interface = interfaceList.interfaces[i]; qBearerDebug() << Q_FUNC_INFO << "discovered interface" << interface; updateConfiguration(interface); currentConfigurations << idForName(QString::fromLatin1(interface)); } QMutexLocker locker(&mutex); const QStringList keys = accessPointConfigurations.uniqueKeys(); locker.unlock(); Q_FOREACH (const QString &id, keys) { if (!currentConfigurations.contains(id)) removeConfiguration(id); } Q_EMIT updateCompleted(); }
void QNetworkSessionPrivate::syncStateWithInterface() { connect(&manager, SIGNAL(updateCompleted()), this, SLOT(networkConfigurationsChanged())); connect(&manager, SIGNAL(configurationChanged(QNetworkConfiguration)), this, SLOT(configurationChanged(QNetworkConfiguration))); connect(sessionManager(), SIGNAL(forcedSessionClose(QNetworkConfiguration)), this, SLOT(forcedSessionClose(QNetworkConfiguration))); opened = false; state = QNetworkSession::Invalid; lastError = QNetworkSession::UnknownSessionError; qRegisterMetaType<QNetworkSessionEngine::ConnectionError> ("QNetworkSessionEngine::ConnectionError"); switch (publicConfig.type()) { case QNetworkConfiguration::InternetAccessPoint: activeConfig = publicConfig; engine = getEngineFromId(activeConfig.identifier()); if (engine) { connect(engine, SIGNAL(connectionError(QString,QNetworkSessionEngine::ConnectionError)), this, SLOT(connectionError(QString,QNetworkSessionEngine::ConnectionError)), Qt::QueuedConnection); } break; case QNetworkConfiguration::ServiceNetwork: serviceConfig = publicConfig; // Defer setting engine and signals until open(). // fall through case QNetworkConfiguration::UserChoice: // Defer setting serviceConfig and activeConfig until open(). // fall through default: engine = 0; } networkConfigurationsChanged(); }
MainWindow::MainWindow() : serviceProvider(0), markerManager(0), positionSource(0), lastNavigator(0), tracking(true), firstUpdate(true) { // our actual maps widget is the centre of the mainwindow mapsWidget = new MapsWidget; setCentralWidget(mapsWidget); // set up the menus QMenuBar *mbar = new QMenuBar(this); mbar->addAction("Quit", qApp, SLOT(quit())); mbar->addAction("My Location", this, SLOT(goToMyLocation())); QMenu *searchMenu = new QMenu("Search"); mbar->addMenu(searchMenu); searchMenu->addAction("For address or name", this, SLOT(showSearchDialog())); QMenu *navigateMenu = new QMenu("Directions"); mbar->addMenu(navigateMenu); navigateMenu->addAction("From here to address", this, SLOT(showNavigateDialog())); setMenuBar(mbar); setWindowTitle("Maps Demo"); // now begin the process of opening the network link netConfigManager = new QNetworkConfigurationManager; connect(netConfigManager, SIGNAL(updateCompleted()), this, SLOT(openNetworkSession())); netConfigManager->updateConfigurations(); }
void QGenericEngine::doRequestUpdate() { #ifndef QT_NO_NETWORKINTERFACE QMutexLocker locker(&mutex); // Immediately after connecting with a wireless access point // QNetworkInterface::allInterfaces() will sometimes return an empty list. Calling it again a // second time results in a non-empty list. If we loose interfaces we will end up removing // network configurations which will break current sessions. QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces(); if (interfaces.isEmpty()) interfaces = QNetworkInterface::allInterfaces(); QStringList previous = accessPointConfigurations.keys(); // create configuration for each interface while (!interfaces.isEmpty()) { QNetworkInterface interface = interfaces.takeFirst(); if (!interface.isValid()) continue; // ignore loopback interface if (interface.flags() & QNetworkInterface::IsLoopBack) continue; // ignore WLAN interface handled in separate engine if (qGetInterfaceType(interface.name()) == QNetworkConfiguration::BearerWLAN) continue; uint identifier; if (interface.index()) identifier = qHash(QLatin1String("generic:") + QString::number(interface.index())); else identifier = qHash(QLatin1String("generic:") + interface.hardwareAddress()); const QString id = QString::number(identifier); previous.removeAll(id); QString name = interface.humanReadableName(); if (name.isEmpty()) name = interface.name(); QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined; if((interface.flags() & QNetworkInterface::IsUp) && !interface.addressEntries().isEmpty()) state |= QNetworkConfiguration::Active; if (accessPointConfigurations.contains(id)) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); bool changed = false; ptr->mutex.lock(); if (!ptr->isValid) { ptr->isValid = true; changed = true; } if (ptr->name != name) { ptr->name = name; changed = true; } if (ptr->id != id) { ptr->id = id; changed = true; } if (ptr->state != state) { ptr->state = state; changed = true; } ptr->mutex.unlock(); if (changed) { locker.unlock(); emit configurationChanged(ptr); locker.relock(); } } else { QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); ptr->name = name; ptr->isValid = true; ptr->id = id; ptr->state = state; ptr->type = QNetworkConfiguration::InternetAccessPoint; ptr->bearerType = qGetInterfaceType(interface.name()); accessPointConfigurations.insert(id, ptr); configurationInterface.insert(id, interface.name()); locker.unlock(); emit configurationAdded(ptr); locker.relock(); } } while (!previous.isEmpty()) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(previous.takeFirst()); configurationInterface.remove(ptr->id); locker.unlock(); emit configurationRemoved(ptr); locker.relock(); } locker.unlock(); #endif emit updateCompleted(); }
/*! \class TorcNetwork * \brief Subclass of QNetworkAccessManager for sending network requests and monitoring the network state. * * \todo Check whether authenticationRequired signal is being emitted. */ TorcNetwork::TorcNetwork() : QNetworkAccessManager(), m_online(false), m_manager(new QNetworkConfigurationManager(this)) { LOG(VB_GENERAL, LOG_INFO, "Opening network access manager"); // create settings and establish correct behaviour m_networkGroup = new TorcSettingGroup(gRootSetting, tr("Network")); m_networkAllowed = new TorcSetting(m_networkGroup, SETTING_NETWORKALLOWED, tr("Enable network access"), TorcSetting::Checkbox, true, QVariant((bool)true)); m_networkAllowedInbound = new TorcSetting(m_networkAllowed, SETTING_NETWORKALLOWEDINBOUND, tr("Allow other devices to connect to Torc"), TorcSetting::Checkbox, true, QVariant((bool)true)); m_networkAllowedOutbound = new TorcSetting(m_networkAllowed, SETTING_NETWORKALLOWEDOUTBOUND, tr("Allow Torc to connect to other devices"), TorcSetting::Checkbox, true, QVariant((bool)true)); m_networkAllowed->SetActive(gLocalContext->FlagIsSet(Torc::Network)); m_networkAllowedInbound->SetActiveThreshold(2); m_networkAllowedOutbound->SetActiveThreshold(2); if (m_networkAllowed->IsActive()) { m_networkAllowedInbound->SetActive(true); m_networkAllowedOutbound->SetActive(true); } if (m_networkAllowed->GetValue().toBool()) { m_networkAllowedInbound->SetActive(true); m_networkAllowedOutbound->SetActive(true); } connect(m_networkAllowed, SIGNAL(ValueChanged(bool)), this, SLOT(SetAllowed(bool))); connect(m_networkAllowed, SIGNAL(ValueChanged(bool)), m_networkAllowedInbound, SLOT(SetActive(bool))); connect(m_networkAllowed, SIGNAL(ActiveChanged(bool)), m_networkAllowedInbound, SLOT(SetActive(bool))); connect(m_networkAllowed, SIGNAL(ValueChanged(bool)), m_networkAllowedOutbound, SLOT(SetActive(bool))); connect(m_networkAllowed, SIGNAL(ActiveChanged(bool)), m_networkAllowedOutbound, SLOT(SetActive(bool))); connect(m_manager, SIGNAL(configurationAdded(const QNetworkConfiguration&)), this, SLOT(ConfigurationAdded(const QNetworkConfiguration&))); connect(m_manager, SIGNAL(configurationChanged(const QNetworkConfiguration&)), this, SLOT(ConfigurationChanged(const QNetworkConfiguration&))); connect(m_manager, SIGNAL(configurationRemoved(const QNetworkConfiguration&)), this, SLOT(ConfigurationRemoved(const QNetworkConfiguration&))); connect(m_manager, SIGNAL(onlineStateChanged(bool)), this, SLOT(OnlineStateChanged(bool))); connect(m_manager, SIGNAL(updateCompleted()), this, SLOT(UpdateCompleted())); connect(this, SIGNAL(NewRequest(TorcNetworkRequest*)), this, SLOT(GetSafe(TorcNetworkRequest*))); connect(this, SIGNAL(CancelRequest(TorcNetworkRequest*)), this, SLOT(CancelSafe(TorcNetworkRequest*))); connect(this, SIGNAL(PokeRequest(TorcNetworkRequest*)), this, SLOT(PokeSafe(TorcNetworkRequest*))); connect(this, SIGNAL(NewAsyncRequest(TorcNetworkRequest*,QObject*)), this, SLOT(GetAsynchronousSafe(TorcNetworkRequest*,QObject*))); // direct connection for authentication requests connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), this, SLOT(Authenticate(QNetworkReply*,QAuthenticator*)), Qt::DirectConnection); // hide the network group if there is nothing to change m_networkGroup->SetActive(gLocalContext->FlagIsSet(Torc::Network)); // set initial state setConfiguration(m_manager->defaultConfiguration()); SetAllowed(m_networkAllowed->IsActive() && m_networkAllowed->GetValue().toBool()); UpdateConfiguration(true); }
void QNativeWifiEngine::scanComplete() { QMutexLocker locker(&mutex); if (!available()) { locker.unlock(); emit updateCompleted(); return; } // enumerate interfaces WLAN_INTERFACE_INFO_LIST *interfaceList; DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); #endif locker.unlock(); emit updateCompleted(); return; } QStringList previous = accessPointConfigurations.keys(); for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; WLAN_AVAILABLE_NETWORK_LIST *networkList; result = local_WlanGetAvailableNetworkList(handle, &interface.InterfaceGuid, 3, 0, &networkList); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanGetAvailableNetworkList failed with error %ld\n", __FUNCTION__, result); #endif continue; } QStringList seenNetworks; for (unsigned int j = 0; j < networkList->dwNumberOfItems; ++j) { WLAN_AVAILABLE_NETWORK &network = networkList->Network[j]; QString networkName; if (network.strProfileName[0] != 0) { networkName = QString::fromWCharArray(network.strProfileName); } else { networkName = QByteArray(reinterpret_cast<char *>(network.dot11Ssid.ucSSID), network.dot11Ssid.uSSIDLength); } const QString id = QString::number(qHash(QLatin1String("WLAN:") + networkName)); previous.removeAll(id); QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Undefined; if (!(network.dwFlags & WLAN_AVAILABLE_NETWORK_HAS_PROFILE)) state = QNetworkConfiguration::Undefined; if (network.strProfileName[0] != 0) { if (network.bNetworkConnectable) { if (network.dwFlags & WLAN_AVAILABLE_NETWORK_CONNECTED) state = QNetworkConfiguration::Active; else state = QNetworkConfiguration::Discovered; } else { state = QNetworkConfiguration::Defined; } } if (seenNetworks.contains(networkName)) continue; else seenNetworks.append(networkName); if (accessPointConfigurations.contains(id)) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); bool changed = false; ptr->mutex.lock(); if (!ptr->isValid) { ptr->isValid = true; changed = true; } if (ptr->name != networkName) { ptr->name = networkName; changed = true; } if (ptr->state != state) { ptr->state = state; changed = true; } ptr->mutex.unlock(); if (changed) { locker.unlock(); emit configurationChanged(ptr); locker.relock(); } } else { QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); ptr->name = networkName; ptr->isValid = true; ptr->id = id; ptr->state = state; ptr->type = QNetworkConfiguration::InternetAccessPoint; ptr->bearerType = QNetworkConfiguration::BearerWLAN; accessPointConfigurations.insert(id, ptr); locker.unlock(); emit configurationAdded(ptr); locker.relock(); } } local_WlanFreeMemory(networkList); } local_WlanFreeMemory(interfaceList); while (!previous.isEmpty()) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(previous.takeFirst()); locker.unlock(); emit configurationRemoved(ptr); locker.relock(); } locker.unlock(); emit updateCompleted(); }
void QAndroidBearerEngine::updateConfigurations() { #ifndef QT_NO_NETWORKINTERFACE if (m_connectivityManager == 0) return; { QMutexLocker locker(&mutex); QStringList oldKeys = accessPointConfigurations.keys(); QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces(); if (interfaces.isEmpty()) interfaces = QNetworkInterface::allInterfaces(); // Create a configuration for each of the main types (WiFi, Mobile, Bluetooth, WiMax, Ethernet) foreach (const AndroidNetworkInfo &netInfo, m_connectivityManager->getAllNetworkInfo()) { if (!netInfo.isValid()) continue; const QString name = networkConfType(netInfo); if (name.isEmpty()) continue; QNetworkConfiguration::BearerType bearerType = getBearerType(netInfo); QString interfaceName; QNetworkConfiguration::StateFlag state = QNetworkConfiguration::Defined; if (netInfo.isAvailable()) { if (netInfo.isConnected()) { // Attempt to map an interface to this configuration while (!interfaces.isEmpty()) { QNetworkInterface interface = interfaces.takeFirst(); // ignore loopback interface if (!interface.isValid()) continue; if (interface.flags() & QNetworkInterface::IsLoopBack) continue; // There is no way to get the interface from the NetworkInfo, so // look for an active interface... if (interface.flags() & QNetworkInterface::IsRunning && !interface.addressEntries().isEmpty()) { state = QNetworkConfiguration::Active; interfaceName = interface.name(); break; } } } } const QString key = QString(QLatin1String("android:%1:%2")).arg(name).arg(interfaceName); const QString id = QString::number(qHash(key)); m_configurationInterface[id] = interfaceName; oldKeys.removeAll(id); if (accessPointConfigurations.contains(id)) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id); bool changed = false; { const QMutexLocker confLocker(&ptr->mutex); if (!ptr->isValid) { ptr->isValid = true; changed = true; } // Don't reset the bearer type to 'Unknown' if (ptr->bearerType != QNetworkConfiguration::BearerUnknown && ptr->bearerType != bearerType) { ptr->bearerType = bearerType; changed = true; } if (ptr->name != name) { ptr->name = name; changed = true; } if (ptr->id != id) { ptr->id = id; changed = true; } if (ptr->state != state) { ptr->state = state; changed = true; } } // Unlock configuration if (changed) { locker.unlock(); Q_EMIT configurationChanged(ptr); locker.relock(); } } else { QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate); ptr->name = name; ptr->isValid = true; ptr->id = id; ptr->state = state; ptr->type = QNetworkConfiguration::InternetAccessPoint; ptr->bearerType = bearerType; accessPointConfigurations.insert(id, ptr); locker.unlock(); Q_EMIT configurationAdded(ptr); locker.relock(); } } while (!oldKeys.isEmpty()) { QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(oldKeys.takeFirst()); m_configurationInterface.remove(ptr->id); locker.unlock(); Q_EMIT configurationRemoved(ptr); locker.relock(); } } // Unlock engine #endif // QT_NO_NETWORKINTERFACE Q_EMIT updateCompleted(); }
void FormUpdate::startUpdate() { QString url_file; const bool update_for_this_system = isUpdateForThisSystem() && isSelfUpdateSupported(); if (update_for_this_system) { url_file = m_updateInfo.m_urls.value(OS_ID).m_fileUrl; } else { url_file = APP_URL; } if (m_readyToInstall) { close(); qDebug("Preparing to launch external installer '%s'.", qPrintable(QDir::toNativeSeparators(m_updateFilePath))); #if defined(Q_OS_WIN) HINSTANCE exec_result = ShellExecute(nullptr, nullptr, reinterpret_cast<const WCHAR*>(QDir::toNativeSeparators(m_updateFilePath).utf16()), nullptr, nullptr, SW_NORMAL); if (((int)exec_result) <= 32) { qDebug("External updater was not launched due to error."); qApp->showGuiMessage(tr("Cannot update application"), tr("Cannot launch external updater. Update application manually."), QSystemTrayIcon::Warning, this); } else { qApp->quit(); } #endif } else if (update_for_this_system) { // Nothing is downloaded yet, but update for this system // is available and self-update feature is present. if (m_downloader == nullptr) { // Initialie downloader. m_downloader = new Downloader(this); connect(m_downloader, SIGNAL(progress(qint64,qint64)), this, SLOT(updateProgress(qint64,qint64))); connect(m_downloader, SIGNAL(completed(QNetworkReply::NetworkError,QByteArray)), this, SLOT(updateCompleted(QNetworkReply::NetworkError,QByteArray))); updateProgress(0, 100); } m_btnUpdate->setText(tr("Downloading update...")); m_btnUpdate->setEnabled(false); m_downloader->downloadFile(url_file); } else { // Self-update and package are not available. if (!WebFactory::instance()->openUrlInExternalBrowser(url_file)) { qApp->showGuiMessage(tr("Cannot update application"), tr("Cannot navigate to installation file. Check new installation downloads manually on project website."), QSystemTrayIcon::Warning, this, true); } } }
void QConnmanEngine::doRequestUpdate() { connmanManager->requestScan(""); getConfigurations(); emit updateCompleted(); }