summaryrefslogtreecommitdiff
path: root/client/src/leap
diff options
context:
space:
mode:
authorIvan Alejandro <ivanalejandro0@gmail.com>2015-05-06 17:42:26 -0300
committerIvan Alejandro <ivanalejandro0@gmail.com>2015-05-27 12:02:39 -0300
commit7d4ab674a167d48686f61310ff4ff6a62a545e67 (patch)
treed8ed270d0a73c50eb65f392f231c5c3107473058 /client/src/leap
parent91674a40edb19cd241c76b27ad998bb5df404570 (diff)
[feat] adapt to new events api on common
- Related: #6359
Diffstat (limited to 'client/src/leap')
-rw-r--r--client/src/leap/soledad/client/api.py2
-rw-r--r--client/src/leap/soledad/client/events.py29
-rw-r--r--client/src/leap/soledad/client/http_target.py6
-rw-r--r--client/src/leap/soledad/client/secrets.py12
4 files changed, 24 insertions, 25 deletions
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):