summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/mail
diff options
context:
space:
mode:
authorKali Kaneko (leap communications) <kali@leap.se>2016-09-01 00:12:28 -0400
committerKali Kaneko (leap communications) <kali@leap.se>2016-09-01 00:52:34 -0400
commit662aed784218a45efbf563ff6150fcb9f1aa81aa (patch)
tree9ac2f47fb24f50d3ada1a4a4a0819d6ef909901e /src/leap/bitmask/mail
parent2a46b146135aa5694eb9de288c24037051268fdf (diff)
[refactor] fix imports after merging submodules
Diffstat (limited to 'src/leap/bitmask/mail')
-rw-r--r--src/leap/bitmask/mail/adaptors/soledad.py18
-rw-r--r--src/leap/bitmask/mail/imap/account.py7
-rw-r--r--src/leap/bitmask/mail/imap/mailbox.py4
-rw-r--r--src/leap/bitmask/mail/imap/messages.py2
-rw-r--r--src/leap/bitmask/mail/imap/service/imap-server.tac9
-rw-r--r--src/leap/bitmask/mail/imap/service/imap.py8
-rw-r--r--src/leap/bitmask/mail/incoming/service.py8
-rw-r--r--src/leap/bitmask/mail/mail.py16
-rw-r--r--src/leap/bitmask/mail/mailbox_indexer.py2
-rw-r--r--src/leap/bitmask/mail/outgoing/service.py22
-rw-r--r--src/leap/bitmask/mail/plugins/soledad_sync_hooks.py2
-rw-r--r--src/leap/bitmask/mail/smtp/README.rst2
-rw-r--r--src/leap/bitmask/mail/smtp/__init__.py7
-rw-r--r--src/leap/bitmask/mail/smtp/bounces.py4
-rw-r--r--src/leap/bitmask/mail/smtp/gateway.py22
-rw-r--r--src/leap/bitmask/mail/sync_hooks.py2
-rw-r--r--src/leap/bitmask/mail/testing/__init__.py7
-rw-r--r--src/leap/bitmask/mail/testing/imap.py10
-rw-r--r--src/leap/bitmask/mail/testing/smtp.py6
-rw-r--r--src/leap/bitmask/mail/walk.py2
20 files changed, 75 insertions, 85 deletions
diff --git a/src/leap/bitmask/mail/adaptors/soledad.py b/src/leap/bitmask/mail/adaptors/soledad.py
index ca8f741d..39c6bcb5 100644
--- a/src/leap/bitmask/mail/adaptors/soledad.py
+++ b/src/leap/bitmask/mail/adaptors/soledad.py
@@ -29,15 +29,15 @@ from leap.soledad.common import l2db
from leap.common.check import leap_assert, leap_assert_type
-from leap.mail import constants
-from leap.mail import walk
-from leap.mail.adaptors import soledad_indexes as indexes
-from leap.mail.constants import INBOX_NAME
-from leap.mail.adaptors import models
-from leap.mail.imap.mailbox import normalize_mailbox
-from leap.mail.utils import lowerdict, first
-from leap.mail.utils import stringify_parts_map
-from leap.mail.interfaces import IMailAdaptor, IMessageWrapper
+from leap.bitmask.mail import constants
+from leap.bitmask.mail import walk
+from leap.bitmask.mail.adaptors import soledad_indexes as indexes
+from leap.bitmask.mail.constants import INBOX_NAME
+from leap.bitmask.mail.adaptors import models
+from leap.bitmask.mail.imap.mailbox import normalize_mailbox
+from leap.bitmask.mail.utils import lowerdict, first
+from leap.bitmask.mail.utils import stringify_parts_map
+from leap.bitmask.mail.interfaces import IMailAdaptor, IMessageWrapper
from leap.soledad.common.document import SoledadDocument
diff --git a/src/leap/bitmask/mail/imap/account.py b/src/leap/bitmask/mail/imap/account.py
index e795c1b9..d885d591 100644
--- a/src/leap/bitmask/mail/imap/account.py
+++ b/src/leap/bitmask/mail/imap/account.py
@@ -28,10 +28,9 @@ from twisted.python import log
from zope.interface import implements
from leap.common.check import leap_assert, leap_assert_type
-
-from leap.mail.constants import MessageFlags
-from leap.mail.mail import Account
-from leap.mail.imap.mailbox import IMAPMailbox, normalize_mailbox
+from leap.bitmask.mail.constants import MessageFlags
+from leap.bitmask.mail.mail import Account
+from leap.bitmask.mail.imap.mailbox import IMAPMailbox, normalize_mailbox
from leap.soledad.client import Soledad
logger = logging.getLogger(__name__)
diff --git a/src/leap/bitmask/mail/imap/mailbox.py b/src/leap/bitmask/mail/imap/mailbox.py
index e70a1d80..b80280c6 100644
--- a/src/leap/bitmask/mail/imap/mailbox.py
+++ b/src/leap/bitmask/mail/imap/mailbox.py
@@ -36,8 +36,8 @@ from zope.interface import implements
from leap.common.check import leap_assert
from leap.common.check import leap_assert_type
-from leap.mail.constants import INBOX_NAME, MessageFlags
-from leap.mail.imap.messages import IMAPMessage
+from leap.bitmask.mail.constants import INBOX_NAME, MessageFlags
+from leap.bitmask.mail.imap.messages import IMAPMessage
logger = logging.getLogger(__name__)
diff --git a/src/leap/bitmask/mail/imap/messages.py b/src/leap/bitmask/mail/imap/messages.py
index d1c7b93c..841ebb2f 100644
--- a/src/leap/bitmask/mail/imap/messages.py
+++ b/src/leap/bitmask/mail/imap/messages.py
@@ -22,7 +22,7 @@ from twisted.mail import imap4
from twisted.internet import defer
from zope.interface import implements
-from leap.mail.utils import find_charset, CaseInsensitiveDict
+from leap.bitmask.mail.utils import find_charset, CaseInsensitiveDict
logger = logging.getLogger(__name__)
diff --git a/src/leap/bitmask/mail/imap/service/imap-server.tac b/src/leap/bitmask/mail/imap/service/imap-server.tac
index c4d602db..685db6bc 100644
--- a/src/leap/bitmask/mail/imap/service/imap-server.tac
+++ b/src/leap/bitmask/mail/imap/service/imap-server.tac
@@ -28,19 +28,18 @@ userid = 'user@provider'
uuid = 'deadbeefdeadabad'
passwd = 'supersecret' # optional, will get prompted if not found.
"""
-
# TODO -- this .tac file should be deprecated in favor of bitmask.core.bitmaskd
-
import ConfigParser
import getpass
import os
import sys
-from leap.keymanager import KeyManager
-from leap.mail.imap.service import imap
+from twisted.application import service, internet
+
+from leap.bitmask.keymanager import KeyManager
+from leap.bitmask.mail.imap.service import imap
from leap.soledad.client import Soledad
-from twisted.application import service, internet
# TODO should get this initializers from some authoritative mocked source
diff --git a/src/leap/bitmask/mail/imap/service/imap.py b/src/leap/bitmask/mail/imap/service/imap.py
index 4663854a..aac49b63 100644
--- a/src/leap/bitmask/mail/imap/service/imap.py
+++ b/src/leap/bitmask/mail/imap/service/imap.py
@@ -32,9 +32,9 @@ from twisted.python import log
from zope.interface import implementer
from leap.common.events import emit_async, catalog
-from leap.mail.cred import LocalSoledadTokenChecker
-from leap.mail.imap.account import IMAPAccount
-from leap.mail.imap.server import LEAPIMAPServer
+from leap.bitmask.mail.cred import LocalSoledadTokenChecker
+from leap.bitmask.mail.imap.account import IMAPAccount
+from leap.bitmask.mail.imap.server import LEAPIMAPServer
# TODO: leave only an implementor of IService in here
@@ -42,7 +42,7 @@ logger = logging.getLogger(__name__)
DO_MANHOLE = os.environ.get("LEAP_MAIL_MANHOLE", None)
if DO_MANHOLE:
- from leap.mail.imap.service import manhole
+ from leap.bitmask.mail.imap.service import manhole
# The default port in which imap service will run
diff --git a/src/leap/bitmask/mail/incoming/service.py b/src/leap/bitmask/mail/incoming/service.py
index 1e20862b..5490c199 100644
--- a/src/leap/bitmask/mail/incoming/service.py
+++ b/src/leap/bitmask/mail/incoming/service.py
@@ -39,10 +39,10 @@ from twisted.internet.task import deferLater
from leap.common.events import emit_async, catalog
from leap.common.check import leap_assert, leap_assert_type
from leap.common.mail import get_email_charset
-from leap.keymanager import errors as keymanager_errors
-from leap.mail.adaptors import soledad_indexes as fields
-from leap.mail.generator import Generator
-from leap.mail.utils import json_loads, empty
+from leap.bitmask.keymanager import errors as keymanager_errors
+from leap.bitmask.mail.adaptors import soledad_indexes as fields
+from leap.bitmask.mail.generator import Generator
+from leap.bitmask.mail.utils import json_loads, empty
from leap.soledad.client import Soledad
from leap.soledad.common.crypto import ENC_SCHEME_KEY, ENC_JSON_KEY
from leap.soledad.common.errors import InvalidAuthTokenError
diff --git a/src/leap/bitmask/mail/mail.py b/src/leap/bitmask/mail/mail.py
index 2fde3a1b..7a16b461 100644
--- a/src/leap/bitmask/mail/mail.py
+++ b/src/leap/bitmask/mail/mail.py
@@ -37,13 +37,13 @@ from twisted.python import log
from leap.common.check import leap_assert_type
from leap.common.events import emit_async, catalog
-from leap.mail.adaptors.soledad import SoledadMailAdaptor
-from leap.mail.constants import INBOX_NAME
-from leap.mail.constants import MessageFlags
-from leap.mail.mailbox_indexer import MailboxIndexer
-from leap.mail.plugins import soledad_sync_hooks
-from leap.mail.utils import find_charset, CaseInsensitiveDict
-from leap.mail.utils import lowerdict
+from leap.bitmask.mail.adaptors.soledad import SoledadMailAdaptor
+from leap.bitmask.mail.constants import INBOX_NAME
+from leap.bitmask.mail.constants import MessageFlags
+from leap.bitmask.mail.mailbox_indexer import MailboxIndexer
+from leap.bitmask.mail.plugins import soledad_sync_hooks
+from leap.bitmask.mail.utils import find_charset, CaseInsensitiveDict
+from leap.bitmask.mail.utils import lowerdict
logger = logging.getLogger(name=__name__)
@@ -870,7 +870,7 @@ class Account(object):
basic collection handled by traditional MUAs, but it can also handle other
types of Collections (tag based, for instance).
- leap.mail.imap.IMAPAccount partially proxies methods in this
+ leap.bitmask.mail.imap.IMAPAccount partially proxies methods in this
class.
"""
diff --git a/src/leap/bitmask/mail/mailbox_indexer.py b/src/leap/bitmask/mail/mailbox_indexer.py
index c49f808b..da123276 100644
--- a/src/leap/bitmask/mail/mailbox_indexer.py
+++ b/src/leap/bitmask/mail/mailbox_indexer.py
@@ -22,7 +22,7 @@ Local tables to store the message Unique Identifiers for a given mailbox.
import re
import uuid
-from leap.mail.constants import METAMSGID_RE
+from leap.bitmask.mail.constants import METAMSGID_RE
def _maybe_first_query_item(thing):
diff --git a/src/leap/bitmask/mail/outgoing/service.py b/src/leap/bitmask/mail/outgoing/service.py
index 8b02f2e4..9fe3ec1b 100644
--- a/src/leap/bitmask/mail/outgoing/service.py
+++ b/src/leap/bitmask/mail/outgoing/service.py
@@ -40,16 +40,16 @@ from twisted.python import log
from leap.common.check import leap_assert_type, leap_assert
from leap.common.events import emit_async, catalog
-from leap.keymanager.errors import KeyNotFound, KeyAddressMismatch
-from leap.mail import __version__
-from leap.mail import errors
-from leap.mail.utils import validate_address
-from leap.mail.rfc3156 import MultipartEncrypted
-from leap.mail.rfc3156 import MultipartSigned
-from leap.mail.rfc3156 import encode_base64_rec
-from leap.mail.rfc3156 import RFC3156CompliantGenerator
-from leap.mail.rfc3156 import PGPSignature
-from leap.mail.rfc3156 import PGPEncrypted
+from leap.bitmask import __version__
+from leap.bitmask.keymanager.errors import KeyNotFound, KeyAddressMismatch
+from leap.bitmask.mail import errors
+from leap.bitmask.mail.utils import validate_address
+from leap.bitmask.mail.rfc3156 import MultipartEncrypted
+from leap.bitmask.mail.rfc3156 import MultipartSigned
+from leap.bitmask.mail.rfc3156 import encode_base64_rec
+from leap.bitmask.mail.rfc3156 import RFC3156CompliantGenerator
+from leap.bitmask.mail.rfc3156 import PGPSignature
+from leap.bitmask.mail.rfc3156 import PGPEncrypted
# TODO
# [ ] rename this module to something else, service should be the implementor
@@ -223,7 +223,7 @@ class OutgoingMail(object):
heloFallback=True,
requireAuthentication=False,
requireTransportSecurity=True)
- factory.domain = bytes('leap.mail-' + __version__)
+ factory.domain = bytes('leap.bitmask.mail-' + __version__)
emit_async(catalog.SMTP_SEND_MESSAGE_START,
self._from_address, recipient.dest.addrstr)
reactor.connectSSL(
diff --git a/src/leap/bitmask/mail/plugins/soledad_sync_hooks.py b/src/leap/bitmask/mail/plugins/soledad_sync_hooks.py
index 9d48126e..a13aaace 100644
--- a/src/leap/bitmask/mail/plugins/soledad_sync_hooks.py
+++ b/src/leap/bitmask/mail/plugins/soledad_sync_hooks.py
@@ -15,5 +15,5 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from leap.mail.sync_hooks import MailProcessingPostSyncHook
+from leap.bitmask.mail.sync_hooks import MailProcessingPostSyncHook
post_sync_uid_reindexer = MailProcessingPostSyncHook()
diff --git a/src/leap/bitmask/mail/smtp/README.rst b/src/leap/bitmask/mail/smtp/README.rst
index 1d3a9038..ec2c8c48 100644
--- a/src/leap/bitmask/mail/smtp/README.rst
+++ b/src/leap/bitmask/mail/smtp/README.rst
@@ -41,4 +41,4 @@ Running tests
Tests are run using Twisted's Trial API, like this::
- python setup.py test -s leap.mail.gateway.tests
+ python setup.py test -s leap.bitmask.mail.gateway.tests
diff --git a/src/leap/bitmask/mail/smtp/__init__.py b/src/leap/bitmask/mail/smtp/__init__.py
index 9fab70a7..5f7fe669 100644
--- a/src/leap/bitmask/mail/smtp/__init__.py
+++ b/src/leap/bitmask/mail/smtp/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# __init__.py
-# Copyright (C) 2013 LEAP
+# Copyright (C) 2013-2016 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,7 +14,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
"""
SMTP gateway helper function.
"""
@@ -25,12 +24,10 @@ from twisted.internet import reactor
from twisted.internet.error import CannotListenError
from leap.common.events import emit_async, catalog
-
-from leap.mail.smtp.gateway import SMTPFactory
+from leap.bitmask.mail.smtp.gateway import SMTPFactory
logger = logging.getLogger(__name__)
-
SMTP_PORT = 2013
diff --git a/src/leap/bitmask/mail/smtp/bounces.py b/src/leap/bitmask/mail/smtp/bounces.py
index 7a4674b9..8260c1b0 100644
--- a/src/leap/bitmask/mail/smtp/bounces.py
+++ b/src/leap/bitmask/mail/smtp/bounces.py
@@ -21,8 +21,8 @@ import time
from email.message import Message
from email.utils import formatdate
-from leap.mail.constants import INBOX_NAME
-from leap.mail.mail import Account
+from leap.bitmask.mail.constants import INBOX_NAME
+from leap.bitmask.mail.mail import Account
# TODO implement localization for this template.
diff --git a/src/leap/bitmask/mail/smtp/gateway.py b/src/leap/bitmask/mail/smtp/gateway.py
index e49bbe82..16e1af97 100644
--- a/src/leap/bitmask/mail/smtp/gateway.py
+++ b/src/leap/bitmask/mail/smtp/gateway.py
@@ -29,6 +29,7 @@ The following classes comprise the SMTP gateway service:
* EncryptedMessage - An implementation of twisted.mail.smtp.IMessage that
knows how to encrypt/sign itself before sending.
"""
+from email import generator
from email.Header import Header
from zope.interface import implements
@@ -42,20 +43,17 @@ from twisted.python import log
from leap.common.check import leap_assert_type
from leap.common.events import emit_async, catalog
-from leap.mail import errors
-from leap.mail.cred import LocalSoledadTokenChecker
-from leap.mail.utils import validate_address
-from leap.mail.rfc3156 import RFC3156CompliantGenerator
-from leap.mail.outgoing.service import outgoingFactory
-from leap.mail.smtp.bounces import bouncerFactory
-from leap.keymanager.errors import KeyNotFound
+from leap.bitmask.mail import errors
+from leap.bitmask.mail.cred import LocalSoledadTokenChecker
+from leap.bitmask.mail.utils import validate_address
+from leap.bitmask.mail.rfc3156 import RFC3156CompliantGenerator
+from leap.bitmask.mail.outgoing.service import outgoingFactory
+from leap.bitmask.mail.smtp.bounces import bouncerFactory
+from leap.bitmask.keymanager.errors import KeyNotFound
# replace email generator with a RFC 3156 compliant one.
-from email import generator
-
generator.Generator = RFC3156CompliantGenerator
-
LOCAL_FQDN = "bitmask.local"
@@ -237,7 +235,7 @@ class SMTPDelivery(object):
mail or not.
:type encrypted_only: bool
:param outgoing_mail: The outgoing mail to send the message
- :type outgoing_mail: leap.mail.outgoing.service.OutgoingMail
+ :type outgoing_mail: leap.bitmask.mail.outgoing.service.OutgoingMail
"""
self._userid = userid
self._outgoing_mail = outgoing_mail
@@ -368,7 +366,7 @@ class EncryptedMessage(object):
:param user: The recipient of this message.
:type user: twisted.mail.smtp.User
:param outgoing_mail: The outgoing mail to send the message
- :type outgoing_mail: leap.mail.outgoing.service.OutgoingMail
+ :type outgoing_mail: leap.bitmask.mail.outgoing.service.OutgoingMail
"""
# assert params
leap_assert_type(user, smtp.User)
diff --git a/src/leap/bitmask/mail/sync_hooks.py b/src/leap/bitmask/mail/sync_hooks.py
index 8efbb7ce..ff4bf56e 100644
--- a/src/leap/bitmask/mail/sync_hooks.py
+++ b/src/leap/bitmask/mail/sync_hooks.py
@@ -29,8 +29,8 @@ from twisted.internet import defer
from twisted.plugin import IPlugin
from twisted.python import log
+from leap.bitmask.mail import constants
from leap.soledad.client.interfaces import ISoledadPostSyncPlugin
-from leap.mail import constants
logger = logging.getLogger(__name__)
diff --git a/src/leap/bitmask/mail/testing/__init__.py b/src/leap/bitmask/mail/testing/__init__.py
index 8822a5c7..b5a2a424 100644
--- a/src/leap/bitmask/mail/testing/__init__.py
+++ b/src/leap/bitmask/mail/testing/__init__.py
@@ -24,12 +24,9 @@ from twisted.internet.defer import gatherResults
from twisted.trial import unittest
from twisted.internet import defer
-
-from leap.soledad.client import Soledad
-from leap.keymanager import KeyManager
-
-
from leap.common.testing.basetest import BaseLeapTest
+from leap.bitmask.keymanager import KeyManager
+from leap.soledad.client import Soledad
ADDRESS = 'leap@leap.se'
ADDRESS_2 = 'anotheruser@leap.se'
diff --git a/src/leap/bitmask/mail/testing/imap.py b/src/leap/bitmask/mail/testing/imap.py
index 72acbf2e..75ee9c7f 100644
--- a/src/leap/bitmask/mail/testing/imap.py
+++ b/src/leap/bitmask/mail/testing/imap.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# utils.py
-# Copyright (C) 2014, 2015 LEAP
+# Copyright (C) 2014-2016 LEAP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -30,10 +30,10 @@ from twisted.protocols import loopback
from twisted.python import log
from zope.interface import implementer
-from leap.mail.adaptors import soledad as soledad_adaptor
-from leap.mail.imap.account import IMAPAccount
-from leap.mail.imap.server import LEAPIMAPServer
-from leap.mail.testing.common import SoledadTestMixin
+from leap.bitmask.mail.adaptors import soledad as soledad_adaptor
+from leap.bitmask.mail.imap.account import IMAPAccount
+from leap.bitmask.mail.imap.server import LEAPIMAPServer
+from leap.bitmask.mail.testing.common import SoledadTestMixin
TEST_USER = "testuser@leap.se"
TEST_PASSWD = "1234"
diff --git a/src/leap/bitmask/mail/testing/smtp.py b/src/leap/bitmask/mail/testing/smtp.py
index d8690f12..834433f3 100644
--- a/src/leap/bitmask/mail/testing/smtp.py
+++ b/src/leap/bitmask/mail/testing/smtp.py
@@ -1,8 +1,8 @@
from twisted.mail import smtp
-from leap.mail.smtp.gateway import SMTPFactory, LOCAL_FQDN
-from leap.mail.smtp.gateway import SMTPDelivery
-from leap.mail.outgoing.service import outgoingFactory
+from leap.bitmask.mail.smtp.gateway import SMTPFactory, LOCAL_FQDN
+from leap.bitmask.mail.smtp.gateway import SMTPDelivery
+from leap.bitmask.mail.outgoing.service import outgoingFactory
TEST_USER = u'anotheruser@leap.se'
diff --git a/src/leap/bitmask/mail/walk.py b/src/leap/bitmask/mail/walk.py
index d143d61e..61bbe0b7 100644
--- a/src/leap/bitmask/mail/walk.py
+++ b/src/leap/bitmask/mail/walk.py
@@ -25,7 +25,7 @@ from cryptography.hazmat.backends.openssl.backend import (
Backend as OpenSSLBackend)
from cryptography.hazmat.primitives import hashes
-from leap.mail.utils import first
+from leap.bitmask.mail.utils import first
crypto_backend = MultiBackend([OpenSSLBackend()])