def update_account (self, account): mbox = self.__connect(account) messages, new_messages = self.__get_mails(mbox, account) num_messages = len(new_messages) max_not = float(SettingsController.get_instance().get_prefs()["max_notifications"]) account.new_unread = [] for mail_id, mail_num in new_messages: account.notifications[mail_id] = mail_num #We only get the e-mail content if all will be shown if num_messages <= max_not: msgNum, sub, fr = self.__get_mail_content(mbox, mail_num) #Store the mail_id, not the msgNum n = Notification(mail_id, sub, fr) else: n = Notification(mail_id, "New mail", "unknow") account.new_unread.append (n) #Remove old unread mails not in the current list of unread mails #TODO Do this better!!!!! only_current_ids = [] for mail_id, mail_num in messages: only_current_ids.append(mail_id) for nid in account.notifications.keys(): if nid not in only_current_ids: del account.notifications[nid] mbox.quit()
def update_account(self, account): mbox = self.__connect(account) messages, new_messages = self.__get_mails(mbox, account) num_messages = len(new_messages) max_not = float( SettingsController.get_instance().get_prefs()["max_notifications"]) account.new_unread = [] for mail_id, mail_num in new_messages: account.notifications[mail_id] = mail_num #We only get the e-mail content if all will be shown if num_messages <= max_not: msgNum, sub, fr = self.__get_mail_content(mbox, mail_num) #Store the mail_id, not the msgNum n = Notification(mail_id, sub, fr) else: n = Notification(mail_id, "New mail", "unknow") account.new_unread.append(n) #Remove old unread mails not in the current list of unread mails #TODO Do this better!!!!! only_current_ids = [] for mail_id, mail_num in messages: only_current_ids.append(mail_id) for nid in account.notifications.keys(): if nid not in only_current_ids: del account.notifications[nid] mbox.quit()
def __get_mails(self, mbox, account): """ Returns: [list of [msgId, msgNum] all mails, list of [msgId, msgNum] new mails""" new_messages = [] messages = [] ids = mbox.uidl() max_not = float(SettingsController.get_instance().get_prefs()["max_notifications"]) for id_pop in ids[1]: msgNum = int(id_pop.split(" ")[0]) msgId = id_pop.split(" ")[1] messages.append( [msgId, msgNum] ) if msgId not in account.notifications: new_messages.append( [msgId, msgNum] ) return [messages, new_messages]
def __get_mails(self, mbox, account): """ Returns: [list of [msgId, msgNum] all mails, list of [msgId, msgNum] new mails""" new_messages = [] messages = [] ids = mbox.uidl() max_not = float( SettingsController.get_instance().get_prefs()["max_notifications"]) for id_pop in ids[1]: msgNum = int(id_pop.split(" ")[0]) msgId = id_pop.split(" ")[1] messages.append([msgId, msgNum]) if msgId not in account.notifications: new_messages.append([msgId, msgNum]) return [messages, new_messages]
def check_auth_configuration(): try: import gnomekeyring as gk from ..core.keyrings import gkeyring except Exception: logger.debug("Gnome keyring is not available") return conf = SettingsController.get_instance() prefs = conf.get_prefs() if AUTH_DONT_ASK_KEY in prefs and get_boolean( prefs[AUTH_DONT_ASK_KEY]) == True: return if get_keyring().get_id() == gkeyring.GNOME_KEYRING_ID: return label = Gtk.Label() label.set_markup( _("""<b>Security warning</b> You have gnome-keyring installed but your are using plain text encryption to store your passwords. You can select the encryption method in the preferences dialog. """)) dialog = Gtk.Dialog( APP_LONG_NAME, None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) dialog.set_icon(get_cloudsn_icon()) dialog.vbox.pack_start(label, False, False, 10) checkbox = Gtk.CheckButton(_("Don't ask me again")) checkbox.show() dialog.vbox.pack_end(checkbox, False, False, 0) label.show() response = dialog.run() dialog.destroy() if checkbox.get_active(): conf.set_pref(AUTH_DONT_ASK_KEY, True) conf.save_prefs()
def check_auth_configuration(): try: import gnomekeyring as gk from ..core.keyrings import gkeyring except Exception: logger.debug("Gnome keyring is not available") return conf = SettingsController.get_instance() prefs = conf.get_prefs() if AUTH_DONT_ASK_KEY in prefs and get_boolean(prefs[AUTH_DONT_ASK_KEY]) == True: return if get_keyring().get_id() == gkeyring.GNOME_KEYRING_ID: return label = Gtk.Label() label.set_markup(_("""<b>Security warning</b> You have gnome-keyring installed but your are using plain text encryption to store your passwords. You can select the encryption method in the preferences dialog. """)) dialog = Gtk.Dialog(APP_LONG_NAME, None, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) dialog.set_icon(get_cloudsn_icon()) dialog.vbox.pack_start(label, False, False, 10) checkbox = Gtk.CheckButton(_("Don't ask me again")) checkbox.show() dialog.vbox.pack_end(checkbox, False, False, 0) label.show() response = dialog.run() dialog.destroy() if checkbox.get_active(): conf.set_pref (AUTH_DONT_ASK_KEY, True) conf.save_prefs()