void mucwin_handle_role_list(ProfMucWin *mucwin, const char *const role, GSList *nicks) { assert(mucwin != NULL); ProfWin *window = (ProfWin*)mucwin; if (nicks) { win_vprint(window, '!', 0, NULL, 0, 0, "", "Role: %s", role); GSList *curr_nick = nicks; while (curr_nick) { char *nick = curr_nick->data; Occupant *occupant = muc_roster_item(mucwin->roomjid, nick); if (occupant) { if (occupant->jid) { win_vprint(window, '!', 0, NULL, 0, 0, "", " %s (%s)", nick, occupant->jid); } else { win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", nick); } } else { win_vprint(window, '!', 0, NULL, 0, 0, "", " %s", nick); } curr_nick = g_slist_next(curr_nick); } win_print(window, '!', 0, NULL, 0, 0, "", ""); } else { win_vprint(window, '!', 0, NULL, 0, 0, "", "No occupants found with role: %s", role); win_print(window, '!', 0, NULL, 0, 0, "", ""); } }
void sv_ev_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 actor, const char *const reason, const char *const show, const char *const status) { Occupant *occupant = muc_roster_item(room, nick); const char *old_role = NULL; const char *old_affiliation = NULL; if (occupant) { old_role = muc_occupant_role_str(occupant); old_affiliation = muc_occupant_affiliation_str(occupant); } gboolean updated = muc_roster_add(room, nick, jid, role, affiliation, show, status); // not yet finished joining room if (!muc_roster_complete(room)) { return; } // handle nickname change char *old_nick = muc_roster_nick_change_complete(room, nick); if (old_nick) { ProfMucWin *mucwin = wins_get_muc(room); if (mucwin) { mucwin_occupant_nick_change(mucwin, old_nick, nick); } wins_private_nick_change(mucwin->roomjid, old_nick, nick); free(old_nick); occupantswin_occupants(room); rosterwin_roster(); return; } // joined room if (!occupant) { char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); ProfMucWin *mucwin = wins_get_muc(room); if (mucwin && g_strcmp0(muc_status_pref, "none") != 0) { mucwin_occupant_online(mucwin, nick, role, affiliation, show, status); } prefs_free_string(muc_status_pref); Jid *jidp = jid_create_from_bare_and_resource(mucwin->roomjid, nick); ProfPrivateWin *privwin = wins_get_private(jidp->fulljid); jid_destroy(jidp); if (privwin) { privwin_occupant_online(privwin); } occupantswin_occupants(room); rosterwin_roster(); return; } // presence updated if (updated) { char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); ProfMucWin *mucwin = wins_get_muc(room); if (mucwin && (g_strcmp0(muc_status_pref, "all") == 0)) { mucwin_occupant_presence(mucwin, nick, show, status); } prefs_free_string(muc_status_pref); occupantswin_occupants(room); // presence unchanged, check for role/affiliation change } else { ProfMucWin *mucwin = wins_get_muc(room); if (mucwin && prefs_get_boolean(PREF_MUC_PRIVILEGES)) { // both changed if ((g_strcmp0(role, old_role) != 0) && (g_strcmp0(affiliation, old_affiliation) != 0)) { mucwin_occupant_role_and_affiliation_change(mucwin, nick, role, affiliation, actor, reason); // role changed } else if (g_strcmp0(role, old_role) != 0) { mucwin_occupant_role_change(mucwin, nick, role, actor, reason); // affiliation changed } else if (g_strcmp0(affiliation, old_affiliation) != 0) { mucwin_occupant_affiliation_change(mucwin, nick, affiliation, actor, reason); } } occupantswin_occupants(room); } rosterwin_roster(); }
void sv_ev_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 actor, const char * const reason, const char * const show, const char * const status) { Occupant *occupant = muc_roster_item(room, nick); const char *old_role = NULL; const char *old_affiliation = NULL; if (occupant) { old_role = muc_occupant_role_str(occupant); old_affiliation = muc_occupant_affiliation_str(occupant); } gboolean updated = muc_roster_add(room, nick, jid, role, affiliation, show, status); // not yet finished joining room if (!muc_roster_complete(room)) { return; } // handle nickname change 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); occupantswin_occupants(room); return; } // joined room if (!occupant) { char *muc_status_pref = prefs_get_string(PREF_STATUSES_MUC); if (g_strcmp0(muc_status_pref, "none") != 0) { ui_room_member_online(room, nick, role, affiliation, show, status); } prefs_free_string(muc_status_pref); occupantswin_occupants(room); return; } // presence updated 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); occupantswin_occupants(room); // presence unchanged, check for role/affiliation change } else { if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) { // both changed if ((g_strcmp0(role, old_role) != 0) && (g_strcmp0(affiliation, old_affiliation) != 0)) { ui_room_occupant_role_and_affiliation_change(room, nick, role, affiliation, actor, reason); // role changed } else if (g_strcmp0(role, old_role) != 0) { ui_room_occupant_role_change(room, nick, role, actor, reason); // affiliation changed } else if (g_strcmp0(affiliation, old_affiliation) != 0) { ui_room_occupant_affiliation_change(room, nick, affiliation, actor, reason); } } occupantswin_occupants(room); } }