about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-03-14 23:10:51 +0000
committerJames Booth <boothj5@gmail.com>2015-03-14 23:10:51 +0000
commitca30ff3910e27d35de8ebf9f909a38b022a16343 (patch)
treee14e6ffa627365f413784a380db1e540c534df9d
parenta79ea3cbe239f6ce9db37896b2251c1b25143b7d (diff)
parent385336c10b0026025d4cd3a32d0a9b1bc521469a (diff)
downloadprofani-tty-ca30ff3910e27d35de8ebf9f909a38b022a16343.tar.gz
Merge branch 'master' into xep-0184
Conflicts:
	src/server_events.c
	src/ui/core.c
	src/ui/ui.h
	tests/ui/stub_ui.c
-rw-r--r--src/server_events.c7
-rw-r--r--src/ui/core.c41
-rw-r--r--src/ui/ui.h1
-rw-r--r--tests/ui/stub_ui.c1
4 files changed, 47 insertions, 3 deletions
diff --git a/src/server_events.c b/src/server_events.c
index d7504b64..cf6ecb75 100644
--- a/src/server_events.c
+++ b/src/server_events.c
@@ -309,8 +309,9 @@ handle_incoming_private_message(char *fulljid, char *message)
 }
 
 void
-handle_carbon(char *barejid, char *message){
-    ui_outgoing_chat_msg(barejid, message, NULL);
+handle_carbon(char *barejid, char *message)
+{
+    ui_outgoing_chat_msg_carbon(barejid, message);
 }
 
 void
@@ -842,4 +843,4 @@ handle_muc_occupant_online(const char * const room, const char * const nick, con
         }
         occupantswin_occupants(room);
     }
-}
\ No newline at end of file
+}
diff --git a/src/ui/core.c b/src/ui/core.c
index aa77e32e..51a44324 100644
--- a/src/ui/core.c
+++ b/src/ui/core.c
@@ -1465,6 +1465,47 @@ ui_outgoing_chat_msg(const char * const barejid, const char * const message, cha
 }
 
 void
+ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message)
+{
+    PContact contact = roster_get_contact(barejid);
+    ProfWin *window = (ProfWin*)wins_get_chat(barejid);
+    int num = 0;
+
+    // create new window
+    if (window == NULL) {
+        window = wins_new_chat(barejid);
+#ifdef HAVE_LIBOTR
+        ProfChatWin *chatwin = (ProfChatWin*)window;
+        if (otr_is_secure(barejid)) {
+            chatwin->is_otr = TRUE;
+        }
+#endif
+        num = wins_get_num(window);
+
+        if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
+            _win_show_history(num, barejid);
+        }
+
+        if (contact != NULL) {
+            if (strcmp(p_contact_presence(contact), "offline") == 0) {
+                const char *show = p_contact_presence(contact);
+                const char *status = p_contact_status(contact);
+                win_show_status_string(window, barejid, show, status, NULL, "--", "offline");
+            }
+        }
+
+    // use existing window
+    } else {
+        num = wins_get_num(window);
+    }
+    ProfChatWin *chatwin = (ProfChatWin*)window;
+    chat_state_active(chatwin->state);
+
+    win_print(window, '-', NULL, 0, THEME_TEXT_ME, "me", message);
+    status_bar_active(num);
+}
+
+void
 ui_outgoing_private_msg(const char * const fulljid, const char * const message)
 {
     ProfWin *window = (ProfWin*)wins_get_private(fulljid);
diff --git a/src/ui/ui.h b/src/ui/ui.h
index 9c8b9b4d..a2ab5945 100644
--- a/src/ui/ui.h
+++ b/src/ui/ui.h
@@ -122,6 +122,7 @@ void ui_disconnected(void);
 void ui_recipient_gone(const char * const barejid, const char * const resource);
 
 void ui_outgoing_chat_msg(const char * const barejid, const char * const message, char *id);
+void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message);
 void ui_outgoing_private_msg(const char * const fulljid, const char * const message);
 
 void ui_room_join(const char * const roomjid, gboolean focus);
diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c
index 802286ba..6b2698a2 100644
--- a/tests/ui/stub_ui.c
+++ b/tests/ui/stub_ui.c
@@ -202,6 +202,7 @@ void ui_disconnected(void) {}
 void ui_recipient_gone(const char * const barejid, const char * const resource) {}
 
 void ui_outgoing_chat_msg(const char * const barejid, const char * const message, char *id) {}
+void ui_outgoing_chat_msg_carbon(const char * const barejid, const char * const message) {}
 void ui_outgoing_private_msg(const char * const fulljid, const char * const message) {}
 
 void ui_room_join(const char * const roomjid, gboolean focus) {}