void QtMarbleConfigDialog::syncSettings() { d->m_settings.sync(); QNetworkProxy proxy; // Make sure that no proxy is used for an empty string or the default value: if ( proxyUrl().isEmpty() || proxyUrl() == "http://" ) { proxy.setType( QNetworkProxy::NoProxy ); } else { if ( proxyType() == Marble::Socks5Proxy ) { proxy.setType( QNetworkProxy::Socks5Proxy ); } else if ( proxyType() == Marble::HttpProxy ) { proxy.setType( QNetworkProxy::HttpProxy ); } else { mDebug() << "Unknown proxy type! Using Http Proxy instead."; proxy.setType( QNetworkProxy::HttpProxy ); } } proxy.setHostName( proxyUrl() ); proxy.setPort( proxyPort() ); if ( proxyAuth() ) { proxy.setUser( proxyUser() ); proxy.setPassword( proxyPass() ); } QNetworkProxy::setApplicationProxy(proxy); }
/*! \brief Determines if something has changed. We do that by comparing every value against what is stored in the storage. \return \arg \c true Yes, something has changed. \arg \c false No, nothing changed. */ bool Settings::changed() const { if( apiKey() != Storage::loadString( QL( "apiKey" ) ) ) return true; if( useSystemProxy() != Storage::loadBool( QL( "useSystemProxy" ) ) ) return true; if( useSystemProxy() ) return false; if( proxyHost() != Storage::loadString( QL( "proxyHost" ) ) ) return true; if( proxyPort() != Storage::loadUShort( QL( "proxyPort" ) ) ) return true; if( proxyLogin() != Storage::loadString( QL( "proxyLogin" ) ) ) return true; if( proxyPassword() != Storage::loadString( QL( "proxyPassword" ) ) ) return true; return false; }
HTTPClientSession* HTTPSSessionInstantiator::createClientSession(const Poco::URI& uri) { poco_assert (uri.getScheme() == "https"); HTTPSClientSession* pSession = new HTTPSClientSession(uri.getHost(), uri.getPort()); pSession->setProxy(proxyHost(), proxyPort()); return pSession; }
Settings::Settings() : m_settingsMain( new QSettings(QSettings::IniFormat, QSettings::UserScope, "KDE", "Installer") ) { m_settings = new QSettings(installDir()+"/etc/installer.ini",QSettings::IniFormat); QString version = m_settings->value("version", "").toString(); // update to current version if (version.isEmpty()) // version 1 { m_settings->setValue("version", SETTINGS_VERSION); setPackageManagerMode(m_settings->value("DeveloperMode",false).toBool()); m_settings->remove("DeveloperMode"); m_settings->sync(); } else if (version != SETTINGS_VERSION) { qCritical() << "unknown settings version" << version << "found"; } #ifdef DEBUG qDebug() << "installDir:" << installDir(); qDebug() << "downloadDir:" << downloadDir(); qDebug() << "showTitlePage:" << showTitlePage(); qDebug() << "createStartMenuEntries:" << createStartMenuEntries(); qDebug() << "isFirstRun" << isFirstRun(); qDebug() << "proxyMode" << proxyMode(); qDebug() << "proxyHost" << proxyHost(); qDebug() << "proxyPort" << proxyPort(); #endif #ifndef Q_OS_WIN // setProxyMode(Environment); #endif }
HTTPClientSession* HTTPSSessionInstantiator::createClientSession(const Poco::URI& uri) { poco_assert (uri.getScheme() == "https"); HTTPSClientSession* pSession = _pContext.isNull() ? new HTTPSClientSession(uri.getHost(), uri.getPort()) : new HTTPSClientSession(uri.getHost(), uri.getPort(), _pContext); pSession->setProxy(proxyHost(), proxyPort()); pSession->setProxyCredentials(proxyUsername(), proxyPassword()); return pSession; }
QVariantMap CoreAccount::toVariantMap(bool forcePassword) const { QVariantMap v; v["AccountId"] = accountId().toInt(); // can't use AccountId because then comparison fails v["AccountName"] = accountName(); v["Uuid"] = uuid().toString(); v["Internal"] = isInternal(); v["User"] = user(); if (_storePassword || forcePassword) v["Password"] = password(); else v["Password"] = QString(); v["StorePassword"] = storePassword(); v["HostName"] = hostName(); v["Port"] = port(); v["UseSSL"] = useSsl(); v["ProxyType"] = proxyType(); v["ProxyUser"] = proxyUser(); v["ProxyPassword"] = proxyPassword(); v["ProxyHostName"] = proxyHostName(); v["ProxyPort"] = proxyPort(); return v; }
void QtMarbleConfigDialog::readSettings() { d->m_initialGraphicsSystem = graphicsSystem(); d->m_previousGraphicsSystem = d->m_initialGraphicsSystem; // Sync settings to make sure that we read the current settings. syncSettings(); // View d->ui_viewSettings.kcfg_distanceUnit->setCurrentIndex( measurementSystem() ); d->ui_viewSettings.kcfg_angleUnit->setCurrentIndex( angleUnit() ); d->ui_viewSettings.kcfg_stillQuality->setCurrentIndex( stillQuality() ); d->ui_viewSettings.kcfg_animationQuality->setCurrentIndex( animationQuality() ); d->ui_viewSettings.kcfg_labelLocalization->setCurrentIndex( Marble::Native ); d->ui_viewSettings.kcfg_mapFont->setCurrentFont( mapFont() ); d->ui_viewSettings.kcfg_graphicsSystem->setCurrentIndex( graphicsSystem() ); // Navigation d->ui_navigationSettings.kcfg_dragLocation->setCurrentIndex( Marble::KeepAxisVertically ); d->ui_navigationSettings.kcfg_onStartup->setCurrentIndex( onStartup() ); d->ui_navigationSettings.kcfg_inertialEarthRotation->setChecked( inertialEarthRotation() ); d->ui_navigationSettings.kcfg_animateTargetVoyage->setChecked( animateTargetVoyage() ); int editorIndex = 0; if ( externalMapEditor() == "potlatch") { editorIndex = 1; } else if ( externalMapEditor() == "josm") { editorIndex = 2; } else if ( externalMapEditor() == "merkaartor") { editorIndex = 3; } d->ui_navigationSettings.kcfg_externalMapEditor->setCurrentIndex( editorIndex ); // Cache d->ui_cacheSettings.kcfg_volatileTileCacheLimit->setValue( volatileTileCacheLimit() ); d->ui_cacheSettings.kcfg_persistentTileCacheLimit->setValue( persistentTileCacheLimit() ); d->ui_cacheSettings.kcfg_proxyUrl->setText( proxyUrl() ); d->ui_cacheSettings.kcfg_proxyPort->setValue( proxyPort() ); d->ui_cacheSettings.kcfg_proxyUser->setText( proxyUser() ); d->ui_cacheSettings.kcfg_proxyPass->setText( proxyPass() ); d->ui_cacheSettings.kcfg_proxyType->setCurrentIndex( proxyType() ); d->ui_cacheSettings.kcfg_proxyAuth->setChecked( proxyAuth() ); // Time d->ui_timeSettings.kcfg_systemTimezone->setChecked( systemTimezone() ); d->ui_timeSettings.kcfg_customTimezone->setChecked( customTimezone() ); d->ui_timeSettings.kcfg_chosenTimezone->setCurrentIndex( chosenTimezone() ); d->ui_timeSettings.kcfg_utc->setChecked( UTC() ); d->ui_timeSettings.kcfg_systemTime->setChecked( systemTime() ); d->ui_timeSettings.kcfg_lastSessionTime->setChecked( lastSessionTime() ); if( systemTimezone() == true ) { QDateTime localTime = QDateTime::currentDateTime().toLocalTime(); localTime.setTimeSpec( Qt::UTC ); d->m_marbleWidget->model()->setClockTimezone( QDateTime::currentDateTime().toUTC().secsTo( localTime ) ); } else if( UTC() == true ) { d->m_marbleWidget->model()->setClockTimezone( 0 ); } else if( customTimezone() == true ) { d->m_marbleWidget->model()->setClockTimezone( d->m_timezone.value( chosenTimezone() ) ); } // Routing // ownCloud d->ui_cloudSyncSettings.kcfg_enableSync->setChecked( syncEnabled() ); d->ui_cloudSyncSettings.kcfg_syncBookmarks->setChecked( syncBookmarks() ); d->ui_cloudSyncSettings.kcfg_syncRoutes->setChecked( syncRoutes() ); d->ui_cloudSyncSettings.kcfg_owncloudServer->setText( owncloudServer() ); d->ui_cloudSyncSettings.kcfg_owncloudUsername->setText( owncloudUsername() ); d->ui_cloudSyncSettings.kcfg_owncloudPassword->setText( owncloudPassword() ); // Read the settings of the plugins d->m_marbleWidget->readPluginSettings( d->m_settings ); // The settings loaded in the config dialog have been changed. emit settingsChanged(); }
std::string ZLCurlNetworkManager::perform(const ZLExecutionData::Vector &dataList) const { const ZLResource &errorResource = ZLResource::resource("dialog")["networkError"]; if (dataList.empty()) { return errorResource["emptyLibrariesList"].value(); } std::set<std::string> errors; const std::string proxy = proxyHost() + ':' + proxyPort(); CURLM *handle = curl_multi_init(); std::map<CURL*,shared_ptr<ZLExecutionData> > handleToRequest; for (ZLExecutionData::Vector::const_iterator it = dataList.begin(); it != dataList.end(); ++it) { if (it->isNull() || !(*it)->isInstanceOf(ZLNetworkRequest::TYPE_ID)) { continue; } ZLNetworkRequest &request = (ZLNetworkRequest&)**it; const std::string err = doBeforeRequest(request); if (!err.empty()) { errors.insert(err); continue; } CURL *easyHandle = curl_easy_init(); if (easyHandle != 0) { handleToRequest[easyHandle] = *it; setStandardOptions(easyHandle, proxy); setRequestOptions(easyHandle, request); curl_multi_add_handle(handle, easyHandle); } } int counter; CURLMcode res; do { res = curl_multi_perform(handle, &counter); } while ((res == CURLM_CALL_MULTI_PERFORM) || (counter > 0)); CURLMsg *message; do { int queueSize; message = curl_multi_info_read(handle, &queueSize); if ((message != 0) && (message->msg == CURLMSG_DONE)) { ZLNetworkRequest &request = (ZLNetworkRequest&)*handleToRequest[message->easy_handle]; const std::string &url = request.url(); CURLcode result = message->data.result; bool doAfterResult = request.doAfter(result == CURLE_OK); if (result == CURLE_OK && !doAfterResult) { result = CURLE_WRITE_ERROR; } switch (result) { case CURLE_OK: break; case CURLE_WRITE_ERROR: if (!request.errorMessage().empty()) { errors.insert(request.errorMessage()); } else { errors.insert(ZLStringUtil::printf(errorResource["somethingWrongMessage"].value(), ZLNetworkUtil::hostFromUrl(url))); } break; default: errors.insert(ZLStringUtil::printf(errorResource["somethingWrongMessage"].value(), ZLNetworkUtil::hostFromUrl(url))); break; case CURLE_COULDNT_RESOLVE_PROXY: errors.insert(ZLStringUtil::printf(errorResource["couldntResolveProxyMessage"].value(), proxyHost())); break; case CURLE_COULDNT_RESOLVE_HOST: errors.insert(ZLStringUtil::printf(errorResource["couldntResolveHostMessage"].value(), ZLNetworkUtil::hostFromUrl(url))); break; case CURLE_COULDNT_CONNECT: errors.insert(ZLStringUtil::printf(errorResource["couldntConnectMessage"].value(), ZLNetworkUtil::hostFromUrl(url))); break; case CURLE_OPERATION_TIMEDOUT: errors.insert(errorResource["operationTimedOutMessage"].value()); break; case CURLE_SSL_CONNECT_ERROR: errors.insert(ZLStringUtil::printf(errorResource["sslConnectErrorMessage"].value(), curl_easy_strerror(CURLE_SSL_CONNECT_ERROR))); break; #if LIBCURL_VERSION_NUM > 0x071100 case CURLE_PEER_FAILED_VERIFICATION: #else case CURLE_SSL_PEER_CERTIFICATE: #endif errors.insert(ZLStringUtil::printf(errorResource["peerFailedVerificationMessage"].value(), ZLNetworkUtil::hostFromUrl(url))); break; case CURLE_SSL_CACERT: errors.insert(ZLStringUtil::printf(errorResource["sslCertificateAuthorityMessage"].value(), ZLNetworkUtil::hostFromUrl(url))); break; case CURLE_SSL_CACERT_BADFILE: errors.insert(ZLStringUtil::printf(errorResource["sslBadCertificateFileMessage"].value(), request.sslCertificate().Path)); break; case CURLE_SSL_SHUTDOWN_FAILED: errors.insert(ZLStringUtil::printf(errorResource["sslShutdownFailedMessage"].value(), ZLNetworkUtil::hostFromUrl(url))); break; } } } while ((message != 0) && (errors.size() < 3)); for (std::map<CURL*,shared_ptr<ZLExecutionData> >::const_iterator jt = handleToRequest.begin(); jt != handleToRequest.end(); ++jt) { CURL *easyHandle = jt->first; curl_multi_remove_handle(handle, easyHandle); curl_easy_cleanup(easyHandle); ZLNetworkRequest &request = (ZLNetworkRequest&)*jt->second; clearRequestOptions(request); } handleToRequest.clear(); curl_multi_cleanup(handle); std::string result; for (std::set<std::string>::const_iterator et = errors.begin(); et != errors.end(); ++et) { if (!result.empty()) { result += '\n'; } result += *et; } return result; }
QString Config::proxy() const { return proxyHost() + ":" + proxyPort(); }