Esempio n. 1
0
def validate(info, MSP, is_new):
    '''
    If user enters more than 16 characters for password, show a warning. Microsoft doesn't currently allow more than 16 chars for passwords,
    but legacy passwords may exist, so users must be allowed to enter them.

    For user safety, we also make sure they have not entered the same thing in their password and remote alias fields.
    '''
    valid = hooks.first('digsby.services.validate',
                        info,
                        MSP,
                        is_new,
                        impl="digsby_service_editor",
                        raise_hook_exceptions=True)

    password = info.get('_real_password_')
    if password is not None:
        if len(password) > 16:
            raise SP.AccountException(
                _("Password should be 16 characters or less."), fatal=False)

    remote_alias = info.get('remote_alias')
    if remote_alias is not None:
        if password == remote_alias:
            raise SP.AccountException(
                _("You can't have your password as your display name."))

    return valid
Esempio n. 2
0
    def update_info(self, kwds):
        if '_encrypted_smtppw' in kwds and '_encrypted_pw' in kwds:
            kwds['password'] = self._encrypted_pw = e_pw = kwds['_encrypted_pw']
            self._encrypted_smtppw = e_spw = kwds['_encrypted_smtppw']
            kwds['smtp_password'] = common.profile.plain_pw(e_spw)

        elif 'password' in kwds:
            try:
                self._encrypted_pw, self._encrypted_smtppw = smtp.SMTPEmailAccount._unglue_pw(kwds.get('password', ''))
                kwds['smtp_password'] = common.profile.plain_pw(self._encrypted_smtppw)
                kwds['password'] = self._encrypted_pw
            except ValueError:
                if 'smtp_password' in kwds:
                    self._encrypted_smtppw = common.profile.crypt_pw(kwds['smtp_password'])
                else:
                    self._encrypted_smtppw = ''
                self._encrypted_pw = kwds['password']

        self.smtp_require_ssl = kwds.get('smtp_require_ssl')

        if 'email_address' in kwds:
            self.email_address = kwds.get('email_address', self.name)
        if 'smtp_username' in kwds:
            self.smtp_username = kwds.get('smtp_username', self.name)
        if kwds.get('smtp_server'):
            self.smtp_server = kwds.get('smtp_server', '')
        else:
            log.debug("smtp_server not provided")
            raise SP.AccountException()
        if 'smtp_port' in kwds:
            try:
                kwds['smtp_port'] = int(kwds['smtp_port'])

            except ValueError:
                log.error("port is not an int, it is %r", kwds['smtp_port'])
                raise SP.AccountException()
        else:
            kwds['smtp_port'] = self.get_metainfo('email')[1].info.defaults['smtp_port_ssl' if self.smtp_require_ssl else 'smtp_port']

        self.smtp_port = kwds.get('smtp_port')

        super(SMTPServiceProvider, self).update_info(kwds)

        mailclient = kwds.get('mailclient', None)
        if mailclient is None and not hasattr(self, 'mailclient'):
            self.mailclient = 'sysdefault'
        custom_inbox_url = kwds.get('custom_inbox_url', None)
        if custom_inbox_url is None and not hasattr(self, 'custom_inbox_url'):
            self.custom_inbox_url = u''
        custom_compose_url = kwds.get('custom_compose_url', None)
        if custom_compose_url is None and not hasattr(self, 'custom_compose_url'):
            self.custom_compose_url = u''
Esempio n. 3
0
def validate(info, MSP, is_new):
    spc = SP.ServiceProviderContainer(common.profile())
    if is_new and spc.has_account(info):
        raise SP.AccountException(_("That account already exists."))

    try:
        sp = hooks.first('digsby.service_provider',
                         impl=MSP.provider_id,
                         raise_hook_exceptions=True,
                         **info)
    except SP.AccountException, e:
        raise e
Esempio n. 4
0
    def update_info(self, info):
        self.require_ssl = info.get('require_ssl')

        if 'imapport' in info:
            try:
                info['imapport'] = int(info['imapport'])
            except ValueError:
                log.error("port is not an int, it is %r", info['imapport'])
                raise SP.AccountException()
            if 'imapport' in info:
                self.imapport = info['imapport']
        else:
            if not hasattr(self, 'imapport'):
                self.imapport = self.get_metainfo('email')[1].info.defaults['imapport_ssl' if self.require_ssl else 'imapport']

        if not info.get('imapserver'):
            log.debug("imapserver not provided")
            raise SP.AccountException()

        self.imapserver = info['imapserver']

        super(IMAPServiceProvider, self).update_info(info)
Esempio n. 5
0
def validate_icq(info, MSP, is_new):
    valid = hooks.first('digsby.services.validate',
                        info,
                        MSP,
                        is_new,
                        impl="digsby_service_editor",
                        raise_hook_exceptions=True)

    password = info.get('_real_password_')
    if password is not None:
        if len(password) > 8:
            raise SP.AccountException(
                _("Password should be 8 characters or less."), fatal=False)
Esempio n. 6
0
def validate(info, MSP, is_new):
    spc = SP.ServiceProviderContainer(common.profile())
    if is_new and spc.has_account(info):
        raise SP.AccountException(_("That account already exists."))

    try:
        sp = hooks.first('digsby.service_provider',
                         impl=MSP.provider_id,
                         raise_hook_exceptions=True,
                         **info)
    except SP.AccountException, e:
        raise e
    except Exception, e:
        import traceback
        traceback.print_exc()
        raise SP.AccountException(e.args[0] if e.args else "Unknown error",
                                  True)

    return True


def normalize(info, MSP, is_new):

    return info


def colorize_name(name):
    # The sum of the strings returned by this should be less
    # than or equal to the length of the input
    if '@' in name:
        split = name.split('@', 1)
        return (('name', split[0]), ('base', '@' + split[1]))