def __init__(self, username): #The cache we use to pass data from one class to another self.user = username #DB connection self.conn = HTTPMail("http://localhost:5000") self.pool = None self.defflags=["\HasNoChildren"]
class HTTPMailAccount(object): implements(imap4.IAccount) def __init__(self, username): #The cache we use to pass data from one class to another self.user = username #DB connection self.conn = HTTPMail("http://localhost:5000") self.pool = None self.defflags=["\HasNoChildren"] #Get all the mailboxes and setup the SQL DB def listMailboxes(self, ref, wildcard): @defer.inlineCallbacks def listcb(boxes): mail_boxes = [] for i in boxes: print i state = HTTPMailImapState(self.user, i['tag'], self.conn) yield state.load() newbox = HTTPMailImapMailbox(state, self.conn) if fnmatch.fnmatch(i['tag'], ref + wildcard): mail_boxes.append((i['tag'], newbox)) defer.returnValue(mail_boxes) d = self.conn.getTags(self.user) d.addCallback(listcb) return d #Select a mailbox def select(self, path, rw=True): #print "Select: %s" % path @defer.inlineCallbacks def selectcb(tag): state = HTTPMailImapState(self.user, tag['tag'], self.conn) yield state.load() defer.returnValue(HTTPMailImapMailbox(state, self.conn)) d = self.conn.getTag(self.user, path) d.addCallback(selectcb) return d def printMsg(msg): pass #print "MSG: ", msg def close(self): return True def create(self, path): self.conn.newTag(self.user, path) def delete(self, path): self.conn.deleteTag(self.user, path) def rename(self, oldname, newname): return False def isSubscribed(self, path): return False def subscribe(self, path): return True def unsubscribe(self, path): return True