diff options
author | James Booth <boothj5@gmail.com> | 2012-11-10 01:17:16 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2012-11-10 01:17:16 +0000 |
commit | 81f92929486e7d37c31686133b7cb6926c2a1f8d (patch) | |
tree | ba99fddac1a1a2024f67bbf0a208b67877489ead | |
parent | 7512d70ff519434215b7e8d40c7aa8d678e5c1a7 (diff) | |
download | profani-tty-81f92929486e7d37c31686133b7cb6926c2a1f8d.tar.gz |
Tidy up leaving room
-rw-r--r-- | src/command.c | 1 | ||||
-rw-r--r-- | src/jabber.c | 18 | ||||
-rw-r--r-- | src/profanity.c | 8 | ||||
-rw-r--r-- | src/profanity.h | 1 |
4 files changed, 22 insertions, 6 deletions
diff --git a/src/command.c b/src/command.c index b91a1180..d9536411 100644 --- a/src/command.c +++ b/src/command.c @@ -1093,7 +1093,6 @@ _cmd_close(const char * const inp, struct cmd_help_t help) if (win_in_groupchat()) { char *room_jid = win_get_recipient(); jabber_leave_chat_room(room_jid); - win_close_win(); } else if (win_in_chat()) { if (prefs_get_states()) { diff --git a/src/jabber.c b/src/jabber.c index fe94d2d2..96e9b9d7 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -251,8 +251,6 @@ jabber_leave_chat_room(const char * const room_jid) room_jid, nick); xmpp_send(jabber_conn.conn, presence); xmpp_stanza_release(presence); - - room_leave(room_jid); } void @@ -589,10 +587,20 @@ _room_presence_handler(const char * const jid, xmpp_stanza_t * const stanza) return 1; } - // handle self presence (means room roster has been sent) + // handle self presence if (strcmp(room_get_nick_for_room(room), nick) == 0) { - room_set_roster_received(room); - prof_handle_room_roster_complete(room); + char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE); + + // left room + if (type != NULL) { + if (strcmp(type, STANZA_TYPE_UNAVAILABLE) == 0) { + prof_handle_leave_room(room); + } + + // roster received + } else { + prof_handle_room_roster_complete(room); + } // handle presence from room members } else { diff --git a/src/profanity.c b/src/profanity.c index cdccb3f9..52ddb20a 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -208,6 +208,7 @@ prof_handle_room_message(const char * const room_jid, const char * const nick, void prof_handle_room_roster_complete(const char * const room) { + room_set_roster_received(room); win_show_room_roster(room); win_page_off(); } @@ -231,6 +232,13 @@ prof_handle_room_member_offline(const char * const room, const char * const nick } void +prof_handle_leave_room(const char * const room) +{ + room_leave(room); + win_close_win(); +} + +void prof_handle_contact_online(char *contact, char *show, char *status) { gboolean updated = contact_list_update_contact(contact, show, status); diff --git a/src/profanity.h b/src/profanity.h index c2018144..5e9755f4 100644 --- a/src/profanity.h +++ b/src/profanity.h @@ -45,5 +45,6 @@ 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_leave_room(const char * const room); #endif |