mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
kinit: use scheme handlers as fallback for remote URLs
the MIME type (if it can be obtained) is more accurate anyway Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
06cafdba67
commit
603c4ba5cf
1 changed files with 14 additions and 13 deletions
|
@ -372,20 +372,21 @@ bool KLauncherAdaptor::start_service_by_url(const QString &url, const QStringLis
|
|||
urlmimetype = kmimetype->name();
|
||||
}
|
||||
} else {
|
||||
// NOTE: scheme handlers are not valid MIME type but are used as such (e.g. in .desktop
|
||||
// files) despite the fact that none of the scheme handlers actually has a entry in the
|
||||
// shared MIME database
|
||||
const QString servicemime = QString::fromLatin1("x-scheme-handler/") + realurl.protocol();
|
||||
KService::Ptr schemeservice = KMimeTypeTrader::self()->preferredService(servicemime);
|
||||
if (schemeservice) {
|
||||
urlmimetype = servicemime;
|
||||
KIO::UDSEntry kioudsentry;
|
||||
if (!KIO::NetAccess::stat(realurl, kioudsentry, findWindow(window))) {
|
||||
kWarning() << "could not stat URL for MIME type" << url;
|
||||
urlmimetype = KProtocolManager::defaultMimetype(realurl);
|
||||
} else {
|
||||
KIO::UDSEntry kioudsentry;
|
||||
if (!KIO::NetAccess::stat(realurl, kioudsentry, findWindow(window))) {
|
||||
kWarning() << "could not stat URL for MIME type" << url;
|
||||
urlmimetype = KProtocolManager::defaultMimetype(realurl);
|
||||
} else {
|
||||
urlmimetype = kioudsentry.stringValue(KIO::UDSEntry::UDS_MIME_TYPE);
|
||||
urlmimetype = kioudsentry.stringValue(KIO::UDSEntry::UDS_MIME_TYPE);
|
||||
}
|
||||
if (urlmimetype.isEmpty()) {
|
||||
// NOTE: scheme handlers are not valid MIME type but are used as such (e.g. in .desktop
|
||||
// files) despite the fact that none of the scheme handlers actually has a entry in the
|
||||
// shared MIME database
|
||||
const QString servicemime = QString::fromLatin1("x-scheme-handler/") + realurl.protocol();
|
||||
KService::Ptr schemeservice = KMimeTypeTrader::self()->preferredService(servicemime);
|
||||
if (schemeservice) {
|
||||
urlmimetype = servicemime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue