1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Send presence changes to chat rooms

This commit is contained in:
James Booth 2012-11-20 00:33:11 +00:00
parent 2d590a81e0
commit 306965501a
3 changed files with 33 additions and 2 deletions

View File

@ -346,6 +346,21 @@ jabber_update_presence(jabber_presence_t status, const char * const msg)
xmpp_stanza_add_child(presence, priority); xmpp_stanza_add_child(presence, priority);
} }
xmpp_send(jabber_conn.conn, presence); xmpp_send(jabber_conn.conn, presence);
// send presence for each room
GList *rooms = room_get_rooms();
while (rooms != NULL) {
char *room = rooms->data;
char *nick = room_get_nick_for_room(room);
char *full_room_jid = room_create_full_room_jid(room, nick);
xmpp_stanza_set_attribute(presence, STANZA_ATTR_TO, full_room_jid);
xmpp_send(jabber_conn.conn, presence);
rooms = g_list_next(rooms);
}
g_list_free(rooms);
xmpp_stanza_release(presence); xmpp_stanza_release(presence);
} }
@ -730,8 +745,9 @@ _room_presence_handler(const char * const jid, xmpp_stanza_t * const stanza)
prof_handle_room_nick_change(room, nick); prof_handle_room_nick_change(room, nick);
// handle roster complete // handle roster complete
} else { } else if (!room_get_roster_received(room)) {
prof_handle_room_roster_complete(room); prof_handle_room_roster_complete(room);
} }
// handle presence from room members // handle presence from room members

View File

@ -120,6 +120,16 @@ room_is_active(const char * const full_room_jid)
} }
} }
GList *
room_get_rooms(void)
{
if (rooms != NULL) {
return g_hash_table_get_keys(rooms);
} else {
return NULL;
}
}
char * char *
room_get_nick_for_room(const char * const room) room_get_nick_for_room(const char * const room)
{ {
@ -313,9 +323,13 @@ room_complete_pending_nick_change(const char * const room,
if (chat_room != NULL) { if (chat_room != NULL) {
char *old_nick = g_hash_table_lookup(chat_room->nick_changes, nick); char *old_nick = g_hash_table_lookup(chat_room->nick_changes, nick);
char *old_nick_cpy;
if (old_nick != NULL) { if (old_nick != NULL) {
return strdup(old_nick); old_nick_cpy = strdup(old_nick);
g_hash_table_remove(chat_room->nick_changes, nick);
return old_nick_cpy;
} }
} }

View File

@ -51,5 +51,6 @@ char * room_create_full_room_jid(const char * const room,
const char * const nick); const char * const nick);
void room_set_pending_nick_change(const char * const room); void room_set_pending_nick_change(const char * const room);
gboolean room_is_pending_nick_change(const char * const room); gboolean room_is_pending_nick_change(const char * const room);
GList* room_get_rooms(void);
#endif #endif