linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH  0/3] Add Support for GetTotalNumOfItems
@ 2015-06-24  9:11 Bharat Panda
  2015-06-24  9:11 ` [PATCH 1/3] audio/avrcp: Add AVRCP GetTotalNumOfItems support Bharat Panda
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Bharat Panda @ 2015-06-24  9:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cpgs, Bharat Panda

Support added for AVRCP GetTotalNumOfItems browsing command.

It is used to retrieve the number of items in a folder prior to
calling GetFolderItems to retrieve a listing of the contents of a
folder. The purpose of the command is to provide both scaling
information, and total item count for devices that may not be
able to store or display an entire folder content listing.

Bharat Panda (3):
  audio/avrcp: Add AVRCP GetTotalNumOfItems support
  audio/player: Add TotalNumberOfItems DBUS method
  tools: Add total-items command for GetTotalNumOfItems

 profiles/audio/avrcp.c   | 77 ++++++++++++++++++++++++++++++++++++++++++++++++
 profiles/audio/player.c  | 53 +++++++++++++++++++++++++++++++++
 profiles/audio/player.h  |  4 +++
 tools/bluetooth-player.c | 40 +++++++++++++++++++++++++
 4 files changed, 174 insertions(+)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH  1/3] audio/avrcp: Add AVRCP GetTotalNumOfItems support
  2015-06-24  9:11 [PATCH 0/3] Add Support for GetTotalNumOfItems Bharat Panda
@ 2015-06-24  9:11 ` Bharat Panda
  2015-07-02  8:13   ` Luiz Augusto von Dentz
  2015-06-24  9:11 ` [PATCH 2/3] audio/player: Add TotalNumberOfItems DBUS method Bharat Panda
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Bharat Panda @ 2015-06-24  9:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cpgs, Bharat Panda

Added support for AVRCP GetTotalNumOfItems browsing command
to retrieve the number of items in a folder(with given scope)
prior to calling GetFolderItems to retrieve a listing of the
contents of the folder.
---
 profiles/audio/avrcp.c  | 77 +++++++++++++++++++++++++++++++++++++++++++++++++
 profiles/audio/player.c | 25 ++++++++++++++++
 profiles/audio/player.h |  4 +++
 3 files changed, 106 insertions(+)

diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 60f8cbf..ebb3af9 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -108,6 +108,7 @@
 #define AVRCP_CHANGE_PATH		0x72
 #define AVRCP_GET_ITEM_ATTRIBUTES	0x73
 #define AVRCP_PLAY_ITEM			0x74
+#define AVRCP_GET_TOTAL_NUMBER_OF_ITEMS	0x75
 #define AVRCP_SEARCH			0x80
 #define AVRCP_ADD_TO_NOW_PLAYING	0x90
 #define AVRCP_GENERAL_REJECT		0xA0
@@ -2821,6 +2822,81 @@ static int ct_add_to_nowplaying(struct media_player *mp, const char *name,
 	return 0;
 }
 
