From: Chris P. <dev...@te...> - 2004-02-20 17:15:45
|
I did hoist the getphonebook method out of the VX4400, and given how the initialization is different, I have changed it a bit so that the TM520-specific code is moved out of the getphonebook function. It seems that the TM520 will always reboot the phone after PhoneBook sync so you don't really need to explicitly switch to BREW mode (and doing so actually break things with the TM520). I have included the snippet of the code relating to getphonebook here for now as I'm not quite done with the rest of the changes. def pbinit(self): req=self.protocolclass.pbstartsyncrequest() self.sendpbcommand(req, self.protocolclass.pbstartsyncresponse) req=self.protocolclass.pbinitrequest() res=self.sendpbcommand(req, self.protocolclass.pbinitresponse) count = res.numentries req=self.protocolclass.pbinforequest() res=self.sendpbcommand(req, self.protocolclass.pbnextentryresponse) ## NOT inforesponse return count def pregetpb(self,result): index={} try: buf=prototypes.buffer(self.getfilecontents("pim/midiringer.dat")) except com_brew.BrewNoSuchFileException: # file may not exist return index g=self.protocolclass.ringindex() g.readfrombuffer(buf) for i in g.items: if i.name != "default": index[i.index+1]=i.name[len('ringer/'):] return index def getphonebook(self,result): """Reads the phonebook data. The L{getfundamentals} information will already be in result.""" pbook={} # Bug in the phone. if you repeatedly read the phone book it starts # returning a random number as the number of entries. We get around # this by switching into brew mode which clears that. #self.mode=self.MODENONE #self.setmode(self.MODEBREW) result['intermediate'] = self.pregetpb(result) self.log("Reading number of phonebook entries") numentries=self.pbinit() self.log("There are %d entries" % (numentries,)) for i in range(0, numentries): ### Read current entry req=self.protocolclass.pbreadentryrequest() res=self.sendpbcommand(req, self.protocolclass.pbreadentryresponse) self.log("Read entry "+`i`+" - "+res.entry.name) entry=self.extractphonebookentry(res.entry, result) pbook[i]=entry self.progress(i, numentries, res.entry.name) #### Advance to next entry req=self.protocolclass.pbnextentryrequest() self.sendpbcommand(req, self.protocolclass.pbnextentryresponse) self.progress(numentries, numentries, "Phone book read completed") result['phonebook']=pbook cats=[] for i in result['groups']: if result['groups'][i]['name']!='No Group': cats.append(result['groups'][i]['name']) result['categories']=cats del result['intermediate'] print "returning keys",result.keys() return pbook PS - with the TM520, phonebook sync must be the last operation if you selected multiple things with Get Phone Data. Is that the case with the VX4400? The reason being that TM520 will always reboot after getting the phonebook so you have to do everything else before that (ringtones and calendar) |