QList< QNetworkProxy > NetworkProxyFactory::queryProxy( const QNetworkProxyQuery& query ) { QList< QNetworkProxy > proxies; QString hostname = query.peerHostName(); if ( m_proxy.hostName().isEmpty() || hostname.isEmpty() || m_noProxyHosts.contains( hostname ) || TomahawkSettings::instance()->proxyType() == QNetworkProxy::NoProxy ) proxies << systemProxyForQuery( query ); else proxies << m_proxy << systemProxyForQuery( query ); return proxies; }
QList< QNetworkProxy > NetworkProxyFactory::queryProxy( const QNetworkProxyQuery& query ) { //tDebug() << Q_FUNC_INFO << "query hostname is " << query.peerHostName(); QList< QNetworkProxy > proxies; QString hostname = query.peerHostName(); s_noProxyHostsMutex.lock(); if ( s_noProxyHosts.contains( hostname ) ) proxies << QNetworkProxy::NoProxy << systemProxyForQuery( query ); else if ( m_proxy.hostName().isEmpty() || hostname.isEmpty() || TomahawkSettings::instance()->proxyType() == QNetworkProxy::NoProxy ) proxies << systemProxyForQuery( query ); else proxies << m_proxy << systemProxyForQuery( query ); s_noProxyHostsMutex.unlock(); return proxies; }
QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery& query) { QList<QNetworkProxy> results; if (query.peerHostName() == QString::fromAscii("127.0.0.1") || query.peerHostName().toLower() == QString::fromAscii("localhost")) { results.append(QNetworkProxy::NoProxy); } else { results = systemProxyForQuery(query); } return results; }
QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()) { QList<QNetworkProxy> plist; #if defined(__WINSCW__) plist.push_back(QNetworkProxy(QNetworkProxy::HttpProxy,QString("dawebproxy01.americas.nokia.com"), 8080)); #endif QUrl proxyUrl = urlFromUserInput(qgetenv("http_proxy")); if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) { int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080; plist.push_back(QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyPort)); } plist.append(systemProxyForQuery(query)); return plist; };
QList<QNetworkProxy> NetworkProxyFactory::queryProxy( const QNetworkProxyQuery& query) { QMutexLocker l(&mutex_); QNetworkProxy ret; switch (mode_) { case Mode_System: #ifdef Q_OS_LINUX Q_UNUSED(query); if (env_url_.isEmpty()) { ret.setType(QNetworkProxy::NoProxy); } else { ret.setHostName(env_url_.host()); ret.setPort(env_url_.port()); ret.setUser(env_url_.userName()); ret.setPassword(env_url_.password()); if (env_url_.scheme().startsWith("http")) ret.setType(QNetworkProxy::HttpProxy); else ret.setType(QNetworkProxy::Socks5Proxy); qLog(Debug) << "Using proxy URL:" << env_url_; } break; #else return systemProxyForQuery(query); #endif case Mode_Direct: ret.setType(QNetworkProxy::NoProxy); break; case Mode_Manual: ret.setType(type_); ret.setHostName(hostname_); ret.setPort(port_); if (use_authentication_) { ret.setUser(username_); ret.setPassword(password_); } break; } return QList<QNetworkProxy>() << ret; }
QList<QNetworkProxy> PackageManagerProxyFactory::queryProxy(const QNetworkProxyQuery &query) { const Settings &settings = m_core->settings(); QList<QNetworkProxy> list; if (settings.proxyType() == Settings::SystemProxy) { QList<QNetworkProxy> systemProxies = systemProxyForQuery(query); auto proxyIter = systemProxies.begin(); for (; proxyIter != systemProxies.end(); ++proxyIter) { QNetworkProxy &proxy = *proxyIter; auto p = std::find_if(m_proxyCredentials.constBegin(), m_proxyCredentials.constEnd(), FindProxyCredential(proxy.hostName(), proxy.port())); if (p != m_proxyCredentials.constEnd()) { proxy.setUser(p->user); proxy.setPassword(p->password); } } return systemProxies; } if ((settings.proxyType() == Settings::NoProxy)) return list << QNetworkProxy(QNetworkProxy::NoProxy); if (query.queryType() == QNetworkProxyQuery::UrlRequest) { QNetworkProxy proxy; if (query.url().scheme() == QLatin1String("ftp")) { proxy = settings.ftpProxy(); } else if (query.url().scheme() == QLatin1String("http") || query.url().scheme() == QLatin1String("https")) { proxy = settings.httpProxy(); } auto p = std::find_if(m_proxyCredentials.constBegin(), m_proxyCredentials.constEnd(), FindProxyCredential(proxy.hostName(), proxy.port())); if (p != m_proxyCredentials.constEnd()) { proxy.setUser(p->user); proxy.setPassword(p->password); } return list << proxy; } return list << QNetworkProxy(QNetworkProxy::DefaultProxy); }