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


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

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


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

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

示例2: TestFailLoginInvalid

void TsDataRetrieverFTP::TestFailLoginInvalid()
{
  try
  {
    QUrl url;
    url.setHost("ftp.dgi.inpe.br");
    url.setPath("/focos_operacao/");
    url.setScheme("FTP");
    url.setPort(21);
    url.setUserName("queimadas");
    url.setUserName("2012");

    curl_global_init(CURL_GLOBAL_ALL);

    //DataProvider information
    terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider();
    terrama2::core::DataProviderPtr dataProviderPtr(dataProvider);
    dataProvider->uri = url.url().toStdString();
    dataProvider->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT;
    dataProvider->dataProviderType = "FTP";
    dataProvider->active = true;

    //empty filter
    terrama2::core::Filter filter;

    MockCurlWrapper mock_;

    ON_CALL(mock_, verifyURL(_)).WillByDefault(Return(CURLE_LOGIN_DENIED));

    try
    {
      terrama2::core::DataRetrieverFTP retrieverFTP(dataProviderPtr,  std::move(mock_));

      QFAIL("Exception expected!");
    }
    catch(const terrama2::core::DataRetrieverException& e)
    {

    }

    curl_global_cleanup();

  }
  catch(const terrama2::Exception& e)
  {
    QFAIL(boost::get_error_info< terrama2::ErrorDescription >(e)->toStdString().c_str());
  }

  catch(...)
  {
    QFAIL("Unexpected exception!");
  }

  return;

}
开发者ID:raphaelrpl,项目名称:terrama2,代码行数:56,代码来源:TsDataRetrieverFTP.cpp

示例3: encode

Song & MagnatuneService::fixPath(Song &s) const
{
    s.type=Song::OnlineSvrTrack;
    if (MB_None!=membership) {
        QUrl url;
        #if QT_VERSION < 0x050000
        url.setEncodedUrl(s.file.toLocal8Bit());
        #else
        url=QUrl(s.file);
        #endif
        url.setScheme("http");
        url.setHost(MB_Streaming==membership ? constStreamingHostname : constDownloadHostname);
        url.setUserName(username);
        url.setPassword(password);

        // And remove the commercial
        QString path = url.path();
        path.insert(path.lastIndexOf('.'), "_nospeech");
        url.setPath(path);
        s.file=url.toString();
    // TODO: Magnatune downloads!
    //    if (MB_Download==membership) {
    //        s.genre=downloadTypeStr(download);
    //    }
    }
    s.setIsFromOnlineService(name());
    return encode(s);
}
开发者ID:edhelas,项目名称:cantata,代码行数:28,代码来源:magnatuneservice.cpp

示例4: getCurrentUrl

void MumbleDBus::getCurrentUrl(const QDBusMessage &msg) {
	if (!g.sh || !g.sh->isRunning() || ! g.uiSession) {
		QDBusConnection::sessionBus().send(msg.createErrorReply(QLatin1String("net.sourceforge.mumble.Error.connection"), QLatin1String("Not connected")));
		return;
	}
	QString host, user, pw;
	unsigned short port;
	QUrl u;

	g.sh->getConnectionInfo(host, port, user, pw);
	u.setScheme(QLatin1String("mumble"));
	u.setHost(host);
	u.setPort(port);
	u.setUserName(user);

#if QT_VERSION >= 0x050000
	QUrlQuery query;
	query.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0"));
	u.setQuery(query);
#else
	u.addQueryItem(QLatin1String("version"), QLatin1String("1.2.0"));
#endif

	QStringList path;
	Channel *c = ClientUser::get(g.uiSession)->cChannel;
	while (c->cParent) {
		path.prepend(c->qsName);
		c = c->cParent;
	}
	u.setPath(path.join(QLatin1String("/")));
	QDBusConnection::sessionBus().send(msg.createReply(QString::fromLatin1(u.toEncoded())));
}
开发者ID:Abextm,项目名称:mumble,代码行数:32,代码来源:DBus.cpp

示例5: DownloadFinished

void MagnatuneDownloadDialog::DownloadFinished() {
  QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
  reply->deleteLater();

  // Close any open file
  download_file_.reset();

  QUrl redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
  if (redirect.isValid()) {
    // Open the output file
    QString output_filename = GetOutputFilename();
    download_file_.reset(new QFile(output_filename));
    if (!download_file_->open(QIODevice::WriteOnly)) {
      ShowError(tr("Couldn't open output file %1").arg(output_filename));
      return;
    }

    // Round and round we go
    redirect.setUserName(service_->username());
    redirect.setPassword(service_->password());

    current_reply_ = network_->get(QNetworkRequest(redirect));

    connect(current_reply_, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(Error(QNetworkReply::NetworkError)));
    connect(current_reply_, SIGNAL(finished()), SLOT(DownloadFinished()));
    connect(current_reply_, SIGNAL(downloadProgress(qint64,qint64)), SLOT(DownloadProgress(qint64,qint64)));
    connect(current_reply_, SIGNAL(readyRead()), SLOT(DownloadReadyRead()));
    return;
  }

  next_row_ ++;
  DownloadNext();
}
开发者ID:ximion,项目名称:Clementine-LibDanceTag,代码行数:33,代码来源:magnatunedownloaddialog.cpp

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

