Changeset View
Changeset View
Standalone View
Standalone View
src/core/job_error.cpp
Show All 14 Lines | 1 | /* This file is part of the KDE libraries | |||
---|---|---|---|---|---|
15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 15 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
16 | Boston, MA 02110-1301, USA. | 16 | Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | #include "job.h" | 19 | #include "job.h" | ||
20 | #include "kioglobal_p.h" | 20 | #include "kioglobal_p.h" | ||
21 | #include <kprotocolmanager.h> | 21 | #include <kprotocolmanager.h> | ||
22 | #include <klocalizedstring.h> | 22 | #include <klocalizedstring.h> | ||
23 | #include <KStringHandler> | ||||
24 | | ||||
23 | #include <QUrl> | 25 | #include <QUrl> | ||
24 | #include <QDateTime> | 26 | #include <QDateTime> | ||
25 | #include <QDataStream> | 27 | #include <QDataStream> | ||
26 | #include <sys/stat.h> // S_IRUSR etc | 28 | #include <sys/stat.h> // S_IRUSR etc | ||
27 | 29 | | |||
30 | static const int maxFilePathLength = 80; | ||||
elvisangelaccio: Maybe it's worth using the `s_` prefix here. | |||||
31 | | ||||
28 | QString KIO::Job::errorString() const | 32 | QString KIO::Job::errorString() const | ||
29 | { | 33 | { | ||
30 | return KIO::buildErrorString(error(), errorText()); | 34 | return KIO::buildErrorString(error(), errorText()); | ||
31 | } | 35 | } | ||
32 | 36 | | |||
33 | KIOCORE_EXPORT QString KIO::buildErrorString(int errorCode, const QString &errorText) | 37 | KIOCORE_EXPORT QString KIO::buildErrorString(int errorCode, const QString &errorText) | ||
34 | { | 38 | { | ||
35 | QString result; | 39 | QString result; | ||
36 | 40 | | |||
37 | switch (errorCode) { | 41 | switch (errorCode) { | ||
38 | case KIO::ERR_CANNOT_OPEN_FOR_READING: | 42 | case KIO::ERR_CANNOT_OPEN_FOR_READING: | ||
39 | result = i18n("Could not read %1.", errorText); | 43 | result = i18n("Could not read %1.", errorText); | ||
40 | break; | 44 | break; | ||
41 | case KIO::ERR_CANNOT_OPEN_FOR_WRITING: | 45 | case KIO::ERR_CANNOT_OPEN_FOR_WRITING: | ||
42 | result = i18n("Could not write to %1.", errorText); | 46 | result = i18n("Could not write to %1.", KStringHandler::csqueeze(errorText, maxFilePathLength)); | ||
43 | break; | 47 | break; | ||
44 | case KIO::ERR_CANNOT_LAUNCH_PROCESS: | 48 | case KIO::ERR_CANNOT_LAUNCH_PROCESS: | ||
45 | result = i18n("Could not start process %1.", errorText); | 49 | result = i18n("Could not start process %1.", errorText); | ||
46 | break; | 50 | break; | ||
47 | case KIO::ERR_INTERNAL: | 51 | case KIO::ERR_INTERNAL: | ||
48 | result = i18n("Internal Error\nPlease send a full bug report at http://bugs.kde.org\n%1", errorText); | 52 | result = i18n("Internal Error\nPlease send a full bug report at http://bugs.kde.org\n%1", errorText); | ||
49 | break; | 53 | break; | ||
50 | case KIO::ERR_MALFORMED_URL: | 54 | case KIO::ERR_MALFORMED_URL: | ||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | 139 | case KIO::ERR_CANNOT_LOGIN: | |||
137 | break; | 141 | break; | ||
138 | case KIO::ERR_CANNOT_STAT: | 142 | case KIO::ERR_CANNOT_STAT: | ||
139 | result = i18n("Could not access %1.", errorText); | 143 | result = i18n("Could not access %1.", errorText); | ||
140 | break; | 144 | break; | ||
141 | case KIO::ERR_CANNOT_CLOSEDIR: | 145 | case KIO::ERR_CANNOT_CLOSEDIR: | ||
142 | result = i18n("Could not terminate listing %1.", errorText); | 146 | result = i18n("Could not terminate listing %1.", errorText); | ||
143 | break; | 147 | break; | ||
144 | case KIO::ERR_CANNOT_MKDIR: | 148 | case KIO::ERR_CANNOT_MKDIR: | ||
145 | result = i18n("Could not make folder %1.", errorText); | 149 | result = i18n("Could not make folder %1.", KStringHandler::csqueeze(errorText, maxFilePathLength)); | ||
146 | break; | 150 | break; | ||
147 | case KIO::ERR_CANNOT_RMDIR: | 151 | case KIO::ERR_CANNOT_RMDIR: | ||
148 | result = i18n("Could not remove folder %1.", errorText); | 152 | result = i18n("Could not remove folder %1.", errorText); | ||
149 | break; | 153 | break; | ||
150 | case KIO::ERR_CANNOT_RESUME: | 154 | case KIO::ERR_CANNOT_RESUME: | ||
151 | result = i18n("Could not resume file %1.", errorText); | 155 | result = i18n("Could not resume file %1.", errorText); | ||
152 | break; | 156 | break; | ||
153 | case KIO::ERR_CANNOT_RENAME: | 157 | case KIO::ERR_CANNOT_RENAME: | ||
154 | result = i18n("Could not rename file %1.", errorText); | 158 | result = i18n("Could not rename file %1.", KStringHandler::csqueeze(errorText, maxFilePathLength)); | ||
155 | break; | 159 | break; | ||
156 | case KIO::ERR_CANNOT_CHMOD: | 160 | case KIO::ERR_CANNOT_CHMOD: | ||
157 | result = i18n("Could not change permissions for %1.", errorText); | 161 | result = i18n("Could not change permissions for %1.", errorText); | ||
158 | break; | 162 | break; | ||
159 | case KIO::ERR_CANNOT_CHOWN: | 163 | case KIO::ERR_CANNOT_CHOWN: | ||
160 | result = i18n("Could not change ownership for %1.", errorText); | 164 | result = i18n("Could not change ownership for %1.", errorText); | ||
161 | break; | 165 | break; | ||
162 | case KIO::ERR_CANNOT_DELETE: | 166 | case KIO::ERR_CANNOT_DELETE: | ||
▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Line(s) | 401 | causes << i18n("You may not have permissions to read the file or open " | |||
398 | "the folder.") << cLocked << cHardware; | 402 | "the folder.") << cLocked << cHardware; | ||
399 | solutions << sAccess << sQuerylock << sSysadmin; | 403 | solutions << sAccess << sQuerylock << sSysadmin; | ||
400 | break; | 404 | break; | ||
401 | 405 | | |||
402 | case KIO::ERR_CANNOT_OPEN_FOR_WRITING: | 406 | case KIO::ERR_CANNOT_OPEN_FOR_WRITING: | ||
403 | errorName = i18n("Cannot Open Resource For Writing"); | 407 | errorName = i18n("Cannot Open Resource For Writing"); | ||
404 | description = i18n("This means that the file, <strong>%1</strong>, could " | 408 | description = i18n("This means that the file, <strong>%1</strong>, could " | ||
405 | "not be written to as requested, because access with permission to " | 409 | "not be written to as requested, because access with permission to " | ||
406 | "write could not be obtained.", filename); | 410 | "write could not be obtained.", KStringHandler::csqueeze(filename, maxFilePathLength)); | ||
407 | causes << cAccess << cLocked << cHardware; | 411 | causes << cAccess << cLocked << cHardware; | ||
408 | solutions << sAccess << sQuerylock << sSysadmin; | 412 | solutions << sAccess << sQuerylock << sSysadmin; | ||
409 | break; | 413 | break; | ||
410 | 414 | | |||
411 | case KIO::ERR_CANNOT_LAUNCH_PROCESS: | 415 | case KIO::ERR_CANNOT_LAUNCH_PROCESS: | ||
412 | errorName = i18n("Cannot Launch Process required by the %1 Protocol", protocol); | 416 | errorName = i18n("Cannot Launch Process required by the %1 Protocol", protocol); | ||
413 | techName = i18n("Unable to Launch Process"); | 417 | techName = i18n("Unable to Launch Process"); | ||
414 | description = i18n("The program on your computer which provides access " | 418 | description = i18n("The program on your computer which provides access " | ||
▲ Show 20 Lines • Show All 411 Lines • ▼ Show 20 Line(s) | 829 | causes << i18n("The protocol, or the server, may not support file " | |||
826 | "resuming."); | 830 | "resuming."); | ||
827 | solutions << i18n("Retry the request without attempting to resume " | 831 | solutions << i18n("Retry the request without attempting to resume " | ||
828 | "transfer."); | 832 | "transfer."); | ||
829 | break; | 833 | break; | ||
830 | 834 | | |||
831 | case KIO::ERR_CANNOT_RENAME: | 835 | case KIO::ERR_CANNOT_RENAME: | ||
832 | errorName = i18n("Could Not Rename Resource"); | 836 | errorName = i18n("Could Not Rename Resource"); | ||
833 | description = i18n("An attempt to rename the specified resource " | 837 | description = i18n("An attempt to rename the specified resource " | ||
834 | "<strong>%1</strong> failed.", url); | 838 | "<strong>%1</strong> failed.", KStringHandler::csqueeze(url, maxFilePathLength)); | ||
835 | causes << cAccess << cExists; | 839 | causes << cAccess << cExists; | ||
836 | if (!isSlaveNetwork) { | 840 | if (!isSlaveNetwork) { | ||
837 | causes << cProtocol; | 841 | causes << cProtocol; | ||
838 | } | 842 | } | ||
839 | solutions << sAccess << sExists; | 843 | solutions << sAccess << sExists; | ||
840 | break; | 844 | break; | ||
841 | 845 | | |||
842 | case KIO::ERR_CANNOT_CHMOD: | 846 | case KIO::ERR_CANNOT_CHMOD: | ||
▲ Show 20 Lines • Show All 289 Lines • Show Last 20 Lines |
Maybe it's worth using the s_ prefix here.