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); } }
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 win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupant) { const char *presence_str = string_from_resource_presence(occupant->presence); const char *occupant_affiliation = muc_occupant_affiliation_str(occupant); const char *occupant_role = muc_occupant_role_str(occupant); theme_item_t presence_colour = theme_main_presence_attrs(presence_str); win_print(window, '!', 0, NULL, NO_EOL, presence_colour, "", occupant->nick); win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", " is %s", presence_str); if (occupant->status) { win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, presence_colour, "", ", \"%s\"", occupant->status); } win_newline(window); if (occupant->jid) { win_vprint(window, '!', 0, NULL, 0, 0, "", " Jid: %s", occupant->jid); } win_vprint(window, '!', 0, NULL, 0, 0, "", " Affiliation: %s", occupant_affiliation); win_vprint(window, '!', 0, NULL, 0, 0, "", " Role: %s", occupant_role); Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick); EntityCapabilities *caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); if (caps) { // show identity if (caps->identity) { DiscoIdentity *identity = caps->identity; win_print(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: "); if (identity->name) { win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); if (identity->category || identity->type) { win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->type) { win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); if (identity->category) { win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } if (identity->category) { win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(window); } if (caps->software_version) { SoftwareVersion *software_version = caps->software_version; if (software_version->software) { win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); } if (software_version->software_version) { win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); } if (software_version->software || software_version->software_version) { win_newline(window); } if (software_version->os) { win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); } if (software_version->os_version) { win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); } if (software_version->os || software_version->os_version) { win_newline(window); } } caps_destroy(caps); } win_print(window, '-', 0, NULL, 0, 0, "", ""); }