示例7: getApiUrl

static QUrl getApiUrl(BtsApi_private *p, const QString &method, const QueryList &querylist = QueryList())
{
	assertClient(p);

	QUrl res;

	res.setScheme("http");

	res.setHost(p->client->getHost());
	res.setPort(p->client->getPort());

	if(!p->client->getUserName().isEmpty())
		res.setUserName(p->client->getUserName());

	if(!p->client->getPassword().isEmpty())
		res.setPassword(p->client->getPassword());

	res.setPath("/api");

	QUrlQuery urlQuery;
	urlQuery.addQueryItem("method", method);

	for(const QueryPair &qp: querylist)
	{
		if(qp.second.isNull())
			urlQuery.addQueryItem(qp.first, "");
		else
			urlQuery.addQueryItem(qp.first, qp.second);
	}

	res.setQuery(urlQuery);

	return res;
}
开发者ID:BtbN,项目名称:btsync-qt,代码行数:34,代码来源:bts_api.cpp

示例8: setUserName

int Url::setUserName ( lua_State * L )// ( const QString & userName )
{
	QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
	//QString* userName = ValueInstaller2<QString>::check( L, 2 );
	lhs->setUserName( Util::toString( L, 2 ) );
	return 0;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlUrl.cpp

示例9: getUpdateUrl

QString DNSUpdater::getUpdateUrl() const
{
    QUrl url;
#ifdef QT_NO_OPENSSL
    url.setScheme("http");
#else
    url.setScheme("https");
#endif
    url.setUserName(m_username);
    url.setPassword(m_password);

    Q_ASSERT(!m_lastIP.isNull());
    // Service specific
    switch (m_service) {
    case DNS::DYNDNS:
        url.setHost("members.dyndns.org");
        break;
    case DNS::NOIP:
        url.setHost("dynupdate.no-ip.com");
        break;
    default:
        qWarning() << "Unrecognized Dynamic DNS service!";
        Q_ASSERT(0);
    }
    url.setPath("/nic/update");

    QUrlQuery urlQuery(url);
    urlQuery.addQueryItem("hostname", m_domain);
    urlQuery.addQueryItem("myip", m_lastIP.toString());
    url.setQuery(urlQuery);
    Q_ASSERT(url.isValid());

    qDebug() << Q_FUNC_INFO << url.toString();
    return url.toString();
}
开发者ID:elFarto,项目名称:qBittorrent,代码行数:35,代码来源:dnsupdater.cpp

示例10: fetch

void DataFetcher::fetch(QString urlString, QString username, QString password)
{
    QUrl url = QUrl::fromUserInput(urlString + "/api/xml?depth=2");
    m_errorMessage = "fetching " + url.toString() + "\n";
    url.setUserName(username);
    url.setPassword(password);

    if (!url.isValid()) {
        emit finished(true, "invalid URL");
        return;
    }

    if (url.scheme() == "file") {
        QString filename = url.toLocalFile();
        QFile file(filename);
        if (file.open(QFile::ReadOnly)) {
            parseXml(QXmlStreamReader(file.readAll()));
        } else {
            emit finished(true, "Unable to read the file: " + filename);
        }
        file.close();
        return;
    }

    QNetworkRequest request(url);
    request.setRawHeader("User-Agent", QString("Qt-Creator/%1 (QHttp %2; %3; %4; %5 bit)")
                         .arg(Core::Constants::IDE_VERSION_LONG).arg(qVersion())
                         .arg(getOsString()).arg(QLocale::system().name())
                         .arg(QSysInfo::WordSize).toLocal8Bit());
    request.setRawHeader("Accept", "text/xml,application/xml; charset=UTF-8");
    request.setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg(username).arg(password).toAscii()).toBase64());
    mNetworkAccess.proxyFactory()->setUseSystemConfiguration(true);
    mNetworkAccess.get( request );
}
开发者ID:maxblagay,项目名称:QtCreator-Jenkins-Plugin,代码行数:34,代码来源:datafetcher.cpp

示例11: TestMakeParser

