/*! * Получение канала из URL адреса. */ ClientChannel ChatUrls::channel(const QUrl &url) { ClientChannel channel; if (url.scheme() != LS("chat") && url.host() != LS("channel")) return channel; QStringList path = ChatUrls::path(url); if (path.isEmpty()) return channel; QByteArray id = SimpleID::decode(path.at(0).toLatin1()); if (!Channel::isCompatibleId(id)) return channel; channel = ChatClient::channels()->get(id); if (channel) return channel; channel = ClientChannel(new Channel(id, ChatId::fromBase32(QUrlQuery(url).queryItemValue(LS("name")).toLatin1()))); channel->gender().setRaw(QUrlQuery(url).queryItemValue(LS("gender")).toInt()); if (!channel->isValid()) return ClientChannel(); return channel; }
void Preview::_size() { this->width = QUrlQuery(this->uri).queryItemValue("width").toUInt(); this->height = QUrlQuery(this->uri).queryItemValue("height").toUInt(); if (!this->width && !this->height) { this->width = 100; this->height = 75; } if (this->width > 800) this->width = 800; if (this->height > 600) this->height = 600; }
bool CoreDbUrl::areaCoordinates(double* lat1, double* lat2, double* lon1, double* lon2) const { bool ok; bool allOk = true; *lat1 = QUrlQuery(*this).queryItemValue(QLatin1String("lat1")).toDouble(&ok); allOk = ok && allOk; *lat2 = QUrlQuery(*this).queryItemValue(QLatin1String("lat2")).toDouble(&ok); allOk = ok && allOk; *lon1 = QUrlQuery(*this).queryItemValue(QLatin1String("lon1")).toDouble(&ok); allOk = ok && allOk; *lon2 = QUrlQuery(*this).queryItemValue(QLatin1String("lon2")).toDouble(&ok); allOk = ok && allOk; return allOk; }
void writeAsDxf( QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response ) { Q_UNUSED( version ); QgsServerRequest::Parameters params = request.parameters(); QgsWmsParameters wmsParameters( QUrlQuery( request.url() ) ); QgsRenderer renderer( serverIface, project, wmsParameters ); QMap<QString, QString> formatOptionsMap = parseFormatOptions( params.value( QStringLiteral( "FORMAT_OPTIONS" ) ) ); QgsDxfExport dxf = renderer.getDxf( formatOptionsMap ); QString codec = QStringLiteral( "ISO-8859-1" ); QMap<QString, QString>::const_iterator codecIt = formatOptionsMap.find( QStringLiteral( "CODEC" ) ); if ( codecIt != formatOptionsMap.constEnd() ) { codec = formatOptionsMap.value( QStringLiteral( "CODEC" ) ); } // Write output response.setHeader( "Content-Type", "application/dxf" ); dxf.writeToFile( response.io(), codec ); }
void Comments::anchorClicked(const QUrl & url) { if(url.host().isEmpty() && url.path() == "edit") { #if QT_VERSION >= 0x050000 int cid = QUrlQuery(url).queryItemValue("id").toInt(); #else int cid = url.queryItemValue("id").toInt(); #endif if(userCanEdit(cid)) { ParameterList params; params.append("mode", "edit"); params.append("sourceType", _sourcetype); params.append("source_id", _sourceid); params.append("comment_id", cid); params.append("commentIDList", _commentIDList); comment newdlg(this, "", true); newdlg.set(params); newdlg.exec(); refresh(); } } else { QDesktopServices::openUrl(url); } }
void AuthForm::url_canged(QUrl url) { if (!isAuthSuccess) { setEnabled(true); setWindowOpacity(1.0); if(!url.toString().contains("access_token")) { return; } url = url.toString().replace("#", "?"); token = QUrlQuery(url).queryItemValue("access_token"); Settings::access_token = token; Settings::Save(); } else { token = Settings::access_token; } emit auth_success(token); close(); }
void Utils::testIncludeUrlParams() { QUrl urla(QString("http://example.com")); QHash<QString, QString> params; params.insert("simple", "c"); params.insert("withspecial", "a?b"); params.insert("withspace", "a b"); params.insert("username", "a123fx b"); params.insert("password", "!@#+-$%^12&*()qweqesaf\"';`~"); params.insert("withplus", "a+b"); QUrl urlb = ::includeQueryParams(urla, params); QVERIFY(urla.scheme() == urlb.scheme()); QVERIFY(urla.host() == urlb.host()); Q_FOREACH (const QString& key, params.keys()) { #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) QString encoded_key = QUrl::toPercentEncoding(key); QString encoded_value = QUrl::toPercentEncoding(params[encoded_key]); QUrlQuery query = QUrlQuery(urlb.query()); QVERIFY(query.queryItemValue(encoded_key, QUrl::FullyEncoded) == encoded_value); #else QVERIFY(urlb.queryItemValue(key) == params[key]); #endif } }
bool AdBlockManager::addSubscriptionFromUrl(const QUrl &url) { const QList<QPair<QString, QString> > queryItems = QUrlQuery(url).queryItems(QUrl::FullyDecoded); QString subscriptionTitle; QString subscriptionUrl; for (int i = 0; i < queryItems.count(); ++i) { QPair<QString, QString> pair = queryItems.at(i); if (pair.first == QL1S("location")) subscriptionUrl = pair.second; else if (pair.first == QL1S("title")) subscriptionTitle = pair.second; } if (subscriptionTitle.isEmpty() || subscriptionUrl.isEmpty()) return false; const QString message = AdBlockManager::tr("Do you want to add <b>%1</b> subscription?").arg(subscriptionTitle); QMessageBox::StandardButton result = QMessageBox::question(0, AdBlockManager::tr("AdBlock Subscription"), message, QMessageBox::Yes | QMessageBox::No); if (result == QMessageBox::Yes) { AdBlockManager::instance()->addSubscription(subscriptionTitle, subscriptionUrl); AdBlockManager::instance()->showDialog(); } return true; }
AuthorizationResultPtr OAuth2Response::parseAuthorizeResponse(const String& webAuthenticationResult, CallStatePtr/* callState*/) { Logger::info(Tag(), "parseAuthorizeResponse"); Logger::hidden(Tag(), "webAuthenticationResult: " + webAuthenticationResult); AuthorizationResultPtr parseResult = nullptr; QUrl url(webAuthenticationResult.data()); if (url.hasQuery()) { QUrlQuery query = QUrlQuery(url); if( query.hasQueryItem(OAuthConstants::oAuthReservedClaim().Code.data()) ) { parseResult = std::make_shared<AuthorizationResult>(query.queryItemValue(OAuthConstants::oAuthReservedClaim().Code.data()).toStdString()); } else if( query.hasQueryItem(OAuthConstants::oAuthReservedClaim().Error.data()) ) { String error = query.queryItemValue(OAuthConstants::oAuthReservedClaim().Error.data()).toStdString(); String errorDesc = query.hasQueryItem(OAuthConstants::oAuthReservedClaim().ErrorDescription.data()) ? query.queryItemValue(OAuthConstants::oAuthReservedClaim().ErrorDescription.data(), QUrl::FullyDecoded).toStdString() : ""; parseResult = std::make_shared<AuthorizationResult>( error, StringUtils::replaceAll(errorDesc, '+', ' ')); } else { parseResult = std::make_shared<AuthorizationResult>( Constants::rmsauthError().AuthenticationFailed, Constants::rmsauthErrorMessage().AuthorizationServerInvalidResponse); } } return parseResult; }
bool OpenLocalHelper::openLocalFile(const QUrl &url) { if (url.scheme() != kSeafileProtocolScheme) { qWarning("[OpenLocalHelper] unknown scheme %s\n", url.scheme().toUtf8().data()); return false; } if (url.host() != kSeafileProtocolHostOpenFile) { qWarning("[OpenLocalHelper] unknown command %s\n", url.host().toUtf8().data()); return false; } #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QUrlQuery url_query = QUrlQuery(url.query()); QString repo_id = url_query.queryItemValue("repo_id", QUrl::FullyDecoded); QString email = url_query.queryItemValue("email", QUrl::FullyDecoded); QString path = url_query.queryItemValue("path", QUrl::FullyDecoded); #else QString repo_id = url.queryItemValue("repo_id"); QString email = url.queryItemValue("email"); QString path = url.queryItemValue("path"); #endif if (repo_id.size() < 36) { qWarning("[OpenLocalHelper] invalid repo_id %s\n", repo_id.toUtf8().data()); return false; } qDebug("[OpenLocalHelper] open local file: repo %s, path %s\n", repo_id.toUtf8().data(), path.toUtf8().data()); RepoService::instance()->openLocalFile(repo_id, path); return true; }
QJsonObject festrip_api::user_update(QString password, QString nickname, QString twitterId, QString name, QString lastname, QString gender, QString countryId, QString cityId, QString avatar) { QUrlQuery query = QUrlQuery(QUrl(QString(FESTRIP_URL).append("/api/user/"))); // Fill in query query.addQueryItem("query", "update"); query.addQueryItem("token", token.toString()); query.addQueryItem("password", password); query.addQueryItem("nickname", nickname); query.addQueryItem("twitterId", twitterId); query.addQueryItem("name", name); query.addQueryItem("lastname", lastname); query.addQueryItem("gender", gender); query.addQueryItem("countryId", countryId); query.addQueryItem("cityId", cityId); query.addQueryItem("avatar", avatar); // Send query to server QJsonObject response = send_query(POST, query); // Return JSON return(response); }
QString serviceUrl( const QgsServerRequest &request, const QgsProject *project ) { QString href; if ( project ) { href = QgsServerProjectUtils::wmtsServiceUrl( *project ); } // Build default url if ( href.isEmpty() ) { QUrl url = request.originalUrl(); QgsWmtsParameters params; params.load( QUrlQuery( url ) ); params.remove( QgsServerParameter::REQUEST ); params.remove( QgsServerParameter::VERSION_SERVICE ); params.remove( QgsServerParameter::SERVICE ); url.setQuery( params.urlQuery() ); href = url.toString(); } return href; }
void tst_QUrlQuery::old_hasQueryItem() { QFETCH(QString, url); QFETCH(QString, item); QFETCH(bool, trueFalse); QCOMPARE(QUrlQuery(url).hasQueryItem(item), trueFalse); }
bool UTIL::urlHasQueryItem( const QUrl& url, const QString& key ) { #if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 ) return QUrlQuery( url ).hasQueryItem( key ); #else return url.hasQueryItem( key ); #endif }
void SettingsDialog::onWebviewLoaded(){ QUrl url = webView->url(); if(url.host() == QString("ivle.nus.edu.sg")&& url.path() == QString("/api/login/login_result.ashx")&& QUrlQuery(url).queryItemValue("r") == QString("0")){ qDebug()<<"OK!"; webviewDialog->close(); emit gottenToken(webView->page()->mainFrame()->toPlainText()); } }
void OAuth::check_URL(QUrl url) { url = url.toString().replace("#","?"); // т.к https://vk.com#token=13123123dsgfdgjsdklgj464624244242&id=dasd this->token = QUrlQuery(url).queryItemValue("access_token"); this->user_id = QUrlQuery(url).queryItemValue("user_id"); if(this->token.isEmpty()) { qDebug() <<"Error get token(check_URL)"; return; } audioManager->setAudioCount(this->requestManager->audioCount(this->getUserId(),this->getToken())); emit oauthSuccess(); }
/*! * Parses URL-encoded form data * * Extracts the key/value pairs from \bold application/x-www-form-urlencoded * \a data, such as the query string from the URL or the form data from a * POST request. */ QHash<QString, QString> QxtWebContent::parseUrlEncodedQuery(const QString& data) { QUrl post("/?" + data); QHash<QString, QString> rv; foreach(const QxtQueryItem& item, QUrlQuery( post ).queryItems()) { rv.insertMulti(item.first, item.second); } return rv; }
Responder::Responder(QHttpRequest *req, QHttpResponse *resp, QObject *parent) : QObject(parent) { m_req = req; connect(req, SIGNAL(end()), resp, SLOT(end())); connect(resp, SIGNAL(done()), this, SLOT(deleteLater())); bool flag = false; QString ext; QByteArray blob; QString fName = req->path(); if(fName.isEmpty()||(fName=="/")) fName = "index.html"; fName = QApplication::applicationDirPath() +"/html/" + fName; QString reqBody = QUrlQuery(req->url()).queryItemValue("ob"); if(QFile::exists(fName)) { QFile file(fName); QFileInfo fInfo(file); QRegExp extExpr("^.*\\.([^\\.]+)$"); if(extExpr.indexIn(fInfo.fileName())!=-1) { ext = extExpr.cap(1); } if(file.open(QIODevice::ReadOnly)) { blob = file.readAll(); flag = true; file.close(); } }else if(!reqBody.isEmpty()){ fName = req->url().fileName(); if(fName=="din.txt") { blob = DynReqManager::getData(fName,reqBody).toUtf8(); flag = true; }else if(fName=="ain.txt") { blob = DynReqManager::getData(fName,reqBody).toUtf8(); flag = true; }else if(fName=="message.txt") { blob = DynReqManager::getData(fName,reqBody).toUtf8(); flag = true; }else if(fName=="status.txt") { blob = DynReqManager::getData(fName,reqBody).toUtf8(); flag = true; } } if(flag) { if(ext=="css") resp->setHeader("Content-Type", "text/css"); else if(ext=="js") resp->setHeader("Content-Type", "text/javascript"); else if(ext=="png") resp->setHeader("Content-Type", "image/png"); else resp->setHeader("Content-Type", "text/html"); resp->writeHead(200); resp->write(blob); }else { resp->writeHead(403); resp->write(QByteArray("File not found!")); } }
QUrlQuery CommandManager::forgeQuery(const QString &path, const QString &postfix) { Q_ASSERT(path.length() > 0 && path[0] == '/'); QString postfixsep = ""; if (!postfix.isEmpty() && path[path.length() - 1] != '/') postfixsep = "/"; return QUrlQuery(QString("%1%2%3%4").arg(websiteUrl).arg(path).arg(postfixsep).arg(postfix.isEmpty() ? "" : postfix + ".json")); }
QJsonObject festrip_api::user_attended_festivals() { QUrlQuery query = QUrlQuery(QUrl(QString(FESTRIP_URL).append("/api/user/"))); // Fill in query query.addQueryItem("query", "attended_festivals"); query.addQueryItem("token", token.toString()); // Send query to server QJsonObject response = send_query(POST, query); // Return JSON return(response); }
/** * @brief Create an AWS V4 Signature canonical request. * * @param[in] operation The HTTP method being used for the request. * @param[in] request The network request to generate a canonical request for. * @param[in] payload Optional data being submitted in the request (eg for `PUT` and `POST` operations). * @param[out] signedHeaders A semi-colon separated list of the names of all headers * included in the result. * * @return An AWS V4 Signature canonical request. * * @see http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html */ QByteArray AwsSignatureV4Private::canonicalRequest(const QNetworkAccessManager::Operation operation, const QNetworkRequest &request, const QByteArray &payload, QByteArray * const signedHeaders) const { return httpMethod(operation).toUtf8() + '\n' + canonicalPath(request.url()).toUtf8() + '\n' + canonicalQuery(QUrlQuery(request.url())) + '\n' + canonicalHeaders(request, signedHeaders) + '\n' + *signedHeaders + '\n' + QCryptographicHash::hash(payload, hashAlgorithm).toHex(); }
void StackOverflowAuth::tokenReady() { OAUTH_PREPARE_REPLY const QByteArray token = QUrlQuery(QUrl(LC('?') + raw)).queryItemValue(LS("access_token")).toUtf8(); log(NodeLog::InfoLevel, "Token is successfully received"); QNetworkRequest request(QUrl(LS("https://api.stackexchange.com/2.1/me?order=desc&sort=reputation&site=stackoverflow&access_token=") + token + LS("&key=") + m_provider->publicKey)); QNetworkReply *reply = m_manager->get(request); connect(reply, SIGNAL(finished()), SLOT(dataReady())); }
QJsonObject festrip_api::user_reset_password(QString username) { QUrlQuery query = QUrlQuery(QUrl(QString(FESTRIP_URL).append("/api/user/"))); // Fill in query query.addQueryItem("query", "reset_password"); query.addQueryItem("username", username); query.addQueryItem("token", token.toString()); // Send query to server QJsonObject response = send_query(GET, query); // Return JSON return(response); }
ServerRequest::ServerRequest(const QHttpRequest &req) : _request(req) { _path = req.path(); #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 2) QUrlQuery query = QUrlQuery(req.url()); _queryItems = query.queryItems(); #else _queryItems = req.url().queryItems(); #endif //TODO: parse principal }
// Updates API QJsonObject festrip_api::updates_get_updates(QDate date) { QUrlQuery query = QUrlQuery(QUrl(QString(FESTRIP_URL).append("/api/updates/"))); // Fill in query query.addQueryItem("query", "get_updates"); query.addQueryItem("token", token.toString()); query.addQueryItem("date", date.toString()); // Send query to server QJsonObject response = send_query(GET, query); // Return JSON return(response); }
QJsonObject festrip_api::user_get_public_info(int userId) { QUrlQuery query = QUrlQuery(QUrl(QString(FESTRIP_URL).append("/api/user/"))); // Fill in query query.addQueryItem("query", "get_public_info"); query.addQueryItem("token", token.toString()); query.addQueryItem("userId", (QString)(userId)); // Send query to server QJsonObject response = send_query(GET, query); // Return JSON return(response); }
void writeGetTile( QgsServerInterface *serverIface, const QgsProject *project, const QString &version, const QgsServerRequest &request, QgsServerResponse &response ) { Q_UNUSED( version ); const QgsWmtsParameters params( QUrlQuery( request.url() ) ); // WMS query QUrlQuery query = translateWmtsParamToWmsQueryItem( QStringLiteral( "GetMap" ), params, project, serverIface ); // Get cached image QgsAccessControl *accessControl = serverIface->accessControls(); QgsServerCacheManager *cacheManager = serverIface->cacheManager(); if ( cacheManager ) { QgsWmtsParameters::Format f = params.format(); QString contentType; QString saveFormat; std::unique_ptr<QImage> image; if ( f == QgsWmtsParameters::Format::JPG ) { contentType = QStringLiteral( "image/jpeg" ); saveFormat = QStringLiteral( "JPEG" ); image = qgis::make_unique<QImage>( 256, 256, QImage::Format_RGB32 ); } else { contentType = QStringLiteral( "image/png" ); saveFormat = QStringLiteral( "PNG" ); image = qgis::make_unique<QImage>( 256, 256, QImage::Format_ARGB32_Premultiplied ); } QByteArray content = cacheManager->getCachedImage( project, request, accessControl ); if ( !content.isEmpty() && image->loadFromData( content ) ) { response.setHeader( QStringLiteral( "Content-Type" ), contentType ); image->save( response.io(), qPrintable( saveFormat ) ); return; } } QgsServerParameters wmsParams( query ); QgsServerRequest wmsRequest( "?" + query.query( QUrl::FullyDecoded ) ); QgsService *service = serverIface->serviceRegistry()->getService( wmsParams.service(), wmsParams.version() ); service->executeRequest( wmsRequest, response, project ); if ( cacheManager ) { QByteArray content = response.data(); if ( !content.isEmpty() ) cacheManager->setCachedImage( &content, project, request, accessControl ); } }
// Game API QJsonObject festrip_api::game_get_badges(QString type) { QUrlQuery query = QUrlQuery(QUrl(QString(FESTRIP_URL).append("/api/game/"))); // Fill in query query.addQueryItem("query", "get_badges"); query.addQueryItem("token", token.toString()); query.addQueryItem("type", type); // Send query to server QJsonObject response = send_query(GET, query); // Return JSON return(response); }
QJsonObject festrip_api::group_festival(int festivalId) { QUrlQuery query = QUrlQuery(QUrl(QString(FESTRIP_URL).append("/api/group/"))); // Fill in query query.addQueryItem("query", "festival"); query.addQueryItem("token", token.toString()); query.addQueryItem("festival_id", QString::number(festivalId)); // Send query to server QJsonObject response = send_query(POST, query); // Return JSON return(response); }
QUrl CoreDbUrl::albumRoot() const { QString albumRoot = QUrlQuery(*this).queryItemValue(QLatin1String("albumRoot")); if (!albumRoot.isNull()) { QUrl albumRootUrl; albumRootUrl.setPath(albumRoot); return albumRootUrl; } return QUrl(); }