diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-07-07 06:28:45 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-07-19 00:32:33 (GMT) |
commit | 75db37022a9fd479e2a446b57e774eaf8e3e73ea (patch) | |
tree | c00dffdb4fe9f38aba2385ff686c2d16b2cae2e3 /examples/network/network-chat | |
parent | 192a3c6d69b42f02aa9033c30502a6930cceb8f7 (diff) | |
download | Qt-75db37022a9fd479e2a446b57e774eaf8e3e73ea.zip Qt-75db37022a9fd479e2a446b57e774eaf8e3e73ea.tar.gz Qt-75db37022a9fd479e2a446b57e774eaf8e3e73ea.tar.bz2 |
Convert examples and demos to use Bearer Management.
Task-number: QTBUG-10439
Diffstat (limited to 'examples/network/network-chat')
-rw-r--r-- | examples/network/network-chat/main.cpp | 48 | ||||
-rw-r--r-- | examples/network/network-chat/network-chat.pro | 2 |
2 files changed, 42 insertions, 8 deletions
diff --git a/examples/network/network-chat/main.cpp b/examples/network/network-chat/main.cpp index 7226217..e3db74b 100644 --- a/examples/network/network-chat/main.cpp +++ b/examples/network/network-chat/main.cpp @@ -41,16 +41,52 @@ #include <QApplication> #include "chatdialog.h" -#ifdef Q_OS_SYMBIAN -#include "sym_iap_util.h" -#endif + +#include <QtCore/QSettings> +#include <QtNetwork/QNetworkConfigurationManager> +#include <QtNetwork/QNetworkSession> int main(int argc, char *argv[]) { -#ifdef Q_OS_SYMBIAN - qt_SetDefaultIap(); -#endif QApplication app(argc, argv); + + QNetworkConfigurationManager manager; + if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { + // Get saved network configuration + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + 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(); + } + + QNetworkSession *networkSession = new QNetworkSession(config, &app); + networkSession->open(); + networkSession->waitForOpened(); + + if (networkSession->isOpen()) { + // Save the used configuration + 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("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); + } + } + ChatDialog dialog; #ifdef Q_OS_SYMBIAN // Make application better looking and more usable on small screen diff --git a/examples/network/network-chat/network-chat.pro b/examples/network/network-chat/network-chat.pro index 1215aea..b3d429e 100644 --- a/examples/network/network-chat/network-chat.pro +++ b/examples/network/network-chat/network-chat.pro @@ -20,8 +20,6 @@ INSTALLS += target sources symbian { include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) - INCLUDEPATH += $$QT_SOURCE_TREE/examples/network/qftp/ - LIBS += -lesock -lcommdb -linsock # For IAP selection LIBS += -lcharconv TARGET.CAPABILITY = "NetworkServices ReadUserData WriteUserData" TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 |