From a759db8bc3c3f9b826f3332da11f090e5c758ee5 Mon Sep 17 00:00:00 2001 From: Folker Bernitt Date: Mon, 20 Jul 2015 11:08:11 +0200 Subject: Enable initial sync and background jobs. --- service/pixelated/application.py | 3 +++ service/pixelated/bitmask_libraries/session.py | 12 +++++++----- service/pixelated/config/leap.py | 7 +++++-- 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'service') diff --git a/service/pixelated/application.py b/service/pixelated/application.py index 68bb70b2..eafeede7 100644 --- a/service/pixelated/application.py +++ b/service/pixelated/application.py @@ -83,6 +83,9 @@ def initialize(): args.organization_mode, args.leap_home)) + deferred.addCallback( + lambda leap_session: leap_session.initial_sync()) + deferred.addCallback( lambda leap_session: start_user_agent( loading_app, diff --git a/service/pixelated/bitmask_libraries/session.py b/service/pixelated/bitmask_libraries/session.py index d1bdac73..50f5e7c7 100644 --- a/service/pixelated/bitmask_libraries/session.py +++ b/service/pixelated/bitmask_libraries/session.py @@ -62,11 +62,12 @@ class LeapSession(object): self.account = soledad_account self.incoming_mail_fetcher = incoming_mail_fetcher - d = self.sync() - d.addCallback(lambda _: self.nicknym.generate_openpgp_key()) - - if self.config.start_background_jobs: - d.addCallback(lambda _: self.start_background_jobs()) + @defer.inlineCallbacks + def initial_sync(self): + yield self.sync() + yield self.nicknym.generate_openpgp_key() + yield self.start_background_jobs() + defer.returnValue(self) def account_email(self): name = self.user_auth.username @@ -78,6 +79,7 @@ class LeapSession(object): @defer.inlineCallbacks def start_background_jobs(self): self.incoming_mail_fetcher = yield self.incoming_mail_fetcher + reactor.callFromThread(self.incoming_mail_fetcher.startService) def stop_background_jobs(self): diff --git a/service/pixelated/config/leap.py b/service/pixelated/config/leap.py index c28c371b..3a0f96fd 100644 --- a/service/pixelated/config/leap.py +++ b/service/pixelated/config/leap.py @@ -6,8 +6,9 @@ from pixelated.bitmask_libraries.config import LeapConfig from pixelated.bitmask_libraries.certs import LeapCertificate from pixelated.bitmask_libraries.provider import LeapProvider from pixelated.bitmask_libraries.session import LeapSessionFactory +from twisted.internet import defer - +@defer.inlineCallbacks def initialize_leap(leap_provider_cert, leap_provider_cert_fingerprint, credentials_file, @@ -23,7 +24,9 @@ def initialize_leap(leap_provider_cert, LeapCertificate(provider).setup_ca_bundle() leap_session = LeapSessionFactory(provider).create(username, password) - return leap_session + yield leap_session.initial_sync() + + defer.returnValue(leap_session) def init_monkeypatches(): -- cgit v1.2.3