diff options
author | James Booth <boothj5@gmail.com> | 2015-10-26 23:50:56 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-10-26 23:50:56 +0000 |
commit | 8bd74cefcf73772a52b40c919a1e70da90be8a33 (patch) | |
tree | 225fc4829a86c8ef951ee330286b3ebde8800039 | |
parent | 3cea2bc4f4ae6d57cf4cdead868c1e02311aca40 (diff) | |
download | profani-tty-8bd74cefcf73772a52b40c919a1e70da90be8a33.tar.gz |
ui_smp_successful takes ProfChatWin
-rw-r--r-- | src/otr/otrlibv3.c | 12 | ||||
-rw-r--r-- | src/otr/otrlibv4.c | 4 | ||||
-rw-r--r-- | src/ui/chatwin.c | 9 | ||||
-rw-r--r-- | src/ui/ui.h | 2 | ||||
-rw-r--r-- | tests/unittests/ui/stub_ui.c | 2 |
5 files changed, 17 insertions, 12 deletions
diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c index b12abbff..05083dea 100644 --- a/src/otr/otrlibv3.c +++ b/src/otr/otrlibv3.c @@ -177,11 +177,13 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext } else { context->smstate->nextExpected = OTRL_SMP_EXPECT1; if (context->smstate->received_question == 0) { + ProfChatWin *chatwin = wins_get_chat(context->username); if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) { - ui_smp_successful(context->username); + if (chatwin) { + ui_smp_successful(chatwin); + } ui_trust(context->username); } else { - ProfChatWin *chatwin = wins_get_chat(context->username); if (chatwin) { ui_smp_unsuccessful_sender(chatwin); } @@ -202,11 +204,13 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext otrl_message_abort_smp(user_state, ops, NULL, context); } else { context->smstate->nextExpected = OTRL_SMP_EXPECT1; + ProfChatWin *chatwin = wins_get_chat(context->username); if (context->active_fingerprint->trust && (context->active_fingerprint->trust[0] != '\0')) { - ui_smp_successful(context->username); + if (chatwin) { + ui_smp_successful(chatwin); + } ui_trust(context->username); } else { - ProfChatWin *chatwin = wins_get_chat(context->username); if (chatwin) { ui_smp_unsuccessful_receiver(chatwin); } diff --git a/src/otr/otrlibv4.c b/src/otr/otrlibv4.c index 089585fb..29d6d57a 100644 --- a/src/otr/otrlibv4.c +++ b/src/otr/otrlibv4.c @@ -196,7 +196,9 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event, case OTRL_SMPEVENT_SUCCESS: if (context->smstate->received_question == 0) { - ui_smp_successful(context->username); + if (chatwin) { + ui_smp_successful(chatwin); + } ui_trust(context->username); } else { ui_smp_answer_success(context->username); diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index a5b2a9be..5c8dbca6 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -148,12 +148,11 @@ ui_smp_aborted(ProfChatWin *chatwin) } void -ui_smp_successful(const char *const barejid) +ui_smp_successful(ProfChatWin *chatwin) { - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_print((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authentication successful."); - } + assert(chatwin != NULL); + + win_print((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authentication successful."); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index 11b0f9c6..d497ea00 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -69,7 +69,7 @@ void ui_untrust(const char *const barejid); void ui_smp_recipient_initiated(ProfChatWin *chatwin); void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question); -void ui_smp_successful(const char *const barejid); +void ui_smp_successful(ProfChatWin *chatwin); void ui_smp_unsuccessful_sender(ProfChatWin *chatwin); void ui_smp_unsuccessful_receiver(ProfChatWin *chatwin); void ui_smp_aborted(ProfChatWin *chatwin); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index f2b7b01e..77c8dd17 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -73,7 +73,7 @@ void ui_untrust(const char * const barejid) {} void ui_smp_recipient_initiated(ProfChatWin *chatwin) {} void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question) {} -void ui_smp_successful(const char * const barejid) {} +void ui_smp_successful(ProfChatWin *chatwin) {} void ui_smp_unsuccessful_sender(ProfChatWin *chatwin) {} void ui_smp_unsuccessful_receiver(ProfChatWin *chatwin) {} void ui_smp_aborted(ProfChatWin *chatwin) {} |