linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Szatkowski <bulislaw@linux.com>
To: linux-bluetooth@vger.kernel.org
Cc: Bartosz Szatkowski <bulislaw@linux.com>
Subject: [PATCH obexd 5/6] Add basic support for MAP folder listing
Date: Thu,  8 Dec 2011 14:07:57 +0100	[thread overview]
Message-ID: <1323349678-17905-5-git-send-email-bulislaw@linux.com> (raw)
In-Reply-To: <1323349678-17905-1-git-send-email-bulislaw@linux.com>

For now just basic functionality - returning whole listing as a string
(no parsing for now) and no apparams handling.
---
 client/map.c    |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 test/map-client |    5 +++++
 2 files changed, 57 insertions(+), 1 deletions(-)

diff --git a/client/map.c b/client/map.c
index bc45a13..397c170 100644
--- a/client/map.c
+++ b/client/map.c
@@ -104,8 +104,59 @@ static DBusMessage *map_setpath(DBusConnection *connection,
 	return NULL;
 }
 
+static void buffer_cb(struct obc_session *session, GError *err,
+							void *user_data)
+{
+	struct obc_transfer *transfer = obc_session_get_transfer(session);
+	struct map_data *map = user_data;
+	DBusMessage *reply;
+	const char *buf;
+	int size;
+
+	if (err != NULL) {
+		reply = g_dbus_create_error(map->msg, ERROR_FAILED_PATH, "%s",
+								err->message);
+		goto done;
+	}
+
+	buf = obc_transfer_get_buffer(transfer, &size);
+	if (size == 0)
+		buf = "";
+
+	reply = g_dbus_create_reply(map->msg, DBUS_TYPE_STRING, &buf,
+							DBUS_TYPE_INVALID);
+
+	obc_transfer_clear_buffer(transfer);
+
+done:
+	g_dbus_send_message(conn, reply);
+	dbus_message_unref(map->msg);
+	obc_transfer_unregister(transfer);
+}
+
+static DBusMessage *map_get_folder_listing(DBusConnection *connection,
+					DBusMessage *message, void *user_data)
+{
+	struct map_data *map = user_data;
+	int err;
+
+	err = obc_session_get(map->session, "x-obex/folder-listing",
+							NULL, NULL, NULL, 0,
+							buffer_cb, map);
+	if (err < 0)
+		return g_dbus_create_error(message, ERROR_FAILED_PATH,
+								"Failed");
+
+	map->msg = dbus_message_ref(message);
+
+	return NULL;
+}
+
 static GDBusMethodTable map_methods[] = {
-	{ "SetFolder",	"s",	"",	map_setpath, G_DBUS_METHOD_FLAG_ASYNC },
+	{ "SetFolder",		"s", "",	map_setpath,
+						G_DBUS_METHOD_FLAG_ASYNC },
+	{ "GetFolderListing",	"a{ss}", "s",	map_get_folder_listing,
+						G_DBUS_METHOD_FLAG_ASYNC },
 	{ }
 };
 
diff --git a/test/map-client b/test/map-client
index 5ee4331..bcd2e66 100755
--- a/test/map-client
+++ b/test/map-client
@@ -11,6 +11,8 @@ def parse_options():
                       help="Device to connect", metavar="DEVICE")
     parser.add_option("-c", "--chdir", dest="new_dir",
                       help="Change current directory to DIR", metavar="DIR")
+    parser.add_option("-l", "--lsdir", action="store_true", dest="ls_dir",
+                      help="List folders in current directory")
     parser.add_option("-v", "--verbose", action="store_true", dest="verbose")
 
     return parser.parse_args()
@@ -49,4 +51,7 @@ if  __name__ == '__main__':
     if options.new_dir:
         set_folder(map, options.new_dir)
 
+    if options.ls_dir:
+        print map.GetFolderListing(dict())
+
     mainloop.run()
-- 
1.7.4.1


  parent reply	other threads:[~2011-12-08 13:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-08 13:07 [PATCH obexd 1/6] gobex: Add translating error codes to strings Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 2/6] Add basic support for MAP client in obex-client Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 3/6] Add support for SetFolder in MAP client Bartosz Szatkowski
2011-12-09 13:22   ` Johan Hedberg
2011-12-09 13:58     ` Bartosz Szatkowski
2011-12-08 13:07 ` [PATCH obexd 4/6] Add simple helper for " Bartosz Szatkowski
2011-12-08 13:07 ` Bartosz Szatkowski [this message]
2011-12-08 13:07 ` [PATCH obexd 6/6] Add support for PullMessagesListing in " Bartosz Szatkowski
  -- strict thread matches above, loose matches on Subject: below --
2011-12-05 11:41 [PATCH obexd 1/6] gobex: Add translating error codes to strings Bartosz Szatkowski
2011-12-05 11:41 ` [PATCH obexd 5/6] Add basic support for MAP folder listing Bartosz Szatkowski

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=1323349678-17905-5-git-send-email-bulislaw@linux.com \
    --to=bulislaw@linux.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).