comparison src/plugins/plugin_misc_imap.py @ 254:9fc32d1d9046

Plugin IMAP, plugin MAILDIR: added IMAP's UID management, mailbox data persistence
author Goffi <goffi@goffi.org>
date Mon, 17 Jan 2011 04:23:31 +0100
parents f45ffbf211e9
children 55b750017b71
comparison
equal deleted inserted replaced
253:f45ffbf211e9 254:9fc32d1d9046
83 83
84 def getUID(self): 84 def getUID(self):
85 """Retrieve the unique identifier associated with this message. 85 """Retrieve the unique identifier associated with this message.
86 """ 86 """
87 debug('getUID (message)') 87 debug('getUID (message)')
88 debug ('===>%i', self.uid)
88 return self.uid 89 return self.uid
89 90
90 def getFlags(self): 91 def getFlags(self):
91 """Retrieve the flags associated with this message. 92 """Retrieve the flags associated with this message.
92 @return: The flags, represented as strings. 93 @return: The flags, represented as strings.
174 175
175 def getUIDNext(self): 176 def getUIDNext(self):
176 """Return the likely UID for the next message added to this mailbox. 177 """Return the likely UID for the next message added to this mailbox.
177 """ 178 """
178 debug ('getUIDNext') 179 debug ('getUIDNext')
179 return self.getMessageCount()+1 180 return self.mailbox.getNextUid()
180 181
181 def getUID(self,message): 182 def getUID(self,message):
182 """Return the UID of a message in the mailbox 183 """Return the UID of a message in the mailbox
183 @param message: The message sequence number 184 @param message: The message sequence number
184 @return: The UID of the message. 185 @return: The UID of the message.
185 """ 186 """
186 debug ('getUID') 187 debug ('getUID')
187 return self.mailbox.getId(message) 188 return self.mailbox.getUid(message)
188 189
189 def getMessageCount(self): 190 def getMessageCount(self):
190 """Return the number of messages in this mailbox. 191 """Return the number of messages in this mailbox.
191 """ 192 """
192 debug('getMessageCount') 193 debug('getMessageCount')
283 @param messages: The identifiers of messages to retrieve information 284 @param messages: The identifiers of messages to retrieve information
284 about 285 about
285 @param uid: If true, the IDs specified in the query are UIDs; 286 @param uid: If true, the IDs specified in the query are UIDs;
286 """ 287 """
287 debug('fetch (%s, %s)'%(messages,uid)) 288 debug('fetch (%s, %s)'%(messages,uid))
288 messages.last = self.getMessageCount() 289 if uid:
289 for mes_idx in messages: 290 messages.last = self.mailbox.getMaxUid()
290 if mes_idx>self.getMessageCount(): 291 messages.getnext = self.mailbox.getNextExistingUid
291 continue 292 for mess_uid in messages:
292 yield (mes_idx,Message(mes_idx,self.mailbox.getMessage(mes_idx-1))) 293 if mess_uid == None:
294 debug ('stopping iteration')
295 raise StopIteration
296 try:
297 debug ('yielding (%s,%s)' % (mess_uid,Message(mess_uid,self.mailbox.getMessageUid(mess_uid))))
298 yield (mess_uid,Message(mess_uid,self.mailbox.getMessageUid(mess_uid)))
299 except IndexError:
300 continue
301 else:
302 messages.last = self.getMessageCount()
303 for mess_idx in messages:
304 if mess_idx>self.getMessageCount():
305 raise StopIteration
306 yield (mess_idx,Message(mess_idx,self.mailbox.getMessage(mess_idx-1)))
293 307
294 def store(self, messages, flags, mode, uid): 308 def store(self, messages, flags, mode, uid):
295 """Set the flags of one or more messages. 309 """Set the flags of one or more messages.
296 @param messages: The identifiers of the messages to set the flags of. 310 @param messages: The identifiers of the messages to set the flags of.
297 @param flags: The flags to set, unset, or add. 311 @param flags: The flags to set, unset, or add.