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


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

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


在下文中一共展示了QUrl::userName方法的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: 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

示例3: 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

示例4: 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

示例5: userName

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

示例6: 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

示例7: cacheCredentials

void QNetworkAccessAuthenticationManager::cacheCredentials(const QUrl &url,
                                                  const QAuthenticator *authenticator)
{
    Q_ASSERT(authenticator);
    QString domain = QString::fromLatin1("/"); // FIXME: make QAuthenticator return the domain
    QString realm = authenticator->realm();

    QMutexLocker mutexLocker(&mutex);

    // Set two credentials actually: one with and one without the username in the URL
    QUrl copy = url;
    copy.setUserName(authenticator->user());
    do {
        QByteArray cacheKey = authenticationKey(copy, realm);
        if (authenticationCache.hasEntry(cacheKey)) {
            QNetworkAuthenticationCache *auth =
                static_cast<QNetworkAuthenticationCache *>(authenticationCache.requestEntryNow(cacheKey));
            auth->insert(domain, authenticator->user(), authenticator->password());
            authenticationCache.releaseEntry(cacheKey);
        } else {
            QNetworkAuthenticationCache *auth = new QNetworkAuthenticationCache;
            auth->insert(domain, authenticator->user(), authenticator->password());
            authenticationCache.addEntry(cacheKey, auth);
        }

        if (copy.userName().isEmpty()) {
            break;
        } else {
            copy.setUserName(QString());
        }
    } while (true);
}
开发者ID:ghjinlei,项目名称:qt5,代码行数:32,代码来源:qnetworkaccessauthenticationmanager.cpp

示例8: openUrl

void DrawpileApp::openUrl(QUrl url)
{
    // See if there is an existing replacable window
    MainWindow *win = nullptr;
    for(QWidget *widget : topLevelWidgets()) {
        MainWindow *mw = qobject_cast<MainWindow*>(widget);
        if(mw && mw->canReplace()) {
            win = mw;
            break;
        }
    }

    // No? Create a new one
    if(!win)
        win = new MainWindow;

    if(url.scheme() == "drawpile") {
        // Our own protocol: connect to a session

        if(url.userName().isEmpty()) {
            // Set username if not specified
            QSettings cfg;
            url.setUserName(cfg.value("history/username").toString());
        }
        win->joinSession(url);

    } else {
        // Other protocols: load image
        win->openUrl(url);
    }
}
开发者ID:ideallx,项目名称:Drawpile,代码行数:31,代码来源:main.cpp

示例9: 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

示例10: 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

示例11: 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:pippijn,项目名称:lina-irc,代码行数:10,代码来源:main.cpp

示例12: 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

示例13: 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

示例14: getKey

QString SFtpConnectionCache::getKey(const QUrl &url) const
{
    QString key;

    key.append(url.userName());
    key.append("@");
    key.append(url.host());
    key.append(":");
    key.append(QString::number(url.port()));

    return key;
}
开发者ID:komh,项目名称:kfw,代码行数:12,代码来源:sftpconnectioncache.cpp

示例15: 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


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