diff options
author | James Booth <boothj5@gmail.com> | 2015-10-26 23:29:01 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-10-26 23:29:01 +0000 |
commit | 3ce55de1e172c37ba32cdb7b2200b8758e2c8459 (patch) | |
tree | ec1197e162a016e44e39432581d0d82eef01eaee | |
parent | 55e857d6a8ccd3c5f993ac867c864e7b22be1645 (diff) | |
download | profani-tty-3ce55de1e172c37ba32cdb7b2200b8758e2c8459.tar.gz |
ui_smp_recipient_initiated_q takes ProfChatWin
-rw-r--r-- | src/otr/otrlibv3.c | 11 | ||||
-rw-r--r-- | src/otr/otrlibv4.c | 4 | ||||
-rw-r--r-- | src/ui/chatwin.c | 13 | ||||
-rw-r--r-- | src/ui/ui.h | 2 | ||||
-rw-r--r-- | tests/unittests/ui/stub_ui.c | 2 |
5 files changed, 18 insertions, 14 deletions
diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c index fa574bfc..52b9a022 100644 --- a/src/otr/otrlibv3.c +++ b/src/otr/otrlibv3.c @@ -152,10 +152,13 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext if (nextMsg != OTRL_SMP_EXPECT1) { otrl_message_abort_smp(user_state, ops, NULL, context); } else { - char *question = (char *)tlv->data; - char *eoq = memchr(question, '\0', tlv->len); - if (eoq) { - ui_smp_recipient_initiated_q(context->username, question); + ProfChatWin *chatwin = wins_get_chat(context->username); + if (chatwin) { + char *question = (char *)tlv->data; + char *eoq = memchr(question, '\0', tlv->len); + if (eoq) { + ui_smp_recipient_initiated_q(chatwin, question); + } } } } diff --git a/src/otr/otrlibv4.c b/src/otr/otrlibv4.c index 1f2c4057..59cd7a0d 100644 --- a/src/otr/otrlibv4.c +++ b/src/otr/otrlibv4.c @@ -189,7 +189,9 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event, break; case OTRL_SMPEVENT_ASK_FOR_ANSWER: - ui_smp_recipient_initiated_q(context->username, question); + if (chatwin) { + ui_smp_recipient_initiated_q(chatwin, question); + } break; case OTRL_SMPEVENT_SUCCESS: diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 7b1c3365..301fc45e 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -110,14 +110,13 @@ ui_smp_recipient_initiated(ProfChatWin *chatwin) } void -ui_smp_recipient_initiated_q(const char *const barejid, const char *question) +ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question) { - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s wants to authenticate your identity with the following question:", barejid); - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", " %s", question); - win_print((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "use '/otr answer <answer>'."); - } + assert(chatwin != NULL); + + win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s wants to authenticate your identity with the following question:", chatwin->barejid); + win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", " %s", question); + win_print((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "use '/otr answer <answer>'."); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index 139a291f..41cc35fe 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -67,7 +67,7 @@ void ui_gone_insecure(ProfChatWin *chatwin); void ui_trust(const char *const barejid); void ui_untrust(const char *const barejid); void ui_smp_recipient_initiated(ProfChatWin *chatwin); -void ui_smp_recipient_initiated_q(const char *const barejid, const char *question); +void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question); void ui_smp_successful(const char *const barejid); void ui_smp_unsuccessful_sender(const char *const barejid); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 27a6314f..f3c20627 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -71,7 +71,7 @@ void ui_gone_insecure(ProfChatWin *chatwin) {} void ui_trust(const char * const barejid) {} void ui_untrust(const char * const barejid) {} void ui_smp_recipient_initiated(ProfChatWin *chatwin) {} -void ui_smp_recipient_initiated_q(const char * const barejid, const char *question) {} +void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question) {} void ui_smp_successful(const char * const barejid) {} void ui_smp_unsuccessful_sender(const char * const barejid) {} |