当前位置: 首页>>代码示例>>C++>>正文


C++ QNetworkProxy函数代码示例

本文整理汇总了C++中QNetworkProxy函数的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkProxy函数的具体用法?C++ QNetworkProxy怎么用?C++ QNetworkProxy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了QNetworkProxy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的QNetworkProxy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。