Exemplo n.º 1
0
    def update_account(self, account):
        account.new_unread = []
        notifications = {}
        all_inbox = []
        credentials = account.get_credentials()

        #Main inbox
        all_inbox.append(
            ImapBox(account["host"], credentials.username,
                    credentials.password, account["port"],
                    utils.get_boolean(account["ssl"])))

        if 'labels' in account.get_properties():
            labels = []
            labels += [l.strip() for l in account["labels"].split(",")]
            for l in labels:
                if l != '':
                    all_inbox.append(
                        ImapBox(account["host"], credentials.username,
                                credentials.password, account["port"],
                                utils.get_boolean(account["ssl"]), False, l))

        for g in all_inbox:
            mails = g.get_mails()
            logger.debug("Checking label %s: %i" % (g.mbox_dir, len(mails)))
            for mail_id, sub, fr in mails:
                notifications[mail_id] = sub
                if mail_id not in account.notifications:
                    n = Notification(mail_id, sub, fr)
                    account.new_unread.append(n)

        account.notifications = notifications
    def update_account (self, account):
        account.new_unread = []
        notifications = {}
        all_inbox = []
        credentials = account.get_credentials()

        #Main inbox
        all_inbox.append(ImapBox (account["host"], credentials.username,
            credentials.password, account["port"],
            utils.get_boolean(account["ssl"])))

        if 'labels' in account.get_properties():
            labels = []
            labels += [l.strip() for l in account["labels"].split(",")]
            for l in labels:
                if l != '':
                    all_inbox.append(ImapBox (account["host"], credentials.username,
                        credentials.password, account["port"],
                        utils.get_boolean(account["ssl"]),
                        False, l))

        for g in all_inbox:
            mails = g.get_mails()
            logger.debug("Checking label %s: %i" %(g.mbox_dir, len(mails)))
            for mail_id, sub, fr in mails:
                notifications[mail_id] = sub
                if mail_id not in account.notifications:
                    n = Notification(mail_id, sub, fr)
                    account.new_unread.append (n)

        account.notifications = notifications
 def populate_dialog(self, widget, acc):
     credentials = acc.get_credentials_save()
     self._set_text_value ("Host",acc["host"])
     self._set_text_value ("User", credentials.username)
     self._set_text_value ("Password", credentials.password)
     self._set_text_value ("Port",str(acc["port"]))
     self._set_check_value ("Use SSL",utils.get_boolean(acc["ssl"]))
Exemplo n.º 4
0
 def load(self):
     self.builder = Gtk.Builder()
     self.builder.set_translation_domain("cloudsn")
     self.builder.add_from_file(config.add_data_prefix("imap-account.ui"))
     self.box = self.builder.get_object("container")
     self.labels_store = self.builder.get_object("labels_store")
     self.labels_treeview = self.builder.get_object("labels_treeview")
     self.builder.connect_signals(self)
     if self.account:
         credentials = self.account.get_credentials_save()
         self.builder.get_object("host_entry").set_text(
             self.account["host"])
         self.builder.get_object("username_entry").set_text(
             credentials.username)
         self.builder.get_object("password_entry").set_text(
             credentials.password)
         self.builder.get_object("port_entry").set_text(
             str(self.account["port"]))
         self.builder.get_object("ssl_check").set_active(
             utils.get_boolean(self.account["ssl"]))
         if 'labels' in self.account.get_properties():
             labels = [l.strip() for l in self.account["labels"].split(",")]
             for label in labels:
                 if label != '':
                     siter = self.labels_store.append()
                     self.labels_store.set_value(siter, 0, label)
     return self.box
 def populate_dialog(self, widget, acc):
     credentials = acc.get_credentials_save()
     self._set_text_value("Host", acc["host"])
     self._set_text_value("User", credentials.username)
     self._set_text_value("Password", credentials.password)
     self._set_text_value("Port", str(acc["port"]))
     self._set_check_value("Use SSL", utils.get_boolean(acc["ssl"]))
    def __connect(self, account):
        credentials = account.get_credentials()
        port = 110
        if "port" in account:
            port = int(float(account["port"]))

        if not utils.get_boolean(account["ssl"]):
            mbox = poplib.POP3(account["host"], port)
        else:
            mbox = poplib.POP3_SSL(account["host"], port)
        mbox.user(credentials.username)
        mbox.pass_(credentials.password)

        return mbox
 def __connect(self, account):
     credentials = account.get_credentials()
     port = 110
     if "port" in account:
         port = int(float(account["port"]))
         
     if not utils.get_boolean(account["ssl"]):
         mbox = poplib.POP3(account["host"], port)
     else:
         mbox = poplib.POP3_SSL(account["host"], port)
     mbox.user(credentials.username)
     mbox.pass_(credentials.password)
     
     return mbox
