本文整理汇总了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;
}
示例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);
}
示例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;
}
示例4: password
QString QUrlProto::password() const
{
QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
if (item)
return item->password();
return QString();
}
示例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() );
}
示例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;
}
示例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();
}
示例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);
}
}
}
示例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());
}
}
示例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);
}
}
示例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);
}
示例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()));
}
示例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();
}
示例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());
}
}
示例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;
}