diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2017-04-06 23:25:02 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2017-04-06 23:27:03 +0300 |
commit | 77f05f77b497b1d69e8107caefd6d19fa9c609ab (patch) | |
tree | e2f921999022cc109769ec9121dfada6f42f760e | |
parent | 7026430bb2c2fc4b19f844ef20e7734628139003 (diff) |
jabber: omemo: working on 4.4
implemented sessions cleanup on exit
-rwxr-xr-x | protocols/JabberG/src/jabber_omemo.cpp | 21 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.cpp | 5 |
2 files changed, 20 insertions, 6 deletions
diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index 4e2472ff75..5a4c38fce7 100755 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -545,7 +545,16 @@ namespace omemo { session_cipher *cipher;
signal_protocol_store_context *store_context;
};
- std::map<MCONTACT, omemo_session_jabber_internal_ptrs> omemo_sessions;
+ std::map<MCONTACT, omemo_session_jabber_internal_ptrs> sessions_internal;
+ void clean_sessions()
+ {
+ for (std::map<MCONTACT, omemo_session_jabber_internal_ptrs>::iterator i = sessions_internal.begin(), end = sessions_internal.end(); i != end; ++i)
+ {
+ session_cipher_free(i->second.cipher);
+ session_builder_free(i->second.builder);
+ signal_protocol_store_context_destroy(i->second.store_context);
+ }
+ }
//signal_protocol_session_store callbacks follow
/*
@@ -720,7 +729,7 @@ db_get_blob sip.user_data = (void*)hContact;
signal_protocol_store_context_set_identity_key_store(store_context, &sip);
- omemo_sessions[hContact].store_context = store_context;
+ sessions_internal[hContact].store_context = store_context;
return true; //success
}
@@ -734,9 +743,9 @@ db_get_blob };
session_builder *builder;
- session_builder_create(&builder, omemo_sessions[hContact].store_context, &address, global_context);
+ session_builder_create(&builder, sessions_internal[hContact].store_context, &address, global_context);
- omemo_sessions[hContact].builder = builder;
+ sessions_internal[hContact].builder = builder;
mir_free(jid_str);
@@ -756,8 +765,8 @@ db_get_blob /* Create the session cipher and encrypt the message */
session_cipher *cipher;
- session_cipher_create(&cipher, omemo_sessions[hContact].store_context, &address, global_context);
- omemo_sessions[hContact].cipher = cipher;
+ session_cipher_create(&cipher, sessions_internal[hContact].store_context, &address, global_context);
+ sessions_internal[hContact].cipher = cipher;
return true; //success
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index b5bb2108ed..46aeb99dc6 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -153,6 +153,10 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : m_tszSelectedLang = mir_wstrdup(L"en");
}
+namespace omemo {
+ void clean_sessions();
+};
+
CJabberProto::~CJabberProto()
{
WsUninit();
@@ -190,6 +194,7 @@ CJabberProto::~CJabberProto() mir_free(m_lstJabberFeatCapPairsDynamic[i]->szDescription);
delete m_lstJabberFeatCapPairsDynamic[i];
}
+ omemo::clean_sessions();
}
////////////////////////////////////////////////////////////////////////////////////////
|