本文整理汇总了C++中QNetworkProxy::port方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkProxy::port方法的具体用法?C++ QNetworkProxy::port怎么用?C++ QNetworkProxy::port使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkProxy
的用法示例。
在下文中一共展示了QNetworkProxy::port方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setProxy
void ownCloudFolder::setProxy()
{
if( _csync_ctx ) {
/* Store proxy */
QUrl proxyUrl(ownCloudInfo::instance()->webdavUrl());
QList<QNetworkProxy> proxies = QNetworkProxyFactory::proxyForQuery(proxyUrl);
// We set at least one in Application
Q_ASSERT(proxies.count() > 0);
QNetworkProxy proxy = proxies.first();
if (proxy.type() == QNetworkProxy::NoProxy) {
qDebug() << "Passing NO proxy to csync for" << proxyUrl;
} else {
qDebug() << "Passing" << proxy.hostName() << "of proxy type " << proxy.type()
<< " to csync for" << proxyUrl;
}
int proxyPort = proxy.port();
csync_set_module_property(_csync_ctx, "proxy_type", (char*) proxyTypeToCStr(proxy.type()) );
csync_set_module_property(_csync_ctx, "proxy_host", proxy.hostName().toUtf8().data() );
csync_set_module_property(_csync_ctx, "proxy_port", &proxyPort );
csync_set_module_property(_csync_ctx, "proxy_user", proxy.user().toUtf8().data() );
csync_set_module_property(_csync_ctx, "proxy_pwd" , proxy.password().toUtf8().data() );
csync_set_module_property(_csync_ctx, "csync_context", _csync_ctx);
}
}
示例2: setRubyProxyEnvironment
void PatMainWindow::setRubyProxyEnvironment(const QNetworkProxy &t_proxy)
{
OS_ASSERT(t_proxy.type() == QNetworkProxy::NoProxy || t_proxy.type() == QNetworkProxy::HttpProxy);
if (t_proxy.type() == QNetworkProxy::NoProxy)
{
LOG(Info, "Clearing proxy environment variables");
bool set = qputenv("HTTP_PROXY", QByteArray());
OS_ASSERT(set);
set = qputenv("HTTP_PROXY_USER", QByteArray());
OS_ASSERT(set);
set = qputenv("HTTP_PROXY_PASS", QByteArray());
OS_ASSERT(set);
set = qputenv("HTTP_USER", QByteArray());
OS_ASSERT(set);
set = qputenv("HTTP_PASS", QByteArray());
OS_ASSERT(set);
} else if (t_proxy.type() == QNetworkProxy::HttpProxy) {
LOG(Info, "Clearing proxy environment variables");
QUrl urlsimple;
urlsimple.setHost(t_proxy.hostName());
urlsimple.setPort(t_proxy.port());
urlsimple.setScheme("http");
bool set = qputenv("HTTP_PROXY", urlsimple.toString().toLatin1());
OS_ASSERT(set);
set = qputenv("HTTP_PROXY_USER", t_proxy.user().toLatin1());
OS_ASSERT(set);
set = qputenv("HTTP_PROXY_PASS", t_proxy.password().toLatin1());
OS_ASSERT(set);
set = qputenv("HTTP_USER", t_proxy.user().toLatin1());
OS_ASSERT(set);
set = qputenv("HTTP_PASS", t_proxy.password().toLatin1());
OS_ASSERT(set);
}
}
示例3: setCSyncProxy
void ClientProxy::setCSyncProxy( const QUrl& url, CSYNC *csync_ctx )
{
/* Store proxy */
QList<QNetworkProxy> proxies = QNetworkProxyFactory::proxyForQuery(QNetworkProxyQuery(url));
// We set at least one in Application
Q_ASSERT(proxies.count() > 0);
QNetworkProxy proxy = proxies.first();
if (proxy.type() == QNetworkProxy::NoProxy) {
qDebug() << "Passing NO proxy to csync for" << url.toString();
} else {
qDebug() << "Passing" << proxy.hostName() << "of proxy type " << proxy.type()
<< " to csync for" << url.toString();
}
const char *proxy_type = proxyTypeToCStr(proxy.type());
const char* proxy_host = proxy.hostName().toUtf8().data();
int proxy_port = proxy.port();
const char *proxy_user = proxy.user().toUtf8().data();
const char *proxy_pwd = proxy.password().toUtf8().data();
csync_set_module_property( csync_ctx, "proxy_type", (void*)proxy_type );
csync_set_module_property( csync_ctx, "proxy_host", (void*)proxy_host );
csync_set_module_property( csync_ctx, "proxy_port", (void*)&proxy_port );
csync_set_module_property( csync_ctx, "proxy_user", (void*)proxy_user );
csync_set_module_property( csync_ctx, "proxy_pwd", (void*)proxy_pwd );
}
示例4: autoDetectProxy
void ProxyPreferencesWidget::autoDetectProxy()
{
LOG("Trying to find system proxy.");
QNetworkProxy proxy;
// QNetworkProxyFactory::setUseSystemConfiguration(true);
QNetworkProxyQuery npq(QUrl("http://www.google.com"));
QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq);
foreach(const QNetworkProxy &p, listOfProxies) {
if (p.type()==QNetworkProxy::HttpProxy && !p.hostName().isEmpty()) {
LOG("Using proxy " + p.hostName());
proxy = p;
break;
}
}
if (proxy.hostName().isEmpty()) {
ui->proxyHostName->clear();
ui->proxyPort->setValue(0);
ui->proxyUserName->clear();
ui->proxyUserPassword->clear();
} else {
ui->proxyHostName->setText(proxy.hostName());
ui->proxyPort->setValue(proxy.port());
ui->proxyUserName->setText(proxy.user());
ui->proxyUserPassword->setText(proxy.password());
}
}
示例5: setProxy
void FileDownloader::setProxy(QNetworkProxy proxy) {
http->abort();
http->setProxy(proxy);
qDebug("FileDownloader::setProxy: host: '%s' port: %d type: %d",
proxy.hostName().toUtf8().constData(), proxy.port(), proxy.type());
}
示例6: setCSyncProxy
void ClientProxy::setCSyncProxy( const QUrl& url, CSYNC *csync_ctx )
{
#ifdef USE_NEON
/* Store proxy */
QList<QNetworkProxy> proxies = QNetworkProxyFactory::proxyForQuery(QNetworkProxyQuery(url));
// We set at least one in Application
Q_ASSERT(proxies.count() > 0);
if (proxies.count() == 0) {
qDebug() << Q_FUNC_INFO << "No proxy!";
return;
}
QNetworkProxy proxy = proxies.first();
if (proxy.type() == QNetworkProxy::NoProxy) {
qDebug() << "Passing NO proxy to csync for" << url.toString();
} else {
qDebug() << "Passing" << proxy.hostName() << "of proxy type " << proxy.type()
<< " to csync for" << url.toString();
}
csync_set_module_property( csync_ctx, "proxy_type", (void*)(proxyTypeToCStr(proxy.type())));
csync_set_module_property( csync_ctx, "proxy_host", proxy.hostName().toUtf8().data());
int proxy_port = proxy.port();
csync_set_module_property( csync_ctx, "proxy_port", &proxy_port );
csync_set_module_property( csync_ctx, "proxy_user", proxy.user().toUtf8().data());
csync_set_module_property( csync_ctx, "proxy_pwd", proxy.password().toUtf8().data());
#else
Q_UNUSED(url);
Q_UNUSED(csync_ctx);
#endif
}
示例7: Init
void Proxy::Init()
{
if (CONF->UsingProxy())
{
QNetworkProxy ps = CONF->GetProxy();
SetProxy(CONF->ProxyType(), ps.hostName(), ps.port(), ps.user(), ps.password());
}
}
示例8: proxy
QString Phantom::proxy()
{
QNetworkProxy proxy = QNetworkProxy::applicationProxy();
if (proxy.hostName().isEmpty()) {
return NULL;
}
return proxy.hostName() + ":" + QString::number(proxy.port());
}
示例9: save
void save()
{
QNetworkProxy proxy = QNetworkProxy::applicationProxy();
Config::setValue("/Network/Proxy/Type", proxy.type());
Config::setValue("/Network/Proxy/HostName", proxy.hostName());
Config::setValue("/Network/Proxy/Port", proxy.port());
Config::setValue("/Network/Proxy/User", proxy.user());
Config::setValue("/Network/Proxy/Password", proxy.password());
}
示例10: setCurrentProxy
void connection::setCurrentProxy(QNetworkProxy &proxyToCopy)
{
currentProxy.setType(proxyToCopy.type());
currentProxy.setHostName(proxyToCopy.hostName());
currentProxy.setPort(proxyToCopy.port());
currentProxy.setUser(proxyToCopy.user());
currentProxy.setPassword(proxyToCopy.password());
}
示例11: setProxyCredentials
void PackageManagerProxyFactory::setProxyCredentials(const QNetworkProxy &proxy,
const QString &user,
const QString &password)
{
auto p = std::find_if(m_proxyCredentials.begin(), m_proxyCredentials.end(),
FindProxyCredential(proxy.hostName(), proxy.port()));
if (p == m_proxyCredentials.end()) {
ProxyCredential proxyCredential;
proxyCredential.host = proxy.hostName();
proxyCredential.port = proxy.port();
proxyCredential.user = user;
proxyCredential.password = password;
m_proxyCredentials.append(proxyCredential);
} else {
p->user = user;
p->password = password;
}
}
示例12: setProxy
void FindSubtitlesWindow::setProxy(QNetworkProxy proxy) {
downloader->abort();
downloader->setProxy(proxy);
#ifdef DOWNLOAD_SUBS
file_downloader->setProxy(proxy);
#endif
qDebug("FindSubtitlesWindow::setProxy: host: '%s' port: %d type: %d",
proxy.hostName().toUtf8().constData(), proxy.port(), proxy.type());
}
示例13: testSetProperty
void HTTPTransportTest::testSetProperty()
{
HTTPTransport transport;
transport.setProperty("foo", "bar");
QString proxyHost("http://foo.bar.net");
transport.setProperty(HTTPNUMBEROFRESENDATTEMPTSPROP, "10");
transport.setProperty(HTTPPROXYHOSTPROP, proxyHost);
transport.setProperty(HTTPPROXYPORTPROP, "5555");
QNetworkProxy proxy = transport.getProxyConfig();
QCOMPARE(proxy.hostName(), proxyHost);
QCOMPARE(proxy.port(), (quint16)5555);
}
示例14: testSetProxy
void HTTPTransportTest::testSetProxy()
{
HTTPTransport transport;
QNetworkProxy proxy;
QString proxyHost("http://foo.bar.net");
quint16 port = 5555;
proxy.setHostName(proxyHost);
proxy.setPort(port);
transport.setProxyConfig(proxy);
proxy = transport.getProxyConfig();
QCOMPARE(proxy.hostName(), proxyHost);
QCOMPARE(proxy.port(), port);
}
示例15: QDialog
NetworkSettingsDialog::NetworkSettingsDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::NetworkSettingsDialog)
{
ui->setupUi(this);
QValidator *val = new QIntValidator(this);
ui->proxyportEdit->setValidator(val);
QNetworkProxy proxy = QNetworkProxy::applicationProxy();
if (proxy.type() != proxy.NoProxy)
{
ui->proxyhostEdit->setText(proxy.hostName());
ui->proxyportEdit->setText(QString::number(proxy.port()));
ui->proxyuserEdit->setText(proxy.user());
ui->proxypassEdit->setText(proxy.password());
}
}