Bug 450897 - KWin JS script callDBus invalid signature
Summary: KWin JS script callDBus invalid signature
Status: RESOLVED INTENTIONAL
Alias: None
Product: kwin
Classification: Plasma
Component: scripting (other bugs)
Version First Reported In: 5.24.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-26 23:53 UTC by pendo3247
Modified: 2023-06-21 09:17 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pendo3247 2022-02-26 23:53:58 UTC
SUMMARY
"callDBus" emitting an invalid signature.

STEPS TO REPRODUCE
0. Have KLauncher plus Dolphin (or another testing app installed)
1. Write a KWin JS Script with the following content
> callDBus("org.kde.klauncher5", "/KLauncher", "org.kde.KLauncher", "exec_blind", "dolphin", new Array(), function(e) { print(e); });

2. Execute the script (either through "plasma-interactiveconsole --kwin" or "kpackagetool5" and enabling) 

OBSERVED RESULT
Nothing happens.

EXPECTED RESULT
Assuming dolphin is installed and in path, a Dolphin window should open. This works correctly when invoking via "qdbus":

> qdbus org.kde.klauncher5 /KLauncher org.kde.KLauncher.exec_blind dolphin

SOFTWARE/OS VERSIONS
Linux Kernel Version: 5.16.11-arch1-1
KDE Plasma Version: 5.24.2 
KDE Frameworks Version: 5.91.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION

After following the repro-script and then running the provided `qdbus` command with `dbus-monitor` open, I noticed that the method call looks almost the same for the two scenarios:

working `qdbus` invocation:

> method call time=1645911839.161296 sender=:1.73 -> destination=org.kde.klauncher5 serial=361 path=/KLauncher; interface=org.kde.KLauncher; member=exec_blind
>    string "dolphin"
>    array [
>    ]

not working KWin script / `callDBus` invocation:
method call time=1645911778.904772 sender=:1.11 -> destination=org.kde.klauncher5 serial=1739 
> path=/KLauncher; interface=org.kde.KLauncher; member=exec_blind
>    string "dolphin"
>    array [
>    ]

but the `callDBus` invocation then returns this error, while the working qdbus command just opens a Dolphin window:
> error time=1645911778.904910 sender=:1.6 -> destination=:1.11 
> error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=1739
>    string "No such method 'exec_blind' in interface 'org.kde.KLauncher' at object path '/KLauncher' (signature 'sav')"

This is my first time posting here, sorry if the formatting is bad. Also, sorry if this is in the wrong category. I tried searching for similar issues, but didn't really find any.
Comment 1 David Edmundson 2022-03-14 23:40:33 UTC
If you run:

qdbus org.kde.klauncher5 /KLauncher org.freedesktop.DBus.Introspectable.Introspect

you'll see

    <method name="exec_blind">
      <arg name="name" type="s" direction="in"/>
      <arg name="arg_list" type="as" direction="in"/>
    </method>

It wants  a string then an array of strings
qdbus is a utility tool so provides a conversion from [] to an array of strings  (which happens to be empty)
when writing code, we expect the types to be set.  Your empty array by default is an array of values ("av" not "as" in the signature) despite being empty it's denied by the receiving app where it compares signatures.

----

As for a fix, klauncher is outdated anyway. If you really want to spawn dolphin use the filemanager1 interface, it's got far more control.
Comment 2 imraro 2023-01-25 12:06:54 UTC
This already has been fixed for 4.10 (https://bugs.kde.org/show_bug.cgi?id=311896) the fix was lost in the migration process.

----
@David Edmundson what is your advice for running applications other than Explorer over the dbus?
Comment 3 David Edmundson 2023-06-21 09:17:54 UTC
>This already has been fixed for 4.10 (https://bugs.kde.org/show_bug.cgi?id=311896) the fix was lost in the migration process.

That's not true.  What was fixed was sending an array at all, we're seeing that happen.

I suspect  if you run `new Array("someArg")` or maybe an empty string it'll work fine with the fix there.

In any case, writing good QML bindings for DBus are out of scope for Kwin. Ideally we need to import something more generic from somewhere else. 

An alternative for you with the QML scripting is to import the plasmacore dataengines for executing arbitrary processes