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 ); }
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(); }
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); }
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); } }
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(); }
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; }
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; }
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); } }
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; }
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)); } }
//----------------------------------------------------------------------------- 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; }
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; }
/*! 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; }
/*! 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; }
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); }
QUrl ServicesDbTestUtils::getDbModifyUrl() { // read the DB values from the DB config file. Settings s = _readDbConfig(); QUrl result; result.setScheme("hootapidb"); result.setHost(s.get("DB_HOST").toString()); result.setPort(s.get("DB_PORT").toInt()); result.setUserName(s.get("DB_USER").toString()); result.setPassword(s.get("DB_PASSWORD").toString()); result.setPath("/" + s.get("DB_NAME").toString() + "/testMap"); return result; }
void MagnatuneDownloadDialog::Error(QNetworkReply::NetworkError e) { QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender()); reply->deleteLater(); QUrl url = reply->url(); url.setPassword(QString()); QMetaEnum error_enum = QNetworkReply::staticMetaObject.enumerator( QNetworkReply::staticMetaObject.indexOfEnumerator("NetworkError")); QString message = tr("Unable to download %1 (%2)") .arg(url.toString()).arg(error_enum.valueToKey(e)); ShowError(message); }
QVariantHash ChooseSamba::values() const { QVariantHash ret = m_args; QString address = ui->addressLE->text().trimmed(); QUrl url; if (address.startsWith(QLatin1String("//"))) { url = QUrl(QLatin1String("smb:") % address); } else if (address.startsWith(QLatin1String("/"))) { url = QUrl(QLatin1String("smb:/") % address); } else if (address.startsWith(QLatin1String("://"))) { url = QUrl(QLatin1String("smb") % address); } else if (address.startsWith(QLatin1String("smb://"))) { url = QUrl(address); } else if (!QUrl::fromUserInput(address).scheme().isEmpty() && QUrl::fromUserInput(address).scheme() != QStringLiteral("smb")) { url = QUrl::fromUserInput(address); url.setScheme(QStringLiteral("smb")); } else { url = QUrl(QStringLiteral("smb://") % address); } qDebug() << 1 << url; if (!ui->usernameLE->text().isEmpty()) { url.setUserName(ui->usernameLE->text()); } if (!ui->passwordLE->text().isEmpty()) { url.setPassword(ui->passwordLE->text()); } qDebug() << 2 << url; qDebug() << 3 << url.url() << url.path().section(QLatin1Char('/'), -1, -1);// same as url.fileName() qDebug() << 4 << url.fileName(); qDebug() << 5 << url.host() << url.url().section(QLatin1Char('/'), 3, 3).toLower(); ret[KCUPS_DEVICE_URI] = url.url(); ret[KCUPS_DEVICE_INFO] = url.fileName(); // if there is 4 '/' means the url is like // smb://group/host/printer, so the location is at a different place if (url.url().count(QLatin1Char('/') == 4)) { ret[KCUPS_DEVICE_LOCATION] = url.url().section(QLatin1Char('/'), 3, 3).toLower(); } else { ret[KCUPS_DEVICE_LOCATION] = url.host(); } return ret; }
/*! Given a URL, generates a unique enough filename (and subdirectory) */ QString QNetworkDiskCachePrivate::uniqueFileName(const QUrl &url) { QUrl cleanUrl = url; cleanUrl.setPassword(QString()); cleanUrl.setFragment(QString()); QCryptographicHash hash(QCryptographicHash::Sha1); hash.addData(cleanUrl.toEncoded()); // convert sha1 to base36 form and return first 8 bytes for use as string QByteArray id = QByteArray::number(*(qlonglong*)hash.result().data(), 36).left(8); // generates <one-char subdir>/<8-char filname.d> uint code = (uint)id.at(id.length()-1) % 16; QString pathFragment = QString::number(code, 16) + QLatin1Char('/') + QLatin1String(id) + CACHE_POSTFIX; return pathFragment; }
void addOutput(std::shared_ptr<terrama2::services::collector::core::DataManager> dataManager) { /////////////////////////////////////////////// // output QUrl uri; uri.setScheme("postgis"); uri.setHost(QString::fromStdString(TERRAMA2_DATABASE_HOST)); uri.setPort(std::stoi(TERRAMA2_DATABASE_PORT)); uri.setUserName(QString::fromStdString(TERRAMA2_DATABASE_USERNAME)); uri.setPassword(QString::fromStdString(TERRAMA2_DATABASE_PASSWORD)); uri.setPath(QString::fromStdString("/"+TERRAMA2_DATABASE_DBNAME)); // DataProvider information terrama2::core::DataProvider* outputDataProvider = new terrama2::core::DataProvider(); terrama2::core::DataProviderPtr outputDataProviderPtr(outputDataProvider); outputDataProvider->id = 2; outputDataProvider->name = "DataProvider queimadas postgis"; outputDataProvider->uri = uri.url().toStdString(); outputDataProvider->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT; outputDataProvider->dataProviderType = "POSTGIS"; outputDataProvider->active = true; dataManager->add(outputDataProviderPtr); // DataSeries information terrama2::core::DataSeries* outputDataSeries = new terrama2::core::DataSeries(); terrama2::core::DataSeriesPtr outputDataSeriesPtr(outputDataSeries); outputDataSeries->id = 2; outputDataSeries->name = "DataProvider queimadas postgis"; auto& semanticsManager = terrama2::core::SemanticsManager::getInstance(); outputDataSeries->semantics = semanticsManager.getSemantics("OCCURRENCE-postgis"); outputDataSeries->dataProviderId = outputDataProviderPtr->id; dataManager->add(outputDataSeriesPtr); // DataSet information terrama2::core::DataSetOccurrence* outputDataSet = new terrama2::core::DataSetOccurrence(); outputDataSet->active = true; outputDataSet->id = 2; outputDataSet->dataSeriesId = outputDataSeries->id; outputDataSet->format.emplace("table_name", "queimadas_test_table"); outputDataSeries->datasetList.emplace_back(outputDataSet); }
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 = re.cap(1); url_text.replace("&", "&"); QUrl url = QUrl(url_text); url.setUserName(service_->username()); url.setPassword(service_->password()); // 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())); // No DownloadProgress connection because the first one is a redirect }
terrama2::core::DataProviderPtr inputDataProvider() { QUrl uri; uri.setScheme("postgis"); uri.setHost(QString::fromStdString(TERRAMA2_DATABASE_HOST)); uri.setPort(std::stoi(TERRAMA2_DATABASE_PORT)); uri.setUserName(QString::fromStdString(TERRAMA2_DATABASE_USERNAME)); uri.setPassword(QString::fromStdString(TERRAMA2_DATABASE_PASSWORD)); uri.setPath(QString::fromStdString("/"+TERRAMA2_DATABASE_DBNAME)); //DataProvider information terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider(); terrama2::core::DataProviderPtr dataProviderPtr(dataProvider); dataProvider->name = "PostGIS provider"; dataProvider->uri = uri.url().toStdString(); dataProvider->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT; dataProvider->dataProviderType = "POSTGIS"; dataProvider->active = true; dataProvider->id = 1; return dataProviderPtr; }
QUrl SieveEditorUtil::SieveServerConfig::url() const { QUrl u; u.setHost(serverName); u.setUserName(userName); u.setPassword(password); u.setPort(port); QString authStr; switch (authenticationType) { case MailTransport::Transport::EnumAuthenticationType::CLEAR: case MailTransport::Transport::EnumAuthenticationType::PLAIN: authStr = QStringLiteral("PLAIN"); break; case MailTransport::Transport::EnumAuthenticationType::LOGIN: authStr = QStringLiteral("LOGIN"); break; case MailTransport::Transport::EnumAuthenticationType::CRAM_MD5: authStr = QStringLiteral("CRAM-MD5"); break; case MailTransport::Transport::EnumAuthenticationType::DIGEST_MD5: authStr = QStringLiteral("DIGEST-MD5"); break; case MailTransport::Transport::EnumAuthenticationType::GSSAPI: authStr = QStringLiteral("GSSAPI"); break; case MailTransport::Transport::EnumAuthenticationType::ANONYMOUS: authStr = QStringLiteral("ANONYMOUS"); break; default: authStr = QStringLiteral("PLAIN"); break; } QUrlQuery query; query.addQueryItem(QStringLiteral("x-mech"), authStr); u.setQuery(query); return u; }
void MagnatuneDownloadDialog::DownloadNext() { // We have to download an XML file first that gives us the URLs of the actual // zipped album. if (next_row_ >= ui_->albums->topLevelItemCount()) { AllFinished(false); return; } QTreeWidgetItem* item = ui_->albums->topLevelItem(next_row_); QString sku = item->data(0, Qt::UserRole).toString(); item->setData(1, Qt::DisplayRole, tr("Starting...")); QUrl url = QString(MagnatuneService::kDownloadUrl); url.setUserName(service_->username()); url.setPassword(service_->password()); url.addQueryItem("id", MagnatuneService::kPartnerId); url.addQueryItem("sku", sku); current_reply_ = network_->get(QNetworkRequest(url)); connect(current_reply_, SIGNAL(error(QNetworkReply::NetworkError)), SLOT(Error(QNetworkReply::NetworkError))); connect(current_reply_, SIGNAL(finished()), SLOT(MetadataFinished())); }
// adds a url to the list, or increase rank of an existing url, making // sure to bump it up the list if needed void PopularUrls::addUrl(const QUrl& url) { QUrl tmpurl = url; tmpurl.setPassword(QString()); // make sure no passwords are permanently stored if (!tmpurl.path().endsWith('/')) // make a uniform trailing slash policy tmpurl.setPath(tmpurl.path() + '/'); UrlNodeP pnode; decreaseRanks(); if (!head) { // if the list is empty ... (assumes dict to be empty as well) pnode = new UrlNode; pnode->rank = STARTING_RANK; pnode->url = tmpurl; appendNode(pnode); ranks.insert(tmpurl.url(), head); } else { if (ranks.find(tmpurl.url()) == ranks.end()) { // is the added url new? if so, append it pnode = new UrlNode; pnode->rank = STARTING_RANK; pnode->url = tmpurl; appendNode(pnode); ranks.insert(tmpurl.url(), pnode); } else { pnode = ranks[ tmpurl.url()]; pnode->rank += INCREASE; } } // do we need to change location for this one? relocateIfNeeded(pnode); // too many urls? if (count > maxUrls) removeNode(tail); //dumpList(); }
int main(int argc, char* argv[]) { terrama2::core::initializeTerraMA(); { QUrl uri; uri.setScheme("postgis"); uri.setHost(QString::fromStdString(TERRAMA2_DATABASE_HOST)); uri.setPort(std::stoi(TERRAMA2_DATABASE_PORT)); uri.setUserName(QString::fromStdString(TERRAMA2_DATABASE_USERNAME)); uri.setPassword(QString::fromStdString(TERRAMA2_DATABASE_PASSWORD)); uri.setPath(QString::fromStdString("/"+TERRAMA2_DATABASE_DBNAME)); //DataProvider information terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider(); terrama2::core::DataProviderPtr dataProviderPtr(dataProvider); dataProvider->uri = uri.url().toStdString(); dataProvider->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT; dataProvider->dataProviderType = "POSTGIS"; dataProvider->active = true; //DataSeries information terrama2::core::DataSeries* dataSeries = new terrama2::core::DataSeries(); terrama2::core::DataSeriesPtr dataSeriesPtr(dataSeries); auto& semanticsManager = terrama2::core::SemanticsManager::getInstance(); dataSeries->semantics = semanticsManager.getSemantics("OCCURRENCE-postgis"); //DataSet information terrama2::core::DataSetOccurrence* dataSet = new terrama2::core::DataSetOccurrence(); dataSet->active = true; dataSet->format.emplace("table_name", "fires"); dataSet->format.emplace("timestamp_property", "data_pas"); dataSet->format.emplace("geometry_property", "geom"); dataSeries->datasetList.emplace_back(dataSet); //accessing data terrama2::core::DataAccessorOccurrencePostGis accessor(dataProviderPtr, dataSeriesPtr); //empty filter terrama2::core::Filter filter; boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone("+00")); filter.lastValue = true; std::string boundingBoxWkt = "POLYGON((-51.11 -17.74, -41.11 -17.74, -41.11 -20.83, -51.11 -20.83, -51.11 -17.74))"; te::gm::Geometry* geometry = te::gm::WKTReader::read(boundingBoxWkt.c_str()); geometry->setSRID(4326); filter.region = std::shared_ptr<te::gm::Geometry>(geometry); terrama2::core::OccurrenceSeriesPtr occurrenceSeries = accessor.getOccurrenceSeries(filter); assert(occurrenceSeries->occurrencesMap().size() == 1); auto teDataSet = (*occurrenceSeries->occurrencesMap().begin()).second.syncDataSet->dataset(); //Print column names and types (DateTime/Double) int dateColumn = -1; int geomColumn = -1; std::string names, types; for(int i = 0; i < teDataSet->getNumProperties(); ++i) { std::string name = teDataSet->getPropertyName(i); names+= name + "\t"; if(name == "data_pas") { types+= "DataTime\t"; dateColumn = i; } else if(name == "geom") { types+= "Geometry\t"; geomColumn = i; } else types+= "Int\t"; } std::cout << names << std::endl; std::cout << types << std::endl; //Print values teDataSet->moveBeforeFirst(); while(teDataSet->moveNext()) { for(int i = 0; i < teDataSet->getNumProperties(); ++i) { if(teDataSet->isNull(i)) { std::cout << "NULL"; continue; } if(i == dateColumn) { std::shared_ptr<te::dt::DateTime> dateTime = teDataSet->getDateTime(i); std::cout << dateTime->toString(); } else if(i == geomColumn) { std::cout << "<<Geometry>>"; } else { std::cout << teDataSet->getInt32(i); } std::cout << "\t"; } std::cout << std::endl; } std::cout << "\ndataset size: " << teDataSet->size() << std::endl; } terrama2::core::finalizeTerraMA(); return 0; }
int main(int argc, char* argv[]) { terrama2::core::initializeTerraMA(); std::cout << "NOT WORKING" << std::endl; return 1; { QUrl uri; uri.setScheme("postgis"); uri.setHost(QString::fromStdString(TERRAMA2_DATABASE_HOST)); uri.setPort(std::stoi(TERRAMA2_DATABASE_PORT)); uri.setUserName(QString::fromStdString(TERRAMA2_DATABASE_USERNAME)); uri.setPassword(QString::fromStdString(TERRAMA2_DATABASE_PASSWORD)); uri.setPath(QString::fromStdString("/"+TERRAMA2_DATABASE_DBNAME)); //DataProvider information terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider(); terrama2::core::DataProviderPtr dataProviderPtr(dataProvider); dataProvider->uri = uri.url().toStdString(); dataProvider->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT; dataProvider->dataProviderType = "POSTGIS"; dataProvider->active = true; //DataSeries information terrama2::core::DataSeries* dataSeries = new terrama2::core::DataSeries(); terrama2::core::DataSeriesPtr dataSeriesPtr(dataSeries); auto& semanticsManager = terrama2::core::SemanticsManager::getInstance(); dataSeries->semantics = semanticsManager.getSemantics("DCP-postgis"); //DataSet information terrama2::core::DataSetDcp* dataSet = new terrama2::core::DataSetDcp(); dataSet->active = true; dataSet->format.emplace("table_name", "inpe"); dataSet->format.emplace("timestamp_property", "datetime"); dataSeries->datasetList.emplace_back(dataSet); //accessing data terrama2::core::DataAccessorDcpPostGIS accessor(dataProviderPtr, dataSeriesPtr); //empty filter terrama2::core::Filter filter; filter.lastValue = true; terrama2::core::DcpSeriesPtr dcpSeries = accessor.getDcpSeries(filter); std::cout << "\nLast data timestamp: " << accessor.lastDateTime()->toString() << std::endl; assert(dcpSeries->dcpSeriesMap().size() == 1); auto datasetSeries = (*dcpSeries->dcpSeriesMap().begin()).second; std::shared_ptr<te::da::DataSet> teDataSet = datasetSeries.syncDataSet->dataset(); std::string tableName = dataSet->format["table_name"]; // creates a DataSource to the data and filters the dataset, // also joins if the DCP comes from separated files std::shared_ptr<te::da::DataSource> datasource(te::da::DataSourceFactory::make("POSTGIS")); std::map<std::string, std::string> connInfo {{"PG_HOST", uri.host().toStdString()}, {"PG_PORT", std::to_string(uri.port())}, {"PG_USER", uri.userName().toStdString()}, {"PG_PASSWORD", uri.password().toStdString()}, {"PG_DB_NAME", uri.path().section("/", 1, 1).toStdString()}, {"PG_CONNECT_TIMEOUT", "4"}, {"PG_CLIENT_ENCODING", "UTF-8"} }; datasource->setConnectionInfo(connInfo); // RAII for open/closing the datasource terrama2::core::OpenClose<std::shared_ptr<te::da::DataSource>> openClose(datasource); // get a transactor to interact to the data source std::shared_ptr<te::da::DataSourceTransactor> transactor(datasource->getTransactor()); auto primaryKey = datasetSeries.teDataSetType->getPrimaryKey(); assert(primaryKey); assert(!teDataSet->isEmpty()); auto pkName = primaryKey->getName(); std::string sql("DELETE FROM " +tableName+" WHERE "+pkName+" NOT IN ("); auto pos = datasetSeries.teDataSetType->getPropertyPosition(pkName); teDataSet->moveBeforeFirst(); while (teDataSet->moveNext()) { sql+=std::to_string(teDataSet->getInt32(pos))+","; } sql.pop_back(); sql+=")"; transactor->execute(sql); std::cout << "dataset size: " << teDataSet->size() << std::endl; } terrama2::core::finalizeTerraMA(); return 0; }
int main(int argc, char *argv[]) { #ifdef MINEFLAYER_GUI_ON QApplication a(argc, argv); #else QCoreApplication a(argc, argv); #endif // parse arguments bool script_debug = false; bool headless = true; QString script_filename; QStringList script_args; QUrl url = QUrl::fromUserInput("mineflayer@localhost:25565"); QString password; // set up lib path QStringList lib_path; lib_path << QDir::currentPath(); QString env_path = QString::fromAscii(std::getenv("MINEFLAYER_LIB")); if (! env_path.isNull()) { lib_path << env_path.split(":"); } QStringList args = a.arguments(); for (int i = 1; i < args.size(); i++) { QString arg = args.at(i); if (arg == "--debug") { script_debug = true; } else if (arg == "--3d") { headless = false; } else if (arg.startsWith("-I")) { lib_path.append(arg.mid(2)); } else if (arg == "--url") { if (i+1 >= args.size()) { qWarning() << "Need url parameter after --url option."; printUsage(args.at(0)); return -1; } QUrl new_url = QUrl::fromUserInput(args.at(++i)); if (new_url.userName().isEmpty()) new_url.setUserName(url.userName()); if (new_url.host().isEmpty()) new_url.setHost(url.host()); new_url.setPort(new_url.port(url.port())); if (! new_url.password().isEmpty()) password = new_url.password(); url = new_url; } else if (arg == "--password") { if (i+1 >= args.size()) { qWarning() << "Need password parameter after --password option."; printUsage(args.at(0)); return -1; } password = args.at(++i); } else if (arg.startsWith("--")) { qWarning() << "Unrecognized option: " << arg; printUsage(args.at(0)); return -1; } else { script_filename = arg; // all the rest of the args get exposed to the script api script_args.append(args.mid(i + 1)); break; } } lib_path.prepend(QFileInfo(script_filename).dir().absolutePath()); if (env_path.isNull()) { // default lib path lib_path << "/usr/lib/mineflayer"; // linux lib_path << a.applicationDirPath() + "/lib"; // windows } url.setPassword(password); MetaTypes::registerMetaTypes(); Item::initializeStaticData(); #ifndef MINEFLAYER_3D_ON if (! headless) qWarning() << "3D support was not compiled in. You cannot use the 3D client."; #endif #ifndef MINEFLAYER_GUI_ON if (script_debug) { qWarning() << "Gui support was not compiled in. You cannot use the debugger."; script_debug = false; } #endif if (! script_filename.isEmpty()) { ScriptRunner runner(url, script_filename, script_args, script_debug, headless, lib_path); runner.bootstrap(); if (headless) return a.exec(); } #ifdef MINEFLAYER_3D_ON MainWindow w(url); return w.exec(); #else printUsage(args.at(0)); return 1; #endif }
// Callback from fetchIcon void MainWindow::iconDownloaded() { QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); QString savePath = reply->request().attribute(QNetworkRequest::User).toString(); int wasRedirected = reply->request().attribute((QNetworkRequest::Attribute)(QNetworkRequest::User+1)).toInt(); QString username = reply->request().attribute((QNetworkRequest::Attribute)(QNetworkRequest::User+2)).toString(); QString password = reply->request().attribute((QNetworkRequest::Attribute)(QNetworkRequest::User+3)).toString(); QVariant redirect = reply->attribute(QNetworkRequest::RedirectionTargetAttribute); if (!redirect.toUrl().isEmpty() && !wasRedirected) { qDebug() << "Was redirected to " << redirect.toUrl(); reply->deleteLater(); QUrl redir = redirect.toUrl(); if (!username.isEmpty()) { redir.setUserName(username); redir.setPassword(password); } QNetworkRequest req = QNetworkRequest(redir); req.setAttribute(QNetworkRequest::User, QVariant(savePath)); req.setAttribute((QNetworkRequest::Attribute)(QNetworkRequest::User+1), QVariant(1)); QNetworkReply *rep = pManager->get(req); connect(rep, SIGNAL(finished()), this, SLOT(iconDownloaded())); return; } qDebug() << "Icon downloaded"; if (reply->error()) { reply->close(); qDebug() << "Couldn't get icon"; fetchHTMLIcon(reply->url().toString(), savePath); return; } QByteArray logoData = reply->readAll(); // The favicon can be in various formats, so convert it to something // we know we can safely display QBuffer logoBuffer(&logoData); logoBuffer.open(QIODevice::ReadOnly); QImageReader reader(&logoBuffer); QSize iconSize(16, 16); if(reader.canRead()) { while((reader.imageCount() > 1) && (reader.currentImageRect() != QRect(0, 0, 16, 16))) { if (!reader.jumpToNextImage()) break; } reader.setScaledSize(iconSize); const QImage icon = reader.read(); if (icon.format() == QImage::Format_Invalid) { fetchHTMLIcon(reply->url().toString(), savePath); } else { icon.save(savePath, "PNG"); QFileInfo info(savePath); int tabIndex = compareTabName(info.baseName()); if (tabIndex != -1) ui->trackerTab->setTabIcon(tabIndex, QIcon(QPixmap::fromImage(icon))); } } else { qDebug() << "Invalid image"; fetchHTMLIcon(reply->url().toString(), savePath); } logoBuffer.close(); reply->close(); }
int main(int argc, char* argv[]) { terrama2::core::initializeTerraMA(); terrama2::core::registerFactories(); auto& serviceManager = terrama2::core::ServiceManager::getInstance(); std::map<std::string, std::string> connInfo{{"PG_HOST", TERRAMA2_DATABASE_HOST}, {"PG_PORT", TERRAMA2_DATABASE_PORT}, {"PG_USER", TERRAMA2_DATABASE_USERNAME}, {"PG_PASSWORD", TERRAMA2_DATABASE_PASSWORD}, {"PG_DB_NAME", TERRAMA2_DATABASE_DBNAME}, {"PG_CONNECT_TIMEOUT", "4"}, {"PG_CLIENT_ENCODING", "UTF-8"} }; serviceManager.setLogConnectionInfo(connInfo); terrama2::services::analysis::core::initInterpreter(); QCoreApplication app(argc, argv); DataManagerPtr dataManager(new DataManager()); QUrl uri; uri.setScheme("postgis"); uri.setHost(QString::fromStdString(TERRAMA2_DATABASE_HOST)); uri.setPort(std::stoi(TERRAMA2_DATABASE_PORT)); uri.setUserName(QString::fromStdString(TERRAMA2_DATABASE_USERNAME)); uri.setPassword(QString::fromStdString(TERRAMA2_DATABASE_PASSWORD)); uri.setPath(QString::fromStdString("/" + TERRAMA2_DATABASE_DBNAME)); // DataProvider information terrama2::core::DataProvider* outputDataProvider = new terrama2::core::DataProvider(); terrama2::core::DataProviderPtr outputDataProviderPtr(outputDataProvider); outputDataProvider->id = 3; outputDataProvider->name = "DataProvider postgis"; outputDataProvider->uri = uri.url().toStdString(); outputDataProvider->intent = terrama2::core::DataProviderIntent::PROCESS_INTENT; outputDataProvider->dataProviderType = "POSTGIS"; outputDataProvider->active = true; dataManager->add(outputDataProviderPtr); // DataSeries information terrama2::core::DataSeries* outputDataSeries = new terrama2::core::DataSeries(); terrama2::core::DataSeriesPtr outputDataSeriesPtr(outputDataSeries); outputDataSeries->id = 3; outputDataSeries->name = "Analysis result"; outputDataSeries->semantics.code = "ANALYSIS_MONITORED_OBJECT-postgis"; outputDataSeries->dataProviderId = outputDataProviderPtr->id; // DataSet information terrama2::core::DataSet* outputDataSet = new terrama2::core::DataSet(); outputDataSet->active = true; outputDataSet->id = 2; outputDataSet->format.emplace("table_name", "dcp_result"); outputDataSeries->datasetList.emplace_back(outputDataSet); dataManager->add(outputDataSeriesPtr); std::string script = "moBuffer = Buffer(BufferType.object_plus_buffer, 2., \"km\")\n" "x = dcp.min(\"Serra do Mar\", \"Pluvio\", moBuffer)\n" "add_value(\"min\", x)\n" "x = dcp.max(\"Serra do Mar\", \"Pluvio\", moBuffer)\n" "add_value(\"max\", x)\n" "x = dcp.mean(\"Serra do Mar\", \"Pluvio\", moBuffer)\n" "add_value(\"mean\", x)\n" "x = dcp.median(\"Serra do Mar\", \"Pluvio\", moBuffer)\n" "add_value(\"median\", x)\n" "x = dcp.standard_deviation(\"Serra do Mar\", \"Pluvio\", moBuffer)\n" "add_value(\"standardDeviation\", x)\n"; Analysis* analysis = new Analysis; AnalysisPtr analysisPtr(analysis); analysis->id = 1; analysis->name = "Min DCP"; analysis->script = script; analysis->scriptLanguage = ScriptLanguage::PYTHON; analysis->type = AnalysisType::MONITORED_OBJECT_TYPE; analysis->active = false; analysis->outputDataSeriesId = 3; analysis->serviceInstanceId = 1; analysis->metadata["INFLUENCE_TYPE"] = "1"; analysis->metadata["INFLUENCE_RADIUS"] = "50"; analysis->metadata["INFLUENCE_RADIUS_UNIT"] = "km"; terrama2::core::DataProvider* dataProvider = new terrama2::core::DataProvider(); terrama2::core::DataProviderPtr dataProviderPtr(dataProvider); dataProvider->name = "Provider"; dataProvider->uri += TERRAMA2_DATA_DIR; dataProvider->uri += "/shapefile"; dataProvider->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT; dataProvider->dataProviderType = "FILE"; dataProvider->active = true; dataProvider->id = 1; dataManager->add(dataProviderPtr); terrama2::core::DataSeries* dataSeries = new terrama2::core::DataSeries(); terrama2::core::DataSeriesPtr dataSeriesPtr(dataSeries); dataSeries->dataProviderId = dataProvider->id; dataSeries->semantics.code = "STATIC_DATA-ogr"; dataSeries->semantics.dataSeriesType = terrama2::core::DataSeriesType::STATIC; dataSeries->name = "Monitored Object"; dataSeries->id = 1; dataSeries->dataProviderId = 1; //DataSet information terrama2::core::DataSet* dataSet = new terrama2::core::DataSet; terrama2::core::DataSetPtr dataSetPtr(dataSet); dataSet->active = true; dataSet->format.emplace("mask", "municipios_afetados.shp"); dataSet->id = 1; dataSeries->datasetList.push_back(dataSetPtr); dataManager->add(dataSeriesPtr); terrama2::core::DataProvider* dataProvider2 = new terrama2::core::DataProvider(); terrama2::core::DataProviderPtr dataProvider2Ptr(dataProvider2); dataProvider2->name = "Provider"; dataProvider2->uri += TERRAMA2_DATA_DIR; dataProvider2->uri += "/PCD_serrmar_INPE"; dataProvider2->intent = terrama2::core::DataProviderIntent::COLLECTOR_INTENT; dataProvider2->dataProviderType = "FILE"; dataProvider2->active = true; dataProvider2->id = 2; dataManager->add(dataProvider2Ptr); AnalysisDataSeries monitoredObjectADS; monitoredObjectADS.id = 1; monitoredObjectADS.dataSeriesId = dataSeriesPtr->id; monitoredObjectADS.type = AnalysisDataSeriesType::DATASERIES_MONITORED_OBJECT_TYPE; monitoredObjectADS.metadata["identifier"] = "objet_id_5"; //DataSeries information terrama2::core::DataSeries* dcpSeries = new terrama2::core::DataSeries; terrama2::core::DataSeriesPtr dcpSeriesPtr(dcpSeries); dcpSeries->dataProviderId = dataProvider2->id; auto& semanticsManager = terrama2::core::SemanticsManager::getInstance(); dcpSeries->semantics = semanticsManager.getSemantics("DCP-inpe"); dcpSeries->semantics.dataSeriesType = terrama2::core::DataSeriesType::DCP; dcpSeries->name = "Serra do Mar"; dcpSeries->id = 2; dcpSeries->dataProviderId = 2; //DataSet information terrama2::core::DataSetDcp* dcpDataset69034 = new terrama2::core::DataSetDcp; terrama2::core::DataSetDcpPtr dcpDataset69034Ptr(dcpDataset69034); dcpDataset69034->active = true; dcpDataset69034->format.emplace("mask", "69033.txt"); dcpDataset69034->format.emplace("timezone", "-02:00"); dcpDataset69034->dataSeriesId = 2; dcpDataset69034->id = 2; dcpDataset69034->position = std::shared_ptr<te::gm::Point>(new te::gm::Point(-44.46540, -23.00506, 4618, nullptr)); dcpSeries->datasetList.push_back(dcpDataset69034Ptr); terrama2::core::DataSetDcp* dcpDataset30886 = new terrama2::core::DataSetDcp; terrama2::core::DataSetDcpPtr dcpDataset30886Ptr(dcpDataset30886); dcpDataset30886->active = true; dcpDataset30886->format.emplace("mask", "30886.txt"); dcpDataset30886->format.emplace("timezone", "-02:00"); dcpDataset30886->dataSeriesId = 2; dcpDataset30886->id = 3; dcpDataset30886->position = std::shared_ptr<te::gm::Point>(new te::gm::Point(-46.121, -23.758, 4618, nullptr)); dcpSeries->datasetList.push_back(dcpDataset30886Ptr); AnalysisDataSeries dcpADS; dcpADS.id = 2; dcpADS.dataSeriesId = dcpSeriesPtr->id; dcpADS.type = AnalysisDataSeriesType::ADDITIONAL_DATA_TYPE; dataManager->add(dcpSeriesPtr); std::vector<AnalysisDataSeries> analysisDataSeriesList; analysisDataSeriesList.push_back(dcpADS); analysisDataSeriesList.push_back(monitoredObjectADS); analysis->analysisDataSeriesList = analysisDataSeriesList; analysis->schedule.frequency = 1; analysis->schedule.frequencyUnit = "min"; dataManager->add(analysisPtr); // Starts the service and adds the analysis Service service(dataManager); terrama2::core::ServiceManager::getInstance().setInstanceId(1); auto logger = std::make_shared<AnalysisLogger>(); logger->setConnectionInfo(connInfo); service.setLogger(logger); service.start(); service.addAnalysis(1); QTimer timer; QObject::connect(&timer, SIGNAL(timeout()), QCoreApplication::instance(), SLOT(quit())); timer.start(30000); app.exec(); terrama2::core::finalizeTerraMA(); return 0; }