Bug 358159 - ktraderclient5 returns the wrong order for x-scheme-handler/magnet
Summary: ktraderclient5 returns the wrong order for x-scheme-handler/magnet
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kservice
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: David Faure
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-18 11:11 UTC by Mathias Tillman
Modified: 2016-03-07 14:39 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mathias Tillman 2016-01-18 11:11:36 UTC
I've noticed that magnet links are always opened in ktorrent, when I want them to open in qBittorrent. I have x-scheme-handler/magnet=qBittorrent.desktop set under Default Applications in mimeapps.list, and yet they still open in ktorrent.
I did some digging and found that xdg-open uses ktraderclient5 (when using kde frameworks 5) to find what program it should open, and calling
ktraderclient5 --mimetype x-scheme-handler/magnet --servicetype Application
does indeed return the wrong order, with ktorrent being offer 0 and qbittorrent being offer 1.
I tried calling ktraderclient (the kde 4 version), and that returns the correct order.

If I run
xdg-mime default qBittorrent.desktop x-scheme-handler/magnet
it works for a little while, but then seems to reset itself. I'm not sure why or how.

Reproducible: Always

Steps to Reproduce:
1. Try to open a magnet link using xdg-open
2.
3.

Actual Results:  
ktorrent opens even though I have qBittorrent set as the default.

Expected Results:  
qBittorrent should open.

Running Kubuntu 15.10 with kde framework 5.15.0 and plasma 5.4.3.
Comment 1 Ed Greshko 2016-02-17 05:28:56 UTC
I believe this is try in all cases that the xdg-mime default command is having no effect on the order.  I am having the same problem with 

xdg-mime default mozilla-thunderbird.desktop 'x-scheme-handler/mailto'

No matter what KMail2.desktop is always returned.
Comment 2 Dmitry Nezhevenko 2016-03-02 09:00:48 UTC
It looks like ktraderclient5 completely ignores ~/.local/share/applications/mimeapps.list.
That's actually why configuring preferred email client via systemsettings5 is ignored by xdg-open.

dion@debpad:~% export XDG_UTILS_DEBUG_LEVEL=2 
dion@debpad:~% xdg-mime query default "x-scheme-handler/mailto"
Running KDE trader query "x-scheme-handler/mailto" mimetype and "Application" servicetype
org.kde.kmail.desktop

dion@debpad:~% xdg-mime default mutt_terminal.desktop x-scheme-handler/mailto                        
make_default_kde: No kde runtime detected
make_default_generic mutt_terminal.desktop x-scheme-handler/mailto
Updating /home/dion/.local/share/applications/mimeapps.list

dion@debpad:~% xdg-mime query default "x-scheme-handler/mailto"              
Running KDE trader query "x-scheme-handler/mailto" mimetype and "Application" servicetype
org.kde.kmail.desktop

And now let's lie to xdg-mime that we don't have KDE:

dion@debpad:~% KDE_SESSION_VERSION= xdg-mime query default "x-scheme-handler/mailto"
Checking /home/dion/.local/share/applications/mimeapps.list
mutt_terminal.desktop
Comment 3 David Faure 2016-03-06 18:28:44 UTC
Dmitry: thanks for the precise steps. Perfect bug report. Fix coming up.
Comment 4 David Faure 2016-03-06 18:36:11 UTC
Git commit c9edc4769d278f174d821cf6d9364fbca356b676 by David Faure.
Committed on 06/03/2016 at 18:35.
Pushed by dfaure into branch 'master'.

Fix handling of x-scheme-handler/* in mimeapps.list parsing.

Since this isn't a known mimetype, such lines were being ignored.
FIXED-IN: 5.21

M  +1    -1    autotests/CMakeLists.txt
M  +3    -0    autotests/kmimeassociationstest.cpp
M  +4    -3    src/sycoca/kmimeassociations.cpp
M  +1    -1    tests/CMakeLists.txt

http://commits.kde.org/kservice/c9edc4769d278f174d821cf6d9364fbca356b676
Comment 5 Ed Greshko 2016-03-07 14:39:53 UTC
The folks at fedora have pulled and built the new package and I've verified the fix.  Thanks.