about summary refs log tree commit diff stats
path: root/src/ui
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-10-27 00:19:22 +0000
committerJames Booth <boothj5@gmail.com>2015-10-27 00:19:22 +0000
commit124aaa9809ee13b382f47f6f3e175bd7fdb98dc5 (patch)
tree8346aecaa20402dc9ac3c84b5fee8573d5341741 /src/ui
parent8bd74cefcf73772a52b40c919a1e70da90be8a33 (diff)
downloadprofani-tty-124aaa9809ee13b382f47f6f3e175bd7fdb98dc5.tar.gz
remaining otr functions take ProfChatWin
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/chatwin.c84
-rw-r--r--src/ui/ui.h12
2 files changed, 45 insertions, 51 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index 5c8dbca6..9d61a62b 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -156,81 +156,75 @@ ui_smp_successful(ProfChatWin *chatwin)
 }
 
 void
-ui_smp_answer_success(const char *const barejid)
+ui_smp_answer_success(ProfChatWin *chatwin)
 {
-    ProfChatWin *chatwin = wins_get_chat(barejid);
-    if (chatwin) {
-        win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s successfully authenticated you.", barejid);
-    }
+    assert(chatwin != NULL);
+
+    win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s successfully authenticated you.", chatwin->barejid);
 }
 
 void
-ui_smp_answer_failure(const char *const barejid)
+ui_smp_answer_failure(ProfChatWin *chatwin)
 {
-    ProfChatWin *chatwin = wins_get_chat(barejid);
-    if (chatwin) {
-        win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s failed to authenticate you.", barejid);
-    }
+    assert(chatwin != NULL);
+
+    win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "%s failed to authenticate you.", chatwin->barejid);
 }
 
 void
-ui_otr_authenticating(const char *const barejid)
+ui_otr_authenticating(ProfChatWin *chatwin)
 {
-    ProfChatWin *chatwin = wins_get_chat(barejid);
-    if (chatwin) {
-        win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authenticating %s...", barejid);
-    }
+    assert(chatwin != NULL);
+
+    win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Authenticating %s...", chatwin->barejid);
 }
 
 void
-ui_otr_authetication_waiting(const char *const barejid)
+ui_otr_authetication_waiting(ProfChatWin *chatwin)
 {
-    ProfChatWin *chatwin = wins_get_chat(barejid);
-    if (chatwin) {
-        win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Awaiting authentication from %s...", barejid);
-    }
+    assert(chatwin != NULL);
+
+    win_vprint((ProfWin*)chatwin, '!', 0, NULL, 0, 0, "", "Awaiting authentication from %s...", chatwin->barejid);
 }
 
 void
-ui_handle_otr_error(const char *const barejid, const char *const message)
+ui_trust(ProfChatWin *chatwin)
 {
-    ProfChatWin *chatwin = wins_get_chat(barejid);
-    if (chatwin) {
-        win_print((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", message);
-    } else {
-        cons_show_error("%s - %s", barejid, message);
+    assert(chatwin != NULL);
+
+    chatwin->is_otr = TRUE;
+    chatwin->otr_is_trusted = TRUE;
+
+    ProfWin *window = (ProfWin*)chatwin;
+    win_print(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted.");
+    if (wins_is_current(window)) {
+        title_bar_switch();
     }
 }
 
 void
-ui_trust(const char *const barejid)
+ui_untrust(ProfChatWin *chatwin)
 {
-    ProfChatWin *chatwin = wins_get_chat(barejid);
-    if (chatwin) {
-        chatwin->is_otr = TRUE;
-        chatwin->otr_is_trusted = TRUE;
+    assert(chatwin != NULL);
 
-        ProfWin *window = (ProfWin*)chatwin;
-        win_print(window, '!', 0, NULL, 0, THEME_OTR_TRUSTED, "", "OTR session trusted.");
-        if (wins_is_current(window)) {
-            title_bar_switch();
-        }
+    chatwin->is_otr = TRUE;
+    chatwin->otr_is_trusted = FALSE;
+
+    ProfWin *window = (ProfWin*)chatwin;
+    win_print(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted.");
+    if (wins_is_current(window)) {
+        title_bar_switch();
     }
 }
 
 void
-ui_untrust(const char *const barejid)
+ui_handle_otr_error(const char *const barejid, const char *const message)
 {
     ProfChatWin *chatwin = wins_get_chat(barejid);
     if (chatwin) {
-        chatwin->is_otr = TRUE;
-        chatwin->otr_is_trusted = FALSE;
-
-        ProfWin *window = (ProfWin*)chatwin;
-        win_print(window, '!', 0, NULL, 0, THEME_OTR_UNTRUSTED, "", "OTR session untrusted.");
-        if (wins_is_current(window)) {
-            title_bar_switch();
-        }
+        win_print((ProfWin*)chatwin, '!', 0, NULL, 0, THEME_ERROR, "", message);
+    } else {
+        cons_show_error("%s - %s", barejid, message);
     }
 }
 
diff --git a/src/ui/ui.h b/src/ui/ui.h
index d497ea00..5d92797d 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -64,8 +64,8 @@ void ui_sigwinch_handler(int sig);
 
 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_trust(ProfChatWin *chatwin);
+void ui_untrust(ProfChatWin *chatwin);
 void ui_smp_recipient_initiated(ProfChatWin *chatwin);
 void ui_smp_recipient_initiated_q(ProfChatWin *chatwin, const char *question);
 
@@ -74,11 +74,11 @@ void ui_smp_unsuccessful_sender(ProfChatWin *chatwin);
 void ui_smp_unsuccessful_receiver(ProfChatWin *chatwin);
 void ui_smp_aborted(ProfChatWin *chatwin);
 
-void ui_smp_answer_success(const char *const barejid);
-void ui_smp_answer_failure(const char *const barejid);
+void ui_smp_answer_success(ProfChatWin *chatwin);
+void ui_smp_answer_failure(ProfChatWin *chatwin);
 
-void ui_otr_authenticating(const char *const barejid);
-void ui_otr_authetication_waiting(const char *const recipient);
+void ui_otr_authenticating(ProfChatWin *chatwin);
+void ui_otr_authetication_waiting(ProfChatWin *chatwin);
 
 void ui_handle_otr_error(const char *const barejid, const char *const message);