Example #1
0
    def set_account_data(self, account_name):
        host = self.builder.get_object("host_entry").get_text()
        port = self.builder.get_object("port_entry").get_text()
        username = self.builder.get_object("username_entry").get_text()
        password = self.builder.get_object("password_entry").get_text()
        ssl = self.builder.get_object("ssl_check").get_active()
        if host == '' or username == '' or password == '':
            raise Exception(
                _("The host, user name and the password are mandatory"))

        if not self.account:
            props = {
                "name": account_name,
                "provider_name": self.provider.get_name(),
                "host": host,
                "port": port,
                "ssl": ssl,
                "labels": self.__get_labels()
            }
            self.account = AccountCacheMails(props, self.provider)
            self.account.notifications = {}
        else:
            self.account["host"] = host
            self.account["port"] = port
            self.account["ssl"] = ssl
            self.account["labels"] = self.__get_labels()

        credentials = Credentials(username, password)
        self.account.set_credentials(credentials)

        return self.account
    def load_account(self, props):
        acc = AccountCacheMails(props, self)
        
        #Hack for gmail domains like mail.quiter.com
        user, tmp, domain = acc.properties['username'].partition('@')

        if domain and domain != "gmail.com":
            activate_url = "https://mail.google.com/a/" + domain
        else:
            activate_url = "https://mail.google.com/a/" 

        acc.properties["activate_url"] = activate_url
        return acc
    def set_account_data_from_widget(self, account_name, widget, account=None):
        username = self.builder.get_object("username_entry").get_text()
        password = self.builder.get_object("password_entry").get_text()
        if not account:
            props = {"name" : account_name, "provider_name" : self.get_name(),
                     "labels" : self.__get_labels()}
            account = AccountCacheMails(props, self)
            account.notifications = {}
        else:
            account["labels"] = self.__get_labels()

        credentials = Credentials(username, password)
        account.set_credentials(credentials)

        return account
Example #4
0
class GMailAccount(AccountCacheMails):
    def __init__(self, properties, provider):
        AccountCacheMails.__init__(self, properties, provider)

    def get_total_unread(self):
        return self.total_unread

    def activate(self):
        #Hack for gmail domains like mail.quiter.com
        #TODO check this when the user change the configuration too
        domain = None
        try:
            user, tmp, domain = self.get_credentials().username.partition('@')
        except Exception, e:
            logger.exception(
                "Cannot load credentials for account " + acc.get_name() +
                ", continue: %s", e)

        if domain and domain != "gmail.com":
            activate_url = "https://mail.google.com/a/" + domain
        else:
            activate_url = "https://mail.google.com/a/"

        self.properties["activate_url"] = activate_url

        AccountCacheMails.activate(self)
 def set_account_data_from_widget(self, account_name, widget, account=None):
     if not account:
         username = self.builder.get_object("username_entry").get_text()
         password = self.builder.get_object("password_entry").get_text()
         props = {"name" : account_name, "provider_name" : self.get_name(),
             "username" : username, "password" : password, 
             "activate_url" : "http://gmail.google.com",
             "labels" : self.__get_labels()}
         account = AccountCacheMails(props, self)
         account.notifications = {}
     else:
         account["username"] = self.builder.get_object("username_entry").get_text()
         account["password"] = self.builder.get_object("password_entry").get_text()
         account["labels"] = self.__get_labels()
         
     return account
    def set_account_data (self, account_name):
        host = self.builder.get_object("host_entry").get_text()
        port = self.builder.get_object("port_entry").get_text()
        username = self.builder.get_object("username_entry").get_text()
        password = self.builder.get_object("password_entry").get_text()
        ssl = self.builder.get_object("ssl_check").get_active()
        if host=='' or username=='' or password=='':
            raise Exception(_("The host, user name and the password are mandatory"))

        if not self.account:
            props = {"name" : account_name, "provider_name" : self.provider.get_name(),
                "host": host, "port": port, "ssl": ssl,
                "labels" : self.__get_labels()}
            self.account = AccountCacheMails(props, self.provider)
            self.account.notifications = {}
        else:
            self.account["host"] = host
            self.account["port"] = port
            self.account["ssl"] = ssl
            self.account["labels"] = self.__get_labels()

        credentials = Credentials(username, password)
        self.account.set_credentials(credentials)

        return self.account
 def load_account(self, props):
     acc = AccountCacheMails(props, self)
     if not "port" in acc:
         acc["port"] = 110
     if not "ssl" in acc:
         acc["ssl"] = False
     return acc