void TsFactory::TestMakeParser()
{
  try
  {
    //test postgis uri
    QUrl postgisUri;
    postgisUri.setScheme("postgis");
    postgisUri.setHost("localhost");
    postgisUri.setPort(5432);
    postgisUri.setUserName("postgres");
    postgisUri.setPassword("postgres");
    postgisUri.setPath("/basedeteste");

    terrama2::core::DataSetItem unknownTypeItem(terrama2::core::DataSetItem::UNKNOWN_TYPE);

    //FIXME: create a DataSetItem kind for ParserPostgis
//    terrama2::collector::ParserPtr parser = terrama2::collector::Factory::makeParser(unknownTypeItem);
//    terrama2::collector::ParserPostgis* parserPostgis = dynamic_cast<terrama2::collector::ParserPostgis*>(parser.get());
//    QVERIFY(parserPostgis);

    QUrl fileUri;
    fileUri.setScheme("file");
    fileUri.setPath("/tmp");

    terrama2::collector::ParserPtr parser = terrama2::collector::Factory::makeParser(unknownTypeItem);
    terrama2::collector::ParserOGR* parserOGR = dynamic_cast<terrama2::collector::ParserOGR*>(parser.get());
    QVERIFY(parserOGR);

    terrama2::core::DataSetItem pcdInpeTypeItem(terrama2::core::DataSetItem::PCD_INPE_TYPE);
    parser = terrama2::collector::Factory::makeParser(pcdInpeTypeItem);
    terrama2::collector::ParserPcdInpe* parserPdcInpe = dynamic_cast<terrama2::collector::ParserPcdInpe*>(parser.get());
    QVERIFY(parserPdcInpe);

    terrama2::core::DataSetItem pcdToaTypeItem(terrama2::core::DataSetItem::PCD_TOA5_TYPE);
    parser = terrama2::collector::Factory::makeParser(pcdToaTypeItem);
    terrama2::collector::ParserPcdToa5* parserPdctoa5 = dynamic_cast<terrama2::collector::ParserPcdToa5*>(parser.get());
    QVERIFY(parserPdctoa5);

    terrama2::core::DataSetItem firePointTypeItem(terrama2::core::DataSetItem::FIRE_POINTS_TYPE);
    parser = terrama2::collector::Factory::makeParser(firePointTypeItem);
    terrama2::collector::ParserFirePoint* parserFirePoint = dynamic_cast<terrama2::collector::ParserFirePoint*>(parser.get());
    QVERIFY(parserFirePoint);

    try
    {
      terrama2::core::DataSetItem diseaseTypeItem(terrama2::core::DataSetItem::DISEASE_OCCURRENCE_TYPE);
      parser = terrama2::collector::Factory::makeParser(diseaseTypeItem);

      QFAIL(NO_EXCEPTION_THROWN);
    }
    catch(terrama2::collector::ConflictingParserTypeSchemeException& e)
    {

    }
  }
  catch(...)
  {
    QFAIL(NO_EXCEPTION_EXPECTED);
  }
}
开发者ID:edelatin,项目名称:terrama2,代码行数:60,代码来源:TsFactory.cpp

示例12: TestOKDownloadFile

void TsDataRetrieverFTP::TestOKDownloadFile()
{
  try
  {
    QUrl url;
    url.setHost("ftp.dgi.inpe.br");
    url.setPath("/focos_operacao/");
    url.setScheme("FTP");
    url.setPort(21);
    url.setUserName("queimadas");
    url.setPassword("inpe_2012");

    curl_global_init(CURL_GLOBAL_ALL);

    //DataProvider information
    terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider();
    terrama2::core::DataProviderPtr dataProviderPtr(dataProvider);
    dataProvider->uri = url.url().toStdString();
    dataProvider->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT;
    dataProvider->dataProviderType = "FTP";
    dataProvider->active = true;

    //empty filter
    terrama2::core::Filter filter;
    std::string path;
    std::string mask = "exporta_20160501_0230.csv";

    MockCurlWrapper mock_;

    ON_CALL(mock_, verifyURL(_)).WillByDefault(Return(CURLE_OK));
    ON_CALL(mock_, getDownloadFiles(_,_,_)).WillByDefault(Return(CURLE_OK));

    try
    {
      terrama2::core::DataRetrieverFTP retrieverFTP(dataProviderPtr, std::move(mock_));
      auto remover = std::make_shared<terrama2::core::FileRemover>();
      path = retrieverFTP.retrieveData(mask, filter, remover);
    }
    catch(...)
    {
      QFAIL("Unexpected exception!");
    }

    curl_global_cleanup();

  }
  catch(const terrama2::Exception& e)
  {
    QFAIL(boost::get_error_info< terrama2::ErrorDescription >(e)->toStdString().c_str());
  }

  catch(...)
  {
    QFAIL("Unexpected exception!");
  }

  return;

}
开发者ID:raphaelrpl,项目名称:terrama2,代码行数:59,代码来源:TsDataRetrieverFTP.cpp

示例13: MetadataFinished

