Tidy regular chat and room notifications

This commit is contained in:
James Booth
2015-11-24 23:03:52 +00:00
parent 00a735ece5
commit 9c8b137a51
8 changed files with 128 additions and 60 deletions

View File

@@ -202,6 +202,47 @@ prefs_reset_room_trigger_ac(void)
autocomplete_reset(room_trigger_ac);
}
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)
{

View File

@@ -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