Example #8
0
    def set_account_data (self, account_name):
        pin = self.pin_entry.get_text()
        if pin=='':
            raise Exception(_("The PIN is mandatory to set the Twitter account"))

        self.auth.get_access_token(pin)
        access_key = self.auth.access_token.key
        access_secret = self.auth.access_token.secret
        if not self.account:
            props = {"name" : account_name, "provider_name" : self.provider.get_name()}
            self.account = AccountCacheMails(props, self.provider)
            self.account.notifications = {}

        credentials = Credentials(access_key, access_secret)
        self.account.set_credentials(credentials)

        return self.account
Example #9
0
class TwitterPrefs:
    def __init__(self, account, provider):
        self.account = account
        self.provider = provider

    def load(self):
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain("cloudsn")
        self.builder.add_from_file(
            config.add_data_prefix("twitter-account.ui"))
        self.box = self.builder.get_object("container")
        self.permission_button = self.builder.get_object("permission_button")
        self.pin_entry = self.builder.get_object("pin_entry")

        self.auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
        auth_url = self.auth.get_authorization_url()
        self.permission_button.set_uri(auth_url)

        self.builder.connect_signals(self)
        if self.account:
            #Do not support editting
            pass
        return self.box

    def set_account_data(self, account_name):
        pin = self.pin_entry.get_text()
        if pin == '':
            raise Exception(
                _("The PIN is mandatory to set the Twitter account"))

        self.auth.get_access_token(pin)
        access_key = self.auth.access_token.key
        access_secret = self.auth.access_token.secret
        if not self.account:
            props = {
                "name": account_name,
                "provider_name": self.provider.get_name()
            }
            self.account = AccountCacheMails(props, self.provider)
            self.account.notifications = {}

        credentials = Credentials(access_key, access_secret)
        self.account.set_credentials(credentials)

        return self.account
Example #10
0
    def set_account_data_from_widget(self, account_name, widget, account=None):
        username = self.builder.get_object("username_entry").get_text()
        password = self.builder.get_object("password_entry").get_text()
        if not account:
            props = {
                "name": account_name,
                "provider_name": self.get_name(),
                "labels": self.__get_labels()
            }
            account = AccountCacheMails(props, self)
            account.notifications = {}
        else:
            account["labels"] = self.__get_labels()

        credentials = Credentials(username, password)
        account.set_credentials(credentials)

        return account
class TwitterPrefs:

    def __init__(self, account, provider):
        self.account = account
        self.provider = provider

    def load(self):
        self.builder=Gtk.Builder()
        self.builder.set_translation_domain("cloudsn")
        self.builder.add_from_file(config.add_data_prefix("twitter-account.ui"))
        self.box = self.builder.get_object("container")
        self.permission_button = self.builder.get_object("permission_button")
        self.pin_entry = self.builder.get_object("pin_entry")

        self.auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
        auth_url = self.auth.get_authorization_url()
        self.permission_button.set_uri(auth_url)

        self.builder.connect_signals(self)
        if self.account:
            #Do not support editting
            pass
        return self.box

    def set_account_data (self, account_name):
        pin = self.pin_entry.get_text()
        if pin=='':
            raise Exception(_("The PIN is mandatory to set the Twitter account"))

        self.auth.get_access_token(pin)
        access_key = self.auth.access_token.key
        access_secret = self.auth.access_token.secret
        if not self.account:
            props = {"name" : account_name, "provider_name" : self.provider.get_name()}
            self.account = AccountCacheMails(props, self.provider)
            self.account.notifications = {}

        credentials = Credentials(access_key, access_secret)
        self.account.set_credentials(credentials)

        return self.account
    def set_account_data (self, account_name):
        pin = self.pin_entry.get_text()
        if pin=='':
            raise Exception(_("The PIN is mandatory to set the Twitter account"))

        self.auth.get_access_token(pin)
        access_key = self.auth.access_token.key
        access_secret = self.auth.access_token.secret
        if not self.account:
            props = {"name" : account_name, "provider_name" : self.provider.get_name()}
            self.account = AccountCacheMails(props, self.provider)
            self.account.notifications = {}

        credentials = Credentials(access_key, access_secret)
        self.account.set_credentials(credentials)

        return self.account
Example #13
0
 def load_account(self, props):
     return AccountCacheMails(props, self)
 def __init__(self, properties, provider):
     AccountCacheMails.__init__(self, properties, provider)
