本文整理汇总了C++中QUrl::setPassword方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::setPassword方法的具体用法?C++ QUrl::setPassword怎么用?C++ QUrl::setPassword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::setPassword方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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();
}
示例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);
}
示例4: saveSettingsEx
void CAlgorithmSettingsModel::saveSettingsEx(int row, QUrl filename) {
QJsonObject data;
CQJsonTreeItem* parentItem = mRootItem->getChilds()->value(row);
CQJsonTreeItem* tempItem;
int size = parentItem->getChilds()->size();
for(int i = 0; i < size; i++)
{
tempItem= parentItem->getChilds()->value(i);
QJsonObject o = tempItem->toJson();
QString key = o.keys().at(0);
data.insert(key, o.take(key));
}
if (filename.isEmpty() == true) {
filename.setPassword("a" + workflow->getStep(row)->Name());
}
if (workflow->getStep(row)->ValidateParameters(&data)) {
emit saveQJsonEx(data, filename);
workflow->getStep(row)->getAlgorithm()->setParameters(data);
}
else{
QString pluginM = workflow->getStep(row)->Name();
pluginM.append(" parameter not Valid!");
CLogController::instance().frameworkMessage(pluginM);
}
}
示例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();
}
示例6: 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;
}
示例7: setPassword
int Url::setPassword ( lua_State * L )// ( const QString & password )
{
QUrl* lhs = ValueInstaller2<QUrl>::check( L, 1 );
//QString* password = ValueInstaller2<QString>::check( L, 2 );
lhs->setPassword( Util::toString( L, 2 ) );
return 0;
}
示例8: 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);
}
}
示例9: 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;
}
示例10: 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));
}
}
示例11: 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;
}
示例12: TestFailUriInvalid
void TsDataRetrieverFTP::TestFailUriInvalid()
{
try
{
QUrl url;
url.setHost("ftp.dgi.inpe.br");
url.setPath("/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;
MockCurlWrapper mock_;
ON_CALL(mock_, verifyURL(_)).WillByDefault(Return(CURLE_COULDNT_RESOLVE_HOST));
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;
}
示例13: 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;
}
示例14: operations
/*!
Returns a new QNetworkReply object to handle the operation \a op
and request \a req. The device \a outgoingData is always 0 for Get and
Head requests, but is the value passed to post() and put() in
those operations (the QByteArray variants will pass a QBuffer
object).
The default implementation calls QNetworkCookieJar::cookiesForUrl()
on the cookie jar set with setCookieJar() to obtain the cookies to
be sent to the remote server.
The returned object must be in an open state.
*/
QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Operation op,
const QNetworkRequest &req,
QIODevice *outgoingData)
{
Q_D(QNetworkAccessManager);
QNetworkRequest request = req;
if (!request.header(QNetworkRequest::ContentLengthHeader).isValid() &&
outgoingData && !outgoingData->isSequential()) {
// request has no Content-Length
// but the data that is outgoing is random-access
request.setHeader(QNetworkRequest::ContentLengthHeader, outgoingData->size());
}
if (d->cookieJar) {
QList<QNetworkCookie> cookies = d->cookieJar->cookiesForUrl(request.url());
if (!cookies.isEmpty())
request.setHeader(QNetworkRequest::CookieHeader, qVariantFromValue(cookies));
}
// first step: create the reply
QUrl url = request.url();
QNetworkReplyImpl *reply = new QNetworkReplyImpl(this);
QNetworkReplyImplPrivate *priv = reply->d_func();
priv->manager = this;
// second step: fetch cached credentials
QNetworkAuthenticationCredential *cred = d->fetchCachedCredentials(url);
if (cred) {
url.setUserName(cred->user);
url.setPassword(cred->password);
priv->urlForLastAuthentication = url;
}
// third step: setup the reply
priv->setup(op, request, outgoingData);
if (request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt() !=
QNetworkRequest::AlwaysNetwork)
priv->setNetworkCache(d->networkCache);
#ifndef QT_NO_NETWORKPROXY
QList<QNetworkProxy> proxyList = d->queryProxy(QNetworkProxyQuery(request.url()));
priv->proxyList = proxyList;
#endif
// fourth step: find a backend
priv->backend = d->findBackend(op, request);
if (priv->backend) {
priv->backend->setParent(reply);
priv->backend->reply = priv;
}
#ifndef QT_NO_OPENSSL
reply->setSslConfiguration(request.sslConfiguration());
#endif
return reply;
}
示例15: algorithmChanged
void CAlgorithmSettingsModel::algorithmChanged(int step) {
QJsonObject object = workflow->getStep(step)->GetParameterJson();
loadQJson(object);
mRootItem->getChilds()->swap(step, mRootItem->getChilds()->size() - 1);
mRootItem->getChilds()->removeLast();
insertName(step);
workflow->getStep(step)->getAlgorithm()->setParameters(object);
QUrl url;
url.setPassword("a" + object.keys().value(0));
emit saveQJson(object, url);
}