本文整理汇总了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();
}
示例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);
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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);
}
示例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:
;
}
}
示例10: setApplicationProxyFactory
void setApplicationProxyFactory(QNetworkProxyFactory *factory)
{
QMutexLocker lock(&mutex);
if (applicationLevelProxy)
*applicationLevelProxy = QNetworkProxy();
delete applicationLevelProxyFactory;
applicationLevelProxyFactory = factory;
}
示例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;
};
示例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, "");
}
示例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));
}
}
示例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);
}
示例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());
}