mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 16:48:01 +02:00
Merge pull request #1485 from daleglass/qt5-fix-qbytearray-append
Housekeeping: Explicitly encode QStrings to utf8.
This commit is contained in:
commit
e2332bae29
6 changed files with 29 additions and 29 deletions
|
@ -182,7 +182,7 @@ void runTimingTests() {
|
||||||
const int EXTRA_JUNK_SIZE = 200;
|
const int EXTRA_JUNK_SIZE = 200;
|
||||||
extraJunk.append((unsigned char)255);
|
extraJunk.append((unsigned char)255);
|
||||||
for (int i = 0; i < EXTRA_JUNK_SIZE; i++) {
|
for (int i = 0; i < EXTRA_JUNK_SIZE; i++) {
|
||||||
extraJunk.append(QString("junk"));
|
extraJunk.append(QString("junk").toUtf8());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -257,17 +257,17 @@ void runUnitTests() {
|
||||||
|
|
||||||
quint64 LAST_TEST = 10;
|
quint64 LAST_TEST = 10;
|
||||||
quint64 SKIP_BY = 1;
|
quint64 SKIP_BY = 1;
|
||||||
|
|
||||||
for (quint64 value = 0; value <= LAST_TEST; value += SKIP_BY) {
|
for (quint64 value = 0; value <= LAST_TEST; value += SKIP_BY) {
|
||||||
qDebug() << "value:" << value;
|
qDebug() << "value:" << value;
|
||||||
|
|
||||||
ByteCountCoded<quint64> codedValue = value;
|
ByteCountCoded<quint64> codedValue = value;
|
||||||
|
|
||||||
QByteArray codedValueBuffer = codedValue;
|
QByteArray codedValueBuffer = codedValue;
|
||||||
|
|
||||||
codedValueBuffer.append((unsigned char)255);
|
codedValueBuffer.append((unsigned char)255);
|
||||||
codedValueBuffer.append(QString("junk"));
|
codedValueBuffer.append(QString("junk").toUtf8());
|
||||||
|
|
||||||
qDebug() << "codedValueBuffer:";
|
qDebug() << "codedValueBuffer:";
|
||||||
outputBufferBits((const unsigned char*)codedValueBuffer.constData(), codedValueBuffer.size());
|
outputBufferBits((const unsigned char*)codedValueBuffer.constData(), codedValueBuffer.size());
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ void runUnitTests() {
|
||||||
quint64 valueDecoded = valueDecoder;
|
quint64 valueDecoded = valueDecoder;
|
||||||
qDebug() << "valueDecoded:" << valueDecoded;
|
qDebug() << "valueDecoded:" << valueDecoded;
|
||||||
qDebug() << "bytesConsumed:" << bytesConsumed;
|
qDebug() << "bytesConsumed:" << bytesConsumed;
|
||||||
|
|
||||||
|
|
||||||
if (value == valueDecoded) {
|
if (value == valueDecoded) {
|
||||||
qDebug() << "SUCCESS!";
|
qDebug() << "SUCCESS!";
|
||||||
|
|
|
@ -525,7 +525,7 @@ bool Wallet::readSecurityImage(const QString& inputFilePath, unsigned char** out
|
||||||
} else {
|
} else {
|
||||||
foundFooter = (line == IMAGE_FOOTER);
|
foundFooter = (line == IMAGE_FOOTER);
|
||||||
if (!foundFooter) {
|
if (!foundFooter) {
|
||||||
base64EncryptedBuffer.append(line);
|
base64EncryptedBuffer.append(line.toUtf8());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ QNetworkRequest AccountManager::createRequest(QString path, AccountManagerAuth::
|
||||||
} else {
|
} else {
|
||||||
requestURL.setPath(getMetaverseServerURLPath(true) + path.left(queryStringLocation));
|
requestURL.setPath(getMetaverseServerURLPath(true) + path.left(queryStringLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
// qCDebug(networking) << "Creating request path" << requestURL;
|
// qCDebug(networking) << "Creating request path" << requestURL;
|
||||||
// qCDebug(networking) << "requestURL.isValid()" << requestURL.isValid();
|
// qCDebug(networking) << "requestURL.isValid()" << requestURL.isValid();
|
||||||
// qCDebug(networking) << "requestURL.errorString()" << requestURL.errorString();
|
// qCDebug(networking) << "requestURL.errorString()" << requestURL.errorString();
|
||||||
|
@ -569,7 +569,7 @@ void AccountManager::requestAccessToken(const QString& login, const QString& pas
|
||||||
postData.append("grant_type=password&");
|
postData.append("grant_type=password&");
|
||||||
postData.append("username=" + QUrl::toPercentEncoding(login) + "&");
|
postData.append("username=" + QUrl::toPercentEncoding(login) + "&");
|
||||||
postData.append("password=" + QUrl::toPercentEncoding(password) + "&");
|
postData.append("password=" + QUrl::toPercentEncoding(password) + "&");
|
||||||
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE);
|
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE.toUtf8());
|
||||||
|
|
||||||
request.setUrl(grantURL);
|
request.setUrl(grantURL);
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
|
@ -590,9 +590,9 @@ void AccountManager::requestAccessTokenWithAuthCode(const QString& authCode, con
|
||||||
|
|
||||||
QByteArray postData;
|
QByteArray postData;
|
||||||
postData.append("grant_type=authorization_code&");
|
postData.append("grant_type=authorization_code&");
|
||||||
postData.append("client_id=" + clientId + "&");
|
postData.append("client_id=" + clientId.toUtf8() + "&");
|
||||||
postData.append("client_secret=" + clientSecret + "&");
|
postData.append("client_secret=" + clientSecret.toUtf8() + "&");
|
||||||
postData.append("code=" + authCode + "&");
|
postData.append("code=" + authCode.toUtf8() + "&");
|
||||||
postData.append("redirect_uri=" + QUrl::toPercentEncoding(redirectUri));
|
postData.append("redirect_uri=" + QUrl::toPercentEncoding(redirectUri));
|
||||||
|
|
||||||
request.setUrl(grantURL);
|
request.setUrl(grantURL);
|
||||||
|
@ -614,7 +614,7 @@ void AccountManager::requestAccessTokenWithSteam(QByteArray authSessionTicket) {
|
||||||
QByteArray postData;
|
QByteArray postData;
|
||||||
postData.append("grant_type=password&");
|
postData.append("grant_type=password&");
|
||||||
postData.append("steam_auth_ticket=" + QUrl::toPercentEncoding(authSessionTicket) + "&");
|
postData.append("steam_auth_ticket=" + QUrl::toPercentEncoding(authSessionTicket) + "&");
|
||||||
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE);
|
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE.toUtf8());
|
||||||
|
|
||||||
request.setUrl(grantURL);
|
request.setUrl(grantURL);
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
|
@ -635,9 +635,9 @@ void AccountManager::requestAccessTokenWithOculus(const QString& nonce, const QS
|
||||||
|
|
||||||
QByteArray postData;
|
QByteArray postData;
|
||||||
postData.append("grant_type=password&");
|
postData.append("grant_type=password&");
|
||||||
postData.append("oculus_nonce=" + nonce + "&");
|
postData.append("oculus_nonce=" + nonce.toUtf8() + "&");
|
||||||
postData.append("oculus_id=" + oculusID + "&");
|
postData.append("oculus_id=" + oculusID.toUtf8() + "&");
|
||||||
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE);
|
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE.toUtf8());
|
||||||
|
|
||||||
request.setUrl(grantURL);
|
request.setUrl(grantURL);
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
|
@ -667,7 +667,7 @@ void AccountManager::refreshAccessToken() {
|
||||||
QByteArray postData;
|
QByteArray postData;
|
||||||
postData.append("grant_type=refresh_token&");
|
postData.append("grant_type=refresh_token&");
|
||||||
postData.append("refresh_token=" + QUrl::toPercentEncoding(_accountInfo.getAccessToken().refreshToken) + "&");
|
postData.append("refresh_token=" + QUrl::toPercentEncoding(_accountInfo.getAccessToken().refreshToken) + "&");
|
||||||
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE);
|
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE.toUtf8());
|
||||||
|
|
||||||
request.setUrl(grantURL);
|
request.setUrl(grantURL);
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||||
|
|
|
@ -57,7 +57,7 @@ void DomainAccountManager::setAuthURL(const QUrl& authURL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentAuth.authURL = authURL;
|
_currentAuth.authURL = authURL;
|
||||||
qCDebug(networking) << "DomainAccountManager URL for authenticated requests has been changed to"
|
qCDebug(networking) << "DomainAccountManager URL for authenticated requests has been changed to"
|
||||||
<< qPrintable(_currentAuth.authURL.toString());
|
<< qPrintable(_currentAuth.authURL.toString());
|
||||||
|
|
||||||
_currentAuth.accessToken = "";
|
_currentAuth.accessToken = "";
|
||||||
|
@ -70,7 +70,7 @@ bool DomainAccountManager::hasLogIn() {
|
||||||
return !_currentAuth.authURL.isEmpty();
|
return !_currentAuth.authURL.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DomainAccountManager::isLoggedIn() {
|
bool DomainAccountManager::isLoggedIn() {
|
||||||
return !_currentAuth.authURL.isEmpty() && hasValidAccessToken();
|
return !_currentAuth.authURL.isEmpty() && hasValidAccessToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ void DomainAccountManager::requestAccessToken(const QString& username, const QSt
|
||||||
formData.append("grant_type=password&");
|
formData.append("grant_type=password&");
|
||||||
formData.append("username=" + QUrl::toPercentEncoding(username) + "&");
|
formData.append("username=" + QUrl::toPercentEncoding(username) + "&");
|
||||||
formData.append("password=" + QUrl::toPercentEncoding(password) + "&");
|
formData.append("password=" + QUrl::toPercentEncoding(password) + "&");
|
||||||
formData.append("client_id=" + _currentAuth.clientID);
|
formData.append("client_id=" + _currentAuth.clientID.toUtf8());
|
||||||
|
|
||||||
request.setUrl(_currentAuth.authURL);
|
request.setUrl(_currentAuth.authURL);
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ bool DomainAccountManager::hasValidAccessToken() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ####### TODO
|
// ####### TODO
|
||||||
|
|
||||||
// if (!_isWaitingForTokenRefresh && needsToRefreshToken()) {
|
// if (!_isWaitingForTokenRefresh && needsToRefreshToken()) {
|
||||||
// refreshAccessToken();
|
// refreshAccessToken();
|
||||||
// }
|
// }
|
||||||
|
@ -184,18 +184,18 @@ void DomainAccountManager::setTokensFromJSON(const QJsonObject& jsonObject, cons
|
||||||
bool DomainAccountManager::checkAndSignalForAccessToken() {
|
bool DomainAccountManager::checkAndSignalForAccessToken() {
|
||||||
bool hasToken = hasValidAccessToken();
|
bool hasToken = hasValidAccessToken();
|
||||||
|
|
||||||
// ####### TODO: Handle hasToken == true.
|
// ####### TODO: Handle hasToken == true.
|
||||||
// It causes the login dialog not to display (OK) but somewhere the domain server needs to be sent it (and if domain server
|
// It causes the login dialog not to display (OK) but somewhere the domain server needs to be sent it (and if domain server
|
||||||
// gets error when trying to use it then user should be prompted to login).
|
// gets error when trying to use it then user should be prompted to login).
|
||||||
hasToken = false;
|
hasToken = false;
|
||||||
|
|
||||||
if (!hasToken) {
|
if (!hasToken) {
|
||||||
// Emit a signal so somebody can call back to us and request an access token given a user name and password.
|
// Emit a signal so somebody can call back to us and request an access token given a user name and password.
|
||||||
|
|
||||||
// Dialog can be hidden immediately after showing if we've just teleported to the domain, unless the signal is delayed.
|
// Dialog can be hidden immediately after showing if we've just teleported to the domain, unless the signal is delayed.
|
||||||
auto domain = _currentAuth.authURL.host();
|
auto domain = _currentAuth.authURL.host();
|
||||||
QTimer::singleShot(500, this, [this, domain] {
|
QTimer::singleShot(500, this, [this, domain] {
|
||||||
emit this->authRequired(domain);
|
emit this->authRequired(domain);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall
|
||||||
// Adding the action name
|
// Adding the action name
|
||||||
QHttpPart actionPart;
|
QHttpPart actionPart;
|
||||||
actionPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"action_name\"");
|
actionPart.setHeader(QNetworkRequest::ContentDispositionHeader, "form-data; name=\"action_name\"");
|
||||||
actionPart.setBody(QByteArray().append(action));
|
actionPart.setBody(QByteArray().append(action.toUtf8()));
|
||||||
multipart->append(actionPart);
|
multipart->append(actionPart);
|
||||||
|
|
||||||
// Log the local-time that this event was logged
|
// Log the local-time that this event was logged
|
||||||
|
|
|
@ -63,11 +63,11 @@ bool OctreeUtils::RawOctreeData::readOctreeDataInfoFromFile(QString path) {
|
||||||
QByteArray OctreeUtils::RawOctreeData::toByteArray() {
|
QByteArray OctreeUtils::RawOctreeData::toByteArray() {
|
||||||
QByteArray jsonString;
|
QByteArray jsonString;
|
||||||
|
|
||||||
jsonString += QString("{\n \"DataVersion\": %1,\n").arg(dataVersion);
|
jsonString += QString("{\n \"DataVersion\": %1,\n").arg(dataVersion).toUtf8();
|
||||||
|
|
||||||
writeSubclassData(jsonString);
|
writeSubclassData(jsonString);
|
||||||
|
|
||||||
jsonString += QString(",\n \"Id\": \"%1\",\n \"Version\": %2\n}").arg(id.toString()).arg(version);
|
jsonString += QString(",\n \"Id\": \"%1\",\n \"Version\": %2\n}").arg(id.toString()).arg(version).toUtf8();
|
||||||
|
|
||||||
return jsonString;
|
return jsonString;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue