SUMMARY The dbus interface definition for krunner plugins as found in org.kde.krunner1.xml list the return type for Match as a(sssuda{sv}). However this seems to incorrect. When writing a dbus plugin I had the return a(sssida{sv}) instead for krunner to accept my matches. STEPS TO REPRODUCE I'm a bit of noob to dbus and krunner so I'm not sure exactly how this stuff is supposed to work, I just know what I've observed. The return type I tell dbus I'm returning doesn't seems to matter (between u and i) but the actual type I return (i32 vs u32) does seem to matter.
When looking the the docs it says "Unsigned 32-bit integer" for the "u" type. https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-types Can you please provide more context how you are writing the plugin? I mean language or lib and maybe a project link/sample. Thanks!
Yes. I'm writing my plugin in Rust using the dbus Rust library. Originally when I was writing my code I use returning a 32-bit unsigned int and knrunner wouldn't show my matches. I then noticed that the python example template I was using for reference that did work was specifying "i" instead of "u" so I switch to returning a 32-bit signed int in my code and krunner started displaying my matches. python example: https://github.com/alex1701c/KDevelopTemplates/blob/master/krunner_dbus_templates/simple_krunner_python_template/%25%7BAPPNAMELC%7D.py my code: https://git.sr.ht/~zethra/poki-launcher/tree/master/item/poki-krunner/src/main.rs#L99 If needed I can explain my code further. It's auto generating most of the dbus code based on the xml spec file.
Ah okay, that helps us further. Actually the the DBus definitions used in the plugin seems wrong, please change the "i" to "u". I will adjust the templates :)
> Actually the the DBus definitions used in the plugin seems wrong, please > change the "i" to "u". But when I return a 32-bit unsigned int to krunner from my plugin it doesn't display my matches, but it does when I return a 32-bit signed int. Why is that? If it is in fact supposed to an unsigned int why does knrunner not seem to like that?
I'm not a cpp dev but looking at the code for krunner it appears that the value in question is a Plasma::QueryMatch::Type which is a cpp enum. I believe cpp enums are represented as "int"s with are 32-bit signed integers. So cpp is expecting an signed int, not an unsigned it. Now, all of the valid values of Plasma::QueryMatch::Type are less than 128 so I don't know why it would matter.
Where do you have the XML file from? Could you please try it with a copy from master: https://invent.kde.org/frameworks/krunner/-/blob/master/src/data/org.kde.krunner1.xml
(In reply to Alexander Lohnau from comment #6) > Where do you have the XML file from? > > Could you please try it with a copy from master: > https://invent.kde.org/frameworks/krunner/-/blob/master/src/data/org.kde. > krunner1.xml That is where I got the XML file from. I modified the version in my project to make the return type of Match what I specified previously. Without the modification, krunner didn't display my matches.
I have build your project locally and had changed the type to "u", then I looked at the KRunner output: kf.runner: Error requesting matches; calling "dev.benaaron.poki-krunner" : "org.freedesktop.DBus.Error.InvalidSignature" "Unexpected reply signature: got \"a(sssuda{sv})\", expected \"a(sssida{sv})\"" In the krunner dbusutils.h file I found: uint type; argument >> type; match.type = static_cast<Plasma::QueryMatch::Type>(type); I also found https://github.com/shochdoerfer/krunner-gitlab/blob/master/krunner.go#L28, there the type is int32. @davidedmundson Do you have any idea?
We need to go into how qDBusRegisterMetaType works It constructs a default RemoteMatch Then it runs it through the marshaller and from that it generates a string signature which it uses for future comparisons. @alex, your snippet is from the demarshaller. When we do that, our type is an enum, which apparently gets treated as an int. DBus messages send the signature on every message for extra validation which is why we hit this issue, even though our demarshaller is assuming a uint and would therefore handle both. The problem we have is anything C++ based that has copied our src/dbus will also be generating the signature this same way. Frankly our best bet will be to change our XML file to match what the current code does and change our demarshalling to match.
I might have a solution that means we could cover both types of signatures if we really think it's necessary.
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/krunner/-/merge_requests/64
Git commit 39e1f2e013be8ba09b07ae813a6d429a1bb388bb by Alexander Lohnau. Committed on 19/04/2021 at 10:33. Pushed by alex into branch 'master'. dbus runner: Fix interface definition qDBusRegisterMetaType registered an int for the type at runtime, but the definitions expect an uint. If one generates code from this XML file the runner's results will not be shown, because the DBus definitions do not match. FIXED-IN: 5.82 M +1 -1 src/data/org.kde.krunner1.xml M +1 -1 src/dbusutils_p.h https://invent.kde.org/frameworks/krunner/commit/39e1f2e013be8ba09b07ae813a6d429a1bb388bb