All of lore.kernel.org
 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 4/4] Add simple helper for MAP client
Date: Tue, 22 Nov 2011 15:46:38 +0100	[thread overview]
Message-ID: <1321973198-23091-4-git-send-email-bulislaw@linux.com> (raw)
In-Reply-To: <1321973198-23091-1-git-send-email-bulislaw@linux.com>

---
 test/map-client |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 52 insertions(+), 0 deletions(-)
 create mode 100755 test/map-client

diff --git a/test/map-client b/test/map-client
new file mode 100755
index 0000000..450ad3e
--- /dev/null
+++ b/test/map-client
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+import gobject
+
+import dbus
+import dbus.mainloop.glib
+from optparse import OptionParser
+
+def parse_options():
+    parser.add_option("-d", "--device", dest="device",
+                      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("-v", "--verbose", action="store_true", dest="verbose")
+
+    return parser.parse_args()
+
+def set_folder(session, new_dir):
+    for node in new_dir.split("/"):
+        session.SetFolder(node)
+
+if  __name__ == '__main__':
+
+    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+    parser = OptionParser()
+
+    (options, args) = parse_options()
+
+    if not options.device:
+        parser.print_help()
+        exit(0)
+
+    bus = dbus.SessionBus()
+    mainloop = gobject.MainLoop()
+
+    client = dbus.Interface(bus.get_object("org.openobex.client", "/"),
+                            "org.openobex.Client")
+
+    session_path = client.CreateSession({ "Destination": options.device,
+                                          "Target": "map"})
+
+    session = dbus.Interface(bus.get_object("org.openobex.client", session_path),
+                 "org.openobex.Session")
+
+    map = dbus.Interface(bus.get_object("org.openobex.client", session_path),
+                 "org.openobex.MessagesAccess")
+
+    if options.new_dir:
+        set_folder(map, options.new_dir)
+
+    mainloop.run()
-- 
1.7.4.1


  parent reply	other threads:[~2011-11-22 14:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-22 14:46 [PATCH obexd 1/4] Add basic support for MAP client in obex-client Bartosz Szatkowski
2011-11-22 14:46 ` [PATCH obexd 2/4] Add support for SetFolder in MAP client Bartosz Szatkowski
2011-11-22 14:46 ` [PATCH obexd 3/4] Add response handling for " Bartosz Szatkowski
2011-11-22 14:46 ` Bartosz Szatkowski [this message]
2011-11-25 11:08 ` [PATCH obexd 1/4] Add basic support for MAP client in obex-client Johan Hedberg
2011-11-25 12:40   ` Bartosz Szatkowski
2011-11-25 15:58     ` Marcel Holtmann
2011-11-25 16:54       ` Bartosz Szatkowski
2011-12-02 11:23 ` Johan Hedberg

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=1321973198-23091-4-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.