diff --git a/src/event/server_events.c b/src/event/server_events.c index 7c1cfd78..36db8ebe 100644 --- a/src/event/server_events.c +++ b/src/event/server_events.c @@ -174,6 +174,10 @@ sv_ev_roster_received(void) const char *fulljid = connection_get_fulljid(); plugins_on_connect(account_name, fulljid); + +#ifdef HAVE_OMEMO + omemo_start_sessions(); +#endif } void diff --git a/src/omemo/omemo.c b/src/omemo/omemo.c index 1d641e4c..7b3855dd 100644 --- a/src/omemo/omemo.c +++ b/src/omemo/omemo.c @@ -23,6 +23,7 @@ #include "xmpp/connection.h" #include "xmpp/muc.h" #include "xmpp/omemo.h" +#include "xmpp/roster_list.h" #include "xmpp/xmpp.h" static gboolean loaded; @@ -304,6 +305,7 @@ omemo_generate_crypto_materials(ProfAccount *account) loaded = TRUE; omemo_publish_crypto_materials(); + omemo_start_sessions(); } void @@ -326,6 +328,20 @@ omemo_publish_crypto_materials(void) jid_destroy(jid); } +void +omemo_start_sessions(void) +{ + GSList *contacts = roster_get_contacts(ROSTER_ORD_NAME); + if (contacts) { + GSList *curr = contacts; + for (curr = contacts; curr != NULL; curr = g_slist_next(curr)){ + PContact contact = curr->data; + const char *jid = p_contact_barejid(contact); + omemo_start_session(jid); + } + } +} + void omemo_start_session(const char *const barejid) { @@ -1267,6 +1283,7 @@ _load_identity(void) loaded = TRUE; omemo_identity_keyfile_save(); + omemo_start_sessions(); } static void diff --git a/src/omemo/omemo.h b/src/omemo/omemo.h index dcae9266..166a5292 100644 --- a/src/omemo/omemo.h +++ b/src/omemo/omemo.h @@ -45,6 +45,7 @@ gboolean omemo_is_trusted_identity(const char *const jid, const char *const fing char *omemo_fingerprint_autocomplete(const char *const search_str, gboolean previous); void omemo_fingerprint_autocomplete_reset(void); +void omemo_start_sessions(void); void omemo_start_session(const char *const barejid); void omemo_start_muc_sessions(const char *const roomjid); void omemo_start_device_session(const char *const jid, uint32_t device_id, GList *prekeys, uint32_t signed_prekey_id, const unsigned char *const signed_prekey, size_t signed_prekey_len, const unsigned char *const signature, size_t signature_len, const unsigned char *const identity_key, size_t identity_key_len);