#!/usr/bin/python import sys import dbus reload(sys) sys.setdefaultencoding('utf8') 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.encode('utf8'))