Skip to content
Commit b433b503 authored by Harald Sitter's avatar Harald Sitter 🐧
Browse files

auto generate desktop file for url handling

Summary:
configure_file on the desktop file to generate a NoDisplay variant to
handle URLs (currently appstream: only) and have the standard desktop file
only accept files.

Discover can accept local files corresponding to a package format mimetype
(e.g. rpm or deb) but these files must be strictly local as discover has
no provisioning for downloading them on the file. To make this work
we'll need an Exec line containing %F which makes kio download a remote
URL to a local file before then passing it to discover. Namely clicking
on a http://foo.bar/x.deb in a browser will cause kio to download the file
and then start discover with the locally downloaded version.

Conversely, discover also implements a scheme handler for appstream: which
isn't itself a protocol implemented by KIO but instead acts as lookup
URI. These URLS cannot be downloaded but instead must be passed verbatim
to discover for handling, to have this working we need %U rather than %F.
End result being that clicking appstream://org.kde.krita.desktop in a
browser will immediately start discover displaying the krita page.

To support both methods we need two separate desktop files, one to handle
the package formats with %F and another handling appstream: with %U.
We are now calling configure_file on a generic desktop file template to
adjust it for these two use cases. The main org.kde.discover.desktop is
visible in menus and can only handle local files. The new
org.kde.discover.urlhandler.desktop is not visible in menus but used when
KIO encounters an appstream url which it won't know what to do with.

Test Plan:
- try opening a http url pointing to a deb (probably needs to have mimetype deb in the http header fields)
- should make plasma show a download arrow thingy

- try opening appstream://org.kde.krita.desktop
- should open discover right away and point it to the krita page

- download old discord and install on neon https://dl.discordapp.net/apps/linux/0.0.1/discord-0.0.1.deb
- open discord
- should notify of new version and recommend to download the deb
- click download
- discord closes and plasma shows a download notification
- discover starts with page for downloaded deb in ~/.cache/...

Reviewers: apol

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7343
parent 37cfd9b5
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment