summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2009-04-29 16:05:08 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2009-04-29 22:30:53 +0300
commit0937f323f75f75deb699c1c875a53c1817c26a0a (patch)
treee459e50ee71e1e6344161202cb86a9694a6267b7 /test
parent6618552692a48bdfe09a507276201945a421f493 (diff)
downloadobexd-0937f323f75f75deb699c1c875a53c1817c26a0a.tar.gz
Add list-folders test.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am2
-rwxr-xr-xtest/list-folders43
2 files changed, 44 insertions, 1 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index d81cda3..f89614b 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -8,6 +8,6 @@ obex_test_LDADD = @GWOBEX_LIBS@ @OPENOBEX_LIBS@ @BLUEZ_LIBS@ @GLIB_LIBS@
AM_CFLAGS = @GLIB_CFLAGS@ @BLUEZ_CFLAGS@ @OPENOBEX_CFLAGS@ @GWOBEX_CFLAGS@
EXTRA_DIST = send-files pull-business-card exchange-business-cards \
- pbap-client simple-agent
+ list-folders pbap-client simple-agent
MAINTAINERCLEANFILES = Makefile.in
diff --git a/test/list-folders b/test/list-folders
new file mode 100755
index 0000000..ef9d9fb
--- /dev/null
+++ b/test/list-folders
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+
+def list_folder(folder):
+ bus = dbus.SessionBus()
+ client = dbus.Interface(bus.get_object("org.openobex.client", "/"),
+ "org.openobex.Client")
+
+ session_path = client.CreateSession({ "Destination": sys.argv[1], "Target": "ftp"})
+
+ ftp = dbus.Interface(bus.get_object("org.openobex.client", session_path),
+ "org.openobex.FileTransfer")
+
+ if folder:
+ for node in folder.split("/"):
+ ftp.ChangeFolder(node)
+
+ listing = ftp.ListFolder()
+
+ name = None
+ ftype = None
+
+ for i in listing:
+ if i["Type"] == "folder":
+ print "%s/" % (i["Name"])
+ else:
+ print "%s" % (i["Name"])
+
+
+if __name__ == '__main__':
+
+ if len(sys.argv) < 2:
+ print "Usage: %s <device> [folder]" % (sys.argv[0])
+ sys.exit(1)
+
+ folder = None
+ if len(sys.argv) == 3:
+ folder = sys.argv[2]
+
+ list_folder(folder)