mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Merge branch 'master' into osx-functional
This commit is contained in:
commit
40297da067
@ -211,10 +211,11 @@ prefs_do_chat_notify(gboolean current_win, const char *const message)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_message_contains_trigger(const char *const message)
|
||||
GList*
|
||||
prefs_message_get_triggers(const char *const message)
|
||||
{
|
||||
gboolean trigger_found = FALSE;
|
||||
GList *result = NULL;
|
||||
|
||||
char *message_lower = g_utf8_strdown(message, -1);
|
||||
gsize len = 0;
|
||||
gchar **triggers = g_key_file_get_string_list(prefs, PREF_GROUP_NOTIFICATIONS, "room.trigger.list", &len, NULL);
|
||||
@ -222,21 +223,19 @@ prefs_message_contains_trigger(const char *const message)
|
||||
for (i = 0; i < len; i++) {
|
||||
char *trigger_lower = g_utf8_strdown(triggers[i], -1);
|
||||
if (g_strrstr(message_lower, trigger_lower)) {
|
||||
trigger_found = TRUE;
|
||||
g_free(trigger_lower);
|
||||
break;
|
||||
result = g_list_append(result, strdup(triggers[i]));
|
||||
}
|
||||
g_free(trigger_lower);
|
||||
}
|
||||
g_strfreev(triggers);
|
||||
g_free(message_lower);
|
||||
|
||||
return trigger_found;
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick,
|
||||
const char *const message)
|
||||
prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick, const char *const message,
|
||||
gboolean mention, gboolean trigger_found)
|
||||
{
|
||||
gboolean notify_current = prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT);
|
||||
gboolean notify_window = FALSE;
|
||||
@ -263,17 +262,9 @@ prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char
|
||||
} else {
|
||||
notify_mention = prefs_get_boolean(PREF_NOTIFY_ROOM_MENTION);
|
||||
}
|
||||
if (notify_mention) {
|
||||
char *message_lower = g_utf8_strdown(message, -1);
|
||||
char *nick_lower = g_utf8_strdown(nick, -1);
|
||||
if (g_strrstr(message_lower, nick_lower)) {
|
||||
g_free(message_lower);
|
||||
g_free(nick_lower);
|
||||
if (notify_mention && mention) {
|
||||
return TRUE;
|
||||
}
|
||||
g_free(message_lower);
|
||||
g_free(nick_lower);
|
||||
}
|
||||
|
||||
gboolean notify_trigger = FALSE;
|
||||
if (g_key_file_has_key(prefs, roomjid, "notify.trigger", NULL)) {
|
||||
@ -281,7 +272,7 @@ prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char
|
||||
} else {
|
||||
notify_trigger = prefs_get_boolean(PREF_NOTIFY_ROOM_TRIGGER);
|
||||
}
|
||||
if (notify_trigger && prefs_message_contains_trigger(message)) {
|
||||
if (notify_trigger && trigger_found) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -225,8 +225,9 @@ void prefs_free_string(char *pref);
|
||||
void prefs_set_string(preference_t pref, char *value);
|
||||
|
||||
gboolean prefs_do_chat_notify(gboolean current_win, const char *const message);
|
||||
gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick, const char *const message);
|
||||
gboolean prefs_message_contains_trigger(const char *const message);
|
||||
gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick,
|
||||
const char *const message, gboolean mention, gboolean trigger_found);
|
||||
GList* prefs_message_get_triggers(const char *const message);
|
||||
|
||||
void prefs_set_room_notify(const char *const roomjid, gboolean value);
|
||||
void prefs_set_room_notify_mention(const char *const roomjid, gboolean value);
|
||||
|
@ -142,6 +142,8 @@ theme_init(const char *const theme_name)
|
||||
g_hash_table_insert(defaults, strdup("roster.xa.unread"), strdup("cyan"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room.unread"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room.trigger"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("roster.room.mention"), strdup("green"));
|
||||
g_hash_table_insert(defaults, strdup("occupants.header"), strdup("yellow"));
|
||||
}
|
||||
|
||||
@ -653,10 +655,11 @@ _theme_prep_bgnd(char *setting, char *def, GString *lookup_str)
|
||||
}
|
||||
|
||||
static void
|
||||
_theme_prep_fgnd(char *setting, char *def, GString *lookup_str, gboolean *bold)
|
||||
_theme_prep_fgnd(char *setting, GString *lookup_str, gboolean *bold)
|
||||
{
|
||||
gchar *val = g_key_file_get_string(theme, "colours", setting, NULL);
|
||||
if (!val) {
|
||||
char *def = g_hash_table_lookup(defaults, setting);
|
||||
g_string_append(lookup_str, def);
|
||||
} else {
|
||||
if (g_str_has_prefix(val, "bold_")) {
|
||||
@ -699,73 +702,75 @@ theme_attrs(theme_item_t attrs)
|
||||
|
||||
// get forground colour
|
||||
switch (attrs) {
|
||||
case THEME_TEXT: _theme_prep_fgnd("main.text", "white", lookup_str, &bold); break;
|
||||
case THEME_TEXT_ME: _theme_prep_fgnd("main.text.me", "white", lookup_str, &bold); break;
|
||||
case THEME_TEXT_THEM: _theme_prep_fgnd("main.text.them", "white", lookup_str, &bold); break;
|
||||
case THEME_SPLASH: _theme_prep_fgnd("main.splash", "cyan", lookup_str, &bold); break;
|
||||
case THEME_ERROR: _theme_prep_fgnd("error", "red", lookup_str, &bold); break;
|
||||
case THEME_INCOMING: _theme_prep_fgnd("incoming", "yellow", lookup_str, &bold); break;
|
||||
case THEME_INPUT_TEXT: _theme_prep_fgnd("input.text", "white", lookup_str, &bold); break;
|
||||
case THEME_TIME: _theme_prep_fgnd("main.time", "white", lookup_str, &bold); break;
|
||||
case THEME_TITLE_TEXT: _theme_prep_fgnd("titlebar.text", "white", lookup_str, &bold); break;
|
||||
case THEME_TITLE_BRACKET: _theme_prep_fgnd("titlebar.brackets", "cyan", lookup_str, &bold); break;
|
||||
case THEME_TITLE_UNENCRYPTED: _theme_prep_fgnd("titlebar.unencrypted", "red", lookup_str, &bold); break;
|
||||
case THEME_TITLE_ENCRYPTED: _theme_prep_fgnd("titlebar.encrypted", "white", lookup_str, &bold); break;
|
||||
case THEME_TITLE_UNTRUSTED: _theme_prep_fgnd("titlebar.untrusted", "yellow", lookup_str, &bold); break;
|
||||
case THEME_TITLE_TRUSTED: _theme_prep_fgnd("titlebar.trusted", "white", lookup_str, &bold); break;
|
||||
case THEME_TITLE_ONLINE: _theme_prep_fgnd("titlebar.online", "white", lookup_str, &bold); break;
|
||||
case THEME_TITLE_OFFLINE: _theme_prep_fgnd("titlebar.offline", "white", lookup_str, &bold); break;
|
||||
case THEME_TITLE_AWAY: _theme_prep_fgnd("titlebar.away", "white", lookup_str, &bold); break;
|
||||
case THEME_TITLE_CHAT: _theme_prep_fgnd("titlebar.chat", "white", lookup_str, &bold); break;
|
||||
case THEME_TITLE_DND: _theme_prep_fgnd("titlebar.dnd", "white", lookup_str, &bold); break;
|
||||
case THEME_TITLE_XA: _theme_prep_fgnd("titlebar.xa", "white", lookup_str, &bold); break;
|
||||
case THEME_STATUS_TEXT: _theme_prep_fgnd("statusbar.text", "white", lookup_str, &bold); break;
|
||||
case THEME_STATUS_BRACKET: _theme_prep_fgnd("statusbar.brackets", "cyan", lookup_str, &bold); break;
|
||||
case THEME_STATUS_ACTIVE: _theme_prep_fgnd("statusbar.active", "cyan", lookup_str, &bold); break;
|
||||
case THEME_STATUS_NEW: _theme_prep_fgnd("statusbar.new", "white", lookup_str, &bold); break;
|
||||
case THEME_ME: _theme_prep_fgnd("me", "yellow", lookup_str, &bold); break;
|
||||
case THEME_THEM: _theme_prep_fgnd("them", "green", lookup_str, &bold); break;
|
||||
case THEME_RECEIPT_SENT: _theme_prep_fgnd("receipt.sent", "red", lookup_str, &bold); break;
|
||||
case THEME_ROOMINFO: _theme_prep_fgnd("roominfo", "yellow", lookup_str, &bold); break;
|
||||
case THEME_ROOMMENTION: _theme_prep_fgnd("roommention", "yellow", lookup_str, &bold); break;
|
||||
case THEME_ROOMTRIGGER: _theme_prep_fgnd("roomtrigger", "yellow", lookup_str, &bold); break;
|
||||
case THEME_ONLINE: _theme_prep_fgnd("online", "green", lookup_str, &bold); break;
|
||||
case THEME_OFFLINE: _theme_prep_fgnd("offline", "red", lookup_str, &bold); break;
|
||||
case THEME_AWAY: _theme_prep_fgnd("away", "cyan", lookup_str, &bold); break;
|
||||
case THEME_CHAT: _theme_prep_fgnd("chat", "green", lookup_str, &bold); break;
|
||||
case THEME_DND: _theme_prep_fgnd("dnd", "red", lookup_str, &bold); break;
|
||||
case THEME_XA: _theme_prep_fgnd("xa", "cyan", lookup_str, &bold); break;
|
||||
case THEME_TYPING: _theme_prep_fgnd("typing", "yellow", lookup_str, &bold); break;
|
||||
case THEME_GONE: _theme_prep_fgnd("gone", "red", lookup_str, &bold); break;
|
||||
case THEME_SUBSCRIBED: _theme_prep_fgnd("subscribed", "green", lookup_str, &bold); break;
|
||||
case THEME_UNSUBSCRIBED: _theme_prep_fgnd("unsubscribed", "red", lookup_str, &bold); break;
|
||||
case THEME_OTR_STARTED_TRUSTED: _theme_prep_fgnd("otr.started.trusted", "green", lookup_str, &bold); break;
|
||||
case THEME_OTR_STARTED_UNTRUSTED: _theme_prep_fgnd("otr.started.untrusted", "yellow", lookup_str, &bold); break;
|
||||
case THEME_OTR_ENDED: _theme_prep_fgnd("otr.ended", "red", lookup_str, &bold); break;
|
||||
case THEME_OTR_TRUSTED: _theme_prep_fgnd("otr.trusted", "green", lookup_str, &bold); break;
|
||||
case THEME_OTR_UNTRUSTED: _theme_prep_fgnd("otr.untrusted", "yellow", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_HEADER: _theme_prep_fgnd("roster.header", "yellow", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ONLINE: _theme_prep_fgnd("roster.online", "green", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_OFFLINE: _theme_prep_fgnd("roster.offline", "red", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_CHAT: _theme_prep_fgnd("roster.chat", "green", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_AWAY: _theme_prep_fgnd("roster.away", "cyan", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_DND: _theme_prep_fgnd("roster.dnd", "red", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_XA: _theme_prep_fgnd("roster.xa", "cyan", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ONLINE_ACTIVE: _theme_prep_fgnd("roster.online.active", "green", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_OFFLINE_ACTIVE: _theme_prep_fgnd("roster.offline.active", "red", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_CHAT_ACTIVE: _theme_prep_fgnd("roster.chat.active", "green", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_AWAY_ACTIVE: _theme_prep_fgnd("roster.away.active", "cyan", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_DND_ACTIVE: _theme_prep_fgnd("roster.dnd.active", "red", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_XA_ACTIVE: _theme_prep_fgnd("roster.xa.active", "cyan", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ONLINE_UNREAD: _theme_prep_fgnd("roster.online.unread", "green", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_OFFLINE_UNREAD: _theme_prep_fgnd("roster.offline.unread", "red", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_CHAT_UNREAD: _theme_prep_fgnd("roster.chat.unread", "green", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_AWAY_UNREAD: _theme_prep_fgnd("roster.away.unread", "cyan", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_DND_UNREAD: _theme_prep_fgnd("roster.dnd.unread", "red", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_XA_UNREAD: _theme_prep_fgnd("roster.xa.unread", "cyan", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ROOM: _theme_prep_fgnd("roster.room", "green", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ROOM_UNREAD: _theme_prep_fgnd("roster.room.unread", "green", lookup_str, &bold); break;
|
||||
case THEME_OCCUPANTS_HEADER: _theme_prep_fgnd("occupants.header", "yellow", lookup_str, &bold); break;
|
||||
case THEME_TEXT: _theme_prep_fgnd("main.text", lookup_str, &bold); break;
|
||||
case THEME_TEXT_ME: _theme_prep_fgnd("main.text.me", lookup_str, &bold); break;
|
||||
case THEME_TEXT_THEM: _theme_prep_fgnd("main.text.them", lookup_str, &bold); break;
|
||||
case THEME_SPLASH: _theme_prep_fgnd("main.splash", lookup_str, &bold); break;
|
||||
case THEME_ERROR: _theme_prep_fgnd("error", lookup_str, &bold); break;
|
||||
case THEME_INCOMING: _theme_prep_fgnd("incoming", lookup_str, &bold); break;
|
||||
case THEME_INPUT_TEXT: _theme_prep_fgnd("input.text", lookup_str, &bold); break;
|
||||
case THEME_TIME: _theme_prep_fgnd("main.time", lookup_str, &bold); break;
|
||||
case THEME_TITLE_TEXT: _theme_prep_fgnd("titlebar.text", lookup_str, &bold); break;
|
||||
case THEME_TITLE_BRACKET: _theme_prep_fgnd("titlebar.brackets", lookup_str, &bold); break;
|
||||
case THEME_TITLE_UNENCRYPTED: _theme_prep_fgnd("titlebar.unencrypted", lookup_str, &bold); break;
|
||||
case THEME_TITLE_ENCRYPTED: _theme_prep_fgnd("titlebar.encrypted", lookup_str, &bold); break;
|
||||
case THEME_TITLE_UNTRUSTED: _theme_prep_fgnd("titlebar.untrusted", lookup_str, &bold); break;
|
||||
case THEME_TITLE_TRUSTED: _theme_prep_fgnd("titlebar.trusted", lookup_str, &bold); break;
|
||||
case THEME_TITLE_ONLINE: _theme_prep_fgnd("titlebar.online", lookup_str, &bold); break;
|
||||
case THEME_TITLE_OFFLINE: _theme_prep_fgnd("titlebar.offline", lookup_str, &bold); break;
|
||||
case THEME_TITLE_AWAY: _theme_prep_fgnd("titlebar.away", lookup_str, &bold); break;
|
||||
case THEME_TITLE_CHAT: _theme_prep_fgnd("titlebar.chat", lookup_str, &bold); break;
|
||||
case THEME_TITLE_DND: _theme_prep_fgnd("titlebar.dnd", lookup_str, &bold); break;
|
||||
case THEME_TITLE_XA: _theme_prep_fgnd("titlebar.xa", lookup_str, &bold); break;
|
||||
case THEME_STATUS_TEXT: _theme_prep_fgnd("statusbar.text", lookup_str, &bold); break;
|
||||
case THEME_STATUS_BRACKET: _theme_prep_fgnd("statusbar.brackets", lookup_str, &bold); break;
|
||||
case THEME_STATUS_ACTIVE: _theme_prep_fgnd("statusbar.active", lookup_str, &bold); break;
|
||||
case THEME_STATUS_NEW: _theme_prep_fgnd("statusbar.new", lookup_str, &bold); break;
|
||||
case THEME_ME: _theme_prep_fgnd("me", lookup_str, &bold); break;
|
||||
case THEME_THEM: _theme_prep_fgnd("them", lookup_str, &bold); break;
|
||||
case THEME_RECEIPT_SENT: _theme_prep_fgnd("receipt.sent", lookup_str, &bold); break;
|
||||
case THEME_ROOMINFO: _theme_prep_fgnd("roominfo", lookup_str, &bold); break;
|
||||
case THEME_ROOMMENTION: _theme_prep_fgnd("roommention", lookup_str, &bold); break;
|
||||
case THEME_ROOMTRIGGER: _theme_prep_fgnd("roomtrigger", lookup_str, &bold); break;
|
||||
case THEME_ONLINE: _theme_prep_fgnd("online", lookup_str, &bold); break;
|
||||
case THEME_OFFLINE: _theme_prep_fgnd("offline", lookup_str, &bold); break;
|
||||
case THEME_AWAY: _theme_prep_fgnd("away", lookup_str, &bold); break;
|
||||
case THEME_CHAT: _theme_prep_fgnd("chat", lookup_str, &bold); break;
|
||||
case THEME_DND: _theme_prep_fgnd("dnd", lookup_str, &bold); break;
|
||||
case THEME_XA: _theme_prep_fgnd("xa", lookup_str, &bold); break;
|
||||
case THEME_TYPING: _theme_prep_fgnd("typing", lookup_str, &bold); break;
|
||||
case THEME_GONE: _theme_prep_fgnd("gone", lookup_str, &bold); break;
|
||||
case THEME_SUBSCRIBED: _theme_prep_fgnd("subscribed", lookup_str, &bold); break;
|
||||
case THEME_UNSUBSCRIBED: _theme_prep_fgnd("unsubscribed", lookup_str, &bold); break;
|
||||
case THEME_OTR_STARTED_TRUSTED: _theme_prep_fgnd("otr.started.trusted", lookup_str, &bold); break;
|
||||
case THEME_OTR_STARTED_UNTRUSTED: _theme_prep_fgnd("otr.started.untrusted", lookup_str, &bold); break;
|
||||
case THEME_OTR_ENDED: _theme_prep_fgnd("otr.ended", lookup_str, &bold); break;
|
||||
case THEME_OTR_TRUSTED: _theme_prep_fgnd("otr.trusted", lookup_str, &bold); break;
|
||||
case THEME_OTR_UNTRUSTED: _theme_prep_fgnd("otr.untrusted", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_HEADER: _theme_prep_fgnd("roster.header", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ONLINE: _theme_prep_fgnd("roster.online", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_OFFLINE: _theme_prep_fgnd("roster.offline", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_CHAT: _theme_prep_fgnd("roster.chat", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_AWAY: _theme_prep_fgnd("roster.away", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_DND: _theme_prep_fgnd("roster.dnd", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_XA: _theme_prep_fgnd("roster.xa", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ONLINE_ACTIVE: _theme_prep_fgnd("roster.online.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_OFFLINE_ACTIVE: _theme_prep_fgnd("roster.offline.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_CHAT_ACTIVE: _theme_prep_fgnd("roster.chat.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_AWAY_ACTIVE: _theme_prep_fgnd("roster.away.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_DND_ACTIVE: _theme_prep_fgnd("roster.dnd.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_XA_ACTIVE: _theme_prep_fgnd("roster.xa.active", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ONLINE_UNREAD: _theme_prep_fgnd("roster.online.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_OFFLINE_UNREAD: _theme_prep_fgnd("roster.offline.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_CHAT_UNREAD: _theme_prep_fgnd("roster.chat.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_AWAY_UNREAD: _theme_prep_fgnd("roster.away.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_DND_UNREAD: _theme_prep_fgnd("roster.dnd.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_XA_UNREAD: _theme_prep_fgnd("roster.xa.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ROOM: _theme_prep_fgnd("roster.room", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ROOM_UNREAD: _theme_prep_fgnd("roster.room.unread", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ROOM_TRIGGER: _theme_prep_fgnd("roster.room.trigger", lookup_str, &bold); break;
|
||||
case THEME_ROSTER_ROOM_MENTION: _theme_prep_fgnd("roster.room.mention", lookup_str, &bold); break;
|
||||
case THEME_OCCUPANTS_HEADER: _theme_prep_fgnd("occupants.header", lookup_str, &bold); break;
|
||||
case THEME_WHITE: g_string_append(lookup_str, "white"); bold = FALSE; break;
|
||||
case THEME_WHITE_BOLD: g_string_append(lookup_str, "white"); bold = TRUE; break;
|
||||
case THEME_GREEN: g_string_append(lookup_str, "green"); bold = FALSE; break;
|
||||
|
@ -106,6 +106,8 @@ typedef enum {
|
||||
THEME_ROSTER_XA_UNREAD,
|
||||
THEME_ROSTER_ROOM,
|
||||
THEME_ROSTER_ROOM_UNREAD,
|
||||
THEME_ROSTER_ROOM_TRIGGER,
|
||||
THEME_ROSTER_ROOM_MENTION,
|
||||
THEME_RECEIPT_SENT,
|
||||
THEME_NONE,
|
||||
THEME_WHITE,
|
||||
|
@ -230,8 +230,7 @@ sv_ev_room_history(const char *const room_jid, const char *const nick,
|
||||
}
|
||||
|
||||
void
|
||||
sv_ev_room_message(const char *const room_jid, const char *const nick,
|
||||
const char *const message)
|
||||
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());
|
||||
@ -244,13 +243,25 @@ sv_ev_room_message(const char *const room_jid, const char *const nick,
|
||||
return;
|
||||
}
|
||||
|
||||
mucwin_message(mucwin, nick, message);
|
||||
char *mynick = muc_nick(mucwin->roomjid);
|
||||
|
||||
gboolean mention = FALSE;
|
||||
char *message_lower = g_utf8_strdown(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(message);
|
||||
|
||||
mucwin_message(mucwin, nick, message, mention, triggers != NULL);
|
||||
|
||||
ProfWin *window = (ProfWin*)mucwin;
|
||||
gboolean is_current = wins_is_current(window);
|
||||
int num = wins_get_num(window);
|
||||
char *my_nick = muc_nick(mucwin->roomjid);
|
||||
gboolean notify = prefs_do_room_notify(is_current, mucwin->roomjid, my_nick, message);
|
||||
gboolean notify = prefs_do_room_notify(is_current, mucwin->roomjid, mynick, message, mention, triggers != NULL);
|
||||
|
||||
// currently in groupchat window
|
||||
if (wins_is_current(window)) {
|
||||
@ -259,15 +270,10 @@ sv_ev_room_message(const char *const room_jid, const char *const nick,
|
||||
// not currently on groupchat window
|
||||
} else {
|
||||
status_bar_new(num);
|
||||
char *muc_show = prefs_get_string(PREF_CONSOLE_MUC);
|
||||
if (g_strcmp0(muc_show, "all") == 0) {
|
||||
cons_show_incoming_room_message(nick, mucwin->roomjid, num);
|
||||
} else if (g_strcmp0(muc_show, "first") == 0 && mucwin->unread == 0) {
|
||||
cons_show_incoming_room_message(NULL, mucwin->roomjid, num);
|
||||
}
|
||||
prefs_free_string(muc_show);
|
||||
|
||||
if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, my_nick) != 0)) {
|
||||
cons_show_incoming_room_message(nick, mucwin->roomjid, num, mention, triggers, mucwin->unread);
|
||||
|
||||
if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, mynick) != 0)) {
|
||||
flash();
|
||||
}
|
||||
|
||||
@ -275,12 +281,23 @@ sv_ev_room_message(const char *const room_jid, const char *const nick,
|
||||
if (notify) {
|
||||
mucwin->notify = TRUE;
|
||||
}
|
||||
|
||||
if (mention) {
|
||||
mucwin->unread_mentions = TRUE;
|
||||
}
|
||||
if (triggers) {
|
||||
mucwin->unread_triggers = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (triggers) {
|
||||
g_list_free_full(triggers, free);
|
||||
}
|
||||
|
||||
rosterwin_roster();
|
||||
|
||||
// don't notify self messages
|
||||
if (strcmp(nick, my_nick) == 0) {
|
||||
if (strcmp(nick, mynick) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -301,8 +301,27 @@ cons_show_typing(const char *const barejid)
|
||||
cons_alert();
|
||||
}
|
||||
|
||||
char*
|
||||
_room_triggers_to_string(GList *triggers)
|
||||
{
|
||||
GString *triggers_str = g_string_new("");
|
||||
GList *curr = triggers;
|
||||
while (curr) {
|
||||
g_string_append_printf(triggers_str, "\"%s\"", (char*)curr->data);
|
||||
curr = g_list_next(curr);
|
||||
if (curr) {
|
||||
g_string_append(triggers_str, ", ");
|
||||
}
|
||||
}
|
||||
|
||||
char *result = triggers_str->str;
|
||||
g_string_free(triggers_str, FALSE);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index)
|
||||
cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, gboolean mention,
|
||||
GList *triggers, int unread)
|
||||
{
|
||||
ProfWin *const console = wins_get_console();
|
||||
|
||||
@ -311,13 +330,35 @@ cons_show_incoming_room_message(const char *const nick, const char *const room,
|
||||
ui_index = 0;
|
||||
}
|
||||
|
||||
if (nick) {
|
||||
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s in %s (win %d)", nick, room, ui_index);
|
||||
} else {
|
||||
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s (win %d)", room, ui_index);
|
||||
}
|
||||
char *muc_show = prefs_get_string(PREF_CONSOLE_MUC);
|
||||
|
||||
if (g_strcmp0(muc_show, "all") == 0) {
|
||||
if (mention) {
|
||||
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room mention: %s in %s (win %d)", nick, room, ui_index);
|
||||
} else if (triggers) {
|
||||
char *triggers_str = _room_triggers_to_string(triggers);
|
||||
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index);
|
||||
free(triggers_str);
|
||||
} else {
|
||||
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s in %s (win %d)", nick, room, ui_index);
|
||||
}
|
||||
cons_alert();
|
||||
|
||||
} else if (g_strcmp0(muc_show, "first") == 0) {
|
||||
if (mention) {
|
||||
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room mention: %s in %s (win %d)", nick, room, ui_index);
|
||||
cons_alert();
|
||||
} else if (triggers) {
|
||||
char *triggers_str = _room_triggers_to_string(triggers);
|
||||
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room trigger %s: %s in %s (win %d)", triggers_str, nick, room, ui_index);
|
||||
free(triggers_str);
|
||||
cons_alert();
|
||||
} else if (unread == 0) {
|
||||
win_vprint(console, '-', 0, NULL, 0, THEME_INCOMING, "", "<< room message: %s (win %d)", room, ui_index);
|
||||
cons_alert();
|
||||
}
|
||||
}
|
||||
prefs_free_string(muc_show);
|
||||
}
|
||||
|
||||
void
|
||||
@ -2148,6 +2189,8 @@ cons_theme_properties(void)
|
||||
_cons_theme_prop(THEME_ROSTER_OFFLINE_UNREAD, "roster.offline.unread");
|
||||
_cons_theme_prop(THEME_ROSTER_ROOM, "roster.room");
|
||||
_cons_theme_prop(THEME_ROSTER_ROOM_UNREAD, "roster.room.unread");
|
||||
_cons_theme_prop(THEME_ROSTER_ROOM_TRIGGER, "roster.room.trigger");
|
||||
_cons_theme_prop(THEME_ROSTER_ROOM_MENTION, "roster.room.mention");
|
||||
|
||||
_cons_theme_prop(THEME_OCCUPANTS_HEADER, "occupants.header");
|
||||
|
||||
|
@ -356,7 +356,8 @@ mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp,
|
||||
}
|
||||
|
||||
void
|
||||
mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message)
|
||||
mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message, gboolean mention,
|
||||
gboolean trigger_found)
|
||||
{
|
||||
assert(mucwin != NULL);
|
||||
|
||||
@ -364,9 +365,9 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
|
||||
char *my_nick = muc_nick(mucwin->roomjid);
|
||||
|
||||
if (g_strcmp0(nick, my_nick) != 0) {
|
||||
if (g_strrstr(message, my_nick)) {
|
||||
if (mention) {
|
||||
win_print(window, '-', 0, NULL, NO_ME, THEME_ROOMMENTION, nick, message);
|
||||
} else if (prefs_message_contains_trigger(message)) {
|
||||
} else if (trigger_found) {
|
||||
win_print(window, '-', 0, NULL, NO_ME, THEME_ROOMTRIGGER, nick, message);
|
||||
} else {
|
||||
win_print(window, '-', 0, NULL, NO_ME, THEME_TEXT_THEM, nick, message);
|
||||
|
@ -479,7 +479,11 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
|
||||
{
|
||||
GString *msg = g_string_new(" ");
|
||||
|
||||
if (mucwin->unread > 0) {
|
||||
if (mucwin->unread_mentions) {
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_MENTION));
|
||||
} else if (mucwin->unread_triggers) {
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_TRIGGER));
|
||||
} else if (mucwin->unread > 0) {
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD));
|
||||
} else {
|
||||
wattron(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
|
||||
@ -514,7 +518,11 @@ _rosterwin_room(ProfLayoutSplit *layout, ProfMucWin *mucwin)
|
||||
win_sub_print(layout->subwin, msg->str, FALSE, wrap, current_indent);
|
||||
g_string_free(msg, TRUE);
|
||||
|
||||
if (mucwin->unread > 0) {
|
||||
if (mucwin->unread_mentions) {
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_MENTION));
|
||||
} else if (mucwin->unread_triggers) {
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_TRIGGER));
|
||||
} else if (mucwin->unread > 0) {
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM_UNREAD));
|
||||
} else {
|
||||
wattroff(layout->subwin, theme_attrs(THEME_ROSTER_ROOM));
|
||||
|
@ -158,7 +158,7 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char
|
||||
const char *const role, const char *const affiliation, const char *const actor, const char *const reason);
|
||||
void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char *const presence);
|
||||
void mucwin_history(ProfMucWin *mucwin, const char *const nick, GDateTime *timestamp, const char *const message);
|
||||
void mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message);
|
||||
void mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const message, gboolean mention, gboolean trigger_found);
|
||||
void mucwin_subject(ProfMucWin *mucwin, const char *const nick, const char *const subject);
|
||||
void mucwin_requires_config(ProfMucWin *mucwin);
|
||||
void mucwin_info(ProfMucWin *mucwin);
|
||||
@ -257,7 +257,8 @@ void cons_show_disco_info(const char *from, GSList *identities, GSList *features
|
||||
void cons_show_room_invite(const char *const invitor, const char *const room, const char *const reason);
|
||||
void cons_check_version(gboolean not_available_msg);
|
||||
void cons_show_typing(const char *const barejid);
|
||||
void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index);
|
||||
void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index,
|
||||
gboolean mention, GList *triggers, int unread);
|
||||
void cons_show_incoming_message(const char *const short_from, const int win_index);
|
||||
void cons_show_incoming_private_message(const char *const nick, const char *const room, const int win_index);
|
||||
void cons_show_room_invites(GSList *invites);
|
||||
|
@ -117,6 +117,8 @@ typedef struct prof_muc_win_t {
|
||||
ProfWin window;
|
||||
char *roomjid;
|
||||
int unread;
|
||||
gboolean unread_mentions;
|
||||
gboolean unread_triggers;
|
||||
gboolean notify;
|
||||
gboolean showjid;
|
||||
unsigned long memcheck;
|
||||
|
@ -181,6 +181,8 @@ win_create_muc(const char *const roomjid)
|
||||
|
||||
new_win->roomjid = strdup(roomjid);
|
||||
new_win->unread = 0;
|
||||
new_win->unread_mentions = FALSE;
|
||||
new_win->unread_triggers = FALSE;
|
||||
new_win->notify = FALSE;
|
||||
if (prefs_get_boolean(PREF_OCCUPANTS_JID)) {
|
||||
new_win->showjid = TRUE;
|
||||
|
@ -228,6 +228,8 @@ wins_set_current_by_num(int i)
|
||||
ProfMucWin *mucwin = (ProfMucWin*) window;
|
||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||
mucwin->unread = 0;
|
||||
mucwin->unread_mentions = FALSE;
|
||||
mucwin->unread_triggers = FALSE;
|
||||
mucwin->notify = FALSE;
|
||||
} else if (window->type == WIN_PRIVATE) {
|
||||
ProfPrivateWin *privatewin = (ProfPrivateWin*) window;
|
||||
|
@ -185,7 +185,7 @@ void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char
|
||||
const char * const affiliation, const char * const actor, const char * const reason) {}
|
||||
void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char * const presence) {}
|
||||
void mucwin_history(ProfMucWin *mucwin, const char * const nick, GDateTime *timestamp, const char * const message) {}
|
||||
void mucwin_message(ProfMucWin *mucwin, const char * const nick, const char * const message) {}
|
||||
void mucwin_message(ProfMucWin *mucwin, const char * const nick, const char * const message, gboolean mention, gboolean trigger_found) {}
|
||||
void mucwin_subject(ProfMucWin *mucwin, const char * const nick, const char * const subject) {}
|
||||
void mucwin_requires_config(ProfMucWin *mucwin) {}
|
||||
void ui_room_destroy(const char * const roomjid) {}
|
||||
@ -394,7 +394,7 @@ void cons_show_room_invite(const char * const invitor, const char * const room,
|
||||
const char * const reason) {}
|
||||
void cons_check_version(gboolean not_available_msg) {}
|
||||
void cons_show_typing(const char * const barejid) {}
|
||||
void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index) {}
|
||||
void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, gboolean mention, GList *triggers, int unread) {}
|
||||
void cons_show_incoming_message(const char * const short_from, const int win_index) {}
|
||||
void cons_show_room_invites(GSList *invites) {}
|
||||
void cons_show_received_subs(void) {}
|
||||
|
@ -67,6 +67,8 @@ roster.dnd.unread=
|
||||
roster.offline.unread=
|
||||
roster.room=
|
||||
roster.room.unread=
|
||||
roster.room.trigger=
|
||||
roster.room.mention=
|
||||
occupants.header=
|
||||
receipt.sent=
|
||||
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=blue
|
||||
roster.offline.unread=bold_black
|
||||
roster.room=cyan
|
||||
roster.room.unread=bold_cyan
|
||||
roster.room.mention=bold_blue
|
||||
roster.room.trigger=bold_blue
|
||||
occupants.header=bold_white
|
||||
receipt.sent=white
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=green
|
||||
roster.offline.unread=bold_black
|
||||
roster.room=green
|
||||
roster.room.unread=green
|
||||
roster.room.mention=green
|
||||
roster.room.trigger=green
|
||||
occupants.header=yellow
|
||||
receipt.sent=red
|
||||
|
@ -67,6 +67,8 @@ roster.dnd.unread=bold_red
|
||||
roster.offline.unread=bold_blue
|
||||
roster.room=bold_red
|
||||
roster.room.unread=bold_magenta
|
||||
roster.room.mention=bold_magenta
|
||||
roster.room.trigger=bold_magenta
|
||||
occupants.header=bold_magenta
|
||||
receipt.sent=bold_blue
|
||||
|
||||
|
@ -42,8 +42,8 @@ typing=yellow
|
||||
gone=red
|
||||
error=red
|
||||
roominfo=yellow
|
||||
roommention=bold_magenta
|
||||
roomtrigger=bold_red
|
||||
roommention=bold_cyan
|
||||
roomtrigger=bold_blue
|
||||
me=blue
|
||||
them=bold_green
|
||||
roster.header=bold_yellow
|
||||
@ -67,6 +67,8 @@ roster.dnd.unread=bold_magenta
|
||||
roster.offline.unread=bold_red
|
||||
roster.room=green
|
||||
roster.room.unread=bold_green
|
||||
roster.room.mention=bold_cyan
|
||||
roster.room.trigger=bold_blue
|
||||
occupants.header=bold_yellow
|
||||
receipt.sent=bold_black
|
||||
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=bold_black
|
||||
roster.offline.unread=bold_black
|
||||
roster.room=green
|
||||
roster.room.unread=bold_green
|
||||
roster.room.mention=bold_green
|
||||
roster.room.trigger=bold_green
|
||||
occupants.header=bold_green
|
||||
receipt.sent=bold_black
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=bold_magenta
|
||||
roster.offline.unread=bold_green
|
||||
roster.room=red
|
||||
roster.room.unread=bold_red
|
||||
roster.room.mention=bold_red
|
||||
roster.room.trigger=bold_red
|
||||
occupants.header=bold_cyan
|
||||
receipt.sent=red
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=green
|
||||
roster.offline.unread=bold_black
|
||||
roster.room=green
|
||||
roster.room.unread=green
|
||||
roster.room.mention=green
|
||||
roster.room.trigger=green
|
||||
occupants.header=magenta
|
||||
receipt.sent=red
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=white
|
||||
roster.offline.unread=white
|
||||
roster.room=white
|
||||
roster.room.unread=white
|
||||
roster.room.mention=white
|
||||
roster.room.trigger=white
|
||||
occupants.header=white
|
||||
receipt.sent=white
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=white
|
||||
roster.offline.unread=white
|
||||
roster.room=blue
|
||||
roster.room.unread=blue
|
||||
roster.room.mention=blue
|
||||
roster.room.trigger=blue
|
||||
occupants.header=black
|
||||
receipt.sent=red
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=red
|
||||
roster.offline.unread=red
|
||||
roster.room=green
|
||||
roster.room.unread=green
|
||||
roster.room.mention=green
|
||||
roster.room.trigger=green
|
||||
occupants.header=yellow
|
||||
receipt.sent=red
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=bold_red
|
||||
roster.offline.unread=bold_red
|
||||
roster.room=bold_green
|
||||
roster.room.unread=bold_green
|
||||
roster.room.mention=bold_green
|
||||
roster.room.trigger=bold_green
|
||||
occupants.header=bold_yellow
|
||||
receipt.sent=bold_red
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=green
|
||||
roster.offline.unread=white
|
||||
roster.room=green
|
||||
roster.room.unread=green
|
||||
roster.room.mention=green
|
||||
roster.room.trigger=green
|
||||
occupants.header=magenta
|
||||
receipt.sent=red
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=green
|
||||
roster.offline.unread=bold_black
|
||||
roster.room=green
|
||||
roster.room.unread=green
|
||||
roster.room.mention=green
|
||||
roster.room.trigger=green
|
||||
occupants.header=white
|
||||
receipt.sent=red
|
||||
|
@ -67,5 +67,7 @@ roster.dnd.unread=red
|
||||
roster.offline.unread=red
|
||||
roster.room=green
|
||||
roster.room.unread=green
|
||||
roster.room.mention=green
|
||||
roster.room.trigger=green
|
||||
occupants.header=black
|
||||
receipt.sent=red
|
||||
|
Loading…
Reference in New Issue
Block a user