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