From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 07/14] tools: Add support for MPRIS Playlists interface to mpris-player
Date: Wed, 15 May 2013 18:31:39 +0300 [thread overview]
Message-ID: <1368631906-15951-7-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1368631906-15951-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support for Playlists interface as defined in MPRIS:
http://specifications.freedesktop.org/mpris-spec/latest/Playlists_Interface.html
---
tools/mpris-player.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 99 insertions(+), 1 deletion(-)
diff --git a/tools/mpris-player.c b/tools/mpris-player.c
index 681bb09..9ac59b3 100644
--- a/tools/mpris-player.c
+++ b/tools/mpris-player.c
@@ -50,6 +50,7 @@
#define MPRIS_INTERFACE "org.mpris.MediaPlayer2"
#define MPRIS_PLAYER_INTERFACE "org.mpris.MediaPlayer2.Player"
#define MPRIS_TRACKLIST_INTERFACE "org.mpris.MediaPlayer2.TrackList"
+#define MPRIS_PLAYLISTS_INTERFACE "org.mpris.MediaPlayer2.Playlists"
#define MPRIS_PLAYER_PATH "/org/mpris/MediaPlayer2"
#define ERROR_INTERFACE "org.mpris.MediaPlayer2.Error"
@@ -1729,6 +1730,89 @@ static const GDBusPropertyTable tracklist_properties[] = {
{ }
};
+static DBusMessage *playlist_activate(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotImplemented",
+ "Not implemented");
+}
+
+static DBusMessage *playlist_get(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotImplemented",
+ "Not implemented");
+}
+
+static const GDBusMethodTable playlist_methods[] = {
+ { GDBUS_METHOD("ActivatePlaylist",
+ GDBUS_ARGS({ "playlist", "o" }), NULL,
+ playlist_activate) },
+ { GDBUS_METHOD("GetPlaylists",
+ GDBUS_ARGS({ "index", "u" }, { "maxcount", "u"},
+ { "order", "s" }, { "reverse", "b" }),
+ GDBUS_ARGS({ "playlists", "a(oss)"}),
+ playlist_get) },
+ { },
+};
+
+static gboolean get_playlist_count(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ uint32_t count = 1;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &count);
+
+ return TRUE;
+}
+
+static gboolean get_orderings(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ DBusMessageIter value;
+ const char *order = "User";
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_OBJECT_PATH_AS_STRING,
+ &value);
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &order);
+ dbus_message_iter_close_container(iter, &value);
+
+ return TRUE;
+}
+
+static gboolean get_active_playlist(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct player *player = data;
+ struct tracklist *tracklist = player->tracklist;
+ DBusMessageIter value, entry;
+ dbus_bool_t enabled = TRUE;
+ const char *empty = "";
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT,
+ NULL, &value);
+ dbus_message_iter_append_basic(&value, DBUS_TYPE_BOOLEAN, &enabled);
+ dbus_message_iter_open_container(&value, DBUS_TYPE_STRUCT, NULL,
+ &entry);
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH,
+ &tracklist->playlist);
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
+ &tracklist->playlist);
+ dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &empty);
+ dbus_message_iter_close_container(&value, &entry);
+ dbus_message_iter_close_container(iter, &value);
+
+ return TRUE;
+}
+
+static const GDBusPropertyTable playlist_properties[] = {
+ { "PlaylistCount", "u", get_playlist_count, NULL, NULL },
+ { "Orderings", "as", get_orderings, NULL, NULL },
+ { "ActivePlaylist", "(b(oss))", get_active_playlist, NULL, NULL },
+ { }
+};
+
#define a_z "abcdefghijklmnopqrstuvwxyz"
#define A_Z "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define _0_9 "_0123456789"
@@ -1831,6 +1915,16 @@ static void register_tracklist(struct player *player, const char *playlist)
return;
}
+ if (!g_dbus_register_interface(player->conn, MPRIS_PLAYER_PATH,
+ MPRIS_PLAYLISTS_INTERFACE,
+ playlist_methods,
+ NULL,
+ playlist_properties,
+ player, NULL)) {
+ fprintf(stderr, "Could not register interface %s",
+ MPRIS_PLAYLISTS_INTERFACE);
+ }
+
player->tracklist = tracklist;
g_dbus_proxy_method_call(proxy, "ChangeFolder", change_folder_setup,
@@ -2075,8 +2169,12 @@ static void unregister_player(struct player *player)
{
players = g_slist_remove(players, player);
- g_dbus_unregister_interface(player->conn, MPRIS_PLAYER_PATH,
+ if (player->tracklist != NULL) {
+ g_dbus_unregister_interface(player->conn, MPRIS_PLAYER_PATH,
+ MPRIS_PLAYLISTS_INTERFACE);
+ g_dbus_unregister_interface(player->conn, MPRIS_PLAYER_PATH,
MPRIS_TRACKLIST_INTERFACE);
+ }
g_dbus_unregister_interface(player->conn, MPRIS_PLAYER_PATH,
MPRIS_INTERFACE);
--
1.8.1.4
next prev parent reply other threads:[~2013-05-15 15:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-15 15:31 [PATCH BlueZ 01/14] tools: Add support for MPRIS TrackList interface to mpris-player Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 02/14] tools: Add implementation of TrackList.GetTracksMetadata " Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 03/14] tools: Add implementation of TrackList.GoTo " Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 04/14] tools: Add support for MPRIS TrackList.TrackAdded signal " Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 05/14] tools: Add support for MPRIS TrackList.TrackRemoved " Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 06/14] tools: Add support for MPRIS TrackList.TrackMetadataChanged " Luiz Augusto von Dentz
2013-05-15 15:31 ` Luiz Augusto von Dentz [this message]
2013-05-15 15:31 ` [PATCH BlueZ 08/14] tools: Add implementation of Playlists.ActivatePlaylist " Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 09/14] tools: Add implementation of Playlists.GetPlaylists " Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 10/14] tools: Map mpris:trackid to Item in mpris-player Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 11/14] tools: Always register Playlists and TrackList " Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 12/14] tools: Wait MediaFolder interface appear to enable " Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 13/14] tools: Use playlist proxy instead of object path " Luiz Augusto von Dentz
2013-05-15 15:31 ` [PATCH BlueZ 14/14] tools: Emit changes to HasTrackList " Luiz Augusto von Dentz
2013-05-17 6:46 ` [PATCH BlueZ 01/14] tools: Add support for MPRIS TrackList interface to mpris-player Luiz Augusto von Dentz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1368631906-15951-7-git-send-email-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).