summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2015-07-11 02:30:44 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2015-08-11 17:00:21 +0200
commit143092359e6543a16c40be76131c10b68c2d51bc (patch)
treeca8ff62835cdb2ac78156b74d7a41e071c175a63 /service/pixelated
parent10d1f5203517ae33535c6cdb8c2e0fe7cebebea8 (diff)
trying out a new migration
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/adapter/model/mail.py18
-rw-r--r--service/pixelated/bitmask_libraries/session.py27
-rw-r--r--service/pixelated/bitmask_libraries/soledad.py14
-rw-r--r--service/pixelated/config/leap.py9
-rw-r--r--service/pixelated/maintenance.py8
-rw-r--r--service/pixelated/resources/mails_resource.py4
-rw-r--r--service/pixelated/support/encrypted_file_storage.py2
7 files changed, 36 insertions, 46 deletions
diff --git a/service/pixelated/adapter/model/mail.py b/service/pixelated/adapter/model/mail.py
index 464e0343..084b41ed 100644
--- a/service/pixelated/adapter/model/mail.py
+++ b/service/pixelated/adapter/model/mail.py
@@ -24,7 +24,7 @@ from email.mime.text import MIMEText
from email.header import decode_header
from email.MIMEMultipart import MIMEMultipart
from pycryptopp.hash import sha256
-from leap.mail.imap.fields import fields
+from leap.mail.adaptors import soledad_indexes as fields
import leap.mail.walk as walk
from pixelated.adapter.model.status import Status
from pixelated.support import date
@@ -128,14 +128,14 @@ class InputMail(Mail):
return self._fd
fd = {}
- fd[fields.MBOX_KEY] = mailbox
- fd[fields.UID_KEY] = next_uid
- fd[fields.CONTENT_HASH_KEY] = self._get_chash()
- fd[fields.SIZE_KEY] = len(self.raw)
- fd[fields.MULTIPART_KEY] = True
- fd[fields.RECENT_KEY] = True
- fd[fields.TYPE_KEY] = fields.TYPE_FLAGS_VAL
- fd[fields.FLAGS_KEY] = Status.to_flags(self._status)
+ fd[fields.MBOX] = mailbox
+ fd[fields.MBOX_UUID] = next_uid
+ fd[fields.CONTENT_HASH] = self._get_chash()
+ # fd[fields.SIZE_KEY] = len(self.raw)
+ # fd[fields.MULTIPART_KEY] = True
+ fd[fields.RECENT] = True
+ fd[fields.TYPE] = fields.TYPE_FLAGS_VAL
+ fd[fields.FLAGS] = Status.to_flags(self._status)
self._fd = fd
return fd
diff --git a/service/pixelated/bitmask_libraries/session.py b/service/pixelated/bitmask_libraries/session.py
index a9cb15f2..19ded34c 100644
--- a/service/pixelated/bitmask_libraries/session.py
+++ b/service/pixelated/bitmask_libraries/session.py
@@ -18,10 +18,7 @@ import traceback
import sys
import os
-from leap.mail.imap.fetch import LeapIncomingMail
-from leap.mail.imap.account import SoledadBackedAccount
-from leap.mail.imap.memorystore import MemoryStore
-from leap.mail.imap.soledadstore import SoledadStore
+from leap.mail.incoming.service import IncomingMail
from twisted.internet import reactor
from .nicknym import NickNym
from leap.auth import SRPAuth
@@ -51,19 +48,16 @@ class LeapSession(object):
- ``nicknym`` the nicknym instance. See https://leap.se/nicknym (NickNym)
- - ``account`` the actual leap mail account. Implements Twisted imap4.IAccount and imap4.INamespacePresenter (SoledadBackedAccount)
-
- ``incoming_mail_fetcher`` Background job for fetching incoming mails from LEAP server (LeapIncomingMail)
"""
- def __init__(self, provider, user_auth, soledad_session, nicknym, soledad_account, incoming_mail_fetcher, smtp):
+ def __init__(self, provider, user_auth, soledad_session, nicknym, incoming_mail_fetcher, smtp):
self.smtp = smtp
self.config = provider.config
self.provider = provider
self.user_auth = user_auth
self.soledad_session = soledad_session
self.nicknym = nicknym
- self.account = soledad_account
self.incoming_mail_fetcher = incoming_mail_fetcher
self.soledad_session.soledad.sync(defer_decryption=False)
self.nicknym.generate_openpgp_key()
@@ -119,12 +113,11 @@ class LeapSessionFactory(object):
soledad = SoledadSessionFactory.create(self._provider, auth.token, auth.uuid, password)
nicknym = self._create_nicknym(account_email, auth.token, auth.uuid, soledad)
- account = self._create_account(auth.uuid, soledad)
- incoming_mail_fetcher = self._create_incoming_mail_fetcher(nicknym, soledad, account, account_email)
+ incoming_mail_fetcher = self._create_incoming_mail_fetcher(nicknym, soledad, account_email)
smtp = LeapSmtp(self._provider, auth, nicknym.keymanager)
- return LeapSession(self._provider, auth, soledad, nicknym, account, incoming_mail_fetcher, smtp)
+ return LeapSession(self._provider, auth, soledad, nicknym, incoming_mail_fetcher, smtp)
def _lookup_session(self, key):
global SESSIONS
@@ -152,10 +145,8 @@ class LeapSessionFactory(object):
def _create_nicknym(self, email_address, token, uuid, soledad_session):
return NickNym(self._provider, self._config, soledad_session, email_address, token, uuid)
- def _create_account(self, uuid, soledad_session):
- memstore = MemoryStore(permanent_store=SoledadStore(soledad_session.soledad))
- return SoledadBackedAccount(uuid, soledad_session.soledad, memstore)
-
- def _create_incoming_mail_fetcher(self, nicknym, soledad_session, account, email_address):
- return LeapIncomingMail(nicknym.keymanager, soledad_session.soledad, account,
- self._config.fetch_interval_in_s, email_address)
+ def _create_incoming_mail_fetcher(self, nicknym, soledad_session, auth, username):
+ return IncomingMail(nicknym.keymanager,
+ soledad_session.soledad,
+ auth.uuid,
+ self._config.fetch_interval_in_s)
diff --git a/service/pixelated/bitmask_libraries/soledad.py b/service/pixelated/bitmask_libraries/soledad.py
index f0cd9f2f..e8e81ffa 100644
--- a/service/pixelated/bitmask_libraries/soledad.py
+++ b/service/pixelated/bitmask_libraries/soledad.py
@@ -17,7 +17,7 @@ import errno
import os
from leap.soledad.client import Soledad
-from leap.soledad.common.crypto import WrongMac, UnknownMacMethod
+from leap.soledad.common.crypto import WrongMacError, UnknownMacMethodError
from pixelated.bitmask_libraries.certs import LeapCertificate
SOLEDAD_TIMEOUT = 120
@@ -57,10 +57,16 @@ class SoledadSession(object):
secrets = self._secrets_path()
local_db = self._local_db_path()
- return Soledad(self.user_uuid, unicode(encryption_passphrase), secrets,
- local_db, server_url, LeapCertificate(self.provider).provider_api_cert, self.user_token, defer_encryption=False)
+ return Soledad(self.user_uuid,
+ unicode(encryption_passphrase),
+ secrets,
+ local_db, server_url,
+ LeapCertificate(self.provider).provider_api_cert,
+ shared_db=None,
+ auth_token=self.user_token,
+ defer_encryption=False)
- except (WrongMac, UnknownMacMethod), e:
+ except (WrongMacError, UnknownMacMethodError), e:
raise SoledadWrongPassphraseException(e)
def _leap_path(self):
diff --git a/service/pixelated/config/leap.py b/service/pixelated/config/leap.py
index 52cd4c8f..c28c371b 100644
--- a/service/pixelated/config/leap.py
+++ b/service/pixelated/config/leap.py
@@ -14,7 +14,7 @@ def initialize_leap(leap_provider_cert,
organization_mode,
leap_home):
init_monkeypatches()
- events_server.ensure_server(random.randrange(8000, 11999))
+ events_server.ensure_server()
provider, username, password = credentials.read(organization_mode, credentials_file)
LeapCertificate.set_cert_and_fingerprint(leap_provider_cert, leap_provider_cert_fingerprint)
@@ -27,11 +27,4 @@ def initialize_leap(leap_provider_cert,
def init_monkeypatches():
- import pixelated.extensions.protobuf_socket
- import pixelated.extensions.sqlcipher_wal
- import pixelated.extensions.esmtp_sender_factory
- import pixelated.extensions.incoming_decrypt_header
- import pixelated.extensions.soledad_sync_exception
- import pixelated.extensions.keymanager_fetch_key
import pixelated.extensions.requests_urllib3
- import pixelated.extensions.shared_db
diff --git a/service/pixelated/maintenance.py b/service/pixelated/maintenance.py
index 7170055c..69cd674b 100644
--- a/service/pixelated/maintenance.py
+++ b/service/pixelated/maintenance.py
@@ -20,7 +20,7 @@ from twisted.internet.threads import deferToThread
from pixelated.config.leap import initialize_leap
from pixelated.config import logger, arguments
-from leap.mail.imap.fields import WithMsgFields
+from leap.mail.constants import MessageFlags
import time
@@ -118,11 +118,11 @@ def add_mail_folder(account, maildir, folder_name, deferreds):
if is_keep_file(mail):
continue
- flags = (WithMsgFields.RECENT_FLAG,) if mail.get_subdir() == 'new' else ()
+ flags = (MessageFlags.RECENT_FLAG,) if mail.get_subdir() == 'new' else ()
if 'S' in mail.get_flags():
- flags = (WithMsgFields.SEEN_FLAG,) + flags
+ flags = (MessageFlags.SEEN_FLAG,) + flags
if 'R' in mail.get_flags():
- flags = (WithMsgFields.ANSWERED_FLAG,) + flags
+ flags = (MessageFlags.ANSWERED_FLAG,) + flags
deferreds.append(mbx.addMessage(mail.as_string(), flags=flags, notify_on_disk=False))
diff --git a/service/pixelated/resources/mails_resource.py b/service/pixelated/resources/mails_resource.py
index c4b578ba..cddaa0ec 100644
--- a/service/pixelated/resources/mails_resource.py
+++ b/service/pixelated/resources/mails_resource.py
@@ -6,7 +6,7 @@ from twisted.web.resource import Resource
from twisted.web import server
from leap.common.events import (
register,
- events_pb2 as proto
+ catalog as events
)
@@ -75,7 +75,7 @@ class MailsResource(Resource):
delivery_error_mail = InputMail.delivery_error_template(delivery_address=event.content)
self._mail_service.mailboxes.inbox.add(delivery_error_mail)
- register(signal=proto.SMTP_SEND_MESSAGE_ERROR, callback=on_error)
+ register(events.SMTP_SEND_MESSAGE_ERROR, callback=on_error)
def __init__(self, mail_service, draft_service):
Resource.__init__(self)
diff --git a/service/pixelated/support/encrypted_file_storage.py b/service/pixelated/support/encrypted_file_storage.py
index 67036054..3f3e47d6 100644
--- a/service/pixelated/support/encrypted_file_storage.py
+++ b/service/pixelated/support/encrypted_file_storage.py
@@ -23,7 +23,7 @@ from whoosh.filedb.filestore import FileStorage
from whoosh.filedb.structfile import StructFile, BufferFile
from leap.soledad.client.crypto import encrypt_sym
from leap.soledad.client.crypto import decrypt_sym
-from leap.soledad.client.crypto import EncryptionMethods
+from leap.soledad.common.crypto import EncryptionMethods
from whoosh.util import random_name