File: pbap-client

package info (click to toggle)
obexd 0.46-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,616 kB
  • sloc: ansic: 25,341; sh: 11,307; python: 423; makefile: 153
file content (41 lines) | stat: -rwxr-xr-x 1,089 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python

import sys
import dbus

bus = dbus.SessionBus()

client = dbus.Interface(bus.get_object("org.openobex.client", "/"),
						"org.openobex.Client")

print "Creating Session"
session_path = client.CreateSession({"Destination": sys.argv[1], "Target": "PBAP"})
pbap = dbus.Interface(bus.get_object("org.openobex.client", session_path),
						"org.openobex.PhonebookAccess")
session = dbus.Interface(bus.get_object("org.openobex.client", session_path),
							"org.openobex.Session")

paths = ["PB", "ICH", "OCH", "MCH", "CCH"]

for path in paths:
	print "\n--- Select Phonebook %s ---\n" % (path)
	pbap.Select("int", path)

	print "\n--- GetSize ---\n"
	ret = pbap.GetSize()
	print "Size = %d\n" % (ret)

	print "\n--- List vCard ---\n"
	ret = pbap.List()
	for item in ret:
		print "%s : %s" % (item[0], item[1])
		pbap.SetFormat("vcard30")
		pbap.SetFilter(["VERSION", "FN", "TEL"]);
		ret = pbap.Pull(item[0])
		print "%s" % (ret)

	print "\n--- PullAll ---\n"
	pbap.SetFormat("vcard30")
	pbap.SetFilter(["VERSION", "FN", "TEL"]);
	ret = pbap.PullAll()
	print "%s" % (ret)