예제 #1
0
 def read(self):
     self._data={}
     text=''
     for i in self._range_entries:
         try:
             self._phone.progress(i, self._max_num_entries,
                                   'Reading Memo Entry: '+str(i))
             s=self._phone.get_memo_entry(i)
             if len(s)!=self._max_num_of_fields:
                 continue
             t=s[self._text_index]
             if len(t)==self._max_text_len and \
                t[-1]==self._continuation_char:
                 # contination to the next record
                 text+=t[:len(t)-1]
                 continue
             # new record
             text+=t
             m=memo.MemoEntry()
             m.text=text
             m.set_date_isostr(s[self._date_index])
             self._data[m.id]=m
             text=''
         except:
             if __debug__: raise
예제 #2
0
 def getmemo(self, result):
     # read the memo file
     res = {}
     try:
         stat_res = self.statfile(self.memolocation)
         # allow for zero length file
         if stat_res != None and stat_res['size'] != 0:
             buf = prototypes.buffer(self.getfilecontents(
                 self.memolocation))
             text_memo = self.protocolclass.textmemofile()
             text_memo.readfrombuffer(buf,
                                      logtitle="Read memo file" +
                                      self.memolocation)
             for m in text_memo.items:
                 entry = memo.MemoEntry()
                 entry.text = m.text
                 try:
                     entry.set_date_isostr("%d%02d%02dT%02d%02d00" %
                                           ((m.memotime)))
                 except ValueError:
                     # deleted memos can remain in file but have a bogus date
                     continue
                 res[entry.id] = entry
     except com_brew.BrewNoSuchFileException:
         pass
     result['memo'] = res
     return result
예제 #3
0
 def getmemo(self, result):
     self.log('Reading Memo')
     self.setmode(self.MODEMODEM)
     self.charset_ascii()
     _req = self.protocolclass.memo_read_req()
     _res = self.sendATcommand(_req, self.protocolclass.memo_read_resp)
     res = {}
     for e in _res:
         _memo = memo.MemoEntry()
         _memo.text = e.text
         res[_memo.id] = _memo
     result['memo'] = res
     return res
예제 #4
0
    def getmemo(self, result):
        memos = {}
        self.log("Getting memo entries")
        self.setmode(self.MODEPHONEBOOK)
        req=self.protocolclass.memorequest()
        for slot in range(self.protocolclass.NUMMEMOENTRIES):
            req.slot=slot
            res=self.sendpbcommand(req,self.protocolclass.memoresponse)
            if len(res) > 0:
                entry=memo.MemoEntry()
                entry.text=res[0].text
                entry.set_date_isostr='%4.4d%2.2d%2.2dT%2.2d%2.2d%2.2d'%(res[0].timestamp[0],res[0].timestamp[1],res[0].timestamp[2],res[0].timestamp[3],res[0].timestamp[4],res[0].timestamp[5])
                memos[entry.id]=entry

        result['memo']=memos
        return result