From 0b51f4d36f4fe91147d2d06930798f84d1878a49 Mon Sep 17 00:00:00 2001 From: James Booth Date: Mon, 26 Oct 2015 23:40:37 +0000 Subject: ui_smp_unsuccessful_receiver takes ProfChatWin --- src/otr/otrlibv3.c | 5 ++++- src/otr/otrlibv4.c | 4 +++- src/ui/chatwin.c | 10 +++++----- src/ui/ui.h | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c index de388b8f..3fb85e0e 100644 --- a/src/otr/otrlibv3.c +++ b/src/otr/otrlibv3.c @@ -206,7 +206,10 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext ui_smp_successful(context->username); ui_trust(context->username); } else { - ui_smp_unsuccessful_receiver(context->username); + ProfChatWin *chatwin = wins_get_chat(context->username); + if (chatwin) { + ui_smp_unsuccessful_receiver(chatwin); + } ui_untrust(context->username); } } diff --git a/src/otr/otrlibv4.c b/src/otr/otrlibv4.c index ebdc2996..acce648e 100644 --- a/src/otr/otrlibv4.c +++ b/src/otr/otrlibv4.c @@ -210,7 +210,9 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event, ui_smp_unsuccessful_sender(chatwin); } } else if (nextMsg == OTRL_SMP_EXPECT4) { - ui_smp_unsuccessful_receiver(context->username); + if (chatwin) { + ui_smp_unsuccessful_receiver(chatwin); + } } ui_untrust(context->username); } else { diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index e782c0bc..35e50af1 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -131,12 +131,12 @@ ui_smp_unsuccessful_sender(ProfChatWin *chatwin) } void -ui_smp_unsuccessful_receiver(const char *const barejid) +ui_smp_unsuccessful_receiver(ProfChatWin *chatwin) { - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authentication failed, the secret entered by %s does not match yours.", barejid); - } + assert(chatwin != NULL); + + win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", + "Authentication failed, the secret entered by %s does not match yours.", chatwin->barejid); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index c1efb9ea..140d3426 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -71,7 +71,7 @@ void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question); void ui_smp_successful(const char *const barejid); void ui_smp_unsuccessful_sender(ProfChatWin *chatwin); -void ui_smp_unsuccessful_receiver(const char *const barejid); +void ui_smp_unsuccessful_receiver(ProfChatWin *chatwin); void ui_smp_aborted(const char *const barejid); void ui_smp_answer_success(const char *const barejid); -- cgit 1.4.1-2-gfad0