Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace QString::fromAscii by QString::fromLatin1 #356

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
228 changes: 114 additions & 114 deletions src/MEGASync/MegaApplication.cpp

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/MEGASync/MegaApplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ class TransferMetaData
{
public:
TransferMetaData(int direction, int total = 0, int pending = 0, QString path = QString())
: transferDirection(direction), totalTransfers(total), pendingTransfers(pending),
localPath(path), totalFiles(0), totalFolders(0),
: totalTransfers(total), pendingTransfers(pending),
totalFiles(0), totalFolders(0),
transfersFileOK(0), transfersFolderOK(0),
transfersFailed(0), transfersCancelled(0) {}
transfersFailed(0), transfersCancelled(0),
transferDirection(direction), localPath(path) {}

int totalTransfers;
int pendingTransfers;
Expand Down
24 changes: 12 additions & 12 deletions src/MEGASync/control/CrashHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ void CrashHandler::tryReboot()
appPath.cdUp();
appPath.cdUp();

args.append(QString::fromAscii("-n"));
args.append(QString::fromLatin1("-n"));
args.append(appPath.absolutePath());
QProcess::startDetached(launchCommand, args);
#endif
Expand Down Expand Up @@ -475,7 +475,7 @@ QStringList CrashHandler::getPendingCrashReports()
for (int i = 0; i < fiList.size(); i++)
{
QFile file(fiList[i].absoluteFilePath());
if (!file.fileName().endsWith(QString::fromAscii(".dmp")))
if (!file.fileName().endsWith(QString::fromLatin1(".dmp")))
{
continue;
}
Expand All @@ -493,18 +493,18 @@ QStringList CrashHandler::getPendingCrashReports()
QString crashReport = QString::fromUtf8(file.readAll());
file.close();

QStringList lines = crashReport.split(QString::fromAscii("\n"));
QStringList lines = crashReport.split(QString::fromLatin1("\n"));
if ((lines.size()<3)
|| (lines.at(0) != QString::fromAscii("MEGAprivate ERROR DUMP"))
|| (!lines.at(1).startsWith(QString::fromAscii("Application: ") + QApplication::applicationName()))
|| (!lines.at(2).startsWith(QString::fromAscii("Version code: ") + QString::number(Preferences::VERSION_CODE))))
|| (lines.at(0) != QString::fromLatin1("MEGAprivate ERROR DUMP"))
|| (!lines.at(1).startsWith(QString::fromLatin1("Application: ") + QApplication::applicationName()))
|| (!lines.at(2).startsWith(QString::fromLatin1("Version code: ") + QString::number(Preferences::VERSION_CODE))))
{
MegaApi::log(MegaApi::LOG_LEVEL_WARNING, QString::fromUtf8("Invalid or outdated dump file: %1").arg(file.fileName()).toUtf8().constData());
file.remove();
continue;
}

QString crashHash = QString::fromAscii(QCryptographicHash::hash(crashReport.toUtf8(),QCryptographicHash::Md5).toHex());
QString crashHash = QString::fromLatin1(QCryptographicHash::hash(crashReport.toUtf8(),QCryptographicHash::Md5).toHex());
if (!previousCrashes.contains(crashHash))
{
MegaApi::log(MegaApi::LOG_LEVEL_INFO, QString::fromUtf8("New crash file: %1 Hash: %2")
Expand Down Expand Up @@ -535,14 +535,14 @@ void CrashHandler::sendPendingCrashReports(QString userMessage)
}

crashes.append(userMessage);
QString postString = crashes.join(QString::fromAscii("------------------------------\n"));
postString.append(QString::fromAscii("\n------------------------------\n"));
QString postString = crashes.join(QString::fromLatin1("------------------------------\n"));
postString.append(QString::fromLatin1("\n------------------------------\n"));

networkManager = new QNetworkAccessManager();
connect(networkManager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(onPostFinished(QNetworkReply*)), Qt::UniqueConnection);
request.setUrl(Preferences::CRASH_REPORT_URL);
request.setHeader(QNetworkRequest::ContentTypeHeader, QString::fromAscii("application/x-www-form-urlencoded"));
request.setHeader(QNetworkRequest::ContentTypeHeader, QString::fromLatin1("application/x-www-form-urlencoded"));

MegaApi::log(MegaApi::LOG_LEVEL_INFO, "Sending crash reports");
networkManager->post(request, postString.toUtf8());
Expand All @@ -556,7 +556,7 @@ void CrashHandler::discardPendingCrashReports()
QStringList previousCrashes = preferences->getPreviousCrashes();
for (int i = 0; i < crashes.size(); i++)
{
QString crashHash = QString::fromAscii(QCryptographicHash::hash(crashes[i].toUtf8(),QCryptographicHash::Md5).toHex());
QString crashHash = QString::fromLatin1(QCryptographicHash::hash(crashes[i].toUtf8(),QCryptographicHash::Md5).toHex());
if (!previousCrashes.contains(crashHash))
{
previousCrashes.append(crashHash);
Expand Down Expand Up @@ -607,7 +607,7 @@ void CrashHandler::deletePendingCrashReports()
for (int i = 0; i < fiList.size(); i++)
{
QFileInfo fi = fiList[i];
if (fi.fileName().endsWith(QString::fromAscii(".dmp")))
if (fi.fileName().endsWith(QString::fromLatin1(".dmp")))
{
QFile::remove(fi.absoluteFilePath());
}
Expand Down
6 changes: 3 additions & 3 deletions src/MEGASync/control/EncryptedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void EncryptedSettings::remove(const QString &key)
{
if (!key.length())
{
QSettings::remove(QString::fromAscii(""));
QSettings::remove(QString::fromLatin1(""));
}
else
{
Expand Down Expand Up @@ -110,7 +110,7 @@ QString EncryptedSettings::encrypt(const QString key, const QString value) const
QByteArray xValue = XOR(k, value.toUtf8());
QByteArray xKey = XOR(k, group().toAscii());
QByteArray xEncrypted = XOR(k, Platform::encrypt(xValue, xKey));
return QString::fromAscii(xEncrypted.toBase64());
return QString::fromLatin1(xEncrypted.toBase64());
}

QString EncryptedSettings::decrypt(const QString key, const QString value) const
Expand All @@ -132,5 +132,5 @@ QString EncryptedSettings::hash(const QString key) const
QByteArray xPath = XOR(encryptionKey, (key+group()).toUtf8());
QByteArray keyHash = QCryptographicHash::hash(xPath, QCryptographicHash::Sha1);
QByteArray xKeyHash = XOR(key.toUtf8(), keyHash);
return QString::fromAscii(xKeyHash.toHex());
return QString::fromLatin1(xKeyHash.toHex());
}
8 changes: 4 additions & 4 deletions src/MEGASync/control/ExportProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ void ExportProcessor::requestLinks()
if (mode == MODE_PATHS)
{
#ifdef WIN32
if (!fileList[i].startsWith(QString::fromAscii("\\\\")))
if (!fileList[i].startsWith(QString::fromLatin1("\\\\")))
{
fileList[i].insert(0, QString::fromAscii("\\\\?\\"));
fileList[i].insert(0, QString::fromLatin1("\\\\?\\"));
}

string tmpPath((const char*)fileList[i].utf16(), fileList[i].size()*sizeof(wchar_t));
Expand Down Expand Up @@ -94,8 +94,8 @@ void ExportProcessor::onRequestFinish(MegaApi *, MegaRequest *request, MegaError
}
else
{
publicLinks.append(QString::fromAscii(request->getLink()));
validPublicLinks.append(QString::fromAscii(request->getLink()));
publicLinks.append(QString::fromLatin1(request->getLink()));
validPublicLinks.append(QString::fromLatin1(request->getLink()));
importSuccess++;
}

Expand Down
8 changes: 4 additions & 4 deletions src/MEGASync/control/HTTPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void HTTPServer::onTransferDataUpdate(MegaHandle handle, int state, long long pr
if (tData->tPath.isEmpty() && !localPath.isEmpty())
{
#ifdef WIN32
if (localPath.startsWith(QString::fromAscii("\\\\?\\")))
if (localPath.startsWith(QString::fromLatin1("\\\\?\\")))
{
localPath = localPath.mid(4);
}
Expand Down Expand Up @@ -235,7 +235,7 @@ void HTTPServer::readClient()
{
QStringList tokens = request->data.split(QString::fromUtf8("\r\n\r\n"));
QStringList headers = tokens[0].split(QString::fromUtf8("\r\n"));
if (!headers.size() || !headers[0].startsWith(QString::fromAscii("POST")))
if (!headers.size() || !headers[0].startsWith(QString::fromLatin1("POST")))
{
MegaApi::log(MegaApi::LOG_LEVEL_WARNING, "Method not allowed for webclient request");
rejectRequest(socket, QString::fromUtf8("405 Method Not Allowed"));
Expand Down Expand Up @@ -460,9 +460,9 @@ void HTTPServer::processRequest(QAbstractSocket *socket, HTTPRequest request)
int end;
bool firstnode = true;

while (request.data[start] == QChar::fromAscii('{'))
while (request.data[start] == QChar::fromLatin1('{'))
{
end = request.data.indexOf(QChar::fromAscii('}'), start);
end = request.data.indexOf(QChar::fromLatin1('}'), start);
if (end < 0)
{
MegaApi::log(MegaApi::LOG_LEVEL_ERROR, "Error parsing webclient request");
Expand Down
4 changes: 2 additions & 2 deletions src/MEGASync/control/LinkProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ void LinkProcessor::onRequestFinish(MegaApi *api, MegaRequest *request, MegaErro
if (e->getErrorCode() == MegaError::API_OK)
{
MegaNode *rootNode = NULL;
if (linkList[currentIndex].count(QChar::fromAscii('!')) == 3)
if (linkList[currentIndex].count(QChar::fromLatin1('!')) == 3)
{
QStringList linkparts = linkList[currentIndex].split(QChar::fromAscii('!'), QString::KeepEmptyParts);
QStringList linkparts = linkList[currentIndex].split(QChar::fromLatin1('!'), QString::KeepEmptyParts);
MegaHandle handle = MegaApi::base64ToHandle(linkparts.last().toUtf8().constData());
rootNode = megaApiFolders->getNodeByHandle(handle);
}
Expand Down
4 changes: 2 additions & 2 deletions src/MEGASync/control/MegaDownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void MegaDownloader::download(MegaNode *parent, QString path, QString appData)
bool MegaDownloader::processDownloadQueue(QQueue<MegaNode *> *downloadQueue, QString path, unsigned long long appDataId)
{
QDir dir(path);
if (!dir.exists() && !dir.mkpath(QString::fromAscii(".")))
if (!dir.exists() && !dir.mkpath(QString::fromLatin1(".")))
{
qDeleteAll(*downloadQueue);
downloadQueue->clear();
Expand Down Expand Up @@ -113,7 +113,7 @@ void MegaDownloader::download(MegaNode *parent, QFileInfo info, QString appData)
#ifndef WIN32
if (!megaApi->createLocalFolder(dir.toNativeSeparators(destPath).toUtf8().constData()))
#else
if (!dir.mkpath(QString::fromAscii(".")))
if (!dir.mkpath(QString::fromLatin1(".")))
#endif
{
return;
Expand Down
2 changes: 1 addition & 1 deletion src/MEGASync/control/MegaSyncLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void MegaSyncLogger::log(const char *time, int loglevel, const char *source, con
dataPath = Utilities::getDefaultBasePath();
}
#endif
filePath = dataPath + QDir::separator() + QString::fromAscii("MEGAsync.log");
filePath = dataPath + QDir::separator() + QString::fromLatin1("MEGAsync.log");
}

QFile file(filePath);
Expand Down
2 changes: 1 addition & 1 deletion src/MEGASync/control/MegaUploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void MegaUploader::upload(QFileInfo info, MegaNode *parent, unsigned long long a
string localPath = megaApi->getLocalPath(parent);
#ifdef WIN32
QString destPath = QDir::toNativeSeparators(QString::fromWCharArray((const wchar_t *)localPath.data()) + QDir::separator() + fileName);
if (destPath.startsWith(QString::fromAscii("\\\\?\\")))
if (destPath.startsWith(QString::fromLatin1("\\\\?\\")))
{
destPath = destPath.mid(4);
}
Expand Down
Loading