Exemplo n.º 8
0
    def play(self, uri):
        global enabled
        if not enabled:
            return

        if not utils.get_boolean(config.SettingsController.get_instance().get_prefs()["enable_sounds"]):
            return

        if uri and self.playing == False:
            self.player = gst.element_factory_make("playbin", "player")
            uri =  "file://" + uri
            self.player.set_property('uri', uri)
            bus = self.player.get_bus()
            bus.add_signal_watch()
            bus.connect("message", self.on_message)

            self.player.set_state(gst.STATE_PLAYING)
            self.playing = True
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 load(self):
     self.builder=Gtk.Builder()
     self.builder.set_translation_domain("cloudsn")
     self.builder.add_from_file(config.add_data_prefix("imap-account.ui"))
     self.box = self.builder.get_object("container")
     self.labels_store = self.builder.get_object("labels_store")
     self.labels_treeview = self.builder.get_object("labels_treeview")
     self.builder.connect_signals(self)
     if self.account:
         credentials = self.account.get_credentials_save()
         self.builder.get_object("host_entry").set_text(self.account["host"])
         self.builder.get_object("username_entry").set_text(credentials.username)
         self.builder.get_object("password_entry").set_text(credentials.password)
         self.builder.get_object("port_entry").set_text(str(self.account["port"]))
         self.builder.get_object("ssl_check").set_active(utils.get_boolean(self.account["ssl"]))
         if 'labels' in self.account.get_properties():
             labels = [l.strip() for l in self.account["labels"].split(",")]
             for label in labels:
                 if label != '':
                     siter = self.labels_store.append()
                     self.labels_store.set_value(siter, 0, label)
     return self.box
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()
Exemplo n.º 12
0
 def get_active(self):
     return utils.get_boolean(self.properties["active"])
Exemplo n.º 13
0
 def set_show_notifications(self, show_notifications):
     self.properties["show_notifications"] = utils.get_boolean(
         show_notifications)
Exemplo n.º 14
0
 def get_show_notifications(self):
     return utils.get_boolean(self.properties["show_notifications"])
Exemplo n.º 15
0
 def _set_check_value(self, label, value):
     return get_widget_by_label(self.box,
                                label).set_active(utils.get_boolean(value))
Exemplo n.º 16
0
    def preferences_action_activate_cb(self, widget, data=None):
        self.pref_dialog = self.builder.get_object("preferences_dialog")
        self.pref_dialog.set_transient_for(self.window)
        self.pref_dialog.set_destroy_with_parent(True)
        indicator_combo = self.builder.get_object("indicator_combo")
        indicators_store = self.builder.get_object("indicators_store")
        keyring_combo = self.builder.get_object("keyring_combo")
        keyring_store = self.builder.get_object("keyring_store")
        minutes = self.builder.get_object("minutes_spin")
        max_not_spin = self.builder.get_object("max_not_spin")
        startup_check = self.builder.get_object("startup_check")
        enable_sounds_check = self.builder.get_object("enable_sounds_check")

        minutes.set_value(float(self.config.get_prefs()["minutes"]))
        max_not_spin.set_value(
            float(self.config.get_prefs()["max_notifications"]))
        if os.path.exists(config.get_startup_file_path()):
            startup_check.set_active(True)
        else:
            startup_check.set_active(False)

        enable_sounds_check.set_active(
            coreutils.get_boolean(self.config.get_prefs()["enable_sounds"]))

        #Populate indicator combo
        i = 0
        indicator_name = self.config.get_prefs()["indicator"]
        indicators_store.clear()
        for indi in self.im.get_indicators():
            indicators_store.append([indi.get_name()])
            if indi.get_name() == indicator_name:
                indicator_combo.set_active(i)
            i += 1
        i = 0
        keyring_id = self.config.get_prefs()["keyring"]
        keyring_store.clear()
        for k in self.km.get_managers():
            keyring_store.append([k.get_name(), k.get_id()])
            if k.get_id() == keyring_id:
                keyring_combo.set_active(i)
            i += 1
        response = self.pref_dialog.run()
        self.pref_dialog.hide()
        self.config.set_pref("minutes", minutes.get_value())
        self.config.set_pref("max_notifications", max_not_spin.get_value())
        self.config.set_pref("enable_sounds", enable_sounds_check.get_active())
        iiter = indicator_combo.get_active_iter()
        if iiter:
            self.config.set_pref("indicator",
                                 indicators_store.get_value(iiter, 0))
        iiter = keyring_combo.get_active_iter()

        selected = keyring_store.get_value(iiter, 1)
        for m in self.km.get_managers():
            logger.debug("selected %s, current %s" % (selected, m.get_id()))
            if m.get_id() == selected:
                self.km.set_manager(m)
                break

        self.config.set_pref("keyring", selected)

        #Check startup checkbox
        if startup_check.get_active():
            if not os.path.exists(config.get_startup_file_path()):
                if not os.path.exists(config.get_startup_file_dir()):
                    os.makedirs(config.get_startup_file_dir())
                shutil.copyfile(config.add_data_prefix("cloudsn.desktop"),
                                config.get_startup_file_path())
        else:
            if os.path.exists(config.get_startup_file_path()):
                os.remove(config.get_startup_file_path())

        self.config.save_prefs()
