예제 #1
0
    def delete_from_server(self, password, on_success, on_fail):
        import jabber
        if not issubclass(self.protocol_class(), jabber.protocol):
            return log.warning('cannot delete from server: %r is not a jabber subclass', self.protocol_class())

        if password != profile.plain_pw(self.password):
            log.error("password didn't match: %r %r", password, profile.plain_pw(self.password))
            return on_fail()
        if self.connection is None:
            log.error('connection was None')
            return on_fail()

        self.connection.delete_account(on_success=on_success, on_fail=on_fail)
예제 #2
0
    def _unglue_pw(cls, password):
        passwordstr = profile.plain_pw(password).encode("utf-8")
        if passwordstr:
            password, r = unpack_pstr(passwordstr)
            try:
                smtppassword, r = unpack_pstr(r)
            except Exception:
                smtppassword, r = "", ""
        else:
            raise ValueError("Can't decrypt %r", password)

        return profile.crypt_pw(password.decode("utf-8")), profile.crypt_pw(smtppassword.decode("utf-8"))
예제 #3
0
 def _decryptedpw(self):
     return profile.plain_pw(self.password)
예제 #4
0
 def _decrypted_smtppw(self):
     return profile.plain_pw(self._encrypted_smtppw)
예제 #5
0
 def _glue_pw(cls, encrypted_pw, encrypted_smtppw):
     password = pack_pstr(profile.plain_pw(encrypted_pw).encode("utf-8")).decode("utf-8")
     smtppw = pack_pstr(profile.plain_pw(encrypted_smtppw).encode("utf-8")).decode("utf-8")
     return profile.crypt_pw(password + smtppw)
예제 #6
0
            )
        )
        return opts

    @classmethod
    def from_net(cls, info):
        password = info.password  # IS BOTH, NEEDS TO BE ONE
        try:
            encrypted_pw, encrypted_smtppw = cls._unglue_pw(password)
        except Exception, e:
            traceback.print_exc()
            assert SMTP_UPGRADING
            encrypted_pw = password
            encrypted_smtppw = u""
        info.password = encrypted_pw
        smtppw = profile.plain_pw(encrypted_smtppw)
        return EmailAccount.from_net(info, smtp_password=smtppw)

    @threaded
    def send_email(self, to="", subject="", body="", cc="", bcc=""):
        un = self.smtp_username or self.username
        f = self.from_name
        password = self._decrypted_smtppw() or (self._decryptedpw() if not self.smtp_username else "")
        srv = self.smtp_server
        if srv in ("smtp.aol.com", "smtp.aim.com"):
            if un.endswith("aol.com") or un.endswith("aim.com"):
                f = un
            else:
                f = un + u"@aol.com"
        s = SMTPsender(un, password, srv, from_name=f, use_tls=self.smtp_require_ssl)
        s.send_email(to=to, subject=subject, body=body, cc=cc, bcc=bcc)
예제 #7
0
파일: smtp.py 프로젝트: sgricci/digsby
        opts.update(dict((a, getattr(self, a)) for a in
            'smtp_server smtp_port smtp_require_ssl smtp_username email_address'.split()))
        return opts

    @classmethod
    def from_net(cls, info):
        password = info.password #IS BOTH, NEEDS TO BE ONE
        try:
            encrypted_pw, encrypted_smtppw = cls._unglue_pw(password)
        except Exception, e:
            traceback.print_exc()
            assert SMTP_UPGRADING
            encrypted_pw = password
            encrypted_smtppw = u''
        info.password = encrypted_pw
        smtppw = profile.plain_pw(encrypted_smtppw)
        return EmailAccount.from_net(info, smtp_password=smtppw)

    @threaded
    def send_email(self, to='', subject='', body='', cc='', bcc=''):
        un  = self.smtp_username or self.username
        f   = self.from_name
        password   = self._decrypted_smtppw() or (self._decryptedpw() if not self.smtp_username else '')
        srv = self.smtp_server
        if srv in ("smtp.aol.com", "smtp.aim.com"):
            if un.endswith('aol.com') or un.endswith('aim.com'):
                f = un
            else:
                f = un + u'@aol.com'
        s = SMTPsender(un, password, srv, from_name=f, use_tls=self.smtp_require_ssl)
        s.send_email(to=to, subject=subject, body=body, cc=cc, bcc=bcc)
예제 #8
0
 def _decryptedpw(self):
     return profile.plain_pw(self.password)