本文整理汇总了C++中QUrl::encodedQueryItems方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::encodedQueryItems方法的具体用法?C++ QUrl::encodedQueryItems怎么用?C++ QUrl::encodedQueryItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::encodedQueryItems方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
QList<QPair<QByteArray, QByteArray> > QUrlProto::encodedQueryItems() const
{
QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
if (item)
return item->encodedQueryItems();
return QList<QPair<QByteArray, QByteArray> >();
}
示例2: loginUrlRequestCompleted
void NetFlixAuthProxy::loginUrlRequestCompleted(int retCode, QString body)
{
qDebug() << "temp token completed!!";
qDebug() << retCode;
qDebug() << body;
QUrl parser;
parser.setEncodedQuery(body.toUtf8());
QString url = parser.queryItemValue(STR(NETFLIX_LOGIN_URL_PARAM));
parser.removeQueryItem(STR(NETFLIX_LOGIN_URL_PARAM));
QString token = parser.queryItemValue(STR(OAUTH_TOKEN));
QString token_secret = parser.queryItemValue(STR(OAUTH_TOKEN_SECRET));
parser.removeQueryItem(STR(OAUTH_TOKEN_SECRET));
settings->setOAuthToken(token);
settings->setOAuthTokenSecret(token_secret);
QUrl loginUrl = QUrl(url);
loginUrl.setEncodedQueryItems(parser.encodedQueryItems());
qDebug() << loginUrl.toEncoded();
emit getTokenUrlSucceeded(loginUrl);
}
示例3: addEngineFromForm
void SearchEnginesManager::addEngineFromForm(const QWebElement &element, WebView* view)
{
QWebElement formElement = element.parent();
while (!formElement.isNull()) {
if (formElement.tagName().toLower() == QLatin1String("form")) {
break;
}
formElement = formElement.parent();
}
if (formElement.isNull()) {
return;
}
const QString method = formElement.hasAttribute("method") ? formElement.attribute("method").toUpper() : "GET";
bool isPost = method == QLatin1String("POST");
QUrl actionUrl = QUrl::fromEncoded(formElement.attribute("action").toUtf8());
if (actionUrl.isRelative()) {
actionUrl = view->url().resolved(actionUrl);
}
QUrl parameterUrl = actionUrl;
if (isPost) {
parameterUrl = QUrl("http://foo.bar");
}
#if QT_VERSION >= 0x050000
QUrlQuery query(parameterUrl);
query.addQueryItem(element.attribute("name"), "%s");
QWebElementCollection allInputs = formElement.findAll("input");
foreach (QWebElement e, allInputs) {
if (element == e || !e.hasAttribute("name")) {
continue;
}
query.addQueryItem(e.attribute("name"), e.evaluateJavaScript("this.value").toString());
}
parameterUrl.setQuery(query);
#else
QList<QPair<QByteArray, QByteArray> > queryItems;
QPair<QByteArray, QByteArray> item;
item.first = element.attribute("name").toUtf8();
item.second = "%s";
queryItems.append(item);
QWebElementCollection allInputs = formElement.findAll("input");
foreach (QWebElement e, allInputs) {
if (element == e || !e.hasAttribute("name")) {
continue;
}
QPair<QByteArray, QByteArray> item;
item.first = QUrl::toPercentEncoding(e.attribute("name").toUtf8());
item.second = QUrl::toPercentEncoding(e.evaluateJavaScript("this.value").toByteArray());
queryItems.append(item);
}
parameterUrl.setEncodedQueryItems(parameterUrl.encodedQueryItems() + queryItems);
#endif
if (!isPost) {
actionUrl = parameterUrl;
}
SearchEngine engine;
engine.name = view->title();
engine.icon = view->icon();
engine.url = actionUrl.toEncoded();
if (isPost) {
QByteArray data = parameterUrl.toEncoded(QUrl::RemoveScheme);
engine.postData = data.contains('?') ? data.mid(data.lastIndexOf('?') + 1) : QByteArray();
}
EditSearchEngine dialog(SearchEnginesDialog::tr("Add Search Engine"), view);
dialog.setName(engine.name);
dialog.setIcon(engine.icon);
dialog.setUrl(engine.url);
dialog.setPostData(engine.postData);
if (dialog.exec() != QDialog::Accepted) {
return;
}
engine.name = dialog.name();
engine.icon = dialog.icon();
engine.url = dialog.url();
engine.shortcut = dialog.shortcut();
engine.postData = dialog.postData().toUtf8();
if (engine.name.isEmpty() || engine.url.isEmpty()) {
return;
//.........这里部分代码省略.........
示例4: generateSignatureBase
/**
* Generates OAuth signature base
* @param url Url with encoded parameters
* @param method Http method
* @param timestamp timestamp
* @param nonce random string
* @return signature base
*/
QByteArray OAuth::generateSignatureBase(const QUrl& url, HttpMethod method, const QByteArray& timestamp, const QByteArray& nonce)
{
//OAuth spec. 9.1 https://oauth.net/core/1.0/#anchor14
//OAuth spec. 9.1.1
QList<QPair<QByteArray, QByteArray> > urlParameters = url.encodedQueryItems();
QList<QByteArray> normParameters;
QListIterator<QPair<QByteArray, QByteArray> > i(urlParameters);
while(i.hasNext()){
QPair<QByteArray, QByteArray> queryItem = i.next();
QByteArray normItem = queryItem.first + '=' + queryItem.second;
normParameters.append(normItem);
}
//consumer key
normParameters.append(QByteArray("oauth_consumer_key=") + m_oauthConsumerKey);
//token
if(!m_oauthToken.isEmpty()){
normParameters.append(QByteArray("oauth_token=") + m_oauthToken);
}
//signature method, only HMAC_SHA1
normParameters.append(QByteArray("oauth_signature_method=HMAC-SHA1"));
//time stamp
normParameters.append(QByteArray("oauth_timestamp=") + timestamp);
//nonce
normParameters.append(QByteArray("oauth_nonce=") + nonce);
//version
normParameters.append(QByteArray("oauth_version=1.0"));
//OAuth spec. 9.1.1.1
qSort(normParameters);
//OAuth spec. 9.1.1.2
//QByteArray normString;
//QListIterator<QByteArray> j(normParameters);
//while(j.hasNext()){
// normString += j.next();
// normString += '&';
//}
//normString.chop(1);
QByteArray normString;
QListIterator<QByteArray> j(normParameters);
while (j.hasNext()) {
normString += j.next().toPercentEncoding();
normString += "%26";
}
normString.chop(3);
//OAuth spec. 9.1.2
QString urlScheme = url.scheme();
QString urlPath = url.path();
QString urlHost = url.host();
QByteArray normUrl = urlScheme.toUtf8() + "://" + urlHost.toUtf8() + urlPath.toUtf8();
QByteArray httpm;
switch (method)
{
case OAuth::GET:
httpm = "GET";
break;
case OAuth::POST:
httpm = "POST";
break;
case OAuth::DELETE:
httpm = "DELETE";
break;
case OAuth::PUT:
httpm = "PUT";
break;
}
//OAuth spec. 9.1.3
return httpm + '&' + normUrl.toPercentEncoding() + '&' + normString;
}
示例5: fromUrl
QgsVirtualLayerDefinition QgsVirtualLayerDefinition::fromUrl( const QUrl& url )
{
QgsVirtualLayerDefinition def;
def.setFilePath( url.toLocalFile() );
// regexp for column name
const QString columnNameRx( "[a-zA-Z_\x80-\xFF][a-zA-Z0-9_\x80-\xFF]*" );
QgsFields fields;
int layerIdx = 0;
QList<QPair<QByteArray, QByteArray> > items = url.encodedQueryItems();
for ( int i = 0; i < items.size(); i++ )
{
QString key = items.at( i ).first;
QString value = items.at( i ).second;
if ( key == "layer_ref" )
{
layerIdx++;
// layer id, with optional layer_name
int pos = value.indexOf( ':' );
QString layerId, vlayerName;
if ( pos == -1 )
{
layerId = value;
vlayerName = QString( "vtab%1" ).arg( layerIdx );
}
else
{
layerId = value.left( pos );
vlayerName = QUrl::fromPercentEncoding( value.mid( pos + 1 ).toUtf8() );
}
// add the layer to the list
def.addSource( vlayerName, layerId );
}
else if ( key == "layer" )
{
layerIdx++;
// syntax: layer=provider:url_encoded_source_URI(:name(:encoding)?)?
int pos = value.indexOf( ':' );
if ( pos != -1 )
{
QString providerKey, source, vlayerName, encoding = "UTF-8";
providerKey = value.left( pos );
int pos2 = value.indexOf( ':', pos + 1 );
if ( pos2 - pos == 2 )
pos2 = value.indexOf( ':', pos + 3 );
if ( pos2 != -1 )
{
source = QUrl::fromPercentEncoding( value.mid( pos + 1, pos2 - pos - 1 ).toUtf8() );
int pos3 = value.indexOf( ':', pos2 + 1 );
if ( pos3 != -1 )
{
vlayerName = QUrl::fromPercentEncoding( value.mid( pos2 + 1, pos3 - pos2 - 1 ).toUtf8() );
encoding = value.mid( pos3 + 1 );
}
else
{
vlayerName = QUrl::fromPercentEncoding( value.mid( pos2 + 1 ).toUtf8() );
}
}
else
{
source = QUrl::fromPercentEncoding( value.mid( pos + 1 ).toUtf8() );
vlayerName = QString( "vtab%1" ).arg( layerIdx );
}
def.addSource( vlayerName, source, providerKey, encoding );
}
}
else if ( key == "geometry" )
{
// geometry field definition, optional
// geometry_column(:wkb_type:srid)?
QRegExp reGeom( "(" + columnNameRx + ")(?::([a-zA-Z0-9]+):(\\d+))?" );
int pos = reGeom.indexIn( value );
if ( pos >= 0 )
{
def.setGeometryField( reGeom.cap( 1 ) );
if ( reGeom.captureCount() > 1 )
{
// not used by the spatialite provider for now ...
QgsWKBTypes::Type wkbType = QgsWKBTypes::parseType( reGeom.cap( 2 ) );
if ( wkbType == QgsWKBTypes::Unknown )
{
wkbType = static_cast<QgsWKBTypes::Type>( reGeom.cap( 2 ).toLong() );
}
def.setGeometryWkbType( wkbType );
def.setGeometrySrid( reGeom.cap( 3 ).toLong() );
}
}
}
else if ( key == "nogeometry" )
{
def.setGeometryWkbType( QgsWKBTypes::NoGeometry );
}
else if ( key == "uid" )
{
//.........这里部分代码省略.........
示例6: sendRegistration
void Ssu::sendRegistration(QString usernameDomain, QString password){
errorFlag = false;
QString ssuCaCertificate, ssuRegisterUrl;
QString username, domainName;
SsuLog *ssuLog = SsuLog::instance();
SsuCoreConfig *settings = SsuCoreConfig::instance();
// Username can include also domain, ([email protected]), separate those
if (usernameDomain.contains('@')) {
// separate domain/username and set domain
username = usernameDomain.section('@', 0, 0);
domainName = usernameDomain.section('@', 1, 1);
setDomain(domainName);
} else {
// No domain defined
username = usernameDomain;
}
if (!settings->contains("ca-certificate")){
setError("CA certificate for SSU not set (config key 'ca-certificate')");
return;
} else
ssuCaCertificate = settings->value("ca-certificate").toString();
if (!settings->contains("register-url")){
ssuRegisterUrl = repoUrl("register-url");
if (ssuRegisterUrl.isEmpty()){
setError("URL for SSU registration not set (config key 'register-url')");
return;
}
} else
ssuRegisterUrl = settings->value("register-url").toString();
QString IMEI = deviceInfo.deviceUid();
if (IMEI == ""){
setError("No valid UID available for your device. For phones: is your modem online?");
return;
}
QSslConfiguration sslConfiguration;
if (!useSslVerify())
sslConfiguration.setPeerVerifyMode(QSslSocket::VerifyNone);
sslConfiguration.setCaCertificates(QSslCertificate::fromPath(ssuCaCertificate));
QNetworkRequest request;
request.setUrl(QUrl(QString(ssuRegisterUrl)
.arg(IMEI)
));
request.setSslConfiguration(sslConfiguration);
request.setRawHeader("Authorization", "Basic " +
QByteArray(QString("%1:%2")
.arg(username).arg(password)
.toAscii()).toBase64());
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
QUrl form;
form.addQueryItem("protocolVersion", SSU_PROTOCOL_VERSION);
form.addQueryItem("deviceModel", deviceInfo.deviceModel());
if (!domain().isEmpty()){
form.addQueryItem("domain", domain());
}
qDebug() << "Sending request to " << request.url();
qDebug() << form.encodedQueryItems();
QNetworkReply *reply;
pendingRequests++;
reply = manager->post(request, form.encodedQuery());
// we could expose downloadProgress() from reply in case we want progress info
QString homeUrl = settings->value("home-url").toString().arg(username);
if (!homeUrl.isEmpty()){
// clear header, the other request bits are reusable
request.setHeader(QNetworkRequest::ContentTypeHeader, 0);
request.setUrl(homeUrl + "/authorized_keys");
ssuLog->print(LOG_DEBUG, QString("Trying to get SSH keys from %1").arg(request.url().toString()));
pendingRequests++;
manager->get(request);
}
}