本文整理汇总了C++中QNetworkProxy函数的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkProxy函数的具体用法?C++ QNetworkProxy怎么用?C++ QNetworkProxy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QNetworkProxy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: proxyFromDictionary
static QNetworkProxy proxyFromDictionary(CFDictionaryRef dict, QNetworkProxy::ProxyType type,
CFStringRef enableKey, CFStringRef hostKey,
CFStringRef portKey)
{
CFNumberRef protoEnabled;
CFNumberRef protoPort;
CFStringRef protoHost;
if (enableKey
&& (protoEnabled = (CFNumberRef)CFDictionaryGetValue(dict, enableKey))
&& (protoHost = (CFStringRef)CFDictionaryGetValue(dict, hostKey))
&& (protoPort = (CFNumberRef)CFDictionaryGetValue(dict, portKey))) {
int enabled;
if (CFNumberGetValue(protoEnabled, kCFNumberIntType, &enabled) && enabled) {
QString host = QCFString::toQString(protoHost);
int port;
CFNumberGetValue(protoPort, kCFNumberIntType, &port);
return QNetworkProxy(type, host, port);
}
}
// proxy not enabled
return QNetworkProxy();
}
开发者ID:2011fuzhou,项目名称:vlc-2.1.0.subproject-2010,代码行数:25,代码来源:qnetworkproxy_mac.cpp
示例2: defined
QList<QNetworkProxy> PackageManagerProxyFactory::queryProxy(const QNetworkProxyQuery &query)
{
const Settings &settings = m_core->settings();
QList<QNetworkProxy> list;
if (settings.proxyType() == Settings::SystemProxy) {
#if defined(Q_OS_UNIX) && !defined(Q_OS_OSX)
QUrl proxyUrl = QUrl::fromUserInput(QString::fromUtf8(qgetenv("http_proxy")));
if (proxyUrl.isValid()) {
return list << QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyUrl.port(),
proxyUrl.userName(), proxyUrl.password());
}
#endif
return QNetworkProxyFactory::systemProxyForQuery(query);
}
if ((settings.proxyType() == Settings::NoProxy))
return list << QNetworkProxy(QNetworkProxy::NoProxy);
if (query.queryType() == QNetworkProxyQuery::UrlRequest) {
if (query.url().scheme() == QLatin1String("ftp"))
return list << settings.ftpProxy();
if ((query.url().scheme() == QLatin1String("http"))
|| (query.url().scheme() == QLatin1String("https"))) {
return list << settings.httpProxy();
}
}
return list << QNetworkProxy(QNetworkProxy::DefaultProxy);
}
开发者ID:olear,项目名称:qtifw,代码行数:30,代码来源:packagemanagerproxyfactory.cpp
示例3: DEBUG
void jConnection::loadProxySettings()
{
DEBUG() << Q_FUNC_INFO;
createSocket();
QSettings settings(QSettings::defaultFormat(), QSettings::UserScope, "qutim/qutim."+m_profile_name+"/jabber."+m_account_name, "accountsettings");
settings.beginGroup("proxy");
int proxy_type = settings.value("type",0).toInt();
int proxy_port = settings.value("port",0).toInt();
QString proxy_host = settings.value("host","").toString();
bool proxy_auth = settings.value("auth",false).toBool();
QString proxy_user = settings.value("user","").toString();
QString proxy_pass = settings.value("password","").toString();
settings.endGroup();
switch(proxy_type)
{
case 0:{ // No Proxy
m_proxy = QNetworkProxy(QNetworkProxy::NoProxy);
m_socket->setProxy(m_proxy);
break;
}
case 1:{ // HTTP
m_proxy = QNetworkProxy(QNetworkProxy::HttpProxy, proxy_host, proxy_port);
if (proxy_auth)
{
m_proxy.setUser(proxy_user);
m_proxy.setPassword(proxy_pass);
}
m_socket->setProxy(m_proxy);
break;}
case 2:{ // SOCKS5
m_proxy = QNetworkProxy(QNetworkProxy::Socks5Proxy, proxy_host, proxy_port);
m_socket->setProxy(m_proxy);
if (proxy_auth)
{
m_proxy.setUser(proxy_user);
m_proxy.setPassword(proxy_pass);
}
break;
}
case 3: // BOSH
// Really don not know what is it
// so it would be equal to no proxy
default:{
m_proxy = QNetworkProxy(QNetworkProxy::DefaultProxy);
m_socket->setProxy(m_proxy);
break;
}
}
}
开发者ID:veksha,项目名称:vekshas-qutim-protocols,代码行数:49,代码来源:jConnection.cpp
示例4: QNetworkProxy
IConnectionProxy ConnectionManager::proxyById(const QUuid &AProxyId) const
{
static const IConnectionProxy noProxy = {" "+tr("<No Proxy>"), QNetworkProxy(QNetworkProxy::NoProxy) };
if (!AProxyId.isNull())
{
OptionsNode pnode;
QList<QUuid> plist = proxyList();
if (plist.contains(AProxyId))
pnode = Options::node(OPV_PROXY_ITEM,AProxyId.toString());
else if (plist.contains(defaultProxy()))
pnode = Options::node(OPV_PROXY_ITEM,defaultProxy().toString());
if (!pnode.isNull())
{
IConnectionProxy proxy;
proxy.name = pnode.value("name").toString();
proxy.proxy.setType((QNetworkProxy::ProxyType)pnode.value("type").toInt());
proxy.proxy.setHostName(pnode.value("host").toString());
proxy.proxy.setPort(pnode.value("port").toInt());
proxy.proxy.setUser(pnode.value("user").toString());
proxy.proxy.setPassword(Options::decrypt(pnode.value("pass").toByteArray()).toString());
return proxy;
}
}
return noProxy;
}
开发者ID:Vacuum-IM,项目名称:vacuum-im,代码行数:28,代码来源:connectionmanager.cpp
示例5: proxy
QNetworkProxy SocksStreams::accountNetworkProxy(const Jid &AStreamJid) const
{
QNetworkProxy proxy(QNetworkProxy::NoProxy);
IXmppStream *stream = FXmppStreams!=NULL ? FXmppStreams->xmppStream(AStreamJid) : NULL;
IDefaultConnection *connection = stream!=NULL ? qobject_cast<IDefaultConnection *>(stream->connection()->instance()) : NULL;
return connection!=NULL ? connection->proxy() : QNetworkProxy(QNetworkProxy::NoProxy);
}
开发者ID:sanchay160887,项目名称:vacuum-im,代码行数:7,代码来源:socksstreams.cpp
示例6: setProxy
/*!
\since 4.1
Returns the network proxy for this socket.
By default QNetworkProxy::DefaultProxy is used.
\sa setProxy(), QNetworkProxy
*/
QNetworkProxy QTcpServer::proxy() const
{
Q_D(const QTcpServer);
if (d->proxy)
return *d->proxy;
return QNetworkProxy();
}
开发者ID:pk-codebox-evo,项目名称:remixos-usb-tool,代码行数:15,代码来源:qtcpserver.cpp
示例7: qDebug
void Translator::translate(const QString &text, const QString &language, QObject *sender) {
qDebug() << "Translator::translate() " + text;
Configuration *config = Configuration::getInstance();
QUrl translatorUrl("http://ajax.googleapis.com/ajax/services/language/translate");
QString request = "?v=1.0&q=" + QUrl::toPercentEncoding(text) + "&format=html&langpair=%7C" + language;
QHttpRequestHeader header;
header.setRequest("GET", translatorUrl.path() + request);
header.setValue("Host", translatorUrl.host());
header.setValue("Referer", "Qwit");
if (config->useProxy) {
http->setProxy(config->proxyAddress, config->proxyPort, config->proxyUsername, config->proxyPassword);
} else {
http->setProxy(QNetworkProxy(QNetworkProxy::NoProxy));
}
if(translatorUrl.toString().indexOf("https") == 0) {
http->setHost(translatorUrl.host(), QHttp::ConnectionModeHttps, translatorUrl.port(443));
} else {
http->setHost(translatorUrl.host(), QHttp::ConnectionModeHttp, translatorUrl.port(80));
}
buffer = new QBuffer(this);
buffer->open(QIODevice::WriteOnly);
int requestId = http->request(header, 0, buffer);
requestSender[requestId] = sender;
}
开发者ID:artikz,项目名称:qwit,代码行数:30,代码来源:Translator.cpp
示例8: query
/*! \internal
Resolve the proxy to its final value.
*/
QNetworkProxy QTcpServerPrivate::resolveProxy(const QHostAddress &address, quint16 port)
{
if (address == QHostAddress::LocalHost ||
address == QHostAddress::LocalHostIPv6)
return QNetworkProxy::NoProxy;
QList<QNetworkProxy> proxies;
if (proxy.type() != QNetworkProxy::DefaultProxy) {
// a non-default proxy was set with setProxy
proxies << proxy;
} else {
// try the application settings instead
QNetworkProxyQuery query(port, QString(), QNetworkProxyQuery::TcpServer);
proxies = QNetworkProxyFactory::proxyForQuery(query);
}
// return the first that we can use
foreach (const QNetworkProxy &p, proxies) {
if (p.capabilities() & QNetworkProxy::ListeningCapability)
return p;
}
// no proxy found
// DefaultProxy will raise an error
return QNetworkProxy(QNetworkProxy::DefaultProxy);
}
开发者ID:wpbest,项目名称:copperspice,代码行数:30,代码来源:qtcpserver.cpp
示例9: GetList
void JamendoBrowser::GetList(QString comefrom, QString text)
{
if(proxy->hasVariable("proxyEnabled") && proxy->getVariable("proxyEnabled") == "true") {
manager.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,
proxy->getVariable("proxyHost"),
proxy->getVariable("proxyPort").toInt(),
proxy->getVariable("proxyUser"),
proxy->getVariable("proxyPassword")));
}
if(!comefrom.size()) comefrom = "http://api.jamendo.com/get2/id+name+rating+url+weight/tag/plain/?order=rating_desc";
comefrom += "&n=50";
reply = manager.get(QNetworkRequest(QUrl(comefrom)));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotError(QNetworkReply::NetworkError)));
if (text.size()) switch(listType) {
case LIST_GENRE:
_tag.tag0.genre = text; break;
case LIST_ARTIST:
_tag.tag0.artist = text; break;
case LIST_ALBUM:
_tag.tag0.album = text; break;
case LIST_NONE:
default:
;
}
}
开发者ID:sushantg11,项目名称:cuberok,代码行数:25,代码来源:jamendo_browser.cpp
示例10: setApplicationProxyFactory
void setApplicationProxyFactory(QNetworkProxyFactory *factory)
{
QMutexLocker lock(&mutex);
if (applicationLevelProxy)
*applicationLevelProxy = QNetworkProxy();
delete applicationLevelProxyFactory;
applicationLevelProxyFactory = factory;
}
开发者ID:maxxant,项目名称:qt,代码行数:8,代码来源:qnetworkproxy.cpp
示例11: queryProxy
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;
};
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:17,代码来源:main.cpp
示例12: QNetworkProxy
QNetworkProxy NetworkProxyDialog::createProxy(const QSettings &t_settings)
{
QNetworkProxy::ProxyType type = static_cast<QNetworkProxy::ProxyType>(t_settings.value("networkproxy_type", QNetworkProxy::NoProxy).toInt());
QString hostname = t_settings.value("networkproxy_hostname").toString();
int port = t_settings.value("networkproxy_port").toInt();
QString user = t_settings.value("networkproxy_user").toString();
return QNetworkProxy(type, hostname, port, user, "");
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:8,代码来源:NetworkProxyDialog.cpp
示例13: proxyUrl
void WebPage::applyProxy()
{
QUrl proxyUrl(qgetenv("http_proxy"));
if (proxyUrl.isValid() && !proxyUrl.host().isEmpty()) {
int proxyPort = (proxyUrl.port() > 0) ? proxyUrl.port() : 8080;
networkAccessManager()->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyPort));
}
}
开发者ID:mcgrawp,项目名称:webkit-webcl,代码行数:9,代码来源:webpage.cpp
示例14: QNetworkProxy
QNetworkProxy ProgramSettings::getProxySettings(const ProgramSettings &programSettings)
{
if (programSettings.useProxy)
{
QString userName;
QString password;
if (programSettings.proxyRequiresAuthorization)
{
userName = programSettings.proxyUserName;
password = programSettings.proxyPassword;
}
return QNetworkProxy(programSettings.proxyType, programSettings.proxyHost, programSettings.getProxyPort(), userName, password);
}
else
return QNetworkProxy(QNetworkProxy::DefaultProxy);
}
开发者ID:ildus,项目名称:moodbox_aka_risovaska,代码行数:18,代码来源:programsettings.cpp
示例15: qDebug
void Composer::connectToHost(){
if(socket->state() != QAbstractSocket::ClosingState
&& socket->state() != QAbstractSocket::UnconnectedState){
qDebug()<<"already connected";
socket->abort();
}
socket->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy,_proxyHost,_proxyPort));
socket->connectToHost(ui->server->text(),ui->port->text().toInt());
}
开发者ID:qhwa,项目名称:Rythem,代码行数:9,代码来源:composer.cpp
示例16: systemProxyForQuery
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);
}
开发者ID:qtproject,项目名称:installer-framework,代码行数:44,代码来源:packagemanagerproxyfactory.cpp
示例17: parseServerList
static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, const QStringList &proxyList)
{
// Reference documentation from Microsoft:
// http://msdn.microsoft.com/en-us/library/aa383912(VS.85).aspx
//
// According to the website, the proxy server list is
// one or more of the space- or semicolon-separated strings in the format:
// ([<scheme>=][<scheme>"://"]<server>[":"<port>])
QList<QNetworkProxy> result;
foreach (const QString &entry, proxyList) {
int server = 0;
int pos = entry.indexOf(QLatin1Char('='));
if (pos != -1) {
QStringRef scheme = entry.leftRef(pos);
if (scheme != query.protocolTag())
continue;
server = pos + 1;
}
QNetworkProxy::ProxyType proxyType = QNetworkProxy::HttpProxy;
quint16 port = 8080;
pos = entry.indexOf(QLatin1String("://"), server);
if (pos != -1) {
QStringRef scheme = entry.midRef(server, pos - server);
if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) {
// no-op
// defaults are above
} else if (scheme == QLatin1String("socks") || scheme == QLatin1String("socks5")) {
proxyType = QNetworkProxy::Socks5Proxy;
port = 1080;
} else {
// unknown proxy type
continue;
}
server = pos + 3;
}
pos = entry.indexOf(QLatin1Char(':'), server);
if (pos != -1) {
bool ok;
uint value = entry.mid(pos + 1).toUInt(&ok);
if (!ok || value > 65535)
continue; // invalid port number
port = value;
} else {
pos = entry.length();
}
result << QNetworkProxy(proxyType, entry.mid(server, pos - server), port);
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:56,代码来源:qnetworkproxy_win.cpp
示例18: QGeoTiledMappingManagerEngine
QGeoMappingManagerEngineOsm::QGeoMappingManagerEngineOsm(const QMap<QString, QVariant> ¶meters, QGeoServiceProvider::Error *error, QString *errorString)
: QGeoTiledMappingManagerEngine(parameters),
m_parameters(parameters)
{
Q_UNUSED(error)
Q_UNUSED(errorString)
setTileSize(QSize(256,256));
setMinimumZoomLevel(0.0);
setMaximumZoomLevel(18.0);
m_tyleStyleId = "1";
QList<QGraphicsGeoMap::MapType> types;
types << QGraphicsGeoMap::StreetMap;
types << QGraphicsGeoMap::TerrainMap; // used for cyclemap
types << TRANSITMAP;
setSupportedMapTypes(types);
m_nam = new QNetworkAccessManager(this);
#ifdef USE_NETWORK_CACHE
m_cache = new QNetworkDiskCache(this);
QDir dir = QDir::temp();
dir.mkdir("maptiles-osm");
dir.cd("maptiles-osm");
m_cache->setCacheDirectory(dir.path());
#endif
QList<QString> keys = m_parameters.keys();
if (keys.contains("mapping.proxy")) {
QString proxy = m_parameters.value("mapping.proxy").toString();
if (!proxy.isEmpty())
m_nam->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxy, 8080));
}
#ifdef USE_NETWORK_CACHE
if (keys.contains("mapping.cache.directory")) {
QString cacheDir = m_parameters.value("mapping.cache.directory").toString();
if (!cacheDir.isEmpty())
m_cache->setCacheDirectory(cacheDir);
}
if (keys.contains("mapping.cache.size")) {
bool ok = false;
qint64 cacheSize = m_parameters.value("mapping.cache.size").toString().toLongLong(&ok);
if (ok)
m_cache->setMaximumCacheSize(cacheSize);
}
m_nam->setCache(m_cache);
#endif
}
开发者ID:harbaum,项目名称:CacheMe,代码行数:56,代码来源:qgeomappingmanagerengine_osm.cpp
示例19: main
int main(int argc, char**argv)
{
QCoreApplication app(argc, argv);
// create it
QAbstractSocketEngine *socketEngine =
QAbstractSocketEngine::createSocketEngine(QAbstractSocket::TcpSocket, QNetworkProxy(QNetworkProxy::NoProxy), 0);
if (!socketEngine) {
qDebug() << "could not create engine";
exit(1);
}
// initialize it
bool initialized = socketEngine->initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol);
if (!initialized) {
qDebug() << "not able to initialize engine";
exit(1);
}
// wait for connected
int r = socketEngine->connectToHost(QHostAddress("74.125.77.99"), 80); // google
bool readyToRead = false;
bool readyToWrite = false;
socketEngine->waitForReadOrWrite(&readyToRead, &readyToWrite, true, true, 10*1000);
if (r <= 0) //timeout or error
exit(1);
if (readyToWrite) {
// write the request
QByteArray request("GET /robots.txt HTTP/1.0\r\n\r\n");
int ret = socketEngine->write(request.constData(), request.length());
if (ret == request.length()) {
// read the response in a loop
do {
bool waitReadResult = socketEngine->waitForRead(10*1000);
int available = socketEngine->bytesAvailable();
if (waitReadResult == true && available == 0) {
// disconnected
exit(0);
}
qFill(buf, buf + bufsize, 0);
ret = socketEngine->read(buf, available);
if (ret > 0) {
printf("%s", buf);
} else {
// some failure when reading
exit(1);
}
} while (1);
} else {
qDebug() << "failed writing";
}
} else {
qDebug() << "failed connecting";
}
delete socketEngine;
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:56,代码来源:main.cpp
示例20: QNetworkProxy
void MainWindow::setProxy(const QString& host, int port, const QString& username, const QString& password)
{
if (m_https)
{
QNetworkProxy proxy = QNetworkProxy(QNetworkProxy::HttpProxy, host, port);
proxy.setUser(username);
proxy.setPassword(password);
m_https->setProxy(proxy);
}
}
开发者ID:ggaudeau,项目名称:spammer,代码行数:10,代码来源:mainwindow.cpp
注:本文中的QNetworkProxy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论