summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/bitmask_libraries/session.py29
-rw-r--r--service/pixelated/bitmask_libraries/soledad.py8
-rw-r--r--service/pixelated/extensions/keymanager_fetch_key.py2
-rw-r--r--service/pixelated/extensions/shared_db.py2
-rw-r--r--service/pixelated/extensions/soledad_sync_exception.py2
-rw-r--r--service/pixelated/maintenance.py34
6 files changed, 53 insertions, 24 deletions
diff --git a/service/pixelated/bitmask_libraries/session.py b/service/pixelated/bitmask_libraries/session.py
index ffe446a4..a18d88d5 100644
--- a/service/pixelated/bitmask_libraries/session.py
+++ b/service/pixelated/bitmask_libraries/session.py
@@ -24,7 +24,7 @@ from .nicknym import NickNym
from leap.auth import SRPAuth
from .soledad import SoledadSessionFactory
from .smtp import LeapSmtp
-
+from leap.mail.imap.account import IMAPAccount
SESSIONS = {}
@@ -51,18 +51,19 @@ class LeapSession(object):
- ``incoming_mail_fetcher`` Background job for fetching incoming mails from LEAP server (LeapIncomingMail)
"""
- def __init__(self, provider, user_auth, soledad_session, nicknym, incoming_mail_fetcher, smtp):
+ def __init__(self, provider, user_auth, soledad_session, nicknym, soledad_account, 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()
+ # self.soledad_session.soledad.sync(defer_decryption=False)
+ # self.nicknym.generate_openpgp_key()
- if self.config.start_background_jobs:
+ if self.config.start_background_jobs and False:
self.start_background_jobs()
def account_email(self):
@@ -110,12 +111,16 @@ class LeapSessionFactory(object):
soledad = SoledadSessionFactory.create(self._provider, auth.token, auth.uuid, password)
- nicknym = self._create_nicknym(account_email, auth.token, auth.uuid, soledad)
- incoming_mail_fetcher = self._create_incoming_mail_fetcher(nicknym, soledad, auth, auth.username)
+ # nicknym = self._create_nicknym(account_email, auth.token, auth.uuid, soledad)
+ nicknym = None
+ account = self._create_account(account_email, soledad)
+ # incoming_mail_fetcher = self._create_incoming_mail_fetcher(nicknym, soledad, auth, auth.username)
+ incoming_mail_fetcher = None
- smtp = LeapSmtp(self._provider, auth, nicknym.keymanager)
+ # smtp = LeapSmtp(self._provider, auth, nicknym.keymanager)
+ smtp = None
- return LeapSession(self._provider, auth, soledad, nicknym, incoming_mail_fetcher, smtp)
+ return LeapSession(self._provider, auth, soledad, nicknym, account, incoming_mail_fetcher, smtp)
def _lookup_session(self, key):
global SESSIONS
@@ -143,6 +148,12 @@ 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, user_mail, soledad_session):
+ account = IMAPAccount(user_mail, soledad_session.soledad)
+ return account
+ # memstore = MemoryStore(permanent_store=SoledadStore(soledad_session.soledad))
+ # return SoledadBackedAccount(uuid, soledad_session.soledad, memstore)
+
def _create_incoming_mail_fetcher(self, nicknym, soledad_session, auth, username):
return IncomingMail(nicknym.keymanager,
soledad_session.soledad,
diff --git a/service/pixelated/bitmask_libraries/soledad.py b/service/pixelated/bitmask_libraries/soledad.py
index e8e81ffa..684d7da8 100644
--- a/service/pixelated/bitmask_libraries/soledad.py
+++ b/service/pixelated/bitmask_libraries/soledad.py
@@ -58,10 +58,10 @@ class SoledadSession(object):
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,
+ passphrase=unicode(encryption_passphrase),
+ secrets_path=secrets,
+ local_db_path=local_db, server_url=server_url,
+ cert_file=LeapCertificate(self.provider).provider_api_cert,
shared_db=None,
auth_token=self.user_token,
defer_encryption=False)
diff --git a/service/pixelated/extensions/keymanager_fetch_key.py b/service/pixelated/extensions/keymanager_fetch_key.py
index d39d1f96..114e852e 100644
--- a/service/pixelated/extensions/keymanager_fetch_key.py
+++ b/service/pixelated/extensions/keymanager_fetch_key.py
@@ -57,4 +57,4 @@ def patched_fetch_keys_from_server(self, address):
raise KeyNotFound(address)
-leap.keymanager.KeyManager._fetch_keys_from_server = patched_fetch_keys_from_server
+# leap.keymanager.KeyManager._fetch_keys_from_server = patched_fetch_keys_from_server
diff --git a/service/pixelated/extensions/shared_db.py b/service/pixelated/extensions/shared_db.py
index 3e8a978e..b433dd50 100644
--- a/service/pixelated/extensions/shared_db.py
+++ b/service/pixelated/extensions/shared_db.py
@@ -13,4 +13,4 @@ def patched_sign_request(self, method, url_query, params):
'Wrong credentials: %s' % self._creds)
-TokenBasedAuth._sign_request = patched_sign_request
+# TokenBasedAuth._sign_request = patched_sign_request
diff --git a/service/pixelated/extensions/soledad_sync_exception.py b/service/pixelated/extensions/soledad_sync_exception.py
index cb3204ad..c3ef5176 100644
--- a/service/pixelated/extensions/soledad_sync_exception.py
+++ b/service/pixelated/extensions/soledad_sync_exception.py
@@ -19,4 +19,4 @@ def patched_sync(self, defer_decryption=True):
client.logger.error("Soledad exception when syncing: %s - %s" % (e.__class__.__name__, e.message))
-client.Soledad.sync = patched_sync
+# client.Soledad.sync = patched_sync
diff --git a/service/pixelated/maintenance.py b/service/pixelated/maintenance.py
index 69cd674b..868c9e5b 100644
--- a/service/pixelated/maintenance.py
+++ b/service/pixelated/maintenance.py
@@ -14,6 +14,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
+import logging
from mailbox import Maildir
from twisted.internet import reactor, defer
from twisted.internet.threads import deferToThread
@@ -22,6 +23,7 @@ from pixelated.config import logger, arguments
from leap.mail.constants import MessageFlags
import time
+from twisted.mail import imap4
def initialize():
@@ -54,12 +56,21 @@ def create_execute_command(args, leap_session):
return leap_session, soledad
+ @defer.inlineCallbacks
def soledad_sync(args):
leap_session, soledad = args
+ log = logging.getLogger('some logger')
- soledad.sync()
+ log.warn('Before sync')
- return args
+ yield soledad.sync()
+
+ log.warn('after sync')
+
+ defer.returnValue(args)
+
+ # return args
+ return
tearDown = defer.Deferred()
@@ -109,11 +120,17 @@ def is_keep_file(mail):
return mail['subject'] is None
+@defer.inlineCallbacks
def add_mail_folder(account, maildir, folder_name, deferreds):
- if folder_name not in account.mailboxes:
+ try:
+ mbx = yield account.getMailbox(folder_name)
+ except imap4.MailboxException:
account.addMailbox(folder_name)
+ mbx = yield account.getMailbox(folder_name)
+ # if folder_name not in account.mailboxes:
+ # account.addMailbox(folder_name)
- mbx = account.getMailbox(folder_name)
+ mbx = yield account.getMailbox(folder_name)
for mail in maildir:
if is_keep_file(mail):
continue
@@ -124,7 +141,7 @@ def add_mail_folder(account, maildir, folder_name, deferreds):
if 'R' in mail.get_flags():
flags = (MessageFlags.ANSWERED_FLAG,) + flags
- deferreds.append(mbx.addMessage(mail.as_string(), flags=flags, notify_on_disk=False))
+ deferreds.append(mbx.addMessage(mail.as_string(), flags=flags, notify_just_mdoc=False))
@defer.inlineCallbacks
@@ -164,20 +181,21 @@ def flush_to_soledad(args, finalize):
return args
+@defer.inlineCallbacks
def dump_soledad(args):
leap_session, soledad = args
- generation, docs = soledad.get_all_docs()
+ generation, docs = yield soledad.get_all_docs()
for doc in docs:
print doc
print '\n'
- return args
+ defer.returnValue(args)
def shutdown(args):
- time.sleep(30)
+ # time.sleep(30)
reactor.stop()