diff options
author | James Booth <boothj5@gmail.com> | 2015-11-24 23:03:52 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2015-11-24 23:03:52 +0000 |
commit | 9c8b137a515e90f55606177c75847493fa02f556 (patch) | |
tree | 2bd84de203d85679dc908d57c2dfd758e19b174d /src/config | |
parent | 00a735ece58421a6d4d3f7a161684b033aea828a (diff) | |
download | profani-tty-9c8b137a515e90f55606177c75847493fa02f556.tar.gz |
Tidy regular chat and room notifications
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/preferences.c | 41 | ||||
-rw-r--r-- | src/config/preferences.h | 3 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/config/preferences.c b/src/config/preferences.c index 2051e66b..205d47df 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -203,6 +203,47 @@ prefs_reset_room_trigger_ac(void) } gboolean +prefs_get_notify_chat(gboolean current_win) +{ + gboolean notify_message = prefs_get_boolean(PREF_NOTIFY_MESSAGE); + gboolean notify_window = FALSE; + + if (!current_win || (current_win && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) { + notify_window = TRUE; + } + + return (notify_message && notify_window); +} + +gboolean +prefs_get_notify_room(gboolean current_win, const char *const nick, const char *const message) +{ + gboolean notify_message = FALSE; + gboolean notify_window = FALSE; + + char *room_setting = prefs_get_string(PREF_NOTIFY_ROOM); + if (g_strcmp0(room_setting, "on") == 0) { + notify_message = TRUE; + } + if (g_strcmp0(room_setting, "mention") == 0) { + char *message_lower = g_utf8_strdown(message, -1); + char *nick_lower = g_utf8_strdown(nick, -1); + if (g_strrstr(message_lower, nick_lower)) { + notify_message = TRUE; + } + g_free(message_lower); + g_free(nick_lower); + } + prefs_free_string(room_setting); + + if (!current_win || (current_win && prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT)) ) { + notify_window = TRUE; + } + + return (notify_message && notify_window); +} + +gboolean prefs_get_boolean(preference_t pref) { const char *group = _get_group(pref); diff --git a/src/config/preferences.h b/src/config/preferences.h index 9038591d..face1811 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -213,4 +213,7 @@ char* prefs_get_string(preference_t pref); void prefs_free_string(char *pref); void prefs_set_string(preference_t pref, char *value); +gboolean prefs_get_notify_chat(gboolean current_win); +gboolean prefs_get_notify_room(gboolean current_win, const char *const nick, const char *const message); + #endif |