本文整理汇总了C++中QMultiMap::unite方法的典型用法代码示例。如果您正苦于以下问题:C++ QMultiMap::unite方法的具体用法?C++ QMultiMap::unite怎么用?C++ QMultiMap::unite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMultiMap
的用法示例。
在下文中一共展示了QMultiMap::unite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: signRequest
QByteArray Token::signRequest(const QUrl& requestUrl, Token::AuthMethod authMethod, Token::HttpMethod method, const QMultiMap<QString, QString>& parameters) const
{
QString timestamp;
QString nonce;
if (d->consumerKey == "test_token") { // Set known values for unit-testing
timestamp = "1234567890"; //Feb 13, 2009, 23:31:30 GMT
nonce = "ABCDEF";
} else {
#if QT_VERSION >= 0x040700
timestamp = QString::number(QDateTime::currentDateTimeUtc().toTime_t());
#else
timestamp = QString::number(QDateTime::currentDateTime().toUTC().toTime_t());
#endif
nonce = QString::number(qrand());
}
if (!requestUrl.isValid()) {
qWarning() << "OAuth::Token: Invalid url. The request will probably be invalid";
}
// Step 1. Get all the oauth params for this request
QMultiMap<QString, QString> oauthParams;
oauthParams.insert("oauth_consumer_key", d->consumerKey);
if(d->serviceType == "dbox")
oauthParams.insert("oauth_signature_method", "PLAINTEXT");
else
oauthParams.insert("oauth_signature_method", "HMAC-SHA1");
oauthParams.insert("oauth_timestamp", timestamp);
oauthParams.insert("oauth_nonce", nonce);
oauthParams.insert("oauth_version", "1.0");
switch (d->tokenType) {
case Token::InvalidToken:
oauthParams.insert("oauth_callback", d->callbackUrl.toString());
break;
case Token::RequestToken:
oauthParams.insert("oauth_token", d->oauthToken);
oauthParams.insert("oauth_verifier", d->oauthVerifier);
break;
case Token::AccessToken:
oauthParams.insert("oauth_token", d->oauthToken);
break;
}
// Step 2. Take the parameters from the url, and add the oauth params to them
QMultiMap<QString, QString> allParams = oauthParams;
QList<QPair<QString, QString> > queryItems = requestUrl.queryItems();
for(int i = 0; i < queryItems.count(); ++i) {
allParams.insert(queryItems[i].first, queryItems[i].second);
}
allParams.unite(parameters);
// Step 3. Calculate the signature from those params, and append the signature to the oauth params
QString signature = generateSignature(requestUrl, allParams, method);
oauthParams.insert("oauth_signature", signature);
// Step 4. Concatenate all oauth params into one comma-separated string
QByteArray authHeader;
if (authMethod == Sasl) {
authHeader = "GET ";
authHeader.append(requestUrl.toString() + " ");
} else {
authHeader = "OAuth ";
}
QMultiMap<QString, QString>::const_iterator p = oauthParams.constBegin();
while (p != oauthParams.constEnd()) {
authHeader += QString("%1=\"%2\",").arg(p.key()).arg(encode(p.value()));
++p;
}
authHeader.chop(1); // remove the last character (the trailing ",")
return authHeader;
}