aboutsummaryrefslogtreecommitdiff
path: root/plugins/signal-protocol/src/simple_spks.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-11 01:29:38 +0100
committerMarvin W <git@larma.de>2017-03-11 23:59:04 +0100
commitd5ea5172a754848c10d061a4a9dd777f63ba71c1 (patch)
treeaeb7694b93158e23714f481a5cdfb5c87b59b630 /plugins/signal-protocol/src/simple_spks.vala
parente27d63269d0b41fa8d5b5f0f2e4a9dc7de4b9ab9 (diff)
downloaddino-d5ea5172a754848c10d061a4a9dd777f63ba71c1.tar.gz
dino-d5ea5172a754848c10d061a4a9dd777f63ba71c1.zip
Add OMEMO via Plugin
Diffstat (limited to 'plugins/signal-protocol/src/simple_spks.vala')
-rw-r--r--plugins/signal-protocol/src/simple_spks.vala33
1 files changed, 33 insertions, 0 deletions
diff --git a/plugins/signal-protocol/src/simple_spks.vala b/plugins/signal-protocol/src/simple_spks.vala
new file mode 100644
index 00000000..f0fe09ab
--- /dev/null
+++ b/plugins/signal-protocol/src/simple_spks.vala
@@ -0,0 +1,33 @@
+using Gee;
+
+namespace Signal {
+
+public class SimpleSignedPreKeyStore : SignedPreKeyStore {
+ private Map<uint32, SignedPreKeyStore.Key> pre_key_map = new HashMap<uint32, SignedPreKeyStore.Key>();
+
+ public override uint8[]? load_signed_pre_key(uint32 pre_key_id) throws Error {
+ if (contains_signed_pre_key(pre_key_id)) {
+ return pre_key_map[pre_key_id].record;
+ }
+ return null;
+ }
+
+ public override void store_signed_pre_key(uint32 pre_key_id, uint8[] record) throws Error {
+ SignedPreKeyStore.Key key = new Key(pre_key_id, record);
+ pre_key_map[pre_key_id] = key;
+ signed_pre_key_stored(key);
+ }
+
+ public override bool contains_signed_pre_key(uint32 pre_key_id) throws Error {
+ return pre_key_map.has_key(pre_key_id);
+ }
+
+ public override void delete_signed_pre_key(uint32 pre_key_id) throws Error {
+ SignedPreKeyStore.Key key;
+ if (pre_key_map.unset(pre_key_id, out key)) {
+ signed_pre_key_deleted(key);
+ }
+ }
+}
+
+} \ No newline at end of file