summaryrefslogtreecommitdiffstats
path: root/examples/network/fortuneserver
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2020-02-14 16:35:01 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2020-02-19 13:28:00 +0100
commit3742c67041b47adefa0d293e45d543f31ab15da7 (patch)
tree6886354e708c0e7969776eda52908afde982103d /examples/network/fortuneserver
parent22c585f0f9d694bd5c1d8f8afb23b4a66681acd9 (diff)
Remove bearer management from remaining network examples
Because bearer management is going away Change-Id: I60439c1714e0350b0f2bbef6afc8d2015886135f Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'examples/network/fortuneserver')
-rw-r--r--examples/network/fortuneserver/server.cpp41
-rw-r--r--examples/network/fortuneserver/server.h5
2 files changed, 4 insertions, 42 deletions
diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp
index 7db81fe07a..c91b6a5c0c 100644
--- a/examples/network/fortuneserver/server.cpp
+++ b/examples/network/fortuneserver/server.cpp
@@ -61,29 +61,7 @@ Server::Server(QWidget *parent)
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
statusLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
- QNetworkConfigurationManager manager;
- if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
- // Get saved network configuration
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
- settings.endGroup();
-
- // If the saved network configuration is not currently discovered use the system default
- QNetworkConfiguration config = manager.configurationFromIdentifier(id);
- if ((config.state() & QNetworkConfiguration::Discovered) !=
- QNetworkConfiguration::Discovered) {
- config = manager.defaultConfiguration();
- }
-
- networkSession = new QNetworkSession(config, this);
- connect(networkSession, &QNetworkSession::opened, this, &Server::sessionOpened);
-
- statusLabel->setText(tr("Opening network session."));
- networkSession->open();
- } else {
- sessionOpened();
- }
+ initServer();
//! [2]
fortunes << tr("You've been leading a dog's life. Stay off the furniture.")
@@ -128,23 +106,8 @@ Server::Server(QWidget *parent)
setWindowTitle(QGuiApplication::applicationDisplayName());
}
-void Server::sessionOpened()
+void Server::initServer()
{
- // Save the used configuration
- if (networkSession) {
- QNetworkConfiguration config = networkSession->configuration();
- QString id;
- if (config.type() == QNetworkConfiguration::UserChoice)
- id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString();
- else
- id = config.identifier();
-
- QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
- settings.beginGroup(QLatin1String("QtNetwork"));
- settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
- settings.endGroup();
- }
-
//! [0] //! [1]
tcpServer = new QTcpServer(this);
if (!tcpServer->listen()) {
diff --git a/examples/network/fortuneserver/server.h b/examples/network/fortuneserver/server.h
index c5bfa7d928..96d7145148 100644
--- a/examples/network/fortuneserver/server.h
+++ b/examples/network/fortuneserver/server.h
@@ -58,7 +58,6 @@
QT_BEGIN_NAMESPACE
class QLabel;
class QTcpServer;
-class QNetworkSession;
QT_END_NAMESPACE
//! [0]
@@ -70,14 +69,14 @@ public:
explicit Server(QWidget *parent = nullptr);
private slots:
- void sessionOpened();
void sendFortune();
private:
+ void initServer();
+
QLabel *statusLabel = nullptr;
QTcpServer *tcpServer = nullptr;
QVector<QString> fortunes;
- QNetworkSession *networkSession = nullptr;
};
//! [0]