def prof_on_chat_win_focus(barejid): if not ProfActiveOmemoChats.account_is_registered(barejid): # get remembered user sessions u_sess = prof.settings_string_list_get(SETTINGS_GROUP, 'omemo_sessions') if u_sess and barejid in u_sess: _start_omemo_session(barejid)
def _start_omemo_session(jid): # should be started before the first message is sent. # we store the jid in ProfActiveOmemoChats as the user at least intends to # use OMEMO encryption. The respecting methods should then not ignore # sending OMEMO messages and fail if no session was created then. if not ProfActiveOmemoChats.account_is_registered(jid): ProfActiveOmemoChats.add(jid) else: ProfActiveOmemoChats.activate(jid) # ensure we have no running OTR session prof.encryption_reset(jid) # Visualize that OMEMO is now running prof.chat_set_titlebar_enctext(jid, 'OMEMO') message_char = _get_omemo_message_char() prof.chat_set_outgoing_char(jid, message_char) show_chat_info(jid, 'OMEMO Session started.') _show_no_trust_mgmt_header(jid) log.info('Query Devicelist for {0}'.format(jid)) _query_device_list(jid) prof.settings_string_list_add(SETTINGS_GROUP, 'omemo_sessions', jid)