• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KIO

kprotocolmanager.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 1999 Torben Weis <weis@kde.org>
00003    Copyright (C) 2000- Waldo Bastain <bastain@kde.org>
00004    Copyright (C) 2000- Dawit Alemayehu <adawit@kde.org>
00005    Copyright (C) 2008 Jarosław Staniek <staniek@kde.org>
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License version 2 as published by the Free Software Foundation.
00010 
00011    This library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Library General Public License for more details.
00015 
00016    You should have received a copy of the GNU Library General Public License
00017    along with this library; see the file COPYING.LIB.  If not, write to
00018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019    Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include "kprotocolmanager.h"
00023 
00024 #include <string.h>
00025 #include <unistd.h>
00026 #include <sys/utsname.h>
00027 #include <QtCore/QCoreApplication>
00028 #include <QtDBus/QtDBus>
00029 
00030 #include <kdeversion.h>
00031 #include <kdebug.h>
00032 #include <kglobal.h>
00033 #include <klocale.h>
00034 #include <kconfiggroup.h>
00035 #include <ksharedconfig.h>
00036 #include <kstandarddirs.h>
00037 #include <kstringhandler.h>
00038 #include <kurl.h>
00039 #include <kio/slaveconfig.h>
00040 #include <kio/ioslave_defaults.h>
00041 #include <kio/http_slave_defaults.h>
00042 
00043 #include <kprotocolinfofactory.h>
00044 
00045 class
00046 KProtocolManagerPrivate
00047 {
00048 public:
00049    KProtocolManagerPrivate();
00050 
00051    ~KProtocolManagerPrivate();
00052 
00053    KSharedConfig::Ptr config;
00054    KSharedConfig::Ptr http_config;
00055    KUrl url;
00056    QString protocol;
00057    QString proxy;
00058    QString modifiers;
00059    QString useragent;
00060 
00061     QMap<QString /*mimetype*/, QString /*protocol*/> protocolForArchiveMimetypes;
00062 };
00063 
00064 K_GLOBAL_STATIC(KProtocolManagerPrivate, kProtocolManagerPrivate)
00065 
00066 KProtocolManagerPrivate::KProtocolManagerPrivate()
00067 {
00068     // post routine since KConfig::sync() breaks if called too late
00069     qAddPostRoutine(kProtocolManagerPrivate.destroy);
00070 }
00071 
00072 KProtocolManagerPrivate::~KProtocolManagerPrivate()
00073 {
00074     qRemovePostRoutine(kProtocolManagerPrivate.destroy);
00075 }
00076 
00077 
00078 // DEFAULT USERAGENT STRING
00079 #define CFG_DEFAULT_UAGENT(X) \
00080 QString("Mozilla/5.0 (compatible; Konqueror/%1.%2%3) KHTML/%4.%5.%6 (like Gecko)") \
00081         .arg(KDE_VERSION_MAJOR).arg(KDE_VERSION_MINOR).arg(X).arg(KDE_VERSION_MAJOR).arg(KDE_VERSION_MINOR).arg(KDE_VERSION_RELEASE)
00082 
00083 #define PRIVATE_DATA \
00084 KProtocolManagerPrivate *d = kProtocolManagerPrivate
00085 
00086 void KProtocolManager::reparseConfiguration()
00087 {
00088     PRIVATE_DATA;
00089     if (d->http_config) {
00090         d->http_config->reparseConfiguration();
00091     }
00092     if (d->config) {
00093         d->config->reparseConfiguration();
00094     }
00095     d->protocol.clear();
00096     d->proxy.clear();
00097     d->modifiers.clear();
00098     d->useragent.clear();
00099     d->url.clear();
00100 
00101   // Force the slave config to re-read its config...
00102   KIO::SlaveConfig::self()->reset ();
00103 }
00104 
00105 KSharedConfig::Ptr KProtocolManager::config()
00106 {
00107     PRIVATE_DATA;
00108   if (!d->config)
00109   {
00110      d->config = KSharedConfig::openConfig("kioslaverc", KConfig::NoGlobals);
00111   }
00112   return d->config;
00113 }
00114 
00115 static KConfigGroup http_config()
00116 {
00117     PRIVATE_DATA;
00118   if (!d->http_config) {
00119      d->http_config = KSharedConfig::openConfig("kio_httprc", KConfig::NoGlobals);
00120   }
00121   return KConfigGroup(d->http_config, QString());
00122 }
00123 
00124 /*=============================== TIMEOUT SETTINGS ==========================*/
00125 
00126 int KProtocolManager::readTimeout()
00127 {
00128   KConfigGroup cg( config(), QString() );
00129   int val = cg.readEntry( "ReadTimeout", DEFAULT_READ_TIMEOUT );
00130   return qMax(MIN_TIMEOUT_VALUE, val);
00131 }
00132 
00133 int KProtocolManager::connectTimeout()
00134 {
00135   KConfigGroup cg( config(), QString() );
00136   int val = cg.readEntry( "ConnectTimeout", DEFAULT_CONNECT_TIMEOUT );
00137   return qMax(MIN_TIMEOUT_VALUE, val);
00138 }
00139 
00140 int KProtocolManager::proxyConnectTimeout()
00141 {
00142   KConfigGroup cg( config(), QString() );
00143   int val = cg.readEntry( "ProxyConnectTimeout", DEFAULT_PROXY_CONNECT_TIMEOUT );
00144   return qMax(MIN_TIMEOUT_VALUE, val);
00145 }
00146 
00147 int KProtocolManager::responseTimeout()
00148 {
00149   KConfigGroup cg( config(), QString() );
00150   int val = cg.readEntry( "ResponseTimeout", DEFAULT_RESPONSE_TIMEOUT );
00151   return qMax(MIN_TIMEOUT_VALUE, val);
00152 }
00153 
00154 /*========================== PROXY SETTINGS =================================*/
00155 
00156 bool KProtocolManager::useProxy()
00157 {
00158   return proxyType() != NoProxy;
00159 }
00160 
00161 bool KProtocolManager::useReverseProxy()
00162 {
00163   KConfigGroup cg(config(), "Proxy Settings" );
00164   return cg.readEntry("ReversedException", false);
00165 }
00166 
00167 KProtocolManager::ProxyType KProtocolManager::proxyType()
00168 {
00169   KConfigGroup cg(config(), "Proxy Settings" );
00170   return static_cast<ProxyType>(cg.readEntry( "ProxyType" , 0));
00171 }
00172 
00173 KProtocolManager::ProxyAuthMode KProtocolManager::proxyAuthMode()
00174 {
00175   KConfigGroup cg(config(), "Proxy Settings" );
00176   return static_cast<ProxyAuthMode>(cg.readEntry( "AuthMode" , 0));
00177 }
00178 
00179 /*========================== CACHING =====================================*/
00180 
00181 bool KProtocolManager::useCache()
00182 {
00183   return http_config().readEntry( "UseCache", true );
00184 }
00185 
00186 KIO::CacheControl KProtocolManager::cacheControl()
00187 {
00188   QString tmp = http_config().readEntry("cache");
00189   if (tmp.isEmpty())
00190     return DEFAULT_CACHE_CONTROL;
00191   return KIO::parseCacheControl(tmp);
00192 }
00193 
00194 QString KProtocolManager::cacheDir()
00195 {
00196   return http_config().readPathEntry("CacheDir", KGlobal::dirs()->saveLocation("cache","http"));
00197 }
00198 
00199 int KProtocolManager::maxCacheAge()
00200 {
00201   return http_config().readEntry( "MaxCacheAge", DEFAULT_MAX_CACHE_AGE ); // 14 days
00202 }
00203 
00204 int KProtocolManager::maxCacheSize()
00205 {
00206   return http_config().readEntry( "MaxCacheSize", DEFAULT_MAX_CACHE_SIZE ); // 5 MB
00207 }
00208 
00209 QString KProtocolManager::noProxyFor()
00210 {
00211   KProtocolManager::ProxyType type = proxyType();
00212 
00213   QString noProxy = config()->group("Proxy Settings").readEntry( "NoProxyFor" );
00214   if (type == EnvVarProxy)
00215     noProxy = QString::fromLocal8Bit(qgetenv(noProxy.toLocal8Bit()));
00216 
00217   return noProxy;
00218 }
00219 
00220 QString KProtocolManager::proxyFor( const QString& protocol )
00221 {
00222   QString scheme = protocol.toLower();
00223 
00224   if (scheme == "webdav")
00225     scheme = "http";
00226   else if (scheme == "webdavs")
00227     scheme = "https";
00228 
00229   return config()->group("Proxy Settings" ).readEntry( scheme + "Proxy", QString() );
00230 }
00231 
00232 QString KProtocolManager::proxyForUrl( const KUrl &url )
00233 {
00234   QString proxy;
00235   ProxyType pt = proxyType();
00236 
00237   switch (pt)
00238   {
00239       case PACProxy:
00240       case WPADProxy:
00241           if (!url.host().isEmpty())
00242           {
00243             KUrl u (url);
00244             QString p = u.protocol().toLower();
00245 
00246             // webdav is a KDE specific protocol. Look up proxy
00247             // information using HTTP instead...
00248             if ( p == "webdav" )
00249             {
00250               p = "http";
00251               u.setProtocol( p );
00252             }
00253             else if ( p == "webdavs" )
00254             {
00255               p = "https";
00256               u.setProtocol( p );
00257             }
00258 
00259             if ( p.startsWith("http") || p == "ftp" || p == "gopher" )
00260             {
00261               QDBusReply<QString> reply =
00262                   QDBusInterface( "org.kde.kded", "/modules/proxyscout", "org.kde.KPAC.ProxyScout" )
00263                   .call( "proxyForUrl", u.url() );
00264               proxy = reply;
00265             }
00266           }
00267           break;
00268       case EnvVarProxy:
00269           proxy = QString::fromLocal8Bit(qgetenv(proxyFor(url.protocol()).toLocal8Bit())).trimmed();
00270           break;
00271       case ManualProxy:
00272           proxy = proxyFor( url.protocol() );
00273           break;
00274       case NoProxy:
00275       default:
00276           break;
00277   }
00278 
00279   return (proxy.isEmpty() ? QLatin1String("DIRECT") : proxy);
00280 }
00281 
00282 void KProtocolManager::badProxy( const QString &proxy )
00283 {
00284   QDBusInterface( "org.kde.kded", "/modules/proxyscout" )
00285       .call( "blackListProxy", proxy );
00286 }
00287 
00288 /*
00289     Domain suffix match. E.g. return true if host is "cuzco.inka.de" and
00290     nplist is "inka.de,hadiko.de" or if host is "localhost" and nplist is
00291     "localhost".
00292 */
00293 static bool revmatch(const char *host, const char *nplist)
00294 {
00295   if (host == 0)
00296     return false;
00297 
00298   const char *hptr = host + strlen( host ) - 1;
00299   const char *nptr = nplist + strlen( nplist ) - 1;
00300   const char *shptr = hptr;
00301 
00302   while ( nptr >= nplist )
00303   {
00304     if ( *hptr != *nptr )
00305     {
00306       hptr = shptr;
00307 
00308       // Try to find another domain or host in the list
00309       while(--nptr>=nplist && *nptr!=',' && *nptr!=' ') ;
00310 
00311       // Strip out multiple spaces and commas
00312       while(--nptr>=nplist && (*nptr==',' || *nptr==' ')) ;
00313     }
00314     else
00315     {
00316       if ( nptr==nplist || nptr[-1]==',' || nptr[-1]==' ')
00317         return true;
00318       if ( hptr == host ) // e.g. revmatch("bugs.kde.org","mybugs.kde.org")
00319         return false;
00320 
00321       hptr--;
00322       nptr--;
00323     }
00324   }
00325 
00326   return false;
00327 }
00328 
00329 QString KProtocolManager::slaveProtocol(const KUrl &url, QString &proxy)
00330 {
00331   if (url.hasSubUrl()) // We don't want the suburl's protocol
00332   {
00333      KUrl::List list = KUrl::split(url);
00334      KUrl l = list.last();
00335      return slaveProtocol(l, proxy);
00336   }
00337 
00338     PRIVATE_DATA;
00339   if (d->url == url)
00340   {
00341      proxy = d->proxy;
00342      return d->protocol;
00343   }
00344 
00345   if (useProxy())
00346   {
00347      proxy = proxyForUrl(url);
00348      if ((proxy != "DIRECT") && (!proxy.isEmpty()))
00349      {
00350         bool isRevMatch = false;
00351         KProtocolManager::ProxyType type = proxyType();
00352         bool useRevProxy = ((type == ManualProxy) && useReverseProxy());
00353 
00354         QString noProxy;
00355         // Check no proxy information iff the proxy type is either
00356         // manual or environment variable based...
00357         if ( (type == ManualProxy) || (type == EnvVarProxy) )
00358           noProxy = noProxyFor();
00359 
00360         if (!noProxy.isEmpty())
00361         {
00362            QString qhost = url.host().toLower();
00363            QByteArray host = qhost.toLatin1();
00364            QString qno_proxy = noProxy.trimmed().toLower();
00365            const QByteArray no_proxy = qno_proxy.toLatin1();
00366            isRevMatch = revmatch(host, no_proxy);
00367 
00368            // If no match is found and the request url has a port
00369            // number, try the combination of "host:port". This allows
00370            // users to enter host:port in the No-proxy-For list.
00371            if (!isRevMatch && url.port() > 0)
00372            {
00373               qhost += ':' + QString::number (url.port());
00374               host = qhost.toLatin1();
00375               isRevMatch = revmatch (host, no_proxy);
00376            }
00377 
00378            // If the hostname does not contain a dot, check if
00379            // <local> is part of noProxy.
00380            if (!isRevMatch && !host.isEmpty() && (strchr(host, '.') == NULL))
00381               isRevMatch = revmatch("<local>", no_proxy);
00382         }
00383 
00384         if ( (!useRevProxy && !isRevMatch) || (useRevProxy && isRevMatch) )
00385         {
00386            d->url = proxy;
00387            if ( d->url.isValid() )
00388            {
00389               // The idea behind slave protocols is not applicable to http
00390               // and webdav protocols.
00391               QString protocol = url.protocol().toLower();
00392               if (protocol.startsWith("http") || protocol.startsWith("webdav"))
00393                 d->protocol = protocol;
00394               else
00395               {
00396                 d->protocol = d->url.protocol();
00397                 kDebug () << "slaveProtocol: " << d->protocol;
00398               }
00399 
00400               d->url = url;
00401               d->proxy = proxy;
00402               return d->protocol;
00403            }
00404         }
00405      }
00406   }
00407 
00408   d->url = url;
00409   d->proxy.clear(); proxy.clear();
00410   d->protocol = url.protocol();
00411   return d->protocol;
00412 }
00413 
00414 /*================================= USER-AGENT SETTINGS =====================*/
00415 
00416 QString KProtocolManager::userAgentForHost( const QString& hostname )
00417 {
00418   QString sendUserAgent = KIO::SlaveConfig::self()->configData("http", hostname.toLower(), "SendUserAgent").toLower();
00419   if (sendUserAgent == "false")
00420      return QString();
00421 
00422   QString useragent = KIO::SlaveConfig::self()->configData("http", hostname.toLower(), "UserAgent");
00423 
00424   // Return the default user-agent if none is specified
00425   // for the requested host.
00426   if (useragent.isEmpty())
00427     return defaultUserAgent();
00428 
00429   return useragent;
00430 }
00431 
00432 QString KProtocolManager::defaultUserAgent( )
00433 {
00434   QString modifiers = KIO::SlaveConfig::self()->configData("http", QString(), "UserAgentKeys");
00435   return defaultUserAgent(modifiers);
00436 }
00437 
00438 QString KProtocolManager::defaultUserAgent( const QString &_modifiers )
00439 {
00440     PRIVATE_DATA;
00441   QString modifiers = _modifiers.toLower();
00442   if (modifiers.isEmpty())
00443      modifiers = DEFAULT_USER_AGENT_KEYS;
00444 
00445   if (d->modifiers == modifiers)
00446      return d->useragent;
00447 
00448   QString systemName, systemVersion, machine, supp;
00449   if (getSystemNameVersionAndMachine( systemName, systemVersion, machine ))
00450   {
00451     if( modifiers.contains('o') )
00452     {
00453       supp += QString("; %1").arg(systemName);
00454       if ( modifiers.contains('v') )
00455         supp += QString(" %1").arg(systemVersion);
00456     }
00457 #ifdef Q_WS_X11
00458     if( modifiers.contains('p') )
00459     {
00460       supp += QLatin1String("; X11");
00461     }
00462 #endif
00463     if( modifiers.contains('m') )
00464     {
00465       supp += QString("; %1").arg(machine);
00466     }
00467     if( modifiers.contains('l') )
00468     {
00469       supp += QString("; %1").arg(acceptLanguagesHeader());
00470     }
00471   }
00472   d->modifiers = modifiers;
00473   d->useragent = CFG_DEFAULT_UAGENT(supp);
00474   return d->useragent;
00475 }
00476 
00477 QString KProtocolManager::userAgentForApplication( const QString &appName, const QString& appVersion,
00478   const QStringList& extraInfo )
00479 {
00480   QString systemName, systemVersion, machine;
00481   QStringList info;
00482   if (getSystemNameVersionAndMachine( systemName, systemVersion, machine ))
00483     info += QString::fromLatin1("%1/%2").arg(systemName).arg(systemVersion);
00484   info += QString::fromLatin1("KDE/%1.%2.%3").arg(KDE_VERSION_MAJOR)
00485     .arg(KDE_VERSION_MINOR).arg(KDE_VERSION_RELEASE);
00486   if (!machine.isEmpty())
00487     info += machine;
00488   info += extraInfo;
00489   return QString::fromLatin1("%1/%2 (%3)").arg(appName).arg(appVersion).arg(info.join("; "));
00490 }
00491 
00492 bool KProtocolManager::getSystemNameVersionAndMachine(
00493   QString& systemName, QString& systemVersion, QString& machine )
00494 {
00495   struct utsname unameBuf;
00496   if ( 0 != uname( &unameBuf ) )
00497     return false;
00498 #ifdef Q_WS_WIN
00499   // we do not use unameBuf.sysname information constructed in kdewin32
00500   // because we want to get separate name and version
00501   systemName = QLatin1String( "Windows" );
00502   OSVERSIONINFOEX versioninfo;
00503   ZeroMemory(&versioninfo, sizeof(OSVERSIONINFOEX));
00504   // try calling GetVersionEx using the OSVERSIONINFOEX, if that fails, try using the OSVERSIONINFO
00505   versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
00506   bool ok = GetVersionEx( (OSVERSIONINFO *) &versioninfo );
00507   if ( !ok ) {
00508     versioninfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
00509     ok = GetVersionEx( (OSVERSIONINFO *) &versioninfo );
00510   }
00511   if ( ok )
00512     systemVersion = QString::fromLatin1("%1.%2")
00513       .arg(versioninfo.dwMajorVersion).arg(versioninfo.dwMinorVersion);
00514 #else
00515   systemName = unameBuf.sysname;
00516   systemVersion = unameBuf.release;
00517 #endif
00518   machine = unameBuf.machine;
00519   return true;
00520 }
00521 
00522 QString KProtocolManager::acceptLanguagesHeader()
00523 {
00524   static const QString &english = KGlobal::staticQString("en");
00525 
00526   // User's desktop language preference.
00527   QStringList languageList = KGlobal::locale()->languageList();
00528 
00529   // Replace possible "C" in the language list with "en", unless "en" is
00530   // already pressent. This is to keep user's priorities in order.
00531   // If afterwards "en" is still not present, append it.
00532   int idx = languageList.indexOf(QString::fromLatin1("C"));
00533   if (idx != -1)
00534   {
00535     if (languageList.contains(english))
00536       languageList.removeAt(idx);
00537     else
00538       languageList[idx] = english;
00539   }
00540   if (!languageList.contains(english))
00541     languageList += english;
00542 
00543   // Some languages may have web codes different from locale codes,
00544   // read them from the config and insert in proper order.
00545   KConfig acclangConf("accept-languages.codes", KConfig::NoGlobals);
00546   KConfigGroup replacementCodes(&acclangConf, "ReplacementCodes");
00547   QStringList languageListFinal;
00548   foreach (const QString &lang, languageList)
00549   {
00550     QStringList langs = replacementCodes.readEntry(lang, QStringList());
00551     if (langs.isEmpty())
00552       languageListFinal += lang;
00553     else
00554       languageListFinal += langs;
00555   }
00556 
00557   // The header is composed of comma separated languages.
00558   QString header = languageListFinal.join(", ");
00559 
00560   // Some of the languages may have country specifier delimited by
00561   // underscore, or modifier delimited by at-sign.
00562   // The header should use dashes instead.
00563   header.replace('_', '-');
00564   header.replace('@', '-');
00565 
00566   return header;
00567 }
00568 
00569 /*==================================== OTHERS ===============================*/
00570 
00571 bool KProtocolManager::markPartial()
00572 {
00573   return config()->group(QByteArray()).readEntry( "MarkPartial", true );
00574 }
00575 
00576 int KProtocolManager::minimumKeepSize()
00577 {
00578     return config()->group(QByteArray()).readEntry( "MinimumKeepSize",
00579                                                 DEFAULT_MINIMUM_KEEP_SIZE ); // 5000 byte
00580 }
00581 
00582 bool KProtocolManager::autoResume()
00583 {
00584   return config()->group(QByteArray()).readEntry( "AutoResume", false );
00585 }
00586 
00587 bool KProtocolManager::persistentConnections()
00588 {
00589   return config()->group(QByteArray()).readEntry( "PersistentConnections", true );
00590 }
00591 
00592 bool KProtocolManager::persistentProxyConnection()
00593 {
00594   return config()->group(QByteArray()).readEntry( "PersistentProxyConnection", false );
00595 }
00596 
00597 QString KProtocolManager::proxyConfigScript()
00598 {
00599   return config()->group("Proxy Settings").readEntry( "Proxy Config Script" );
00600 }
00601 
00602 /* =========================== PROTOCOL CAPABILITIES ============== */
00603 
00604 static KProtocolInfo::Ptr findProtocol(const KUrl &url)
00605 {
00606    QString protocol = url.protocol();
00607 
00608    if ( !KProtocolInfo::proxiedBy( protocol ).isEmpty() )
00609    {
00610       QString dummy;
00611       protocol = KProtocolManager::slaveProtocol(url, dummy);
00612    }
00613 
00614    return KProtocolInfoFactory::self()->findProtocol(protocol);
00615 }
00616 
00617 
00618 KProtocolInfo::Type KProtocolManager::inputType( const KUrl &url )
00619 {
00620   KProtocolInfo::Ptr prot = findProtocol(url);
00621   if ( !prot )
00622     return KProtocolInfo::T_NONE;
00623 
00624   return prot->m_inputType;
00625 }
00626 
00627 KProtocolInfo::Type KProtocolManager::outputType( const KUrl &url )
00628 {
00629   KProtocolInfo::Ptr prot = findProtocol(url);
00630   if ( !prot )
00631     return KProtocolInfo::T_NONE;
00632 
00633   return prot->m_outputType;
00634 }
00635 
00636 
00637 bool KProtocolManager::isSourceProtocol( const KUrl &url )
00638 {
00639   KProtocolInfo::Ptr prot = findProtocol(url);
00640   if ( !prot )
00641     return false;
00642 
00643   return prot->m_isSourceProtocol;
00644 }
00645 
00646 bool KProtocolManager::supportsListing( const KUrl &url )
00647 {
00648   KProtocolInfo::Ptr prot = findProtocol(url);
00649   if ( !prot )
00650     return false;
00651 
00652   return prot->m_supportsListing;
00653 }
00654 
00655 QStringList KProtocolManager::listing( const KUrl &url )
00656 {
00657   KProtocolInfo::Ptr prot = findProtocol(url);
00658   if ( !prot )
00659     return QStringList();
00660 
00661   return prot->m_listing;
00662 }
00663 
00664 bool KProtocolManager::supportsReading( const KUrl &url )
00665 {
00666   KProtocolInfo::Ptr prot = findProtocol(url);
00667   if ( !prot )
00668     return false;
00669 
00670   return prot->m_supportsReading;
00671 }
00672 
00673 bool KProtocolManager::supportsWriting( const KUrl &url )
00674 {
00675   KProtocolInfo::Ptr prot = findProtocol(url);
00676   if ( !prot )
00677     return false;
00678 
00679   return prot->m_supportsWriting;
00680 }
00681 
00682 bool KProtocolManager::supportsMakeDir( const KUrl &url )
00683 {
00684   KProtocolInfo::Ptr prot = findProtocol(url);
00685   if ( !prot )
00686     return false;
00687 
00688   return prot->m_supportsMakeDir;
00689 }
00690 
00691 bool KProtocolManager::supportsDeleting( const KUrl &url )
00692 {
00693   KProtocolInfo::Ptr prot = findProtocol(url);
00694   if ( !prot )
00695     return false;
00696 
00697   return prot->m_supportsDeleting;
00698 }
00699 
00700 bool KProtocolManager::supportsLinking( const KUrl &url )
00701 {
00702   KProtocolInfo::Ptr prot = findProtocol(url);
00703   if ( !prot )
00704     return false;
00705 
00706   return prot->m_supportsLinking;
00707 }
00708 
00709 bool KProtocolManager::supportsMoving( const KUrl &url )
00710 {
00711   KProtocolInfo::Ptr prot = findProtocol(url);
00712   if ( !prot )
00713     return false;
00714 
00715   return prot->m_supportsMoving;
00716 }
00717 
00718 bool KProtocolManager::supportsOpening( const KUrl &url )
00719 {
00720   KProtocolInfo::Ptr prot = findProtocol(url);
00721   if ( !prot )
00722     return false;
00723 
00724   return prot->m_supportsOpening;
00725 }
00726 
00727 bool KProtocolManager::canCopyFromFile( const KUrl &url )
00728 {
00729   KProtocolInfo::Ptr prot = findProtocol(url);
00730   if ( !prot )
00731     return false;
00732 
00733   return prot->m_canCopyFromFile;
00734 }
00735 
00736 
00737 bool KProtocolManager::canCopyToFile( const KUrl &url )
00738 {
00739   KProtocolInfo::Ptr prot = findProtocol(url);
00740   if ( !prot )
00741     return false;
00742 
00743   return prot->m_canCopyToFile;
00744 }
00745 
00746 bool KProtocolManager::canRenameFromFile( const KUrl &url )
00747 {
00748   KProtocolInfo::Ptr prot = findProtocol(url);
00749   if ( !prot )
00750     return false;
00751 
00752   return prot->canRenameFromFile();
00753 }
00754 
00755 
00756 bool KProtocolManager::canRenameToFile( const KUrl &url )
00757 {
00758   KProtocolInfo::Ptr prot = findProtocol(url);
00759   if ( !prot )
00760     return false;
00761 
00762   return prot->canRenameToFile();
00763 }
00764 
00765 bool KProtocolManager::canDeleteRecursive( const KUrl &url )
00766 {
00767   KProtocolInfo::Ptr prot = findProtocol(url);
00768   if ( !prot )
00769     return false;
00770 
00771   return prot->canDeleteRecursive();
00772 }
00773 
00774 KProtocolInfo::FileNameUsedForCopying KProtocolManager::fileNameUsedForCopying( const KUrl &url )
00775 {
00776   KProtocolInfo::Ptr prot = findProtocol(url);
00777   if ( !prot )
00778     return KProtocolInfo::FromUrl;
00779 
00780   return prot->fileNameUsedForCopying();
00781 }
00782 
00783 QString KProtocolManager::defaultMimetype( const KUrl &url )
00784 {
00785   KProtocolInfo::Ptr prot = findProtocol(url);
00786   if ( !prot )
00787     return QString();
00788 
00789   return prot->m_defaultMimetype;
00790 }
00791 
00792 QString KProtocolManager::protocolForArchiveMimetype( const QString& mimeType )
00793 {
00794     PRIVATE_DATA;
00795     if (d->protocolForArchiveMimetypes.isEmpty()) {
00796         const KProtocolInfo::List allProtocols = KProtocolInfoFactory::self()->allProtocols();
00797         for (KProtocolInfo::List::const_iterator it = allProtocols.begin();
00798              it != allProtocols.end(); ++it) {
00799             const QStringList archiveMimetypes = (*it)->archiveMimeTypes();
00800             Q_FOREACH(const QString& mime, archiveMimetypes) {
00801                 d->protocolForArchiveMimetypes.insert(mime, (*it)->name());
00802             }
00803         }
00804     }
00805     return d->protocolForArchiveMimetypes.value(mimeType);
00806 }
00807 
00808 #undef PRIVATE_DATA

KIO

Skip menu "KIO"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal