本文整理汇总了C++中QNetworkProxy::password方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkProxy::password方法的具体用法?C++ QNetworkProxy::password怎么用?C++ QNetworkProxy::password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QNetworkProxy
的用法示例。
在下文中一共展示了QNetworkProxy::password方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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
}
示例3: slotProxyAuthenticationRequired
void AccessManager::slotProxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator)
{
Q_UNUSED(authenticator);
qDebug() << Q_FUNC_INFO << proxy.type();
// We put in the password here and in ClientProxy in the proxy itself.
if (!proxy.user().isEmpty() || !proxy.password().isEmpty()) {
authenticator->setUser(proxy.user());
authenticator->setPassword(proxy.password());
}
}
示例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: 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 );
}
示例6: aSlot
void AbstractSocketSubclass::aSlot(const QNetworkProxy &proxy, QAuthenticator *authenticator)
{
if (authenticator != 0) {
authenticator->setUser(proxy.user());
authenticator->setPassword(proxy.password());
}
}
示例7: 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());
}
}
示例8: QNetworkAuthenticationCredential
QNetworkAuthenticationCredential
QNetworkAccessAuthenticationManager::fetchCachedProxyCredentials(const QNetworkProxy &p,
const QAuthenticator *authenticator)
{
QNetworkProxy proxy = p;
if (proxy.type() == QNetworkProxy::DefaultProxy) {
proxy = QNetworkProxy::applicationProxy();
}
if (!proxy.password().isEmpty())
return QNetworkAuthenticationCredential(); // no need to set credentials if it already has them
QString realm;
if (authenticator)
realm = authenticator->realm();
QMutexLocker mutexLocker(&mutex);
QByteArray cacheKey = proxyAuthenticationKey(proxy, realm);
if (cacheKey.isEmpty())
return QNetworkAuthenticationCredential();
if (!authenticationCache.hasEntry(cacheKey))
return QNetworkAuthenticationCredential();
QNetworkAuthenticationCache *auth =
static_cast<QNetworkAuthenticationCache *>(authenticationCache.requestEntryNow(cacheKey));
QNetworkAuthenticationCredential cred = *auth->findClosestMatch(QString());
authenticationCache.releaseEntry(cacheKey);
// proxy cache credentials always have exactly one item
Q_ASSERT_X(!cred.isNull(), "QNetworkAccessManager",
"Internal inconsistency: found a cache key for a proxy, but it's empty");
return cred;
}
示例9: 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
}
示例10: proxyAuthentication
void NetworkManager::proxyAuthentication(const QString &proxyHost, QAuthenticator *auth, QWidget *parent)
{
const QNetworkProxy proxy = QNetworkProxy::applicationProxy();
if (!proxy.user().isEmpty() && !proxy.password().isEmpty()) {
auth->setUser(proxy.user());
auth->setPassword(proxy.password());
return;
}
QDialog* dialog = new QDialog(parent);
dialog->setWindowTitle(tr("Proxy authorisation required"));
QFormLayout* formLa = new QFormLayout(dialog);
QLabel* label = new QLabel(dialog);
QLabel* userLab = new QLabel(dialog);
QLabel* passLab = new QLabel(dialog);
userLab->setText(tr("Username: "));
passLab->setText(tr("Password: "));
QLineEdit* user = new QLineEdit(dialog);
QLineEdit* pass = new QLineEdit(dialog);
pass->setEchoMode(QLineEdit::Password);
QDialogButtonBox* box = new QDialogButtonBox(dialog);
box->addButton(QDialogButtonBox::Ok);
box->addButton(QDialogButtonBox::Cancel);
connect(box, SIGNAL(rejected()), dialog, SLOT(reject()));
connect(box, SIGNAL(accepted()), dialog, SLOT(accept()));
label->setText(tr("A username and password are being requested by proxy %1. ").arg(proxyHost));
formLa->addRow(label);
formLa->addRow(userLab, user);
formLa->addRow(passLab, pass);
formLa->addWidget(box);
if (dialog->exec() != QDialog::Accepted) {
*auth = QAuthenticator();
delete dialog;
return;
}
auth->setUser(user->text());
auth->setPassword(pass->text());
delete dialog;
}
示例11: Init
void Proxy::Init()
{
if (CONF->UsingProxy())
{
QNetworkProxy ps = CONF->GetProxy();
SetProxy(CONF->ProxyType(), ps.hostName(), ps.port(), ps.user(), ps.password());
}
}
示例12: 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());
}
示例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: setProxy
void QHttpSocketEngine::setProxy(const QNetworkProxy &proxy)
{
Q_D(QHttpSocketEngine);
d->proxy = proxy;
QString user = proxy.user();
if (!user.isEmpty())
d->authenticator.setUser(user);
QString password = proxy.password();
if (!password.isEmpty())
d->authenticator.setPassword(password);
}
示例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());
}
}