about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-11-14 00:04:08 +0000
committerJames Booth <boothj5@gmail.com>2012-11-14 00:04:08 +0000
commita574f7ff40c5c82e47dfb2c705fef9d7cf78a7da (patch)
tree45932642c864fe74b1568e13b4f491b63669c42c /src
parentfaa5f8871f76565c1f50f5e67353320debbf741e (diff)
downloadprofani-tty-a574f7ff40c5c82e47dfb2c705fef9d7cf78a7da.tar.gz
Set correct window type on private messages
Diffstat (limited to 'src')
-rw-r--r--src/jabber.c9
-rw-r--r--src/profanity.c9
-rw-r--r--src/profanity.h5
-rw-r--r--src/ui.h2
-rw-r--r--src/windows.c11
5 files changed, 24 insertions, 12 deletions
diff --git a/src/jabber.c b/src/jabber.c
index f4f53732..bdb801c9 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -516,6 +516,7 @@ _error_handler(xmpp_stanza_t * const stanza)
 static int
 _chat_message_handler(xmpp_stanza_t * const stanza)
 {
+    gboolean priv = FALSE;
     gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
 
     char from_cpy[strlen(from) + 1];
@@ -526,9 +527,11 @@ _chat_message_handler(xmpp_stanza_t * const stanza)
     // private message from chat room use full jid (room/nick)
     if (room_is_active(short_from)) {
         jid = strdup(from);
+        priv = TRUE;
     // standard chat message, use jid without resource
     } else {
         jid = strdup(short_from);
+        priv = FALSE;
     }
 
     // determine chatstate support of recipient
@@ -574,13 +577,13 @@ _chat_message_handler(xmpp_stanza_t * const stanza)
 
             if (g_time_val_from_iso8601(utc_stamp, &tv_stamp)) {
                 if (message != NULL) {
-                    prof_handle_delayed_message(jid, message, tv_stamp);
+                    prof_handle_delayed_message(jid, message, tv_stamp, priv);
                 }
             } else {
                 log_error("Couldn't parse datetime string of historic message: %s", utc_stamp);
             }
         } else {
-            prof_handle_incoming_message(jid, message);
+            prof_handle_incoming_message(jid, message, priv);
         }
     }
 
@@ -660,7 +663,7 @@ _roster_handler(xmpp_conn_t * const conn,
         }
 
         /* TODO: Save somehow last presence show and use it for initial
-         *       presence rather than PRESENCE_ONLINE. It will be helpful 
+         *       presence rather than PRESENCE_ONLINE. It will be helpful
          *       when I set dnd status and reconnect for some reason */
         // send initial presence
         jabber_update_presence(PRESENCE_ONLINE, NULL);
diff --git a/src/profanity.c b/src/profanity.c
index a6369a90..f1b8743e 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -102,9 +102,9 @@ prof_handle_typing(char *from)
 }
 
 void
-prof_handle_incoming_message(char *from, char *message)
+prof_handle_incoming_message(char *from, char *message, gboolean priv)
 {
-    win_show_incomming_msg(from, message, NULL);
+    win_show_incomming_msg(from, message, NULL, priv);
     win_page_off();
 
     if (prefs_get_chlog()) {
@@ -118,9 +118,10 @@ prof_handle_incoming_message(char *from, char *message)
 }
 
 void
-prof_handle_delayed_message(char *from, char *message, GTimeVal tv_stamp)
+prof_handle_delayed_message(char *from, char *message, GTimeVal tv_stamp,
+    gboolean priv)
 {
-    win_show_incomming_msg(from, message, &tv_stamp);
+    win_show_incomming_msg(from, message, &tv_stamp, priv);
     win_page_off();
 
     if (prefs_get_chlog()) {
diff --git a/src/profanity.h b/src/profanity.h
index a547ce23..ab1ea878 100644
--- a/src/profanity.h
+++ b/src/profanity.h
@@ -33,8 +33,9 @@ void prof_handle_failed_login(void);
 void prof_handle_typing(char *from);
 void prof_handle_contact_online(char *contact, char *show, char *status);
 void prof_handle_contact_offline(char *contact, char *show, char *status);
-void prof_handle_incoming_message(char *from, char *message);
-void prof_handle_delayed_message(char *from, char *message, GTimeVal tv_stamp);
+void prof_handle_incoming_message(char *from, char *message, gboolean priv);
+void prof_handle_delayed_message(char *from, char *message, GTimeVal tv_stamp,
+    gboolean priv);
 void prof_handle_error_message(const char *from, const char *err_msg);
 void prof_handle_subscription(const char *from, jabber_subscr_t type);
 void prof_handle_roster(GSList *roster);
diff --git a/src/ui.h b/src/ui.h
index 0b171ea6..2d883835 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -98,7 +98,7 @@ char *win_get_recipient(void);
 void win_show_typing(const char * const from);
 void win_show_gone(const char * const from);
 void win_show_incomming_msg(const char * const from, const char * const message,
-    GTimeVal *tv_stamp);
+    GTimeVal *tv_stamp, gboolean priv);
 void win_show_error_msg(const char * const from, const char *err_msg);
 void win_show_system_msg(const char * const from, const char *message);
 void win_show_outgoing_msg(const char * const from, const char * const to,
diff --git a/src/windows.c b/src/windows.c
index 4401a126..0e747fef 100644
--- a/src/windows.c
+++ b/src/windows.c
@@ -298,11 +298,18 @@ win_no_activity(void)
 
 void
 win_show_incomming_msg(const char * const from, const char * const message,
-    GTimeVal *tv_stamp)
+    GTimeVal *tv_stamp, gboolean priv)
 {
+    win_type_t win_type;
+    if (priv) {
+        win_type = WIN_PRIVATE;
+    } else {
+        win_type = WIN_CHAT;
+    }
+
     int win_index = _find_prof_win_index(from);
     if (win_index == NUM_WINS)
-        win_index = _new_prof_win(from, WIN_CHAT);
+        win_index = _new_prof_win(from, win_type);
 
     WINDOW *win = _wins[win_index].win;