mirror of
https://github.com/profanity-im/profanity.git
synced 2024-09-01 19:24:15 -04:00
Don't show notification reminders for messages the user does not want notifications for
This commit is contained in:
parent
e1962261a9
commit
6702bb9739
@ -228,9 +228,13 @@ prefs_message_get_triggers(const char *const message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
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 mynick,
|
||||||
gboolean mention, gboolean trigger_found)
|
const char *const theirnick, const char *const message, gboolean mention, gboolean trigger_found)
|
||||||
{
|
{
|
||||||
|
if (g_strcmp0(mynick, theirnick) == 0) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
gboolean notify_current = prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT);
|
gboolean notify_current = prefs_get_boolean(PREF_NOTIFY_ROOM_CURRENT);
|
||||||
gboolean notify_window = FALSE;
|
gboolean notify_window = FALSE;
|
||||||
if (!current_win || (current_win && notify_current) ) {
|
if (!current_win || (current_win && notify_current) ) {
|
||||||
|
@ -232,8 +232,8 @@ void prefs_free_string(char *pref);
|
|||||||
void prefs_set_string(preference_t pref, char *value);
|
void prefs_set_string(preference_t pref, char *value);
|
||||||
|
|
||||||
gboolean prefs_do_chat_notify(gboolean current_win);
|
gboolean prefs_do_chat_notify(gboolean current_win);
|
||||||
gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const nick,
|
gboolean prefs_do_room_notify(gboolean current_win, const char *const roomjid, const char *const mynick,
|
||||||
const char *const message, gboolean mention, gboolean trigger_found);
|
const char *const theirnick, const char *const message, gboolean mention, gboolean trigger_found);
|
||||||
GList* prefs_message_get_triggers(const char *const message);
|
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(const char *const roomjid, gboolean value);
|
||||||
|
@ -259,28 +259,29 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha
|
|||||||
mucwin_message(mucwin, nick, message, mention, triggers != NULL);
|
mucwin_message(mucwin, nick, message, mention, triggers != NULL);
|
||||||
|
|
||||||
ProfWin *window = (ProfWin*)mucwin;
|
ProfWin *window = (ProfWin*)mucwin;
|
||||||
gboolean is_current = wins_is_current(window);
|
|
||||||
int num = wins_get_num(window);
|
int num = wins_get_num(window);
|
||||||
gboolean notify = prefs_do_room_notify(is_current, mucwin->roomjid, mynick, message, mention, triggers != NULL);
|
gboolean is_current = FALSE;
|
||||||
|
|
||||||
// currently in groupchat window
|
// currently in groupchat window
|
||||||
if (wins_is_current(window)) {
|
if (wins_is_current(window)) {
|
||||||
|
is_current = TRUE;
|
||||||
status_bar_active(num);
|
status_bar_active(num);
|
||||||
|
|
||||||
|
if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_BEEP))) {
|
||||||
|
beep();
|
||||||
|
}
|
||||||
|
|
||||||
// not currently on groupchat window
|
// not currently on groupchat window
|
||||||
} else {
|
} else {
|
||||||
status_bar_new(num);
|
status_bar_new(num);
|
||||||
|
|
||||||
cons_show_incoming_room_message(nick, mucwin->roomjid, num, mention, triggers, mucwin->unread);
|
if ((g_strcmp0(mynick, nick) != 0) && (prefs_get_boolean(PREF_FLASH))) {
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_FLASH) && (strcmp(nick, mynick) != 0)) {
|
|
||||||
flash();
|
flash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cons_show_incoming_room_message(nick, mucwin->roomjid, num, mention, triggers, mucwin->unread);
|
||||||
|
|
||||||
mucwin->unread++;
|
mucwin->unread++;
|
||||||
if (notify) {
|
|
||||||
mucwin->notify = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mention) {
|
if (mention) {
|
||||||
mucwin->unread_mentions = TRUE;
|
mucwin->unread_mentions = TRUE;
|
||||||
@ -290,26 +291,17 @@ sv_ev_room_message(const char *const room_jid, const char *const nick, const cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (prefs_do_room_notify(is_current, mucwin->roomjid, mynick, nick, message, mention, triggers != NULL)) {
|
||||||
|
Jid *jidp = jid_create(mucwin->roomjid);
|
||||||
|
notify_room_message(nick, jidp->localpart, num, message);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
}
|
||||||
|
|
||||||
if (triggers) {
|
if (triggers) {
|
||||||
g_list_free_full(triggers, free);
|
g_list_free_full(triggers, free);
|
||||||
}
|
}
|
||||||
|
|
||||||
rosterwin_roster();
|
rosterwin_roster();
|
||||||
|
|
||||||
// don't notify self messages
|
|
||||||
if (strcmp(nick, mynick) == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_BEEP)) {
|
|
||||||
beep();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notify) {
|
|
||||||
Jid *jidp = jid_create(mucwin->roomjid);
|
|
||||||
notify_room_message(nick, jidp->localpart, num, message);
|
|
||||||
jid_destroy(jidp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -258,9 +258,7 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
|
|||||||
}
|
}
|
||||||
|
|
||||||
chatwin->unread++;
|
chatwin->unread++;
|
||||||
if (notify) {
|
|
||||||
chatwin->notify = TRUE;
|
|
||||||
}
|
|
||||||
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
if (prefs_get_boolean(PREF_CHLOG) && prefs_get_boolean(PREF_HISTORY)) {
|
||||||
_chatwin_history(chatwin, chatwin->barejid);
|
_chatwin_history(chatwin, chatwin->barejid);
|
||||||
}
|
}
|
||||||
|
@ -72,9 +72,6 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
|
|||||||
win_print_incoming_message(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN);
|
win_print_incoming_message(window, timestamp, jidp->resourcepart, message, PROF_MSG_PLAIN);
|
||||||
|
|
||||||
privatewin->unread++;
|
privatewin->unread++;
|
||||||
if (notify) {
|
|
||||||
privatewin->notify = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prefs_get_boolean(PREF_FLASH)) {
|
if (prefs_get_boolean(PREF_FLASH)) {
|
||||||
flash();
|
flash();
|
||||||
|
@ -102,7 +102,6 @@ typedef struct prof_chat_win_t {
|
|||||||
ProfWin window;
|
ProfWin window;
|
||||||
char *barejid;
|
char *barejid;
|
||||||
int unread;
|
int unread;
|
||||||
gboolean notify;
|
|
||||||
ChatState *state;
|
ChatState *state;
|
||||||
gboolean is_otr;
|
gboolean is_otr;
|
||||||
gboolean otr_is_trusted;
|
gboolean otr_is_trusted;
|
||||||
@ -119,7 +118,6 @@ typedef struct prof_muc_win_t {
|
|||||||
int unread;
|
int unread;
|
||||||
gboolean unread_mentions;
|
gboolean unread_mentions;
|
||||||
gboolean unread_triggers;
|
gboolean unread_triggers;
|
||||||
gboolean notify;
|
|
||||||
gboolean showjid;
|
gboolean showjid;
|
||||||
unsigned long memcheck;
|
unsigned long memcheck;
|
||||||
} ProfMucWin;
|
} ProfMucWin;
|
||||||
@ -135,7 +133,6 @@ typedef struct prof_private_win_t {
|
|||||||
ProfWin window;
|
ProfWin window;
|
||||||
char *fulljid;
|
char *fulljid;
|
||||||
int unread;
|
int unread;
|
||||||
gboolean notify;
|
|
||||||
unsigned long memcheck;
|
unsigned long memcheck;
|
||||||
gboolean occupant_offline;
|
gboolean occupant_offline;
|
||||||
gboolean room_left;
|
gboolean room_left;
|
||||||
|
@ -141,7 +141,6 @@ win_create_chat(const char *const barejid)
|
|||||||
new_win->pgp_send = FALSE;
|
new_win->pgp_send = FALSE;
|
||||||
new_win->history_shown = FALSE;
|
new_win->history_shown = FALSE;
|
||||||
new_win->unread = 0;
|
new_win->unread = 0;
|
||||||
new_win->notify = FALSE;
|
|
||||||
new_win->state = chat_state_new();
|
new_win->state = chat_state_new();
|
||||||
|
|
||||||
new_win->memcheck = PROFCHATWIN_MEMCHECK;
|
new_win->memcheck = PROFCHATWIN_MEMCHECK;
|
||||||
@ -183,7 +182,6 @@ win_create_muc(const char *const roomjid)
|
|||||||
new_win->unread = 0;
|
new_win->unread = 0;
|
||||||
new_win->unread_mentions = FALSE;
|
new_win->unread_mentions = FALSE;
|
||||||
new_win->unread_triggers = FALSE;
|
new_win->unread_triggers = FALSE;
|
||||||
new_win->notify = FALSE;
|
|
||||||
if (prefs_get_boolean(PREF_OCCUPANTS_JID)) {
|
if (prefs_get_boolean(PREF_OCCUPANTS_JID)) {
|
||||||
new_win->showjid = TRUE;
|
new_win->showjid = TRUE;
|
||||||
} else {
|
} else {
|
||||||
@ -219,7 +217,6 @@ win_create_private(const char *const fulljid)
|
|||||||
|
|
||||||
new_win->fulljid = strdup(fulljid);
|
new_win->fulljid = strdup(fulljid);
|
||||||
new_win->unread = 0;
|
new_win->unread = 0;
|
||||||
new_win->notify = FALSE;
|
|
||||||
new_win->occupant_offline = FALSE;
|
new_win->occupant_offline = FALSE;
|
||||||
new_win->room_left = FALSE;
|
new_win->room_left = FALSE;
|
||||||
|
|
||||||
@ -1313,19 +1310,45 @@ win_has_active_subwin(ProfWin *window)
|
|||||||
gboolean
|
gboolean
|
||||||
win_notify(ProfWin *window)
|
win_notify(ProfWin *window)
|
||||||
{
|
{
|
||||||
if (window->type == WIN_CHAT) {
|
switch (window->type) {
|
||||||
|
case WIN_CHAT:
|
||||||
|
{
|
||||||
ProfChatWin *chatwin = (ProfChatWin*) window;
|
ProfChatWin *chatwin = (ProfChatWin*) window;
|
||||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||||
return chatwin->notify;
|
|
||||||
} else if (window->type == WIN_MUC) {
|
if (prefs_get_boolean(PREF_NOTIFY_CHAT) && chatwin->unread > 0) {
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case WIN_MUC:
|
||||||
|
{
|
||||||
ProfMucWin *mucwin = (ProfMucWin*) window;
|
ProfMucWin *mucwin = (ProfMucWin*) window;
|
||||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||||
return mucwin->notify;
|
|
||||||
} else if (window->type == WIN_PRIVATE) {
|
if (prefs_get_room_notify(mucwin->roomjid) && mucwin->unread > 0) {
|
||||||
|
return TRUE;
|
||||||
|
} else if (prefs_get_room_notify_mention(mucwin->roomjid) && mucwin->unread_mentions) {
|
||||||
|
return TRUE;
|
||||||
|
} else if (prefs_get_room_notify_trigger(mucwin->roomjid) && mucwin->unread_triggers) {
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case WIN_PRIVATE:
|
||||||
|
{
|
||||||
ProfPrivateWin *privatewin = (ProfPrivateWin*) window;
|
ProfPrivateWin *privatewin = (ProfPrivateWin*) window;
|
||||||
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
||||||
return privatewin->notify;
|
|
||||||
} else {
|
if (prefs_get_boolean(PREF_NOTIFY_CHAT) && privatewin->unread > 0) {
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,18 +273,15 @@ wins_set_current_by_num(int i)
|
|||||||
ProfChatWin *chatwin = (ProfChatWin*) window;
|
ProfChatWin *chatwin = (ProfChatWin*) window;
|
||||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||||
chatwin->unread = 0;
|
chatwin->unread = 0;
|
||||||
chatwin->notify = FALSE;
|
|
||||||
} else if (window->type == WIN_MUC) {
|
} else if (window->type == WIN_MUC) {
|
||||||
ProfMucWin *mucwin = (ProfMucWin*) window;
|
ProfMucWin *mucwin = (ProfMucWin*) window;
|
||||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||||
mucwin->unread = 0;
|
mucwin->unread = 0;
|
||||||
mucwin->unread_mentions = FALSE;
|
mucwin->unread_mentions = FALSE;
|
||||||
mucwin->unread_triggers = FALSE;
|
mucwin->unread_triggers = FALSE;
|
||||||
mucwin->notify = FALSE;
|
|
||||||
} else if (window->type == WIN_PRIVATE) {
|
} else if (window->type == WIN_PRIVATE) {
|
||||||
ProfPrivateWin *privatewin = (ProfPrivateWin*) window;
|
ProfPrivateWin *privatewin = (ProfPrivateWin*) window;
|
||||||
privatewin->unread = 0;
|
privatewin->unread = 0;
|
||||||
privatewin->notify = FALSE;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user