def do_reset(): utils = IndexUtils() for cls in (Message, Thread, Tag, Path): utils.db.truncate(cls) utils.close()
def do_list(): utils = IndexUtils() ids = utils.message.get_ids() for id in ids: print(id) utils.close()
def do_list_tags(): utils = IndexUtils() tags = utils.tag.get_tags() for tag in tags: print(tag.__unicode__()) utils.close()
def do_list_recipients(): utils = IndexUtils() recipients = utils.recipient.get_recipients() for recipient in recipients: print(recipient.__unicode__()) utils.close()
def do_undelete(self, args): id = int(args) for msg in self.msgs: if msg.id == id: msg.delete = False utils = IndexUtils() utils.message.undelete(msg.id) utils.close() #self.msgs.remove(msg) self.do_refresh(None) break
def do_show(id): utils = IndexUtils() msg = utils.message.get(id) utils.close() if msg: print(msg.path.path) mail = maildir.get_mail(msg.path.path) content = maildir.get_content(mail) else: print('Not found')
def do_list(self, args): limit = 16 if args: try: limit = int(args) except: pass self.screen.main.show_tab('list') utils = IndexUtils() self.msgs = utils.message.get_messages(limit) utils.close() self.do_refresh(None) self.screen.set_status('%i results' % len(self.msgs)) self.screen.update_title()
def on_selection_changed(self, selection): selection = self.msgList.get_selection() if selection == None: return model, paths = selection.get_selected_rows() if paths and len(paths) == 1: path = paths[0] iter = model.get_iter(path) id = model.get_value(iter, 2) utils = IndexUtils() msg = utils.message.get(id) utils.close() #msg.open() self.set_msgView(msg, 'plain') self.set_msgView(msg, 'html') self.set_msgView(msg, 'headers') #msg.close() msgViewTabs = self.xml.get_widget('msgViewTabs') msgViewTabs.set_current_page(0)
def do_search(self, widget=None, event=None): listStore = self.msgList.get_model() self.msgList.set_model(None) tagsSearchEntry = self.xml.get_widget('tagsSearchEntry') tags = tagsSearchEntry.get_text() if tags != '': for tag in tags.split(' '): if tag != '': pass nb = 0 utils = IndexUtils() for msg in utils.message.get_messages(): listStore.append([msg.subject, msg.sender.mail, msg.id, msg.path.path]) nb += 1 utils.close() status = self.xml.get_widget('statusbar') status.pop(1) status.push(1, str(nb) + ' messages') self.msgList.set_model(listStore)
def do_sync(name): if not name in config.stores: print('Invalid store') else: print('Syncing %s' % name) store = config.stores[name] uri = store['uri'] if not os.path.exists(uri): print('Invalid uri: %s' % uri) return # TODO: merge service interfaces utils = IndexUtils() # TODO: move that to a maildir utils interface mails = maildir.get_mails(uri) for (uid, mail) in mails.items(): if not utils.message.exists(uid): filename = mails.get_file(uid)._file.name (display, addr) = maildir.get_sender(mail) subject = maildir.get_subject(mail) msg = Message() msg.uid = uid msg.sender = utils.recipient.lookup_recipient(display, addr, True) msg.subject = subject msg.path = Path(filename) msg.thread = Thread() utils.message.add(msg) else: # assumes emails are immutable pass utils.close()
def do_drop(): utils = IndexUtils() utils.db.drop() utils.close()
def do_create(): utils = IndexUtils() utils.db.create() utils.close()
def do_tag(id, tagname): utils = IndexUtils() utils.thread.add_tag(id, tagname) utils.close()
def do_delete(id): utils = IndexUtils() utils.message.delete(id) utils.close()