From 5cf70a34ddcde184cd6c50ba26c995934c2a2642 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Wed, 28 Aug 2013 15:05:01 -0300 Subject: Use dirspec instead of plain xdg. Closes #3574. --- src/leap/mail/imap/service/imap-server.tac | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/leap') diff --git a/src/leap/mail/imap/service/imap-server.tac b/src/leap/mail/imap/service/imap-server.tac index 8638be2..da72cae 100644 --- a/src/leap/mail/imap/service/imap-server.tac +++ b/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) -- cgit v1.2.3 From c80eaa6d594092d02f4739a7db85551ac229957c Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Mon, 2 Sep 2013 00:25:24 +0200 Subject: Signal unread message when msg saved locally. Closes: #3654 --- src/leap/mail/imap/fetch.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/leap') diff --git a/src/leap/mail/imap/fetch.py b/src/leap/mail/imap/fetch.py index 8b29c5e..e620a58 100644 --- a/src/leap/mail/imap/fetch.py +++ b/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() -- cgit v1.2.3 From 39c0bc2671910f46ec565f57ce450438a51bb858 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Mon, 2 Sep 2013 00:53:01 +0200 Subject: Send UNREAD event to UI when flag changes. Closes: #3662 --- src/leap/mail/imap/server.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/leap') diff --git a/src/leap/mail/imap/server.py b/src/leap/mail/imap/server.py index cfcb3d6..ae76833 100644 --- a/src/leap/mail/imap/server.py +++ b/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): -- cgit v1.2.3 From 14902d1cc79d1777361e144ff3c46ff52cc005fd Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 3 Sep 2013 11:12:18 +0200 Subject: Return SMTP factory so the client can stop it. --- src/leap/mail/smtp/__init__.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'src/leap') diff --git a/src/leap/mail/smtp/__init__.py b/src/leap/mail/smtp/__init__.py index d5d61bf..cc9cc26 100644 --- a/src/leap/mail/smtp/__init__.py +++ b/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: @@ -77,6 +79,7 @@ def setup_smtp_relay(port, keymanager, smtp_host, smtp_port, try: reactor.listenTCP(port, factory) signal(proto.SMTP_SERVICE_STARTED, str(smtp_port)) + return factory except CannotListenError: logger.error("STMP Service failed to start: " "cannot listen in port %s" % ( -- cgit v1.2.3 From 6aa4e588c84579b785e49d903d0239e9ae13aba6 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Tue, 3 Sep 2013 20:35:00 +0200 Subject: Make mail services bind to 127.0.0.1 instead of 0.0.0.0 Closes: #3627 --- src/leap/mail/imap/service/imap.py | 3 ++- src/leap/mail/smtp/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/leap') diff --git a/src/leap/mail/imap/service/imap.py b/src/leap/mail/imap/service/imap.py index 9e9a524..b840e86 100644 --- a/src/leap/mail/imap/service/imap.py +++ b/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/src/leap/mail/smtp/__init__.py b/src/leap/mail/smtp/__init__.py index cc9cc26..2a4abc5 100644 --- a/src/leap/mail/smtp/__init__.py +++ b/src/leap/mail/smtp/__init__.py @@ -77,7 +77,8 @@ 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: -- cgit v1.2.3