summaryrefslogtreecommitdiffstats
path: root/src/libs/installer/downloadfiletask.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2014-10-31 17:08:22 +0100
committerKarsten Heimrich <karsten.heimrich@theqtcompany.com>2014-11-18 15:49:31 +0100
commitb303e47d1c073d60d7b95adeda8feb079fa0ec34 (patch)
tree1575cafc30df19f404d452402ec95206aaacb303 /src/libs/installer/downloadfiletask.cpp
parente801f4d79c361c5106069f80cff005faafedab8b (diff)
Translate exception messages in DownloadFileTask
All messages will be also shown in the GUI, and therefore should be translated. Change-Id: Id8e372f71672e392c2a8c55f19b73188f4b942c8 Reviewed-by: Niels Weber <niels.weber@theqtcompany.com> Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com> Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Diffstat (limited to 'src/libs/installer/downloadfiletask.cpp')
-rw-r--r--src/libs/installer/downloadfiletask.cpp60
1 files changed, 34 insertions, 26 deletions
diff --git a/src/libs/installer/downloadfiletask.cpp b/src/libs/installer/downloadfiletask.cpp
index fe5551539..bbb3cc4e3 100644
--- a/src/libs/installer/downloadfiletask.cpp
+++ b/src/libs/installer/downloadfiletask.cpp
@@ -112,8 +112,10 @@ void Downloader::onReadyRead()
const Data &data = m_downloads[reply];
if (!data.file->isOpen()) {
- m_futureInterface->reportException(FileTaskException(QString::fromLatin1("Target '%1' not "
- "open for write. Error: %2.").arg(data.file->fileName(), data.file->errorString())));
+ //: %2 is a sentence describing the error.
+ m_futureInterface->reportException(
+ FileTaskException(tr("Target '%1' not open for write. Error: %2.").arg(
+ data.file->fileName(), data.file->errorString())));
return;
}
@@ -129,9 +131,10 @@ void Downloader::onReadyRead()
while (written < read) {
const qint64 toWrite = data.file->write(buffer.constData() + written, read - written);
if (toWrite < 0) {
- m_futureInterface->reportException(FileTaskException(QString::fromLatin1("Writing "
- "to target '%1' failed. Error: %2.").arg(data.file->fileName(),
- data.file->errorString())));
+ //: %2 is a sentence describing the error.
+ m_futureInterface->reportException(
+ FileTaskException(tr("Writing to target '%1' failed. Error: %2.").arg(
+ data.file->fileName(), data.file->errorString())));
return;
}
written += toWrite;
@@ -179,8 +182,8 @@ void Downloader::onFinished(QNetworkReply *reply)
reply->deleteLater();
return;
} else {
- m_futureInterface->reportException(FileTaskException(QString::fromLatin1("Redirect"
- " loop detected '%1'.").arg(url.toString())));
+ m_futureInterface->reportException(
+ FileTaskException(tr("Redirect loop detected '%1'.").arg(url.toString())));
return;
}
}
@@ -196,8 +199,9 @@ void Downloader::onFinished(QNetworkReply *reply)
const QByteArray expectedCheckSum = data.taskItem.value(TaskRole::Checksum).toByteArray();
if (!expectedCheckSum.isEmpty()) {
if (expectedCheckSum != data.observer->checkSum().toHex()) {
- m_futureInterface->reportException(FileTaskException(QString::fromLatin1("Checksum"
- " mismatch detected '%1'.").arg(reply->url().toString())));
+ m_futureInterface->reportException(
+ FileTaskException(tr("Checksum mismatch detected '%1'.").arg(
+ reply->url().toString())));
}
}
m_futureInterface->reportResult(FileTaskResult(filename, data.observer->checkSum(), data.taskItem));
@@ -222,15 +226,14 @@ void Downloader::onError(QNetworkReply::NetworkError error)
QNetworkReply *const reply = qobject_cast<QNetworkReply *>(sender());
if (reply) {
const Data &data = m_downloads[reply];
+ //: %2 is a sentence describing the error
m_futureInterface->reportException(
- FileTaskException(
- QString::fromLatin1("Network error while downloading '%1': %2.").arg(
- data.taskItem.source(), reply->errorString())));
+ FileTaskException(tr("Network error while downloading '%1': %2.").arg(
+ data.taskItem.source(), reply->errorString())));
} else {
+ //: %1 is a sentence describing the error
m_futureInterface->reportException(
- FileTaskException(
- QString::fromLatin1("Unknown network error while downloading: %1.").arg(
- error)));
+ FileTaskException(tr("Unknown network error while downloading: %1.").arg(error)));
}
}
@@ -266,9 +269,9 @@ void Downloader::onAuthenticationRequired(QNetworkReply *reply, QAuthenticator *
authenticator->setPassword(auth.password());
item->insert(TaskRole::Authenticator, QVariant()); // clear so we fail on next call
} else {
- m_futureInterface->reportException(FileTaskException(QString::fromLatin1("Could not "
- "authenticate using the provided credentials. Source: '%1'.").arg(reply->url()
- .toString())));
+ m_futureInterface->reportException(
+ FileTaskException(tr("Could not authenticate using the provided credentials. "
+ "Source: '%1'.").arg(reply->url().toString())));
}
}
@@ -280,8 +283,8 @@ bool Downloader::testCanceled()
// TODO: figure out how to implement pause and resume
if (m_futureInterface->isPaused()) {
m_futureInterface->togglePaused(); // Note: this will trigger cancel
- m_futureInterface->reportException(FileTaskException(QLatin1String("Pause and resume not "
- "supported by network transfers.")));
+ m_futureInterface->reportException(
+ FileTaskException(tr("Pause and resume not supported by network transfers.")));
}
return m_futureInterface->isCanceled();
}
@@ -290,8 +293,10 @@ QNetworkReply *Downloader::startDownload(const FileTaskItem &item)
{
QUrl const source = item.source();
if (!source.isValid()) {
- m_futureInterface->reportException(FileTaskException(QString::fromLatin1("Invalid source "
- "'%1'. Error: %2.").arg(source.toString(), source.errorString())));
+ //: %2 is a sentence describing the error
+ m_futureInterface->reportException(
+ FileTaskException(tr("Invalid source '%1'. Error: %2.").arg(
+ source.toString(), source.errorString())));
return 0;
}
@@ -306,14 +311,17 @@ QNetworkReply *Downloader::startDownload(const FileTaskItem &item)
}
if (file->exists() && (!QFileInfo(file->fileName()).isFile())) {
- m_futureInterface->reportException(FileTaskException(QString::fromLatin1("Target file "
- "'%1' already exists but is not a file.").arg(file->fileName())));
+ m_futureInterface->reportException(
+ FileTaskException(tr("Target file '%1' already exists but is not a file.").arg(
+ file->fileName())));
return 0;
}
if (!file->open(QIODevice::WriteOnly | QIODevice::Truncate)) {
- m_futureInterface->reportException(FileTaskException(QString::fromLatin1("Could not open "
- "target '%1' for write. Error: %2.").arg(file->fileName(), file->errorString())));
+ //: %2 is a sentence describing the error
+ m_futureInterface->reportException(
+ FileTaskException(tr("Could not open target '%1' for write. Error: %2.").arg(
+ file->fileName(), file->errorString())));
return 0;
}