1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

ui_gone_secure takes ProfChatWin

This commit is contained in:
James Booth 2015-10-26 23:04:45 +00:00
parent 2efaa464bf
commit 4fb0b4b0da
5 changed files with 15 additions and 17 deletions

View File

@ -1532,7 +1532,7 @@ cmd_msg(ProfWin *window, const char *const command, gchar **args)
} else { } else {
#ifdef HAVE_LIBOTR #ifdef HAVE_LIBOTR
if (otr_is_secure(barejid)) { if (otr_is_secure(barejid)) {
ui_gone_secure(barejid, otr_is_trusted(barejid)); ui_gone_secure(chatwin, otr_is_trusted(barejid));
} }
#endif #endif
} }
@ -4893,7 +4893,7 @@ cmd_otr(ProfWin *window, const char *const command, gchar **args)
return TRUE; return TRUE;
} }
ui_gone_secure(barejid, otr_is_trusted(barejid)); ui_gone_secure(chatwin, otr_is_trusted(barejid));
return TRUE; return TRUE;
// no recipient, use current chat // no recipient, use current chat

View File

@ -42,6 +42,7 @@
#include "otr/otrlib.h" #include "otr/otrlib.h"
#include "log.h" #include "log.h"
#include "roster_list.h" #include "roster_list.h"
#include "window_list.h"
#include "contact.h" #include "contact.h"
#include "ui/ui.h" #include "ui/ui.h"
#include "config/preferences.h" #include "config/preferences.h"
@ -143,7 +144,12 @@ cb_write_fingerprints(void *opdata)
static void static void
cb_gone_secure(void *opdata, ConnContext *context) cb_gone_secure(void *opdata, ConnContext *context)
{ {
ui_gone_secure(context->username, otr_is_trusted(context->username)); ProfChatWin *chatwin = wins_get_chat(context->username);
if (!chatwin) {
chatwin = (ProfChatWin*) wins_new_chat(context->username);
}
ui_gone_secure(chatwin, otr_is_trusted(context->username));
} }
char* char*

View File

@ -54,20 +54,12 @@ ui_message_receipt(ProfChatWin *chatwin, const char *const id)
} }
void void
ui_gone_secure(const char *const barejid, gboolean trusted) ui_gone_secure(ProfChatWin *chatwin, gboolean trusted)
{ {
ProfWin *window = NULL;
ProfChatWin *chatwin = wins_get_chat(barejid);
if (chatwin) {
window = (ProfWin*)chatwin;
} else {
window = wins_new_chat(barejid);
chatwin = (ProfChatWin*)window;
}
chatwin->is_otr = TRUE; chatwin->is_otr = TRUE;
chatwin->otr_is_trusted = trusted; chatwin->otr_is_trusted = trusted;
ProfWin *window = (ProfWin*) chatwin;
if (trusted) { if (trusted) {
win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted)."); win_print(window, '!', 0, NULL, 0, THEME_OTR_STARTED_TRUSTED, "", "OTR session started (trusted).");
} else { } else {
@ -84,7 +76,7 @@ ui_gone_secure(const char *const barejid, gboolean trusted)
if (ui_index == 10) { if (ui_index == 10) {
ui_index = 0; ui_index = 0;
} }
cons_show("%s started an OTR session (%d).", barejid, ui_index); cons_show("%s started an OTR session (%d).", chatwin->barejid, ui_index);
cons_alert(); cons_alert();
} }
} }

View File

@ -62,7 +62,7 @@ GSList* ui_get_chat_recipients(void);
void ui_switch_win(ProfWin *window); void ui_switch_win(ProfWin *window);
void ui_sigwinch_handler(int sig); void ui_sigwinch_handler(int sig);
void ui_gone_secure(const char *const barejid, gboolean trusted); void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted);
void ui_gone_insecure(const char *const barejid); void ui_gone_insecure(const char *const barejid);
void ui_trust(const char *const barejid); void ui_trust(const char *const barejid);
void ui_untrust(const char *const barejid); void ui_untrust(const char *const barejid);

View File

@ -66,7 +66,7 @@ GSList* ui_get_chat_recipients(void)
void ui_switch_win(ProfWin *win) {} void ui_switch_win(ProfWin *win) {}
void ui_gone_secure(const char * const barejid, gboolean trusted) {} void ui_gone_secure(ProfChatWin *chatwin, gboolean trusted) {}
void ui_gone_insecure(const char * const barejid) {} void ui_gone_insecure(const char * const barejid) {}
void ui_trust(const char * const barejid) {} void ui_trust(const char * const barejid) {}
void ui_untrust(const char * const barejid) {} void ui_untrust(const char * const barejid) {}