Exemplo n.º 1
0
void
ui_show_software_version(const char *const jid, const char *const  presence,
    const char *const name, const char *const version, const char *const os)
{
    Jid *jidp = jid_create(jid);
    ProfWin *window = NULL;
    ProfWin *chatwin = (ProfWin*)wins_get_chat(jidp->barejid);
    ProfWin *mucwin = (ProfWin*)wins_get_muc(jidp->barejid);
    ProfWin *privwin = (ProfWin*)wins_get_private(jidp->fulljid);
    ProfWin *console = wins_get_console();
    jid_destroy(jidp);

    if (chatwin) {
        if (wins_is_current(chatwin)) {
            window = chatwin;
        } else {
            window = console;
        }
    } else if (privwin) {
        if (wins_is_current(privwin)) {
            window = privwin;
        } else {
            window = console;
        }
    } else if (mucwin) {
        if (wins_is_current(mucwin)) {
            window = mucwin;
        } else {
            window = console;
        }
    } else {
        window = console;
    }

    if (name || version || os) {
        win_println(window, THEME_DEFAULT, '-', "");
        theme_item_t presence_colour = theme_main_presence_attrs(presence);
        win_print(window, presence_colour, '-', "%s", jid);
        win_appendln(window, THEME_DEFAULT, ":");
    }
    if (name) {
        win_println(window, THEME_DEFAULT, '-', "Name    : %s", name);
    }
    if (version) {
        win_println(window, THEME_DEFAULT, '-', "Version : %s", version);
    }
    if (os) {
        win_println(window, THEME_DEFAULT, '-', "OS      : %s", os);
    }
}
Exemplo n.º 2
0
void
sv_ev_delayed_private_message(const char *const fulljid, char *message, GDateTime *timestamp)
{
    char *new_message = plugins_pre_priv_message_display(fulljid, message);

    ProfPrivateWin *privatewin = wins_get_private(fulljid);
    if (privatewin == NULL) {
        ProfWin *window = wins_new_private(fulljid);
        privatewin = (ProfPrivateWin*)window;
    }
    privwin_incoming_msg(privatewin, new_message, timestamp);

    plugins_post_priv_message_display(fulljid, new_message);

    free(new_message);
}
Exemplo n.º 3
0
void
sv_ev_incoming_private_message(const char *const fulljid, char *message)
{
    char *plugin_message =  plugins_pre_priv_message_display(fulljid, message);

    ProfPrivateWin *privatewin = wins_get_private(fulljid);
    if (privatewin == NULL) {
        ProfWin *window = wins_new_private(fulljid);
        privatewin = (ProfPrivateWin*)window;
    }
    privwin_incoming_msg(privatewin, plugin_message, NULL);

    plugins_post_priv_message_display(fulljid, plugin_message);

    free(plugin_message);
    rosterwin_roster();
}
Exemplo n.º 4
0
void
sv_ev_room_occupent_banned(const char *const room, const char *const nick, const char *const actor,
    const char *const reason)
{
    muc_roster_remove(room, nick);
    ProfMucWin *mucwin = wins_get_muc(room);
    if (mucwin) {
        mucwin_occupant_banned(mucwin, nick, actor, reason);
    }

    Jid *jidp = jid_create_from_bare_and_resource(room, nick);
    ProfPrivateWin *privwin = wins_get_private(jidp->fulljid);
    jid_destroy(jidp);
    if (privwin != NULL) {
        privwin_occupant_banned(privwin, actor, reason);
    }

    occupantswin_occupants(room);
    rosterwin_roster();
}
Exemplo n.º 5
0
void
sv_ev_room_occupant_offline(const char *const room, const char *const nick,
    const char *const show, const char *const status)
{
    muc_roster_remove(room, nick);

    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_offline(mucwin, nick);
    }
    prefs_free_string(muc_status_pref);

    Jid *jidp = jid_create_from_bare_and_resource(room, nick);
    ProfPrivateWin *privwin = wins_get_private(jidp->fulljid);
    jid_destroy(jidp);
    if (privwin != NULL) {
        privwin_occupant_offline(privwin);
    }

    occupantswin_occupants(room);
    rosterwin_roster();
}
Exemplo n.º 6
0
void
ui_handle_recipient_error(const char *const recipient, const char *const err_msg)
{
    // always show in console
    cons_show_error("Error from %s: %s", recipient, err_msg);

    ProfChatWin *chatwin = wins_get_chat(recipient);
    if (chatwin) {
        win_println((ProfWin*)chatwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg);
        return;
    }

    ProfMucWin *mucwin = wins_get_muc(recipient);
    if (mucwin) {
        win_println((ProfWin*)mucwin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg);
        return;
    }

    ProfPrivateWin *privatewin = wins_get_private(recipient);
    if (privatewin) {
        win_println((ProfWin*)privatewin, THEME_ERROR, '!', "Error from %s: %s", recipient, err_msg);
        return;
    }
}
Exemplo n.º 7
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();
}