1
/* This file is part of the KDE libraries
2
Copyright (C) 1999 Torben Weis <weis@kde.org>
3
Copyright (C) 2000- Waldo Bastain <bastain@kde.org>
4
Copyright (C) 2000- Dawit Alemayehu <adawit@kde.org>
5
Copyright (C) 2008 Jarosław Staniek <staniek@kde.org>
7
This library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Library General Public
9
License version 2 as published by the Free Software Foundation.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Library General Public License for more details.
16
You should have received a copy of the GNU Library General Public License
17
along with this library; see the file COPYING.LIB. If not, write to
18
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
Boston, MA 02110-1301, USA.
22
#include "kprotocolmanager.h"
26
#include <sys/utsname.h>
28
#include <QtCore/QCoreApplication>
29
#include <QtCore/QStringBuilder>
30
#include <QtNetwork/QSslSocket>
31
#include <QtDBus/QtDBus>
33
#include <kdeversion.h>
37
#include <kconfiggroup.h>
38
#include <ksharedconfig.h>
39
#include <kstandarddirs.h>
40
#include <kstringhandler.h>
42
#include <kmimetypetrader.h>
43
#include <kio/slaveconfig.h>
44
#include <kio/ioslave_defaults.h>
45
#include <kio/http_slave_defaults.h>
46
#include <kprotocolinfofactory.h>
48
#define QL1S(x) QLatin1String(x)
49
#define QL1C(x) QLatin1Char(x)
52
KProtocolManagerPrivate
55
KProtocolManagerPrivate();
57
~KProtocolManagerPrivate();
59
KSharedConfig::Ptr config;
60
KSharedConfig::Ptr http_config;
67
QMap<QString /*mimetype*/, QString /*protocol*/> protocolForArchiveMimetypes;
70
K_GLOBAL_STATIC(KProtocolManagerPrivate, kProtocolManagerPrivate)
72
KProtocolManagerPrivate::KProtocolManagerPrivate()
74
// post routine since KConfig::sync() breaks if called too late
75
qAddPostRoutine(kProtocolManagerPrivate.destroy);
78
KProtocolManagerPrivate::~KProtocolManagerPrivate()
80
qRemovePostRoutine(kProtocolManagerPrivate.destroy);
84
// DEFAULT USERAGENT STRING
85
#define CFG_DEFAULT_UAGENT(X) \
86
QL1S("Mozilla/5.0 (compatible; Konqueror/") % \
87
QString::number(KDE::versionMajor()) % QL1C('.') % QString::number(KDE::versionMinor()) % \
88
X % QL1S(") KHTML/") % \
89
QString::number(KDE::versionMajor()) % QL1C('.') % QString::number(KDE::versionMinor()) % \
90
QL1C('.') % QString::number(KDE::versionRelease()) % QL1S(" (like Gecko)")
92
#define PRIVATE_DATA \
93
KProtocolManagerPrivate *d = kProtocolManagerPrivate
95
void KProtocolManager::reparseConfiguration()
99
d->http_config->reparseConfiguration();
102
d->config->reparseConfiguration();
106
d->modifiers.clear();
107
d->useragent.clear();
110
// Force the slave config to re-read its config...
111
KIO::SlaveConfig::self()->reset ();
114
KSharedConfig::Ptr KProtocolManager::config()
119
d->config = KSharedConfig::openConfig("kioslaverc", KConfig::NoGlobals);
124
static KConfigGroup http_config()
127
if (!d->http_config) {
128
d->http_config = KSharedConfig::openConfig("kio_httprc", KConfig::NoGlobals);
130
return KConfigGroup(d->http_config, QString());
133
/*=============================== TIMEOUT SETTINGS ==========================*/
135
int KProtocolManager::readTimeout()
137
KConfigGroup cg( config(), QString() );
138
int val = cg.readEntry( "ReadTimeout", DEFAULT_READ_TIMEOUT );
139
return qMax(MIN_TIMEOUT_VALUE, val);
142
int KProtocolManager::connectTimeout()
144
KConfigGroup cg( config(), QString() );
145
int val = cg.readEntry( "ConnectTimeout", DEFAULT_CONNECT_TIMEOUT );
146
return qMax(MIN_TIMEOUT_VALUE, val);
149
int KProtocolManager::proxyConnectTimeout()
151
KConfigGroup cg( config(), QString() );
152
int val = cg.readEntry( "ProxyConnectTimeout", DEFAULT_PROXY_CONNECT_TIMEOUT );
153
return qMax(MIN_TIMEOUT_VALUE, val);
156
int KProtocolManager::responseTimeout()
158
KConfigGroup cg( config(), QString() );
159
int val = cg.readEntry( "ResponseTimeout", DEFAULT_RESPONSE_TIMEOUT );
160
return qMax(MIN_TIMEOUT_VALUE, val);
163
/*========================== PROXY SETTINGS =================================*/
165
bool KProtocolManager::useProxy()
167
return proxyType() != NoProxy;
170
bool KProtocolManager::useReverseProxy()
172
KConfigGroup cg(config(), "Proxy Settings" );
173
return cg.readEntry("ReversedException", false);
176
KProtocolManager::ProxyType KProtocolManager::proxyType()
178
KConfigGroup cg(config(), "Proxy Settings" );
179
return static_cast<ProxyType>(cg.readEntry( "ProxyType" , 0));
182
KProtocolManager::ProxyAuthMode KProtocolManager::proxyAuthMode()
184
KConfigGroup cg(config(), "Proxy Settings" );
185
return static_cast<ProxyAuthMode>(cg.readEntry( "AuthMode" , 0));
188
/*========================== CACHING =====================================*/
190
bool KProtocolManager::useCache()
192
return http_config().readEntry( "UseCache", true );
195
KIO::CacheControl KProtocolManager::cacheControl()
197
QString tmp = http_config().readEntry("cache");
199
return DEFAULT_CACHE_CONTROL;
200
return KIO::parseCacheControl(tmp);
203
QString KProtocolManager::cacheDir()
205
return http_config().readPathEntry("CacheDir", KGlobal::dirs()->saveLocation("cache","http"));
208
int KProtocolManager::maxCacheAge()
210
return http_config().readEntry( "MaxCacheAge", DEFAULT_MAX_CACHE_AGE ); // 14 days
213
int KProtocolManager::maxCacheSize()
215
return http_config().readEntry( "MaxCacheSize", DEFAULT_MAX_CACHE_SIZE ); // 5 MB
218
QString KProtocolManager::noProxyFor()
220
KProtocolManager::ProxyType type = proxyType();
222
QString noProxy = config()->group("Proxy Settings").readEntry( "NoProxyFor" );
223
if (type == EnvVarProxy)
224
noProxy = QString::fromLocal8Bit(qgetenv(noProxy.toLocal8Bit()));
229
QString KProtocolManager::proxyFor( const QString& protocol )
231
QString key = protocol.toLower();
233
if (key == QL1S("webdav"))
235
else if (key == QL1S("webdavs"))
238
key += QL1S("Proxy");
240
return config()->group("Proxy Settings").readEntry(key, QString());
243
QString KProtocolManager::proxyForUrl( const KUrl &url )
246
ProxyType pt = proxyType();
252
if (!url.host().isEmpty())
255
QString p = u.protocol().toLower();
257
// webdav is a KDE specific protocol. Look up proxy
258
// information using HTTP instead...
259
if (p == QL1S("webdav"))
264
else if (p == QL1S("webdavs"))
270
if (p.startsWith(QL1S("http")) || p.startsWith(QL1S("ftp")))
272
QDBusReply<QString> reply = QDBusInterface(QL1S("org.kde.kded"),
273
QL1S("/modules/proxyscout"),
274
QL1S("org.kde.KPAC.ProxyScout"))
275
.call(QL1S("proxyForUrl"), u.url() );
281
proxy = QString::fromLocal8Bit(qgetenv(proxyFor(url.protocol()).toLocal8Bit())).trimmed();
284
proxy = proxyFor( url.protocol() );
291
return (proxy.isEmpty() ? QL1S("DIRECT") : proxy);
294
void KProtocolManager::badProxy( const QString &proxy )
296
QDBusInterface( QL1S("org.kde.kded"), QL1S("/modules/proxyscout"))
297
.call(QL1S("blackListProxy"), proxy);
301
Domain suffix match. E.g. return true if host is "cuzco.inka.de" and
302
nplist is "inka.de,hadiko.de" or if host is "localhost" and nplist is
305
static bool revmatch(const char *host, const char *nplist)
310
const char *hptr = host + strlen( host ) - 1;
311
const char *nptr = nplist + strlen( nplist ) - 1;
312
const char *shptr = hptr;
314
while ( nptr >= nplist )
316
if ( *hptr != *nptr )
320
// Try to find another domain or host in the list
321
while(--nptr>=nplist && *nptr!=',' && *nptr!=' ') ;
323
// Strip out multiple spaces and commas
324
while(--nptr>=nplist && (*nptr==',' || *nptr==' ')) ;
328
if ( nptr==nplist || nptr[-1]==',' || nptr[-1]==' ')
330
if ( nptr[-1]=='/' && hptr == host ) // "bugs.kde.org" vs "http://bugs.kde.org", the config UI says URLs are ok
332
if ( hptr == host ) // e.g. revmatch("bugs.kde.org","mybugs.kde.org")
343
QString KProtocolManager::slaveProtocol(const KUrl &url, QString &proxy)
345
if (url.hasSubUrl()) // We don't want the suburl's protocol
347
KUrl::List list = KUrl::split(url);
348
KUrl l = list.last();
349
return slaveProtocol(l, proxy);
361
proxy = proxyForUrl(url);
362
if ((proxy != "DIRECT") && (!proxy.isEmpty()))
364
bool isRevMatch = false;
365
KProtocolManager::ProxyType type = proxyType();
366
bool useRevProxy = ((type == ManualProxy) && useReverseProxy());
369
// Check no proxy information iff the proxy type is either
370
// manual or environment variable based...
371
if ( (type == ManualProxy) || (type == EnvVarProxy) )
372
noProxy = noProxyFor();
374
if (!noProxy.isEmpty())
376
QString qhost = url.host().toLower();
377
QByteArray host = qhost.toLatin1();
378
QString qno_proxy = noProxy.trimmed().toLower();
379
const QByteArray no_proxy = qno_proxy.toLatin1();
380
isRevMatch = revmatch(host, no_proxy);
382
// If no match is found and the request url has a port
383
// number, try the combination of "host:port". This allows
384
// users to enter host:port in the No-proxy-For list.
385
if (!isRevMatch && url.port() > 0)
388
qhost += QString::number(url.port());
389
host = qhost.toLatin1();
390
isRevMatch = revmatch (host, no_proxy);
393
// If the hostname does not contain a dot, check if
394
// <local> is part of noProxy.
395
if (!isRevMatch && !host.isEmpty() && (strchr(host, '.') == NULL))
396
isRevMatch = revmatch("<local>", no_proxy);
399
if ( (!useRevProxy && !isRevMatch) || (useRevProxy && isRevMatch) )
402
if (d->url.isValid() && !d->url.protocol().isEmpty())
404
// The idea behind slave protocols is not applicable to http
405
// and webdav protocols.
406
const QString protocol = url.protocol().toLower();
407
if (protocol.startsWith(QL1S("http")) || protocol.startsWith(QL1S("webdav")) ||
408
!KProtocolInfo::isKnownProtocol(protocol))
409
d->protocol = protocol;
412
d->protocol = d->url.protocol();
413
kDebug () << "slaveProtocol: " << d->protocol;
425
d->proxy.clear(); proxy.clear();
426
d->protocol = url.protocol();
430
/*================================= USER-AGENT SETTINGS =====================*/
432
QString KProtocolManager::userAgentForHost( const QString& hostname )
434
const QString sendUserAgent = KIO::SlaveConfig::self()->configData("http", hostname.toLower(), "SendUserAgent").toLower();
435
if (sendUserAgent == QL1S("false"))
438
const QString useragent = KIO::SlaveConfig::self()->configData("http", hostname.toLower(), "UserAgent");
440
// Return the default user-agent if none is specified
441
// for the requested host.
442
if (useragent.isEmpty())
443
return defaultUserAgent();
448
QString KProtocolManager::defaultUserAgent( )
450
const QString modifiers = KIO::SlaveConfig::self()->configData("http", QString(), "UserAgentKeys");
451
return defaultUserAgent(modifiers);
454
static QString defaultUserAgentFromPreferredService()
458
// Check if the default COMPONENT contains a custom default UA string...
459
KService::Ptr service = KMimeTypeTrader::self()->preferredService(QL1S("text/html"),
460
QL1S("KParts/ReadOnlyPart"));
461
if (service && service->showInKDE())
462
agentStr = service->property(QL1S("X-KDE-Default-UserAgent"),
463
QVariant::String).toString();
467
QString KProtocolManager::defaultUserAgent( const QString &_modifiers )
470
QString modifiers = _modifiers.toLower();
471
if (modifiers.isEmpty())
472
modifiers = DEFAULT_USER_AGENT_KEYS;
474
if (d->modifiers == modifiers && !d->useragent.isEmpty())
477
d->modifiers = modifiers;
480
The following code attempts to determine the default user agent string
481
from the 'X-KDE-UA-DEFAULT-STRING' property of the desktop file
482
for the preferred service that was configured to handle the 'text/html'
483
mime type. If the prefered service's desktop file does not specify this
484
property, the long standing default user agent string will be used.
485
The following keyword placeholders are automatically converted when the
486
user agent string is read from the property:
488
%SECURITY% Expands to"U" when SSL is supported, "N" otherwise.
489
%OSNAME% Expands to operating system name, e.g. Linux.
490
%OSVERSION% Expands to operating system version, e.g. 2.6.32
491
%SYSTYPE% Expands to machine or system type, e.g. i386
492
%PLATFORM% Expands to windowing system, e.g. X11 on Unix/Linux.
493
%LANGUAGE% Expands to default language in use, e.g. en-US.
494
%APPVERSION% Expands to QCoreApplication applicationName()/applicationVerison(),
495
e.g. Konqueror/4.5.0. If application name and/or application version
496
number are not set, then "KDE" and the runtime KDE version numbers
497
are used respectively.
499
All of the keywords are handled case-insensitively.
502
QString systemName, systemVersion, machine, supp;
503
const bool sysInfoFound = getSystemNameVersionAndMachine( systemName, systemVersion, machine );
504
QString agentStr = defaultUserAgentFromPreferredService();
506
if (agentStr.isEmpty())
510
if( modifiers.contains('o') )
514
if ( modifiers.contains('v') )
517
supp += systemVersion;
521
if( modifiers.contains('p') )
522
supp += QL1S("; X11");
524
if( modifiers.contains('m') )
529
if( modifiers.contains('l') )
532
supp += KGlobal::locale()->language();
536
d->useragent = CFG_DEFAULT_UAGENT(supp);
540
QString appName = QCoreApplication::applicationName();
541
if (appName.isEmpty() || appName.startsWith(QL1S("kcmshell"), Qt::CaseInsensitive))
542
appName = QL1S ("KDE");
544
QString appVersion = QCoreApplication::applicationVersion();
545
if (appVersion.isEmpty())
546
appVersion += (QString::number(KDE::versionMajor()) % QL1C('.') %
547
QString::number(KDE::versionMinor()) % QL1C('.') %
548
QString::number(KDE::versionRelease()));
550
appName += QL1C('/') % appVersion;
552
agentStr.replace(QL1S("%appversion%"), appName, Qt::CaseInsensitive);
554
if (QSslSocket::supportsSsl())
555
agentStr.replace(QL1S("%security%"), QL1S("U"), Qt::CaseInsensitive);
557
agentStr.replace(QL1S("%security%"), QL1S("N"), Qt::CaseInsensitive);
561
if (modifiers.contains('o'))
563
agentStr.replace(QL1S("%osname%"), systemName, Qt::CaseInsensitive);
564
if (modifiers.contains('v'))
565
agentStr.replace(QL1S("%osversion%"), systemVersion, Qt::CaseInsensitive);
567
agentStr.remove(QL1S("%osversion%"), Qt::CaseInsensitive);
571
agentStr.remove(QL1S("%osname%"), Qt::CaseInsensitive);
572
agentStr.remove(QL1S("%osversion%"), Qt::CaseInsensitive);
575
if (modifiers.contains('p'))
576
#if defined(Q_WS_X11)
577
agentStr.replace(QL1S("%platform%"), QL1S("X11"), Qt::CaseInsensitive);
578
#elif defined(Q_WS_MAC)
579
agentStr.replace(QL1S("%platform%"), QL1S("Macintosh"), Qt::CaseInsensitive);
580
#elif defined(Q_WS_WIN)
581
agentStr.replace(QL1S("%platform%"), QL1S("Windows"), Qt::CaseInsensitive);
582
#elif defined (Q_WS_S60)
583
agentStr.replace(QL1S("%platform%"), QL1S("Symbian"), Qt::CaseInsensitive);
586
agentStr.remove(QL1S("%platform%"), Qt::CaseInsensitive);
588
if (modifiers.contains('m'))
589
agentStr.replace(QL1S("%systype%"), machine, Qt::CaseInsensitive);
591
agentStr.remove(QL1S("%systype%"), Qt::CaseInsensitive);
593
if (modifiers.contains('l'))
594
agentStr.replace(QL1S("%language%"), KGlobal::locale()->language(), Qt::CaseInsensitive);
596
agentStr.remove(QL1S("%language%"), Qt::CaseInsensitive);
598
// Clean up unnecessary separators that could be left over from the
599
// possible keyword removal above...
600
agentStr.replace(QRegExp("[(]\\s*[;]\\s*"), QL1S("("));
601
agentStr.replace(QRegExp("[;]\\s*[;]\\s*"), QL1S(";"));
602
agentStr.replace(QRegExp("\\s*[;]\\s*[)]"), QL1S(")"));
606
agentStr.remove(QL1S("%osname%"));
607
agentStr.remove(QL1S("%osversion%"));
608
agentStr.remove(QL1S("%platform%"));
609
agentStr.remove(QL1S("%systype%"));
610
agentStr.remove(QL1S("%language%"));
613
d->useragent = agentStr.simplified();
616
//kDebug() << "USERAGENT STRING:" << d->useragent;
620
QString KProtocolManager::userAgentForApplication( const QString &appName, const QString& appVersion,
621
const QStringList& extraInfo )
623
QString systemName, systemVersion, machine, info;
625
if (getSystemNameVersionAndMachine( systemName, systemVersion, machine ))
629
info += systemVersion;
633
info += QL1S("KDE/");
634
info += QString::number(KDE::versionMajor());
636
info += QString::number(KDE::versionMinor());
638
info += QString::number(KDE::versionRelease());
640
if (!machine.isEmpty())
647
info += extraInfo.join(QL1S("; "));
649
return (appName % QL1C('/') % appVersion % QL1S(" (") % info % QL1C(')'));
652
bool KProtocolManager::getSystemNameVersionAndMachine(
653
QString& systemName, QString& systemVersion, QString& machine )
655
struct utsname unameBuf;
656
if ( 0 != uname( &unameBuf ) )
658
#if defined(Q_WS_WIN) && !defined(_WIN32_WCE)
659
// we do not use unameBuf.sysname information constructed in kdewin32
660
// because we want to get separate name and version
661
systemName = QL1S( "Windows" );
662
OSVERSIONINFOEX versioninfo;
663
ZeroMemory(&versioninfo, sizeof(OSVERSIONINFOEX));
664
// try calling GetVersionEx using the OSVERSIONINFOEX, if that fails, try using the OSVERSIONINFO
665
versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
666
bool ok = GetVersionEx( (OSVERSIONINFO *) &versioninfo );
668
versioninfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
669
ok = GetVersionEx( (OSVERSIONINFO *) &versioninfo );
672
systemVersion = (QString::number(versioninfo.dwMajorVersion) %
673
QL1C('.') % QString::number(versioninfo.dwMinorVersion));
675
systemName = unameBuf.sysname;
676
systemVersion = unameBuf.release;
678
machine = unameBuf.machine;
682
QString KProtocolManager::acceptLanguagesHeader()
684
static const QString &english = KGlobal::staticQString("en");
686
// User's desktop language preference.
687
QStringList languageList = KGlobal::locale()->languageList();
689
// Replace possible "C" in the language list with "en", unless "en" is
690
// already pressent. This is to keep user's priorities in order.
691
// If afterwards "en" is still not present, append it.
692
int idx = languageList.indexOf(QString::fromLatin1("C"));
695
if (languageList.contains(english))
696
languageList.removeAt(idx);
698
languageList[idx] = english;
700
if (!languageList.contains(english))
701
languageList += english;
703
// Some languages may have web codes different from locale codes,
704
// read them from the config and insert in proper order.
705
KConfig acclangConf("accept-languages.codes", KConfig::NoGlobals);
706
KConfigGroup replacementCodes(&acclangConf, "ReplacementCodes");
707
QStringList languageListFinal;
708
Q_FOREACH (const QString &lang, languageList)
710
const QStringList langs = replacementCodes.readEntry(lang, QStringList());
712
languageListFinal += lang;
714
languageListFinal += langs;
717
// The header is composed of comma separated languages, with an optional
718
// associated priority estimate (q=1..0) defaulting to 1.
719
// As our language tags are already sorted by priority, we'll just decrease
723
Q_FOREACH (const QString &lang,languageListFinal) {
726
header += QL1S(";q=0.");
727
header += QString::number(prio);
729
// do not add cosmetic whitespace in here : it is less compatible (#220677)
736
// Some of the languages may have country specifier delimited by
737
// underscore, or modifier delimited by at-sign.
738
// The header should use dashes instead.
739
header.replace('_', '-');
740
header.replace('@', '-');
745
/*==================================== OTHERS ===============================*/
747
bool KProtocolManager::markPartial()
749
return config()->group(QByteArray()).readEntry( "MarkPartial", true );
752
int KProtocolManager::minimumKeepSize()
754
return config()->group(QByteArray()).readEntry( "MinimumKeepSize",
755
DEFAULT_MINIMUM_KEEP_SIZE ); // 5000 byte
758
bool KProtocolManager::autoResume()
760
return config()->group(QByteArray()).readEntry( "AutoResume", false );
763
bool KProtocolManager::persistentConnections()
765
return config()->group(QByteArray()).readEntry( "PersistentConnections", true );
768
bool KProtocolManager::persistentProxyConnection()
770
return config()->group(QByteArray()).readEntry( "PersistentProxyConnection", false );
773
QString KProtocolManager::proxyConfigScript()
775
return config()->group("Proxy Settings").readEntry( "Proxy Config Script" );
778
/* =========================== PROTOCOL CAPABILITIES ============== */
780
static KProtocolInfo::Ptr findProtocol(const KUrl &url)
782
QString protocol = url.protocol();
784
if ( !KProtocolInfo::proxiedBy( protocol ).isEmpty() )
787
protocol = KProtocolManager::slaveProtocol(url, dummy);
790
return KProtocolInfoFactory::self()->findProtocol(protocol);
794
KProtocolInfo::Type KProtocolManager::inputType( const KUrl &url )
796
KProtocolInfo::Ptr prot = findProtocol(url);
798
return KProtocolInfo::T_NONE;
800
return prot->m_inputType;
803
KProtocolInfo::Type KProtocolManager::outputType( const KUrl &url )
805
KProtocolInfo::Ptr prot = findProtocol(url);
807
return KProtocolInfo::T_NONE;
809
return prot->m_outputType;
813
bool KProtocolManager::isSourceProtocol( const KUrl &url )
815
KProtocolInfo::Ptr prot = findProtocol(url);
819
return prot->m_isSourceProtocol;
822
bool KProtocolManager::supportsListing( const KUrl &url )
824
KProtocolInfo::Ptr prot = findProtocol(url);
828
return prot->m_supportsListing;
831
QStringList KProtocolManager::listing( const KUrl &url )
833
KProtocolInfo::Ptr prot = findProtocol(url);
835
return QStringList();
837
return prot->m_listing;
840
bool KProtocolManager::supportsReading( const KUrl &url )
842
KProtocolInfo::Ptr prot = findProtocol(url);
846
return prot->m_supportsReading;
849
bool KProtocolManager::supportsWriting( const KUrl &url )
851
KProtocolInfo::Ptr prot = findProtocol(url);
855
return prot->m_supportsWriting;
858
bool KProtocolManager::supportsMakeDir( const KUrl &url )
860
KProtocolInfo::Ptr prot = findProtocol(url);
864
return prot->m_supportsMakeDir;
867
bool KProtocolManager::supportsDeleting( const KUrl &url )
869
KProtocolInfo::Ptr prot = findProtocol(url);
873
return prot->m_supportsDeleting;
876
bool KProtocolManager::supportsLinking( const KUrl &url )
878
KProtocolInfo::Ptr prot = findProtocol(url);
882
return prot->m_supportsLinking;
885
bool KProtocolManager::supportsMoving( const KUrl &url )
887
KProtocolInfo::Ptr prot = findProtocol(url);
891
return prot->m_supportsMoving;
894
bool KProtocolManager::supportsOpening( const KUrl &url )
896
KProtocolInfo::Ptr prot = findProtocol(url);
900
return prot->m_supportsOpening;
903
bool KProtocolManager::canCopyFromFile( const KUrl &url )
905
KProtocolInfo::Ptr prot = findProtocol(url);
909
return prot->m_canCopyFromFile;
913
bool KProtocolManager::canCopyToFile( const KUrl &url )
915
KProtocolInfo::Ptr prot = findProtocol(url);
919
return prot->m_canCopyToFile;
922
bool KProtocolManager::canRenameFromFile( const KUrl &url )
924
KProtocolInfo::Ptr prot = findProtocol(url);
928
return prot->canRenameFromFile();
932
bool KProtocolManager::canRenameToFile( const KUrl &url )
934
KProtocolInfo::Ptr prot = findProtocol(url);
938
return prot->canRenameToFile();
941
bool KProtocolManager::canDeleteRecursive( const KUrl &url )
943
KProtocolInfo::Ptr prot = findProtocol(url);
947
return prot->canDeleteRecursive();
950
KProtocolInfo::FileNameUsedForCopying KProtocolManager::fileNameUsedForCopying( const KUrl &url )
952
KProtocolInfo::Ptr prot = findProtocol(url);
954
return KProtocolInfo::FromUrl;
956
return prot->fileNameUsedForCopying();
959
QString KProtocolManager::defaultMimetype( const KUrl &url )
961
KProtocolInfo::Ptr prot = findProtocol(url);
965
return prot->m_defaultMimetype;
968
QString KProtocolManager::protocolForArchiveMimetype( const QString& mimeType )
971
if (d->protocolForArchiveMimetypes.isEmpty()) {
972
const KProtocolInfo::List allProtocols = KProtocolInfoFactory::self()->allProtocols();
973
for (KProtocolInfo::List::const_iterator it = allProtocols.begin();
974
it != allProtocols.end(); ++it) {
975
const QStringList archiveMimetypes = (*it)->archiveMimeTypes();
976
Q_FOREACH(const QString& mime, archiveMimetypes) {
977
d->protocolForArchiveMimetypes.insert(mime, (*it)->name());
981
return d->protocolForArchiveMimetypes.value(mimeType);