Exemplo n.º 17
0
    def preferences_action_activate_cb (self, widget, data=None):
        self.pref_dialog = self.builder.get_object("preferences_dialog")
        self.pref_dialog.set_transient_for(self.window)
        self.pref_dialog.set_destroy_with_parent (True)
        indicator_combo = self.builder.get_object("indicator_combo")
        indicators_store = self.builder.get_object("indicators_store");
        keyring_combo = self.builder.get_object("keyring_combo")
        keyring_store = self.builder.get_object("keyring_store");
        minutes=self.builder.get_object("minutes_spin")
        max_not_spin=self.builder.get_object("max_not_spin")
        startup_check = self.builder.get_object("startup_check")
        enable_sounds_check = self.builder.get_object("enable_sounds_check")

        minutes.set_value (float(self.config.get_prefs()["minutes"]))
        max_not_spin.set_value (float(self.config.get_prefs()["max_notifications"]))
        if os.path.exists(config.get_startup_file_path()):
            startup_check.set_active(True)
        else:
            startup_check.set_active(False)

        enable_sounds_check.set_active(coreutils.get_boolean(self.config.get_prefs()["enable_sounds"]))

        #Populate indicator combo
        i=0
        indicator_name = self.config.get_prefs()["indicator"]
        indicators_store.clear()
        for indi in self.im.get_indicators():
            indicators_store.append([indi.get_name()])
            if indi.get_name() == indicator_name:
                indicator_combo.set_active(i)
            i+=1
        i=0
        keyring_id = self.config.get_prefs()["keyring"]
        keyring_store.clear()
        for k in self.km.get_managers():
            keyring_store.append([k.get_name(), k.get_id()])
            if k.get_id() == keyring_id:
                keyring_combo.set_active(i)
            i+=1
        response = self.pref_dialog.run()
        self.pref_dialog.hide()
        self.config.set_pref ("minutes", minutes.get_value())
        self.config.set_pref ("max_notifications", max_not_spin.get_value())
        self.config.set_pref ("enable_sounds", enable_sounds_check.get_active())
        iiter = indicator_combo.get_active_iter()
        if iiter:
            self.config.set_pref ("indicator", indicators_store.get_value(iiter,0))
        iiter = keyring_combo.get_active_iter()

        selected = keyring_store.get_value(iiter,1)
        for m in self.km.get_managers():
            logger.debug("selected %s, current %s" % (selected, m.get_id()))
            if m.get_id() == selected:
                self.km.set_manager(m)
                break

        self.config.set_pref ("keyring", selected)

        #Check startup checkbox
        if startup_check.get_active():
            if not os.path.exists(config.get_startup_file_path()):
                if not os.path.exists(config.get_startup_file_dir()):
                    os.makedirs(config.get_startup_file_dir())
                shutil.copyfile(config.add_data_prefix("cloudsn.desktop"),
                    config.get_startup_file_path())
        else:
            if os.path.exists(config.get_startup_file_path()):
                os.remove (config.get_startup_file_path())

        self.config.save_prefs()
Exemplo n.º 18
0
 def get_active (self):
     return utils.get_boolean(self.properties["active"])
Exemplo n.º 19
0
 def set_show_notifications(self, show_notifications):
     self.properties["show_notifications"] = utils.get_boolean(show_notifications)
Exemplo n.º 20
0
 def get_show_notifications(self):
     return utils.get_boolean(self.properties["show_notifications"])
 def _set_check_value (self, label, value):
     return get_widget_by_label(self.box, label).set_active(utils.get_boolean(value))
 def __init__(self, data):
     self.feed_num = int(data[0])
     self.feed_id = data[1]
     self.feed_read = utils.get_boolean(data[2])
 def populate_dialog(self, widget, acc):
     self._set_text_value ("Host",acc["host"])
     self._set_text_value ("User",acc["username"])
     self._set_text_value ("Password", acc["password"])
     self._set_text_value ("Port",str(acc["port"]))
     self._set_check_value ("Use SSL",utils.get_boolean(acc["ssl"]))
Exemplo n.º 24
0
 def set_active(self, active):
     self.properties["active"] = utils.get_boolean(active)
Exemplo n.º 25
0
 def set_active(self, active):
     self.properties["active"] = utils.get_boolean(active)
Exemplo n.º 26
0
 def __init__(self, data):
     self.feed_num = int(data[0])
     self.feed_id = data[1]
     self.feed_read = utils.get_boolean(data[2])