New class KApplicationTrader, to replace KMimeTypeTrader and KServiceTypeTrader
Needs ReviewPublic

Authored by dfaure on Mon, Dec 2, 9:37 PM.

Details

Summary

The old traders could lookup both applications and plugins, but plugins
should nowadays be loaded via their JSON file, no desktop-file trader
needed anymore.

To get rid of plugins and servicetypes from the API, and keep
only the application-lookup-related code, the older traders will be
deprecated and their users should either switch to JSON for plugins (KPluginLoader)
or KApplicationTrader for application desktop files.

One API question remains:
KApplicationTrader::self()->query("...") like the old traders, or
KApplicationTrader::query("...") (static methods only, or making it a namespace, a bit procedural rather than OO), or
KApplicationTrader().query("...") like QMimeDatabase/QFontDatabase (but with default ctors for performance) ?

Test Plan

New unittest (partly based on kservicetest, but simplified and added new types of checks) passes

Diff Detail

Repository
R309 KService
Branch
kapplicationtrader
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 19413
Build 19431: arc lint + arc unit
dfaure created this revision.Mon, Dec 2, 9:37 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptMon, Dec 2, 9:37 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
dfaure requested review of this revision.Mon, Dec 2, 9:37 PM
dhaumann added inline comments.
src/services/kapplicationtrader.h
34

Typo: you want to _get_...

dfaure updated this revision to Diff 70787.Mon, Dec 2, 9:58 PM

add missing "get" (this bug was in kmimetypetrader.h already, blatant proof of copy/pasting... ;-) )

Works fine for my rather simple KDE Connect use case

+1

Feedback on the API question would be welcome.

Also, see the discovery in T12256. I'm thinking of renaming this class to KServiceTrader and add a queryByServiceType to it.

aacid added a subscriber: aacid.Sat, Dec 7, 10:06 AM

How would i load a "KPart that can open PDF files" then?

Doesn't seem that KPluginLoader has api for that and a Part is not an Application either

dfaure added a comment.Sat, Dec 7, 9:10 PM

Assuming we install all parts under plugins/parts instead of just plugins/ like we currently do, the application should be able to do

KPluginTrader::createInstanceFromQuery<KParts::ReadOnlyPart>("parts", "KParts/ReadOnlyPart", "'application/pdf' in MimeTypes", parent, parentWidget)

This makes me realize however that mimetype inheritance would probably not be supported when doing it this way.
We probably want to add a queryByMimeType to KPluginTrader as well, and a createInstanceFromQuery that takes a mimetype name, like KMimeTypeTrader has (maybe with another name though, too many overloads otherwise).

Would this work for you?

aacid added a comment.Sun, Dec 8, 10:22 PM

Would this work for you?

I guess, i'm not really sure if i understand all you wrote, but i just want to make sure we can do a "generic part loader that opens files" if we want to