From 7d4ab674a167d48686f61310ff4ff6a62a545e67 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Wed, 6 May 2015 17:42:26 -0300 Subject: [feat] adapt to new events api on common - Related: #6359 --- client/changes/VERSION_COMPAT | 2 ++ .../changes/feature_adapt-to-new-events-on-common | 1 + client/src/leap/soledad/client/api.py | 2 +- client/src/leap/soledad/client/events.py | 29 +++++++++++----------- client/src/leap/soledad/client/http_target.py | 6 ++--- client/src/leap/soledad/client/secrets.py | 12 ++++----- 6 files changed, 27 insertions(+), 25 deletions(-) create mode 100644 client/changes/feature_adapt-to-new-events-on-common (limited to 'client') diff --git a/client/changes/VERSION_COMPAT b/client/changes/VERSION_COMPAT index 782844d7..c0747052 100644 --- a/client/changes/VERSION_COMPAT +++ b/client/changes/VERSION_COMPAT @@ -9,3 +9,5 @@ # BEGIN DEPENDENCY LIST ------------------------- # leap.foo.bar>=x.y.z pysqlcipher>2.6.3 +leap.common>=0.4 +leap.soledad.common>=0.6.5 diff --git a/client/changes/feature_adapt-to-new-events-on-common b/client/changes/feature_adapt-to-new-events-on-common new file mode 100644 index 00000000..cd55fa7d --- /dev/null +++ b/client/changes/feature_adapt-to-new-events-on-common @@ -0,0 +1 @@ +- Adapt soledad to the new events api on leap.common. Related to #6359. diff --git a/client/src/leap/soledad/client/api.py b/client/src/leap/soledad/client/api.py index 91e0a4a0..76d6acc3 100644 --- a/client/src/leap/soledad/client/api.py +++ b/client/src/leap/soledad/client/api.py @@ -656,7 +656,7 @@ class Soledad(object): defer_decryption=defer_decryption) def _sync_callback(local_gen): - soledad_events.signal( + soledad_events.emit( soledad_events.SOLEDAD_DONE_DATA_SYNC, self.uuid) return local_gen diff --git a/client/src/leap/soledad/client/events.py b/client/src/leap/soledad/client/events.py index 88e28674..b1379521 100644 --- a/client/src/leap/soledad/client/events.py +++ b/client/src/leap/soledad/client/events.py @@ -20,28 +20,27 @@ Signaling functions. """ +from leap.common.events import emit +from leap.common.events import catalog -from leap.common import events -from leap.common.events import signal - -SOLEDAD_CREATING_KEYS = events.proto.SOLEDAD_CREATING_KEYS -SOLEDAD_DONE_CREATING_KEYS = events.proto.SOLEDAD_DONE_CREATING_KEYS -SOLEDAD_DOWNLOADING_KEYS = events.proto.SOLEDAD_DOWNLOADING_KEYS +SOLEDAD_CREATING_KEYS = catalog.SOLEDAD_CREATING_KEYS +SOLEDAD_DONE_CREATING_KEYS = catalog.SOLEDAD_DONE_CREATING_KEYS +SOLEDAD_DOWNLOADING_KEYS = catalog.SOLEDAD_DOWNLOADING_KEYS SOLEDAD_DONE_DOWNLOADING_KEYS = \ - events.proto.SOLEDAD_DONE_DOWNLOADING_KEYS -SOLEDAD_UPLOADING_KEYS = events.proto.SOLEDAD_UPLOADING_KEYS + catalog.SOLEDAD_DONE_DOWNLOADING_KEYS +SOLEDAD_UPLOADING_KEYS = catalog.SOLEDAD_UPLOADING_KEYS SOLEDAD_DONE_UPLOADING_KEYS = \ - events.proto.SOLEDAD_DONE_UPLOADING_KEYS -SOLEDAD_NEW_DATA_TO_SYNC = events.proto.SOLEDAD_NEW_DATA_TO_SYNC -SOLEDAD_DONE_DATA_SYNC = events.proto.SOLEDAD_DONE_DATA_SYNC -SOLEDAD_SYNC_SEND_STATUS = events.proto.SOLEDAD_SYNC_SEND_STATUS -SOLEDAD_SYNC_RECEIVE_STATUS = events.proto.SOLEDAD_SYNC_RECEIVE_STATUS + catalog.SOLEDAD_DONE_UPLOADING_KEYS +SOLEDAD_NEW_DATA_TO_SYNC = catalog.SOLEDAD_NEW_DATA_TO_SYNC +SOLEDAD_DONE_DATA_SYNC = catalog.SOLEDAD_DONE_DATA_SYNC +SOLEDAD_SYNC_SEND_STATUS = catalog.SOLEDAD_SYNC_SEND_STATUS +SOLEDAD_SYNC_RECEIVE_STATUS = catalog.SOLEDAD_SYNC_RECEIVE_STATUS __all__ = [ - "events", - "signal", + "catalog", + "emit", "SOLEDAD_CREATING_KEYS", "SOLEDAD_DONE_CREATING_KEYS", "SOLEDAD_DOWNLOADING_KEYS", diff --git a/client/src/leap/soledad/client/http_target.py b/client/src/leap/soledad/client/http_target.py index 5eef2df3..30590ae1 100644 --- a/client/src/leap/soledad/client/http_target.py +++ b/client/src/leap/soledad/client/http_target.py @@ -47,7 +47,7 @@ from leap.soledad.client.crypto import encrypt_doc from leap.soledad.client.crypto import decrypt_doc from leap.soledad.client.events import SOLEDAD_SYNC_SEND_STATUS from leap.soledad.client.events import SOLEDAD_SYNC_RECEIVE_STATUS -from leap.soledad.client.events import signal +from leap.soledad.client.events import emit from leap.soledad.client.encdecpool import SyncDecrypterPool @@ -311,7 +311,7 @@ class SoledadHTTPSyncTarget(SyncTarget): if self._defer_encryption: self._sync_enc_pool.delete_encrypted_doc( doc.doc_id, doc.rev) - signal(SOLEDAD_SYNC_SEND_STATUS, + emit(SOLEDAD_SYNC_SEND_STATUS, "Soledad sync send status: %d/%d" % (idx, total)) response_dict = json.loads(result)[0] @@ -535,7 +535,7 @@ class SoledadHTTPSyncTarget(SyncTarget): # end of symmetric decryption # ------------------------------------------------------------- msg = "%d/%d" % (idx, total) - signal(SOLEDAD_SYNC_RECEIVE_STATUS, msg) + emit(SOLEDAD_SYNC_RECEIVE_STATUS, msg) logger.debug("Soledad sync receive status: %s" % msg) return number_of_changes, new_generation, new_transaction_id diff --git a/client/src/leap/soledad/client/secrets.py b/client/src/leap/soledad/client/secrets.py index 96f7e906..e89e21aa 100644 --- a/client/src/leap/soledad/client/secrets.py +++ b/client/src/leap/soledad/client/secrets.py @@ -480,13 +480,13 @@ class SoledadSecrets(object): :return: a document with encrypted key material in its contents :rtype: document.SoledadDocument """ - events.signal(events.SOLEDAD_DOWNLOADING_KEYS, self._uuid) + events.emit(events.SOLEDAD_DOWNLOADING_KEYS, self._uuid) db = self._shared_db if not db: logger.warning('No shared db found') return doc = db.get_doc(self._shared_db_doc_id()) - events.signal(events.SOLEDAD_DONE_DOWNLOADING_KEYS, self._uuid) + events.emit(events.SOLEDAD_DONE_DOWNLOADING_KEYS, self._uuid) return doc def _put_secrets_in_shared_db(self): @@ -509,13 +509,13 @@ class SoledadSecrets(object): # fill doc with encrypted secrets doc.content = self._export_recovery_document() # upload secrets to server - events.signal(events.SOLEDAD_UPLOADING_KEYS, self._uuid) + events.emit(events.SOLEDAD_UPLOADING_KEYS, self._uuid) db = self._shared_db if not db: logger.warning('No shared db found') return db.put_doc(doc) - events.signal(events.SOLEDAD_DONE_UPLOADING_KEYS, self._uuid) + events.emit(events.SOLEDAD_DONE_UPLOADING_KEYS, self._uuid) # # Management of secret for symmetric encryption. @@ -635,13 +635,13 @@ class SoledadSecrets(object): :return: The id of the generated secret. :rtype: str """ - events.signal(events.SOLEDAD_CREATING_KEYS, self._uuid) + events.emit(events.SOLEDAD_CREATING_KEYS, self._uuid) # generate random secret secret = os.urandom(self.GEN_SECRET_LENGTH) secret_id = sha256(secret).hexdigest() self._secrets[secret_id] = secret self._store_secrets() - events.signal(events.SOLEDAD_DONE_CREATING_KEYS, self._uuid) + events.emit(events.SOLEDAD_DONE_CREATING_KEYS, self._uuid) return secret_id def _store_secrets(self): -- cgit v1.2.3