fix tricky regression noticed by Vyacheslav Tokarev on Google Reader.
[kdelibs.git] / kio / kio / global.cpp
blob711575771d45d9dc9ec5d977aa822b3aa087c2d6
1 /* This file is part of the KDE libraries
2 Copyright (C) 2000 David Faure <faure@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "global.h"
20 #include "job.h"
22 #include <config.h>
24 #include <kdebug.h>
25 #include <klocale.h>
26 #include <kglobal.h>
27 #include <kiconloader.h>
28 #include <kprotocolmanager.h>
29 #include <kmimetype.h>
30 #include <kdynamicjobtracker_p.h>
32 #include <QtCore/QByteArray>
33 #include <QtCore/QDate>
34 #include <QtGui/QTextDocument>
36 #include <sys/types.h>
37 #include <sys/wait.h>
38 #include <sys/uio.h>
40 #include <assert.h>
41 #include <signal.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <unistd.h>
45 #include <stdio.h>
47 K_GLOBAL_STATIC(KDynamicJobTracker, globalJobTracker)
49 // If someone wants the SI-standard prefixes kB/MB/GB/TB, I would recommend
50 // a hidden kconfig option and getting the code from #57240 into the same
51 // method, so that all KDE apps use the same unit, instead of letting each app decide.
53 KIO_EXPORT QString KIO::convertSize( KIO::filesize_t size )
55 return KGlobal::locale()->formatByteSize(size);
58 KIO_EXPORT QString KIO::convertSizeFromKiB( KIO::filesize_t kibSize )
60 return KGlobal::locale()->formatByteSize(kibSize * 1024);
63 KIO_EXPORT QString KIO::number( KIO::filesize_t size )
65 char charbuf[256];
66 sprintf(charbuf, "%lld", size);
67 return QLatin1String(charbuf);
70 KIO_EXPORT unsigned int KIO::calculateRemainingSeconds( KIO::filesize_t totalSize,
71 KIO::filesize_t processedSize, KIO::filesize_t speed )
73 if ( (speed != 0) && (totalSize != 0) )
74 return ( totalSize - processedSize ) / speed;
75 else
76 return 0;
79 KIO_EXPORT QString KIO::convertSeconds( unsigned int seconds )
81 unsigned int days = seconds / 86400;
82 unsigned int hours = (seconds - (days * 86400)) / 3600;
83 unsigned int mins = (seconds - (days * 86400) - (hours * 3600)) / 60;
84 seconds = (seconds - (days * 86400) - (hours * 3600) - (mins * 60));
86 const QTime time(hours, mins, seconds);
87 const QString timeStr( KGlobal::locale()->formatTime(time, true /*with seconds*/, true /*duration*/) );
88 if ( days > 0 )
89 return i18np("1 day %2", "%1 days %2", days, timeStr);
90 else
91 return timeStr;
94 KIO_EXPORT QTime KIO::calculateRemaining( KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed )
96 QTime remainingTime;
98 if ( speed != 0 ) {
99 KIO::filesize_t secs;
100 if ( totalSize == 0 ) {
101 secs = 0;
102 } else {
103 secs = ( totalSize - processedSize ) / speed;
105 if (secs >= (24*60*60)) // Limit to 23:59:59
106 secs = (24*60*60)-1;
107 int hr = secs / ( 60 * 60 );
108 int mn = ( secs - hr * 60 * 60 ) / 60;
109 int sc = ( secs - hr * 60 * 60 - mn * 60 );
111 remainingTime.setHMS( hr, mn, sc );
114 return remainingTime;
117 KIO_EXPORT QString KIO::itemsSummaryString(uint items, uint files, uint dirs, KIO::filesize_t size, bool showSize)
119 if ( files == 0 && dirs == 0 && items == 0 ) {
120 return i18np( "%1 Item", "%1 Items", 0 );
123 QString summary;
124 const QString foldersText = i18np( "1 Folder", "%1 Folders", dirs );
125 const QString filesText = i18np( "1 File", "%1 Files", files );
126 if ( files > 0 && dirs > 0 ) {
127 summary = showSize ?
128 i18nc( "folders, files (size)", "%1, %2 (%3)", foldersText, filesText, KIO::convertSize( size ) ) :
129 i18nc( "folders, files", "%1, %2", foldersText, filesText );
130 } else if ( files > 0 ) {
131 summary = showSize ? i18nc( "files (size)", "%1 (%2)", filesText, KIO::convertSize( size ) ) : filesText;
132 } else if ( dirs > 0 ) {
133 summary = foldersText;
136 if ( items > dirs + files ) {
137 const QString itemsText = i18np( "%1 Item", "%1 Items", items );
138 summary = summary.isEmpty() ? itemsText : i18nc( "items: folders, files (size)", "%1: %2", itemsText, summary );
141 return summary;
144 KIO_EXPORT QString KIO::encodeFileName( const QString & _str )
146 QString str( _str );
147 str.replace('/', QChar(0x2044)); // "Fraction slash"
148 return str;
151 KIO_EXPORT QString KIO::decodeFileName( const QString & _str )
153 // Nothing to decode. "Fraction slash" is fine in filenames.
154 return _str;
157 KIO_EXPORT QString KIO::Job::errorString() const
159 return KIO::buildErrorString(error(), errorText());
162 KIO_EXPORT QString KIO::buildErrorString(int errorCode, const QString &errorText)
164 QString result;
166 switch( errorCode )
168 case KIO::ERR_CANNOT_OPEN_FOR_READING:
169 result = i18n( "Could not read %1." , errorText );
170 break;
171 case KIO::ERR_CANNOT_OPEN_FOR_WRITING:
172 result = i18n( "Could not write to %1." , errorText );
173 break;
174 case KIO::ERR_CANNOT_LAUNCH_PROCESS:
175 result = i18n( "Could not start process %1." , errorText );
176 break;
177 case KIO::ERR_INTERNAL:
178 result = i18n( "Internal Error\nPlease send a full bug report at http://bugs.kde.org\n%1" , errorText );
179 break;
180 case KIO::ERR_MALFORMED_URL:
181 result = i18n( "Malformed URL %1." , errorText );
182 break;
183 case KIO::ERR_UNSUPPORTED_PROTOCOL:
184 result = i18n( "The protocol %1 is not supported." , errorText );
185 break;
186 case KIO::ERR_NO_SOURCE_PROTOCOL:
187 result = i18n( "The protocol %1 is only a filter protocol.", errorText );
188 break;
189 case KIO::ERR_UNSUPPORTED_ACTION:
190 result = errorText;
191 // result = i18n( "Unsupported action %1" ).arg( errorText );
192 break;
193 case KIO::ERR_IS_DIRECTORY:
194 result = i18n( "%1 is a folder, but a file was expected." , errorText );
195 break;
196 case KIO::ERR_IS_FILE:
197 result = i18n( "%1 is a file, but a folder was expected." , errorText );
198 break;
199 case KIO::ERR_DOES_NOT_EXIST:
200 result = i18n( "The file or folder %1 does not exist." , errorText );
201 break;
202 case KIO::ERR_FILE_ALREADY_EXIST:
203 result = i18n( "A file named %1 already exists." , errorText );
204 break;
205 case KIO::ERR_DIR_ALREADY_EXIST:
206 result = i18n( "A folder named %1 already exists." , errorText );
207 break;
208 case KIO::ERR_UNKNOWN_HOST:
209 result = errorText.isEmpty() ? i18n( "No hostname specified." ) : i18n( "Unknown host %1" , errorText );
210 break;
211 case KIO::ERR_ACCESS_DENIED:
212 result = i18n( "Access denied to %1." , errorText );
213 break;
214 case KIO::ERR_WRITE_ACCESS_DENIED:
215 result = i18n( "Access denied.\nCould not write to %1." , errorText );
216 break;
217 case KIO::ERR_CANNOT_ENTER_DIRECTORY:
218 result = i18n( "Could not enter folder %1." , errorText );
219 break;
220 case KIO::ERR_PROTOCOL_IS_NOT_A_FILESYSTEM:
221 result = i18n( "The protocol %1 does not implement a folder service." , errorText );
222 break;
223 case KIO::ERR_CYCLIC_LINK:
224 result = i18n( "Found a cyclic link in %1." , errorText );
225 break;
226 case KIO::ERR_USER_CANCELED:
227 // Do nothing in this case. The user doesn't need to be told what he just did.
228 break;
229 case KIO::ERR_CYCLIC_COPY:
230 result = i18n( "Found a cyclic link while copying %1." , errorText );
231 break;
232 case KIO::ERR_COULD_NOT_CREATE_SOCKET:
233 result = i18n( "Could not create socket for accessing %1." , errorText );
234 break;
235 case KIO::ERR_COULD_NOT_CONNECT:
236 result = i18n( "Could not connect to host %1." , errorText.isEmpty() ? QLatin1String("localhost") : errorText );
237 break;
238 case KIO::ERR_CONNECTION_BROKEN:
239 result = i18n( "Connection to host %1 is broken." , errorText );
240 break;
241 case KIO::ERR_NOT_FILTER_PROTOCOL:
242 result = i18n( "The protocol %1 is not a filter protocol." , errorText );
243 break;
244 case KIO::ERR_COULD_NOT_MOUNT:
245 result = i18n( "Could not mount device.\nThe reported error was:\n%1" , errorText );
246 break;
247 case KIO::ERR_COULD_NOT_UNMOUNT:
248 result = i18n( "Could not unmount device.\nThe reported error was:\n%1" , errorText );
249 break;
250 case KIO::ERR_COULD_NOT_READ:
251 result = i18n( "Could not read file %1." , errorText );
252 break;
253 case KIO::ERR_COULD_NOT_WRITE:
254 result = i18n( "Could not write to file %1." , errorText );
255 break;
256 case KIO::ERR_COULD_NOT_BIND:
257 result = i18n( "Could not bind %1." , errorText );
258 break;
259 case KIO::ERR_COULD_NOT_LISTEN:
260 result = i18n( "Could not listen %1." , errorText );
261 break;
262 case KIO::ERR_COULD_NOT_ACCEPT:
263 result = i18n( "Could not accept %1." , errorText );
264 break;
265 case KIO::ERR_COULD_NOT_LOGIN:
266 result = errorText;
267 break;
268 case KIO::ERR_COULD_NOT_STAT:
269 result = i18n( "Could not access %1." , errorText );
270 break;
271 case KIO::ERR_COULD_NOT_CLOSEDIR:
272 result = i18n( "Could not terminate listing %1." , errorText );
273 break;
274 case KIO::ERR_COULD_NOT_MKDIR:
275 result = i18n( "Could not make folder %1." , errorText );
276 break;
277 case KIO::ERR_COULD_NOT_RMDIR:
278 result = i18n( "Could not remove folder %1." , errorText );
279 break;
280 case KIO::ERR_CANNOT_RESUME:
281 result = i18n( "Could not resume file %1." , errorText );
282 break;
283 case KIO::ERR_CANNOT_RENAME:
284 result = i18n( "Could not rename file %1." , errorText );
285 break;
286 case KIO::ERR_CANNOT_CHMOD:
287 result = i18n( "Could not change permissions for %1." , errorText );
288 break;
289 case KIO::ERR_CANNOT_CHOWN:
290 result = i18n( "Could not change ownership for %1." , errorText );
291 break;
292 case KIO::ERR_CANNOT_DELETE:
293 result = i18n( "Could not delete file %1." , errorText );
294 break;
295 case KIO::ERR_SLAVE_DIED:
296 result = i18n( "The process for the %1 protocol died unexpectedly." , errorText );
297 break;
298 case KIO::ERR_OUT_OF_MEMORY:
299 result = i18n( "Error. Out of memory.\n%1" , errorText );
300 break;
301 case KIO::ERR_UNKNOWN_PROXY_HOST:
302 result = i18n( "Unknown proxy host\n%1" , errorText );
303 break;
304 case KIO::ERR_COULD_NOT_AUTHENTICATE:
305 result = i18n( "Authorization failed, %1 authentication not supported" , errorText );
306 break;
307 case KIO::ERR_ABORTED:
308 result = i18n( "User canceled action\n%1" , errorText );
309 break;
310 case KIO::ERR_INTERNAL_SERVER:
311 result = i18n( "Internal error in server\n%1" , errorText );
312 break;
313 case KIO::ERR_SERVER_TIMEOUT:
314 result = i18n( "Timeout on server\n%1" , errorText );
315 break;
316 case KIO::ERR_UNKNOWN:
317 result = i18n( "Unknown error\n%1" , errorText );
318 break;
319 case KIO::ERR_UNKNOWN_INTERRUPT:
320 result = i18n( "Unknown interrupt\n%1" , errorText );
321 break;
323 case KIO::ERR_CHECKSUM_MISMATCH:
324 if (errorText)
325 result = i18n( "Warning: MD5 Checksum for %1 does not match checksum returned from server" ).arg(errorText);
326 else
327 result = i18n( "Warning: MD5 Checksum for %1 does not match checksum returned from server" ).arg("document");
328 break;
330 case KIO::ERR_CANNOT_DELETE_ORIGINAL:
331 result = i18n( "Could not delete original file %1.\nPlease check permissions." , errorText );
332 break;
333 case KIO::ERR_CANNOT_DELETE_PARTIAL:
334 result = i18n( "Could not delete partial file %1.\nPlease check permissions." , errorText );
335 break;
336 case KIO::ERR_CANNOT_RENAME_ORIGINAL:
337 result = i18n( "Could not rename original file %1.\nPlease check permissions." , errorText );
338 break;
339 case KIO::ERR_CANNOT_RENAME_PARTIAL:
340 result = i18n( "Could not rename partial file %1.\nPlease check permissions." , errorText );
341 break;
342 case KIO::ERR_CANNOT_SYMLINK:
343 result = i18n( "Could not create symlink %1.\nPlease check permissions." , errorText );
344 break;
345 case KIO::ERR_NO_CONTENT:
346 result = errorText;
347 break;
348 case KIO::ERR_DISK_FULL:
349 result = i18n( "Could not write file %1.\nDisk full." , errorText );
350 break;
351 case KIO::ERR_IDENTICAL_FILES:
352 result = i18n( "The source and destination are the same file.\n%1" , errorText );
353 break;
354 case KIO::ERR_SLAVE_DEFINED:
355 result = errorText;
356 break;
357 case KIO::ERR_UPGRADE_REQUIRED:
358 result = i18n( "%1 is required by the server, but is not available." , errorText);
359 break;
360 case KIO::ERR_POST_DENIED:
361 result = i18n( "Access to restricted port in POST denied.");
362 break;
363 default:
364 result = i18n( "Unknown error code %1\n%2\nPlease send a full bug report at http://bugs.kde.org." , errorCode , errorText );
365 break;
368 return result;
371 KIO_EXPORT QString KIO::unsupportedActionErrorString(const QString &protocol, int cmd) {
372 switch (cmd) {
373 case CMD_CONNECT:
374 return i18n("Opening connections is not supported with the protocol %1." , protocol);
375 case CMD_DISCONNECT:
376 return i18n("Closing connections is not supported with the protocol %1." , protocol);
377 case CMD_STAT:
378 return i18n("Accessing files is not supported with the protocol %1.", protocol);
379 case CMD_PUT:
380 return i18n("Writing to %1 is not supported.", protocol);
381 case CMD_SPECIAL:
382 return i18n("There are no special actions available for protocol %1.", protocol);
383 case CMD_LISTDIR:
384 return i18n("Listing folders is not supported for protocol %1.", protocol);
385 case CMD_GET:
386 return i18n("Retrieving data from %1 is not supported.", protocol);
387 case CMD_MIMETYPE:
388 return i18n("Retrieving mime type information from %1 is not supported.", protocol);
389 case CMD_RENAME:
390 return i18n("Renaming or moving files within %1 is not supported.", protocol);
391 case CMD_SYMLINK:
392 return i18n("Creating symlinks is not supported with protocol %1.", protocol);
393 case CMD_COPY:
394 return i18n("Copying files within %1 is not supported.", protocol);
395 case CMD_DEL:
396 return i18n("Deleting files from %1 is not supported.", protocol);
397 case CMD_MKDIR:
398 return i18n("Creating folders is not supported with protocol %1.", protocol);
399 case CMD_CHMOD:
400 return i18n("Changing the attributes of files is not supported with protocol %1.", protocol);
401 case CMD_CHOWN:
402 return i18n("Changing the ownership of files is not supported with protocol %1.", protocol);
403 case CMD_SUBURL:
404 return i18n("Using sub-URLs with %1 is not supported.", protocol);
405 case CMD_MULTI_GET:
406 return i18n("Multiple get is not supported with protocol %1.", protocol);
407 case CMD_OPEN:
408 return i18n("Opening files is not supported with protocol %1.", protocol);
409 default:
410 return i18n("Protocol %1 does not support action %2.", protocol, cmd);
411 }/*end switch*/
414 KIO_EXPORT QStringList KIO::Job::detailedErrorStrings( const KUrl *reqUrl /*= 0L*/,
415 int method /*= -1*/ ) const
417 QString errorName, techName, description, ret2;
418 QStringList causes, solutions, ret;
420 QByteArray raw = rawErrorDetail( error(), errorText(), reqUrl, method );
421 QDataStream stream(raw);
423 stream >> errorName >> techName >> description >> causes >> solutions;
425 QString url, protocol, datetime;
426 if ( reqUrl ) {
427 url = Qt::escape(reqUrl->prettyUrl());
428 protocol = reqUrl->protocol();
429 } else {
430 url = i18nc("@info url", "(unknown)" );
433 datetime = KGlobal::locale()->formatDateTime( QDateTime::currentDateTime(),
434 KLocale::LongDate );
436 ret << errorName;
437 ret << i18nc( "@info %1 error name, %2 description",
438 "<qt><p><b>%1</b></p><p>%2</p></qt>", errorName, description);
440 ret2 = QLatin1String( "<qt>" );
441 if ( !techName.isEmpty() )
442 ret2 += QLatin1String( "<p>" ) + i18n( "<b>Technical reason</b>: " ) +
443 techName + QLatin1String( "</p>" );
444 ret2 += QLatin1String( "<p>" ) + i18n( "<b>Details of the request</b>:" ) +
445 QLatin1String( "</p><ul>" ) + i18n( "<li>URL: %1</li>", url );
446 if ( !protocol.isEmpty() ) {
447 ret2 += i18n( "<li>Protocol: %1</li>" , protocol );
449 ret2 += i18n( "<li>Date and time: %1</li>", datetime ) +
450 i18n( "<li>Additional information: %1</li>" , errorText() ) +
451 QLatin1String( "</ul>" );
452 if ( !causes.isEmpty() ) {
453 ret2 += QLatin1String( "<p>" ) + i18n( "<b>Possible causes</b>:" ) +
454 QLatin1String( "</p><ul><li>" ) + causes.join( "</li><li>" ) +
455 QLatin1String( "</li></ul>" );
457 if ( !solutions.isEmpty() ) {
458 ret2 += QLatin1String( "<p>" ) + i18n( "<b>Possible solutions</b>:" ) +
459 QLatin1String( "</p><ul><li>" ) + solutions.join( "</li><li>" ) +
460 QLatin1String( "</li></ul>" );
462 ret2 += QLatin1String( "</qt>" );
463 ret << ret2;
465 return ret;
468 KIO_EXPORT QByteArray KIO::rawErrorDetail(int errorCode, const QString &errorText,
469 const KUrl *reqUrl /*= 0L*/, int /*method = -1*/ )
471 QString url, host, protocol, datetime, domain, path, filename;
472 bool isSlaveNetwork = false;
473 if ( reqUrl ) {
474 url = reqUrl->prettyUrl();
475 host = reqUrl->host();
476 protocol = reqUrl->protocol();
478 if ( host.startsWith( QLatin1String( "www." ) ) )
479 domain = host.mid(4);
480 else
481 domain = host;
483 filename = reqUrl->fileName();
484 path = reqUrl->path();
486 // detect if protocol is a network protocol...
487 isSlaveNetwork = KProtocolInfo::protocolClass(protocol) == ":internet";
488 } else {
489 // assume that the errorText has the location we are interested in
490 url = host = domain = path = filename = errorText;
491 protocol = i18nc("@info protocol", "(unknown)" );
494 datetime = KGlobal::locale()->formatDateTime( QDateTime::currentDateTime(),
495 KLocale::LongDate );
497 QString errorName, techName, description;
498 QStringList causes, solutions;
500 // c == cause, s == solution
501 QString sSysadmin = i18n( "Contact your appropriate computer support system, "
502 "whether the system administrator, or technical support group for further "
503 "assistance." );
504 QString sServeradmin = i18n( "Contact the administrator of the server "
505 "for further assistance." );
506 // FIXME active link to permissions dialog
507 QString sAccess = i18n( "Check your access permissions on this resource." );
508 QString cAccess = i18n( "Your access permissions may be inadequate to "
509 "perform the requested operation on this resource." );
510 QString cLocked = i18n( "The file may be in use (and thus locked) by "
511 "another user or application." );
512 QString sQuerylock = i18n( "Check to make sure that no other "
513 "application or user is using the file or has locked the file." );
514 QString cHardware = i18n( "Although unlikely, a hardware error may have "
515 "occurred." );
516 QString cBug = i18n( "You may have encountered a bug in the program." );
517 QString cBuglikely = i18n( "This is most likely to be caused by a bug in the "
518 "program. Please consider submitting a full bug report as detailed below." );
519 QString sUpdate = i18n( "Update your software to the latest version. "
520 "Your distribution should provide tools to update your software." );
521 QString sBugreport = i18n( "When all else fails, please consider helping the "
522 "KDE team or the third party maintainer of this software by submitting a "
523 "high quality bug report. If the software is provided by a third party, "
524 "please contact them directly. Otherwise, first look to see if "
525 "the same bug has been submitted by someone else by searching at the "
526 "<a href=\"http://bugs.kde.org/\">KDE bug reporting website</a>. If not, take "
527 "note of the details given above, and include them in your bug report, along "
528 "with as many other details as you think might help." );
529 QString cNetwork = i18n( "There may have been a problem with your network "
530 "connection." );
531 // FIXME netconf kcontrol link
532 QString cNetconf = i18n( "There may have been a problem with your network "
533 "configuration. If you have been accessing the Internet with no problems "
534 "recently, this is unlikely." );
535 QString cNetpath = i18n( "There may have been a problem at some point along "
536 "the network path between the server and this computer." );
537 QString sTryagain = i18n( "Try again, either now or at a later time." );
538 QString cProtocol = i18n( "A protocol error or incompatibility may have occurred." );
539 QString sExists = i18n( "Ensure that the resource exists, and try again." );
540 QString cExists = i18n( "The specified resource may not exist." );
541 QString cTypo = i18n( "You may have incorrectly typed the location." );
542 QString sTypo = i18n( "Double-check that you have entered the correct location "
543 "and try again." );
544 QString sNetwork = i18n( "Check your network connection status." );
546 switch( errorCode ) {
547 case KIO::ERR_CANNOT_OPEN_FOR_READING:
548 errorName = i18n( "Cannot Open Resource For Reading" );
549 description = i18n( "This means that the contents of the requested file "
550 "or folder <strong>%1</strong> could not be retrieved, as read "
551 "access could not be obtained.", path );
552 causes << i18n( "You may not have permissions to read the file or open "
553 "the folder.") << cLocked << cHardware;
554 solutions << sAccess << sQuerylock << sSysadmin;
555 break;
557 case KIO::ERR_CANNOT_OPEN_FOR_WRITING:
558 errorName = i18n( "Cannot Open Resource For Writing" );
559 description = i18n( "This means that the file, <strong>%1</strong>, could "
560 "not be written to as requested, because access with permission to "
561 "write could not be obtained." , filename );
562 causes << cAccess << cLocked << cHardware;
563 solutions << sAccess << sQuerylock << sSysadmin;
564 break;
566 case KIO::ERR_CANNOT_LAUNCH_PROCESS:
567 errorName = i18n( "Cannot Initiate the %1 Protocol" , protocol );
568 techName = i18n( "Unable to Launch Process" );
569 description = i18n( "The program on your computer which provides access "
570 "to the <strong>%1</strong> protocol could not be started. This is "
571 "usually due to technical reasons." , protocol );
572 causes << i18n( "The program which provides compatibility with this "
573 "protocol may not have been updated with your last update of KDE. "
574 "This can cause the program to be incompatible with the current version "
575 "and thus not start." ) << cBug;
576 solutions << sUpdate << sSysadmin;
577 break;
579 case KIO::ERR_INTERNAL:
580 errorName = i18n( "Internal Error" );
581 description = i18n( "The program on your computer which provides access "
582 "to the <strong>%1</strong> protocol has reported an internal error." ,
583 protocol );
584 causes << cBuglikely;
585 solutions << sUpdate << sBugreport;
586 break;
588 case KIO::ERR_MALFORMED_URL:
589 errorName = i18n( "Improperly Formatted URL" );
590 description = i18n( "The <strong>U</strong>niform <strong>R</strong>esource "
591 "<strong>L</strong>ocator (URL) that you entered was not properly "
592 "formatted. The format of a URL is generally as follows:"
593 "<blockquote><strong>protocol://user:password@www.example.org:port/folder/"
594 "filename.extension?query=value</strong></blockquote>" );
595 solutions << sTypo;
596 break;
598 case KIO::ERR_UNSUPPORTED_PROTOCOL:
599 errorName = i18n( "Unsupported Protocol %1" , protocol );
600 description = i18n( "The protocol <strong>%1</strong> is not supported "
601 "by the KDE programs currently installed on this computer." ,
602 protocol );
603 causes << i18n( "The requested protocol may not be supported." )
604 << i18n( "The versions of the %1 protocol supported by this computer and "
605 "the server may be incompatible." , protocol );
606 solutions << i18n( "You may perform a search on the Internet for a KDE "
607 "program (called a kioslave or ioslave) which supports this protocol. "
608 "Places to search include <a href=\"http://kde-apps.org/\">"
609 "http://kde-apps.org/</a> and <a href=\"http://freshmeat.net/\">"
610 "http://freshmeat.net/</a>." )
611 << sUpdate << sSysadmin;
612 break;
614 case KIO::ERR_NO_SOURCE_PROTOCOL:
615 errorName = i18n( "URL Does Not Refer to a Resource." );
616 techName = i18n( "Protocol is a Filter Protocol" );
617 description = i18n( "The <strong>U</strong>niform <strong>R</strong>esource "
618 "<strong>L</strong>ocator (URL) that you entered did not refer to a "
619 "specific resource." );
620 causes << i18n( "KDE is able to communicate through a protocol within a "
621 "protocol; the protocol specified is only for use in such situations, "
622 "however this is not one of these situations. This is a rare event, and "
623 "is likely to indicate a programming error." );
624 solutions << sTypo;
625 break;
627 case KIO::ERR_UNSUPPORTED_ACTION:
628 errorName = i18n( "Unsupported Action: %1" , errorText );
629 description = i18n( "The requested action is not supported by the KDE "
630 "program which is implementing the <strong>%1</strong> protocol." ,
631 protocol );
632 causes << i18n( "This error is very much dependent on the KDE program. The "
633 "additional information should give you more information than is available "
634 "to the KDE input/output architecture." );
635 solutions << i18n( "Attempt to find another way to accomplish the same "
636 "outcome." );
637 break;
639 case KIO::ERR_IS_DIRECTORY:
640 errorName = i18n( "File Expected" );
641 description = i18n( "The request expected a file, however the "
642 "folder <strong>%1</strong> was found instead." , path );
643 causes << i18n( "This may be an error on the server side." ) << cBug;
644 solutions << sUpdate << sSysadmin;
645 break;
647 case KIO::ERR_IS_FILE:
648 errorName = i18n( "Folder Expected" );
649 description = i18n( "The request expected a folder, however "
650 "the file <strong>%1</strong> was found instead." , filename );
651 causes << cBug;
652 solutions << sUpdate << sSysadmin;
653 break;
655 case KIO::ERR_DOES_NOT_EXIST:
656 errorName = i18n( "File or Folder Does Not Exist" );
657 description = i18n( "The specified file or folder <strong>%1</strong> "
658 "does not exist." , path );
659 causes << cBug;
660 solutions << sUpdate << sSysadmin;
661 break;
663 case KIO::ERR_FILE_ALREADY_EXIST:
664 errorName = i18n( "File Already Exists" );
665 description = i18n( "The requested file could not be created because a "
666 "file with the same name already exists." );
667 solutions << i18n ( "Try moving the current file out of the way first, "
668 "and then try again." )
669 << i18n ( "Delete the current file and try again." )
670 << i18n( "Choose an alternate filename for the new file." );
671 break;
673 case KIO::ERR_DIR_ALREADY_EXIST:
674 errorName = i18n( "Folder Already Exists" );
675 description = i18n( "The requested folder could not be created because "
676 "a folder with the same name already exists." );
677 solutions << i18n( "Try moving the current folder out of the way first, "
678 "and then try again." )
679 << i18n( "Delete the current folder and try again." )
680 << i18n( "Choose an alternate name for the new folder." );
681 break;
683 case KIO::ERR_UNKNOWN_HOST:
684 errorName = i18n( "Unknown Host" );
685 description = i18n( "An unknown host error indicates that the server with "
686 "the requested name, <strong>%1</strong>, could not be "
687 "located on the Internet." , host );
688 causes << i18n( "The name that you typed, %1, may not exist: it may be "
689 "incorrectly typed." , host )
690 << cNetwork << cNetconf;
691 solutions << sNetwork << sSysadmin;
692 break;
694 case KIO::ERR_ACCESS_DENIED:
695 errorName = i18n( "Access Denied" );
696 description = i18n( "Access was denied to the specified resource, "
697 "<strong>%1</strong>." , url );
698 causes << i18n( "You may have supplied incorrect authentication details or "
699 "none at all." )
700 << i18n( "Your account may not have permission to access the "
701 "specified resource." );
702 solutions << i18n( "Retry the request and ensure your authentication details "
703 "are entered correctly." ) << sSysadmin;
704 if ( !isSlaveNetwork ) solutions << sServeradmin;
705 break;
707 case KIO::ERR_WRITE_ACCESS_DENIED:
708 errorName = i18n( "Write Access Denied" );
709 description = i18n( "This means that an attempt to write to the file "
710 "<strong>%1</strong> was rejected." , filename );
711 causes << cAccess << cLocked << cHardware;
712 solutions << sAccess << sQuerylock << sSysadmin;
713 break;
715 case KIO::ERR_CANNOT_ENTER_DIRECTORY:
716 errorName = i18n( "Unable to Enter Folder" );
717 description = i18n( "This means that an attempt to enter (in other words, "
718 "to open) the requested folder <strong>%1</strong> was rejected." ,
719 path );
720 causes << cAccess << cLocked;
721 solutions << sAccess << sQuerylock << sSysadmin;
722 break;
724 case KIO::ERR_PROTOCOL_IS_NOT_A_FILESYSTEM:
725 errorName = i18n( "Folder Listing Unavailable" );
726 techName = i18n( "Protocol %1 is not a Filesystem" , protocol );
727 description = i18n( "This means that a request was made which requires "
728 "determining the contents of the folder, and the KDE program supporting "
729 "this protocol is unable to do so." );
730 causes << cBug;
731 solutions << sUpdate << sBugreport;
732 break;
734 case KIO::ERR_CYCLIC_LINK:
735 errorName = i18n( "Cyclic Link Detected" );
736 description = i18n( "UNIX environments are commonly able to link a file or "
737 "folder to a separate name and/or location. KDE detected a link or "
738 "series of links that results in an infinite loop - i.e. the file was "
739 "(perhaps in a roundabout way) linked to itself." );
740 solutions << i18n( "Delete one part of the loop in order that it does not "
741 "cause an infinite loop, and try again." ) << sSysadmin;
742 break;
744 case KIO::ERR_USER_CANCELED:
745 // Do nothing in this case. The user doesn't need to be told what he just did.
746 // rodda: However, if we have been called, an application is about to display
747 // this information anyway. If we don't return sensible information, the
748 // user sees a blank dialog (I have seen this myself)
749 errorName = i18n( "Request Aborted By User" );
750 description = i18n( "The request was not completed because it was "
751 "aborted." );
752 solutions << i18n( "Retry the request." );
753 break;
755 case KIO::ERR_CYCLIC_COPY:
756 errorName = i18n( "Cyclic Link Detected During Copy" );
757 description = i18n( "UNIX environments are commonly able to link a file or "
758 "folder to a separate name and/or location. During the requested copy "
759 "operation, KDE detected a link or series of links that results in an "
760 "infinite loop - i.e. the file was (perhaps in a roundabout way) linked "
761 "to itself." );
762 solutions << i18n( "Delete one part of the loop in order that it does not "
763 "cause an infinite loop, and try again." ) << sSysadmin;
764 break;
766 case KIO::ERR_COULD_NOT_CREATE_SOCKET:
767 errorName = i18n( "Could Not Create Network Connection" );
768 techName = i18n( "Could Not Create Socket" );
769 description = i18n( "This is a fairly technical error in which a required "
770 "device for network communications (a socket) could not be created." );
771 causes << i18n( "The network connection may be incorrectly configured, or "
772 "the network interface may not be enabled." );
773 solutions << sNetwork << sSysadmin;
774 break;
776 case KIO::ERR_COULD_NOT_CONNECT:
777 errorName = i18n( "Connection to Server Refused" );
778 description = i18n( "The server <strong>%1</strong> refused to allow this "
779 "computer to make a connection." , host );
780 causes << i18n( "The server, while currently connected to the Internet, "
781 "may not be configured to allow requests." )
782 << i18n( "The server, while currently connected to the Internet, "
783 "may not be running the requested service (%1)." , protocol )
784 << i18n( "A network firewall (a device which restricts Internet "
785 "requests), either protecting your network or the network of the server, "
786 "may have intervened, preventing this request." );
787 solutions << sTryagain << sServeradmin << sSysadmin;
788 break;
790 case KIO::ERR_CONNECTION_BROKEN:
791 errorName = i18n( "Connection to Server Closed Unexpectedly" );
792 description = i18n( "Although a connection was established to "
793 "<strong>%1</strong>, the connection was closed at an unexpected point "
794 "in the communication." , host );
795 causes << cNetwork << cNetpath << i18n( "A protocol error may have occurred, "
796 "causing the server to close the connection as a response to the error." );
797 solutions << sTryagain << sServeradmin << sSysadmin;
798 break;
800 case KIO::ERR_NOT_FILTER_PROTOCOL:
801 errorName = i18n( "URL Resource Invalid" );
802 techName = i18n( "Protocol %1 is not a Filter Protocol" , protocol );
803 description = i18n( "The <strong>U</strong>niform <strong>R</strong>esource "
804 "<strong>L</strong>ocator (URL) that you entered did not refer to "
805 "a valid mechanism of accessing the specific resource, "
806 "<strong>%1%2</strong>." ,
807 !host.isNull() ? host + '/' : QString() , path );
808 causes << i18n( "KDE is able to communicate through a protocol within a "
809 "protocol. This request specified a protocol be used as such, however "
810 "this protocol is not capable of such an action. This is a rare event, "
811 "and is likely to indicate a programming error." );
812 solutions << sTypo << sSysadmin;
813 break;
815 case KIO::ERR_COULD_NOT_MOUNT:
816 errorName = i18n( "Unable to Initialize Input/Output Device" );
817 techName = i18n( "Could Not Mount Device" );
818 description = i18n( "The requested device could not be initialized "
819 "(\"mounted\"). The reported error was: <strong>%1</strong>" ,
820 errorText );
821 causes << i18n( "The device may not be ready, for example there may be "
822 "no media in a removable media device (i.e. no CD-ROM in a CD drive), "
823 "or in the case of a peripheral/portable device, the device may not "
824 "be correctly connected." )
825 << i18n( "You may not have permissions to initialize (\"mount\") the "
826 "device. On UNIX systems, often system administrator privileges are "
827 "required to initialize a device." )
828 << cHardware;
829 solutions << i18n( "Check that the device is ready; removable drives "
830 "must contain media, and portable devices must be connected and powered "
831 "on.; and try again." ) << sAccess << sSysadmin;
832 break;
834 case KIO::ERR_COULD_NOT_UNMOUNT:
835 errorName = i18n( "Unable to Uninitialize Input/Output Device" );
836 techName = i18n( "Could Not Unmount Device" );
837 description = i18n( "The requested device could not be uninitialized "
838 "(\"unmounted\"). The reported error was: <strong>%1</strong>" ,
839 errorText );
840 causes << i18n( "The device may be busy, that is, still in use by "
841 "another application or user. Even such things as having an open "
842 "browser window on a location on this device may cause the device to "
843 "remain in use." )
844 << i18n( "You may not have permissions to uninitialize (\"unmount\") "
845 "the device. On UNIX systems, system administrator privileges are "
846 "often required to uninitialize a device." )
847 << cHardware;
848 solutions << i18n( "Check that no applications are accessing the device, "
849 "and try again." ) << sAccess << sSysadmin;
850 break;
852 case KIO::ERR_COULD_NOT_READ:
853 errorName = i18n( "Cannot Read From Resource" );
854 description = i18n( "This means that although the resource, "
855 "<strong>%1</strong>, was able to be opened, an error occurred while "
856 "reading the contents of the resource." , url );
857 causes << i18n( "You may not have permissions to read from the resource." );
858 if ( !isSlaveNetwork ) causes << cNetwork;
859 causes << cHardware;
860 solutions << sAccess;
861 if ( !isSlaveNetwork ) solutions << sNetwork;
862 solutions << sSysadmin;
863 break;
865 case KIO::ERR_COULD_NOT_WRITE:
866 errorName = i18n( "Cannot Write to Resource" );
867 description = i18n( "This means that although the resource, <strong>%1</strong>"
868 ", was able to be opened, an error occurred while writing to the resource." ,
869 url );
870 causes << i18n( "You may not have permissions to write to the resource." );
871 if ( !isSlaveNetwork ) causes << cNetwork;
872 causes << cHardware;
873 solutions << sAccess;
874 if ( !isSlaveNetwork ) solutions << sNetwork;
875 solutions << sSysadmin;
876 break;
878 case KIO::ERR_COULD_NOT_BIND:
879 errorName = i18n( "Could Not Listen for Network Connections" );
880 techName = i18n( "Could Not Bind" );
881 description = i18n( "This is a fairly technical error in which a required "
882 "device for network communications (a socket) could not be established "
883 "to listen for incoming network connections." );
884 causes << i18n( "The network connection may be incorrectly configured, or "
885 "the network interface may not be enabled." );
886 solutions << sNetwork << sSysadmin;
887 break;
889 case KIO::ERR_COULD_NOT_LISTEN:
890 errorName = i18n( "Could Not Listen for Network Connections" );
891 techName = i18n( "Could Not Listen" );
892 description = i18n( "This is a fairly technical error in which a required "
893 "device for network communications (a socket) could not be established "
894 "to listen for incoming network connections." );
895 causes << i18n( "The network connection may be incorrectly configured, or "
896 "the network interface may not be enabled." );
897 solutions << sNetwork << sSysadmin;
898 break;
900 case KIO::ERR_COULD_NOT_ACCEPT:
901 errorName = i18n( "Could Not Accept Network Connection" );
902 description = i18n( "This is a fairly technical error in which an error "
903 "occurred while attempting to accept an incoming network connection." );
904 causes << i18n( "The network connection may be incorrectly configured, or "
905 "the network interface may not be enabled." )
906 << i18n( "You may not have permissions to accept the connection." );
907 solutions << sNetwork << sSysadmin;
908 break;
910 case KIO::ERR_COULD_NOT_LOGIN:
911 errorName = i18n( "Could Not Login: %1" , errorText );
912 description = i18n( "An attempt to login to perform the requested "
913 "operation was unsuccessful." );
914 causes << i18n( "You may have supplied incorrect authentication details or "
915 "none at all." )
916 << i18n( "Your account may not have permission to access the "
917 "specified resource." ) << cProtocol;
918 solutions << i18n( "Retry the request and ensure your authentication details "
919 "are entered correctly." ) << sServeradmin << sSysadmin;
920 break;
922 case KIO::ERR_COULD_NOT_STAT:
923 errorName = i18n( "Could Not Determine Resource Status" );
924 techName = i18n( "Could Not Stat Resource" );
925 description = i18n( "An attempt to determine information about the status "
926 "of the resource <strong>%1</strong>, such as the resource name, type, "
927 "size, etc., was unsuccessful." , url );
928 causes << i18n( "The specified resource may not have existed or may "
929 "not be accessible." ) << cProtocol << cHardware;
930 solutions << i18n( "Retry the request and ensure your authentication details "
931 "are entered correctly." ) << sSysadmin;
932 break;
934 case KIO::ERR_COULD_NOT_CLOSEDIR:
935 //result = i18n( "Could not terminate listing %1" ).arg( errorText );
936 errorName = i18n( "Could Not Cancel Listing" );
937 techName = i18n( "FIXME: Document this" );
938 break;
940 case KIO::ERR_COULD_NOT_MKDIR:
941 errorName = i18n( "Could Not Create Folder" );
942 description = i18n( "An attempt to create the requested folder failed." );
943 causes << cAccess << i18n( "The location where the folder was to be created "
944 "may not exist." );
945 if ( !isSlaveNetwork ) causes << cProtocol;
946 solutions << i18n( "Retry the request." ) << sAccess;
947 break;
949 case KIO::ERR_COULD_NOT_RMDIR:
950 errorName = i18n( "Could Not Remove Folder" );
951 description = i18n( "An attempt to remove the specified folder, "
952 "<strong>%1</strong>, failed." , path );
953 causes << i18n( "The specified folder may not exist." )
954 << i18n( "The specified folder may not be empty." )
955 << cAccess;
956 if ( !isSlaveNetwork ) causes << cProtocol;
957 solutions << i18n( "Ensure that the folder exists and is empty, and try "
958 "again." ) << sAccess;
959 break;
961 case KIO::ERR_CANNOT_RESUME:
962 errorName = i18n( "Could Not Resume File Transfer" );
963 description = i18n( "The specified request asked that the transfer of "
964 "file <strong>%1</strong> be resumed at a certain point of the "
965 "transfer. This was not possible." , filename );
966 causes << i18n( "The protocol, or the server, may not support file "
967 "resuming." );
968 solutions << i18n( "Retry the request without attempting to resume "
969 "transfer." );
970 break;
972 case KIO::ERR_CANNOT_RENAME:
973 errorName = i18n( "Could Not Rename Resource" );
974 description = i18n( "An attempt to rename the specified resource "
975 "<strong>%1</strong> failed." , url );
976 causes << cAccess << cExists;
977 if ( !isSlaveNetwork ) causes << cProtocol;
978 solutions << sAccess << sExists;
979 break;
981 case KIO::ERR_CANNOT_CHMOD:
982 errorName = i18n( "Could Not Alter Permissions of Resource" );
983 description = i18n( "An attempt to alter the permissions on the specified "
984 "resource <strong>%1</strong> failed." , url );
985 causes << cAccess << cExists;
986 solutions << sAccess << sExists;
987 break;
989 case KIO::ERR_CANNOT_CHOWN:
990 errorName = i18n( "Could Not Change Ownership of Resource" );
991 description = i18n( "An attempt to change the ownership of the specified "
992 "resource <strong>%1</strong> failed." , url );
993 causes << cAccess << cExists;
994 solutions << sAccess << sExists;
995 break;
997 case KIO::ERR_CANNOT_DELETE:
998 errorName = i18n( "Could Not Delete Resource" );
999 description = i18n( "An attempt to delete the specified resource "
1000 "<strong>%1</strong> failed." , url );
1001 causes << cAccess << cExists;
1002 solutions << sAccess << sExists;
1003 break;
1005 case KIO::ERR_SLAVE_DIED:
1006 errorName = i18n( "Unexpected Program Termination" );
1007 description = i18n( "The program on your computer which provides access "
1008 "to the <strong>%1</strong> protocol has unexpectedly terminated." ,
1009 url );
1010 causes << cBuglikely;
1011 solutions << sUpdate << sBugreport;
1012 break;
1014 case KIO::ERR_OUT_OF_MEMORY:
1015 errorName = i18n( "Out of Memory" );
1016 description = i18n( "The program on your computer which provides access "
1017 "to the <strong>%1</strong> protocol could not obtain the memory "
1018 "required to continue." , protocol );
1019 causes << cBuglikely;
1020 solutions << sUpdate << sBugreport;
1021 break;
1023 case KIO::ERR_UNKNOWN_PROXY_HOST:
1024 errorName = i18n( "Unknown Proxy Host" );
1025 description = i18n( "While retrieving information about the specified "
1026 "proxy host, <strong>%1</strong>, an Unknown Host error was encountered. "
1027 "An unknown host error indicates that the requested name could not be "
1028 "located on the Internet." , errorText );
1029 causes << i18n( "There may have been a problem with your network "
1030 "configuration, specifically your proxy's hostname. If you have been "
1031 "accessing the Internet with no problems recently, this is unlikely." )
1032 << cNetwork;
1033 solutions << i18n( "Double-check your proxy settings and try again." )
1034 << sSysadmin;
1035 break;
1037 case KIO::ERR_COULD_NOT_AUTHENTICATE:
1038 errorName = i18n( "Authentication Failed: Method %1 Not Supported" ,
1039 errorText );
1040 description = i18n( "Although you may have supplied the correct "
1041 "authentication details, the authentication failed because the "
1042 "method that the server is using is not supported by the KDE "
1043 "program implementing the protocol %1." , protocol );
1044 solutions << i18n( "Please file a bug at <a href=\"http://bugs.kde.org/\">"
1045 "http://bugs.kde.org/</a> to inform the KDE team of the unsupported "
1046 "authentication method." ) << sSysadmin;
1047 break;
1049 case KIO::ERR_ABORTED:
1050 errorName = i18n( "Request Aborted" );
1051 description = i18n( "The request was not completed because it was "
1052 "aborted." );
1053 solutions << i18n( "Retry the request." );
1054 break;
1056 case KIO::ERR_INTERNAL_SERVER:
1057 errorName = i18n( "Internal Error in Server" );
1058 description = i18n( "The program on the server which provides access "
1059 "to the <strong>%1</strong> protocol has reported an internal error: "
1060 "%2." , protocol, errorText );
1061 causes << i18n( "This is most likely to be caused by a bug in the "
1062 "server program. Please consider submitting a full bug report as "
1063 "detailed below." );
1064 solutions << i18n( "Contact the administrator of the server "
1065 "to advise them of the problem." )
1066 << i18n( "If you know who the authors of the server software are, "
1067 "submit the bug report directly to them." );
1068 break;
1070 case KIO::ERR_SERVER_TIMEOUT:
1071 errorName = i18n( "Timeout Error" );
1072 description = i18n( "Although contact was made with the server, a "
1073 "response was not received within the amount of time allocated for "
1074 "the request as follows:<ul>"
1075 "<li>Timeout for establishing a connection: %1 seconds</li>"
1076 "<li>Timeout for receiving a response: %2 seconds</li>"
1077 "<li>Timeout for accessing proxy servers: %3 seconds</li></ul>"
1078 "Please note that you can alter these timeout settings in the KDE "
1079 "Control Center, by selecting Network -> Preferences." ,
1080 KProtocolManager::connectTimeout() ,
1081 KProtocolManager::responseTimeout() ,
1082 KProtocolManager::proxyConnectTimeout() );
1083 causes << cNetpath << i18n( "The server was too busy responding to other "
1084 "requests to respond." );
1085 solutions << sTryagain << sServeradmin;
1086 break;
1088 case KIO::ERR_UNKNOWN:
1089 errorName = i18n( "Unknown Error" );
1090 description = i18n( "The program on your computer which provides access "
1091 "to the <strong>%1</strong> protocol has reported an unknown error: "
1092 "%2." , protocol , errorText );
1093 causes << cBug;
1094 solutions << sUpdate << sBugreport;
1095 break;
1097 case KIO::ERR_UNKNOWN_INTERRUPT:
1098 errorName = i18n( "Unknown Interruption" );
1099 description = i18n( "The program on your computer which provides access "
1100 "to the <strong>%1</strong> protocol has reported an interruption of "
1101 "an unknown type: %2." , protocol , errorText );
1102 causes << cBug;
1103 solutions << sUpdate << sBugreport;
1104 break;
1106 case KIO::ERR_CANNOT_DELETE_ORIGINAL:
1107 errorName = i18n( "Could Not Delete Original File" );
1108 description = i18n( "The requested operation required the deleting of "
1109 "the original file, most likely at the end of a file move operation. "
1110 "The original file <strong>%1</strong> could not be deleted." ,
1111 errorText );
1112 causes << cAccess;
1113 solutions << sAccess;
1114 break;
1116 case KIO::ERR_CANNOT_DELETE_PARTIAL:
1117 errorName = i18n( "Could Not Delete Temporary File" );
1118 description = i18n( "The requested operation required the creation of "
1119 "a temporary file in which to save the new file while being "
1120 "downloaded. This temporary file <strong>%1</strong> could not be "
1121 "deleted." , errorText );
1122 causes << cAccess;
1123 solutions << sAccess;
1124 break;
1126 case KIO::ERR_CANNOT_RENAME_ORIGINAL:
1127 errorName = i18n( "Could Not Rename Original File" );
1128 description = i18n( "The requested operation required the renaming of "
1129 "the original file <strong>%1</strong>, however it could not be "
1130 "renamed." , errorText );
1131 causes << cAccess;
1132 solutions << sAccess;
1133 break;
1135 case KIO::ERR_CANNOT_RENAME_PARTIAL:
1136 errorName = i18n( "Could Not Rename Temporary File" );
1137 description = i18n( "The requested operation required the creation of "
1138 "a temporary file <strong>%1</strong>, however it could not be "
1139 "created." , errorText );
1140 causes << cAccess;
1141 solutions << sAccess;
1142 break;
1144 case KIO::ERR_CANNOT_SYMLINK:
1145 errorName = i18n( "Could Not Create Link" );
1146 techName = i18n( "Could Not Create Symbolic Link" );
1147 description = i18n( "The requested symbolic link %1 could not be created." ,
1148 errorText );
1149 causes << cAccess;
1150 solutions << sAccess;
1151 break;
1153 case KIO::ERR_NO_CONTENT:
1154 errorName = i18n( "No Content" );
1155 description = errorText;
1156 break;
1158 case KIO::ERR_DISK_FULL:
1159 errorName = i18n( "Disk Full" );
1160 description = i18n( "The requested file <strong>%1</strong> could not be "
1161 "written to as there is inadequate disk space." , errorText );
1162 solutions << i18n( "Free up enough disk space by 1) deleting unwanted and "
1163 "temporary files; 2) archiving files to removable media storage such as "
1164 "CD-Recordable discs; or 3) obtain more storage capacity." )
1165 << sSysadmin;
1166 break;
1168 case KIO::ERR_IDENTICAL_FILES:
1169 errorName = i18n( "Source and Destination Files Identical" );
1170 description = i18n( "The operation could not be completed because the "
1171 "source and destination files are the same file." );
1172 solutions << i18n( "Choose a different filename for the destination file." );
1173 break;
1175 // We assume that the slave has all the details
1176 case KIO::ERR_SLAVE_DEFINED:
1177 errorName.clear();
1178 description = errorText;
1179 break;
1181 default:
1182 // fall back to the plain error...
1183 errorName = i18n( "Undocumented Error" );
1184 description = buildErrorString( errorCode, errorText );
1187 QByteArray ret;
1188 QDataStream stream(&ret, QIODevice::WriteOnly);
1189 stream << errorName << techName << description << causes << solutions;
1190 return ret;
1193 /***************************************************************
1195 * Utility functions
1197 ***************************************************************/
1199 KIO::CacheControl KIO::parseCacheControl(const QString &cacheControl)
1201 QString tmp = cacheControl.toLower();
1203 if (tmp == "cacheonly")
1204 return KIO::CC_CacheOnly;
1205 if (tmp == "cache")
1206 return KIO::CC_Cache;
1207 if (tmp == "verify")
1208 return KIO::CC_Verify;
1209 if (tmp == "refresh")
1210 return KIO::CC_Refresh;
1211 if (tmp == "reload")
1212 return KIO::CC_Reload;
1214 kDebug() << "unrecognized Cache control option:"<<cacheControl;
1215 return KIO::CC_Verify;
1218 QString KIO::getCacheControlString(KIO::CacheControl cacheControl)
1220 if (cacheControl == KIO::CC_CacheOnly)
1221 return "CacheOnly";
1222 if (cacheControl == KIO::CC_Cache)
1223 return "Cache";
1224 if (cacheControl == KIO::CC_Verify)
1225 return "Verify";
1226 if (cacheControl == KIO::CC_Refresh)
1227 return "Refresh";
1228 if (cacheControl == KIO::CC_Reload)
1229 return "Reload";
1230 kDebug() << "unrecognized Cache control enum value:"<<cacheControl;
1231 return QString();
1234 QPixmap KIO::pixmapForUrl( const KUrl & _url, mode_t _mode, KIconLoader::Group _group,
1235 int _force_size, int _state, QString * _path )
1237 const QString iconName = KMimeType::iconNameForUrl( _url, _mode );
1238 return KIconLoader::global()->loadMimeTypeIcon( iconName, _group, _force_size, _state, QStringList(), _path );
1241 KJobTrackerInterface *KIO::getJobTracker()
1243 return globalJobTracker;