diff options
author | James Booth <boothj5@gmail.com> | 2015-10-26 23:22:59 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-10-26 23:22:59 +0000 |
commit | 55e857d6a8ccd3c5f993ac867c864e7b22be1645 (patch) | |
tree | 9198deb58bed0a6544d347bbe9a09d4b9964865b | |
parent | 93c3feeacf090262ee24a8610f451a9196d92581 (diff) | |
download | profani-tty-55e857d6a8ccd3c5f993ac867c864e7b22be1645.tar.gz |
ui_smp_recipient_initiated takes ProfChatWin
-rw-r--r-- | src/otr/otrlibv3.c | 5 | ||||
-rw-r--r-- | src/otr/otrlibv4.c | 7 | ||||
-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, 16 insertions, 9 deletions
diff --git a/src/otr/otrlibv3.c b/src/otr/otrlibv3.c index 9bab4eed..fa574bfc 100644 --- a/src/otr/otrlibv3.c +++ b/src/otr/otrlibv3.c @@ -140,7 +140,10 @@ otrlib_handle_tlvs(OtrlUserState user_state, OtrlMessageAppOps *ops, ConnContext if (nextMsg != OTRL_SMP_EXPECT1) { otrl_message_abort_smp(user_state, ops, NULL, context); } else { - ui_smp_recipient_initiated(context->username); + ProfChatWin *chatwin = wins_get_chat(context->username); + if (chatwin) { + ui_smp_recipient_initiated(chatwin); + } g_hash_table_insert(smp_initiators, strdup(context->username), strdup(context->username)); } } diff --git a/src/otr/otrlibv4.c b/src/otr/otrlibv4.c index 8ed17fcf..1f2c4057 100644 --- a/src/otr/otrlibv4.c +++ b/src/otr/otrlibv4.c @@ -37,6 +37,7 @@ #include <libotr/message.h> #include "ui/ui.h" +#include "window_list.h" #include "log.h" #include "otr/otr.h" #include "otr/otrlib.h" @@ -176,10 +177,14 @@ cb_handle_smp_event(void *opdata, OtrlSMPEvent smp_event, OtrlMessageAppOps *ops = otr_messageops(); GHashTable *smp_initiators = otr_smpinitators(); + ProfChatWin *chatwin = wins_get_chat(context->username); + switch(smp_event) { case OTRL_SMPEVENT_ASK_FOR_SECRET: - ui_smp_recipient_initiated(context->username); + if (chatwin) { + ui_smp_recipient_initiated(chatwin); + } g_hash_table_insert(smp_initiators, strdup(context->username), strdup(context->username)); break; diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c index 3b3d2e1c..7b1c3365 100644 --- a/src/ui/chatwin.c +++ b/src/ui/chatwin.c @@ -102,12 +102,11 @@ ui_gone_insecure(ProfChatWin *chatwin) } void -ui_smp_recipient_initiated(const char *const barejid) +ui_smp_recipient_initiated(ProfChatWin *chatwin) { - ProfChatWin *chatwin = wins_get_chat(barejid); - if (chatwin) { - win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s wants to authenticate your identity, use '/otr secret <secret>'.", barejid); - } + assert(chatwin != NULL); + + win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s wants to authenticate your identity, use '/otr secret <secret>'.", chatwin->barejid); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index 9df8d9d3..139a291f 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -66,7 +66,7 @@ void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted); 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(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_successful(const char *const barejid); diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index 11f648a5..27a6314f 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -70,7 +70,7 @@ void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted) {} 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(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_successful(const char * const barejid) {} |