global.cpp Source File (kio Library)

| # kio Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# global.cpp

    00001 /* This file is part of the KDE libraries
    00002    Copyright (C) 2000 David Faure <faure@kde.org>
    00003
    00004    $Id: global.cpp,v 1.101.2.6 2003/01/27 22:20:49 brade Exp $
    00005
    00006    This library is free software; you can redistribute it and/or
    00007    modify it under the terms of the GNU Library General Public
    00008    License version 2 as published by the Free Software Foundation.
    00009
    00010    This library is distributed in the hope that it will be useful,
    00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013    Library General Public License for more details.
    00014
    00015    You should have received a copy of the GNU Library General Public License
    00016    along with this library; see the file COPYING.LIB.  If not, write to
    00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018    Boston, MA 02111-1307, USA.
    00019 */
    00020
    00021 #include <config.h>
    00022
    00023 #include <sys/types.h>
    00024 #include <sys/wait.h>
    00025 #include <sys/uio.h>
    00026
    00027 #include <assert.h>
    00028 #include <signal.h>
    00029 #include <stdlib.h>
    00030 #include <string.h>
    00031 #include <unistd.h>
    00032 #include <stdio.h>
    00033
    00034 #include "kio/global.h"
    00035 #include "kio/job.h"
    00036
    00037 #include <kdebug.h>
    00038 #include <klocale.h>
    00039 #include <kglobal.h>
    00040 #include <kprotocolmanager.h>
    00041
    00042 #ifdef HAVE_VOLMGT
    00043 #include <volmgt.h>
    00044 #endif
    00045
    00046 QString KIO::convertSize( KIO::filesize_t size )
    00047 {
    00048     float fsize;
    00049     QString s;
    00050     // Giga-byte
    00051     if ( size >= 1073741824 )
    00052     {
    00053         fsize = (float) size / (float) 1073741824;
    00054         if ( fsize > 1024 ) // Tera-byte
    00055             s = i18n( "%1 TB" ).arg( KGlobal::locale()->formatNumber(fsize / (float)1024, 1));
    00056         else
    00057             s = i18n( "%1 GB" ).arg( KGlobal::locale()->formatNumber(fsize, 1));
    00058     }
    00059     // Mega-byte
    00060     else if ( size >= 1048576 )
    00061     {
    00062         fsize = (float) size / (float) 1048576;
    00063         s = i18n( "%1 MB" ).arg( KGlobal::locale()->formatNumber(fsize, 1));
    00064     }
    00065     // Kilo-byte
    00066     else if ( size > 1024 )
    00067     {
    00068         fsize = (float) size / (float) 1024;
    00069         s = i18n( "%1 KB" ).arg( KGlobal::locale()->formatNumber(fsize, 1));
    00070     }
    00071     // Just byte
    00072     else
    00073     {
    00074         fsize = (float) size;
    00075         s = i18n( "%1 B" ).arg( KGlobal::locale()->formatNumber(fsize, 0));
    00076     }
    00077     return s;
    00078 }
    00079
    00080 QString KIO::convertSizeFromKB( KIO::filesize_t kbSize )
    00081 {
    00082     return convertSize(kbSize * 1024);
    00083 }
    00084
    00085 QString KIO::number( KIO::filesize_t size )
    00086 {
    00087     char charbuf[256];
    00088     sprintf(charbuf, "%lld", size);
    00089     return QString::fromLatin1(charbuf);
    00090 }
    00091
    00092 QTime KIO::calculateRemaining( KIO::filesize_t totalSize, KIO::filesize_t processedSize, KIO::filesize_t speed )
    00093 {
    00094   QTime remainingTime;
    00095
    00096   if ( speed != 0 ) {
    00097     KIO::filesize_t secs;
    00098     if ( totalSize == 0 ) {
    00099       secs = 0;
    00100     } else {
    00101       secs = ( totalSize - processedSize ) / speed;
    00102     }
    00103     if (secs >= (24*60*60)) // Limit to 23:59:59
    00104        secs = (24*60*60)-1;
    00105     int hr = secs / ( 60 * 60 );
    00106     int mn = ( secs - hr * 60 * 60 ) / 60;
    00107     int sc = ( secs - hr * 60 * 60 - mn * 60 );
    00108
    00109     remainingTime.setHMS( hr, mn, sc );
    00110   }
    00111
    00112   return remainingTime;
    00113 }
    00114
    00115 QString KIO::itemsSummaryString(uint items, uint files, uint dirs, KIO::filesize_t size, bool showSize)
    00116 {
    00117     QString text = i18n( "One Item", "%n Items", items );
    00118     text += " - ";
    00119     text += i18n( "One File", "%n Files", files );
    00120     if ( showSize && files > 0 )
    00121     {
    00122         text += " ";
    00123         text += i18n("(%1 Total)").arg(KIO::convertSize( size ) );
    00124     }
    00125     text += " - ";
    00126     text += i18n("One Directory", "%n Directories", dirs);
    00127     return text;
    00128 }
    00129
    00130 QString KIO::encodeFileName( const QString & _str )
    00131 {
    00132   QString str( _str );
    00133
    00134   int i = 0;
    00135   while ( ( i = str.find( "%", i ) ) != -1 )
    00136   {
    00137     str.replace( i, 1, "%%");
    00138     i += 2;
    00139   }
    00140   while ( ( i = str.find( "/" ) ) != -1 )
    00141       str.replace( i, 1, "%2f");
    00142   return str;
    00143 }
    00144
    00145 QString KIO::decodeFileName( const QString & _str )
    00146 {
    00147   QString str;
    00148
    00149   unsigned int i = 0;
    00150   for ( ; i < _str.length() ; ++i )
    00151   {
    00152     if ( _str[i]=='%' )
    00153     {
    00154       if ( _str[i+1]=='%' ) // %% -> %
    00155       {
    00156         str.append('%');
    00157         ++i;
    00158       }
    00159       else if ( _str[i+1]=='2' && (i+2<_str.length()) && _str[i+2].lower()=='f' ) // %2f -> /
    00160       {
    00161         str.append('/');
    00162         i += 2;
    00163       }
    00164       else
    00165         str.append('%');
    00166     } else
    00167       str.append(_str[i]);
    00168   }
    00169
    00170   return str;
    00171 }
    00172
    00173 QString KIO::Job::errorString() const
    00174 {
    00175   return KIO::buildErrorString(m_error, m_errorText);
    00176 }
    00177
    00178 QString KIO::buildErrorString(int errorCode, const QString &errorText)
    00179 {
    00180   QString result;
    00181
    00182   switch( errorCode )
    00183     {
    00184     case  KIO::ERR_CANNOT_OPEN_FOR_READING:
    00185       result = i18n( "Could not read %1" ).arg( errorText );
    00186       break;
    00187     case  KIO::ERR_CANNOT_OPEN_FOR_WRITING:
    00188       result = i18n( "Could not write to %1" ).arg( errorText );
    00189       break;
    00190     case  KIO::ERR_CANNOT_LAUNCH_PROCESS:
    00191       result = i18n( "Could not start process %1" ).arg( errorText );
    00192       break;
    00193     case  KIO::ERR_INTERNAL:
    00194       result = i18n( "Internal Error\nPlease send a full bug report at http://bugs.kde.org\n%1" ).arg( errorText );
    00195       break;
    00196     case  KIO::ERR_MALFORMED_URL:
    00197       result = i18n( "Malformed URL %1" ).arg( errorText );
    00198       break;
    00199     case  KIO::ERR_UNSUPPORTED_PROTOCOL:
    00200       result = i18n( "The protocol %1 is not supported." ).arg( errorText );
    00201       break;
    00202     case  KIO::ERR_NO_SOURCE_PROTOCOL:
    00203       result = i18n( "The protocol %1 is only a filter protocol.").arg( errorText );
    00204       break;
    00205     case  KIO::ERR_UNSUPPORTED_ACTION:
    00206       result = errorText;
    00207 //       result = i18n( "Unsupported action %1" ).arg( errorText );
    00208       break;
    00209     case  KIO::ERR_IS_DIRECTORY:
    00210       result = i18n( "%1 is a directory, but a file was expected." ).arg( errorText );
    00211       break;
    00212     case  KIO::ERR_IS_FILE:
    00213       result = i18n( "%1 is a file, but a directory was expected." ).arg( errorText );
    00214       break;
    00215     case  KIO::ERR_DOES_NOT_EXIST:
    00216       result = i18n( "The file or directory %1 does not exist." ).arg( errorText );
    00217       break;
    00218     case  KIO::ERR_FILE_ALREADY_EXIST:
    00219       result = i18n( "A file named %1 already exists." ).arg( errorText );
    00220       break;
    00221     case  KIO::ERR_DIR_ALREADY_EXIST:
    00222       result = i18n( "A directory named %1 already exists." ).arg( errorText );
    00223       break;
    00224     case  KIO::ERR_UNKNOWN_HOST:
    00225       result = i18n( "Unknown host %1" ).arg( errorText );
    00226       break;
    00227     case  KIO::ERR_ACCESS_DENIED:
    00228       result = i18n( "Access denied to %1" ).arg( errorText );
    00229       break;
    00230     case  KIO::ERR_WRITE_ACCESS_DENIED:
    00231       result = i18n( "Access denied\nCould not write to %1" ).arg( errorText );
    00232       break;
    00233     case  KIO::ERR_CANNOT_ENTER_DIRECTORY:
    00234       result = i18n( "Could not enter directory %1" ).arg( errorText );
    00235       break;
    00236     case  KIO::ERR_PROTOCOL_IS_NOT_A_FILESYSTEM:
    00237       result = i18n( "The protocol %1 does not implement a directory service." ).arg( errorText );
    00238       break;
    00239     case  KIO::ERR_CYCLIC_LINK:
    00240       result = i18n( "Found a cyclic link in %1" ).arg( errorText );
    00241       break;
    00242     case  KIO::ERR_USER_CANCELED:
    00243       // Do nothing in this case. The user doesn't need to be told what he just did.
    00244       break;
    00245     case  KIO::ERR_CYCLIC_COPY:
    00246       result = i18n( "Found a cyclic link while copying %1" ).arg( errorText );
    00247       break;
    00248     case  KIO::ERR_COULD_NOT_CREATE_SOCKET:
    00249       result = i18n( "Could not create socket for accessing %1" ).arg( errorText );
    00250       break;
    00251     case  KIO::ERR_COULD_NOT_CONNECT:
    00252       result = i18n( "Could not connect to host %1" ).arg( errorText.isEmpty() ? QString::fromLatin1("localhost") : errorText );
    00253       break;
    00254     case  KIO::ERR_CONNECTION_BROKEN:
    00255       result = i18n( "Connection to host %1 is broken" ).arg( errorText );
    00256       break;
    00257     case  KIO::ERR_NOT_FILTER_PROTOCOL:
    00258       result = i18n( "The protocol %1 is not a filter protocol" ).arg( errorText );
    00259       break;
    00260     case  KIO::ERR_COULD_NOT_MOUNT:
    00261       result = i18n( "Could not mount device.\nThe reported error was:\n%1" ).arg( errorText );
    00262       break;
    00263     case  KIO::ERR_COULD_NOT_UNMOUNT:
    00264       result = i18n( "Could not unmount device.\nThe reported error was:\n%1" ).arg( errorText );
    00265       break;
    00266     case  KIO::ERR_COULD_NOT_READ:
    00267       result = i18n( "Could not read file %1" ).arg( errorText );
    00268       break;
    00269     case  KIO::ERR_COULD_NOT_WRITE:
    00270       result = i18n( "Could not write to file %1" ).arg( errorText );
    00271       break;
    00272     case  KIO::ERR_COULD_NOT_BIND:
    00273       result = i18n( "Could not bind %1" ).arg( errorText );
    00274       break;
    00275     case  KIO::ERR_COULD_NOT_LISTEN:
    00276       result = i18n( "Could not listen %1" ).arg( errorText );
    00277       break;
    00278     case  KIO::ERR_COULD_NOT_ACCEPT:
    00279       result = i18n( "Could not accept %1" ).arg( errorText );
    00280       break;
    00281     case  KIO::ERR_COULD_NOT_LOGIN:
    00282       result = errorText;
    00283       break;
    00284     case  KIO::ERR_COULD_NOT_STAT:
    00285       result = i18n( "Could not access %1" ).arg( errorText );
    00286       break;
    00287     case  KIO::ERR_COULD_NOT_CLOSEDIR:
    00288       result = i18n( "Could not terminate listing %1" ).arg( errorText );
    00289       break;
    00290     case  KIO::ERR_COULD_NOT_MKDIR:
    00291       result = i18n( "Could not make directory %1" ).arg( errorText );
    00292       break;
    00293     case  KIO::ERR_COULD_NOT_RMDIR:
    00294       result = i18n( "Could not remove directory %1" ).arg( errorText );
    00295       break;
    00296     case  KIO::ERR_CANNOT_RESUME:
    00297       result = i18n( "Could not resume file %1" ).arg( errorText );
    00298       break;
    00299     case  KIO::ERR_CANNOT_RENAME:
    00300       result = i18n( "Could not rename file %1" ).arg( errorText );
    00301       break;
    00302     case  KIO::ERR_CANNOT_CHMOD:
    00303       result = i18n( "Could not change permissions for %1" ).arg( errorText );
    00304       break;
    00305     case  KIO::ERR_CANNOT_DELETE:
    00306       result = i18n( "Could not delete file %1" ).arg( errorText );
    00307       break;
    00308     case  KIO::ERR_SLAVE_DIED:
    00309       result = i18n( "The process for the %1 protocol died unexpectedly." ).arg( errorText );
    00310       break;
    00311     case  KIO::ERR_OUT_OF_MEMORY:
    00312       result = i18n( "Error. Out of Memory.\n%1" ).arg( errorText );
    00313       break;
    00314     case  KIO::ERR_UNKNOWN_PROXY_HOST:
    00315       result = i18n( "Unknown proxy host\n%1" ).arg( errorText );
    00316       break;
    00317     case  KIO::ERR_COULD_NOT_AUTHENTICATE:
    00318       result = i18n( "Authorization failed, %1 authentication not supported" ).arg( errorText );
    00319       break;
    00320     case  KIO::ERR_ABORTED:
    00321       result = i18n( "User canceled action\n%1" ).arg( errorText );
    00322       break;
    00323     case  KIO::ERR_INTERNAL_SERVER:
    00324       result = i18n( "Internal error in server\n%1" ).arg( errorText );
    00325       break;
    00326     case  KIO::ERR_SERVER_TIMEOUT:
    00327       result = i18n( "Timeout on server\n%1" ).arg( errorText );
    00328       break;
    00329     case  KIO::ERR_UNKNOWN:
    00330       result = i18n( "Unknown error\n%1" ).arg( errorText );
    00331       break;
    00332     case  KIO::ERR_UNKNOWN_INTERRUPT:
    00333       result = i18n( "Unknown interrupt\n%1" ).arg( errorText );
    00334       break;
    00335 /*
    00336     case  KIO::ERR_CHECKSUM_MISMATCH:
    00337       if (errorText)
    00338         result = i18n( "Warning: MD5 Checksum for %1 does not match checksum returned from server" ).arg(errorText);
    00339       else
    00340         result = i18n( "Warning: MD5 Checksum for %1 does not match checksum returned from server" ).arg("document");
    00341       break;
    00342 */
    00343     case KIO::ERR_CANNOT_DELETE_ORIGINAL:
    00344       result = i18n( "Could not delete original file %1.\nPlease check permissions." ).arg( errorText );
    00345       break;
    00346     case KIO::ERR_CANNOT_DELETE_PARTIAL:
    00347       result = i18n( "Could not delete partial file %1.\nPlease check permissions." ).arg( errorText );
    00348       break;
    00349     case KIO::ERR_CANNOT_RENAME_ORIGINAL:
    00350       result = i18n( "Could not rename original file %1.\nPlease check permissions." ).arg( errorText );
    00351       break;
    00352     case KIO::ERR_CANNOT_RENAME_PARTIAL:
    00353       result = i18n( "Could not rename partial file %1.\nPlease check permissions." ).arg( errorText );
    00354       break;
    00355     case KIO::ERR_CANNOT_SYMLINK:
    00356       result = i18n( "Could not create symlink %1.\nPlease check permissions." ).arg( errorText );
    00357       break;
    00358     case KIO::ERR_NO_CONTENT:
    00359       result = errorText;
    00360       break;
    00361     case KIO::ERR_DISK_FULL:
    00362       result = i18n( "Could not write file %1.\nDisk full." ).arg( errorText );
    00363       break;
    00364     case KIO::ERR_IDENTICAL_FILES:
    00365       result = i18n( "The source and destination are the same file.\n%1" ).arg( errorText );
    00366       break;
    00367     case KIO::ERR_SLAVE_DEFINED:
    00368       result = errorText;
    00369       break;
    00370     case KIO::ERR_UPGRADE_REQUIRED:
    00371       result = i18n( "%1 is required by the server, but is not available." ).arg(errorText);
    00372     case KIO::ERR_POST_DENIED:
    00373       result = i18n( "Access to restricted port in POST denied");
    00374       break;
    00375     default:
    00376       result = i18n( "Unknown error code %1\n%2\nPlease send a full bug report at http://bugs.kde.org." ).arg( errorCode ).arg( errorText );
    00377       break;
    00378     }
    00379
    00380   return result;
    00381 }
    00382
    00383 QStringList KIO::Job::detailedErrorStrings( const KURL *reqUrl /*= 0L*/,
    00384                                             int method /*= -1*/ ) const
    00385 {
    00386   QString errorName, techName, description, ret2;
    00387   QStringList causes, solutions, ret;
    00388
    00389   QByteArray raw = rawErrorDetail( m_error, m_errorText, reqUrl, method );
    00390   QDataStream stream(raw, IO_ReadOnly);
    00391
    00392   stream >> errorName >> techName >> description >> causes >> solutions;
    00393
    00394   QString url, protocol, datetime;
    00395   if ( reqUrl ) {
    00396     url = reqUrl->htmlURL();
    00397     protocol = reqUrl->protocol();
    00398   } else {
    00399     url = i18n( "(unknown)" );
    00400   }
    00401
    00402   datetime = KGlobal::locale()->formatDateTime( QDateTime::currentDateTime(),
    00403                                                 false );
    00404
    00405   ret << errorName;
    00406   ret << QString::fromLatin1( "<qt><p><b>" ) + errorName +
    00407          QString::fromLatin1( "</b></p><p>" ) + description +
    00408          QString::fromLatin1( "</p>" );
    00409   ret2 = QString::fromLatin1( "<qt><p>" );
    00410   if ( techName != QString::null )
    00411     ret2 += i18n( "<b>Technical Reason</b>: " ) + techName + QString::fromLatin1( "</p>" );
    00412   ret2 += i18n( "</p><p><b>Details of the Request</b>:" );
    00413   ret2 += i18n( "</p><ul><li>URL: %1</li>" ).arg( url );
    00414   if ( protocol != QString::null ) {
    00415     ret2 += i18n( "<li>Protocol: %1</li>" ).arg( protocol );
    00416   }
    00417   ret2 += i18n( "<li>Date and Time: %1</li>" ).arg( datetime );
    00418   ret2 += i18n( "<li>Additional Information: %1</li></ul>" ).arg( m_errorText );
    00419   if ( causes.count() ) {
    00420     ret2 += i18n( "<p><b>Possible Causes</b>:</p><ul><li>" );
    00421     ret2 += causes.join( "</li><li>" );
    00422     ret2 += QString::fromLatin1( "</li></ul>" );
    00423   }
    00424   if ( solutions.count() ) {
    00425     ret2 += i18n( "<p><b>Possible Solutions</b>:</p><ul><li>" );
    00426     ret2 += solutions.join( "</li><li>" );
    00427     ret2 += QString::fromLatin1( "</li></ul>" );
    00428   }
    00429   ret << ret2;
    00430   return ret;
    00431 }
    00432
    00433 QByteArray KIO::rawErrorDetail(int errorCode, const QString &errorText,
    00434                                const KURL *reqUrl /*= 0L*/, int /*method = -1*/ )
    00435 {
    00436   QString url, host, protocol, datetime, domain, path, dir, filename;
    00437   bool isSlaveNetwork = false;
    00438   if ( reqUrl ) {
    00439     url = reqUrl->prettyURL();
    00440     host = reqUrl->host();
    00441     protocol = reqUrl->protocol();
    00442
    00443     if ( host.left(4) == "www." )
    00444       domain = host.mid(4);
    00445     else
    00446       domain = host;
    00447
    00448     path = reqUrl->path(1);
    00449     filename = reqUrl->filename();
    00450     dir =  path + filename;
    00451
    00452     // detect if protocol is a network protocol...
    00453     // add your hacks here...
    00454     if ( protocol == "http" ||
    00455          protocol == "https" ||
    00456          protocol == "ftp" ||
    00457          protocol == "sftp" ||
    00458          protocol == "webdav" ||
    00459          protocol == "webdavs" ||
    00460          protocol == "finger" ||
    00461          protocol == "fish" ||
    00462          protocol == "gopher" ||
    00463          protocol == "imap" ||
    00464          protocol == "imaps" ||
    00465          protocol == "lan" ||
    00466          protocol == "ldap" ||
    00467          protocol == "mailto" ||
    00468          protocol == "news" ||
    00469          protocol == "nntp" ||
    00470          protocol == "pop3" ||
    00471          protocol == "pop3s" ||
    00472          protocol == "smtp" ||
    00473          protocol == "smtps" ||
    00474          protocol == "telnet"
    00475         ) {
    00476       isSlaveNetwork = false;
    00477     }
    00478   } else {
    00479     // assume that the errorText has the location we are interested in
    00480     url = host = domain = path = filename = dir = errorText;
    00481     protocol = i18n( "(unknown)" );
    00482   }
    00483
    00484   datetime = KGlobal::locale()->formatDateTime( QDateTime::currentDateTime(),
    00485                                                 false );
    00486
    00487   QString errorName, techName, description;
    00488   QStringList causes, solutions;
    00489
    00490   // c == cause, s == solution
    00491   QString sSysadmin = i18n( "Contact your appropriate computer support system, "
    00492     "whether the system administrator, or technical support group for further "
    00493     "assistance." );
    00494   QString sServeradmin = i18n( "Contact the administrator of the server "
    00495     "for further assistance." );
    00496   // FIXME active link to permissions dialog
    00497   QString sAccess = i18n( "Check your access permissions on this resource." );
    00498   QString cAccess = i18n( "Your access permissions may be inadequate to "
    00499     "perform the requested operation on this resource." );
    00500   QString cLocked = i18n( "The file may be in use (and thus locked) by "
    00501     "another user or application." );
    00502   QString sQuerylock = i18n( "Check to make sure that no other "
    00503     "application or user is using the file or has locked the file." );
    00504   QString cHardware = i18n( "Although unlikely, a hardware error may have "
    00505     "occurred." );
    00506   QString cBug = i18n( "You may have encountered a bug in the program." );
    00507   QString cBuglikely = i18n( "This is most likely to be caused by a bug in the "
    00508     "program. Please consider submitting a full bug report as detailed below." );
    00509   QString sUpdate = i18n( "Update your software to the latest version. "
    00510     "Your distribution should provide tools to update your software." );
    00511   QString sBugreport = i18n( "When all else fails, please consider helping the "
    00512     "KDE team or the third party maintainer of this software by submitting a "
    00513     "high quality bug report. If the software is provided by a third party, "
    00514     "please contact them directly. Otherwise, first look to see if "
    00515     "the same bug has been submitted by someone else by searching at the "
    00516     "<a href=\"http://bugs.kde.org/\">KDE bug reporting website</a>. If not, take "
    00517     "note of the details given above, and include them in your bug report, along "
    00518     "with as many other details as you think might help." );
    00519   QString cNetwork = i18n( "There may have been a problem with your network "
    00520     "connection." );
    00521   // FIXME netconf kcontrol link
    00522   QString cNetconf = i18n( "There may have been a problem with your network "
    00523     "configuration. If you have been accessing the Internet with no problems "
    00524     "recently, this is unlikely." );
    00525   QString cNetpath = i18n( "There may have been a problem at some point along "
    00526     "the network path between the server and this computer." );
    00527   QString sTryagain = i18n( "Try again, either now or at a later time." );
    00528   QString cProtocol = i18n( "A protocol error or incompatibility may have occurred." );
    00529   QString sExists = i18n( "Ensure that the resource exists, and try again." );
    00530   QString cExists = i18n( "The specified resource may not exist." );
    00531   QString cTypo = i18n( "You may have incorrectly typed the location." );
    00532   QString sTypo = i18n( "Double-check that you have entered the correct location "
    00533     "and try again." );
    00534   QString sNetwork = i18n( "Check your network connection status." );
    00535
    00536   switch( errorCode ) {
    00537     case  KIO::ERR_CANNOT_OPEN_FOR_READING:
    00538       errorName = i18n( "Cannot Open Resource For Reading" );
    00539       description = i18n( "This means that the contents of the requested file "
    00540         "or directory <strong>%1</strong> could not be retrieved, as read "
    00541         "access could not be obtained." ).arg( dir );
    00542       causes << i18n( "You may not have permissions to read the file or open "
    00543         "the directory.") << cLocked << cHardware;
    00544       solutions << sAccess << sQuerylock << sSysadmin;
    00545       break;
    00546
    00547     case  KIO::ERR_CANNOT_OPEN_FOR_WRITING:
    00548       errorName = i18n( "Cannot Open Resource For Writing" );
    00549       description = i18n( "This means that the file, <strong>%1</strong>, could "
    00550         "not be written to as requested, because access with permission to "
    00551         "write could not be obtained." ).arg( filename );
    00552       causes << cAccess << cLocked << cHardware;
    00553       solutions << sAccess << sQuerylock << sSysadmin;
    00554       break;
    00555
    00556     case  KIO::ERR_CANNOT_LAUNCH_PROCESS:
    00557       errorName = i18n( "Cannot Initiate the %1 Protocol" ).arg( protocol );
    00558       techName = i18n( "Unable to Launch Process" );
    00559       description = i18n( "The program on your computer which provides access "
    00560         "to the <strong>%1</strong> protocol could not be started. This is "
    00561         "usually due to technical reasons." ).arg( protocol );
    00562       causes << i18n( "The program which provides compatibility with this "
    00563         "protocol may not have been updated with your last update of KDE. "
    00564         "This can cause the program to be incompatible with the current version "
    00565         "and thus not start." ) << cBug;
    00566       solutions << sUpdate << sSysadmin;
    00567       break;
    00568
    00569     case  KIO::ERR_INTERNAL:
    00570       errorName = i18n( "Internal Error" );
    00571       description = i18n( "The program on your computer which provides access "
    00572         "to the <strong>%1</strong> protocol has reported an internal error." )
    00573         .arg( protocol );
    00574       causes << cBuglikely;
    00575       solutions << sUpdate << sBugreport;
    00576       break;
    00577
    00578     case  KIO::ERR_MALFORMED_URL:
    00579       errorName = i18n( "Inproperly Formatted URL" );
    00580       description = i18n( "The <strong>U</strong>niform <strong>R</strong>esource "
    00581         "<strong>L</strong>ocator (URL) that you entered was not properly "
    00582         "formatted. The format of a URL is generally as follows:"
    00583         "<blockquote><strong>protocol://user:password@www.example.org:port/directory/"
    00584         "filename.extension?query=value</strong></blockquote>" );
    00585       solutions << sTypo;
    00586       break;
    00587
    00588     case  KIO::ERR_UNSUPPORTED_PROTOCOL:
    00589       errorName = i18n( "Unsupported Protocol %1" ).arg( protocol );
    00590       description = i18n( "The protocol <strong>%1</strong> is not supported "
    00591         "by the KDE programs currently installed on this computer." )
    00592         .arg( protocol );
    00593       causes << i18n( "The requested protocol may not be supported." )
    00594         << i18n( "The versions of the %1 protocol supported by this computer and "
    00595         "the server may be incompatible." ).arg( protocol );
    00596       solutions << i18n( "You may perform a search on the Internet for a KDE "
    00597         "program (called a kioslave or ioslave) which supports this protocol. "
    00598         "Places to search include <a href=\"http://apps.kde.com/\">"
    00599         "http://apps.kde.com/</a> and <a href=\"http://freshmeat.net/\">"
    00600         "http://freshmeat.net/</a>." )
    00601         << sUpdate << sSysadmin;
    00602       break;
    00603
    00604     case  KIO::ERR_NO_SOURCE_PROTOCOL:
    00605       errorName = i18n( "URL Does Not Refer to a Resource." );
    00606       techName = i18n( "Protocol is a Filter Protocol" );
    00607       description = i18n( "The <strong>U</strong>niform <strong>R</strong>esource "
    00608         "<strong>L</strong>ocator (URL) that you entered did not refer to a "
    00609         "specific resource." );
    00610       causes << i18n( "KDE is able to communicate through a protocol within a "
    00611         "protocol; the protocol specified is only for use in such situations, "
    00612         "however this is not one of these situations. This is a rare event, and "
    00613         "is likely to indicate a programming error." );
    00614       solutions << sTypo;
    00615       break;
    00616
    00617     case  KIO::ERR_UNSUPPORTED_ACTION:
    00618       errorName = i18n( "Unsupported Action: %1" ).arg( errorText );
    00619       description = i18n( "The requested action is not supported by the KDE "
    00620         "program which is implementing the <strong>%1</strong> protocol." )
    00621         .arg( protocol );
    00622       causes << i18n( "This error is very much dependent on the KDE program. The "
    00623         "additional information should give you more information than is available "
    00624         "to the KDE input/output architecture." );
    00625       solutions << i18n( "Attempt to find another way to accomplish the same "
    00626         "outcome." );
    00627       break;
    00628
    00629     case  KIO::ERR_IS_DIRECTORY:
    00630       errorName = i18n( "File Expected" );
    00631       description = i18n( "The request expected a file, however the "
    00632         "directory <strong>%1</strong> was found instead." ).arg( dir );
    00633       causes << i18n( "This may be an error on the server side." ) << cBug;
    00634       solutions << sUpdate << sSysadmin;
    00635       break;
    00636
    00637     case  KIO::ERR_IS_FILE:
    00638       errorName = i18n( "Directory Expected" );
    00639       description = i18n( "The request expected a directory, however "
    00640         "the file <strong>%1</strong> was found instead." ).arg( filename );
    00641       causes << cBug;
    00642       solutions << sUpdate << sSysadmin;
    00643       break;
    00644
    00645     case  KIO::ERR_DOES_NOT_EXIST:
    00646       errorName = i18n( "File or Directory Does Not Exist" );
    00647       description = i18n( "The specified file or directory <strong>%1</strong> "
    00648         "does not exist." ).arg( dir );
    00649       causes << cBug;
    00650       solutions << sUpdate << sSysadmin;
    00651       break;
    00652
    00653     case  KIO::ERR_FILE_ALREADY_EXIST:
    00654       errorName = i18n( "File Already Exists" );
    00655       description = i18n( "The requested file could not be created because a "
    00656         "file with the same name already exists." );
    00657       solutions << i18n ( "Try moving the current file out of the way first, "
    00658         "and then try again." )
    00659         << i18n ( "Delete the current file and try again." )
    00660         << i18n( "Choose an alternate filename for the new file." );
    00661       break;
    00662
    00663     case  KIO::ERR_DIR_ALREADY_EXIST:
    00664       errorName = i18n( "Directory Already Exists" );
    00665       description = i18n( "The requested directory could not be created because "
    00666         "a directory with the same name already exists." );
    00667       solutions << i18n( "Try moving the current directory out of the way first, "
    00668         "and then try again." )
    00669         << i18n( "Delete the current directory and try again." )
    00670         << i18n( "Choose an alternate name for the new directory." );
    00671       break;
    00672
    00673     case  KIO::ERR_UNKNOWN_HOST:
    00674       errorName = i18n( "Unknown Host" );
    00675       description = i18n( "An unknown host error indicates that the server with "
    00676         "the requested name, <strong>%1</strong>, could not be "
    00677         "located on the Internet." ).arg( host );
    00678       causes << i18n( "The name that you typed, %1, may not exist: it may be "
    00679         "incorrectly typed." ).arg( host )
    00680         << cNetwork << cNetconf;
    00681       solutions << sNetwork << sSysadmin;
    00682       break;
    00683
    00684     case  KIO::ERR_ACCESS_DENIED:
    00685       errorName = i18n( "Access Denied" );
    00686       description = i18n( "Access was denied to the specified resource, "
    00687         "<strong>%1</strong>." ).arg( url );
    00688       causes << i18n( "You may have supplied incorrect authentication details or "
    00689         "none at all." )
    00690         << i18n( "Your account may not have permission to access the "
    00691         "specified resource." );
    00692       solutions << i18n( "Retry the request and ensure your authentication details "
    00693         "are entered correctly." ) << sSysadmin;
    00694       if ( !isSlaveNetwork ) solutions << sServeradmin;
    00695       break;
    00696
    00697     case  KIO::ERR_WRITE_ACCESS_DENIED:
    00698       errorName = i18n( "Write Access Denied" );
    00699       description = i18n( "This means that an attempt to write to the file "
    00700         "<strong>%1</strong> was rejected." ).arg( filename );
    00701       causes << cAccess << cLocked << cHardware;
    00702       solutions << sAccess << sQuerylock << sSysadmin;
    00703       break;
    00704
    00705     case  KIO::ERR_CANNOT_ENTER_DIRECTORY:
    00706       errorName = i18n( "Unable to Enter Directory" );
    00707       description = i18n( "This means that an attempt to enter (in other words, "
    00708         "to open) the requested directory <strong>%1</strong> was rejected." )
    00709         .arg( dir );
    00710       causes << cAccess << cLocked;
    00711       solutions << sAccess << sQuerylock << sSysadmin;
    00712       break;
    00713
    00714     case  KIO::ERR_PROTOCOL_IS_NOT_A_FILESYSTEM:
    00715       errorName = i18n( "Directory Listing Unavailable" );
    00716       techName = i18n( "Protocol %1 is not a Filesystem" ).arg( protocol );
    00717       description = i18n( "This means that a request was made which requires "
    00718         "determining the contents of the directory, and the KDE program supporting "
    00719         "this protocol is unable to do so." );
    00720       causes << cBug;
    00721       solutions << sUpdate << sBugreport;
    00722       break;
    00723
    00724     case  KIO::ERR_CYCLIC_LINK:
    00725       errorName = i18n( "Cyclic Link Detected" );
    00726       description = i18n( "UNIX environments are commonly able to link a file or "
    00727         "directory to a separate name and/or location. KDE detected a link or "
    00728         "series of links that results in an infinite loop - i.e. the file was "
    00729         "(perhaps in a roundabout way) linked to itself." );
    00730       solutions << i18n( "Delete one part of the loop in order that it does not "
    00731         "cause an infinite loop, and try again." ) << sSysadmin;
    00732       break;
    00733
    00734     case  KIO::ERR_USER_CANCELED:
    00735       // Do nothing in this case. The user doesn't need to be told what he just did.
    00736       // rodda: However, if we have been called, an application is about to display
    00737       // this information anyway. If we don't return sensible information, the
    00738       // user sees a blank dialog (I have seen this myself)
    00739       errorName = i18n( "Request Aborted By User" );
    00740       description = i18n( "The request was not completed because it was "
    00741         "aborted." );
    00742       solutions << i18n( "Retry the request." );
    00743       break;
    00744
    00745     case  KIO::ERR_CYCLIC_COPY:
    00746       errorName = i18n( "Cyclic Link Detected During Copy" );
    00747       description = i18n( "UNIX environments are commonly able to link a file or "
    00748         "directory to a separate name and/or location. During the requested copy "
    00749         "operation, KDE detected a link or series of links that results in an "
    00750         "infinite loop - i.e. the file was (perhaps in a roundabout way) linked "
    00751         "to itself." );
    00752       solutions << i18n( "Delete one part of the loop in order that it does not "
    00753         "cause an infinite loop, and try again." ) << sSysadmin;
    00754       break;
    00755
    00756     case  KIO::ERR_COULD_NOT_CREATE_SOCKET:
    00757       errorName = i18n( "Could Not Create Network Connection" );
    00758       techName = i18n( "Could Not Create Socket" );
    00759       description = i18n( "This is a fairly technical error in which a required "
    00760         "device for network communications (a socket) could not be created." );
    00761       causes << i18n( "The network connection may be incorrectly configured, or "
    00762         "the network interface may not be enabled." );
    00763       solutions << sNetwork << sSysadmin;
    00764       break;
    00765
    00766     case  KIO::ERR_COULD_NOT_CONNECT:
    00767       errorName = i18n( "Connection to Server Refused" );
    00768       description = i18n( "The server <strong>%1</strong> refused to allow this "
    00769         "computer to make a connection." ).arg( host );
    00770       causes << i18n( "The server, while currently connected to the Internet, "
    00771         "may not be configured to allow requests." )
    00772         << i18n( "The server, while currently connected to the Internet, "
    00773         "may not be running the requested service (%1)." ).arg( protocol )
    00774         << i18n( "A network firewall (a device which restricts Internet "
    00775         "requests), either protecting your network or the network of the server, "
    00776         "may have intervened, preventing this request." );
    00777       solutions << sTryagain << sServeradmin << sSysadmin;
    00778       break;
    00779
    00780     case  KIO::ERR_CONNECTION_BROKEN:
    00781       errorName = i18n( "Connection to Server Closed Unexpectedly" );
    00782       description = i18n( "Although a connection was established to "
    00783         "<strong>%1</strong>, the connection was closed at an unexpected point "
    00784         "in the communication." ).arg( host );
    00785       causes << cNetwork << cNetpath << i18n( "A protocol error may have occurred, "
    00786         "causing the server to close the connection as a response to the error." );
    00787       solutions << sTryagain << sServeradmin << sSysadmin;
    00788       break;
    00789
    00790     case  KIO::ERR_NOT_FILTER_PROTOCOL:
    00791       errorName = i18n( "URL Resource Invalid." );
    00792       techName = i18n( "Protocol %1 is not a Filter Protocol" ).arg( protocol );
    00793       description = i18n( "The <strong>U</strong>niform <strong>R</strong>esource "
    00794         "<strong>L</strong>ocator (URL) that you entered did not refer to "
    00795         "a valid mechanism of accessing the specific resource, "
    00796         "<strong>%1%2</strong>." )
    00797         .arg( host != QString::null ? host + '/' : QString::null ).arg( dir );
    00798       causes << i18n( "KDE is able to communicate through a protocol within a "
    00799         "protocol. This request specified a protocol be used as such, however "
    00800         "this protocol is not capable of such an action. This is a rare event, "
    00801         "and is likely to indicate a programming error." );
    00802       solutions << sTypo << sSysadmin;
    00803       break;
    00804
    00805     case  KIO::ERR_COULD_NOT_MOUNT:
    00806       errorName = i18n( "Unable to Initialize Input/Output Device" );
    00807       techName = i18n( "Could Not Mount Device" );
    00808       description = i18n( "The requested device could not be initialized "
    00809         "(\"mounted\"). The reported error was: <strong>%1</strong>" )
    00810         .arg( errorText );
    00811       causes << i18n( "The device may not be ready, for example there may be "
    00812         "no media in a removable media device (i.e. no CD-ROM in a CD drive), "
    00813         "or in the case of a peripheral/portable device, the device may not "
    00814         "be correctly connected." )
    00815         << i18n( "You may not have permissions to initialize (\"mount\") the "
    00816         "device. On UNIX systems, often system administrator privileges are "
    00817         "required to initialize a device." )
    00818         << cHardware;
    00819       solutions << i18n( "Check that the device is ready; removable drives "
    00820         "must contain media, and portable devices must be connected and powered "
    00821         "on.; and try again." ) << sAccess << sSysadmin;
    00822       break;
    00823
    00824     case  KIO::ERR_COULD_NOT_UNMOUNT:
    00825       errorName = i18n( "Unable to Uninitialize Input/Output Device" );
    00826       techName = i18n( "Could Not Unmount Device" );
    00827       description = i18n( "The requested device could not be uninitialized "
    00828         "(\"unmounted\"). The reported error was: <strong>%1</strong>" )
    00829         .arg( errorText );
    00830       causes << i18n( "The device may be busy, that is, still in use by "
    00831         "another application or user. Even such things as having an open "
    00832         "browser window on a location on this device may cause the device to "
    00833         "remain in use." )
    00834         << i18n( "You may not have permissions to uninitialize (\"unmount\") "
    00835         "the device. On UNIX systems, system administrator privileges are "
    00836         "often required to uninitialize a device." )
    00837         << cHardware;
    00838       solutions << i18n( "Check that no applications are accessing the device, "
    00839         "and try again." ) << sAccess << sSysadmin;
    00840       break;
    00841
    00842     case  KIO::ERR_COULD_NOT_READ:
    00843       errorName = i18n( "Cannot Read From Resource" );
    00844       description = i18n( "This means that although the resource, "
    00845         "<strong>%1</strong>, was able to be opened, an error occurred while "
    00846         "reading the contents of the resource." ).arg( url );
    00847       causes << i18n( "You may not have permissions to read from the resource." );
    00848       if ( !isSlaveNetwork ) causes << cNetwork;
    00849       causes << cHardware;
    00850       solutions << sAccess;
    00851       if ( !isSlaveNetwork ) solutions << sNetwork;
    00852       solutions << sSysadmin;
    00853       break;
    00854
    00855     case  KIO::ERR_COULD_NOT_WRITE:
    00856       errorName = i18n( "Cannot Write to Resource" );
    00857       description = i18n( "This means that although the resource, <strong>%1</strong>"
    00858         ", was able to be opened, an error occurred while writing to the resource." )
    00859         .arg( url );
    00860       causes << i18n( "You may not have permissions to write to the resource." );
    00861       if ( !isSlaveNetwork ) causes << cNetwork;
    00862       causes << cHardware;
    00863       solutions << sAccess;
    00864       if ( !isSlaveNetwork ) solutions << sNetwork;
    00865       solutions << sSysadmin;
    00866       break;
    00867
    00868     case  KIO::ERR_COULD_NOT_BIND:
    00869       errorName = i18n( "Could Not Listen for Network Connections" );
    00870       techName = i18n( "Could Not Bind" );
    00871       description = i18n( "This is a fairly technical error in which a required "
    00872         "device for network communications (a socket) could not be established "
    00873         "to listen for incoming network connections." );
    00874       causes << i18n( "The network connection may be incorrectly configured, or "
    00875         "the network interface may not be enabled." );
    00876       solutions << sNetwork << sSysadmin;
    00877       break;
    00878
    00879     case  KIO::ERR_COULD_NOT_LISTEN:
    00880       errorName = i18n( "Could Not Listen for Network Connections" );
    00881       techName = i18n( "Could Not Listen" );
    00882       description = i18n( "This is a fairly technical error in which a required "
    00883         "device for network communications (a socket) could not be established "
    00884         "to listen for incoming network connections." );
    00885       causes << i18n( "The network connection may be incorrectly configured, or "
    00886         "the network interface may not be enabled." );
    00887       solutions << sNetwork << sSysadmin;
    00888       break;
    00889
    00890     case  KIO::ERR_COULD_NOT_ACCEPT:
    00891       errorName = i18n( "Could Not Accept Network Connection" );
    00892       description = i18n( "This is a fairly technical error in which an error "
    00893         "occurred while attempting to accept an incoming network connection." );
    00894       causes << i18n( "The network connection may be incorrectly configured, or "
    00895         "the network interface may not be enabled." )
    00896         << i18n( "You may not have permissions to accept the connection." );
    00897       solutions << sNetwork << sSysadmin;
    00898       break;
    00899
    00900     case  KIO::ERR_COULD_NOT_LOGIN:
    00901       errorName = i18n( "Could Not Login: %1" ).arg( errorText );
    00902       description = i18n( "An attempt to login to perform the requested "
    00903         "operation was unsuccessful." );
    00904       causes << i18n( "You may have supplied incorrect authentication details or "
    00905         "none at all." )
    00906         << i18n( "Your account may not have permission to access the "
    00907         "specified resource." ) << cProtocol;
    00908       solutions << i18n( "Retry the request and ensure your authentication details "
    00909         "are entered correctly." ) << sServeradmin << sSysadmin;
    00910       break;
    00911
    00912     case  KIO::ERR_COULD_NOT_STAT:
    00913       errorName = i18n( "Could Not Determine Resource Status" );
    00914       techName = i18n( "Could Not Stat Resource" );
    00915       description = i18n( "An attempt to determine information about the status "
    00916         "of the resource <strong>%1</strong>, such as the resource name, type, "
    00917         "size, etc., was unsuccessful." ).arg( url );
    00918       causes << i18n( "The specified resource may not have existed or may "
    00919         "not be accessible." ) << cProtocol << cHardware;
    00920       solutions << i18n( "Retry the request and ensure your authentication details "
    00921         "are entered correctly." ) << sSysadmin;
    00922       break;
    00923
    00924     case  KIO::ERR_COULD_NOT_CLOSEDIR:
    00925       //result = i18n( "Could not terminate listing %1" ).arg( errorText );
    00926       errorName = i18n( "Could Not Cancel Listing" );
    00927       techName = i18n( "FIXME: Document this" );
    00928       break;
    00929
    00930     case  KIO::ERR_COULD_NOT_MKDIR:
    00931       errorName = i18n( "Could Not Create Directory" );
    00932       description = i18n( "An attempt to create the requested directory failed." );
    00933       causes << cAccess << i18n( "The location where the directory was to be created "
    00934         "may not exist." );
    00935       if ( !isSlaveNetwork ) causes << cProtocol;
    00936       solutions << i18n( "Retry the request." ) << sAccess;
    00937       break;
    00938
    00939     case  KIO::ERR_COULD_NOT_RMDIR:
    00940       errorName = i18n( "Could Not Remove Directory" );
    00941       description = i18n( "An attempt to remove the specified directory, "
    00942         "<strong>%1</strong>, failed." ).arg( dir );
    00943       causes << i18n( "The specified directory may not exist." )
    00944         << i18n( "The specified directory may not be empty." )
    00945         << cAccess;
    00946       if ( !isSlaveNetwork ) causes << cProtocol;
    00947       solutions << i18n( "Ensure that the directory exists and is empty, and try "
    00948         "again." ) << sAccess;
    00949       break;
    00950
    00951     case  KIO::ERR_CANNOT_RESUME:
    00952       errorName = i18n( "Could Not Resume File Transfer" );
    00953       description = i18n( "The specified request asked that the transfer of "
    00954         "file <strong>%1</strong> be resumed at a certain point of the "
    00955         "transfer. This was not possible." ).arg( filename );
    00956       causes << i18n( "The protocol, or the server, may not support file "
    00957         "resuming." );
    00958       solutions << i18n( "Retry the request without attempting to resume "
    00959         "transfer." );
    00960       break;
    00961
    00962     case  KIO::ERR_CANNOT_RENAME:
    00963       errorName = i18n( "Could Not Rename Resource" );
    00964       description = i18n( "An attempt to rename the specified resource "
    00965         "<strong>%1</strong> failed." ).arg( url );
    00966       causes << cAccess << cExists;
    00967       if ( !isSlaveNetwork ) causes << cProtocol;
    00968       solutions << sAccess << sExists;
    00969       break;
    00970
    00971     case  KIO::ERR_CANNOT_CHMOD:
    00972       errorName = i18n( "Could Not Alter Permissions of Resource" );
    00973       description = i18n( "An attempt to alter the permissions on the specified "
    00974         "resource <strong>%1</strong> failed." ).arg( url );
    00975       causes << cAccess << cExists;
    00976       solutions << sAccess << sExists;
    00977       break;
    00978
    00979     case  KIO::ERR_CANNOT_DELETE:
    00980       errorName = i18n( "Could Not Delete Resource" );
    00981       description = i18n( "An attempt to delete the specified resource "
    00982         "<strong>%1</strong> failed." ).arg( url );
    00983       causes << cAccess << cExists;
    00984       solutions << sAccess << sExists;
    00985       break;
    00986
    00987     case  KIO::ERR_SLAVE_DIED:
    00988       errorName = i18n( "Unexpected Program Termination" );
    00989       description = i18n( "The program on your computer which provides access "
    00990         "to the <strong>%1</strong> protocol has unexpectedly terminated." )
    00991         .arg( url );
    00992       causes << cBuglikely;
    00993       solutions << sUpdate << sBugreport;
    00994       break;
    00995
    00996     case  KIO::ERR_OUT_OF_MEMORY:
    00997       errorName = i18n( "Out Of Memory" );
    00998       description = i18n( "The program on your computer which provides access "
    00999         "to the <strong>%1</strong> protocol could not obtain the memory "
    01000         "required to continue." ).arg( protocol );
    01001       causes << cBuglikely;
    01002       solutions << sUpdate << sBugreport;
    01003       break;
    01004
    01005     case  KIO::ERR_UNKNOWN_PROXY_HOST:
    01006       errorName = i18n( "Unknown Proxy Host" );
    01007       description = i18n( "While retrieving information about the specified "
    01008         "proxy host, <strong>%1</strong>, an Unknown Host error was encountered. "
    01009         "An unknown host error indicates that the requested name could not be "
    01010         "located on the Internet." ).arg( errorText );
    01011       causes << i18n( "There may have been a problem with your network "
    01012         "configuration, specifically your proxy's hostname. If you have been "
    01013         "accessing the Internet with no problems recently, this is unlikely." )
    01014         << cNetwork;
    01015       solutions << i18n( "Double-check your proxy settings and try again." )
    01016         << sSysadmin;
    01017       break;
    01018
    01019     case  KIO::ERR_COULD_NOT_AUTHENTICATE:
    01020       errorName = i18n( "Authentication Failed: Method %1 Not Supported" )
    01021          .arg( errorText );
    01022       description = i18n( "Although you may have supplied the correct "
    01023         "authentication details, the authentication failed because the "
    01024         "method that the server is using is not supported by the KDE "
    01025         "program implementing the protocol %1." ).arg( protocol );
    01026       solutions << i18n( "Please file a bug at <a href=\"http://bugs.kde.org/\">"
    01027         "http://bugs.kde.org/</a> to inform the KDE team of the unsupported "
    01028         "authentication method." ) << sSysadmin;
    01029       break;
    01030
    01031     case  KIO::ERR_ABORTED:
    01032       errorName = i18n( "Request Aborted" );
    01033       description = i18n( "The request was not completed because it was "
    01034         "aborted." );
    01035       solutions << i18n( "Retry the request." );
    01036       break;
    01037
    01038     case  KIO::ERR_INTERNAL_SERVER:
    01039       errorName = i18n( "Internal Error in Server" );
    01040       description = i18n( "The program on the server which provides access "
    01041         "to the <strong>%1</strong> protocol has reported an internal error: "
    01042         "%0." ).arg( protocol );
    01043       causes << i18n( "This is most likely to be caused by a bug in the "
    01044         "server program. Please consider submitting a full bug report as "
    01045         "detailed below." );
    01046       solutions << i18n( "Contact the administrator of the server "
    01047         "to advise them of the problem." )
    01048         << i18n( "If you know who the authors of the server software are, "
    01049         "submit the bug report directly to them." );
    01050       break;
    01051
    01052     case  KIO::ERR_SERVER_TIMEOUT:
    01053       errorName = i18n( "Timeout Error" );
    01054       description = i18n( "Although contact was made with the server, a "
    01055         "response was not received within the amount of time allocated for "
    01056         "the request as follows:<ul>"
    01057         "<li>Timeout for establishing a connection: %1 seconds</li>"
    01058         "<li>Timeout for receiving a response: %2 seconds</li>"
    01059         "<li>Timeout for accessing proxy servers: %3 seconds</li></ul>"
    01060         "Please note that you can alter these timeout settings in the KDE "
    01061         "Control Center, by selecting Network -> Preferences." )
    01062         .arg( KProtocolManager::connectTimeout() )
    01063         .arg( KProtocolManager::responseTimeout() )
    01064         .arg( KProtocolManager::proxyConnectTimeout() );
    01065       causes << cNetpath << i18n( "The server was too busy responding to other "
    01066         "requests to respond." );
    01067       solutions << sTryagain << sServeradmin;
    01068       break;
    01069
    01070     case  KIO::ERR_UNKNOWN:
    01071       errorName = i18n( "Unknown Error" );
    01072       description = i18n( "The program on your computer which provides access "
    01073         "to the <strong>%1</strong> protocol has reported an unknown error: "
    01074         "%2." ).arg( protocol ).arg( errorText );
    01075       causes << cBug;
    01076       solutions << sUpdate << sBugreport;
    01077       break;
    01078
    01079     case  KIO::ERR_UNKNOWN_INTERRUPT:
    01080       errorName = i18n( "Unknown Interruption" );
    01081       description = i18n( "The program on your computer which provides access "
    01082         "to the <strong>%1</strong> protocol has reported an interruption of "
    01083         "an unknown type: %2." ).arg( protocol ).arg( errorText );
    01084       causes << cBug;
    01085       solutions << sUpdate << sBugreport;
    01086       break;
    01087
    01088     case KIO::ERR_CANNOT_DELETE_ORIGINAL:
    01089       errorName = i18n( "Could Not Delete Original File" );
    01090       description = i18n( "The requested operation required the deleting of "
    01091         "the original file, most likely at the end of a file move operation. "
    01092         "The original file <strong>%1</strong> could not be deleted." )
    01093         .arg( errorText );
    01094       causes << cAccess;
    01095       solutions << sAccess;
    01096       break;
    01097
    01098     case KIO::ERR_CANNOT_DELETE_PARTIAL:
    01099       errorName = i18n( "Could Not Delete Temporary File" );
    01100       description = i18n( "The requested operation required the creation of "
    01101         "a temporary file in which to save the new file while being "
    01102         "downloaded. This temporary file <strong>%1</strong> could not be "
    01103         "deleted." ).arg( errorText );
    01104       causes << cAccess;
    01105       solutions << sAccess;
    01106       break;
    01107
    01108     case KIO::ERR_CANNOT_RENAME_ORIGINAL:
    01109       errorName = i18n( "Could Not Rename Original File" );
    01110       description = i18n( "The requested operation required the renaming of "
    01111         "the original file <strong>%1</strong>, however it could not be "
    01112         "renamed." ).arg( errorText );
    01113       causes << cAccess;
    01114       solutions << sAccess;
    01115       break;
    01116
    01117     case KIO::ERR_CANNOT_RENAME_PARTIAL:
    01118       errorName = i18n( "Could Not Rename Temporary File" );
    01119       description = i18n( "The requested operation required the creation of "
    01120         "a temporary file <strong>%1</strong>, however it could not be "
    01121         "created." ).arg( errorText );
    01122       causes << cAccess;
    01123       solutions << sAccess;
    01124       break;
    01125
    01126     case KIO::ERR_CANNOT_SYMLINK:
    01127       errorName = i18n( "Could Not Create Link" );
    01128       techName = i18n( "Could Not Create Symbolic Link" );
    01129       description = i18n( "The requested symbolic link %1 could not be created." )
    01130         .arg( errorText );
    01131       causes << cAccess;
    01132       solutions << sAccess;
    01133       break;
    01134
    01135     case KIO::ERR_NO_CONTENT:
    01136       errorName = i18n( "No Content" );
    01137       description = errorText;
    01138       break;
    01139
    01140     case KIO::ERR_DISK_FULL:
    01141       errorName = i18n( "Disk Full" );
    01142       description = i18n( "The requested file <strong>%1</strong> could not be "
    01143         "written to as there is inadequate disk space." ).arg( errorText );
    01144       solutions << i18n( "Free up enough disk space by 1) deleting unwanted and "
    01145         "temporary files; 2) archiving files to removable media storage such as "
    01146         "CD-Recordable discs; or 3) obtain more storage capacity." )
    01147         << sSysadmin;
    01148       break;
    01149
    01150     case KIO::ERR_IDENTICAL_FILES:
    01151       errorName = i18n( "Source and Destination Files Identical" );
    01152       description = i18n( "The operation could not be completed because the "
    01153         "source and destination files are the same file." );
    01154       solutions << i18n( "Choose a different filename for the destination file." );
    01155       break;
    01156
    01157     default:
    01158       // fall back to the plain error...
    01159       errorName = i18n( "Undocumented Error" );
    01160       description = buildErrorString( errorCode, errorText );
    01161   }
    01162
    01163   QByteArray ret;
    01164   QDataStream stream(ret, IO_WriteOnly);
    01165   stream << errorName << techName << description << causes << solutions;
    01166   return ret;
    01167 }
    01168
    01169 #include <limits.h>
    01170 #include <stdlib.h>
    01171 #include <stdio.h>
    01172 #include <qfile.h>
    01173
    01174 #include <config.h>
    01175
    01176 #ifdef HAVE_PATHS_H
    01177 #include <paths.h>
    01178 #endif
    01179 #ifdef HAVE_SYS_STAT_H
    01180 #include <sys/stat.h>
    01181 #endif
    01182 #include <sys/param.h>
    01183 #ifdef HAVE_LIMITS_H
    01184 #include <limits.h>
    01185 #endif
    01186 #ifdef HAVE_SYS_MNTTAB_H
    01187 #include <sys/mnttab.h>
    01188 #endif
    01189 #ifdef HAVE_MNTENT_H
    01190 #include <mntent.h>
    01191 #endif
    01192 #ifdef HAVE_SYS_UCRED_H
    01193 #include <sys/ucred.h>
    01194 #endif
    01195 #ifdef HAVE_SYS_MOUNT_H
    01196 #include <sys/mount.h>
    01197 #endif
    01198 #ifdef HAVE_FSTAB_H
    01199 #include <fstab.h>
    01200 #endif
    01201 #if defined(_AIX)
    01202 #include <sys/mntctl.h>
    01203 #include <sys/vmount.h>
    01204 #include <sys/vfs.h>
    01205 /* AIX does not prototype mntctl anywhere that I can find */
    01206 #ifndef mntctl
    01207 extern "C" {
    01208 int mntctl(int command, int size, void* buffer);
    01209 }
    01210 #endif
    01211 extern "C" struct vfs_ent *getvfsbytype(int vfsType);
    01212 extern "C" void endvfsent( );
    01213 #endif
    01214
    01215 /***************************************************************
    01216  *
    01217  * Utility functions
    01218  *
    01219  ***************************************************************/
    01220
    01221 #ifndef HAVE_GETMNTINFO
    01222
    01223 #ifdef _PATH_MOUNTED
    01224 // On some Linux, MNTTAB points to /etc/fstab !
    01225 # undef MNTTAB
    01226 # define MNTTAB _PATH_MOUNTED
    01227 #else
    01228 # ifndef MNTTAB
    01229 #  ifdef MTAB_FILE
    01230 #   define MNTTAB MTAB_FILE
    01231 #  else
    01232 #   define MNTTAB "/etc/mnttab"
    01233 #  endif
    01234 # endif
    01235 #endif
    01236
    01237 // There are (at least) four kind of APIs:
    01238 // setmntent + getmntent + struct mntent (linux...)
    01239 //             getmntent + struct mnttab
    01240 // mntctl                + struct vmount (AIX)
    01241 // getmntinfo + struct statfs&flags (BSD 4.4 and friends)
    01242 // getfsent + char* (BSD 4.3 and friends)
    01243
    01244 #ifdef HAVE_SETMNTENT
    01245 #define SETMNTENT setmntent
    01246 #define ENDMNTENT endmntent
    01247 #define STRUCT_MNTENT struct mntent *
    01248 #define STRUCT_SETMNTENT FILE *
    01249 #define GETMNTENT(file, var) ((var = getmntent(file)) != 0)
    01250 #define MOUNTPOINT(var) var->mnt_dir
    01251 #define MOUNTTYPE(var) var->mnt_type
    01252 #define HASMNTOPT(var, opt) hasmntopt(var, opt)
    01253 #define FSNAME(var) var->mnt_fsname
    01254 #elif defined(_AIX)
    01255 /* we don't need this stuff */
    01256 #else
    01257 #define SETMNTENT fopen
    01258 #define ENDMNTENT fclose
    01259 #define STRUCT_MNTENT struct mnttab
    01260 #define STRUCT_SETMNTENT FILE *
    01261 #define GETMNTENT(file, var) (getmntent(file, &var) == 0)
    01262 #define MOUNTPOINT(var) var.mnt_mountp
    01263 #define MOUNTTYPE(var) var.mnt_fstype
    01264 #define HASMNTOPT(var, opt) hasmntopt(&var, opt)
    01265 #define FSNAME(var) var.mnt_special
    01266 #endif
    01267
    01268 #endif /* HAVE_GETMNTINFO */
    01269
    01270 QString KIO::findDeviceMountPoint( const QString& filename )
    01271 {
    01272     QString result;
    01273
    01274 #ifdef HAVE_VOLMGT
    01275         /*
    01276          *  support for Solaris volume management
    01277          */
    01278         const char *volpath;
    01279         FILE *mnttab;
    01280         struct mnttab mnt;
    01281         int len;
    01282         QCString devname;
    01283
    01284         if( (volpath = volmgt_root()) == NULL ) {
    01285                 kdDebug( 7007 ) << "findDeviceMountPoint: "
    01286                         << "VOLMGT: can't find volmgt root dir" << endl;
    01287                 return QString::null;
    01288         }
    01289
    01290         if( (mnttab = fopen( MNTTAB, "r" )) == NULL ) {
    01291                 kdDebug( 7007 ) << "findDeviceMountPoint: "
    01292                         << "VOLMGT: can't open mnttab" << endl;
    01293                 return QString::null;
    01294         }
    01295
    01296         devname = volpath;
    01297         devname += QFile::encodeName( filename );
    01298         devname += '/';
    01299         len = devname.length();
    01300 //      kdDebug( 7007 ) << "findDeviceMountPoint: "
    01301 //              << "VOLMGT: searching mountpoint for \"" << devname << "\""
    01302 //              << endl;
    01303
    01304         /*
    01305          *  find the mountpoint
    01306          *  floppies:
    01307          *      /dev/disketteN    => <volpath>/dev/disketteN
    01308          *  CDROM, ZIP, and other media:
    01309          *      /dev/dsk/cXtYdZs2 => <volpath>/dev/dsk/cXtYdZ  (without slice#)
    01310          */
    01311         rewind( mnttab );
    01312         result = QString::null;
    01313         while( getmntent( mnttab, &mnt ) == 0 ) {
    01314                 /*
    01315                  *  either match the exact device name (floppies),
    01316                  *  or the device name without the slice#
    01317                  */
    01318                 if( strncmp( devname.data(), mnt.mnt_special, len ) == 0
    01319                         || (strncmp( devname.data(), mnt.mnt_special, len - 3 ) == 0
    01320                                 && mnt.mnt_special[len - 3] == '/' )
    01321                         || (strcmp(QFile::encodeName(filename).data()
    01322                                         , mnt.mnt_special)==0)) {
    01323                         result = mnt.mnt_mountp;
    01324                         break;
    01325                 }
    01326         }
    01327         fclose( mnttab );
    01328         devname.~QCString();
    01329 #else
    01330
    01331     char    realpath_buffer[MAXPATHLEN];
    01332     QCString realname;
    01333
    01334     realname = QFile::encodeName(filename);
    01335     /* If the path contains symlinks, get the real name */
    01336     if (realpath(realname, realpath_buffer) != 0)
    01337       // succes, use result from realpath
    01338       realname = realpath_buffer;
    01339
    01340 #ifdef HAVE_GETMNTINFO
    01341
    01342     struct statfs *mounted;
    01343
    01344     int num_fs = getmntinfo(&mounted, MNT_NOWAIT);
    01345
    01346     for (int i=0;i<num_fs;i++) {
    01347
    01348         QCString device_name = mounted[i].f_mntfromname;
    01349
    01350         // If the path contains symlinks, get
    01351         // the real name
    01352         if (realpath(device_name, realpath_buffer) != 0)
    01353             // succes, use result from realpath
    01354             device_name = realpath_buffer;
    01355
    01356         if (realname == device_name) {
    01357             result = mounted[i].f_mntonname;
    01358             break;
    01359         }
    01360     }
    01361
    01362 #elif defined(_AIX)
    01363
    01364     struct vmount *mntctl_buffer;
    01365     struct vmount *vm;
    01366     char *mountedfrom;
    01367     char *mountedto;
    01368     int fsname_len, num;
    01369     int buf_sz = 4096;
    01370
    01371     /* mntctl can be used to query mounted file systems.
    01372      * mntctl takes only the command MCTL_QUERY so far.
    01373      * The buffer is filled with an array of vmount structures, but these
    01374      * vmount structures have variable size.
    01375      * mntctl return values:
    01376      * -1 error
    01377      *  0 look in first word of buffer for required bytes, 4096 may be
    01378      *    a good starting size, but if tables grow too large, look here.
    01379      * >0 number of vmount structures
    01380      */
    01381     mntctl_buffer = (struct vmount*)malloc(buf_sz);
    01382     num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
    01383     if (num == 0)
    01384     {
    01385         buf_sz = *(int*)mntctl_buffer;
    01386         free(mntctl_buffer);
    01387         mntctl_buffer = (struct vmount*)malloc(buf_sz);
    01388         num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
    01389     }
    01390
    01391     if (num > 0)
    01392     {
    01393         /* iterate through items in the vmount structure: */
    01394         vm = mntctl_buffer;
    01395         for ( ; num > 0; num-- )
    01396         {
    01397             /* get the name of the mounted file systems: */
    01398             fsname_len = vmt2datasize(vm, VMT_STUB);
    01399             mountedto     = (char*)malloc(fsname_len + 1);
    01400             mountedto[fsname_len] = '\0';
    01401             strncpy(mountedto, (char *)vmt2dataptr(vm, VMT_STUB), fsname_len);
    01402
    01403             /* get the mount-from information: */
    01404             fsname_len = vmt2datasize(vm, VMT_OBJECT);
    01405             mountedfrom     = (char*)malloc(fsname_len + 1);
    01406             mountedfrom[fsname_len] = '\0';
    01407             strncpy(mountedfrom, (char *)vmt2dataptr(vm, VMT_OBJECT), fsname_len);
    01408
    01409             QCString device_name = mountedfrom;
    01410
    01411             if (realpath(device_name, realpath_buffer) != 0)
    01412                 // success, use result from realpath
    01413                 device_name = realpath_buffer;
    01414
    01415             free(mountedfrom);
    01416
    01417             if (realname == device_name) {
    01418                 result = mountedto;
    01419                 free(mountedto);
    01420                 break;
    01421             }
    01422
    01423             free(mountedto);
    01424
    01425             /* goto the next vmount structure: */
    01426             vm = (struct vmount *)((char *)vm + vm->vmt_length);
    01427         }
    01428     }
    01429
    01430     free( mntctl_buffer );
    01431
    01432 #else
    01433
    01434     STRUCT_SETMNTENT mtab;
    01435
    01436     //kdDebug( 7007 ) << "realname " << realname << endl;
    01437
    01438     /* Get the list of mounted file systems */
    01439
    01440     if ((mtab = SETMNTENT(MNTTAB, "r")) == 0) {
    01441         perror("setmntent");
    01442         return QString::null;
    01443     }
    01444
    01445     /* Loop over all file systems and see if we can find our
    01446      * mount point.
    01447      * Note that this is the mount point with the longest match.
    01448      * XXX: Fails if me->mnt_dir is not a realpath but goes
    01449      * through a symlink, e.g. /foo/bar where /foo is a symlink
    01450      * pointing to /local/foo.
    01451      *
    01452      * How kinky can you get with a filesystem?
    01453      */
    01454
    01455     STRUCT_MNTENT me;
    01456
    01457     while (GETMNTENT(mtab, me))
    01458     {
    01459       // There may be symbolic links into the /etc/mnttab
    01460       // So we have to find the real device name here as well!
    01461       QCString device_name = FSNAME(me);
    01462
    01463       //kdDebug( 7007 ) << "device_name=" << device_name << endl;
    01464
    01465       // If the path contains symlinks, get
    01466       // the real name
    01467       if (realpath(device_name, realpath_buffer) != 0)
    01468           // succes, use result from realpath
    01469          device_name = realpath_buffer;
    01470
    01471       //kdDebug( 7007 ) << "device_name after realpath =" << device_name << endl;
    01472
    01473       if (realname == device_name)
    01474       {
    01475           result = MOUNTPOINT(me);
    01476           break;
    01477       }
    01478     }
    01479
    01480     ENDMNTENT(mtab);
    01481
    01482 #endif /* GET_MNTINFO */
    01483 #endif /* HAVE_VOLMGT */
    01484
    01485     //kdDebug( 7007 ) << "Returning result " << result << endl;
    01486     return result;
    01487 }
    01488
    01489 // Don't just trust the return value, keep iterating to check for a better match (bigger max)
    01490 static bool is_my_mountpoint( const char *mountpoint, const char *realname, int &max )
    01491 {
    01492     int length = strlen(mountpoint);
    01493
    01494     if (!strncmp(mountpoint, realname, length)
    01495         && length > max) {
    01496         max = length;
    01497         if (length == 1 || realname[length] == '/' || realname[length] == '\0')
    01498             return true;
    01499     }
    01500     return false;
    01501 }
    01502
    01503 typedef enum { Unseen, Right, Wrong } MountState;
    01504
    01508 static void check_mount_point(const char *mounttype,
    01509                               const char *fsname,
    01510                               MountState &isslow, MountState &isautofs)
    01511 {
    01512     bool nfs = !strcmp(mounttype, "nfs");
    01513     bool autofs = !strcmp(mounttype, "autofs");
    01514     bool pid = (strstr(fsname, ":(pid") != 0);
    01515
    01516     if (nfs && !pid)
    01517         isslow = Right;
    01518     else if (isslow == Right)
    01519         isslow = Wrong;
    01520
    01521     /* Does this look like automounted? */
    01522     if (autofs || (nfs && pid)) {
    01523         isautofs = Right;
    01524         isslow = Right;
    01525     }
    01526 }
    01527
    01528 // returns the mount point, checks the mount state.
    01529 // if ismanual == Wrong this function does not check the manual mount state
    01530 static QString get_mount_info(const QString& filename,
    01531     MountState& isautofs, MountState& isslow, MountState& ismanual)
    01532 {
    01533     char realname[MAXPATHLEN];
    01534
    01535     memset(realname, 0, MAXPATHLEN);
    01536
    01537     /* If the path contains symlinks, get the real name */
    01538     if (realpath(QFile::encodeName(filename), realname) == 0) {
    01539         if( strlcpy(realname, QFile::encodeName(filename),MAXPATHLEN)>=MAXPATHLEN)
    01540             return QString::null;
    01541     }
    01542
    01543     int max = 0;
    01544     QString mountPoint;
    01545
    01546     /* Loop over all file systems and see if we can find our
    01547      * mount point.
    01548      * Note that this is the mount point with the longest match.
    01549      * XXX: Fails if me->mnt_dir is not a realpath but goes
    01550      * through a symlink, e.g. /foo/bar where /foo is a symlink
    01551      * pointing to /local/foo.
    01552      *
    01553      * How kinky can you get with a filesystem?
    01554      */
    01555
    01556 #ifdef HAVE_GETMNTINFO
    01557
    01558     struct statfs *mounted;
    01559     char    realpath_buffer[MAXPATHLEN];
    01560
    01561     int num_fs = getmntinfo(&mounted, MNT_NOWAIT);
    01562
    01563     for (int i=0;i<num_fs;i++) {
    01564
    01565         QCString device_name = mounted[i].f_mntfromname;
    01566
    01567         // If the path contains symlinks, get
    01568         // the real name
    01569         if (realpath(device_name, realpath_buffer) != 0)
    01570             // succes, use result from realpath
    01571             device_name = realpath_buffer;
    01572 #ifdef __osf__
    01573         char * mounttype = mnt_names[mounted[i].f_type];
    01574 #else
    01575         char * mounttype = mounted[i].f_fstypename;
    01576 #endif
    01577         if ( is_my_mountpoint( mounted[i].f_mntonname, realname, max ) )
    01578         {
    01579             mountPoint = QFile::decodeName(mounted[i].f_mntonname);
    01580             check_mount_point( mounttype, mounted[i].f_mntfromname,
    01581                                isautofs, isslow );
    01582             // keep going, looking for a potentially better one
    01583
    01584             if (ismanual == Unseen)
    01585             {
    01586                 struct fstab *ft = getfsfile(mounted[i].f_mntonname);
    01587                 if (!ft || strstr(ft->fs_mntops, "noauto"))
    01588                   ismanual = Right;
    01589             }
    01590         }
    01591     }
    01592
    01593 #elif defined(_AIX)
    01594
    01595     struct vmount *mntctl_buffer;
    01596     struct vmount *vm;
    01597     char *mountedfrom;
    01598     char *mountedto;
    01599     int fsname_len, num;
    01600     char realpath_buffer[MAXPATHLEN];
    01601     int buf_sz = 4096;
    01602
    01603     mntctl_buffer = (struct vmount*)malloc(buf_sz);
    01604     num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
    01605     if (num == 0)
    01606     {
    01607         buf_sz = *(int*)mntctl_buffer;
    01608         free(mntctl_buffer);
    01609         mntctl_buffer = (struct vmount*)malloc(buf_sz);
    01610         num = mntctl(MCTL_QUERY, buf_sz, mntctl_buffer);
    01611     }
    01612
    01613     if (num > 0)
    01614     {
    01615         /* iterate through items in the vmount structure: */
    01616         vm = (struct vmount *)mntctl_buffer;
    01617         for ( ; num > 0; num-- )
    01618         {
    01619             /* get the name of the mounted file systems: */
    01620             fsname_len = vmt2datasize(vm, VMT_STUB);
    01621             mountedto     = (char*)malloc(fsname_len + 1);
    01622             mountedto[fsname_len] = '\0';
    01623             strncpy(mountedto, (char *)vmt2dataptr(vm, VMT_STUB), fsname_len);
    01624
    01625             fsname_len = vmt2datasize(vm, VMT_OBJECT);
    01626             mountedfrom     = (char*)malloc(fsname_len + 1);
    01627             mountedfrom[fsname_len] = '\0';
    01628             strncpy(mountedfrom, (char *)vmt2dataptr(vm, VMT_OBJECT), fsname_len);
    01629
    01630             /* get the mount-from information: */
    01631             QCString device_name = mountedfrom;
    01632
    01633             if (realpath(device_name, realpath_buffer) != 0)
    01634                 // success, use result from realpath
    01635                 device_name = realpath_buffer;
    01636
    01637             /* Look up the string for the file system type,
    01638              * as listed in /etc/vfs.
    01639              * ex.: nfs,jfs,afs,cdrfs,sfs,cachefs,nfs3,autofs
    01640              */
    01641             struct vfs_ent* ent = getvfsbytype(vm->vmt_gfstype);
    01642
    01643             if ( is_my_mountpoint( mountedto, realname, max ) )
    01644             {
    01645                 mountPoint = QFile::decodeName(mountedto);
    01646                 check_mount_point(ent->vfsent_name, device_name, isautofs, isslow);
    01647
    01648                 if (ismanual == Unseen)
    01649                 {
    01650                     // TODO: add check for ismanual, I couldn't find any way
    01651                     // how to get the mount attribute from /etc/filesystems
    01652                     ismanual == Wrong;
    01653                 }
    01654             }
    01655
    01656             free(mountedfrom);
    01657             free(mountedto);
    01658
    01659             /* goto the next vmount structure: */
    01660             vm = (struct vmount *)((char *)vm + vm->vmt_length);
    01661         }
    01662
    01663         endvfsent( );
    01664     }
    01665
    01666     free( mntctl_buffer );
    01667
    01668 #else
    01669
    01670     STRUCT_SETMNTENT mtab;
    01671     /* Get the list of mounted file systems */
    01672
    01673     if ((mtab = SETMNTENT(MNTTAB, "r")) == 0) {
    01674         perror("setmntent");
    01675         return QString::null;
    01676     }
    01677
    01678     STRUCT_MNTENT me;
    01679
    01680     while (true) {
    01681         if (!GETMNTENT(mtab, me))
    01682             break;
    01683
    01684         if ( is_my_mountpoint( MOUNTPOINT(me), realname, max ) )
    01685         {
    01686             mountPoint = QFile::decodeName( MOUNTPOINT(me) );
    01687             check_mount_point(MOUNTTYPE(me), FSNAME(me), isautofs, isslow);
    01688             // we don't check if ismanual is Right, if /a/b is manually
    01689             // mounted /a/b/c can't be automounted. At least IMO.
    01690             if (ismanual == Unseen)
    01691             {
    01692                 // The next GETMNTENT call may destroy 'me'
    01693                 // Copy out the info that we need
    01694                 QCString fsname_me = FSNAME(me);
    01695                 QCString mounttype_me = MOUNTTYPE(me);
    01696
    01697                 STRUCT_SETMNTENT fstab;
    01698                 // TODO: #define FSTAB (FSTAB_FILE?), important for Solaris
    01699                 if ((fstab = SETMNTENT("/etc/fstab", "r")) == 0)
    01700                     continue;
    01701
    01702                 bool found = false;
    01703                 STRUCT_MNTENT fe;
    01704                 while (GETMNTENT(fstab, fe))
    01705                 {
    01706                     if (fsname_me == FSNAME(fe))
    01707                     {
    01708                         found = true;
    01709                         if (HASMNTOPT(fe, "noauto") ||
    01710                             !strcmp(MOUNTTYPE(fe), "supermount"))
    01711                             ismanual = Right;
    01712                         break;
    01713                     }
    01714                 }
    01715                 if (!found || (mounttype_me == "supermount"))
    01716                   ismanual = Right;
    01717
    01718                 ENDMNTENT(fstab);
    01719             }
    01720         }
    01721     }
    01722
    01723     ENDMNTENT(mtab);
    01724
    01725 #endif
    01726
    01727     if (isautofs == Right && isslow == Unseen)
    01728         isslow = Right;
    01729
    01730     return mountPoint;
    01731 }
    01732
    01733 QString KIO::findPathMountPoint(const QString& filename)
    01734 {
    01735   MountState isautofs = Unseen, isslow = Unseen, ismanual = Wrong;
    01736   return get_mount_info(filename, isautofs, isslow, ismanual);
    01737 }
    01738
    01739 bool KIO::manually_mounted(const QString& filename)
    01740 {
    01741   MountState isautofs = Unseen, isslow = Unseen, ismanual = Unseen;
    01742   QString mountPoint = get_mount_info(filename, isautofs, isslow, ismanual);
    01743   return (mountPoint != QString::null) && (ismanual == Right);
    01744 }
    01745
    01746 bool KIO::probably_slow_mounted(const QString& filename)
    01747 {
    01748   MountState isautofs = Unseen, isslow = Unseen, ismanual = Wrong;
    01749   QString mountPoint = get_mount_info(filename, isautofs, isslow, ismanual);
    01750   return (mountPoint != QString::null) && (isslow == Right);
    01751 }
    01752
    01753 KIO::CacheControl KIO::parseCacheControl(const QString &cacheControl)
    01754 {
    01755   QString tmp = cacheControl.lower();
    01756
    01757   if (tmp == "cacheonly")
    01758      return KIO::CC_CacheOnly;
    01759   if (tmp == "cache")
    01760      return KIO::CC_Cache;
    01761   if (tmp == "verify")
    01762      return KIO::CC_Verify;
    01763   if (tmp == "refresh")
    01764      return KIO::CC_Refresh;
    01765   if (tmp == "reload")
    01766      return KIO::CC_Reload;
    01767
    01768   kdWarning() << "unrecognized Cache control option:"<<cacheControl<<endl;
    01769   return KIO::CC_Verify;
    01770 }
    01771
    01772 QString KIO::getCacheControlString(KIO::CacheControl cacheControl)
    01773 {
    01774     if (cacheControl == KIO::CC_CacheOnly)
    01775         return "CacheOnly";
    01776     if (cacheControl == KIO::CC_Cache)
    01777         return "Cache";
    01778     if (cacheControl == KIO::CC_Verify)
    01779         return "Verify";
    01780     if (cacheControl == KIO::CC_Refresh)
    01781         return "Refresh";
    01782     if (cacheControl == KIO::CC_Reload)
    01783         return "Reload";
    01784     kdFatal() << "unrecognized Cache control enum value:"<<cacheControl<<endl;
    01785     return QString::null;
    01786 }

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:12:45 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001