diff options
author | Kali Kaneko <kali@leap.se> | 2015-09-14 23:19:58 -0400 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2015-09-16 02:00:27 +0200 |
commit | 0a03c0a014b1874114eabb855705ca79f09d1982 (patch) | |
tree | ea10d37ba6b21a91636daf96163c79f62ac73179 /src/leap/mail/outgoing/service.py | |
parent | cf7906eda74ad73d026f1a2a29b3581d72abb473 (diff) |
[feat] use async events api
in this way, we're using twisted reactor instead of having another
thread with zmq's own copy of tornado ioloop.
Resolves: #7274
Diffstat (limited to 'src/leap/mail/outgoing/service.py')
-rw-r--r-- | src/leap/mail/outgoing/service.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/leap/mail/outgoing/service.py b/src/leap/mail/outgoing/service.py index 838a908..3708f33 100644 --- a/src/leap/mail/outgoing/service.py +++ b/src/leap/mail/outgoing/service.py @@ -31,7 +31,7 @@ from twisted.protocols.amp import ssl from twisted.python import log from leap.common.check import leap_assert_type, leap_assert -from leap.common.events import emit, catalog +from leap.common.events import emit_async, catalog from leap.keymanager.openpgp import OpenPGPKey from leap.keymanager.errors import KeyNotFound, KeyAddressMismatch from leap.mail import __version__ @@ -135,7 +135,7 @@ class OutgoingMail: """ dest_addrstr = smtp_sender_result[1][0][0] log.msg('Message sent to %s' % dest_addrstr) - emit(catalog.SMTP_SEND_MESSAGE_SUCCESS, dest_addrstr) + emit_async(catalog.SMTP_SEND_MESSAGE_SUCCESS, dest_addrstr) def sendError(self, failure): """ @@ -145,7 +145,7 @@ class OutgoingMail: :type e: anything """ # XXX: need to get the address from the exception to send signal - # emit(catalog.SMTP_SEND_MESSAGE_ERROR, self._user.dest.addrstr) + # emit_async(catalog.SMTP_SEND_MESSAGE_ERROR, self._user.dest.addrstr) err = failure.value log.err(err) raise err @@ -178,7 +178,7 @@ class OutgoingMail: requireAuthentication=False, requireTransportSecurity=True) factory.domain = __version__ - emit(catalog.SMTP_SEND_MESSAGE_START, recipient.dest.addrstr) + emit_async(catalog.SMTP_SEND_MESSAGE_START, recipient.dest.addrstr) reactor.connectSSL( self._host, self._port, factory, contextFactory=SSLContextFactory(self._cert, self._key)) @@ -240,7 +240,7 @@ class OutgoingMail: return d def signal_encrypt_sign(newmsg): - emit(catalog.SMTP_END_ENCRYPT_AND_SIGN, + emit_async(catalog.SMTP_END_ENCRYPT_AND_SIGN, "%s,%s" % (self._from_address, to_address)) return newmsg, recipient @@ -248,18 +248,18 @@ class OutgoingMail: failure.trap(KeyNotFound, KeyAddressMismatch) log.msg('Will send unencrypted message to %s.' % to_address) - emit(catalog.SMTP_START_SIGN, self._from_address) + emit_async(catalog.SMTP_START_SIGN, self._from_address) d = self._sign(message, from_address) d.addCallback(signal_sign) return d def signal_sign(newmsg): - emit(catalog.SMTP_END_SIGN, self._from_address) + emit_async(catalog.SMTP_END_SIGN, self._from_address) return newmsg, recipient log.msg("Will encrypt the message with %s and sign with %s." % (to_address, from_address)) - emit(catalog.SMTP_START_ENCRYPT_AND_SIGN, + emit_async(catalog.SMTP_START_ENCRYPT_AND_SIGN, "%s,%s" % (self._from_address, to_address)) d = self._maybe_attach_key(origmsg, from_address, to_address) d.addCallback(maybe_encrypt_and_sign) |