#!/usr/bin/python # A simple qtopia-x11 dbus contacts tool # Marco Trevisan (TreviƱo) -- 2009 import os import dbus output_dir="/tmp/contacts" dbus_name = "org.openmoko.qtopia.Phonestatus" dbus_path = "/Contacts" dbus_iface = "org.openmoko.qtopia.Contact" phone_types = ["homeMobile", "homePhone", "homeVoip", "businessMobile", "businessPhone", "businessVoip"] session_bus = dbus.SessionBus() system_bus = dbus.SystemBus() qtopia_obj = session_bus.get_object(dbus_name, dbus_path) qtopia_iface = dbus.Interface(qtopia_obj, dbus_interface=dbus_iface) qtopia_iface.open() contacts_list = qtopia_iface.listContacts() for i in contacts_list: name = '' number = '' if len(qtopia_iface.contact(i)['firstName']): name = qtopia_iface.contact(i)['firstName'] if len(qtopia_iface.contact(i)['lastName']): if len(name): name += ' ' name += qtopia_iface.contact(i)['lastName'] if (len(name)): found = False titlename = name for j in phone_types: if len(qtopia_iface.contact(i)[j]): number = qtopia_iface.contact(i)[j] if found: titlename = name + ' ' + j found = True desktop_file = "[Desktop Entry]\n" \ "Name="+titlename+ "\n"\ "Comment=Call "+titlename+ "\n" \ "Exec=qcop service send Dialer dial\(QString,QString\) " \ + number + " " + number+ "\n" \ "Icon=dialer/Dialer\n" \ "Type=Application\n" \ "Categories=Office;Application;PIM;\n" \ "StartupNotify=true" savename = titlename.replace(' ', '_') print "Saving the "+titlename+" contact..." if not os.path.exists(output_dir): os.makedirs(output_dir) desktop = open(output_dir+'/'+savename+'.desktop', 'w') desktop.write(desktop_file) desktop.close qtopia_iface.close()