本文整理汇总了C++中QNetworkProxy::hostName方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkProxy::hostName方法的具体用法?C++ QNetworkProxy::hostName怎么用?C++ QNetworkProxy::hostName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkProxy
的用法示例。
在下文中一共展示了QNetworkProxy::hostName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2: 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 );
}
示例3: proxyAuthenticationRequired
/** Slot connected to proxy authentication required */
void HttpDownloaderPrivate::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
{
LOG("Proxy authentication required: " + proxy.hostName());
const QString &host = proxy.hostName();
m_AuthTimes.insert(host, m_AuthTimes.value(host, 0) + 1);
if (m_AuthTimes.value(host) > MAX_AUTHENTIFICATION_TRIES) {
LOG_ERROR("Proxy authentication max tries achieved. " + host);
return;
}
if (!proxy.user().isEmpty() && !proxy.password().isEmpty()) {
authenticator->setUser(proxy.user());
authenticator->setPassword(proxy.password());
} else {
// Ask user for identification
Utils::BasicLoginDialog dlg;
dlg.setModal(true);
dlg.setTitle(tr("Proxy authentication required"));
// TODO: manage icon
// dlg.setToggleViewIcon(core().icon(ICONEYES));
if (dlg.exec()==QDialog::Accepted) {
authenticator->setUser(dlg.login());
authenticator->setPassword(dlg.password());
}
}
// TODO: manage ServerEngineStatus here
}
示例4: 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);
}
}
示例5: 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());
}
}
示例6: proxyAuthenticationRequired
void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth)
{
QWidget *mainWindow = Gui::getMainWindow();
QDialog dialog(mainWindow);
dialog.setWindowFlags(Qt::Sheet);
Ui_DlgAuthorization proxyDialog;
proxyDialog.setupUi(&dialog);
dialog.adjustSize();
QString introMessage = tr("<qt>Connect to proxy \"%1\" using:</qt>");
#if QT_VERSION >= 0x050000
introMessage = introMessage.arg(QString(proxy.hostName()).toHtmlEscaped());
#else
introMessage = introMessage.arg(Qt::escape(proxy.hostName()));
#endif
proxyDialog.siteDescription->setText(introMessage);
proxyDialog.siteDescription->setWordWrap(true);
if (dialog.exec() == QDialog::Accepted) {
auth->setUser(proxyDialog.username->text());
auth->setPassword(proxyDialog.password->text());
}
}
示例7: proxy
QString Phantom::proxy()
{
QNetworkProxy proxy = QNetworkProxy::applicationProxy();
if (proxy.hostName().isEmpty()) {
return NULL;
}
return proxy.hostName() + ":" + QString::number(proxy.port());
}
示例8: 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());
}
示例9: proxyAuthenticationRequired
void MapNetwork::proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
{
qDebug() << "Proxy Aut req" << proxy.hostName() << &authenticator;
QDialog dialog;
QGridLayout layout;
QLabel username, password;
username.setText("Username:");
password.setText("Password:");
layout.addWidget(&username, 0, 0);
layout.addWidget(&password, 1, 0);
QLineEdit user, pass;
pass.setEchoMode(QLineEdit::Password);
connect(&user, SIGNAL(returnPressed()), &dialog, SLOT(accept()));
connect(&pass, SIGNAL(returnPressed()), &dialog, SLOT(accept()));
layout.addWidget(&user, 0, 1);
layout.addWidget(&pass, 1, 1);
QPushButton button;
button.setText("OK");
connect(&button, SIGNAL(clicked()), &dialog, SLOT(accept()));
layout.addWidget(&button, 2, 0, 1, 2, Qt::AlignCenter);
dialog.setLayout(&layout);
dialog.exec();
authenticator->setUser(user.text());
authenticator->setPassword(pass.text());
}
示例10: initNetManager
void PaymentServer::initNetManager()
{
if (!optionsModel)
return;
delete netManager;
// netManager is used to fetch paymentrequests given in bitcoin: URIs
netManager = new QNetworkAccessManager(this);
QNetworkProxy proxy;
// Query active SOCKS5 proxy
if (optionsModel->getProxySettings(proxy)) {
netManager->setProxy(proxy);
qDebug() << "PaymentServer::initNetManager: Using SOCKS5 proxy" << proxy.hostName() << ":" << proxy.port();
}
else
qDebug() << "PaymentServer::initNetManager: No active proxy server found.";
connect(netManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(netRequestFinished(QNetworkReply*)));
connect(netManager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError> &)),
this, SLOT(reportSslErrors(QNetworkReply*, const QList<QSslError> &)));
}
示例11: 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);
}
}
示例12: Init
void Proxy::Init()
{
if (CONF->UsingProxy())
{
QNetworkProxy ps = CONF->GetProxy();
SetProxy(CONF->ProxyType(), ps.hostName(), ps.port(), ps.user(), ps.password());
}
}
示例13: 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());
}
示例14: 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());
}
示例15: delayedStart
void SslTlsSocket::delayedStart()
{
QSslSocket *sock = qobject_cast<QSslSocket *>(d);
Q_ASSERT(sock);
switch (m_proxySettings) {
case Streams::ProxySettings::RespectSystemProxy:
{
QNetworkProxy setting;
QNetworkProxyQuery query = QNetworkProxyQuery(host, port, m_protocolTag, QNetworkProxyQuery::TcpSocket);
// set to true if a capable setting is found
bool capableSettingFound = false;
// set to true if at least one valid setting is found
bool settingFound = false;
// FIXME: this static function works particularly slow in Windows
QList<QNetworkProxy> proxySettingsList = QNetworkProxyFactory::systemProxyForQuery(query);
/* Proxy Settings are read from the user's environment variables by the above static method.
* A peculiar case is with *nix systems, where an undefined environment variable is returned as
* an empty string. Such entries *might* exist in our proxySettingsList, and shouldn't be processed.
* One good check is to use hostName() of the QNetworkProxy object, and treat the Proxy Setting as invalid if
* the host name is empty. */
Q_FOREACH (setting, proxySettingsList) {
if (!setting.hostName().isEmpty()) {
settingFound = true;
// now check whether setting has capabilities
if (setting.capabilities().testFlag(QNetworkProxy::TunnelingCapability)) {
sock->setProxy(setting);
capableSettingFound = true;
break;
}
}
}
if (!settingFound || proxySettingsList.isEmpty()) {
sock->setProxy(QNetworkProxy::NoProxy);
} else if (!capableSettingFound) {
emit disconnected(tr("The underlying socket is having troubles when processing connection to %1:%2: %3")
.arg(host, QString::number(port), QStringLiteral("Cannot find proxy setting capable of tunneling")));
}
break;
}
case Streams::ProxySettings::DirectConnect:
sock->setProxy(QNetworkProxy::NoProxy);
break;
}
if (startEncrypted)
sock->connectToHostEncrypted(host, port);
else
sock->connectToHost(host, port);
}