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); }
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); }