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


C++ QUrl::password方法代码示例

本文整理汇总了C++中QUrl::password方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::password方法的具体用法?C++ QUrl::password怎么用?C++ QUrl::password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QUrl的用法示例。


在下文中一共展示了QUrl::password方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: proxy

QT_BEGIN_NAMESPACE

QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &)
{
    QList<QNetworkProxy> proxyList;

    QByteArray proxy_env = qgetenv("http_proxy");
    if (!proxy_env.isEmpty()) {
        QUrl url = QUrl(QString::fromLocal8Bit(proxy_env));
        if (url.scheme() == QLatin1String("socks5")) {
            QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(),
                    url.port() ? url.port() : 1080, url.userName(), url.password());
            proxyList << proxy;
        } else if (url.scheme() == QLatin1String("socks5h")) {
            QNetworkProxy proxy(QNetworkProxy::Socks5Proxy, url.host(),
                    url.port() ? url.port() : 1080, url.userName(), url.password());
            proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability);
            proxyList << proxy;
        } else if (url.scheme() == QLatin1String("http") || url.scheme().isEmpty()) {
            QNetworkProxy proxy(QNetworkProxy::HttpProxy, url.host(),
                    url.port() ? url.port() : 8080, url.userName(), url.password());
            proxyList << proxy;
        }
    }
    if (proxyList.isEmpty())
        proxyList << QNetworkProxy::NoProxy;

    return proxyList;
}
开发者ID:kaiquewdev,项目名称:phantomjs,代码行数:29,代码来源:qnetworkproxy_generic.cpp

示例2: systemProxyForQuery

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: db_open

bool db_open(QUrl dburl)
{
    QSqlDatabase db;
    db.removeDatabase("vengeance");



    if(dburl.scheme().isEmpty())
       db=QSqlDatabase::addDatabase("QMYSQL","vengeance");
    else
       db=QSqlDatabase::addDatabase(dburl.scheme(),"vengeance");


    if(dburl.host().isEmpty())
        db.setHostName("localhost");
    else
        db.setHostName(dburl.host());

    db.setDatabaseName(dburl.path().replace("/",""));

    db.setUserName(dburl.userName());
    db.setPassword(dburl.password());



    bool w=db.open();

    if(!w)
    {
        qDebug()<<db.lastError ();
    }

    return w;
}
开发者ID:aep,项目名称:asgaard-aera,代码行数:34,代码来源:db.cpp

示例4: password

