Exemplo n.º 1
0
 def _unpackGoogleTitle(self, atts, gtitle):
     """
     Takes the components of a Google Title apart (all names)
     
     The whole thing is about guessing - check code for details.
     """
     pisiprogress.getCallback().verbose("Google Contacts: Loading")
     title,  first,  last,  middle = pisitools.parseFullName(gtitle)
     atts['title'] = title
     atts['firstname'] = first
     atts['lastname'] = last
     atts['middlename'] = middle
Exemplo n.º 2
0
    def load(self):
        """
        Load all data from backend
        """
        pisiprogress.getCallback().verbose ("DBUS_SIM: Loading")
        pisiprogress.getCallback().progress.push(0, 100)        
        pisiprogress.getCallback().verbose ("  >SIM Card Limitations: %d entries maximum; no more than %d characters per name" %(self._max_simentries, self._name_maxlength))
        bus = dbus.SystemBus()
        gsm_device_obj = bus.get_object(DBUS_GSM_DEVICE[0], DBUS_GSM_DEVICE[1])
        sim = dbus.Interface(gsm_device_obj,DBUS_SIM)
        dbusContacts = sim.RetrievePhonebook(DBUS_CONTACTS, 1, self._max_simentries)
        pisiprogress.getCallback().progress.setProgress(20) 
        pisiprogress.getCallback().update("Loading")
        i = 0
        for c in dbusContacts:
            dbus_id = c[0]
            name = c[1]
            number = c[2]
            
            del self._availableIds[dbus_id]
            
            type = PHONE_TYPE_MOBILE
            if name.endswith(DBUS_NAME_MOBILEPHONE_SUFFIX):
                name = name[:len(name) - len(DBUS_NAME_MOBILEPHONE_SUFFIX)]
            if name.endswith(DBUS_NAME_WORKPHONE_SUFFIX):
                type = PHONE_TYPE_WORK
                name = name[:len(name) - len(DBUS_NAME_WORKPHONE_SUFFIX)]
            elif name.endswith(DBUS_NAME_HOMEPHONE_SUFFIX):
                type = PHONE_TYPE_HOME
                name = name[:len(name) - len(DBUS_NAME_HOMEPHONE_SUFFIX)]
            
            atts = {}
            title,  first,  last,  middle = pisitools.parseFullName(name)
            atts['title'] = title
            atts['firstname'] = first
            atts['lastname'] = last
            atts['middlename'] = middle

            id = contacts.assembleID(atts)
            if self._allContacts.has_key(id):
                c = self._allContacts[id]
                if type == PHONE_TYPE_MOBILE:
                    c.attributes['mobile'] = number.strip()
                elif type == PHONE_TYPE_WORK:
                    c.attributes['officePhone'] = number.strip()
                elif type == PHONE_TYPE_HOME:
                    c.attributes['phone'] = number.strip()
                
            else:
                if type == PHONE_TYPE_MOBILE:
                    atts['mobile'] = number.strip()
                elif type == PHONE_TYPE_WORK:
                    atts['officePhone'] = number.strip()
                elif type == PHONE_TYPE_HOME:
                    atts['phone'] = number.strip()
                c = contacts.Contact(id,  atts)
                self._allContacts[id] = c
                self._idMappings[id] = []
            self._idMappings[id].append(dbus_id)
            i+=1
            pisiprogress.getCallback().progress.setProgress(20 + ((i*80) / len(dbusContacts)))
            pisiprogress.getCallback().update('Loading')
        pisiprogress.getCallback().progress.drop()