diff options
Diffstat (limited to 'examples/network/bearermonitor')
-rw-r--r-- | examples/network/bearermonitor/bearermonitor.cpp | 421 | ||||
-rw-r--r-- | examples/network/bearermonitor/bearermonitor.h | 95 | ||||
-rw-r--r-- | examples/network/bearermonitor/bearermonitor.pro | 22 | ||||
-rw-r--r-- | examples/network/bearermonitor/bearermonitor_240_320.ui | 420 | ||||
-rw-r--r-- | examples/network/bearermonitor/bearermonitor_640_480.ui | 386 | ||||
-rw-r--r-- | examples/network/bearermonitor/main.cpp | 69 | ||||
-rw-r--r-- | examples/network/bearermonitor/sessionwidget.cpp | 203 | ||||
-rw-r--r-- | examples/network/bearermonitor/sessionwidget.h | 88 | ||||
-rw-r--r-- | examples/network/bearermonitor/sessionwidget.ui | 307 |
9 files changed, 0 insertions, 2011 deletions
diff --git a/examples/network/bearermonitor/bearermonitor.cpp b/examples/network/bearermonitor/bearermonitor.cpp deleted file mode 100644 index 322224a902..0000000000 --- a/examples/network/bearermonitor/bearermonitor.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "bearermonitor.h" -#include "sessionwidget.h" - -#include <QtCore/QDebug> - -#ifdef Q_OS_WIN -#include <winsock2.h> -#undef interface - -#ifndef NS_NLA -#define NS_NLA 15 -#endif -#endif - -BearerMonitor::BearerMonitor(QWidget *parent) -: QWidget(parent) -{ - setupUi(this); - delete tabWidget->currentWidget(); - sessionGroup->hide(); - 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, &QNetworkConfigurationManager::onlineStateChanged, - this, &BearerMonitor::onlineStateChanged); - connect(&manager, &QNetworkConfigurationManager::configurationAdded, - this, [this](const QNetworkConfiguration &config) { configurationAdded(config); }); - connect(&manager, &QNetworkConfigurationManager::configurationRemoved, - this, &BearerMonitor::configurationRemoved); - connect(&manager, &QNetworkConfigurationManager::configurationChanged, - this, &BearerMonitor::configurationChanged); - connect(&manager, &QNetworkConfigurationManager::updateCompleted, - this, &BearerMonitor::updateConfigurations); - -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) - connect(registerButton, &QPushButton::clicked, - this, &BearerMonitor::registerNetwork); - connect(unregisterButton, &QPushButton::clicked, - this, &BearerMonitor::unregisterNetwork); -#else // Q_OS_WIN && !Q_OS_WINRT - nlaGroup->hide(); -#endif - - connect(treeWidget, &QTreeWidget::itemActivated, - this, &BearerMonitor::createSessionFor); - connect(treeWidget, &QTreeWidget::currentItemChanged, - this, &BearerMonitor::showConfigurationFor); - - connect(newSessionButton, &QPushButton::clicked, - this, &BearerMonitor::createNewSession); - connect(deleteSessionButton, &QPushButton::clicked, - this, &BearerMonitor::deleteSession); - connect(scanButton, &QPushButton::clicked, - this, &BearerMonitor::performScan); - - // Just in case update all configurations so that all - // configurations are up to date. - manager.updateConfigurations(); -} - -BearerMonitor::~BearerMonitor() -{ -} - -static void updateItem(QTreeWidgetItem *item, const QNetworkConfiguration &config) -{ - item->setText(0, config.name()); - item->setData(0, Qt::UserRole, config.identifier()); - - QFont font = item->font(1); - font.setBold(config.state().testFlag(QNetworkConfiguration::Active)); - item->setFont(0, font); -} - -void BearerMonitor::configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent) -{ - if (!config.isValid()) - return; - - QTreeWidgetItem *item = new QTreeWidgetItem; - updateItem(item, config); - - if (parent) - parent->addChild(item); - else - treeWidget->addTopLevelItem(item); - - if (config.type() == QNetworkConfiguration::ServiceNetwork) { - const QList<QNetworkConfiguration> children = config.children(); - for (const QNetworkConfiguration &child : children) - configurationAdded(child, item); - } -} - -void BearerMonitor::configurationRemoved(const QNetworkConfiguration &config) -{ - for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) { - QTreeWidgetItem *item = treeWidget->topLevelItem(i); - - if (item->data(0, Qt::UserRole).toString() == config.identifier()) { - delete item; - break; - } - } -} - -void BearerMonitor::configurationChanged(const QNetworkConfiguration &config) -{ - for (int i = 0; i < treeWidget->topLevelItemCount(); ++i) { - QTreeWidgetItem *item = treeWidget->topLevelItem(i); - - if (item->data(0, Qt::UserRole).toString() == config.identifier()) { - updateItem(item, config); - - if (config.type() == QNetworkConfiguration::ServiceNetwork) - updateSnapConfiguration(item, config); - - if (item == treeWidget->currentItem()) - showConfigurationFor(item); - - break; - } - } -} - -void BearerMonitor::updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap) -{ - QMap<QString, QTreeWidgetItem *> itemMap; - const QList<QTreeWidgetItem *> children = parent->takeChildren(); - for (QTreeWidgetItem *item : children) - itemMap.insert(item->data(0, Qt::UserRole).toString(), item); - - QList<QNetworkConfiguration> allConfigurations = snap.children(); - - while (!allConfigurations.isEmpty()) { - QNetworkConfiguration config = allConfigurations.takeFirst(); - - QTreeWidgetItem *item = itemMap.take(config.identifier()); - if (item) { - updateItem(item, config); - - parent->addChild(item); - - if (config.type() == QNetworkConfiguration::ServiceNetwork) - updateSnapConfiguration(item, config); - } else { - configurationAdded(config, parent); - } - } - - qDeleteAll(itemMap); -} - -void BearerMonitor::updateConfigurations() -{ - progressBar->hide(); - scanButton->show(); - - // Just in case update online state, on Symbian platform - // WLAN scan needs to be triggered initially to have their true state. - onlineStateChanged(manager.isOnline()); - - QList<QTreeWidgetItem *> items = treeWidget->findItems(QLatin1String("*"), Qt::MatchWildcard); - QMap<QString, QTreeWidgetItem *> itemMap; - while (!items.isEmpty()) { - QTreeWidgetItem *item = items.takeFirst(); - itemMap.insert(item->data(0, Qt::UserRole).toString(), item); - } - - QNetworkConfiguration defaultConfiguration = manager.defaultConfiguration(); - QTreeWidgetItem *defaultItem = itemMap.take(defaultConfiguration.identifier()); - - if (defaultItem) { - updateItem(defaultItem, defaultConfiguration); - - if (defaultConfiguration.type() == QNetworkConfiguration::ServiceNetwork) - updateSnapConfiguration(defaultItem, defaultConfiguration); - } else { - configurationAdded(defaultConfiguration); - } - - QList<QNetworkConfiguration> allConfigurations = manager.allConfigurations(); - - while (!allConfigurations.isEmpty()) { - QNetworkConfiguration config = allConfigurations.takeFirst(); - - if (config.identifier() == defaultConfiguration.identifier()) - continue; - - QTreeWidgetItem *item = itemMap.take(config.identifier()); - if (item) { - updateItem(item, config); - - if (config.type() == QNetworkConfiguration::ServiceNetwork) - updateSnapConfiguration(item, config); - } else { - configurationAdded(config); - } - } - - qDeleteAll(itemMap); -} - -void BearerMonitor::onlineStateChanged(bool isOnline) -{ - if (isOnline) - onlineState->setText(tr("Online")); - else - onlineState->setText(tr("Offline")); -} - -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) -void BearerMonitor::registerNetwork() -{ - QTreeWidgetItem *item = treeWidget->currentItem(); - if (!item) return; - - QNetworkConfiguration configuration = - manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString()); - - const QString name = configuration.name(); - - qDebug() << "Registering" << name << "with system"; - - WSAQUERYSET networkInfo; - memset(&networkInfo, 0, sizeof(networkInfo)); - networkInfo.dwSize = sizeof(networkInfo); - networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16(); - networkInfo.dwNameSpace = NS_NLA; - - if (WSASetService(&networkInfo, RNRSERVICE_REGISTER, 0) == SOCKET_ERROR) - qDebug() << "WSASetService(RNRSERVICE_REGISTER) returned" << WSAGetLastError(); -} - -void BearerMonitor::unregisterNetwork() -{ - QTreeWidgetItem *item = treeWidget->currentItem(); - if (!item) return; - - QNetworkConfiguration configuration = - manager.configurationFromIdentifier(item->data(0, Qt::UserRole).toString()); - - const QString name = configuration.name(); - - qDebug() << "Unregistering" << name << "with system"; - - WSAQUERYSET networkInfo; - memset(&networkInfo, 0, sizeof(networkInfo)); - networkInfo.dwSize = sizeof(networkInfo); - networkInfo.lpszServiceInstanceName = (LPWSTR)name.utf16(); - networkInfo.dwNameSpace = NS_NLA; - - if (WSASetService(&networkInfo, RNRSERVICE_DELETE, 0) == SOCKET_ERROR) - qDebug() << "WSASetService(RNRSERVICE_DELETE) returned" << WSAGetLastError(); -} -#endif // Q_OS_WIN && !Q_OS_WINRT - -void BearerMonitor::showConfigurationFor(QTreeWidgetItem *item) -{ - QString identifier; - - if (item) - identifier = item->data(0, Qt::UserRole).toString(); - - QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier); - - switch (conf.state()) { - case QNetworkConfiguration::Active: - configurationState->setText(tr("Active")); - break; - case QNetworkConfiguration::Discovered: - configurationState->setText(tr("Discovered")); - break; - case QNetworkConfiguration::Defined: - configurationState->setText(tr("Defined")); - break; - case QNetworkConfiguration::Undefined: - configurationState->setText(tr("Undefined")); - break; - } - - switch (conf.type()) { - case QNetworkConfiguration::InternetAccessPoint: - configurationType->setText(tr("Internet Access Point")); - break; - case QNetworkConfiguration::ServiceNetwork: - configurationType->setText(tr("Service Network")); - break; - case QNetworkConfiguration::UserChoice: - configurationType->setText(tr("User Choice")); - break; - case QNetworkConfiguration::Invalid: - configurationType->setText(tr("Invalid")); - break; - } - - switch (conf.purpose()) { - case QNetworkConfiguration::UnknownPurpose: - configurationPurpose->setText(tr("Unknown")); - break; - case QNetworkConfiguration::PublicPurpose: - configurationPurpose->setText(tr("Public")); - break; - case QNetworkConfiguration::PrivatePurpose: - configurationPurpose->setText(tr("Private")); - break; - case QNetworkConfiguration::ServiceSpecificPurpose: - configurationPurpose->setText(tr("Service Specific")); - break; - } - - configurationIdentifier->setText(conf.identifier()); - - configurationRoaming->setText(conf.isRoamingAvailable() ? tr("Available") : tr("Not available")); - - configurationChildren->setText(QString::number(conf.children().count())); - - configurationName->setText(conf.name()); -} - -void BearerMonitor::createSessionFor(QTreeWidgetItem *item) -{ - const QString identifier = item->data(0, Qt::UserRole).toString(); - - QNetworkConfiguration conf = manager.configurationFromIdentifier(identifier); - - SessionWidget *session = new SessionWidget(conf); - - tabWidget->addTab(session, conf.name()); - - sessionGroup->show(); - - sessionWidgets.append(session); -} - -void BearerMonitor::createNewSession() -{ - QTreeWidgetItem *item = treeWidget->currentItem(); - if (!item) return; - - createSessionFor(item); -} - -void BearerMonitor::deleteSession() -{ - SessionWidget *session = qobject_cast<SessionWidget *>(tabWidget->currentWidget()); - if (session) { - sessionWidgets.removeAll(session); - - delete session; - - if (tabWidget->count() == 0) - sessionGroup->hide(); - } -} - -void BearerMonitor::performScan() -{ - scanButton->hide(); - progressBar->show(); - manager.updateConfigurations(); -} diff --git a/examples/network/bearermonitor/bearermonitor.h b/examples/network/bearermonitor/bearermonitor.h deleted file mode 100644 index 79b8d876ec..0000000000 --- a/examples/network/bearermonitor/bearermonitor.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef BEARERMONITOR_H -#define BEARERMONITOR_H - -#include <QNetworkConfigurationManager> -#include "ui_bearermonitor_640_480.h" - -QT_USE_NAMESPACE - -class SessionWidget; - -class BearerMonitor : public QWidget, public Ui_BearerMonitor -{ - Q_OBJECT - -public: - BearerMonitor(QWidget *parent = nullptr); - ~BearerMonitor(); - -private slots: - void configurationAdded(const QNetworkConfiguration &config, QTreeWidgetItem *parent = nullptr); - void configurationRemoved(const QNetworkConfiguration &config); - void configurationChanged(const QNetworkConfiguration &config); - void updateSnapConfiguration(QTreeWidgetItem *parent, const QNetworkConfiguration &snap); - void updateConfigurations(); - - void onlineStateChanged(bool isOnline); - -#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) - void registerNetwork(); - void unregisterNetwork(); -#endif // Q_OS_WIN && !Q_OS_WINRT - - void showConfigurationFor(QTreeWidgetItem *item); - - void createSessionFor(QTreeWidgetItem *item); - void createNewSession(); - void deleteSession(); - void performScan(); - -private: - QNetworkConfigurationManager manager; - QVector<SessionWidget *> sessionWidgets; -}; - -#endif //BEARERMONITOR_H diff --git a/examples/network/bearermonitor/bearermonitor.pro b/examples/network/bearermonitor/bearermonitor.pro deleted file mode 100644 index 16ac41298a..0000000000 --- a/examples/network/bearermonitor/bearermonitor.pro +++ /dev/null @@ -1,22 +0,0 @@ -TARGET = bearermonitor -QT = core gui network widgets -requires(qtConfig(treeview)) - -HEADERS = sessionwidget.h \ - bearermonitor.h - -SOURCES = main.cpp \ - bearermonitor.cpp \ - sessionwidget.cpp - -FORMS = bearermonitor_240_320.ui \ - bearermonitor_640_480.ui \ - sessionwidget.ui - -win32: QMAKE_USE += ws2_32 - -CONFIG += console - -# install -target.path = $$[QT_INSTALL_EXAMPLES]/network/bearermonitor -INSTALLS += target diff --git a/examples/network/bearermonitor/bearermonitor_240_320.ui b/examples/network/bearermonitor/bearermonitor_240_320.ui deleted file mode 100644 index 93cfc5e0e3..0000000000 --- a/examples/network/bearermonitor/bearermonitor_240_320.ui +++ /dev/null @@ -1,420 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>BearerMonitor</class> - <widget class="QWidget" name="BearerMonitor"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>240</width> - <height>320</height> - </rect> - </property> - <property name="windowTitle"> - <string>BearerMonitor</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <item> - <widget class="QScrollArea" name="scrollArea"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>-274</y> - <width>206</width> - <height>576</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QGroupBox" name="systemState"> - <property name="title"> - <string>System State</string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <layout class="QHBoxLayout" name="onlineStateLayout"> - <item> - <widget class="QLabel" name="onlineStateLabel"> - <property name="text"> - <string>Online State:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="onlineState"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Configurations</string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_9"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="configurationNameLayout"> - <item> - <widget class="QLabel" name="configurationNameLabel"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationName"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationStateLayout"> - <item> - <widget class="QLabel" name="configurationStateLabel"> - <property name="text"> - <string>State:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationState"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationTypeLayout"> - <item> - <widget class="QLabel" name="configurationTypeLabel"> - <property name="text"> - <string>Type:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationType"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Invalid</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationPurposeLayout"> - <item> - <widget class="QLabel" name="configurationPurposeLabel"> - <property name="text"> - <string>Purpose:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationPurpose"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Unknown</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationIdentifierLayout"> - <item> - <widget class="QLabel" name="configurationIdentifierLabel"> - <property name="text"> - <string>Identifier:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationIdentifier"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationRoamingLayout"> - <item> - <widget class="QLabel" name="configurationRoamingLabel"> - <property name="text"> - <string>Roaming:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationRoaming"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationChildrenLayout"> - <item> - <widget class="QLabel" name="configurationChildrenLabel"> - <property name="text"> - <string>Children:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationChildren"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QGroupBox" name="nlaGroup"> - <property name="title"> - <string>Network Location Awareness</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="registerButton"> - <property name="text"> - <string>Register</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="unregisterButton"> - <property name="text"> - <string>Unregister</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QPushButton" name="newSessionButton"> - <property name="text"> - <string>New Session</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="deleteSessionButton"> - <property name="text"> - <string>Delete Session</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="scanButton"> - <property name="text"> - <string>Scan</string> - </property> - </widget> - </item> - <item> - <widget class="QProgressBar" name="progressBar"> - <property name="maximum"> - <number>0</number> - </property> - <property name="value"> - <number>-1</number> - </property> - <property name="textVisible"> - <bool>false</bool> - </property> - <property name="invertedAppearance"> - <bool>false</bool> - </property> - <property name="format"> - <string>%p%</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QTreeWidget" name="treeWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="verticalScrollBarPolicy"> - <enum>Qt::ScrollBarAlwaysOff</enum> - </property> - <attribute name="headerVisible"> - <bool>false</bool> - </attribute> - <column> - <property name="text"> - <string>1</string> - </property> - </column> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="sessionGroup"> - <property name="title"> - <string>Sessions</string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string>Session 1</string> - </attribute> - </widget> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/examples/network/bearermonitor/bearermonitor_640_480.ui b/examples/network/bearermonitor/bearermonitor_640_480.ui deleted file mode 100644 index 52866bc9cd..0000000000 --- a/examples/network/bearermonitor/bearermonitor_640_480.ui +++ /dev/null @@ -1,386 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>BearerMonitor</class> - <widget class="QWidget" name="BearerMonitor"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>640</width> - <height>515</height> - </rect> - </property> - <property name="windowTitle"> - <string>BearerMonitor</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QGroupBox" name="systemState"> - <property name="title"> - <string>System State</string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <layout class="QHBoxLayout" name="onlineStateLayout"> - <item> - <widget class="QLabel" name="onlineStateLabel"> - <property name="text"> - <string>Online State:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="onlineState"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item row="1" column="0"> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>Configurations</string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_9"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QTreeWidget" name="treeWidget"> - <attribute name="headerVisible"> - <bool>false</bool> - </attribute> - <column> - <property name="text"> - <string>1</string> - </property> - </column> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="configurationNameLayout"> - <item> - <widget class="QLabel" name="configurationNameLabel"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationName"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationStateLayout"> - <item> - <widget class="QLabel" name="configurationStateLabel"> - <property name="text"> - <string>State:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationState"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationTypeLayout"> - <item> - <widget class="QLabel" name="configurationTypeLabel"> - <property name="text"> - <string>Type:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationType"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Invalid</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationPurposeLayout"> - <item> - <widget class="QLabel" name="configurationPurposeLabel"> - <property name="text"> - <string>Purpose:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationPurpose"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Unknown</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationIdentifierLayout"> - <item> - <widget class="QLabel" name="configurationIdentifierLabel"> - <property name="text"> - <string>Identifier:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationIdentifier"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationRoamingLayout"> - <item> - <widget class="QLabel" name="configurationRoamingLabel"> - <property name="text"> - <string>Roaming:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationRoaming"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationChildrenLayout"> - <item> - <widget class="QLabel" name="configurationChildrenLabel"> - <property name="text"> - <string>Children:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configurationChildren"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QGroupBox" name="nlaGroup"> - <property name="title"> - <string>Network Location Awareness</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="registerButton"> - <property name="text"> - <string>Register</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="unregisterButton"> - <property name="text"> - <string>Unregister</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QPushButton" name="newSessionButton"> - <property name="text"> - <string>New Session</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="deleteSessionButton"> - <property name="text"> - <string>Delete Session</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="scanButton"> - <property name="text"> - <string>Scan</string> - </property> - </widget> - </item> - <item> - <widget class="QProgressBar" name="progressBar"> - <property name="maximum"> - <number>0</number> - </property> - <property name="value"> - <number>-1</number> - </property> - <property name="textVisible"> - <bool>false</bool> - </property> - <property name="invertedAppearance"> - <bool>false</bool> - </property> - <property name="format"> - <string>%p%</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item row="2" column="0"> - <widget class="QGroupBox" name="sessionGroup"> - <property name="title"> - <string>Sessions</string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string>Session 1</string> - </attribute> - </widget> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/examples/network/bearermonitor/main.cpp b/examples/network/bearermonitor/main.cpp deleted file mode 100644 index 3c2525012d..0000000000 --- a/examples/network/bearermonitor/main.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QApplication> -#include <QMainWindow> - -#include "bearermonitor.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QMainWindow mainWindow; - - BearerMonitor monitor; - - mainWindow.setCentralWidget(&monitor); - mainWindow.show(); - - return app.exec(); -} - diff --git a/examples/network/bearermonitor/sessionwidget.cpp b/examples/network/bearermonitor/sessionwidget.cpp deleted file mode 100644 index 0fd5d4f67f..0000000000 --- a/examples/network/bearermonitor/sessionwidget.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sessionwidget.h" -#include <QNetworkConfigurationManager> - -SessionWidget::SessionWidget(const QNetworkConfiguration &config, QWidget *parent) -: QWidget(parent) -{ - setupUi(this); - -#ifdef QT_NO_NETWORKINTERFACE - interfaceName->setVisible(false); - interfaceNameLabel->setVisible(false); - interfaceGuid->setVisible(false); - interfaceGuidLabel->setVisible(false); -#endif - - session = new QNetworkSession(config, this); - - connect(session, &QNetworkSession::stateChanged, - this, &SessionWidget::updateSession); - connect(session, QOverload<QNetworkSession::SessionError>::of(&QNetworkSession::error), - this, &SessionWidget::updateSessionError); - - updateSession(); - - sessionId->setText(QString("0x%1").arg(qulonglong(session), 8, 16, QChar('0'))); - - configuration->setText(session->configuration().name()); - - connect(openSessionButton, &QPushButton::clicked, - this, &SessionWidget::openSession); - connect(openSyncSessionButton, &QPushButton::clicked, - this, &SessionWidget::openSyncSession); - connect(closeSessionButton, &QPushButton::clicked, - this, &SessionWidget::closeSession); - connect(stopSessionButton, &QPushButton::clicked, - this, &SessionWidget::stopSession); -} - -SessionWidget::~SessionWidget() -{ - delete session; -} - -void SessionWidget::timerEvent(QTimerEvent *e) -{ - if (e->timerId() == statsTimer) { - rxData->setText(QString::number(session->bytesReceived())); - txData->setText(QString::number(session->bytesWritten())); - activeTime->setText(QString::number(session->activeTime())); - } -} - -void SessionWidget::updateSession() -{ - updateSessionState(session->state()); - - if (session->state() == QNetworkSession::Connected) - statsTimer = startTimer(1000); - else if (statsTimer != -1) - killTimer(statsTimer); - - if (session->configuration().type() == QNetworkConfiguration::InternetAccessPoint) - bearer->setText(session->configuration().bearerTypeName()); - else { - QNetworkConfigurationManager mgr; - QNetworkConfiguration c = mgr.configurationFromIdentifier(session->sessionProperty("ActiveConfiguration").toString()); - bearer->setText(c.bearerTypeName()); - } - -#ifndef QT_NO_NETWORKINTERFACE - interfaceName->setText(session->interface().humanReadableName()); - interfaceGuid->setText(session->interface().name()); -#endif -} - -void SessionWidget::openSession() -{ - clearError(); - session->open(); - updateSession(); -} - -void SessionWidget::openSyncSession() -{ - clearError(); - session->open(); - session->waitForOpened(); - updateSession(); -} - -void SessionWidget::closeSession() -{ - clearError(); - session->close(); - updateSession(); -} - -void SessionWidget::stopSession() -{ - clearError(); - session->stop(); - updateSession(); -} - -void SessionWidget::updateSessionState(QNetworkSession::State state) -{ - QString s = tr("%1 (%2)"); - - switch (state) { - case QNetworkSession::Invalid: - s = s.arg(tr("Invalid")); - break; - case QNetworkSession::NotAvailable: - s = s.arg(tr("Not Available")); - break; - case QNetworkSession::Connecting: - s = s.arg(tr("Connecting")); - break; - case QNetworkSession::Connected: - s = s.arg(tr("Connected")); - break; - case QNetworkSession::Closing: - s = s.arg(tr("Closing")); - break; - case QNetworkSession::Disconnected: - s = s.arg(tr("Disconnected")); - break; - case QNetworkSession::Roaming: - s = s.arg(tr("Roaming")); - break; - default: - s = s.arg(tr("Unknown")); - } - - if (session->isOpen()) - s = s.arg(tr("Open")); - else - s = s.arg(tr("Closed")); - - sessionState->setText(s); -} - -void SessionWidget::updateSessionError(QNetworkSession::SessionError error) -{ - lastError->setText(QString::number(error)); - errorString->setText(session->errorString()); -} - -void SessionWidget::clearError() -{ - lastError->clear(); - errorString->clear(); -} diff --git a/examples/network/bearermonitor/sessionwidget.h b/examples/network/bearermonitor/sessionwidget.h deleted file mode 100644 index 6b2da2c1c1..0000000000 --- a/examples/network/bearermonitor/sessionwidget.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SESSIONWIDGET_H -#define SESSIONWIDGET_H - -#include <QNetworkSession> - -#include "ui_sessionwidget.h" - -QT_USE_NAMESPACE - -class SessionWidget : public QWidget, public Ui_SessionWidget -{ - Q_OBJECT - -public: - explicit SessionWidget(const QNetworkConfiguration &config, QWidget *parent = nullptr); - ~SessionWidget(); - - void timerEvent(QTimerEvent *e) override; - -private: - void updateSessionState(QNetworkSession::State state); - void clearError(); - -private Q_SLOTS: - void openSession(); - void openSyncSession(); - void closeSession(); - void stopSession(); - void updateSession(); - void updateSessionError(QNetworkSession::SessionError error); - -private: - QNetworkSession *session = nullptr; - int statsTimer = -1; -}; - -#endif - diff --git a/examples/network/bearermonitor/sessionwidget.ui b/examples/network/bearermonitor/sessionwidget.ui deleted file mode 100644 index 4199109ce3..0000000000 --- a/examples/network/bearermonitor/sessionwidget.ui +++ /dev/null @@ -1,307 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>SessionWidget</class> - <widget class="QWidget" name="SessionWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>340</width> - <height>276</height> - </rect> - </property> - <property name="windowTitle"> - <string>Session Details</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QHBoxLayout" name="sessionIdLayout"> - <item> - <widget class="QLabel" name="sessionIdLabel"> - <property name="text"> - <string>Session ID:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="sessionId"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="sessionStateLayout"> - <item> - <widget class="QLabel" name="sessionStateLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Session State:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="sessionState"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Invalid</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="configurationLayout"> - <item> - <widget class="QLabel" name="configurationLabel"> - <property name="text"> - <string>Configuration:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="configuration"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="bearerLayout"> - <item> - <widget class="QLabel" name="bearerLabel"> - <property name="text"> - <string>Bearer:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="bearer"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="interfaceNameLayout"> - <item> - <widget class="QLabel" name="interfaceNameLabel"> - <property name="text"> - <string>Interface Name:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="interfaceName"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="interfaceGuidLayout"> - <item> - <widget class="QLabel" name="interfaceGuidLabel"> - <property name="text"> - <string>Interface GUID:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="interfaceGuid"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="lastErrorLayout"> - <item> - <widget class="QLabel" name="lastErrorLabel"> - <property name="text"> - <string>Last Error:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="lastError"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="errorStringLayout"> - <item> - <widget class="QLabel" name="errorStringLabel"> - <property name="text"> - <string>Error String:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="errorString"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="rxData"> - <property name="text"> - <string>0</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="txData"> - <property name="text"> - <string>0</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Active Time:</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="activeTime"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>0 seconds</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QPushButton" name="openSessionButton"> - <property name="text"> - <string>Open</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="openSyncSessionButton"> - <property name="text"> - <string>Blocking Open</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QPushButton" name="closeSessionButton"> - <property name="text"> - <string>Close</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="stopSessionButton"> - <property name="text"> - <string>Stop</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> |