diff options
Diffstat (limited to 'mail/src/leap')
-rw-r--r-- | mail/src/leap/mail/imap/fetch.py | 11 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/server.py | 10 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/service/imap-server.tac | 5 | ||||
-rw-r--r-- | mail/src/leap/mail/imap/service/imap.py | 3 | ||||
-rw-r--r-- | mail/src/leap/mail/smtp/__init__.py | 38 |
5 files changed, 44 insertions, 23 deletions
diff --git a/mail/src/leap/mail/imap/fetch.py b/mail/src/leap/mail/imap/fetch.py index 8b29c5e..e620a58 100644 --- a/mail/src/leap/mail/imap/fetch.py +++ b/mail/src/leap/mail/imap/fetch.py @@ -150,6 +150,13 @@ class LeapIncomingMail(object): doclist = self._soledad.get_from_index("just-mail", "*") return doclist + def _signal_unread_to_ui(self): + """ + Sends unread event to ui. + """ + leap_events.signal( + IMAP_UNREAD_MAIL, str(self._inbox.getUnseenCount())) + def _signal_fetch_to_ui(self, doclist): """ Sends leap events to ui. @@ -164,8 +171,7 @@ class LeapIncomingMail(object): log.msg("there are %s mails" % (num_mails,)) leap_events.signal( IMAP_FETCHED_INCOMING, str(num_mails), str(fetched_ts)) - leap_events.signal( - IMAP_UNREAD_MAIL, str(self._inbox.getUnseenCount())) + self._signal_unread_to_ui() return doclist def _sync_soledad_error(self, failure): @@ -318,3 +324,4 @@ class LeapIncomingMail(object): self._soledad.delete_doc(doc) log.msg("deleted doc %s from incoming" % doc_id) leap_events.signal(IMAP_MSG_DELETED_INCOMING) + self._signal_unread_to_ui() diff --git a/mail/src/leap/mail/imap/server.py b/mail/src/leap/mail/imap/server.py index cfcb3d6..ae76833 100644 --- a/mail/src/leap/mail/imap/server.py +++ b/mail/src/leap/mail/imap/server.py @@ -35,6 +35,8 @@ from twisted.python import log #import u1db +from leap.common import events as leap_events +from leap.common.events.events_pb2 import IMAP_UNREAD_MAIL from leap.common.check import leap_assert, leap_assert_type from leap.soledad.client import Soledad @@ -1405,6 +1407,13 @@ class SoledadMailbox(WithMsgFields): result.append((msg_id, msg)) return tuple(result) + def _signal_unread_to_ui(self): + """ + Sends unread event to ui. + """ + leap_events.signal( + IMAP_UNREAD_MAIL, str(self.getUnseenCount())) + def store(self, messages, flags, mode, uid): """ Sets the flags of one or more messages. @@ -1455,6 +1464,7 @@ class SoledadMailbox(WithMsgFields): self._update(msg.setFlags(flags)) result[msg_id] = msg.getFlags() + self._signal_unread_to_ui() return result def close(self): diff --git a/mail/src/leap/mail/imap/service/imap-server.tac b/mail/src/leap/mail/imap/service/imap-server.tac index 8638be2..da72cae 100644 --- a/mail/src/leap/mail/imap/service/imap-server.tac +++ b/mail/src/leap/mail/imap/service/imap-server.tac @@ -1,10 +1,9 @@ import ConfigParser import os -from xdg import BaseDirectory - from leap.soledad.client import Soledad from leap.mail.imap.service import imap +from leap.common.config import get_path_prefix config = ConfigParser.ConfigParser() @@ -34,7 +33,7 @@ def initialize_soledad_mailbox(user_uuid, soledad_pass, server_url, :rtype: Soledad instance """ - base_config = BaseDirectory.xdg_config_home + base_config = get_path_prefix() secret_path = os.path.join( base_config, "leap", "soledad", "%s.secret" % user_uuid) diff --git a/mail/src/leap/mail/imap/service/imap.py b/mail/src/leap/mail/imap/service/imap.py index 9e9a524..b840e86 100644 --- a/mail/src/leap/mail/imap/service/imap.py +++ b/mail/src/leap/mail/imap/service/imap.py @@ -157,7 +157,8 @@ def run_service(*args, **kwargs): from twisted.internet import reactor try: - reactor.listenTCP(port, factory) + reactor.listenTCP(port, factory, + interface="localhost") fetcher = LeapIncomingMail( keymanager, soledad, diff --git a/mail/src/leap/mail/smtp/__init__.py b/mail/src/leap/mail/smtp/__init__.py index d5d61bf..2a4abc5 100644 --- a/mail/src/leap/mail/smtp/__init__.py +++ b/mail/src/leap/mail/smtp/__init__.py @@ -37,22 +37,24 @@ def setup_smtp_relay(port, keymanager, smtp_host, smtp_port, This function sets up the SMTP relay configuration and the Twisted reactor. - @param port: The port in which to run the server. - @type port: int - @param keymanager: A Key Manager from where to get recipients' public - keys. - @type keymanager: leap.common.keymanager.KeyManager - @param smtp_host: The hostname of the remote SMTP server. - @type smtp_host: str - @param smtp_port: The port of the remote SMTP server. - @type smtp_port: int - @param smtp_cert: The client certificate for authentication. - @type smtp_cert: str - @param smtp_key: The client key for authentication. - @type smtp_key: str - @param encrypted_only: Whether the SMTP relay should send unencrypted mail - or not. - @type encrypted_only: bool + :param port: The port in which to run the server. + :type port: int + :param keymanager: A Key Manager from where to get recipients' public + keys. + :type keymanager: leap.common.keymanager.KeyManager + :param smtp_host: The hostname of the remote SMTP server. + :type smtp_host: str + :param smtp_port: The port of the remote SMTP server. + :type smtp_port: int + :param smtp_cert: The client certificate for authentication. + :type smtp_cert: str + :param smtp_key: The client key for authentication. + :type smtp_key: str + :param encrypted_only: Whether the SMTP relay should send unencrypted mail + or not. + :type encrypted_only: bool + + :returns: SMTPFactory """ # The configuration for the SMTP relay is a dict with the following # format: @@ -75,8 +77,10 @@ def setup_smtp_relay(port, keymanager, smtp_host, smtp_port, # configure the use of this service with twistd factory = SMTPFactory(keymanager, config) try: - reactor.listenTCP(port, factory) + reactor.listenTCP(port, factory, + interface="localhost") signal(proto.SMTP_SERVICE_STARTED, str(smtp_port)) + return factory except CannotListenError: logger.error("STMP Service failed to start: " "cannot listen in port %s" % ( |