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:
Ivailo Monev 2024-05-12 13:11:46 +03:00
parent 06cafdba67
commit 603c4ba5cf

View file

@ -372,6 +372,14 @@ bool KLauncherAdaptor::start_service_by_url(const QString &url, const QStringLis
urlmimetype = kmimetype->name();
}
} 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);
}
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
@ -379,13 +387,6 @@ bool KLauncherAdaptor::start_service_by_url(const QString &url, const QStringLis
KService::Ptr schemeservice = KMimeTypeTrader::self()->preferredService(servicemime);
if (schemeservice) {
urlmimetype = servicemime;
} 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);
}
}
}