+static gboolean avrcp_get_total_numberofitems_rsp(struct avctp *conn,
+					uint8_t *operands, size_t operand_count,
+					void *user_data)
+{
+	struct avrcp_browsing_header *pdu = (void *) operands;
+	struct avrcp *session = user_data;
+	struct avrcp_player *player = session->controller->player;
+	struct media_player *mp = player->user_data;
+	int ret = 0;
+
+	if (pdu == NULL) {
+		ret = -ETIMEDOUT;
+		goto done;
+	}
+
+	if (pdu->params[0] != AVRCP_STATUS_SUCCESS || operand_count < 7) {
+		ret = -EINVAL;
+		goto done;
+	}
+
+	if (pdu->params[0] == AVRCP_STATUS_OUT_OF_BOUNDS)
+		goto done;
+
+	player->uid_counter = get_be16(&pdu->params[1]);
+	ret = get_be32(&pdu->params[3]);
+
+done:
+	media_player_get_number_of_items_complete(mp, ret);
+
+	return FALSE;
+}
+
+static void avrcp_get_total_numberofitems(struct avrcp *session)
+{
+	uint8_t buf[AVRCP_BROWSING_HEADER_LENGTH + 7];
+	struct avrcp_player *player = session->controller->player;
+	struct avrcp_browsing_header *pdu = (void *) buf;
+	uint16_t length = AVRCP_BROWSING_HEADER_LENGTH + 7;
+
+	memset(buf, 0, sizeof(buf));
+
+	pdu->pdu_id = AVRCP_GET_TOTAL_NUMBER_OF_ITEMS;
+	pdu->param_len = htons(7 + sizeof(uint32_t));
+
+	pdu->params[0] = player->scope;
+
+	length += sizeof(uint32_t);
+
+	avctp_send_browsing_req(session->conn, buf, length,
+				avrcp_get_total_numberofitems_rsp, session);
+}
+
+static int ct_get_total_numberofitems(struct media_player *mp, const char *name,
+						void *user_data)
+{
+	struct avrcp_player *player = user_data;
+	struct avrcp *session;
+
+	if (player->p != NULL)
+		return -EBUSY;
+
+	session = player->sessions->data;
+
+	if (g_str_has_prefix(name, "/NowPlaying"))
+		player->scope = 0x03;
+	else if (g_str_has_suffix(name, "/search"))
+		player->scope = 0x02;
+	else
+		player->scope = 0x01;
+
+	avrcp_get_total_numberofitems(session);
+
+	return 0;
+}
+
 static const struct media_player_callback ct_cbs = {
 	.set_setting	= ct_set_setting,
 	.play		= ct_play,
@@ -2835,6 +2911,7 @@ static const struct media_player_callback ct_cbs = {
 	.search		= ct_search,
 	.play_item	= ct_play_item,
 	.add_to_nowplaying = ct_add_to_nowplaying,
+	.total_items = ct_get_total_numberofitems,
 };
 
 static struct avrcp_player *create_ct_player(struct avrcp *session,
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 94eb2eb..b7f7b60 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -702,6 +702,31 @@ done:
 	folder->msg = NULL;
 }
 
+void media_player_get_number_of_items_complete(struct media_player *mp, int ret)
+{
+	struct media_folder *folder = mp->scope;
+	DBusMessage *reply;
+
+	if (folder == NULL || folder->msg == NULL)
+		return;
+
+	if (ret < 0) {
+		reply = btd_error_failed(folder->msg, strerror(-ret));
+		goto done;
+	}
+
+	folder->number_of_items = ret;
+
+	reply = g_dbus_create_reply(folder->msg,
+				DBUS_TYPE_INT32, &folder->number_of_items,
+				DBUS_TYPE_INVALID);
+
+done:
+	g_dbus_send_message(btd_get_dbus_connection(), reply);
+	dbus_message_unref(folder->msg);
+	folder->msg = NULL;
+}
+
 static const GDBusMethodTable media_player_methods[] = {
 	{ GDBUS_METHOD("Play", NULL, NULL, media_player_play) },
 	{ GDBUS_METHOD("Pause", NULL, NULL, media_player_pause) },
diff --git a/profiles/audio/player.h b/profiles/audio/player.h
index ac2a3da..bc9fa57 100644
--- a/profiles/audio/player.h
+++ b/profiles/audio/player.h
@@ -64,6 +64,8 @@ struct media_player_callback {
 					uint64_t uid, void *user_data);
 	int (*add_to_nowplaying) (struct media_player *mp, const char *name,
 					uint64_t uid, void *user_data);
+	int (*total_items) (struct media_player *mp, const char *name,
+						void *user_data);
 };
 
 struct media_player *media_player_controller_create(const char *path,
@@ -104,6 +106,8 @@ void media_player_list_complete(struct media_player *mp, GSList *items,
 void media_player_change_folder_complete(struct media_player *player,
 						const char *path, int ret);
 void media_player_search_complete(struct media_player *mp, int ret);
+void media_player_get_number_of_items_complete(struct media_player *mp,
+						int ret);
 
 void media_player_set_callbacks(struct media_player *mp,
 				const struct media_player_callback *cbs,
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH  2/3] audio/player: Add TotalNumberOfItems DBUS method
  2015-06-24  9:11 [PATCH 0/3] Add Support for GetTotalNumOfItems Bharat Panda
  2015-06-24  9:11 ` [PATCH 1/3] audio/avrcp: Add AVRCP GetTotalNumOfItems support Bharat Panda
@ 2015-06-24  9:11 ` Bharat Panda
  2015-07-02  8:17   ` Luiz Augusto von Dentz
  2015-06-24  9:11 ` [PATCH 3/3] tools: Add total-items command for GetTotalNumOfItems Bharat Panda
  2015-07-01  5:27 ` [PATCH 0/3] Add Support " Bharat Bhusan Panda
  3 siblings, 1 reply; 8+ messages in thread
From: Bharat Panda @ 2015-06-24  9:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cpgs, Bharat Panda

Adds support for TotalNumberOfItems DBUS method on
org.bluez.MediaFolder1 interface.
---
 profiles/audio/player.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index b7f7b60..c8e10e1 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -877,6 +877,30 @@ static DBusMessage *media_folder_list_items(DBusConnection *conn,
 	return NULL;
 }
 
+static DBusMessage *media_folder_total_items(DBusConnection *conn,
+						DBusMessage *msg, void *data)
+{
+	struct media_player *mp = data;
+	struct media_folder *folder = mp->scope;
+	struct player_callback *cb = mp->cb;
+	int err;
+
+	if (cb->cbs->list_items == NULL)
+		return btd_error_not_supported(msg);
+
+	if (folder->msg != NULL)
+		return btd_error_failed(msg, strerror(EBUSY));
+
+	err = cb->cbs->total_items(mp, folder->item->name,
+							cb->user_data);
+	if (err < 0)
+		return btd_error_failed(msg, strerror(-err));
+
+	folder->msg = dbus_message_ref(msg);
+
+	return NULL;
+}
+
 static void media_item_free(struct media_item *item)
 {
 	if (item->metadata != NULL)
@@ -1091,6 +1115,10 @@ static const GDBusMethodTable media_folder_methods[] = {
 			GDBUS_ARGS({ "filter", "a{sv}" }),
 			GDBUS_ARGS({ "items", "a{oa{sv}}" }),
 			media_folder_list_items) },
+	{ GDBUS_ASYNC_METHOD("TotalNumberOfItems",
+			NULL,
+			GDBUS_ARGS({ "totalitems", "u" }),
+			media_folder_total_items) },
 	{ GDBUS_ASYNC_METHOD("ChangeFolder",
 			GDBUS_ARGS({ "folder", "o" }), NULL,
 			media_folder_change_folder) },
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH  3/3] tools: Add total-items command for GetTotalNumOfItems
  2015-06-24  9:11 [PATCH 0/3] Add Support for GetTotalNumOfItems Bharat Panda
  2015-06-24  9:11 ` [PATCH 1/3] audio/avrcp: Add AVRCP GetTotalNumOfItems support Bharat Panda
  2015-06-24  9:11 ` [PATCH 2/3] audio/player: Add TotalNumberOfItems DBUS method Bharat Panda
@ 2015-06-24  9:11 ` Bharat Panda
  2015-07-02  8:19   ` Luiz Augusto von Dentz
  2015-07-01  5:27 ` [PATCH 0/3] Add Support " Bharat Bhusan Panda
  3 siblings, 1 reply; 8+ messages in thread
From: Bharat Panda @ 2015-06-24  9:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cpgs, Bharat Panda

Added command "total-items" to send request for
"GetTotalNumOfItems".
---
 tools/bluetooth-player.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c
index 9e19997..66303a7 100644
--- a/tools/bluetooth-player.c
+++ b/tools/bluetooth-player.c
@@ -891,6 +891,44 @@ done:
 	rl_printf("Attempting to list items\n");
 }
 
+static void total_items_reply(DBusMessage *message, void *user_data)
+{
+	DBusError error;
+
+	dbus_error_init(&error);
+
+	if (dbus_set_error_from_message(&error, message) == TRUE) {
+		rl_printf("Failed to get total number of items: %s\n",
+					error.name);
+		dbus_error_free(&error);
+		return;
+	}
+
+	rl_printf("TotalItems successful\n");
+}
+
+static void cmd_total_items(int argc, char *argv[])
+{
+	GDBusProxy *proxy;
+
+	if (check_default_player() == FALSE)
+		return;
+
+	proxy = find_folder(g_dbus_proxy_get_path(default_player));
+	if (proxy == NULL) {
+		rl_printf("Operation not supported\n");
+		return;
+	}
+
+	if (g_dbus_proxy_method_call(proxy, "TotalNumberOfItems", NULL,
+				total_items_reply, NULL, g_free) == FALSE) {
+		rl_printf("Failed to get total number of items\n");
+		return;
+	}
+
+	rl_printf("Attempting to list items\n");
+}
+
 static void search_setup(DBusMessageIter *iter, void *user_data)
 {
 	char *string = user_data;
@@ -1025,6 +1063,8 @@ static const struct {
 					"List items of current folder" },
 	{ "search",     "string",     cmd_search,
 					"Search items containing string" },
+	{ "total-items", NULL, cmd_total_items,
+					"Get total number of items" },
 	{ "queue",       "<item>",    cmd_queue, "Add item to playlist queue" },
 	{ "show-item",   "<item>",    cmd_show_item, "Show item information" },
 	{ "quit",         NULL,       cmd_quit, "Quit program" },
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: [PATCH  0/3] Add Support for GetTotalNumOfItems
  2015-06-24  9:11 [PATCH 0/3] Add Support for GetTotalNumOfItems Bharat Panda
                   ` (2 preceding siblings ...)
  2015-06-24  9:11 ` [PATCH 3/3] tools: Add total-items command for GetTotalNumOfItems Bharat Panda
@ 2015-07-01  5:27 ` Bharat Bhusan Panda
  3 siblings, 0 replies; 8+ messages in thread
From: Bharat Bhusan Panda @ 2015-07-01  5:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: cpgs

ping

> -----Original Message-----
> From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-
> owner@vger.kernel.org] On Behalf Of Bharat Panda
> Sent: Wednesday, June 24, 2015 2:41 PM
> To: linux-bluetooth@vger.kernel.org
> Cc: cpgs@samsung.com; Bharat Panda
> Subject: [PATCH 0/3] Add Support for GetTotalNumOfItems
> 
> Support added for AVRCP GetTotalNumOfItems browsing command.
> 
> It is used to retrieve the number of items in a folder prior to calling
> GetFolderItems to retrieve a listing of the contents of a folder. The
purpose
> of the command is to provide both scaling information, and total item
count
> for devices that may not be able to store or display an entire folder
content
> listing.
> 
> Bharat Panda (3):
>   audio/avrcp: Add AVRCP GetTotalNumOfItems support
>   audio/player: Add TotalNumberOfItems DBUS method
>   tools: Add total-items command for GetTotalNumOfItems
> 
>  profiles/audio/avrcp.c   | 77
> ++++++++++++++++++++++++++++++++++++++++++++++++
>  profiles/audio/player.c  | 53 +++++++++++++++++++++++++++++++++
> profiles/audio/player.h  |  4 +++  tools/bluetooth-player.c | 40
> +++++++++++++++++++++++++
>  4 files changed, 174 insertions(+)
> 
> --
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
in
> the body of a message to majordomo@vger.kernel.org More majordomo
> info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] audio/avrcp: Add AVRCP GetTotalNumOfItems support
  2015-06-24  9:11 ` [PATCH 1/3] audio/avrcp: Add AVRCP GetTotalNumOfItems support Bharat Panda
@ 2015-07-02  8:13   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2015-07-02  8:13 UTC (permalink / raw)
  To: Bharat Panda; +Cc: linux-bluetooth@vger.kernel.org, cpgs

Hi Bharat,

On Wed, Jun 24, 2015 at 12:11 PM, Bharat Panda <bharat.panda@samsung.com> wrote:
> Added support for AVRCP GetTotalNumOfItems browsing command
> to retrieve the number of items in a folder(with given scope)
> prior to calling GetFolderItems to retrieve a listing of the
> contents of the folder.
> ---
>  profiles/audio/avrcp.c  | 77 +++++++++++++++++++++++++++++++++++++++++++++++++
>  profiles/audio/player.c | 25 ++++++++++++++++
>  profiles/audio/player.h |  4 +++
>  3 files changed, 106 insertions(+)
>
> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
> index 60f8cbf..ebb3af9 100644
> --- a/profiles/audio/avrcp.c
> +++ b/profiles/audio/avrcp.c
> @@ -108,6 +108,7 @@
>  #define AVRCP_CHANGE_PATH              0x72
>  #define AVRCP_GET_ITEM_ATTRIBUTES      0x73
>  #define AVRCP_PLAY_ITEM                        0x74
> +#define AVRCP_GET_TOTAL_NUMBER_OF_ITEMS        0x75
>  #define AVRCP_SEARCH                   0x80
>  #define AVRCP_ADD_TO_NOW_PLAYING       0x90
>  #define AVRCP_GENERAL_REJECT           0xA0
> @@ -2821,6 +2822,81 @@ static int ct_add_to_nowplaying(struct media_player *mp, const char *name,
>         return 0;
>  }
>
> +static gboolean avrcp_get_total_numberofitems_rsp(struct avctp *conn,
> +                                       uint8_t *operands, size_t operand_count,
> +                                       void *user_data)
> +{
> +       struct avrcp_browsing_header *pdu = (void *) operands;
> +       struct avrcp *session = user_data;
> +       struct avrcp_player *player = session->controller->player;
> +       struct media_player *mp = player->user_data;
> +       int ret = 0;
> +
> +       if (pdu == NULL) {
> +               ret = -ETIMEDOUT;
> +               goto done;
> +       }
> +
> +       if (pdu->params[0] != AVRCP_STATUS_SUCCESS || operand_count < 7) {
> +               ret = -EINVAL;
> +               goto done;
> +       }
> +
> +       if (pdu->params[0] == AVRCP_STATUS_OUT_OF_BOUNDS)
> +               goto done;
> +
> +       player->uid_counter = get_be16(&pdu->params[1]);
> +       ret = get_be32(&pdu->params[3]);
> +
> +done:
> +       media_player_get_number_of_items_complete(mp, ret);
> +
> +       return FALSE;
> +}
> +
> +static void avrcp_get_total_numberofitems(struct avrcp *session)
> +{
> +       uint8_t buf[AVRCP_BROWSING_HEADER_LENGTH + 7];
> +       struct avrcp_player *player = session->controller->player;
> +       struct avrcp_browsing_header *pdu = (void *) buf;
> +       uint16_t length = AVRCP_BROWSING_HEADER_LENGTH + 7;
> +
> +       memset(buf, 0, sizeof(buf));
> +
> +       pdu->pdu_id = AVRCP_GET_TOTAL_NUMBER_OF_ITEMS;
> +       pdu->param_len = htons(7 + sizeof(uint32_t));
> +
> +       pdu->params[0] = player->scope;
> +
> +       length += sizeof(uint32_t);
> +
> +       avctp_send_browsing_req(session->conn, buf, length,
> +                               avrcp_get_total_numberofitems_rsp, session);
> +}
> +
> +static int ct_get_total_numberofitems(struct media_player *mp, const char *name,
> +                                               void *user_data)
> +{
> +       struct avrcp_player *player = user_data;
> +       struct avrcp *session;
> +
> +       if (player->p != NULL)
> +               return -EBUSY;
> +
> +       session = player->sessions->data;
> +
> +       if (g_str_has_prefix(name, "/NowPlaying"))
> +               player->scope = 0x03;
> +       else if (g_str_has_suffix(name, "/search"))
> +               player->scope = 0x02;
> +       else
> +               player->scope = 0x01;
> +
> +       avrcp_get_total_numberofitems(session);
> +
> +       return 0;
> +}
> +
>  static const struct media_player_callback ct_cbs = {
>         .set_setting    = ct_set_setting,
>         .play           = ct_play,
> @@ -2835,6 +2911,7 @@ static const struct media_player_callback ct_cbs = {
>         .search         = ct_search,
>         .play_item      = ct_play_item,
>         .add_to_nowplaying = ct_add_to_nowplaying,
> +       .total_items = ct_get_total_numberofitems,
>  };
>
>  static struct avrcp_player *create_ct_player(struct avrcp *session,
> diff --git a/profiles/audio/player.c b/profiles/audio/player.c
> index 94eb2eb..b7f7b60 100644
> --- a/profiles/audio/player.c
> +++ b/profiles/audio/player.c
> @@ -702,6 +702,31 @@ done:
>         folder->msg = NULL;
>  }
>
> +void media_player_get_number_of_items_complete(struct media_player *mp, int ret)
> +{
> +       struct media_folder *folder = mp->scope;
> +       DBusMessage *reply;
> +
> +       if (folder == NULL || folder->msg == NULL)
> +               return;
> +
> +       if (ret < 0) {
> +               reply = btd_error_failed(folder->msg, strerror(-ret));
> +               goto done;
> +       }
> +
> +       folder->number_of_items = ret;
> +
> +       reply = g_dbus_create_reply(folder->msg,
> +                               DBUS_TYPE_INT32, &folder->number_of_items,
> +                               DBUS_TYPE_INVALID);

Im not quite sure what you are responding here? NumberOfItems is a
property you should emit a signal instead.

> +
> +done:
> +       g_dbus_send_message(btd_get_dbus_connection(), reply);
> +       dbus_message_unref(folder->msg);
> +       folder->msg = NULL;
> +}
> +
>  static const GDBusMethodTable media_player_methods[] = {
>         { GDBUS_METHOD("Play", NULL, NULL, media_player_play) },
>         { GDBUS_METHOD("Pause", NULL, NULL, media_player_pause) },
> diff --git a/profiles/audio/player.h b/profiles/audio/player.h
> index ac2a3da..bc9fa57 100644
> --- a/profiles/audio/player.h
> +++ b/profiles/audio/player.h
> @@ -64,6 +64,8 @@ struct media_player_callback {
>                                         uint64_t uid, void *user_data);
>         int (*add_to_nowplaying) (struct media_player *mp, const char *name,
>                                         uint64_t uid, void *user_data);
> +       int (*total_items) (struct media_player *mp, const char *name,
> +                                               void *user_data);
>  };
>
>  struct media_player *media_player_controller_create(const char *path,
> @@ -104,6 +106,8 @@ void media_player_list_complete(struct media_player *mp, GSList *items,
>  void media_player_change_folder_complete(struct media_player *player,
>                                                 const char *path, int ret);
>  void media_player_search_complete(struct media_player *mp, int ret);
> +void media_player_get_number_of_items_complete(struct media_player *mp,
> +                                               int ret);
>
>  void media_player_set_callbacks(struct media_player *mp,
>                                 const struct media_player_callback *cbs,
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] audio/player: Add TotalNumberOfItems DBUS method
  2015-06-24  9:11 ` [PATCH 2/3] audio/player: Add TotalNumberOfItems DBUS method Bharat Panda
@ 2015-07-02  8:17   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2015-07-02  8:17 UTC (permalink / raw)
  To: Bharat Panda; +Cc: linux-bluetooth@vger.kernel.org, cpgs

Hi Bharat,

On Wed, Jun 24, 2015 at 12:11 PM, Bharat Panda <bharat.panda@samsung.com> wrote:
> Adds support for TotalNumberOfItems DBUS method on
> org.bluez.MediaFolder1 interface.
> ---
>  profiles/audio/player.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
>
> diff --git a/profiles/audio/player.c b/profiles/audio/player.c
> index b7f7b60..c8e10e1 100644
> --- a/profiles/audio/player.c
> +++ b/profiles/audio/player.c
> @@ -877,6 +877,30 @@ static DBusMessage *media_folder_list_items(DBusConnection *conn,
>         return NULL;
>  }
>
> +static DBusMessage *media_folder_total_items(DBusConnection *conn,
> +                                               DBusMessage *msg, void *data)
> +{
> +       struct media_player *mp = data;
> +       struct media_folder *folder = mp->scope;
> +       struct player_callback *cb = mp->cb;
> +       int err;
> +
> +       if (cb->cbs->list_items == NULL)
> +               return btd_error_not_supported(msg);
> +
> +       if (folder->msg != NULL)
> +               return btd_error_failed(msg, strerror(EBUSY));
> +
> +       err = cb->cbs->total_items(mp, folder->item->name,
> +                                                       cb->user_data);
> +       if (err < 0)
> +               return btd_error_failed(msg, strerror(-err));
> +
> +       folder->msg = dbus_message_ref(msg);
> +
> +       return NULL;
> +}
> +
>  static void media_item_free(struct media_item *item)
>  {
>         if (item->metadata != NULL)
> @@ -1091,6 +1115,10 @@ static const GDBusMethodTable media_folder_methods[] = {
>                         GDBUS_ARGS({ "filter", "a{sv}" }),
>                         GDBUS_ARGS({ "items", "a{oa{sv}}" }),
>                         media_folder_list_items) },
> +       { GDBUS_ASYNC_METHOD("TotalNumberOfItems",
> +                       NULL,
> +                       GDBUS_ARGS({ "totalitems", "u" }),
> +                       media_folder_total_items) },

This shall be updated via NumberOfItems property probably once you
switch folder/scope we can send the command to read the number of
items and update its property so no new API should be needed.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] tools: Add total-items command for GetTotalNumOfItems
  2015-06-24  9:11 ` [PATCH 3/3] tools: Add total-items command for GetTotalNumOfItems Bharat Panda
@ 2015-07-02  8:19   ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 8+ messages in thread
From: Luiz Augusto von Dentz @ 2015-07-02  8:19 UTC (permalink / raw)
  To: Bharat Panda; +Cc: linux-bluetooth@vger.kernel.org, cpgs

Hi Bharat,

On Wed, Jun 24, 2015 at 12:11 PM, Bharat Panda <bharat.panda@samsung.com> wrote:
> Added command "total-items" to send request for
> "GetTotalNumOfItems".
> ---
>  tools/bluetooth-player.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
>
> diff --git a/tools/bluetooth-player.c b/tools/bluetooth-player.c
> index 9e19997..66303a7 100644
> --- a/tools/bluetooth-player.c
> +++ b/tools/bluetooth-player.c
> @@ -891,6 +891,44 @@ done:
>         rl_printf("Attempting to list items\n");
>  }
>
> +static void total_items_reply(DBusMessage *message, void *user_data)
> +{
> +       DBusError error;
> +
> +       dbus_error_init(&error);
> +
> +       if (dbus_set_error_from_message(&error, message) == TRUE) {
> +               rl_printf("Failed to get total number of items: %s\n",
> +                                       error.name);
> +               dbus_error_free(&error);
> +               return;
> +       }
> +
> +       rl_printf("TotalItems successful\n");
> +}
> +
> +static void cmd_total_items(int argc, char *argv[])
> +{
> +       GDBusProxy *proxy;
> +
> +       if (check_default_player() == FALSE)
> +               return;
> +
> +       proxy = find_folder(g_dbus_proxy_get_path(default_player));
> +       if (proxy == NULL) {
> +               rl_printf("Operation not supported\n");
> +               return;
> +       }
> +
> +       if (g_dbus_proxy_method_call(proxy, "TotalNumberOfItems", NULL,
> +                               total_items_reply, NULL, g_free) == FALSE) {
> +               rl_printf("Failed to get total number of items\n");
> +               return;
> +       }
> +
> +       rl_printf("Attempting to list items\n");
> +}
> +
>  static void search_setup(DBusMessageIter *iter, void *user_data)
>  {
>         char *string = user_data;
> @@ -1025,6 +1063,8 @@ static const struct {
>                                         "List items of current folder" },
>         { "search",     "string",     cmd_search,
>                                         "Search items containing string" },
> +       { "total-items", NULL, cmd_total_items,
> +                                       "Get total number of items" },
>         { "queue",       "<item>",    cmd_queue, "Add item to playlist queue" },
>         { "show-item",   "<item>",    cmd_show_item, "Show item information" },
>         { "quit",         NULL,       cmd_quit, "Quit program" },
> --
> 1.9.1

This entire patch should not be necessary if we just update
NumberOfItems property.


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-07-02  8:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-24  9:11 [PATCH 0/3] Add Support for GetTotalNumOfItems Bharat Panda
2015-06-24  9:11 ` [PATCH 1/3] audio/avrcp: Add AVRCP GetTotalNumOfItems support Bharat Panda
2015-07-02  8:13   ` Luiz Augusto von Dentz
2015-06-24  9:11 ` [PATCH 2/3] audio/player: Add TotalNumberOfItems DBUS method Bharat Panda
2015-07-02  8:17   ` Luiz Augusto von Dentz
2015-06-24  9:11 ` [PATCH 3/3] tools: Add total-items command for GetTotalNumOfItems Bharat Panda
2015-07-02  8:19   ` Luiz Augusto von Dentz
2015-07-01  5:27 ` [PATCH 0/3] Add Support " Bharat Bhusan Panda

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).