Beispiel #1
0
    def info(self):
        "Returns a Storage containing the attributes edited by this dialog."

        info = Storage(name=self.name.Value, protocol=self.protocol_name)

        info.protocol, info.name = strip_acct_id(info.protocol, info.name)

        if hasattr(self, "password"):
            info.password_len = len(self.password.Value)
            try:
                info.password = profile.crypt_pw(self.password.Value)
            except UnicodeEncodeError:
                # the database has corrupted the password.
                log.warning("corrupted password")
                info.password = ""
                self.password.Value = ""
                import hub

                hub.get_instance().on_error(
                    "This account's password has been corrupted somehow. Please report it immediately."
                )

        if hasattr(self, "host"):
            info.server = (self.host.Value, int(self.port.Value) if self.port.Value else "")

        if hasattr(self, "remote_alias"):
            info.remote_alias = self.remote_alias.Value

        if hasattr(self, "autologin"):
            info.autologin = bool(self.autologin.Value)

        if hasattr(self, "resource"):
            info.update(
                resource=self.resource.Value,
                priority=try_this(lambda: int(self.priority.Value), DEFAULT_JABBER_PRIORITY),
            )
        #                        ,
        #                        confserver = self.confserver.Value
        if hasattr(self, "dataproxy"):
            info.update(dataproxy=self.dataproxy.Value)

        for d in getattr(self.protocolinfo, "more_details", []):
            attr = d["store"]
            ctrl = getattr(self, attr)
            info[attr] = ctrl.Value

        getattr(self, "info_" + self.formtype, lambda *a: {})(info)

        for info_cb in self.info_callbacks:
            info_cb(info)

        defaults = self.protocolinfo.get("defaults", {})
        for k in defaults:
            if k not in info:
                info[k] = getattr(self.account, k, defaults.get(k))

        return info
Beispiel #2
0
    def info(self):
        'Returns a Storage containing the attributes edited by this dialog.'

        info = Storage(name = self.name.Value,
                       protocol = self.protocol_name)

        info.protocol, info.name = strip_acct_id(info.protocol, info.name)

        if hasattr(self, 'password'):
            info.password_len = len(self.password.Value)
            try:
                info.password = profile.crypt_pw(self.password.Value)
            except UnicodeEncodeError:
                # the database has corrupted the password.
                log.warning('corrupted password')
                info.password = ''
                self.password.Value = ''
                import hub
                hub.get_instance().on_error('This account\'s password has been corrupted somehow. Please report it immediately.')

        if hasattr(self, 'host'):
            info.server = (self.host.Value, int(self.port.Value) if self.port.Value else '')

        if hasattr(self, 'remote_alias'):
            info.remote_alias = self.remote_alias.Value

        if hasattr(self, 'autologin'):
            info.autologin = bool(self.autologin.Value)

        if hasattr(self, 'resource'):
            info.update(resource = self.resource.Value,
                        priority = try_this(lambda: int(self.priority.Value), DEFAULT_JABBER_PRIORITY))
#                        ,
#                        confserver = self.confserver.Value
        if hasattr(self, 'dataproxy'):
            info.update(dataproxy = self.dataproxy.Value)

        for d in getattr(self.protocolinfo, 'more_details', []):
            attr = d['store']
            ctrl = getattr(self, attr)
            info[attr] = ctrl.Value

        getattr(self, 'info_' + self.formtype, lambda *a: {})(info)

        for info_cb in self.info_callbacks:
            info_cb(info)

        defaults = self.protocolinfo.get('defaults', {})
        for k in defaults:
            if k not in info:
                info[k] = getattr(self.account, k, defaults.get(k))

        return info