示例#1
0
文件: api.c 项目: anossov/profanity
int
api_room_show(const char *const roomjid, const char *message)
{
    if (message == NULL) {
        log_warning("%s", "api_room_show failed, message is NULL");
        return 0;
    }

    if (roomjid == NULL) {
        log_warning("%s", "api_room_show failed, roomjid is NULL");
        return 0;
    }

    ProfMucWin *mucwin = wins_get_muc(roomjid);
    if (mucwin == NULL) {
        log_warning("%s", "api_room_show failed, could not find room window for %s", roomjid);
        return 0;
    }

    char *parsed = str_replace(message, "\r\n", "\n");
    win_println((ProfWin*)mucwin, THEME_TEXT, '-', "%s", parsed);
    free(parsed);

    return 1;
}
示例#2
0
文件: api.c 项目: anossov/profanity
int
api_room_set_message_char(const char *const roomjid, const char *const ch)
{
    if (ch == NULL) {
        log_warning("%s", "api_room_set_message_char failed, ch is NULL");
        return 0;
    }

    if (strlen(ch) != 1) {
        log_warning("%s", "api_room_set_message_char failed, ch must be a string of length 1");
        return 0;
    }

    if (roomjid == NULL) {
        log_warning("%s", "api_room_set_message_char failed, roomjid is NULL");
        return 0;
    }

    ProfMucWin *mucwin = wins_get_muc(roomjid);
    if (mucwin == NULL) {
        log_warning("%s", "api_room_set_message_char failed, could not find room window for %s", roomjid);
        return 0;
    }

    mucwin_set_message_char(mucwin, ch);

    return 1;
}
示例#3
0
void
ui_handle_room_config_submit_result(const char *const roomjid)
{
    if (roomjid) {
        ProfWin *form_window = NULL;
        ProfWin *muc_window = (ProfWin*)wins_get_muc(roomjid);

        GString *form_recipient = g_string_new(roomjid);
        g_string_append(form_recipient, " config");
        form_window = (ProfWin*) wins_get_muc_conf(form_recipient->str);
        g_string_free(form_recipient, TRUE);

        if (form_window) {
            int num = wins_get_num(form_window);
            wins_close_by_num(num);
        }

        if (muc_window) {
            ui_focus_win((ProfWin*)muc_window);
            win_println(muc_window, THEME_ROOMINFO, '!', "Room configuration successful");
        } else {
            ProfWin *console = wins_get_console();
            ui_focus_win(console);
            cons_show("Room configuration successful: %s", roomjid);
        }
    } else {
        cons_show("Room configuration successful");
    }
}
示例#4
0
void
ui_room_banned(const char *const roomjid, const char *const actor, const char *const reason)
{
    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
    if (window == NULL) {
        log_error("Received ban, but no window open for %s.", roomjid);
    } else {
        int num = wins_get_num(window);
        ui_close_win(num);

        GString *message = g_string_new("Banned from ");
        g_string_append(message, roomjid);
        if (actor) {
            g_string_append(message, " by ");
            g_string_append(message, actor);
        }
        if (reason) {
            g_string_append(message, ", reason: ");
            g_string_append(message, reason);
        }

        ProfWin *console = wins_get_console();
        win_println(console, THEME_TYPING, '!', "<- %s", message->str);
        g_string_free(message, TRUE);
    }

    GList *privwins = wins_get_private_chats(roomjid);
    GList *curr = privwins;
    while (curr) {
        ProfPrivateWin *privwin = curr->data;
        privwin_room_banned(privwin, actor, reason);
        curr = g_list_next(curr);
    }
    g_list_free(privwins);
}
示例#5
0
void
sv_ev_room_subject(const char *const room, const char *const nick, const char *const subject)
{
    muc_set_subject(room, subject);
    ProfMucWin *mucwin = wins_get_muc(room);
    if (mucwin && muc_roster_complete(room)) {
        mucwin_subject(mucwin, nick, subject);
    }
}
示例#6
0
void
sv_ev_room_history(const char *const room_jid, const char *const nick,
    GDateTime *timestamp, const char *const message)
{
    ProfMucWin *mucwin = wins_get_muc(room_jid);
    if (mucwin) {
        mucwin_history(mucwin, nick, timestamp, message);
    }
}
示例#7
0
void
sv_ev_room_broadcast(const char *const room_jid, const char *const message)
{
    if (muc_roster_complete(room_jid)) {
        ProfMucWin *mucwin = wins_get_muc(room_jid);
        if (mucwin) {
            mucwin_broadcast(mucwin, message);
        }
    } else {
        muc_pending_broadcasts_add(room_jid, message);
    }
}
示例#8
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);
    }
}
示例#9
0
文件: api.c 项目: anossov/profanity
int
api_room_unset_message_char(const char *const roomjid)
{
    if (roomjid == NULL) {
        log_warning("%s", "api_room_unset_message_char failed, roomjid is NULL");
        return 0;
    }

    ProfMucWin *mucwin = wins_get_muc(roomjid);
    if (mucwin == NULL) {
        log_warning("%s", "api_room_unset_message_char failed, could not find room window for %s", roomjid);
        return 0;
    }

    mucwin_unset_message_char(mucwin);

    return 1;
}
示例#10
0
文件: api.c 项目: anossov/profanity
int
api_room_unset_titlebar_enctext(const char *const roomjid)
{
    if (roomjid == NULL) {
        log_warning("%s", "api_room_unset_titlebar_enctext failed, roomjid is NULL");
        return 0;
    }

    ProfMucWin *mucwin = wins_get_muc(roomjid);
    if (mucwin == NULL) {
        log_warning("%s", "api_room_unset_titlebar_enctext failed, coudl not find room window for %s", roomjid);
        return 0;
    }

    mucwin_unset_enctext(mucwin);

    return 1;
}
示例#11
0
void
ui_leave_room(const char *const roomjid)
{
    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
    if (window) {
        int num = wins_get_num(window);
        ui_close_win(num);
    }

    GList *privwins = wins_get_private_chats(roomjid);
    GList *curr = privwins;
    while (curr) {
        ProfPrivateWin *privwin = curr->data;
        privwin_room_left(privwin);
        curr = g_list_next(curr);
    }
    g_list_free(privwins);

}
示例#12
0
void
ui_room_join(const char *const roomjid, gboolean focus)
{
    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
    if (!window) {
        window = wins_new_muc(roomjid);
    }

    char *nick = muc_nick(roomjid);
    win_vprint(window, '!', 0, NULL, NO_EOL, THEME_ROOMINFO, "", "-> You have joined the room as %s", nick);
    if (prefs_get_boolean(PREF_MUC_PRIVILEGES)) {
        char *role = muc_role_str(roomjid);
        char *affiliation = muc_affiliation_str(roomjid);
        if (role) {
            win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", role: %s", role);
        }
        if (affiliation) {
            win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, THEME_ROOMINFO, "", ", affiliation: %s", affiliation);
        }
    }
    win_print(window, '!', 0, NULL, NO_DATE, THEME_ROOMINFO, "", "");


    if (focus) {
        ui_focus_win(window);
    } else {
        int num = wins_get_num(window);
        status_bar_active(num);
        ProfWin *console = wins_get_console();
        char *nick = muc_nick(roomjid);
        win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "-> Autojoined %s as %s (%d).", roomjid, nick, num);
    }

    GList *privwins = wins_get_private_chats(roomjid);
    GList *curr = privwins;
    while (curr) {
        ProfPrivateWin *privwin = curr->data;
        privwin_room_joined(privwin);
        curr = g_list_next(curr);
    }
    g_list_free(privwins);
}
示例#13
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();
}
示例#14
0
void
ui_room_destroy(const char *const roomjid)
{
    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
    if (window == NULL) {
        log_error("Received room destroy result, but no window open for %s.", roomjid);
    } else {
        int num = wins_get_num(window);
        ui_close_win(num);
        cons_show("Room destroyed: %s", roomjid);
    }

    GList *privwins = wins_get_private_chats(roomjid);
    GList *curr = privwins;
    while (curr) {
        ProfPrivateWin *privwin = curr->data;
        privwin_room_destroyed(privwin);
        curr = g_list_next(curr);
    }
    g_list_free(privwins);
}
示例#15
0
文件: api.c 项目: anossov/profanity
int
api_room_show_themed(const char *const roomjid, const char *const group, const char *const key, const char *const def,
    const char *const ch, const char *const message)
{
    if (message == NULL) {
        log_warning("%s", "api_room_show_themed failed, message is NULL");
        return 0;
    }

    if (roomjid == NULL) {
        log_warning("%s", "api_room_show_themed failed, roomjid is NULL");
        return 0;
    }

    char show_ch = '-';
    if (ch) {
        if (strlen(ch) != 1) {
            log_warning("%s", "api_room_show_themed failed, ch must be a string of length 1");
            return 0;
        } else {
            show_ch = ch[0];
        }
    }

    ProfMucWin *mucwin = wins_get_muc(roomjid);
    if (mucwin == NULL) {
        log_warning("%s", "api_room_show_themed failed, could not find room window for %s", roomjid);
        return 0;
    }

    char *parsed = str_replace(message, "\r\n", "\n");
    theme_item_t themeitem = plugin_themes_get(group, key, def);

    win_println((ProfWin*)mucwin, themeitem, show_ch, "%s", parsed);
    free(parsed);

    return 1;
}
示例#16
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();
}
示例#17
0
void
ui_handle_room_configuration_form_error(const char *const roomjid, const char *const message)
{
    ProfWin *window = NULL;
    GString *message_str = g_string_new("");

    if (roomjid) {
        window = (ProfWin*)wins_get_muc(roomjid);
        g_string_printf(message_str, "Could not get room configuration for %s", roomjid);
    } else {
        window = wins_get_console();
        g_string_printf(message_str, "Could not get room configuration");
    }

    if (message) {
        g_string_append(message_str, ": ");
        g_string_append(message_str, message);
    }

    win_println(window, THEME_ERROR, '-', "%s", message_str->str);

    g_string_free(message_str, TRUE);
}
示例#18
0
void
ui_handle_room_config_submit_result_error(const char *const roomjid, const char *const message)
{
    ProfWin *console = wins_get_console();
    if (roomjid) {
        ProfWin *muc_window = NULL;
        ProfWin *form_window = NULL;
        muc_window = (ProfWin*)wins_get_muc(roomjid);

        GString *form_recipient = g_string_new(roomjid);
        g_string_append(form_recipient, " config");
        form_window = (ProfWin*) wins_get_muc_conf(form_recipient->str);
        g_string_free(form_recipient, TRUE);

        if (form_window) {
            if (message) {
                win_println(form_window, THEME_ERROR, '!', "Configuration error: %s", message);
            } else {
                win_println(form_window, THEME_ERROR, '!', "Configuration error");
            }
        } else if (muc_window) {
            if (message) {
                win_println(muc_window, THEME_ERROR, '!', "Configuration error: %s", message);
            } else {
                win_println(muc_window, THEME_ERROR, '!', "Configuration error");
            }
        } else {
            if (message) {
                win_println(console, THEME_ERROR, '!', "Configuration error for %s: %s", roomjid, message);
            } else {
                win_println(console, THEME_ERROR, '!', "Configuration error for %s", roomjid);
            }
        }
    } else {
        win_println(console, THEME_ERROR, '!', "Configuration error");
    }
}
示例#19
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;
    }
}
示例#20
0
void
ui_room_destroyed(const char *const roomjid, const char *const reason, const char *const new_jid,
    const char *const password)
{
    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
    if (window == NULL) {
        log_error("Received room destroy, but no window open for %s.", roomjid);
    } else {
        int num = wins_get_num(window);
        ui_close_win(num);
        ProfWin *console = wins_get_console();

        if (reason) {
            win_println(console, THEME_TYPING, '!', "<- Room destroyed: %s, reason: %s", roomjid, reason);
        } else {
            win_println(console, THEME_TYPING, '!', "<- Room destroyed: %s", roomjid);
        }

        if (new_jid) {
            if (password) {
                win_println(console, THEME_TYPING, '!', "Replacement room: %s, password: %s", new_jid, password);
            } else {
                win_println(console, THEME_TYPING, '!', "Replacement room: %s", new_jid);
            }
        }
    }

    GList *privwins = wins_get_private_chats(roomjid);
    GList *curr = privwins;
    while (curr) {
        ProfPrivateWin *privwin = curr->data;
        privwin_room_destroyed(privwin);
        curr = g_list_next(curr);
    }
    g_list_free(privwins);
}
示例#21
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();
}
示例#22
0
void
sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean config_required,
    const char *const role, const char *const affiliation, const char *const actor, const char *const reason,
    const char *const jid, const char *const show, const char *const status)
{
    muc_roster_add(room, nick, jid, role, affiliation, show, status);
    char *old_role = muc_role_str(room);
    char *old_affiliation = muc_affiliation_str(room);
    muc_set_role(room, role);
    muc_set_affiliation(room, affiliation);

    // handle self nick change
    if (muc_nick_change_pending(room)) {
        muc_nick_change_complete(room, nick);
        ProfMucWin *mucwin = wins_get_muc(room);
        if (mucwin) {
            mucwin_nick_change(mucwin, nick);
        }

    // handle roster complete
    } else if (!muc_roster_complete(room)) {
        if (muc_autojoin(room)) {
            ui_room_join(room, FALSE);
        } else {
            ui_room_join(room, TRUE);
        }

        iq_room_info_request(room, FALSE);

        if (muc_invites_contain(room)) {
            if (prefs_get_boolean(PREF_BOOKMARK_INVITE) && !bookmark_exists(room)) {
                bookmark_add(room, nick, muc_invite_password(room), "on");
            }
            muc_invites_remove(room);
        }

        muc_roster_set_complete(room);

        // show roster if occupants list disabled by default
        ProfMucWin *mucwin = wins_get_muc(room);
        if (mucwin && !prefs_get_boolean(PREF_OCCUPANTS)) {
            GList *occupants = muc_roster(room);
            mucwin_roster(mucwin, occupants, NULL);
            g_list_free(occupants);
        }

        char *subject = muc_subject(room);
        if (mucwin && subject) {
            mucwin_subject(mucwin, NULL, subject);
        }

        GList *pending_broadcasts = muc_pending_broadcasts(room);
        if (mucwin && pending_broadcasts) {
            GList *curr = pending_broadcasts;
            while (curr) {
                mucwin_broadcast(mucwin, curr->data);
                curr = g_list_next(curr);
            }
        }

        // room configuration required
        if (config_required) {
            muc_set_requires_config(room, TRUE);
            if (mucwin) {
                mucwin_requires_config(mucwin);
            }
        }

        rosterwin_roster();

    // check for change in role/affiliation
    } 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_role_and_affiliation_change(mucwin, role, affiliation, actor, reason);

            // role changed
            } else if (g_strcmp0(role, old_role) != 0) {
                mucwin_role_change(mucwin, role, actor, reason);

            // affiliation changed
            } else if (g_strcmp0(affiliation, old_affiliation) != 0) {
                mucwin_affiliation_change(mucwin, affiliation, actor, reason);
            }
        }
    }

    occupantswin_occupants(room);
}
示例#23
0
void
sv_ev_room_message(const char *const room_jid, const char *const nick, const char *const message)
{
    if (prefs_get_boolean(PREF_GRLOG)) {
        Jid *jid = jid_create(connection_get_fulljid());
        groupchat_log_chat(jid->barejid, room_jid, nick, message);
        jid_destroy(jid);
    }

    ProfMucWin *mucwin = wins_get_muc(room_jid);
    if (!mucwin) {
        return;
    }

    char *new_message = plugins_pre_room_message_display(room_jid, nick, message);
    char *mynick = muc_nick(mucwin->roomjid);

    gboolean whole_word = prefs_get_boolean(PREF_NOTIFY_MENTION_WHOLE_WORD);
    gboolean case_sensitive = prefs_get_boolean(PREF_NOTIFY_MENTION_CASE_SENSITIVE);
    char *message_search = case_sensitive ? strdup(new_message) : g_utf8_strdown(new_message, -1);
    char *mynick_search = case_sensitive ? strdup(mynick) : g_utf8_strdown(mynick, -1);

    GSList *mentions = NULL;
    mentions = prof_occurrences(mynick_search, message_search, 0, whole_word, &mentions);
    gboolean mention = g_slist_length(mentions) > 0;
    g_free(message_search);
    g_free(mynick_search);

    GList *triggers = prefs_message_get_triggers(new_message);

    mucwin_message(mucwin, nick, new_message, mentions, triggers);

    g_slist_free(mentions);

    ProfWin *window = (ProfWin*)mucwin;
    int num = wins_get_num(window);
    gboolean is_current = FALSE;

    // currently in groupchat window
    if (wins_is_current(window)) {
        is_current = TRUE;
        status_bar_active(num);

        if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_BEEP))) {
            beep();
        }

    // not currently on groupchat window
    } else {
        status_bar_new(num);

        if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_FLASH))) {
            flash();
        }

        cons_show_incoming_room_message(nick, mucwin->roomjid, num, mention, triggers, mucwin->unread);

        mucwin->unread++;

        if (mention) {
            mucwin->unread_mentions = TRUE;
        }
        if (triggers) {
            mucwin->unread_triggers = TRUE;
        }
    }

    if (prefs_do_room_notify(is_current, mucwin->roomjid, mynick, nick, new_message, mention, triggers != NULL)) {
        Jid *jidp = jid_create(mucwin->roomjid);
        notify_room_message(nick, jidp->localpart, num, new_message);
        jid_destroy(jidp);
    }

    if (triggers) {
        g_list_free_full(triggers, free);
    }

    rosterwin_roster();

    plugins_post_room_message_display(room_jid, nick, new_message);
    free(new_message);
}
示例#24
0
void
ui_switch_to_room(const char *const roomjid)
{
    ProfWin *window = (ProfWin*)wins_get_muc(roomjid);
    ui_focus_win(window);
}
示例#25
0
void
sv_ev_room_message(const char *const room_jid, const char *const nick, const char *const message)
{
    if (prefs_get_boolean(PREF_GRLOG)) {
        Jid *jid = jid_create(jabber_get_fulljid());
        groupchat_log_chat(jid->barejid, room_jid, nick, message);
        jid_destroy(jid);
    }

    ProfMucWin *mucwin = wins_get_muc(room_jid);
    if (!mucwin) {
        return;
    }

    char *new_message = plugins_pre_room_message_display(room_jid, nick, message);
    char *mynick = muc_nick(mucwin->roomjid);

    gboolean mention = FALSE;
    char *message_lower = g_utf8_strdown(new_message, -1);
    char *mynick_lower = g_utf8_strdown(mynick, -1);
    if (g_strrstr(message_lower, mynick_lower)) {
        mention = TRUE;
    }
    g_free(message_lower);
    g_free(mynick_lower);

    GList *triggers = prefs_message_get_triggers(new_message);

    mucwin_message(mucwin, nick, new_message, mention, triggers);

    ProfWin *window = (ProfWin*)mucwin;
    int num = wins_get_num(window);
    gboolean is_current = FALSE;

    // currently in groupchat window
    if (wins_is_current(window)) {
        is_current = TRUE;
        status_bar_active(num);

        if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_BEEP))) {
            beep();
        }

    // not currently on groupchat window
    } else {
        status_bar_new(num);

        if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_FLASH))) {
            flash();
        }

        cons_show_incoming_room_message(nick, mucwin->roomjid, num, mention, triggers, mucwin->unread);

        mucwin->unread++;

        if (mention) {
            mucwin->unread_mentions = TRUE;
        }
        if (triggers) {
            mucwin->unread_triggers = TRUE;
        }
    }

    if (prefs_do_room_notify(is_current, mucwin->roomjid, mynick, nick, new_message, mention, triggers != NULL)) {
        Jid *jidp = jid_create(mucwin->roomjid);
        notify_room_message(nick, jidp->localpart, num, new_message);
        jid_destroy(jidp);
    }

    if (triggers) {
        g_list_free_full(triggers, free);
    }

    rosterwin_roster();

    plugins_post_room_message_display(room_jid, nick, new_message);
    free(new_message);
}