about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jabber.c6
-rw-r--r--src/profanity.c13
-rw-r--r--src/profanity.h3
-rw-r--r--src/room_chat.c17
-rw-r--r--src/room_chat.h1
-rw-r--r--src/ui.h2
-rw-r--r--src/windows.c14
7 files changed, 55 insertions, 1 deletions
diff --git a/src/jabber.c b/src/jabber.c
index 037f03d9..b55a4019 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -767,7 +767,11 @@ _room_presence_handler(const char * const jid, xmpp_stanza_t * const stanza)
                     room_add_to_roster(room, nick, show_str, status_str);
                     prof_handle_room_member_nick_change(room, old_nick, nick);
                 } else {
-                    prof_handle_room_member_online(room, nick, show_str, status_str);
+                    if (!room_nick_in_roster(room, nick)) {
+                        prof_handle_room_member_online(room, nick, show_str, status_str);
+                    } else {
+                        prof_handle_room_member_presence(room, nick, show_str, status_str);
+                    }
                 }
             }
         }
diff --git a/src/profanity.c b/src/profanity.c
index 21dcb5da..debfa448 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -247,6 +247,19 @@ prof_handle_room_roster_complete(const char * const room)
 }
 
 void
+prof_handle_room_member_presence(const char * const room,
+    const char * const nick, const char * const show,
+    const char * const status)
+{
+    gboolean updated = room_add_to_roster(room, nick, show, status);
+
+    if (updated) {
+        win_show_room_member_presence(room, nick, show, status);
+        win_page_off();
+    }
+}
+
+void
 prof_handle_room_member_online(const char * const room, const char * const nick,
     const char * const show, const char * const status)
 {
diff --git a/src/profanity.h b/src/profanity.h
index 62d73a3f..b97796fa 100644
--- a/src/profanity.h
+++ b/src/profanity.h
@@ -51,6 +51,9 @@ void prof_handle_room_member_online(const char * const room,
     const char * const nick, const char * const show, const char * const status);
 void prof_handle_room_member_offline(const char * const room,
     const char * const nick, const char * const show, const char * const status);
+void prof_handle_room_member_presence(const char * const room,
+    const char * const nick, const char * const show,
+    const char * const status);
 void prof_handle_leave_room(const char * const room);
 void prof_handle_room_member_nick_change(const char * const room,
     const char * const old_nick, const char * const nick);
diff --git a/src/room_chat.c b/src/room_chat.c
index d6a80b9d..21d8e1df 100644
--- a/src/room_chat.c
+++ b/src/room_chat.c
@@ -202,6 +202,23 @@ room_parse_room_jid(const char * const full_room_jid, char **room, char **nick)
 }
 
 gboolean
+room_nick_in_roster(const char * const room, const char * const nick)
+{
+    muc_room *chat_room = g_hash_table_lookup(rooms, room);
+
+    if (chat_room != NULL) {
+        PContact contact = g_hash_table_lookup(chat_room->roster, nick);
+        if (contact != NULL) {
+            return TRUE;
+        } else {
+            return FALSE;
+        }
+    }
+
+    return FALSE;
+}
+
+gboolean
 room_add_to_roster(const char * const room, const char * const nick,
     const char * const show, const char * const status)
 {
diff --git a/src/room_chat.h b/src/room_chat.h
index c5260605..9a210bbe 100644
--- a/src/room_chat.h
+++ b/src/room_chat.h
@@ -40,6 +40,7 @@ void room_add_pending_nick_change(const char * const room,
     const char * const new_nick, const char * const old_nick);
 char* room_complete_pending_nick_change(const char * const room,
     const char * const nick);
+gboolean room_nick_in_roster(const char * const room, const char * const nick);
 
 GList * room_get_roster(const char * const room);
 void room_set_roster_received(const char * const room);
diff --git a/src/ui.h b/src/ui.h
index 54658eca..62f95526 100644
--- a/src/ui.h
+++ b/src/ui.h
@@ -134,6 +134,8 @@ int win_in_private_chat(void);
 void win_show_room_member_nick_change(const char * const room,
     const char * const old_nick, const char * const nick);
 void win_show_room_nick_change(const char * const room, const char * const nick);
+void win_show_room_member_presence(const char * const room,
+    const char * const nick, const char * const show, const char * const status);
 
 // console window actions
 void cons_about(void);
diff --git a/src/windows.c b/src/windows.c
index eeefaf29..dd0cec21 100644
--- a/src/windows.c
+++ b/src/windows.c
@@ -722,6 +722,20 @@ win_show_room_member_online(const char * const room, const char * const nick,
 }
 
 void
+win_show_room_member_presence(const char * const room, const char * const nick,
+    const char * const show, const char * const status)
+{
+    int win_index = _find_prof_win_index(room);
+    if (win_index != NUM_WINS) {
+        WINDOW *win = _wins[win_index].win;
+        _show_status_string(win, nick, show, status, "++", "online");
+    }
+
+    if (win_index == _curr_prof_win)
+        dirty = TRUE;
+}
+
+void
 win_show_room_member_nick_change(const char * const room,
     const char * const old_nick, const char * const nick)
 {