void MagnatuneDownloadDialog::MetadataFinished() {
  QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
  reply->deleteLater();

  // The reply isn't valid XML so we can't use QtXML to parse it :(
  QString data = QString::fromUtf8(reply->readAll());

  // Check for errors
  if (data.contains("<ERROR>")) {
    ShowError(tr("There was a problem fetching the metadata from Magnatune"));
    return;
  }

  // Work out what format we want
  QString type;
  switch (ui_->format->currentIndex()) {
    case MagnatuneService::Format_Ogg:     type = "URL_OGGZIP";    break;
    case MagnatuneService::Format_Flac:    type = "URL_FLACZIP";   break;
    case MagnatuneService::Format_Wav:     type = "URL_WAVZIP";    break;
    case MagnatuneService::Format_MP3_VBR: type = "URL_VBRZIP";    break;
    case MagnatuneService::Format_MP3_128: type = "URL_128KMP3ZIP"; break;
  }

  // Parse the XML (lol) to find the URL
  QRegExp re(QString("<%1>([^<]+)</%2>").arg(type, type));
  if (re.indexIn(data) == -1) {
    ShowError(tr("This album is not available in the requested format"));
    return;
  }

  // Munge the URL a bit
  QString url_text = Utilities::DecodeHtmlEntities(re.cap(1));

  QUrl url = QUrl(url_text);
  url.setUserName(service_->username());
  url.setPassword(service_->password());

  qLog(Debug) << "Downloading" << url;

  // Start the actual download
  current_reply_ = network_->get(QNetworkRequest(url));

  connect(current_reply_, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(Error(QNetworkReply::NetworkError)));
  connect(current_reply_, SIGNAL(finished()), SLOT(DownloadFinished()));
  connect(current_reply_, SIGNAL(downloadProgress(qint64,qint64)), SLOT(DownloadProgress(qint64,qint64)));
  connect(current_reply_, SIGNAL(readyRead()), SLOT(DownloadReadyRead()));

  // Close any open file
  download_file_.reset();

  // Open the output file
  QString output_filename = GetOutputFilename();
  download_file_.reset(new QFile(output_filename));
  if (!download_file_->open(QIODevice::WriteOnly)) {
    ShowError(tr("Couldn't open output file %1").arg(output_filename));
  }
}
开发者ID:nti1094,项目名称:clementine-subsonic,代码行数:57,代码来源:magnatunedownloaddialog.cpp

示例14: run

//-----------------------------------------------------------------------------
bool CloneDialog::run(QWidget *parent, QUrl &url, QString &repository)
{
	CloneDialog dlg(parent);

	// Try to parse a url from the clipboard
	QClipboard *clipboard = QApplication::clipboard();
	if(clipboard)
	{
		QUrl nurl = QUrl::fromUserInput(clipboard->text());

		// If we have a valid url
		if(nurl.isValid() && !nurl.isEmpty())
		{
			// Fill in dialog
			dlg.ui->lineUserName->setText(nurl.userName());
			dlg.ui->linePassword->setText(nurl.password());
			nurl.setUserName("");
			nurl.setPassword("");
			dlg.ui->lineURL->setText(nurl.toString());
		}
	}

	if(dlg.exec() != QDialog::Accepted)
		return false;

	url.setUrl(dlg.ui->lineURL->text());
	if(url.isEmpty() || !url.isValid())
	{
		QMessageBox::critical(parent, tr("Error"), tr("Invalid URL."), QMessageBox::Ok );
		return false;
	}

	url.setUserName(dlg.ui->lineUserName->text());
	url.setPassword(dlg.ui->linePassword->text());

	if(dlg.ui->lineRepository->text().isEmpty() )
	{
		QMessageBox::critical(parent, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok );
		return false;
	}

	repository = dlg.ui->lineRepository->text();
	return true;
}
开发者ID:ilchenkoanna,项目名称:VCS,代码行数:45,代码来源:CloneDialog.cpp

示例15: acc

/*!
  Returns the URL of the WAP gateway (including port, login and password).

  \code
    QWapAccount acc(...)
    ...
    QUrl gateway = acc.gateway();
    QString password = gateway.password();
    QString username = gateway.userName();
  \endcode

  \sa setGateway(), QUrl
*/
QUrl QWapAccount::gateway() const
{
    QUrl url;
    url.setHost( d->conf->value( QLatin1String("Wap/Gateway") ).toString());
    url.setUserName( d->conf->value( QLatin1String("Wap/UserName") ).toString() );
    url.setPassword( d->conf->value( QLatin1String("Wap/Password") ).toString() );
    url.setPort( d->conf->value( QLatin1String("Wap/Port")).toInt() );

    return url;
}
开发者ID:Camelek,项目名称:qtmoko,代码行数:23,代码来源:qwapaccount.cpp


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