int main(int argc, char *argv[]) { 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; InitialWindow window; #ifdef Q_OS_SYMBIAN // Make application better looking and more usable on small screen // dialog.showMaximized(); #else // dialog.show(); window.show(); #endif return app.exec(); }
void QNetworkReplyImplPrivate::_q_startOperation() { // ensure this function is only being called once if (state == Working) { qDebug("QNetworkReplyImpl::_q_startOperation was called more than once"); return; } state = Working; // note: if that method is called directly, it cannot happen that the backend is 0, // because we just checked via a qobject_cast that we got a http backend (see // QNetworkReplyImplPrivate::setup()) if (!backend) { error(QNetworkReplyImpl::ProtocolUnknownError, QCoreApplication::translate("QNetworkReply", "Protocol \"%1\" is unknown").arg(url.scheme())); // not really true!; finished(); return; } #ifndef QT_NO_BEARERMANAGEMENT if (!backend->start()) { // backend failed to start because the session state is not Connected. // QNetworkAccessManager will call reply->backend->start() again for us when the session // state changes. state = WaitingForSession; QNetworkSession *session = manager->d_func()->networkSession; if (session) { Q_Q(QNetworkReplyImpl); QObject::connect(session, SIGNAL(error(QNetworkSession::SessionError)), q, SLOT(_q_networkSessionFailed())); if (!session->isOpen()) session->open(); } else { qWarning("Backend is waiting for QNetworkSession to connect, but there is none!"); } return; } #endif if (state != Finished) { if (operation == QNetworkAccessManager::GetOperation) pendingNotifications.append(NotifyDownstreamReadyWrite); handleNotifications(); } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); 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(); } QNetworkSession *networkSession = new QNetworkSession(config, &a); 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("QtProject")); settings.beginGroup(QLatin1String("QtNetwork")); settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); settings.endGroup(); } } interface w; w.show(); return a.exec(); }
int main(int argc, char *argv[]) { QApplication a(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, &a); 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(); } } RedDeerNote w; QSplashScreen *splash=new QSplashScreen; splash->setPixmap(QPixmap(":/icons/logord2.png")); splash->show(); splash->showMessage( "Initializing..." ); SleeperThread::msleep(300); splash->showMessage( "Load GUI..." ); SleeperThread::msleep(300); splash->showMessage( "Load Library..." ); SleeperThread::msleep(300); splash->showMessage( "Starting..." ); SleeperThread::msleep(300); w.show(); splash->finish(&w); delete splash; return a.exec(); }