From 88d0e72667c58c86142ea747337fdecbae6242d6 Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sat, 28 Apr 2018 00:23:45 +0200 Subject: [PATCH] Request status when connecting Summary: Send requestNowPlaying packet when a player is discovered Depends on D12546 Test Plan: Restart daemon, open app. Status is now displayed correctly, previously it was not until the first update Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: #kde_connect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D12550 --- plugins/mprisremote/mprisremoteplugin.cpp | 9 +++++---- plugins/mprisremote/mprisremoteplugin.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/mprisremote/mprisremoteplugin.cpp b/plugins/mprisremote/mprisremoteplugin.cpp index e877e6600..4abbc7645 100644 --- a/plugins/mprisremote/mprisremoteplugin.cpp +++ b/plugins/mprisremote/mprisremoteplugin.cpp @@ -50,7 +50,7 @@ bool MprisRemotePlugin::receivePacket(const NetworkPacket& np) return false; if (np.has(QStringLiteral("player"))) { - m_players[m_currentPlayer]->parseNetworkPacket(np); + m_players[np.get(QStringLiteral("player"))]->parseNetworkPacket(np); } if (np.has(QStringLiteral("playerList"))) { @@ -59,6 +59,7 @@ bool MprisRemotePlugin::receivePacket(const NetworkPacket& np) m_players.clear(); for (const QString& player : players) { m_players[player] = new MprisRemotePlayer(); + requestPlayerStatus(player); } if (m_players.empty()) { @@ -84,10 +85,10 @@ QString MprisRemotePlugin::dbusPath() const return "/modules/kdeconnect/devices/" + device()->id() + "/mprisremote"; } -void MprisRemotePlugin::requestPlayerStatus() +void MprisRemotePlugin::requestPlayerStatus(const QString& player) { NetworkPacket np(PACKET_TYPE_MPRIS_REQUEST, { - {"player", m_currentPlayer}, + {"player", player}, {"requestNowPlaying", true}, {"requestVolume", true}} ); @@ -141,7 +142,7 @@ void MprisRemotePlugin::setPlayer(const QString& player) { if (m_currentPlayer != player) { m_currentPlayer = player; - requestPlayerStatus(); + requestPlayerStatus(player); Q_EMIT propertiesChanged(); } } diff --git a/plugins/mprisremote/mprisremoteplugin.h b/plugins/mprisremote/mprisremoteplugin.h index 6d83a123e..175f5e8c4 100644 --- a/plugins/mprisremote/mprisremoteplugin.h +++ b/plugins/mprisremote/mprisremoteplugin.h @@ -77,7 +77,7 @@ Q_SIGNALS: void propertiesChanged(); private: - void requestPlayerStatus(); + void requestPlayerStatus(const QString& player); QString m_currentPlayer; QMap m_players;