1311cfdf1a7dfeffb263d7fa3fff53228b4634e1
[profile/ivi/obexd.git] / test / pbap-client
1 #!/usr/bin/python
2
3 import sys
4 import dbus
5
6 reload(sys)
7 sys.setdefaultencoding('utf8')
8
9 bus = dbus.SessionBus()
10
11 client = dbus.Interface(bus.get_object("org.openobex.client", "/"),
12                                                 "org.openobex.Client")
13
14 print "Creating Session"
15 session_path = client.CreateSession({"Destination": sys.argv[1], "Target": "PBAP"})
16 pbap = dbus.Interface(bus.get_object("org.openobex.client", session_path),
17                                                 "org.openobex.PhonebookAccess")
18 session = dbus.Interface(bus.get_object("org.openobex.client", session_path),
19                                                         "org.openobex.Session")
20
21 paths = ["PB", "ICH", "OCH", "MCH", "CCH"]
22
23 for path in paths:
24         print "\n--- Select Phonebook %s ---\n" % (path)
25         pbap.Select("int", path)
26
27         print "\n--- GetSize ---\n"
28         ret = pbap.GetSize()
29         print "Size = %d\n" % (ret)
30
31         print "\n--- List vCard ---\n"
32         ret = pbap.List()
33         for item in ret:
34                 print "%s : %s" % (item[0], item[1])
35                 pbap.SetFormat("vcard30")
36                 pbap.SetFilter(["VERSION", "FN", "TEL"]);
37                 ret = pbap.Pull(item[0])
38                 print "%s" % (ret)
39
40         print "\n--- PullAll ---\n"
41         pbap.SetFormat("vcard30")
42         pbap.SetFilter(["VERSION", "FN", "TEL"]);
43         ret = pbap.PullAll()
44         print "%s" % (ret.encode('utf8'))