summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2013-09-06 16:01:09 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2013-09-06 16:01:09 -0300
commitc5847f8991fb93d34f6364163ecae15c8376ab2b (patch)
tree427afc6c926574929bb6b04a8d8261a4412293c4
parent29f38265cd1869bdbbaccc38fe450a17f2edea30 (diff)
parent6b1c81448f34b844f198bed20c31901617d4f0b5 (diff)
Merge branch 'release-0.3.2'
-rw-r--r--mail/CHANGELOG7
-rw-r--r--mail/README.rst4
-rw-r--r--mail/src/leap/mail/imap/fetch.py11
-rw-r--r--mail/src/leap/mail/imap/server.py10
-rw-r--r--mail/src/leap/mail/imap/service/imap-server.tac5
-rw-r--r--mail/src/leap/mail/imap/service/imap.py3
-rw-r--r--mail/src/leap/mail/smtp/__init__.py38
7 files changed, 55 insertions, 23 deletions
diff --git a/mail/CHANGELOG b/mail/CHANGELOG
index 761669f..40446be 100644
--- a/mail/CHANGELOG
+++ b/mail/CHANGELOG
@@ -1,3 +1,10 @@
+0.3.2 Sep 6:
+ o Make mail services bind to 127.0.0.1. Closes: #3627.
+ o Signal unread message to UI when message is saved locally. Closes: #3654.
+ o Signal unread to UI when flag in message change. Closes: #3662.
+ o Use dirspec instead of plain xdg. Closes #3574.
+ o SMTP service invocation returns factory instance.
+
0.3.1 Aug 23:
o Avoid logging dummy password on imap server. Closes: #3416
o Do not fail while processing an empty mail, just skip it. Fixes
diff --git a/mail/README.rst b/mail/README.rst
index 7224cba..9090d7c 100644
--- a/mail/README.rst
+++ b/mail/README.rst
@@ -2,6 +2,10 @@ leap.mail
=========
Mail services for the LEAP Client.
+.. image:: https://pypip.in/v/leap.mail/badge.png
+ :target: https://crate.io/packages/leap.mail
+
+
More info: https://leap.se
running tests
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" % (