linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 09/13] player: Add implementation of MediaFolder.ChangeFolder
Date: Tue, 28 May 2013 15:51:27 +0300	[thread overview]
Message-ID: <1369745491-23897-10-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1369745491-23897-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 profiles/audio/player.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index deae112..371487c 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -856,7 +856,42 @@ static struct media_folder *media_player_find_folder(struct media_player *mp,
 static DBusMessage *media_folder_change_folder(DBusConnection *conn,
 						DBusMessage *msg, void *data)
 {
-	return btd_error_failed(msg, strerror(ENOTSUP));
+	struct media_player *mp = data;
+	struct media_folder *folder = mp->scope;
+	struct player_callback *cb = mp->cb;
+	const char *path;
+	int err;
+
+	if (!dbus_message_get_args(msg, NULL,
+					DBUS_TYPE_OBJECT_PATH, &path,
+					DBUS_TYPE_INVALID))
+		return btd_error_failed(msg, strerror(EINVAL));
+
+	if (folder->msg != NULL)
+		return btd_error_failed(msg, strerror(EINVAL));
+
+	folder = media_player_find_folder(mp, path);
+	if (folder == NULL)
+		return btd_error_failed(msg, strerror(EINVAL));
+
+	if (mp->scope == folder)
+		goto done;
+
+	if (folder == mp->playlist || folder == mp->folder) {
+		media_player_change_scope(mp, folder);
+		goto done;
+	}
+
+	if (cb->cbs->change_folder == NULL)
+		return btd_error_failed(msg, strerror(ENOTSUP));
+
+	err = cb->cbs->change_folder(mp, folder->item->name, folder->item->uid,
+								cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+done:
+	return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
 }
 
 static gboolean folder_name_exists(const GDBusPropertyTable *property,
-- 
1.8.1.4


  parent reply	other threads:[~2013-05-28 12:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-28 12:51 [PATCH BlueZ v2 00/13] MediaFolder and MediaItem implementation Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 01/13] player: Split item creation Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 02/13] AVRCP: Add browsed flag to player Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 03/13] AVRCP: Add support for GetFolderItems command Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 04/13] player: Add implementation of MediaFolder.ListItems Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 05/13] player: Add support for setting current Item object Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 06/13] player: Add function media_item_set_playable Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 07/13] player: Add support for MediaItem.Metadata property Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 08/13] AVRCP: Add support for ChangePath command Luiz Augusto von Dentz
2013-05-28 12:51 ` Luiz Augusto von Dentz [this message]
2013-05-28 12:51 ` [PATCH BlueZ v2 10/13] AVRCP: Add support for PlayItem command Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 11/13] player: Add implementation of MediaItem.Play Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 12/13] AVRCP: Add support for AddToNowPlaying command Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 13/13] player: Add implementation of MediaItem.AddToNowPlaying 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=1369745491-23897-10-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).