From d8eb97eec878d797e4184f48c22a7e6284fc213d Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 7 Oct 2014 00:57:51 +0100 Subject: Refactor handle_muc_occupant_online --- src/server_events.c | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/server_events.c b/src/server_events.c index 0e559c3c..40de2318 100644 --- a/src/server_events.c +++ b/src/server_events.c @@ -719,35 +719,33 @@ void handle_muc_occupant_online(const char * const room, const char * const nick, const char * const jid, const char * const role, const char * const affiliation, const char * const show, const char * const status) { + gboolean updated = muc_roster_add(room, nick, jid, role, affiliation, show, status); + if (!muc_roster_complete(room)) { - muc_roster_add(room, nick, jid, role, affiliation, show, status); - } else { - char *old_nick = muc_roster_nick_change_complete(room, nick); + return; + } - if (old_nick) { - muc_roster_add(room, nick, jid, role, affiliation, show, status); - ui_room_member_nick_change(room, old_nick, nick); - free(old_nick); - } else { - if (!muc_roster_contains_nick(room, nick)) { - muc_roster_add(room, nick, jid, role, affiliation, show, status); + char *old_nick = muc_roster_nick_change_complete(room, nick); + if (old_nick) { + ui_room_member_nick_change(room, old_nick, nick); + free(old_nick); + return; + } - char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); - if (g_strcmp0(muc_status_pref, "none") != 0) { - ui_room_member_online(room, nick, show, status); - } - prefs_free_string(muc_status_pref); - } else { - gboolean updated = muc_roster_add(room, nick, jid, role, affiliation, show, status); - - if (updated) { - char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); - if (g_strcmp0(muc_status_pref, "all") == 0) { - ui_room_member_presence(room, nick, show, status); - } - prefs_free_string(muc_status_pref); - } - } + if (!muc_roster_contains_nick(room, nick)) { + char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); + if (g_strcmp0(muc_status_pref, "none") != 0) { + ui_room_member_online(room, nick, show, status); + } + prefs_free_string(muc_status_pref); + return; + } + + if (updated) { + char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); + if (g_strcmp0(muc_status_pref, "all") == 0) { + ui_room_member_presence(room, nick, show, status); } + prefs_free_string(muc_status_pref); } } \ No newline at end of file -- cgit 1.4.1-2-gfad0