QString QUrlProto::password() const
{
  QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
  if (item)
    return item->password();
  return QString();
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例5: setGateway

/*!
  \a url points to the new WAP gateway.

  \sa gateway()
*/
void QWapAccount::setGateway( const QUrl& url )
{
    d->conf->setValue( QLatin1String("Wap/Gateway"), url.host() );
    d->conf->setValue( QLatin1String("Wap/UserName"), url.userName() );
    d->conf->setValue( QLatin1String("Wap/Password"), url.password() );
    d->conf->setValue( QLatin1String("Wap/Port"), url.port() );
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:12,代码来源:qwapaccount.cpp

示例6: QNetworkAuthenticationCredential

/*!
    Fetch the credential data from the credential cache.

    If auth is 0 (as it is when called from createRequest()), this will try to
    look up with an empty realm. That fails in most cases for HTTP (because the
    realm is seldom empty for HTTP challenges). In any case, QHttpNetworkConnection
    never sends the credentials on the first attempt: it needs to find out what
    authentication methods the server supports.

    For FTP, realm is always empty.
*/
QNetworkAuthenticationCredential
QNetworkAccessAuthenticationManager::fetchCachedCredentials(const QUrl &url,
                                                     const QAuthenticator *authentication)
{
    if (!url.password().isEmpty())
        return QNetworkAuthenticationCredential(); // no need to set credentials if it already has them

    QString realm;
    if (authentication)
        realm = authentication->realm();

    QByteArray cacheKey = authenticationKey(url, realm);

    QMutexLocker mutexLocker(&mutex);
    if (!authenticationCache.hasEntry(cacheKey))
        return QNetworkAuthenticationCredential();

    QNetworkAuthenticationCache *auth =
        static_cast<QNetworkAuthenticationCache *>(authenticationCache.requestEntryNow(cacheKey));
    QNetworkAuthenticationCredential *cred = auth->findClosestMatch(url.path());
    QNetworkAuthenticationCredential ret;
    if (cred)
        ret = *cred;
    authenticationCache.releaseEntry(cacheKey);
    return ret;
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:37,代码来源:qnetworkaccessauthenticationmanager.cpp

示例7: initializePage

void OwncloudHttpCredsPage::initializePage()
{
    WizardCommon::initErrorLabel(_ui.errorLabel);

    OwncloudWizard* ocWizard = qobject_cast< OwncloudWizard* >(wizard());
    AbstractCredentials *cred = ocWizard->account()->credentials();
    HttpCredentials *httpCreds = qobject_cast<HttpCredentials*>(cred);
    if (httpCreds) {
        const QString user = httpCreds->fetchUser();
        if (!user.isEmpty()) {
            _ui.leUsername->setText(user);
        }
    } else {
        QUrl url = ocWizard->account()->url();

        // If the final url does not have a username, check the
        // user specified url too. Sometimes redirects can lose
        // the user:pw information.
        if (url.userName().isEmpty()) {
            url = ocWizard->ocUrl();
        }

        const QString user = url.userName();
        const QString password = url.password();

        if(!user.isEmpty()) {
            _ui.leUsername->setText(user);
        }
        if(!password.isEmpty()) {
            _ui.lePassword->setText(password);
        }
    }
    _ui.leUsername->setFocus();
}
开发者ID:RobinGeuze,项目名称:client,代码行数:34,代码来源:owncloudhttpcredspage.cpp

示例8: dropSlsk

void Transfers::dropSlsk(const QList<QUrl>& l) {
	QList<QUrl>::const_iterator it = l.begin();
	for(; it != l.end(); ++it) {
		QUrl url = *it;
		if(url.scheme() == "slsk" && !url.host().isEmpty() && !url.path().isEmpty()) {
            // Try to find a size
			qint64 size = 0;
            bool ok;
            size = url.password().toLongLong(&ok);
            if(! ok)
				size = 0;

            // Find the user name
            QString user = url.userName();
			if (user.isEmpty())
                user = url.host();

            // Find the path (folder or file)
			QString path = url.path().replace("/", "\\");

			if(path.right(1) == "\\")
				museeq->downloadFolder(user, QString(path));
			else
				museeq->downloadFile(user, QString(path), size);
		}
	}
}
开发者ID:anthonylauzon,项目名称:museek-plus,代码行数:27,代码来源:transfers.cpp

示例9: parseCnnString

void ClientPrivate::parseCnnString(const QUrl &con) {
	P_Q(QAMQP::Client);
	if (con.scheme() == AMQPSCHEME || con.scheme() == AMQPSSCHEME) 	{
		q->setSsl(con.scheme() == AMQPSSCHEME);
		q->setPassword(con.password());
		q->setUser(con.userName());
		q->setPort(con.port());
		q->setHost(con.host());				
		q->setVirtualHost(con.path());
	}
}
开发者ID:d---,项目名称:QAMQP,代码行数:11,代码来源:amqp.cpp

示例10: setApplicationProxy

static void setApplicationProxy(QUrl url)
{
	if ( !url.isEmpty() )
	{
		if ( url.port() == -1 )
			url.setPort( 8080 );
		QNetworkProxy proxy( QNetworkProxy::HttpProxy, url.host(), url.port(),
							 url.userName(), url.password() );
		QNetworkProxy::setApplicationProxy(proxy);
	}
}
开发者ID:c3c,项目名称:quazaa,代码行数:11,代码来源:main.cpp

示例11: authenticationRequired

void QNetworkAccessManagerPrivate::authenticationRequired(QNetworkAccessBackend *backend,
                                                          QAuthenticator *authenticator)
{
    Q_Q(QNetworkAccessManager);

    // FIXME: Add support for domains (i.e., the leading path)
    QUrl url = backend->reply->url;

    // don't try the cache for the same URL twice in a row
    // being called twice for the same URL means the authentication failed
    // also called when last URL is empty, e.g. on first call
    if (backend->reply->urlForLastAuthentication.isEmpty()
            || url != backend->reply->urlForLastAuthentication) {
        // if credentials are included in the url, then use them
        if (!url.userName().isEmpty()
            && !url.password().isEmpty()) {
            authenticator->setUser(url.userName());
            authenticator->setPassword(url.password());
            backend->reply->urlForLastAuthentication = url;
            authenticationManager->cacheCredentials(url, authenticator);
            return;
        }

        QNetworkAuthenticationCredential cred = authenticationManager->fetchCachedCredentials(url, authenticator);
        if (!cred.isNull()) {
            authenticator->setUser(cred.user);
            authenticator->setPassword(cred.password);
            backend->reply->urlForLastAuthentication = url;
            return;
        }
    }

    // if we emit a signal here in synchronous mode, the user might spin
    // an event loop, which might recurse and lead to problems
    if (backend->isSynchronous())
        return;

    backend->reply->urlForLastAuthentication = url;
    emit q->authenticationRequired(backend->reply->q_func(), authenticator);
    authenticationManager->cacheCredentials(url, authenticator);
}
开发者ID:AlekSi,项目名称:phantomjs,代码行数:41,代码来源:qnetworkaccessmanager.cpp

示例12: download

void FileDownloader::download(QUrl url) {
	QHttp::ConnectionMode mode = url.scheme().toLower() == "https" ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp;
	http->setHost(url.host(), mode, url.port() == -1 ? 0 : url.port());
    
	if (!url.userName().isEmpty())
		http->setUser(url.userName(), url.password());

	http_request_aborted = false;
	http_get_id = http->get(url.path(), &buffer);

	setLabelText(tr("Downloading %1").arg(url.toString()));
}
开发者ID:autoscatto,项目名称:retroshare,代码行数:12,代码来源:filedownloader.cpp

示例13: setUrl

    void setUrl(const QUrl &url)
    {
        QString hdr;
        hdr = QString("GET %PATH% HTTP/1.1\r\n"
                      "Host: %HOST%\r\n"
                      "User-Agent: MythMusic/%VERSION%\r\n"
                      "Accept: */*\r\n");

        QString path = url.path();
        QString host = url.host();

        if (path.isEmpty())
            path = "/";

        if (url.hasQuery())
            path += '?' + url.encodedQuery();

        if (url.port() != -1)
            host += QString(":%1").arg(url.port());

        hdr.replace("%PATH%", path);
        hdr.replace("%HOST%", host);
        hdr.replace("%VERSION%", MYTH_BINARY_VERSION);

        if (!url.userName().isEmpty() && !url.password().isEmpty()) 
        {
            QString authstring = url.userName() + ":" + url.password();
            QString auth = QCodecs::base64Encode(authstring.toLocal8Bit());

            hdr += "Authorization: Basic " + auth + "\r\n";
        }

        hdr += QString("TE: trailers\r\n"
                       "Icy-Metadata: 1\r\n"
                       "\r\n");

        LOG(VB_NETWORK, LOG_INFO, QString("ShoutCastRequest: '%1'").arg(hdr));

        m_data = hdr.toAscii();
    }
开发者ID:KungFuJesus,项目名称:mythtv,代码行数:40,代码来源:shoutcast.cpp

示例14: setSystemProxy

void Config::setSystemProxy(bool checked)
{
    ui.proxyPort->setEnabled(!checked);
    ui.proxyHost->setEnabled(!checked);
    ui.proxyUser->setEnabled(!checked);
    ui.proxyPass->setEnabled(!checked);
    if(checked) {
        // save values in input box
        proxy.setScheme("http");
        proxy.setUserName(ui.proxyUser->text());
        proxy.setPassword(ui.proxyPass->text());
        proxy.setHost(ui.proxyHost->text());
        proxy.setPort(ui.proxyPort->text().toInt());
        // show system values in input box
        QUrl envproxy = System::systemProxy();
        qDebug() << "[Config] setting system proxy" << envproxy;

        ui.proxyHost->setText(envproxy.host());
        ui.proxyPort->setText(QString("%1").arg(envproxy.port()));
        ui.proxyUser->setText(envproxy.userName());
        ui.proxyPass->setText(envproxy.password());

        if(envproxy.host().isEmpty() || envproxy.port() == -1) {
            qDebug() << "[Config] sytem proxy is invalid.";
            QMessageBox::warning(this, tr("Proxy Detection"),
                    tr("The System Proxy settings are invalid!\n"
                        "Rockbox Utility can't work with this proxy settings. "
                        "Make sure the system proxy is set correctly. Note that "
                        "\"proxy auto-config (PAC)\" scripts are not supported by "
                        "Rockbox Utility. If your system uses this you need "
                        "to use manual proxy settings."),
                    QMessageBox::Ok ,QMessageBox::Ok);
            // the current proxy settings are invalid. Check the saved proxy
            // type again.
            if(RbSettings::value(RbSettings::ProxyType).toString() == "manual")
                ui.radioManualProxy->setChecked(true);
            else
                ui.radioNoProxy->setChecked(true);
        }

    }
    else {
        ui.proxyHost->setText(proxy.host());
        if(proxy.port() > 0)
            ui.proxyPort->setText(QString("%1").arg(proxy.port()));
        else ui.proxyPort->setText("");
        ui.proxyUser->setText(proxy.userName());
        ui.proxyPass->setText(proxy.password());
    }

}
开发者ID:,项目名称:,代码行数:51,代码来源:

示例15: setUrl

    void setUrl(const QUrl &url)
    {
        QString hdr;
        hdr = QString("GET %1 HTTP/1.1\r\n"
                      "Host: %2\r\n"
                      "User-Agent: mythmusic/svn\r\n"
                      "Keep-Alive:\r\n"
                      "Connection: TE, Keep-Alive\r\n").arg(url.path()).arg(url.host());

        if (!url.userName().isEmpty() && !url.password().isEmpty()) 
        {
            QString authstring = url.userName() + ":" + url.password();
            QString auth = QCodecs::base64Encode(authstring.toLocal8Bit());

            hdr += "Authorization: Basic " + auth;
        }

        hdr += QString("TE: trailers\r\n"
                       "icy-metadata:1\r\n"
                       "\r\n");

        m_data = hdr;
    }
开发者ID:lazerdye,项目名称:mythtv,代码行数:23,代码来源:shoutcast.cpp


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