class ImapPrefs:

    def __init__(self, account, provider):
        self.account = account
        self.provider = provider

    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 set_account_data (self, account_name):
        host = self.builder.get_object("host_entry").get_text()
        port = self.builder.get_object("port_entry").get_text()
        username = self.builder.get_object("username_entry").get_text()
        password = self.builder.get_object("password_entry").get_text()
        ssl = self.builder.get_object("ssl_check").get_active()
        if host=='' or username=='' or password=='':
            raise Exception(_("The host, user name and the password are mandatory"))

        if not self.account:
            props = {"name" : account_name, "provider_name" : self.provider.get_name(),
                "host": host, "port": port, "ssl": ssl,
                "labels" : self.__get_labels()}
            self.account = AccountCacheMails(props, self.provider)
            self.account.notifications = {}
        else:
            self.account["host"] = host
            self.account["port"] = port
            self.account["ssl"] = ssl
            self.account["labels"] = self.__get_labels()

        credentials = Credentials(username, password)
        self.account.set_credentials(credentials)

        return self.account

    def __get_labels(self):
        labels = []
        def add(model, path, siter, labels):
            label = model.get_value(siter, 0)
            labels.append(label)
        self.labels_store.foreach(add, labels)
        labels_string = ""
        for label in labels:
            labels_string += label + ","
        return labels_string[:len(labels_string)-1]

    def add_label_button_clicked_cb (self, widget, data=None):
        siter = self.labels_store.append()
        self.labels_store.set_value(siter, 0, _("Type the label name here"))
        selection = self.labels_treeview.get_selection()
        selection.select_iter(siter)
        model, path_list = selection.get_selected_rows()
        path = path_list[0]
        self.labels_treeview.grab_focus()
        self.labels_treeview.set_cursor(path,self.labels_treeview.get_column(0), True)


    def del_label_button_clicked_cb (self, widget, data=None):
        selection = self.labels_treeview.get_selection()
        model, path_list = selection.get_selected_rows()
        if path_list:
            path = path_list[0]
            siter = model.get_iter(path)
            self.labels_store.remove(siter)

    def label_cell_edited_cb(self, cell, path, new_text):
        siter = self.labels_store.get_iter((int(path), ))
        self.labels_store.set_value(siter, 0, new_text)
Example #16
0
class ImapPrefs:
    def __init__(self, account, provider):
        self.account = account
        self.provider = provider

    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 set_account_data(self, account_name):
        host = self.builder.get_object("host_entry").get_text()
        port = self.builder.get_object("port_entry").get_text()
        username = self.builder.get_object("username_entry").get_text()
        password = self.builder.get_object("password_entry").get_text()
        ssl = self.builder.get_object("ssl_check").get_active()
        if host == '' or username == '' or password == '':
            raise Exception(
                _("The host, user name and the password are mandatory"))

        if not self.account:
            props = {
                "name": account_name,
                "provider_name": self.provider.get_name(),
                "host": host,
                "port": port,
                "ssl": ssl,
                "labels": self.__get_labels()
            }
            self.account = AccountCacheMails(props, self.provider)
            self.account.notifications = {}
        else:
            self.account["host"] = host
            self.account["port"] = port
            self.account["ssl"] = ssl
            self.account["labels"] = self.__get_labels()

        credentials = Credentials(username, password)
        self.account.set_credentials(credentials)

        return self.account

    def __get_labels(self):
        labels = []

        def add(model, path, siter, labels):
            label = model.get_value(siter, 0)
            labels.append(label)

        self.labels_store.foreach(add, labels)
        labels_string = ""
        for label in labels:
            labels_string += label + ","
        return labels_string[:len(labels_string) - 1]

    def add_label_button_clicked_cb(self, widget, data=None):
        siter = self.labels_store.append()
        self.labels_store.set_value(siter, 0, _("Type the label name here"))
        selection = self.labels_treeview.get_selection()
        selection.select_iter(siter)
        model, path_list = selection.get_selected_rows()
        path = path_list[0]
        self.labels_treeview.grab_focus()
        self.labels_treeview.set_cursor(path,
                                        self.labels_treeview.get_column(0),
                                        True)

    def del_label_button_clicked_cb(self, widget, data=None):
        selection = self.labels_treeview.get_selection()
        model, path_list = selection.get_selected_rows()
        if path_list:
            path = path_list[0]
            siter = model.get_iter(path)
            self.labels_store.remove(siter)

    def label_cell_edited_cb(self, cell, path, new_text):
        siter = self.labels_store.get_iter((int(path), ))
        self.labels_store.set_value(siter, 0, new_text)
Example #17
0
 def load_account(self, props):
     acc = AccountCacheMails(props, self)
     acc.properties["activate_url"] = "http://reader.google.com"
     return acc
Example #18
0
 def __init__(self, properties, provider):
     AccountCacheMails.__init__(self, properties, provider)
 def load_account(self, props):
     acc = AccountCacheMails(props, self)
     acc.properties["activate_url"] = "http://reader.google.com"
     return acc