about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-10-27 23:25:18 +0000
committerJames Booth <boothj5@gmail.com>2015-10-27 23:25:18 +0000
commit31016a21503c42c95eaa8115b8fe7f389c634dd0 (patch)
tree747408216e335c37f053b5d9524f54fe9d50c954
parente7148bf82d8a0e0c68cb794dbce7b2f70d3d0e55 (diff)
downloadprofani-tty-31016a21503c42c95eaa8115b8fe7f389c634dd0.tar.gz
Tidied chatwin_outgoing_carbon
-rw-r--r--src/event/server_events.c9
-rw-r--r--src/ui/chatwin.c18
-rw-r--r--src/ui/ui.h2
-rw-r--r--tests/unittests/ui/stub_ui.c2
4 files changed, 18 insertions, 13 deletions
diff --git a/src/event/server_events.c b/src/event/server_events.c
index e4d19953..b607c4f8 100644
--- a/src/event/server_events.c
+++ b/src/event/server_events.c
@@ -180,7 +180,14 @@ sv_ev_incoming_private_message(const char *const fulljid, char *message)
 void
 sv_ev_outgoing_carbon(char *barejid, char *message)
 {
-    ui_outgoing_chat_msg_carbon(barejid, message);
+    ProfChatWin *chatwin = wins_get_chat(barejid);
+    if (!chatwin) {
+        chatwin = chatwin_new(barejid);
+    }
+
+    chat_state_active(chatwin->state);
+
+    chatwin_outgoing_carbon(chatwin, message);
 }
 
 void
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index 35d502c0..58b6c6eb 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -205,6 +205,8 @@ chatwin_otr_untrust(ProfChatWin *chatwin)
 void
 chatwin_recipient_gone(ProfChatWin *chatwin)
 {
+    assert(chatwin != NULL);
+
     const char *display_usr = NULL;
     PContact contact = roster_get_contact(chatwin->barejid);
     if (contact) {
@@ -223,6 +225,8 @@ chatwin_recipient_gone(ProfChatWin *chatwin)
 void
 chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const char *const message, GDateTime *timestamp, gboolean win_created, prof_enc_t enc_mode)
 {
+    assert(chatwin != NULL);
+
     ProfWin *window = (ProfWin*)chatwin;
     int num = wins_get_num(window);
 
@@ -273,6 +277,8 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
 void
 chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode)
 {
+    assert(chatwin != NULL);
+
     char enc_char = '-';
     if (enc_mode == PROF_MSG_OTR) {
         enc_char = prefs_get_otr_char();
@@ -288,19 +294,11 @@ chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id,
 }
 
 void
-ui_outgoing_chat_msg_carbon(const char *const barejid, const char *const message)
+chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message)
 {
-    ProfChatWin *chatwin = wins_get_chat(barejid);
-
-    // create new window
-    if (!chatwin) {
-        chatwin = chatwin_new(barejid);
-    }
-
-    chat_state_active(chatwin->state);
+    assert(chatwin != NULL);
 
     win_print((ProfWin*)chatwin, '-', 0, NULL, 0, THEME_TEXT_ME, "me", message);
-
     int num = wins_get_num((ProfWin*)chatwin);
     status_bar_active(num);
 }
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 2375c5dc..fa8e45f1 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -107,7 +107,7 @@ void ui_disconnected(void);
 void chatwin_recipient_gone(ProfChatWin *chatwin);
 
 void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode);
-void ui_outgoing_chat_msg_carbon(const char *const barejid, const char *const message);
+void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char *const message);
 void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char *const message);
 
 void ui_room_join(const char *const roomjid, gboolean focus);
diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c
index f2f5369b..83d59135 100644
--- a/tests/unittests/ui/stub_ui.c
+++ b/tests/unittests/ui/stub_ui.c
@@ -182,7 +182,7 @@ void ui_disconnected(void) {}
 void chatwin_recipient_gone(ProfChatWin *chatwin) {}
 
 void chatwin_outgoing_msg(ProfChatWin *chatwin, const char * const message, char *id, prof_enc_t enc_mode) {}
-void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message) {}
+void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char * const message) {}
 void ui_outgoing_private_msg(ProfPrivateWin *privwin, const char * const message) {}
 
 void ui_room_join(const char * const roomjid, gboolean focus) {}