• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kio/kio
 

kio/kio

  • kio
  • kio
global.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 David Faure <faure@kde.org>
3 
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.
7 
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.
12 
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.
17 */
18 
19 #include <config.h>
20 
21 #include <sys/types.h>
22 #include <sys/wait.h>
23 #include <sys/uio.h>
24 
25 #include <assert.h>
26 #include <signal.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <unistd.h>
30 #include <stdio.h>
31 
32 #include "kio/global.h"
33 #include "kio/job.h"
34 
35 #include <kdebug.h>
36 #include <klocale.h>
37 #include <kglobal.h>
38 #include <kprotocolmanager.h>
39 #include <kde_file.h>
40 
41 #ifdef HAVE_VOLMGT
42 #include <volmgt.h>
43 #endif
44 
45 KIO_EXPORT TQString KIO::convertSizeWithBytes( KIO::filesize_t size )
46 {
47  if ( size >= 1024 )
48  return convertSize( size ) + " (" + i18n( "%1 B" ).arg( KGlobal::locale()->formatNumber(size, 0) ) + ")";
49  else
50  return convertSize( size );
51 }
52 
53 KIO_EXPORT TQString KIO::convertSize( KIO::filesize_t size )
54 {
55  double fsize = size;
56  TQString s;
57  // Giga-byte
58  if ( size >= 1073741824 )
59  {
60  fsize /= 1073741824.0;
61  if ( fsize > 1024 ) // Tera-byte
62  s = i18n( "%1 TB" ).arg( KGlobal::locale()->formatNumber(fsize / 1024.0, 1));
63  else
64  s = i18n( "%1 GB" ).arg( KGlobal::locale()->formatNumber(fsize, 1));
65  }
66  // Mega-byte
67  else if ( size >= 1048576 )
68  {
69  fsize /= 1048576.0;
70  s = i18n( "%1 MB" ).arg( KGlobal::locale()->formatNumber(fsize, 1));
71  }
72  // Kilo-byte
73  else if ( size >= 1024 )
74  {
75  fsize /= 1024.0;
76  s = i18n( "%1 KB" ).arg( KGlobal::locale()->formatNumber(fsize, 1));
77  }
78  // Just byte
79  else if ( size > 0 )
80  {
81  s = i18n( "%1 B" ).arg( KGlobal::locale()->formatNumber(fsize, 0));
82  }
83  // Nothing
84  else
85  {
86  s = i18n( "0 B" );
87  }
88  return s;
89 }
90 
91 KIO_EXPORT TQString KIO::convertSizeFromKB( KIO::filesize_t kbSize )
92 {
93  return convertSize(kbSize * 1024);
94 }
95 
96 KIO_EXPORT TQString KIO::number( KIO::filesize_t size )
97 {
98  char charbuf[256];
99  sprintf(charbuf, "%lld", size);
100  return TQString::fromLatin1(charbuf);
101 }
102 
103 KIO_EXPORT unsigned int KIO::calculateRemainingSeconds( KIO::filesize_t totalSize,
104  KIO::filesize_t processedSize, KIO::filesize_t speed )
105 {
106  if ( (speed != 0) && (totalSize != 0) )
107  return ( totalSize - processedSize ) / speed;
108  else
109  return 0;
110 }
111 
112 KIO_EXPORT TQString KIO::convertSeconds( unsigned int seconds )
113 {
114  unsigned int days = seconds / 86400;
115  unsigned int hours = (seconds - (days * 86400)) / 3600;
116  unsigned int mins = (seconds - (days * 86400) - (hours * 3600)) / 60;
117  seconds = (seconds - (days * 86400) - (hours * 3600) - (mins * 60));
118 
119  const TQTime time(hours, mins, seconds);
120  const TQString timeStr( KGlobal::locale()->formatTime(time, true /*with seconds*/, true /*duration*/) );
121  if ( days > 0 )
122  return i18n("1 day %1", "%n days %1", days).arg(timeStr);
123  else
124  return timeStr;
125 }
126 
127 KIO_EXPORT TQTime KIO::calculateRemaining( KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed )
128 {
129  TQTime remainingTime;
130 
131  if ( speed != 0 ) {
132  KIO::filesize_t secs;
133  if ( totalSize == 0 ) {
134  secs = 0;
135  } else {
136  secs = ( totalSize - processedSize ) / speed;
137  }
138  if (secs >= (24*60*60)) // Limit to 23:59:59
139  secs = (24*60*60)-1;
140  int hr = secs / ( 60 * 60 );
141  int mn = ( secs - hr * 60 * 60 ) / 60;
142  int sc = ( secs - hr * 60 * 60 - mn * 60 );
143 
144  remainingTime.setHMS( hr, mn, sc );
145  }
146 
147  return remainingTime;
148 }
149 
150 KIO_EXPORT TQString KIO::itemsSummaryString(uint items, uint files, uint dirs, KIO::filesize_t size, bool showSize)
151 {
152  TQString text = items == 0 ? i18n( "No Items" ) : i18n( "One Item", "%n Items", items );
153  text += " - ";
154  text += files == 0 ? i18n( "No Files" ) : i18n( "One File", "%n Files", files );
155  if ( showSize && files > 0 )
156  {
157  text += " ";
158  text += i18n("(%1 Total)").arg(KIO::convertSize( size ) );
159  }
160  text += " - ";
161  text += dirs == 0 ? i18n( "No Folders" ) : i18n("One Folder", "%n Folders", dirs);
162  return text;
163 }
164 
165 KIO_EXPORT TQString KIO::encodeFileName( const TQString & _str )
166 {
167  TQString str( _str );
168  bool unicode_supported = (TQString::fromLocal8Bit(TQString(TQChar((uint)0x2215)).local8Bit())[0].unicode() != 0x3f);
169 
170  int i = 0;
171  while ( ( i = str.find( "%", i ) ) != -1 ) {
172  str.replace( i, 1, "%%");
173  i += 2;
174  }
175  while ( ( i = str.find( "/" ) ) != -1 ) {
176  if (unicode_supported) {
177  // Use U+2215 (DIVISION SLASH) to represent the forward slash
178  // While U+2044 (FRACTION SLASH) is a tempting replacement, it can indicate to
179  // rendering engines that a combined fraction character should be displayed
180  str.replace( i, 1, TQChar((uint)0x2215));
181  }
182  else {
183  // Unicode does not appear to be supported on this system!
184  // Fall back to older encoding method...
185  str.replace( i, 1, "%2f");
186  }
187  }
188  return str;
189 }
190 
191 KIO_EXPORT TQString KIO::decodeFileName( const TQString & _str )
192 {
193  TQString str;
194  bool unicode_supported = (TQString::fromLocal8Bit(TQString(TQChar((uint)0x2215)).local8Bit())[0].unicode() != 0x3f);
195 
196  unsigned int i = 0;
197  for ( ; i < _str.length() ; ++i ) {
198  if ( _str[i]=='%' ) {
199  if ( _str[i+1]=='%' ) // %% -> %
200  {
201  str.append('%');
202  ++i;
203  }
204  else if ((!unicode_supported) && ( _str[i+1]=='2' && (i+2<_str.length()) && _str[i+2].lower()=='f' )) // %2f -> /
205  {
206  str.append('/');
207  i += 2;
208  }
209  else
210  {
211  str.append('%');
212  }
213  }
214  else if ( _str[i] == TQChar((uint)0x2215) ) {
215  str.append('/');
216  }
217  else {
218  str.append(_str[i]);
219  }
220  }
221 
222  return str;
223 }
224 
225 KIO_EXPORT TQString KIO::Job::errorString() const
226 {
227  return KIO::buildErrorString(m_error, m_errorText);
228 }
229 
230 KIO_EXPORT TQString KIO::buildErrorString(int errorCode, const TQString &errorText)
231 {
232  TQString result;
233 
234  switch( errorCode )
235  {
236  case KIO::ERR_CANNOT_OPEN_FOR_READING:
237  result = i18n( "Could not read %1." ).arg( errorText );
238  break;
239  case KIO::ERR_CANNOT_OPEN_FOR_WRITING:
240  result = i18n( "Could not write to %1." ).arg( errorText );
241  break;
242  case KIO::ERR_CANNOT_LAUNCH_PROCESS:
243  result = i18n( "Could not start process %1." ).arg( errorText );
244  break;
245  case KIO::ERR_INTERNAL:
246  result = i18n( "Internal Error\nPlease send a full bug report at http://bugs.trinitydesktop.org\n%1" ).arg( errorText );
247  break;
248  case KIO::ERR_MALFORMED_URL:
249  result = i18n( "Malformed URL %1." ).arg( errorText );
250  break;
251  case KIO::ERR_UNSUPPORTED_PROTOCOL:
252  result = i18n( "The protocol %1 is not supported." ).arg( errorText );
253  break;
254  case KIO::ERR_NO_SOURCE_PROTOCOL:
255  result = i18n( "The protocol %1 is only a filter protocol.").arg( errorText );
256  break;
257  case KIO::ERR_UNSUPPORTED_ACTION:
258  result = errorText;
259 // result = i18n( "Unsupported action %1" ).arg( errorText );
260  break;
261  case KIO::ERR_IS_DIRECTORY:
262  result = i18n( "%1 is a folder, but a file was expected." ).arg( errorText );
263  break;
264  case KIO::ERR_IS_FILE:
265  result = i18n( "%1 is a file, but a folder was expected." ).arg( errorText );
266  break;
267  case KIO::ERR_DOES_NOT_EXIST:
268  result = i18n( "The file or folder %1 does not exist." ).arg( errorText );
269  break;
270  case KIO::ERR_FILE_ALREADY_EXIST:
271  result = i18n( "A file named %1 already exists." ).arg( errorText );
272  break;
273  case KIO::ERR_DIR_ALREADY_EXIST:
274  result = i18n( "A folder named %1 already exists." ).arg( errorText );
275  break;
276  case KIO::ERR_UNKNOWN_HOST:
277  result = errorText.isEmpty() ? i18n( "No hostname specified." ) : i18n( "Unknown host %1" ).arg( errorText );
278  break;
279  case KIO::ERR_ACCESS_DENIED:
280  result = i18n( "Access denied to %1." ).arg( errorText );
281  break;
282  case KIO::ERR_WRITE_ACCESS_DENIED:
283  result = i18n( "Access denied.\nCould not write to %1." ).arg( errorText );
284  break;
285  case KIO::ERR_CANNOT_ENTER_DIRECTORY:
286  result = i18n( "Could not enter folder %1." ).arg( errorText );
287  break;
288  case KIO::ERR_PROTOCOL_IS_NOT_A_FILESYSTEM:
289  result = i18n( "The protocol %1 does not implement a folder service." ).arg( errorText );
290  break;
291  case KIO::ERR_CYCLIC_LINK:
292  result = i18n( "Found a cyclic link in %1." ).arg( errorText );
293  break;
294  case KIO::ERR_USER_CANCELED:
295  // Do nothing in this case. The user doesn't need to be told what he just did.
296  break;
297  case KIO::ERR_CYCLIC_COPY:
298  result = i18n( "Found a cyclic link while copying %1." ).arg( errorText );
299  break;
300  case KIO::ERR_COULD_NOT_CREATE_SOCKET:
301  result = i18n( "Could not create socket for accessing %1." ).arg( errorText );
302  break;
303  case KIO::ERR_COULD_NOT_CONNECT:
304  result = i18n( "Could not connect to host %1." ).arg( errorText.isEmpty() ? TQString::fromLatin1("localhost") : errorText );
305  break;
306  case KIO::ERR_CONNECTION_BROKEN:
307  result = i18n( "Connection to host %1 is broken." ).arg( errorText );
308  break;
309  case KIO::ERR_NOT_FILTER_PROTOCOL:
310  result = i18n( "The protocol %1 is not a filter protocol." ).arg( errorText );
311  break;
312  case KIO::ERR_COULD_NOT_MOUNT:
313  result = i18n( "Could not mount device.\nThe reported error was:\n%1" ).arg( errorText );
314  break;
315  case KIO::ERR_COULD_NOT_UNMOUNT:
316  result = i18n( "Could not unmount device.\nThe reported error was:\n%1" ).arg( errorText );
317  break;
318  case KIO::ERR_COULD_NOT_READ:
319  result = i18n( "Could not read file %1." ).arg( errorText );
320  break;
321  case KIO::ERR_COULD_NOT_WRITE:
322  result = i18n( "Could not write to file %1." ).arg( errorText );
323  break;
324  case KIO::ERR_COULD_NOT_BIND:
325  result = i18n( "Could not bind %1." ).arg( errorText );
326  break;
327  case KIO::ERR_COULD_NOT_LISTEN:
328  result = i18n( "Could not listen %1." ).arg( errorText );
329  break;
330  case KIO::ERR_COULD_NOT_ACCEPT:
331  result = i18n( "Could not accept %1." ).arg( errorText );
332  break;
333  case KIO::ERR_COULD_NOT_LOGIN:
334  result = errorText;
335  break;
336  case KIO::ERR_COULD_NOT_STAT:
337  result = i18n( "Could not access %1." ).arg( errorText );
338  break;
339  case KIO::ERR_COULD_NOT_CLOSEDIR:
340  result = i18n( "Could not terminate listing %1." ).arg( errorText );
341  break;
342  case KIO::ERR_COULD_NOT_MKDIR:
343  result = i18n( "Could not make folder %1." ).arg( errorText );
344  break;
345  case KIO::ERR_COULD_NOT_RMDIR:
346  result = i18n( "Could not remove folder %1." ).arg( errorText );
347  break;
348  case KIO::ERR_CANNOT_RESUME:
349  result = i18n( "Could not resume file %1." ).arg( errorText );
350  break;
351  case KIO::ERR_CANNOT_RENAME:
352  result = i18n( "Could not rename file %1." ).arg( errorText );
353  break;
354  case KIO::ERR_CANNOT_CHMOD:
355  result = i18n( "Could not change permissions for %1." ).arg( errorText );
356  break;
357  case KIO::ERR_CANNOT_DELETE:
358  result = i18n( "Could not delete file %1." ).arg( errorText );
359  break;
360  case KIO::ERR_SLAVE_DIED:
361  result = i18n( "The process for the %1 protocol died unexpectedly." ).arg( errorText );
362  break;
363  case KIO::ERR_OUT_OF_MEMORY:
364  result = i18n( "Error. Out of memory.\n%1" ).arg( errorText );
365  break;
366  case KIO::ERR_UNKNOWN_PROXY_HOST:
367  result = i18n( "Unknown proxy host\n%1" ).arg( errorText );
368  break;
369  case KIO::ERR_COULD_NOT_AUTHENTICATE:
370  result = i18n( "Authorization failed, %1 authentication not supported" ).arg( errorText );
371  break;
372  case KIO::ERR_ABORTED:
373  result = i18n( "User canceled action\n%1" ).arg( errorText );
374  break;
375  case KIO::ERR_INTERNAL_SERVER:
376  result = i18n( "Internal error in server\n%1" ).arg( errorText );
377  break;
378  case KIO::ERR_SERVER_TIMEOUT:
379  result = i18n( "Timeout on server\n%1" ).arg( errorText );
380  break;
381  case KIO::ERR_UNKNOWN:
382  result = i18n( "Unknown error\n%1" ).arg( errorText );
383  break;
384  case KIO::ERR_UNKNOWN_INTERRUPT:
385  result = i18n( "Unknown interrupt\n%1" ).arg( errorText );
386  break;
387 /*
388  case KIO::ERR_CHECKSUM_MISMATCH:
389  if (errorText)
390  result = i18n( "Warning: MD5 Checksum for %1 does not match checksum returned from server" ).arg(errorText);
391  else
392  result = i18n( "Warning: MD5 Checksum for %1 does not match checksum returned from server" ).arg("document");
393  break;
394 */
395  case KIO::ERR_CANNOT_DELETE_ORIGINAL:
396  result = i18n( "Could not delete original file %1.\nPlease check permissions." ).arg( errorText );
397  break;
398  case KIO::ERR_CANNOT_DELETE_PARTIAL:
399  result = i18n( "Could not delete partial file %1.\nPlease check permissions." ).arg( errorText );
400  break;
401  case KIO::ERR_CANNOT_RENAME_ORIGINAL:
402  result = i18n( "Could not rename original file %1.\nPlease check permissions." ).arg( errorText );
403  break;
404  case KIO::ERR_CANNOT_RENAME_PARTIAL:
405  result = i18n( "Could not rename partial file %1.\nPlease check permissions." ).arg( errorText );
406  break;
407  case KIO::ERR_CANNOT_SYMLINK:
408  result = i18n( "Could not create symlink %1.\nPlease check permissions." ).arg( errorText );
409  break;
410  case KIO::ERR_NO_CONTENT:
411  result = errorText;
412  break;
413  case KIO::ERR_DISK_FULL:
414  result = i18n( "Could not write file %1.\nDisk full." ).arg( errorText );
415  break;
416  case KIO::ERR_IDENTICAL_FILES:
417  result = i18n( "The source and destination are the same file.\n%1" ).arg( errorText );
418  break;
419  case KIO::ERR_SLAVE_DEFINED:
420  result = errorText;
421  break;
422  case KIO::ERR_UPGRADE_REQUIRED:
423  result = i18n( "%1 is required by the server, but is not available." ).arg(errorText);
424  break;
425  case KIO::ERR_POST_DENIED:
426  result = i18n( "Access to restricted port in POST denied.");
427  break;
428  case KIO::ERR_OFFLINE_MODE:
429  result = i18n( "Could not access %1.\nOffline mode active.").arg( errorText );
430  break;
431  default:
432  result = i18n( "Unknown error code %1\n%2\nPlease send a full bug report at http://bugs.trinitydesktop.org." ).arg( errorCode ).arg( errorText );
433  break;
434  }
435 
436  return result;
437 }
438 
439 KIO_EXPORT TQString KIO::unsupportedActionErrorString(const TQString &protocol, int cmd) {
440  switch (cmd) {
441  case CMD_CONNECT:
442  return i18n("Opening connections is not supported with the protocol %1." ).arg(protocol);
443  case CMD_DISCONNECT:
444  return i18n("Closing connections is not supported with the protocol %1." ).arg(protocol);
445  case CMD_STAT:
446  return i18n("Accessing files is not supported with the protocol %1.").arg(protocol);
447  case CMD_PUT:
448  return i18n("Writing to %1 is not supported.").arg(protocol);
449  case CMD_SPECIAL:
450  return i18n("There are no special actions available for protocol %1.").arg(protocol);
451  case CMD_LISTDIR:
452  return i18n("Listing folders is not supported for protocol %1.").arg(protocol);
453  case CMD_GET:
454  return i18n("Retrieving data from %1 is not supported.").arg(protocol);
455  case CMD_MIMETYPE:
456  return i18n("Retrieving mime type information from %1 is not supported.").arg(protocol);
457  case CMD_RENAME:
458  return i18n("Renaming or moving files within %1 is not supported.").arg(protocol);
459  case CMD_SYMLINK:
460  return i18n("Creating symlinks is not supported with protocol %1.").arg(protocol);
461  case CMD_COPY:
462  return i18n("Copying files within %1 is not supported.").arg(protocol);
463  case CMD_DEL:
464  return i18n("Deleting files from %1 is not supported.").arg(protocol);
465  case CMD_MKDIR:
466  return i18n("Creating folders is not supported with protocol %1.").arg(protocol);
467  case CMD_CHMOD:
468  return i18n("Changing the attributes of files is not supported with protocol %1.").arg(protocol);
469  case CMD_SUBURL:
470  return i18n("Using sub-URLs with %1 is not supported.").arg(protocol);
471  case CMD_MULTI_GET:
472  return i18n("Multiple get is not supported with protocol %1.").arg(protocol);
473  default:
474  return i18n("Protocol %1 does not support action %2.").arg(protocol).arg(cmd);
475  }/*end switch*/
476 }
477 
478 KIO_EXPORT TQStringList KIO::Job::detailedErrorStrings( const KURL *reqUrl /*= 0L*/,
479  int method /*= -1*/ ) const
480 {
481  TQString errorName, techName, description, ret2;
482  TQStringList causes, solutions, ret;
483 
484  TQByteArray raw = rawErrorDetail( m_error, m_errorText, reqUrl, method );
485  TQDataStream stream(raw, IO_ReadOnly);
486 
487  stream >> errorName >> techName >> description >> causes >> solutions;
488 
489  TQString url, protocol, datetime;
490  if ( reqUrl ) {
491  url = reqUrl->htmlURL();
492  protocol = reqUrl->protocol();
493  } else {
494  url = i18n( "(unknown)" );
495  }
496 
497  datetime = KGlobal::locale()->formatDateTime( TQDateTime::currentDateTime(),
498  false );
499 
500  ret << errorName;
501  ret << TQString::fromLatin1( "<qt><p><b>" ) + errorName +
502  TQString::fromLatin1( "</b></p><p>" ) + description +
503  TQString::fromLatin1( "</p>" );
504  ret2 = TQString::fromLatin1( "<qt><p>" );
505  if ( !techName.isEmpty() )
506  ret2 += i18n( "<b>Technical reason</b>: " ) + techName + TQString::fromLatin1( "</p>" );
507  ret2 += i18n( "</p><p><b>Details of the request</b>:" );
508  ret2 += i18n( "</p><ul><li>URL: %1</li>" ).arg( url );
509  if ( !protocol.isEmpty() ) {
510  ret2 += i18n( "<li>Protocol: %1</li>" ).arg( protocol );
511  }
512  ret2 += i18n( "<li>Date and time: %1</li>" ).arg( datetime );
513  ret2 += i18n( "<li>Additional information: %1</li></ul>" ).arg( m_errorText );
514  if ( !causes.isEmpty() ) {
515  ret2 += i18n( "<p><b>Possible causes</b>:</p><ul><li>" );
516  ret2 += causes.join( "</li><li>" );
517  ret2 += TQString::fromLatin1( "</li></ul>" );
518  }
519  if ( !solutions.isEmpty() ) {
520  ret2 += i18n( "<p><b>Possible solutions</b>:</p><ul><li>" );
521  ret2 += solutions.join( "</li><li>" );
522  ret2 += TQString::fromLatin1( "</li></ul>" );
523  }
524  ret << ret2;
525  return ret;
526 }
527 
528 KIO_EXPORT TQByteArray KIO::rawErrorDetail(int errorCode, const TQString &errorText,
529  const KURL *reqUrl /*= 0L*/, int /*method = -1*/ )
530 {
531  TQString url, host, protocol, datetime, domain, path, dir, filename;
532  bool isSlaveNetwork = false;
533  if ( reqUrl ) {
534  url = reqUrl->prettyURL();
535  host = reqUrl->host();
536  protocol = reqUrl->protocol();
537 
538  if ( host.left(4) == "www." )
539  domain = host.mid(4);
540  else
541  domain = host;
542 
543  path = reqUrl->path(1);
544  filename = reqUrl->fileName();
545  dir = path + filename;
546 
547  // detect if protocol is a network protocol...
548  // add your hacks here...
549  if ( protocol == "http" ||
550  protocol == "https" ||
551  protocol == "ftp" ||
552  protocol == "sftp" ||
553  protocol == "webdav" ||
554  protocol == "webdavs" ||
555  protocol == "finger" ||
556  protocol == "fish" ||
557  protocol == "gopher" ||
558  protocol == "imap" ||
559  protocol == "imaps" ||
560  protocol == "lan" ||
561  protocol == "ldap" ||
562  protocol == "mailto" ||
563  protocol == "news" ||
564  protocol == "nntp" ||
565  protocol == "pop3" ||
566  protocol == "pop3s" ||
567  protocol == "smtp" ||
568  protocol == "smtps" ||
569  protocol == "telnet"
570  ) {
571  isSlaveNetwork = false;
572  }
573  } else {
574  // assume that the errorText has the location we are interested in
575  url = host = domain = path = filename = dir = errorText;
576  protocol = i18n( "(unknown)" );
577  }
578 
579  datetime = KGlobal::locale()->formatDateTime( TQDateTime::currentDateTime(),
580  false );
581 
582  TQString errorName, techName, description;
583  TQStringList causes, solutions;
584 
585  // c == cause, s == solution
586  TQString sSysadmin = i18n( "Contact your appropriate computer support system, "
587  "whether the system administrator, or technical support group for further "
588  "assistance." );
589  TQString sServeradmin = i18n( "Contact the administrator of the server "
590  "for further assistance." );
591  // FIXME active link to permissions dialog
592  TQString sAccess = i18n( "Check your access permissions on this resource." );
593  TQString cAccess = i18n( "Your access permissions may be inadequate to "
594  "perform the requested operation on this resource." );
595  TQString cLocked = i18n( "The file may be in use (and thus locked) by "
596  "another user or application." );
597  TQString sQuerylock = i18n( "Check to make sure that no other "
598  "application or user is using the file or has locked the file." );
599  TQString cHardware = i18n( "Although unlikely, a hardware error may have "
600  "occurred." );
601  TQString cBug = i18n( "You may have encountered a bug in the program." );
602  TQString cBuglikely = i18n( "This is most likely to be caused by a bug in the "
603  "program. Please consider submitting a full bug report as detailed below." );
604  TQString sUpdate = i18n( "Update your software to the latest version. "
605  "Your distribution should provide tools to update your software." );
606  TQString sBugreport = i18n( "When all else fails, please consider helping the "
607  "KDE team or the third party maintainer of this software by submitting a "
608  "high quality bug report. If the software is provided by a third party, "
609  "please contact them directly. Otherwise, first look to see if "
610  "the same bug has been submitted by someone else by searching at the "
611  "<a href=\"http://bugs.trinitydesktop.org/\">TDE bug reporting website</a>. If not, take "
612  "note of the details given above, and include them in your bug report, along "
613  "with as many other details as you think might help." );
614  TQString cNetwork = i18n( "There may have been a problem with your network "
615  "connection." );
616  // FIXME netconf kcontrol link
617  TQString cNetconf = i18n( "There may have been a problem with your network "
618  "configuration. If you have been accessing the Internet with no problems "
619  "recently, this is unlikely." );
620  TQString cNetpath = i18n( "There may have been a problem at some point along "
621  "the network path between the server and this computer." );
622  TQString sTryagain = i18n( "Try again, either now or at a later time." );
623  TQString cProtocol = i18n( "A protocol error or incompatibility may have occurred." );
624  TQString sExists = i18n( "Ensure that the resource exists, and try again." );
625  TQString cExists = i18n( "The specified resource may not exist." );
626  TQString cTypo = i18n( "You may have incorrectly typed the location." );
627  TQString sTypo = i18n( "Double-check that you have entered the correct location "
628  "and try again." );
629  TQString sNetwork = i18n( "Check your network connection status." );
630 
631  switch( errorCode ) {
632  case KIO::ERR_CANNOT_OPEN_FOR_READING:
633  errorName = i18n( "Cannot Open Resource For Reading" );
634  description = i18n( "This means that the contents of the requested file "
635  "or folder <strong>%1</strong> could not be retrieved, as read "
636  "access could not be obtained." ).arg( dir );
637  causes << i18n( "You may not have permissions to read the file or open "
638  "the folder.") << cLocked << cHardware;
639  solutions << sAccess << sQuerylock << sSysadmin;
640  break;
641 
642  case KIO::ERR_CANNOT_OPEN_FOR_WRITING:
643  errorName = i18n( "Cannot Open Resource For Writing" );
644  description = i18n( "This means that the file, <strong>%1</strong>, could "
645  "not be written to as requested, because access with permission to "
646  "write could not be obtained." ).arg( filename );
647  causes << cAccess << cLocked << cHardware;
648  solutions << sAccess << sQuerylock << sSysadmin;
649  break;
650 
651  case KIO::ERR_CANNOT_LAUNCH_PROCESS:
652  errorName = i18n( "Cannot Initiate the %1 Protocol" ).arg( protocol );
653  techName = i18n( "Unable to Launch Process" );
654  description = i18n( "The program on your computer which provides access "
655  "to the <strong>%1</strong> protocol could not be started. This is "
656  "usually due to technical reasons." ).arg( protocol );
657  causes << i18n( "The program which provides compatibility with this "
658  "protocol may not have been updated with your last update of KDE. "
659  "This can cause the program to be incompatible with the current version "
660  "and thus not start." ) << cBug;
661  solutions << sUpdate << sSysadmin;
662  break;
663 
664  case KIO::ERR_INTERNAL:
665  errorName = i18n( "Internal Error" );
666  description = i18n( "The program on your computer which provides access "
667  "to the <strong>%1</strong> protocol has reported an internal error." )
668  .arg( protocol );
669  causes << cBuglikely;
670  solutions << sUpdate << sBugreport;
671  break;
672 
673  case KIO::ERR_MALFORMED_URL:
674  errorName = i18n( "Improperly Formatted URL" );
675  description = i18n( "The <strong>U</strong>niform <strong>R</strong>esource "
676  "<strong>L</strong>ocator (URL) that you entered was not properly "
677  "formatted. The format of a URL is generally as follows:"
678  "<blockquote><strong>protocol://user:password@www.example.org:port/folder/"
679  "filename.extension?query=value</strong></blockquote>" );
680  solutions << sTypo;
681  break;
682 
683  case KIO::ERR_UNSUPPORTED_PROTOCOL:
684  errorName = i18n( "Unsupported Protocol %1" ).arg( protocol );
685  description = i18n( "The protocol <strong>%1</strong> is not supported "
686  "by the KDE programs currently installed on this computer." )
687  .arg( protocol );
688  causes << i18n( "The requested protocol may not be supported." )
689  << i18n( "The versions of the %1 protocol supported by this computer and "
690  "the server may be incompatible." ).arg( protocol );
691  solutions << i18n( "You may perform a search on the Internet for a KDE "
692  "program (called a kioslave or ioslave) which supports this protocol. "
693  "Places to search include <a href=\"http://kde-apps.org/\">"
694  "http://kde-apps.org/</a> and <a href=\"http://freshmeat.net/\">"
695  "http://freshmeat.net/</a>." )
696  << sUpdate << sSysadmin;
697  break;
698 
699  case KIO::ERR_NO_SOURCE_PROTOCOL:
700  errorName = i18n( "URL Does Not Refer to a Resource." );
701  techName = i18n( "Protocol is a Filter Protocol" );
702  description = i18n( "The <strong>U</strong>niform <strong>R</strong>esource "
703  "<strong>L</strong>ocator (URL) that you entered did not refer to a "
704  "specific resource." );
705  causes << i18n( "KDE is able to communicate through a protocol within a "
706  "protocol; the protocol specified is only for use in such situations, "
707  "however this is not one of these situations. This is a rare event, and "
708  "is likely to indicate a programming error." );
709  solutions << sTypo;
710  break;
711 
712  case KIO::ERR_UNSUPPORTED_ACTION:
713  errorName = i18n( "Unsupported Action: %1" ).arg( errorText );
714  description = i18n( "The requested action is not supported by the KDE "
715  "program which is implementing the <strong>%1</strong> protocol." )
716  .arg( protocol );
717  causes << i18n( "This error is very much dependent on the KDE program. The "
718  "additional information should give you more information than is available "
719  "to the KDE input/output architecture." );
720  solutions << i18n( "Attempt to find another way to accomplish the same "
721  "outcome." );
722  break;
723 
724  case KIO::ERR_IS_DIRECTORY:
725  errorName = i18n( "File Expected" );
726  description = i18n( "The request expected a file, however the "
727  "folder <strong>%1</strong> was found instead." ).arg( dir );
728  causes << i18n( "This may be an error on the server side." ) << cBug;
729  solutions << sUpdate << sSysadmin;
730  break;
731 
732  case KIO::ERR_IS_FILE:
733  errorName = i18n( "Folder Expected" );
734  description = i18n( "The request expected a folder, however "
735  "the file <strong>%1</strong> was found instead." ).arg( filename );
736  causes << cBug;
737  solutions << sUpdate << sSysadmin;
738  break;
739 
740  case KIO::ERR_DOES_NOT_EXIST:
741  errorName = i18n( "File or Folder Does Not Exist" );
742  description = i18n( "The specified file or folder <strong>%1</strong> "
743  "does not exist." ).arg( dir );
744  causes << cBug;
745  solutions << sUpdate << sSysadmin;
746  break;
747 
748  case KIO::ERR_FILE_ALREADY_EXIST:
749  errorName = i18n( "File Already Exists" );
750  description = i18n( "The requested file could not be created because a "
751  "file with the same name already exists." );
752  solutions << i18n ( "Try moving the current file out of the way first, "
753  "and then try again." )
754  << i18n ( "Delete the current file and try again." )
755  << i18n( "Choose an alternate filename for the new file." );
756  break;
757 
758  case KIO::ERR_DIR_ALREADY_EXIST:
759  errorName = i18n( "Folder Already Exists" );
760  description = i18n( "The requested folder could not be created because "
761  "a folder with the same name already exists." );
762  solutions << i18n( "Try moving the current folder out of the way first, "
763  "and then try again." )
764  << i18n( "Delete the current folder and try again." )
765  << i18n( "Choose an alternate name for the new folder." );
766  break;
767 
768  case KIO::ERR_UNKNOWN_HOST:
769  errorName = i18n( "Unknown Host" );
770  description = i18n( "An unknown host error indicates that the server with "
771  "the requested name, <strong>%1</strong>, could not be "
772  "located on the Internet." ).arg( host );
773  causes << i18n( "The name that you typed, %1, may not exist: it may be "
774  "incorrectly typed." ).arg( host )
775  << cNetwork << cNetconf;
776  solutions << sNetwork << sSysadmin;
777  break;
778 
779  case KIO::ERR_ACCESS_DENIED:
780  errorName = i18n( "Access Denied" );
781  description = i18n( "Access was denied to the specified resource, "
782  "<strong>%1</strong>." ).arg( url );
783  causes << i18n( "You may have supplied incorrect authentication details or "
784  "none at all." )
785  << i18n( "Your account may not have permission to access the "
786  "specified resource." );
787  solutions << i18n( "Retry the request and ensure your authentication details "
788  "are entered correctly." ) << sSysadmin;
789  if ( !isSlaveNetwork ) solutions << sServeradmin;
790  break;
791 
792  case KIO::ERR_WRITE_ACCESS_DENIED:
793  errorName = i18n( "Write Access Denied" );
794  description = i18n( "This means that an attempt to write to the file "
795  "<strong>%1</strong> was rejected." ).arg( filename );
796  causes << cAccess << cLocked << cHardware;
797  solutions << sAccess << sQuerylock << sSysadmin;
798  break;
799 
800  case KIO::ERR_CANNOT_ENTER_DIRECTORY:
801  errorName = i18n( "Unable to Enter Folder" );
802  description = i18n( "This means that an attempt to enter (in other words, "
803  "to open) the requested folder <strong>%1</strong> was rejected." )
804  .arg( dir );
805  causes << cAccess << cLocked;
806  solutions << sAccess << sQuerylock << sSysadmin;
807  break;
808 
809  case KIO::ERR_PROTOCOL_IS_NOT_A_FILESYSTEM:
810  errorName = i18n( "Folder Listing Unavailable" );
811  techName = i18n( "Protocol %1 is not a Filesystem" ).arg( protocol );
812  description = i18n( "This means that a request was made which requires "
813  "determining the contents of the folder, and the KDE program supporting "
814  "this protocol is unable to do so." );
815  causes << cBug;
816  solutions << sUpdate << sBugreport;
817  break;
818 
819  case KIO::ERR_CYCLIC_LINK:
820  errorName = i18n( "Cyclic Link Detected" );
821  description = i18n( "UNIX environments are commonly able to link a file or "
822  "folder to a separate name and/or location. KDE detected a link or "
823  "series of links that results in an infinite loop - i.e. the file was "
824  "(perhaps in a roundabout way) linked to itself." );
825  solutions << i18n( "Delete one part of the loop in order that it does not "
826  "cause an infinite loop, and try again." ) << sSysadmin;
827  break;
828 
829  case KIO::ERR_USER_CANCELED:
830  // Do nothing in this case. The user doesn't need to be told what he just did.
831  // rodda: However, if we have been called, an application is about to display
832  // this information anyway. If we don't return sensible information, the
833  // user sees a blank dialog (I have seen this myself)
834  errorName = i18n( "Request Aborted By User" );
835  description = i18n( "The request was not completed because it was "
836  "aborted." );
837  solutions << i18n( "Retry the request." );
838  break;
839 
840  case KIO::ERR_CYCLIC_COPY:
841  errorName = i18n( "Cyclic Link Detected During Copy" );
842  description = i18n( "UNIX environments are commonly able to link a file or "
843  "folder to a separate name and/or location. During the requested copy "
844  "operation, KDE detected a link or series of links that results in an "
845  "infinite loop - i.e. the file was (perhaps in a roundabout way) linked "
846  "to itself." );
847  solutions << i18n( "Delete one part of the loop in order that it does not "
848  "cause an infinite loop, and try again." ) << sSysadmin;
849  break;
850 
851  case KIO::ERR_COULD_NOT_CREATE_SOCKET:
852  errorName = i18n( "Could Not Create Network Connection" );
853  techName = i18n( "Could Not Create Socket" );
854  description = i18n( "This is a fairly technical error in which a required "
855  "device for network communications (a socket) could not be created." );
856  causes << i18n( "The network connection may be incorrectly configured, or "
857  "the network interface may not be enabled." );
858  solutions << sNetwork << sSysadmin;
859  break;
860 
861  case KIO::ERR_COULD_NOT_CONNECT:
862  errorName = i18n( "Connection to Server Refused" );
863  description = i18n( "The server <strong>%1</strong> refused to allow this "
864  "computer to make a connection." ).arg( host );
865  causes << i18n( "The server, while currently connected to the Internet, "
866  "may not be configured to allow requests." )
867  << i18n( "The server, while currently connected to the Internet, "
868  "may not be running the requested service (%1)." ).arg( protocol )
869  << i18n( "A network firewall (a device which restricts Internet "
870  "requests), either protecting your network or the network of the server, "
871  "may have intervened, preventing this request." );
872  solutions << sTryagain << sServeradmin << sSysadmin;
873  break;
874 
875  case KIO::ERR_CONNECTION_BROKEN:
876  errorName = i18n( "Connection to Server Closed Unexpectedly" );
877  description = i18n( "Although a connection was established to "
878  "<strong>%1</strong>, the connection was closed at an unexpected point "
879  "in the communication." ).arg( host );
880  causes << cNetwork << cNetpath << i18n( "A protocol error may have occurred, "
881  "causing the server to close the connection as a response to the error." );
882  solutions << sTryagain << sServeradmin << sSysadmin;
883  break;
884 
885  case KIO::ERR_NOT_FILTER_PROTOCOL:
886  errorName = i18n( "URL Resource Invalid" );
887  techName = i18n( "Protocol %1 is not a Filter Protocol" ).arg( protocol );
888  description = i18n( "The <strong>U</strong>niform <strong>R</strong>esource "
889  "<strong>L</strong>ocator (URL) that you entered did not refer to "
890  "a valid mechanism of accessing the specific resource, "
891  "<strong>%1%2</strong>." )
892  .arg( !host.isNull() ? host + '/' : TQString::null ).arg( dir );
893  causes << i18n( "KDE is able to communicate through a protocol within a "
894  "protocol. This request specified a protocol be used as such, however "
895  "this protocol is not capable of such an action. This is a rare event, "
896  "and is likely to indicate a programming error." );
897  solutions << sTypo << sSysadmin;
898  break;
899 
900  case KIO::ERR_COULD_NOT_MOUNT:
901  errorName = i18n( "Unable to Initialize Input/Output Device" );
902  techName = i18n( "Could Not Mount Device" );
903  description = i18n( "The requested device could not be initialized "
904  "(\"mounted\"). The reported error was: <strong>%1</strong>" )
905  .arg( errorText );
906  causes << i18n( "The device may not be ready, for example there may be "
907  "no media in a removable media device (i.e. no CD-ROM in a CD drive), "
908  "or in the case of a peripheral/portable device, the device may not "
909  "be correctly connected." )
910  << i18n( "You may not have permissions to initialize (\"mount\") the "
911  "device. On UNIX systems, often system administrator privileges are "
912  "required to initialize a device." )
913  << cHardware;
914  solutions << i18n( "Check that the device is ready; removable drives "
915  "must contain media, and portable devices must be connected and powered "
916  "on.; and try again." ) << sAccess << sSysadmin;
917  break;
918 
919  case KIO::ERR_COULD_NOT_UNMOUNT:
920  errorName = i18n( "Unable to Uninitialize Input/Output Device" );
921  techName = i18n( "Could Not Unmount Device" );
922  description = i18n( "The requested device could not be uninitialized "
923  "(\"unmounted\"). The reported error was: <strong>%1</strong>" )
924  .arg( errorText );
925  causes << i18n( "The device may be busy, that is, still in use by "
926  "another application or user. Even such things as having an open "
927  "browser window on a location on this device may cause the device to "
928  "remain in use." )
929  << i18n( "You may not have permissions to uninitialize (\"unmount\") "
930  "the device. On UNIX systems, system administrator privileges are "
931  "often required to uninitialize a device." )
932  << cHardware;
933  solutions << i18n( "Check that no applications are accessing the device, "
934  "and try again." ) << sAccess << sSysadmin;
935  break;
936 
937  case KIO::ERR_COULD_NOT_READ:
938  errorName = i18n( "Cannot Read From Resource" );
939  description = i18n( "This means that although the resource, "
940  "<strong>%1</strong>, was able to be opened, an error occurred while "
941  "reading the contents of the resource." ).arg( url );
942  causes << i18n( "You may not have permissions to read from the resource." );
943  if ( !isSlaveNetwork ) causes << cNetwork;
944  causes << cHardware;
945  solutions << sAccess;
946  if ( !isSlaveNetwork ) solutions << sNetwork;
947  solutions << sSysadmin;
948  break;
949 
950  case KIO::ERR_COULD_NOT_WRITE:
951  errorName = i18n( "Cannot Write to Resource" );
952  description = i18n( "This means that although the resource, <strong>%1</strong>"
953  ", was able to be opened, an error occurred while writing to the resource." )
954  .arg( url );
955  causes << i18n( "You may not have permissions to write to the resource." );
956  if ( !isSlaveNetwork ) causes << cNetwork;
957  causes << cHardware;
958  solutions << sAccess;
959  if ( !isSlaveNetwork ) solutions << sNetwork;
960  solutions << sSysadmin;
961  break;
962 
963  case KIO::ERR_COULD_NOT_BIND:
964  errorName = i18n( "Could Not Listen for Network Connections" );
965  techName = i18n( "Could Not Bind" );
966  description = i18n( "This is a fairly technical error in which a required "
967  "device for network communications (a socket) could not be established "
968  "to listen for incoming network connections." );
969  causes << i18n( "The network connection may be incorrectly configured, or "
970  "the network interface may not be enabled." );
971  solutions << sNetwork << sSysadmin;
972  break;
973 
974  case KIO::ERR_COULD_NOT_LISTEN:
975  errorName = i18n( "Could Not Listen for Network Connections" );
976  techName = i18n( "Could Not Listen" );
977  description = i18n( "This is a fairly technical error in which a required "
978  "device for network communications (a socket) could not be established "
979  "to listen for incoming network connections." );
980  causes << i18n( "The network connection may be incorrectly configured, or "
981  "the network interface may not be enabled." );
982  solutions << sNetwork << sSysadmin;
983  break;
984 
985  case KIO::ERR_COULD_NOT_ACCEPT:
986  errorName = i18n( "Could Not Accept Network Connection" );
987  description = i18n( "This is a fairly technical error in which an error "
988  "occurred while attempting to accept an incoming network connection." );
989  causes << i18n( "The network connection may be incorrectly configured, or "
990  "the network interface may not be enabled." )
991  << i18n( "You may not have permissions to accept the connection." );
992  solutions << sNetwork << sSysadmin;
993  break;
994 
995  case KIO::ERR_COULD_NOT_LOGIN:
996  errorName = i18n( "Could Not Login: %1" ).arg( errorText );
997  description = i18n( "An attempt to login to perform the requested "
998  "operation was unsuccessful." );
999  causes << i18n( "You may have supplied incorrect authentication details or "
1000  "none at all." )
1001  << i18n( "Your account may not have permission to access the "
1002  "specified resource." ) << cProtocol;
1003  solutions << i18n( "Retry the request and ensure your authentication details "
1004  "are entered correctly." ) << sServeradmin << sSysadmin;
1005  break;
1006 
1007  case KIO::ERR_COULD_NOT_STAT:
1008  errorName = i18n( "Could Not Determine Resource Status" );
1009  techName = i18n( "Could Not Stat Resource" );
1010  description = i18n( "An attempt to determine information about the status "
1011  "of the resource <strong>%1</strong>, such as the resource name, type, "
1012  "size, etc., was unsuccessful." ).arg( url );
1013  causes << i18n( "The specified resource may not have existed or may "
1014  "not be accessible." ) << cProtocol << cHardware;
1015  solutions << i18n( "Retry the request and ensure your authentication details "
1016  "are entered correctly." ) << sSysadmin;
1017  break;
1018 
1019  case KIO::ERR_COULD_NOT_CLOSEDIR:
1020  //result = i18n( "Could not terminate listing %1" ).arg( errorText );
1021  errorName = i18n( "Could Not Cancel Listing" );
1022  techName = i18n( "FIXME: Document this" );
1023  break;
1024 
1025  case KIO::ERR_COULD_NOT_MKDIR:
1026  errorName = i18n( "Could Not Create Folder" );
1027  description = i18n( "An attempt to create the requested folder failed." );
1028  causes << cAccess << i18n( "The location where the folder was to be created "
1029  "may not exist." );
1030  if ( !isSlaveNetwork ) causes << cProtocol;
1031  solutions << i18n( "Retry the request." ) << sAccess;
1032  break;
1033 
1034  case KIO::ERR_COULD_NOT_RMDIR:
1035  errorName = i18n( "Could Not Remove Folder" );
1036  description = i18n( "An attempt to remove the specified folder, "
1037  "<strong>%1</strong>, failed." ).arg( dir );
1038  causes << i18n( "The specified folder may not exist." )
1039  << i18n( "The specified folder may not be empty." )
1040  << cAccess;
1041  if ( !isSlaveNetwork ) causes << cProtocol;
1042  solutions << i18n( "Ensure that the folder exists and is empty, and try "
1043  "again." ) << sAccess;
1044  break;
1045 
1046  case KIO::ERR_CANNOT_RESUME:
1047  errorName = i18n( "Could Not Resume File Transfer" );
1048  description = i18n( "The specified request asked that the transfer of "
1049  "file <strong>%1</strong> be resumed at a certain point of the "
1050  "transfer. This was not possible." ).arg( filename );
1051  causes << i18n( "The protocol, or the server, may not support file "
1052  "resuming." );
1053  solutions << i18n( "Retry the request without attempting to resume "
1054  "transfer." );
1055  break;
1056 
1057  case KIO::ERR_CANNOT_RENAME:
1058  errorName = i18n( "Could Not Rename Resource" );
1059  description = i18n( "An attempt to rename the specified resource "
1060  "<strong>%1</strong> failed." ).arg( url );
1061  causes << cAccess << cExists;
1062  if ( !isSlaveNetwork ) causes << cProtocol;
1063  solutions << sAccess << sExists;
1064  break;
1065 
1066  case KIO::ERR_CANNOT_CHMOD:
1067  errorName = i18n( "Could Not Alter Permissions of Resource" );
1068  description = i18n( "An attempt to alter the permissions on the specified "
1069  "resource <strong>%1</strong> failed." ).arg( url );
1070  causes << cAccess << cExists;
1071  solutions << sAccess << sExists;
1072  break;
1073 
1074  case KIO::ERR_CANNOT_DELETE:
1075  errorName = i18n( "Could Not Delete Resource" );
1076  description = i18n( "An attempt to delete the specified resource "
1077  "<strong>%1</strong> failed." ).arg( url );
1078  causes << cAccess << cExists;
1079  solutions << sAccess << sExists;
1080  break;
1081 
1082  case KIO::ERR_SLAVE_DIED:
1083  errorName = i18n( "Unexpected Program Termination" );
1084  description = i18n( "The program on your computer which provides access "
1085  "to the <strong>%1</strong> protocol has unexpectedly terminated." )
1086  .arg( url );
1087  causes << cBuglikely;
1088  solutions << sUpdate << sBugreport;
1089  break;
1090 
1091  case KIO::ERR_OUT_OF_MEMORY:
1092  errorName = i18n( "Out of Memory" );
1093  description = i18n( "The program on your computer which provides access "
1094  "to the <strong>%1</strong> protocol could not obtain the memory "
1095  "required to continue." ).arg( protocol );
1096  causes << cBuglikely;
1097  solutions << sUpdate << sBugreport;
1098  break;
1099 
1100  case KIO::ERR_UNKNOWN_PROXY_HOST:
1101  errorName = i18n( "Unknown Proxy Host" );
1102  description = i18n( "While retrieving information about the specified "
1103  "proxy host, <strong>%1</strong>, an Unknown Host error was encountered. "
1104  "An unknown host error indicates that the requested name could not be "
1105  "located on the Internet." ).arg( errorText );
1106  causes << i18n( "There may have been a problem with your network "
1107  "configuration, specifically your proxy's hostname. If you have been "
1108  "accessing the Internet with no problems recently, this is unlikely." )
1109  << cNetwork;
1110  solutions << i18n( "Double-check your proxy settings and try again." )
1111  << sSysadmin;
1112  break;
1113 
1114  case KIO::ERR_COULD_NOT_AUTHENTICATE:
1115  errorName = i18n( "Authentication Failed: Method %1 Not Supported" )
1116  .arg( errorText );
1117  description = i18n( "Although you may have supplied the correct "
1118  "authentication details, the authentication failed because the "
1119  "method that the server is using is not supported by the KDE "
1120  "program implementing the protocol %1." ).arg( protocol );
1121  solutions << i18n( "Please file a bug at <a href=\"http://bugs.trinitydesktop.org/\">"
1122  "http://bugs.trinitydesktop.org/</a> to inform the TDE team of the unsupported "
1123  "authentication method." ) << sSysadmin;
1124  break;
1125 
1126  case KIO::ERR_ABORTED:
1127  errorName = i18n( "Request Aborted" );
1128  description = i18n( "The request was not completed because it was "
1129  "aborted." );
1130  solutions << i18n( "Retry the request." );
1131  break;
1132 
1133  case KIO::ERR_INTERNAL_SERVER:
1134  errorName = i18n( "Internal Error in Server" );
1135  description = i18n( "The program on the server which provides access "
1136  "to the <strong>%1</strong> protocol has reported an internal error: "
1137  "%0." ).arg( protocol );
1138  causes << i18n( "This is most likely to be caused by a bug in the "
1139  "server program. Please consider submitting a full bug report as "
1140  "detailed below." );
1141  solutions << i18n( "Contact the administrator of the server "
1142  "to advise them of the problem." )
1143  << i18n( "If you know who the authors of the server software are, "
1144  "submit the bug report directly to them." );
1145  break;
1146 
1147  case KIO::ERR_SERVER_TIMEOUT:
1148  errorName = i18n( "Timeout Error" );
1149  description = i18n( "Although contact was made with the server, a "
1150  "response was not received within the amount of time allocated for "
1151  "the request as follows:<ul>"
1152  "<li>Timeout for establishing a connection: %1 seconds</li>"
1153  "<li>Timeout for receiving a response: %2 seconds</li>"
1154  "<li>Timeout for accessing proxy servers: %3 seconds</li></ul>"
1155  "Please note that you can alter these timeout settings in the KDE "
1156  "Control Center, by selecting Network -> Preferences." )
1157  .arg( KProtocolManager::connectTimeout() )
1158  .arg( KProtocolManager::responseTimeout() )
1159  .arg( KProtocolManager::proxyConnectTimeout() );
1160  causes << cNetpath << i18n( "The server was too busy responding to other "
1161  "requests to respond." );
1162  solutions << sTryagain << sServeradmin;
1163  break;
1164 
1165  case KIO::ERR_UNKNOWN:
1166  errorName = i18n( "Unknown Error" );
1167  description = i18n( "The program on your computer which provides access "
1168  "to the <strong>%1</strong> protocol has reported an unknown error: "
1169  "%2." ).arg( protocol ).arg( errorText );
1170  causes << cBug;
1171  solutions << sUpdate << sBugreport;
1172  break;
1173 
1174  case KIO::ERR_UNKNOWN_INTERRUPT:
1175  errorName = i18n( "Unknown Interruption" );
1176  description = i18n( "The program on your computer which provides access "
1177  "to the <strong>%1</strong> protocol has reported an interruption of "
1178  "an unknown type: %2." ).arg( protocol ).arg( errorText );
1179  causes << cBug;
1180  solutions << sUpdate << sBugreport;
1181  break;
1182 
1183  case KIO::ERR_CANNOT_DELETE_ORIGINAL:
1184  errorName = i18n( "Could Not Delete Original File" );
1185  description = i18n( "The requested operation required the deleting of "
1186  "the original file, most likely at the end of a file move operation. "
1187  "The original file <strong>%1</strong> could not be deleted." )
1188  .arg( errorText );
1189  causes << cAccess;
1190  solutions << sAccess;
1191  break;
1192 
1193  case KIO::ERR_CANNOT_DELETE_PARTIAL:
1194  errorName = i18n( "Could Not Delete Temporary File" );
1195  description = i18n( "The requested operation required the creation of "
1196  "a temporary file in which to save the new file while being "
1197  "downloaded. This temporary file <strong>%1</strong> could not be "
1198  "deleted." ).arg( errorText );
1199  causes << cAccess;
1200  solutions << sAccess;
1201  break;
1202 
1203  case KIO::ERR_CANNOT_RENAME_ORIGINAL:
1204  errorName = i18n( "Could Not Rename Original File" );
1205  description = i18n( "The requested operation required the renaming of "
1206  "the original file <strong>%1</strong>, however it could not be "
1207  "renamed." ).arg( errorText );
1208  causes << cAccess;
1209  solutions << sAccess;
1210  break;
1211 
1212  case KIO::ERR_CANNOT_RENAME_PARTIAL:
1213  errorName = i18n( "Could Not Rename Temporary File" );
1214  description = i18n( "The requested operation required the creation of "
1215  "a temporary file <strong>%1</strong>, however it could not be "
1216  "created." ).arg( errorText );
1217  causes << cAccess;
1218  solutions << sAccess;
1219  break;
1220 
1221  case KIO::ERR_CANNOT_SYMLINK:
1222  errorName = i18n( "Could Not Create Link" );
1223  techName = i18n( "Could Not Create Symbolic Link" );
1224  description = i18n( "The requested symbolic link %1 could not be created." )
1225  .arg( errorText );
1226  causes << cAccess;
1227  solutions << sAccess;
1228  break;
1229 
1230  case KIO::ERR_NO_CONTENT:
1231  errorName = i18n( "No Content" );
1232  description = errorText;
1233  break;
1234 
1235  case KIO::ERR_DISK_FULL:
1236  errorName = i18n( "Disk Full" );
1237  description = i18n( "The requested file <strong>%1</strong> could not be "
1238  "written to as there is inadequate disk space." ).arg( errorText );
1239  solutions << i18n( "Free up enough disk space by 1) deleting unwanted and "
1240  "temporary files; 2) archiving files to removable media storage such as "
1241  "CD-Recordable discs; or 3) obtain more storage capacity." )
1242  << sSysadmin;
1243  break;
1244 
1245  case KIO::ERR_IDENTICAL_FILES:
1246  errorName = i18n( "Source and Destination Files Identical" );
1247  description = i18n( "The operation could not be completed because the "
1248  "source and destination files are the same file." );
1249  solutions << i18n( "Choose a different filename for the destination file." );
1250  break;
1251 
1252  // We assume that the slave has all the details
1253  case KIO::ERR_SLAVE_DEFINED:
1254  errorName = TQString::null;
1255  description = errorText;
1256  break;
1257 
1258  default:
1259  // fall back to the plain error...
1260  errorName = i18n( "Undocumented Error" );
1261  description = buildErrorString( errorCode, errorText );
1262  }
1263 
1264  TQByteArray ret;
1265  TQDataStream stream(ret, IO_WriteOnly);
1266  stream << errorName << techName << description << causes << solutions;
1267  return ret;
1268 }
1269 
1270 #ifdef Q_OS_UNIX
1271 
1272 #include <limits.h>
1273 #include <stdlib.h>
1274 #include <stdio.h>
1275 #include <tqfile.h>
1276 
1277 #include <config.h>
1278 
1279 #ifdef HAVE_PATHS_H
1280 #include <paths.h>
1281 #endif
1282 #ifdef HAVE_SYS_STAT_H
1283 #include <sys/stat.h>
1284 #endif
1285 #include <sys/param.h>
1286 #ifdef HAVE_LIMITS_H
1287 #include <limits.h>
1288 #endif
1289 #ifdef HAVE_SYS_MNTTAB_H
1290 #include <sys/mnttab.h>
1291 #endif
1292 #ifdef HAVE_MNTENT_H
1293 #include <mntent.h>
1294 #elif defined(HAVE_SYS_MNTENT_H)
1295 #include <sys/mntent.h>
1296 #endif
1297 #ifdef HAVE_SYS_UCRED_H
1298 #include <sys/ucred.h>
1299 #endif
1300 #ifdef HAVE_SYS_MOUNT_H
1301 #include <sys/mount.h>
1302 #endif
1303 #ifdef HAVE_FSTAB_H
1304 #include <fstab.h>
1305 #endif
1306 #if defined(_AIX)
1307 #include <sys/mntctl.h>
1308 #include <sys/vmount.h>
1309 #include <sys/vfs.h>
1310 
1311 /* AIX does not prototype mntctl anywhere that I can find */
1312 #ifndef mntctl
1313 extern "C" {
1314 int mntctl(int command, int size, void* buffer);
1315 }
1316 #endif
1317 extern "C" struct vfs_ent *getvfsbytype(int vfsType);
1318 extern "C" void endvfsent( );
1319 #endif
1320 
1321 /***************************************************************
1322  *
1323  * Utility functions
1324  *
1325  ***************************************************************/
1326 
1327 #ifndef HAVE_GETMNTINFO
1328 
1329 #ifdef _PATH_MOUNTED
1330 // On some Linux, MNTTAB points to /etc/fstab !
1331 # undef MNTTAB
1332 # define MNTTAB _PATH_MOUNTED
1333 #else
1334 # ifndef MNTTAB
1335 # ifdef MTAB_FILE
1336 # define MNTTAB MTAB_FILE
1337 # else
1338 # define MNTTAB "/etc/mnttab"
1339 # endif
1340 # endif
1341 #endif
1342 
1343 #ifndef FSTAB
1344 # ifdef _PATH_FSTAB
1345 # define FSTAB _PATH_FSTAB
1346 # else
1347 # define FSTAB "/etc/fstab"
1348 # endif
1349 #endif
1350 
1351 #ifdef __CYGWIN__
1352 #define hasmntopt(var,opt) (0)
1353 #endif
1354 
1355 // There are (at least) four kind of APIs:
1356 // setmntent + getmntent + struct mntent (linux...)
1357 // getmntent + struct mnttab
1358 // mntctl + struct vmount (AIX)
1359 // getmntinfo + struct statfs&flags (BSD 4.4 and friends)
1360 // getfsent + char* (BSD 4.3 and friends)
1361 
1362 #ifdef HAVE_SETMNTENT
1363 #define SETMNTENT setmntent
1364 #define ENDMNTENT endmntent
1365 #define STRUCT_MNTENT struct mntent *
1366 #define STRUCT_SETMNTENT FILE *
1367 #define GETMNTENT(file, var) ((var = getmntent(file)) != 0)
1368 #define MOUNTPOINT(var) var->mnt_dir
1369 #define MOUNTTYPE(var) var->mnt_type
1370 #define HASMNTOPT(var, opt) hasmntopt(var, opt)
1371 #define FSNAME(var) var->mnt_fsname
1372 #elif defined(_AIX)
1373 /* we don't need this stuff */
1374 #else
1375 #define SETMNTENT fopen
1376 #define ENDMNTENT fclose
1377 #define STRUCT_MNTENT struct mnttab
1378 #define STRUCT_SETMNTENT FILE *
1379 #define GETMNTENT(file, var) (getmntent(file, &var) == 0)
1380 #define MOUNTPOINT(var) var.mnt_mountp
1381 #define MOUNTTYPE(var) var.mnt_fstype
1382 #define HASMNTOPT(var, opt) hasmntopt(&var, opt)
1383 #define FSNAME(var) var.mnt_special
1384 #endif
1385 
1386 #endif /* HAVE_GETMNTINFO */
1387 
1388 TQString KIO::findDeviceMountPoint( const TQString& filename )
1389 {
1390  TQString result;
1391 
1392 #ifdef HAVE_VOLMGT
1393  /*
1394  * support for Solaris volume management
1395  */
1396  const char *volpath;
1397  FILE *mnttab;
1398  struct mnttab mnt;
1399  int len;
1400  TQCString devname;
1401 
1402  if( (volpath = volmgt_root()) == NULL ) {
1403  kdDebug( 7007 ) << "findDeviceMountPoint: "
1404  << "VOLMGT: can't find volmgt root dir" << endl;
1405  return TQString::null;
1406  }
1407 
1408  if( (mnttab = fopen( MNTTAB, "r" )) == NULL ) {
1409  kdDebug( 7007 ) << "findDeviceMountPoint: "
1410  << "VOLMGT: can't open mnttab" << endl;
1411  return TQString::null;
1412  }
1413 
1414  devname = volpath;
1415  devname += TQFile::encodeName( filename );
1416  devname += '/';
1417  len = devname.length();
1418 // kdDebug( 7007 ) << "findDeviceMountPoint: "
1419 // << "VOLMGT: searching mountpoint for \"" << devname << "\""
1420 // << endl;
1421 
1422  /*
1423  * find the mountpoint
1424  * floppies:
1425  * /dev/disketteN => <volpath>/dev/disketteN
1426  * CDROM, ZIP, and other media:
1427  * /dev/dsk/cXtYdZs2 => <volpath>/dev/dsk/cXtYdZ (without slice#)
1428  */
1429  rewind( mnttab );
1430  result = TQString::null;
1431  while( getmntent( mnttab, &mnt ) == 0 ) {
1432  /*
1433  * either match the exact device name (floppies),
1434  * or the device name without the slice#
1435  */
1436  if( strncmp( devname.data(), mnt.mnt_special, len ) == 0
1437  || (strncmp( devname.data(), mnt.mnt_special, len - 3 ) == 0
1438  && mnt.mnt_special[len - 3] == '/' )
1439  || (strcmp(TQFile::encodeName(filename).data()
1440  , mnt.mnt_special)==0)) {
1441  result = mnt.mnt_mountp;
1442  break;
1443  }
1444  }
1445  fclose( mnttab );
1446 #else
1447 
1448  char realpath_buffer[MAXPATHLEN];
1449  TQCString realname;
1450 
1451  realname = TQFile::encodeName(filename);
1452  /* If the path contains symlinks, get the real name */
1453  if (realpath(realname, realpath_buffer) != 0)
1454  // succes, use result from realpath
1455  realname = realpath_buffer;
1456 
1457  //kdDebug(7007) << "findDeviceMountPoint realname=" << realname << endl;
1458 
1459 #ifdef HAVE_GETMNTINFO
1460 
1461 #ifdef GETMNTINFO_USES_STATVFS
1462  struct statvfs *mounted;
1463 #else
1464  struct statfs *mounted;
1465 #endif
1466 
1467  int num_fs = getmntinfo(&mounted, MNT_NOWAIT);
1468 
1469  for (int i=0;i<num_fs;i++) {
1470 
1471  TQCString device_name = mounted[i].f_mntfromname;
1472 
1473  // If the path contains symlinks, get
1474  // the real name
1475  if (realpath(device_name, realpath_buffer) != 0)
1476  // succes, use result from realpath
1477  device_name = realpath_buffer;
1478 
1479  if (realname == device_name) {
1480  result = mounted[i].f_mntonname;
1481  break;
1482  }
1483  }
1484 
1485 #elif defined(_AIX)
1486 
1487  struct vmount *mntctl_buffer;
1488  struct vmount *vm;
1489  char *mountedfrom;
1490  char *mountedto;
1491  int fsname_len, num;
1492  int buf_sz = 4096;
1493 
1494  /* mntctl can be used to query mounted file systems.
1495  * mntctl takes only the command MCTL_QUERY so far.
1496  * The buffer is filled with an array of vmount structures, but these
1497  * vmount structures have variable size.
1498  * mntctl return values:
1499  * -1 error
1500  * 0 look in first word of buffer for required bytes, 4096 may be
1501  * a good starting size, but if tables grow too large, look here.
1502  * >0 number of vmount structures
1503  */
1504  mntctl_buffer = (struct vmount*)malloc(buf_sz);
1505  num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
1506  if (num == 0)
1507  {
1508  buf_sz = *(int*)mntctl_buffer;
1509  free(mntctl_buffer);
1510  mntctl_buffer = (struct vmount*)malloc(buf_sz);
1511  num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
1512  }
1513 
1514  if (num > 0)
1515  {
1516  /* iterate through items in the vmount structure: */
1517  vm = mntctl_buffer;
1518  for ( ; num > 0; num-- )
1519  {
1520  /* get the name of the mounted file systems: */
1521  fsname_len = vmt2datasize(vm, VMT_STUB);
1522  mountedto = (char*)malloc(fsname_len + 1);
1523  mountedto[fsname_len] = '\0';
1524  strncpy(mountedto, (char *)vmt2dataptr(vm, VMT_STUB), fsname_len);
1525 
1526  /* get the mount-from information: */
1527  fsname_len = vmt2datasize(vm, VMT_OBJECT);
1528  mountedfrom = (char*)malloc(fsname_len + 1);
1529  mountedfrom[fsname_len] = '\0';
1530  strncpy(mountedfrom, (char *)vmt2dataptr(vm, VMT_OBJECT), fsname_len);
1531 
1532  TQCString device_name = mountedfrom;
1533 
1534  if (realpath(device_name, realpath_buffer) != 0)
1535  // success, use result from realpath
1536  device_name = realpath_buffer;
1537 
1538  free(mountedfrom);
1539 
1540  if (realname == device_name) {
1541  result = mountedto;
1542  free(mountedto);
1543  break;
1544  }
1545 
1546  free(mountedto);
1547 
1548  /* goto the next vmount structure: */
1549  vm = (struct vmount *)((char *)vm + vm->vmt_length);
1550  }
1551  }
1552 
1553  free( mntctl_buffer );
1554 
1555 #else
1556 
1557  STRUCT_SETMNTENT mtab;
1558 
1559  /* Get the list of mounted file systems */
1560 
1561  if ((mtab = SETMNTENT(MNTTAB, "r")) == 0) {
1562  perror("setmntent");
1563  return TQString::null;
1564  }
1565 
1566  /* Loop over all file systems and see if we can find our
1567  * mount point.
1568  * Note that this is the mount point with the longest match.
1569  * XXX: Fails if me->mnt_dir is not a realpath but goes
1570  * through a symlink, e.g. /foo/bar where /foo is a symlink
1571  * pointing to /local/foo.
1572  *
1573  * How kinky can you get with a filesystem?
1574  */
1575 
1576  STRUCT_MNTENT me;
1577 
1578  while (GETMNTENT(mtab, me))
1579  {
1580  // There may be symbolic links into the /etc/mnttab
1581  // So we have to find the real device name here as well!
1582  TQCString device_name = FSNAME(me);
1583  if (device_name.isEmpty() || (device_name == "none"))
1584  continue;
1585 
1586  //kdDebug( 7007 ) << "device_name=" << device_name << endl;
1587 
1588  // If the path contains symlinks, get
1589  // the real name
1590  if (realpath(device_name, realpath_buffer) != 0)
1591  // succes, use result from realpath
1592  device_name = realpath_buffer;
1593 
1594  //kdDebug( 7007 ) << "device_name after realpath =" << device_name << endl;
1595 
1596  if (realname == device_name)
1597  {
1598  result = MOUNTPOINT(me);
1599  break;
1600  }
1601  }
1602 
1603  ENDMNTENT(mtab);
1604 
1605 #endif /* GET_MNTINFO */
1606 #endif /* HAVE_VOLMGT */
1607 
1608  //kdDebug( 7007 ) << "Returning result " << result << endl;
1609  return result;
1610 }
1611 
1612 // Don't just trust the return value, keep iterating to check for a better match (bigger max)
1613 static bool is_my_mountpoint( const char *mountpoint, const char *realname, int &max )
1614 {
1615  int length = strlen(mountpoint);
1616 
1617  if (!strncmp(mountpoint, realname, length)
1618  && length > max) {
1619  max = length;
1620  if (length == 1 || realname[length] == '/' || realname[length] == '\0')
1621  return true;
1622  }
1623  return false;
1624 }
1625 
1626 typedef enum { Unseen, Right, Wrong } MountState;
1627 
1631 static void check_mount_point(const char *mounttype,
1632  const char *fsname,
1633  MountState &isslow, MountState &isautofs)
1634 {
1635  bool nfs = !strcmp(mounttype, "nfs");
1636  bool autofs = !strcmp(mounttype, "autofs") || !strcmp(mounttype,"subfs");
1637  bool pid = (strstr(fsname, ":(pid") != 0);
1638 
1639  if (nfs && !pid)
1640  isslow = Right;
1641  else if (isslow == Right)
1642  isslow = Wrong;
1643 
1644  /* Does this look like automounted? */
1645  if (autofs || (nfs && pid)) {
1646  isautofs = Right;
1647  isslow = Right;
1648  }
1649 }
1650 
1651 // returns the mount point, checks the mount state.
1652 // if ismanual == Wrong this function does not check the manual mount state
1653 static TQString get_mount_info(const TQString& filename,
1654  MountState& isautofs, MountState& isslow, MountState& ismanual,
1655  TQString& fstype)
1656 {
1657  static bool gotRoot = false;
1658  static dev_t rootDevice;
1659 
1660  struct cachedDevice_t
1661  {
1662  dev_t device;
1663  TQString mountPoint;
1664  MountState isautofs;
1665  MountState isslow;
1666  MountState ismanual;
1667  TQString fstype;
1668  };
1669  static struct cachedDevice_t *cachedDevice = 0;
1670 
1671  if (!gotRoot)
1672  {
1673  KDE_struct_stat stat_buf;
1674  KDE_stat("/", &stat_buf);
1675  gotRoot = true;
1676  rootDevice = stat_buf.st_dev;
1677  }
1678 
1679  bool gotDevice = false;
1680  KDE_struct_stat stat_buf;
1681  if (KDE_stat(TQFile::encodeName(filename), &stat_buf) == 0)
1682  {
1683  gotDevice = true;
1684  if (stat_buf.st_dev == rootDevice)
1685  {
1686  static const TQString &root = KGlobal::staticQString("/");
1687  isautofs = Wrong;
1688  isslow = Wrong;
1689  ismanual = Wrong;
1690  fstype = TQString::null; // ### do we need it?
1691  return root;
1692  }
1693  if (cachedDevice && (stat_buf.st_dev == cachedDevice->device))
1694  {
1695  bool interestedInIsManual = ismanual != Wrong;
1696  isautofs = cachedDevice->isautofs;
1697  isslow = cachedDevice->isslow;
1698  ismanual = cachedDevice->ismanual;
1699  fstype = cachedDevice->fstype;
1700  // Don't use the cache if it doesn't have the information we're looking for
1701  if ( !interestedInIsManual || ismanual != Unseen )
1702  return cachedDevice->mountPoint;
1703  }
1704  }
1705 
1706  char realname[MAXPATHLEN];
1707 
1708  memset(realname, 0, MAXPATHLEN);
1709 
1710  /* If the path contains symlinks, get the real name */
1711  if (realpath(TQFile::encodeName(filename), realname) == 0) {
1712  if( strlcpy(realname, TQFile::encodeName(filename), MAXPATHLEN)>=MAXPATHLEN)
1713  return TQString::null;
1714  }
1715 
1716  int max = 0;
1717  TQString mountPoint;
1718 
1719  /* Loop over all file systems and see if we can find our
1720  * mount point.
1721  * Note that this is the mount point with the longest match.
1722  * XXX: Fails if me->mnt_dir is not a realpath but goes
1723  * through a symlink, e.g. /foo/bar where /foo is a symlink
1724  * pointing to /local/foo.
1725  *
1726  * How kinky can you get with a filesystem?
1727  */
1728 
1729 #ifdef HAVE_GETMNTINFO
1730 
1731 #ifdef GETMNTINFO_USES_STATVFS
1732  struct statvfs *mounted;
1733 #else
1734  struct statfs *mounted;
1735 #endif
1736 
1737  char realpath_buffer[MAXPATHLEN];
1738 
1739  int num_fs = getmntinfo(&mounted, MNT_NOWAIT);
1740 
1741  for (int i=0;i<num_fs;i++) {
1742 
1743  TQCString device_name = mounted[i].f_mntfromname;
1744 
1745  // If the path contains symlinks, get
1746  // the real name
1747  if (realpath(device_name, realpath_buffer) != 0)
1748  // succes, use result from realpath
1749  device_name = realpath_buffer;
1750 #ifdef __osf__
1751  char * mounttype = mnt_names[mounted[i].f_type];
1752 #else
1753  char * mounttype = mounted[i].f_fstypename;
1754 #endif
1755  if ( is_my_mountpoint( mounted[i].f_mntonname, realname, max ) )
1756  {
1757  mountPoint = TQFile::decodeName(mounted[i].f_mntonname);
1758  fstype = TQString::fromLatin1(mounttype);
1759  check_mount_point( mounttype, mounted[i].f_mntfromname,
1760  isautofs, isslow );
1761  // keep going, looking for a potentially better one
1762 
1763  if (ismanual == Unseen)
1764  {
1765  struct fstab *ft = getfsfile(mounted[i].f_mntonname);
1766  if (!ft || strstr(ft->fs_mntops, "noauto"))
1767  ismanual = Right;
1768  }
1769  }
1770  }
1771 
1772 #elif defined(_AIX)
1773 
1774  struct vmount *mntctl_buffer;
1775  struct vmount *vm;
1776  char *mountedfrom;
1777  char *mountedto;
1778  int fsname_len, num;
1779  char realpath_buffer[MAXPATHLEN];
1780  int buf_sz = 4096;
1781 
1782  mntctl_buffer = (struct vmount*)malloc(buf_sz);
1783  num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
1784  if (num == 0)
1785  {
1786  buf_sz = *(int*)mntctl_buffer;
1787  free(mntctl_buffer);
1788  mntctl_buffer = (struct vmount*)malloc(buf_sz);
1789  num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
1790  }
1791 
1792  if (num > 0)
1793  {
1794  /* iterate through items in the vmount structure: */
1795  vm = (struct vmount *)mntctl_buffer;
1796  for ( ; num > 0; num-- )
1797  {
1798  /* get the name of the mounted file systems: */
1799  fsname_len = vmt2datasize(vm, VMT_STUB);
1800  mountedto = (char*)malloc(fsname_len + 1);
1801  mountedto[fsname_len] = '\0';
1802  strncpy(mountedto, (char *)vmt2dataptr(vm, VMT_STUB), fsname_len);
1803 
1804  fsname_len = vmt2datasize(vm, VMT_OBJECT);
1805  mountedfrom = (char*)malloc(fsname_len + 1);
1806  mountedfrom[fsname_len] = '\0';
1807  strncpy(mountedfrom, (char *)vmt2dataptr(vm, VMT_OBJECT), fsname_len);
1808 
1809  /* get the mount-from information: */
1810  TQCString device_name = mountedfrom;
1811 
1812  if (realpath(device_name, realpath_buffer) != 0)
1813  // success, use result from realpath
1814  device_name = realpath_buffer;
1815 
1816  /* Look up the string for the file system type,
1817  * as listed in /etc/vfs.
1818  * ex.: nfs,jfs,afs,cdrfs,sfs,cachefs,nfs3,autofs
1819  */
1820  struct vfs_ent* ent = getvfsbytype(vm->vmt_gfstype);
1821 
1822  if ( is_my_mountpoint( mountedto, realname, max ) )
1823  {
1824  mountPoint = TQFile::decodeName(mountedto);
1825  fstype = TQString::fromLatin1(ent->vfsent_name);
1826  check_mount_point(ent->vfsent_name, device_name, isautofs, isslow);
1827 
1828  if (ismanual == Unseen)
1829  {
1830  // TODO: add check for ismanual, I couldn't find any way
1831  // how to get the mount attribute from /etc/filesystems
1832  ismanual == Wrong;
1833  }
1834  }
1835 
1836  free(mountedfrom);
1837  free(mountedto);
1838 
1839  /* goto the next vmount structure: */
1840  vm = (struct vmount *)((char *)vm + vm->vmt_length);
1841  }
1842 
1843  endvfsent( );
1844  }
1845 
1846  free( mntctl_buffer );
1847 
1848 #else
1849 
1850  STRUCT_SETMNTENT mtab;
1851  /* Get the list of mounted file systems */
1852 
1853  if ((mtab = SETMNTENT(MNTTAB, "r")) == 0) {
1854  perror("setmntent");
1855  return TQString::null;
1856  }
1857 
1858  STRUCT_MNTENT me;
1859 
1860  while (true) {
1861  if (!GETMNTENT(mtab, me))
1862  break;
1863 
1864  if ( is_my_mountpoint( MOUNTPOINT(me), realname, max ) )
1865  {
1866  mountPoint = TQFile::decodeName( MOUNTPOINT(me) );
1867  fstype = MOUNTTYPE(me);
1868  check_mount_point(MOUNTTYPE(me), FSNAME(me), isautofs, isslow);
1869  // we don't check if ismanual is Right, if /a/b is manually
1870  // mounted /a/b/c can't be automounted. At least IMO.
1871  if (ismanual == Unseen)
1872  {
1873  // The next GETMNTENT call may destroy 'me'
1874  // Copy out the info that we need
1875  TQCString fsname_me = FSNAME(me);
1876  TQCString mounttype_me = MOUNTTYPE(me);
1877 
1878  STRUCT_SETMNTENT fstab;
1879  if ((fstab = SETMNTENT(FSTAB, "r")) == 0) {
1880  continue;
1881  }
1882 
1883  bool found = false;
1884  STRUCT_MNTENT fe;
1885  while (GETMNTENT(fstab, fe))
1886  {
1887  if (fsname_me == FSNAME(fe))
1888  {
1889  found = true;
1890  if (HASMNTOPT(fe, "noauto") ||
1891  !strcmp(MOUNTTYPE(fe), "supermount"))
1892  ismanual = Right;
1893  break;
1894  }
1895  }
1896  if (!found || (mounttype_me == "supermount"))
1897  ismanual = Right;
1898 
1899  ENDMNTENT(fstab);
1900  }
1901  }
1902  }
1903 
1904  ENDMNTENT(mtab);
1905 
1906 #endif
1907 
1908  if (isautofs == Right && isslow == Unseen)
1909  isslow = Right;
1910 
1911  if (gotDevice)
1912  {
1913  if (!cachedDevice)
1914  cachedDevice = new cachedDevice_t;
1915 
1916  cachedDevice->device = stat_buf.st_dev;
1917  cachedDevice->mountPoint = mountPoint;
1918  cachedDevice->isautofs = isautofs;
1919  cachedDevice->isslow = isslow;
1920  cachedDevice->ismanual = ismanual;
1921  cachedDevice->fstype = fstype;
1922  }
1923 
1924  return mountPoint;
1925 }
1926 
1927 #else
1928 //dummy
1929 TQString KIO::findDeviceMountPoint( const TQString& filename )
1930 {
1931  return TQString::null;
1932 }
1933 #endif
1934 
1935 TQString KIO::findPathMountPoint(const TQString& filename)
1936 {
1937 #ifdef Q_OS_UNIX
1938  MountState isautofs = Unseen, isslow = Unseen, ismanual = Wrong;
1939  TQString fstype;
1940  return get_mount_info(filename, isautofs, isslow, ismanual, fstype);
1941 #else
1942  return TQString::null;
1943 #endif
1944 }
1945 
1946 bool KIO::manually_mounted(const TQString& filename)
1947 {
1948 #ifdef Q_OS_UNIX
1949  MountState isautofs = Unseen, isslow = Unseen, ismanual = Unseen;
1950  TQString fstype;
1951  TQString mountPoint = get_mount_info(filename, isautofs, isslow, ismanual, fstype);
1952  return !mountPoint.isNull() && (ismanual == Right);
1953 #else
1954  return false;
1955 #endif
1956 }
1957 
1958 bool KIO::probably_slow_mounted(const TQString& filename)
1959 {
1960 #ifdef Q_OS_UNIX
1961  MountState isautofs = Unseen, isslow = Unseen, ismanual = Wrong;
1962  TQString fstype;
1963  TQString mountPoint = get_mount_info(filename, isautofs, isslow, ismanual, fstype);
1964  return !mountPoint.isNull() && (isslow == Right);
1965 #else
1966  return false;
1967 #endif
1968 }
1969 
1970 bool KIO::testFileSystemFlag(const TQString& filename, FileSystemFlag flag)
1971 {
1972 #ifdef Q_OS_UNIX
1973  MountState isautofs = Unseen, isslow = Unseen, ismanual = Wrong;
1974  TQString fstype;
1975  TQString mountPoint = get_mount_info(filename, isautofs, isslow, ismanual, fstype);
1976  kdDebug() << "testFileSystemFlag: fstype=" << fstype << endl;
1977  if (mountPoint.isNull())
1978  return false;
1979  bool isMsDos = ( fstype == "msdos" || fstype == "fat" || fstype == "vfat" );
1980  switch (flag) {
1981  case SupportsChmod:
1982  case SupportsChown:
1983  case SupportsUTime:
1984  case SupportsSymlinks:
1985  return !isMsDos; // it's amazing the number of things FAT doesn't support :)
1986  case CaseInsensitive:
1987  return isMsDos;
1988  }
1989 #endif
1990  return false;
1991 }
1992 
1993 KIO::CacheControl KIO::parseCacheControl(const TQString &cacheControl)
1994 {
1995  TQString tmp = cacheControl.lower();
1996 
1997  if (tmp == "cacheonly")
1998  return KIO::CC_CacheOnly;
1999  if (tmp == "cache")
2000  return KIO::CC_Cache;
2001  if (tmp == "verify")
2002  return KIO::CC_Verify;
2003  if (tmp == "refresh")
2004  return KIO::CC_Refresh;
2005  if (tmp == "reload")
2006  return KIO::CC_Reload;
2007 
2008  kdDebug() << "unrecognized Cache control option:"<<cacheControl<<endl;
2009  return KIO::CC_Verify;
2010 }
2011 
2012 TQString KIO::getCacheControlString(KIO::CacheControl cacheControl)
2013 {
2014  if (cacheControl == KIO::CC_CacheOnly)
2015  return "CacheOnly";
2016  if (cacheControl == KIO::CC_Cache)
2017  return "Cache";
2018  if (cacheControl == KIO::CC_Verify)
2019  return "Verify";
2020  if (cacheControl == KIO::CC_Refresh)
2021  return "Refresh";
2022  if (cacheControl == KIO::CC_Reload)
2023  return "Reload";
2024  kdDebug() << "unrecognized Cache control enum value:"<<cacheControl<<endl;
2025  return TQString::null;
2026 }
KIO::convertSizeFromKB
KIO_EXPORT TQString convertSizeFromKB(KIO::filesize_t kbSize)
Converts size from kilo-bytes to the string representation.
Definition: global.cpp:91
KIO::CC_CacheOnly
Fail request if not in cache.
Definition: global.h:388
KIO::testFileSystemFlag
KIO_EXPORT bool testFileSystemFlag(const TQString &filename, FileSystemFlag flag)
Checks the capabilities of the filesystem to which a given file belongs.
Definition: global.cpp:1970
KIO::rawErrorDetail
KIO_EXPORT TQByteArray rawErrorDetail(int errorCode, const TQString &errorText, const KURL *reqUrl=0L, int method=-1)
Returns translated error details for errorCode using the additional error information provided by err...
Definition: global.cpp:528
KIO::Job::errorText
const TQString & errorText() const
Returns the error text if there has been an error.
Definition: jobclasses.h:111
KIO::calculateRemainingSeconds
KIO_EXPORT unsigned int calculateRemainingSeconds(KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed)
Calculates remaining time in seconds from total size, processed size and speed.
Definition: global.cpp:103
KIO::probably_slow_mounted
KIO_EXPORT bool probably_slow_mounted(const TQString &filename)
Checks if the path belongs to a filesystem that is probably slow.
Definition: global.cpp:1958
KIO::CC_Reload
Always fetch from remote site.
Definition: global.h:393
KIO::convertSeconds
KIO_EXPORT TQString convertSeconds(unsigned int seconds)
Convert seconds to a string representing number of days, hours, minutes and seconds.
Definition: global.cpp:112
KIO::manually_mounted
KIO_EXPORT bool manually_mounted(const TQString &filename)
Checks if the path belongs to a filesystem that is manually mounted.
Definition: global.cpp:1946
KIO::number
KIO_EXPORT TQString number(KIO::filesize_t size)
Converts a size to a string representation Not unlike TQString::number(...)
Definition: global.cpp:96
KIO::itemsSummaryString
KIO_EXPORT TQString itemsSummaryString(uint items, uint files, uint dirs, KIO::filesize_t size, bool showSize)
Helper for showing information about a set of files and directories.
Definition: global.cpp:150
KProtocolManager::responseTimeout
static int responseTimeout()
Returns the preferred response timeout value for remote connecting in seconds.
Definition: kprotocolmanager.cpp:136
KIO::decodeFileName
KIO_EXPORT TQString decodeFileName(const TQString &str)
Decodes (from the filename to the text displayed) This translates %2[fF] into /, %% into %...
Definition: global.cpp:191
KIO::encodeFileName
KIO_EXPORT TQString encodeFileName(const TQString &str)
Encodes (from the text displayed to the real filename) This translates % into %% and / into ∕ (U+22...
Definition: global.cpp:165
KIO::CacheControl
CacheControl
Specifies how to use the cache.
Definition: global.h:386
KIO::calculateRemaining
KIO_EXPORT TQTime calculateRemaining(KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed) KDE_DEPRECATED
Calculates remaining time from total size, processed size and speed.
Definition: global.cpp:127
KIO::filesize_t
TQ_ULLONG filesize_t
64-bit file size
Definition: global.h:39
KProtocolManager::connectTimeout
static int connectTimeout()
Returns the preferred timeout value for remote connections in seconds.
Definition: kprotocolmanager.cpp:120
KIO::convertSizeWithBytes
KIO_EXPORT TQString convertSizeWithBytes(KIO::filesize_t size)
Converts size from bytes to a string representation with includes the size in bytes.
Definition: global.cpp:45
KIO::convertSize
KIO_EXPORT TQString convertSize(KIO::filesize_t size)
Converts size from bytes to the string representation.
Definition: global.cpp:53
KIO::Job::errorString
TQString errorString() const
Converts an error code and a non-i18n error message into an error message in the current language...
Definition: global.cpp:225
KIO::findDeviceMountPoint
KIO_EXPORT TQString findDeviceMountPoint(const TQString &device)
Returns the mount point where device is mounted right now.
Definition: global.cpp:1388
KIO::CC_Cache
Use cached entry if available.
Definition: global.h:389
KIO::CC_Refresh
Always validate cached entry with remote site.
Definition: global.h:391
KIO::CC_Verify
Validate cached entry with remote site if expired.
Definition: global.h:390
KIO::buildErrorString
KIO_EXPORT TQString buildErrorString(int errorCode, const TQString &errorText)
Returns a translated error message for errorCode using the additional error information provided by e...
Definition: global.cpp:230
KIO::findPathMountPoint
KIO_EXPORT TQString findPathMountPoint(const TQString &filename)
Returns the mount point on which resides filename.
Definition: global.cpp:1935
KProtocolManager::proxyConnectTimeout
static int proxyConnectTimeout()
Returns the preferred timeout value for proxy connections in seconds.
Definition: kprotocolmanager.cpp:128
KIO::parseCacheControl
KIO_EXPORT KIO::CacheControl parseCacheControl(const TQString &cacheControl)
Parses the string representation of the cache control option.
Definition: global.cpp:1993
KIO::getCacheControlString
KIO_EXPORT TQString getCacheControlString(KIO::CacheControl cacheControl)
Returns a string representation of the given cache control method.
Definition: global.cpp:2012
KIO::unsupportedActionErrorString
KIO_EXPORT TQString unsupportedActionErrorString(const TQString &protocol, int cmd)
Returns an appropriate error message if the given command cmd is an unsupported action (ERR_UNSUPPORT...
Definition: global.cpp:439
KIO::Job::result
void result(KIO::Job *job)
Emitted when the job is finished, in any case (completed, canceled, failed...).
KIO::Job::detailedErrorStrings
TQStringList detailedErrorStrings(const KURL *reqUrl=0L, int method=-1) const
Converts an error code and a non-i18n error message into i18n strings suitable for presentation in a ...
Definition: global.cpp:478

kio/kio

Skip menu "kio/kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kio/kio

Skip menu "kio/kio"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kio/kio by doxygen 1.8.13
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |