Commit graph

68 commits

Author SHA1 Message Date
Albert Vaca Cintora
7010c66c05 Exclude Chrome/Firefox players if Plasma Extension is installed
The extension provides a superset of the features of the browser mpris
2024-05-04 19:41:02 +00:00
Alexander Lohnau
ed1e24d231 kdeconnect_add_plugin: Autogenerate logging category
This is far less code and allows for an easier enforcing of standards, for
example the name of the log identifiers which were adjusted in a few cases.

Also clean up unused includes when noticed.
2023-08-07 19:47:41 +02:00
Alexander Lohnau
405f61bf85 Discard unused params more elegantly
By commenting out the parameter name, we get compile-time checks
Also, we can omit them for slots and Qt will not forward the parameters.

In case we had TODOs next to the code, I kept the Q_UNUSED statements
for now.
2023-08-05 20:22:18 +00:00
Alexander Lohnau
1631ada5b3 Simplify KDEConnectPlugin::recievePacket
- We do not need the return type. If a plugin declares it can handle the
  packet it should do so. We don't have any fallback logic in place and
  the packet types are namespaced with the plugin IDs anyway.

- Provide a default implementation with a warning, not all plugins need
  to overwrite this
2023-08-03 20:49:44 +02:00
Alexander Lohnau
2e67f95017 Add explicit moc includes to cpp files
The rationale is explained in https://planet.kde.org/friedrich-kossebau-2023-06-28-include-also-moc-files-of-headers/

In case of KDEConnect, it impressively speeds up compilation. Before it
took 390 seconds on a clean build and with this change it took 330 seconds.
This is due to the mocs_compilation having to include the header files
and thus all their headers. Due to the lots of small plugins we have,
this means that the same headers must be compiled plenty of times.
When we include the moc files directly in the C++ file, they are already
available.
2023-07-30 07:27:45 +00:00
Albert Vaca Cintora
59adbc2da4 Move all generated dbus interfaces to kdeconnectinterfaces exclude them from clazy
* Moves the XML definitions of DBus interfaces and code generation from the different plugins
  to kdeconnectinterfaces. Before each plugin had their own, some of them duplicated.
* Appends `// clazy:skip` to the generated interface files, so Clazy doesn't emit warnings
  about them because they are missing the NOTIFY/CONSTANT keywords on Q_PROPERTIES.
* Makes kdeconnectinterfaces static on Qt5 as well (removes a difference with Qt6).
* Moves the generated files to a `generated` directory and updates the includes so they are
  easily distinguished from other header files.
2023-07-24 12:18:47 +00:00
Albert Vaca Cintora
2e0550651e Remove mpris "nowPlaying" field
We've had separate title & artist for a while, and all clients should be
using those by now.

Also fixes the position change not being emitted when the song changes,
and fixes the values being written after emitting that they changed.
2023-06-08 21:58:58 +00:00
Albert Vaca Cintora
7866a5f656 Remove my swearing from 10 years ago :D 2023-03-26 14:13:55 +00:00
Fushan Wen
47c6f5b768
plugins/mpris*: "xesam:artist" is of stringlist type
Fix the type in metadata, but still use string type in network packets.
2023-03-25 22:13:31 +08:00
Nicolas Fella
a918ffc0cb Add and make use of ECM's clang-format integration 2022-09-11 23:21:58 +00:00
Weixuan Xiao
f1843cb492 Improve D-Bus implementation on macOS
Better patch to replace !218.

- Auto and quick detection of previous D-Bus instance;
- Remove private D-Bus compile definition, only use it on macOS without an existing D-Bus instance;
- Safe reboot after crashes because the indicator is not relating on the kdeconnectd to run a D-Bus session;
- Safe exit after clicking on `Quit` in the systray.


More details in commit logs:

Only enable private D-Bus on macOS because the other platforms do not
need them.
The app should be able to easily detect the session bus from the env
DBUS_LAUNCHD_SESSION_BUS_SOCKET from launchd through launchctl.
Because https://gitlab.freedesktop.org/dbus/dbus/-/blob/master/dbus/dbus-sysdeps-unix.c#L4392
shows that it is the only probing method on macOS with launchd.

The D-Bus session bus can be easily found from launchd/launchctl
with DBUS_LAUNCHD_SESSION_BUS_SOCKET env. It can be an external one
(installed from HomeBrew) or an internal one (launched by a previous
instance followed by a crash).

The indicator helper on macOS can now automatically detect whether we can use a potentially
(with launchd/launchctl env set, or KDE Connect macOS
private_bus_address set) existed and usable session bus.
If previous bus is usable, just try to launch the kdeconnectd with us.
Otherwise, launch a private D-Bus daemon, export the launchd/launchctl
env, and run a kdeconnectd instance.

Everything works better and quicker now :)
2022-04-12 05:40:03 +00:00
Łukasz Patron
fb8646b309 Expose LoopStatus and Shuffle control over mpris control plugin
This allows us to read and write these to fields from KDE Connect client.
2021-06-21 17:38:05 +00:00
Nicolas Fella
87db95b22f Convert license headers to SPDX expressions 2020-08-17 09:48:10 +00:00
Antonio Larrosa
1d36164230 Use ecm_qt_declare_logging_category to declare the logging categories
This automatizes the generation of logging categories so a
kdeconnect-kde.categories is generated and installed to
/usr/share/qlogging-categories5/ so kdebugsettings can use it.

Also, sets the default logging level to Warning. So now the logs
of users won't be filled with debug messages but they can
modify the configuration easily with kdebugsettings.
2020-05-26 18:55:47 +02:00
Max Rumpf
fbadf09fb5 mpriscontrol plugin should ignore playerctld
playerctld (https://github.com/altdesktop/playerctl/issues/161) is a proxy daemon for the currently active player by playerctl, which facilitates managing mpris players, forwarding requests to the currently active/last active player, and sorting out troubles with selecting the correct player manually.
Unfortunately, it also creates an annoying issue with kdeconnect: when playing media on the phone, kdeconnect publishes the state to the computer through the mprisremote plugin - then, playerctld picks it up as active player, and registers its own mpris media player. As a result, the mpriscontrol plugin sees this as a running media player, and in turn, publishes the state back to the phone, essentially creating another media session on the phone, resulting in two notifications. As playerctld is _always_ only a proxy to another media player (or kdeconnect), it can safely be ignored, just like kdeconnect itself already is. This commit adds an if check doing exactly that.
2020-05-20 21:12:33 +00:00
Albert Vaca Cintora
9feb4e5510 Merge branch 'strace/kdeconnect-kde-seamless_playback' 2020-03-21 00:24:49 +01:00
Matthijs Tijink
f7b7cdbfd5 Adds an MPRIS server for controlling other device's MPRIS services
By creating a DBus connection per player, we are able to support
multiple remote players.

The album art is not yet supported.
2020-03-15 22:38:03 +00:00
Nicolas Fella
f28ea834e1 Use generated DBus interface in mpriscontrol 2020-01-20 17:36:44 +01:00
Soul Trace
1829c89235 Apply suggestion to plugins/mpriscontrol/mpriscontrolplugin.cpp 2020-01-18 17:26:16 +00:00
Soul Trace
d80e48f4c7 Let user open in the PC browser media URL to Android device [2/2]
Let kdeconnect-kde send xesam:url field to renote device in "url" field.
2020-01-18 16:28:05 +03:00
Baptiste Ashka
8aca11e102 Use URL as title and album in MPRIS plugin
Summary:
The current behavior in plasma-workspace's mediacontroller is to get the
title and the album info from the URL contained in the MPRIS metadata,
if it is dealing with a local file and missing title and artist. This
commit aligns the behavior to the one mediacontroller has.

Reviewers: #kde_connect, nicolasfella

Reviewed By: #kde_connect, nicolasfella

Subscribers: nicolasfella, kdeconnect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D26097
2019-12-19 18:11:12 +01:00
Nicolas Fella
0d7c504cf0 Rename DbusHelper => DBusHelper 2019-08-14 17:36:19 +02:00
Nicolas Fella
5c16bfda5d Use K_PLUGIN_CLASS_WITH_JSON 2019-06-12 22:16:54 +02:00
Nicolas Fella
e601755644 Force usage of QStringLiteral and port remaining offenders 2019-06-10 14:40:28 +00:00
Weixuan Xiao
5431073844 Add wrapper for macos dbus connection 2019-06-09 15:28:49 +00:00
Nicolas Fella
3b8fedea1a Replace http GNU urls with https 2019-03-23 17:29:26 +01:00
Matthijs Tijink
33c2a100b1 Support file url album art - Desktop
Summary: If the android code sees a file url, and album art is needed, it will start a request to transfer the album art. This code does some sanity checks to prevent abuse and then transfers the album art.

Test Plan: Art is transferred succesfully.

Reviewers: #kde_connect, nicolasfella, albertvaka

Reviewed By: #kde_connect, albertvaka

Subscribers: nicolasfella, albertvaka

Differential Revision: https://phabricator.kde.org/D11017
2018-03-25 13:45:01 +02:00
Friedrich W. H. Kossebau
8d6236bb7e MPRIS control: fix instance indicator with multiple app instances
Summary:
Not sure what operator+ overload has been used exactly for the int,
in any case it does not work as intended and needs e.g. an explicit
QString::number() invocation.

Also start with number 2 for duplicated instances.

Test Plan:
Start multiple instances of an MPRIS player (e.g. Gwenview). Before the
second instance would get labelled with "Name []", with this patch it is
labelled with "Name [2]".

Reviewers: #kde_connect, mtijink

Reviewed By: #kde_connect, mtijink

Subscribers: mtijink, nicolasfella

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D11411
2018-03-17 23:37:26 +01:00
Friedrich W. H. Kossebau
72fc67ee05 MPRIS control: do not accumulate interface objects
Summary:
If MPRIS players were appearing and disappearing multiple times, the
OrgFreedesktopDBusPropertiesInterface & OrgMprisMediaPlayer2PlayerInterface
instances created for listening to the signals had been accumulating and
thus resulting in X signals per X restarted player, because the instances
were not deleted when a player disappeared.
Additionally were instances of them created on the fly on the stack in
some of the methods, instead of reusing the existing ones.

This patch changes that by introducing a class MprisPlayer which holds all
data & instances per player. This allows to look up the respective
interfaces instances to reuse them as well as properly controlling their
lifetime.

Test Plan:
Starting and restarting multiple MPRIS players (incl. multiple instances of
the same player app) works as expected as befire. They are listed on the
Android Media control as well as have proper states there when selected.
Additionally no longer multiple change signals are emitted if restarting a
player.

Reviewers: #kde_connect, mtijink

Reviewed By: #kde_connect, mtijink

Subscribers: mtijink

Differential Revision: https://phabricator.kde.org/D11389
2018-03-16 23:53:40 +01:00
Albert Vaca
f47f517827 Rename NetworkPackage -> NetworkPacket
Summary: KDE Connect, now with correct naming!

Test Plan: It still builds.

Reviewers: #kde_connect, apol, nicolasfella

Reviewed By: #kde_connect, apol, nicolasfella

Subscribers: nicolasfella

Differential Revision: https://phabricator.kde.org/D11036
2018-03-05 20:03:23 +01:00
Matthijs Tijink
1f6544e55c Add album art to mpris network packets.
Summary: Sends the album art url, so that the android app can display the album art (by fetching it from the internet). Transferring local album art is not supported yet, but can be added in a future diff.

Test Plan: Works for me in players with/without album art and with/without local file album art.

Reviewers: #kde_connect, nicolasfella

Reviewed By: #kde_connect, nicolasfella

Differential Revision: https://phabricator.kde.org/D9563
2018-01-03 20:40:08 +01:00
Matthijs Tijink
71d8eb07c3 Add title, artist and album to MPRIS network packets
Summary: This diff adds the title, artist and album to the MPRIS network packets. That's useful when you need more detail than just "artist - title", for example in the future media control notification. It also fixes weird song descriptions for empty artist strings (e.g. Spotify uses an empty (but present) artist when playing ads)

Reviewers: #kde_connect, apol

Reviewed By: #kde_connect, apol

Subscribers: nicolasfella, apol

Differential Revision: https://phabricator.kde.org/D8957
2017-12-30 12:21:57 +01:00
Jean Vincent
9e0d4874c0 Make sure MPRIS players have a unique name
Summary:
Add a number in brackets to distinguish different players with the same display name so that they can all be controlled.
See this task: https://phabricator.kde.org/T6500

Reviewers: #kde_connect

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D7017
2017-08-02 15:43:08 +02:00
Jean Vincent
c864267f04 Replace Q_FOREACH with C++11 range-for
Summary:
The use of Q_FOREACH is advised against (https://doc.qt.io/qt-5/qtglobal.html#Q_FOREACH) since Qt 5.7 and will eventually be removed from Qt.

I replaced all occurrences with the range-for loop introduced in C++11 (except for the one in daemon.cpp in deviceIdByName which might have a bug / typo in it).

I added const to the container or casted it with qAsConst when appropriate to avoid unnecessary copies.

(This is my first submission. I did all the unit tests, and they all passed but I don't know how to show it here.)

Reviewers: #kde_connect, nicolasfella, apol

Reviewed By: #kde_connect, nicolasfella, apol

Subscribers: albertvaka, apol, nicolasfella

Tags: #kde_connect

Differential Revision: https://phabricator.kde.org/D6724
2017-07-21 09:57:19 +02:00
Albert Vaca
0f643d9c57 Revert "Add album art support for mpris plugin"
This was very poorly implemented and can't stay as it is right now:
 - Every second or so the art image was being loaded from disk, scaled,
   base64 encoded and sent over the freakin network!
 - The Android interface didn't take into account small screens, and
   adding the image would cut stuff out of the screen.
 - Didn't manage "edge cases" like playing a song without cover after one
   with cover (previous image was still being shown) or changing players.

This reverts commit e66096d05a.

# Conflicts:
#	plugins/mpriscontrol/mpriscontrolplugin.cpp
2016-12-08 23:49:59 +01:00
Albert Vaca
60331ccbf1 Clazy says all this QStringLiteral and QLatin1String were missing/wrong 2016-11-26 16:21:29 +01:00
Albert Vaca
a1340c8042 Fixed old style connects with clazy 2016-11-26 15:14:19 +01:00
Saikrishna Arcot
8f4d39424a MPRIS: Send info about whether certain actions are allowed.
So the remote side can then disable some actions as necessary.

REVIEW: 128271
2016-08-26 11:11:07 +02:00
Albert Vaca
308a89f5ea playerList was sometimes sent as null since this change (maybe when empty?)
Reverted to the previous, saner, syntax.
2016-06-26 17:11:08 +02:00
Aleix Pol
f9406e8afc Introduce QVariantMap as an argument of NetworkPackage
Makes it possible to specify the different properties sent at once,
rather than one by one as we used to do.

Also port whenever possible to the initializer-list syntax.

REVIEW: 128269
2016-06-21 20:07:12 +02:00
Pinak Ahuja
e66096d05a Add album art support for mpris plugin
Right now we only support album art if the player provides a local URL,
but some players provide a remote URL (spotify) I'll be adding support
for that in a later patch.

REVIEW: 128199
2016-06-16 10:37:35 +02:00
David Kahles
337dd191e4 Fix mpris player discovery
The previous used QDbusServiceWatcher doesn't work as it does only watch out
for specific services, but the players use different, unpredictable names, so
we need to check all service registrations for mpris players.

BUG: 361367
REVIEW: 127611
2016-04-08 01:22:22 +02:00
Albert Vaca
c1ce7f523c Reordered lines 2015-11-11 11:03:00 -08:00
Albert Vaca
9afb4a587b Reduce the dbus timeout when dealing with mpris players
We probably want to do this in way more places, since the default dbus
timeout is 25 seconds!
2015-11-11 11:02:08 -08:00
Albert Vaca
cbc4cc5fd7 Improvise a name for a player if the mpris interface doesn't provide one 2015-11-11 11:00:59 -08:00
Albert Vaca
bb0b5fcf44 Were connecting to the wrong slot 2015-09-11 03:06:26 -07:00
David Edmundson
d621000621 Watch all serivies with the watcher
media player services are not registered as org.mpris.MediaPlayer2 just
use a service name that starts with that. We need to watch all services
and then filter.

BUG: 352529
Reviewed-by: Albert Vaca
2015-09-11 11:27:35 +02:00
Boris Egorov
1924173df2 Fix various krazy2 warnings
Fix following krazy2 warning types:
[explicit], [endswithnewline], [doublequote_chars], [includes], [normalize],
[postfixop], [spelling]

See http://ebn.kde.org/krazy/reports/playground/base/kdeconnect-kde/index.html
for details.

SLOT/SIGNAL normalization done with Qt normalize utility:
https://github.com/qtproject/qtrepotools/tree/master/util/normalize

REVIEW: 124857
2015-08-21 22:38:54 +06:00
Aleix Pol
5c79e8a7a6 Implement an MPRIS client plugin
Makes it possible to control remote MPRIS instances.

REVIEW: 124100
2015-06-18 04:01:01 +02:00
Aleix Pol
d7e06c5fb2 Fix warning, don't use discouraged API
We used to have the following warning: "Connecting to deprecated signal
QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)"

Port away from it as recommended in Qt documentation.

REVIEW: 123637
2015-05-05 01:40:34 +02:00