auto generate desktop file for url handling
ClosedPublic

Authored by sitter on Aug 16 2017, 10:12 AM.

Details

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/...

Diff Detail

Repository
R134 Discover Software Store
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sitter created this revision.Aug 16 2017, 10:12 AM
Restricted Application added a project: Plasma. · View Herald TranscriptAug 16 2017, 10:12 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
sitter added a subscriber: ltoscano.

@ltoscano is this file name change compatible from an i18n POV?

This revision was automatically updated to reflect the committed changes.
sitter reopened this revision.Aug 16 2017, 12:03 PM

Blergh, reverted. Pushed in wrong terminal.

ltoscano edited edge metadata.Aug 20 2017, 1:44 PM

@ltoscano is this file name change compatible from an i18n POV?

*.desktop.cmake files are processed like .desktop files also elsewhere, so this should work.

leinir accepted this revision.Aug 21 2017, 1:40 PM
leinir added a subscriber: leinir.

Hmm... LGTM - mind that i am not the maintainer here, but it does look like it's likely the needed approach.

This revision is now accepted and ready to land.Aug 21 2017, 1:40 PM
This revision was automatically updated to reflect the committed changes.