mirror of
https://github.com/profanity-im/profanity.git
synced 2024-10-27 20:30:13 -04:00
Only show reminder notifications when notifications are enabled
This commit is contained in:
parent
20e63e364b
commit
d3389db233
@ -239,6 +239,9 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
|
|||||||
|
|
||||||
char *display_name = roster_get_msg_display_name(chatwin->barejid, resource);
|
char *display_name = roster_get_msg_display_name(chatwin->barejid, resource);
|
||||||
|
|
||||||
|
gboolean is_current = wins_is_current(window);
|
||||||
|
gboolean notify = prefs_get_notify_chat(is_current, message);
|
||||||
|
|
||||||
// currently viewing chat window with sender
|
// currently viewing chat window with sender
|
||||||
if (wins_is_current(window)) {
|
if (wins_is_current(window)) {
|
||||||
win_print_incoming_message(window, timestamp, display_name, message, enc_mode);
|
win_print_incoming_message(window, timestamp, display_name, message, enc_mode);
|
||||||
@ -255,6 +258,9 @@ 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);
|
||||||
}
|
}
|
||||||
@ -274,8 +280,6 @@ chatwin_incoming_msg(ProfChatWin *chatwin, const char *const resource, const cha
|
|||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean is_current = wins_is_current(window);
|
|
||||||
gboolean notify = prefs_get_notify_chat(is_current, message);
|
|
||||||
if (!notify) {
|
if (!notify) {
|
||||||
free(display_name);
|
free(display_name);
|
||||||
return;
|
return;
|
||||||
|
@ -374,6 +374,9 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
|
|||||||
win_print(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message);
|
win_print(window, '-', 0, NULL, 0, THEME_TEXT_ME, nick, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean is_current = wins_is_current(window);
|
||||||
|
gboolean notify = prefs_get_notify_room(is_current, my_nick, message);
|
||||||
|
|
||||||
// currently in groupchat window
|
// currently in groupchat window
|
||||||
if (wins_is_current(window)) {
|
if (wins_is_current(window)) {
|
||||||
status_bar_active(num);
|
status_bar_active(num);
|
||||||
@ -388,6 +391,9 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
|
|||||||
}
|
}
|
||||||
|
|
||||||
mucwin->unread++;
|
mucwin->unread++;
|
||||||
|
if (notify) {
|
||||||
|
mucwin->notify = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't notify self messages
|
// don't notify self messages
|
||||||
@ -399,8 +405,6 @@ mucwin_message(ProfMucWin *mucwin, const char *const nick, const char *const mes
|
|||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean is_current = wins_is_current(window);
|
|
||||||
gboolean notify = prefs_get_notify_room(is_current, my_nick, message);
|
|
||||||
if (!notify) {
|
if (!notify) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -140,13 +140,14 @@ notify_remind(void)
|
|||||||
gdouble elapsed = g_timer_elapsed(remind_timer, NULL);
|
gdouble elapsed = g_timer_elapsed(remind_timer, NULL);
|
||||||
gint remind_period = prefs_get_notify_remind();
|
gint remind_period = prefs_get_notify_remind();
|
||||||
if (remind_period > 0 && elapsed >= remind_period) {
|
if (remind_period > 0 && elapsed >= remind_period) {
|
||||||
|
gboolean notify = wins_get_notify();
|
||||||
gint unread = wins_get_total_unread();
|
gint unread = wins_get_total_unread();
|
||||||
gint open = muc_invites_count();
|
gint open = muc_invites_count();
|
||||||
gint subs = presence_sub_request_count();
|
gint subs = presence_sub_request_count();
|
||||||
|
|
||||||
GString *text = g_string_new("");
|
GString *text = g_string_new("");
|
||||||
|
|
||||||
if (unread > 0) {
|
if (notify && unread > 0) {
|
||||||
if (unread == 1) {
|
if (unread == 1) {
|
||||||
g_string_append(text, "1 unread message");
|
g_string_append(text, "1 unread message");
|
||||||
} else {
|
} else {
|
||||||
@ -175,7 +176,7 @@ notify_remind(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((unread > 0) || (open > 0) || (subs > 0)) {
|
if ((notify && unread > 0) || (open > 0) || (subs > 0)) {
|
||||||
_notify(text->str, 5000, "Incoming message");
|
_notify(text->str, 5000, "Incoming message");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +53,9 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
|
|||||||
|
|
||||||
char *display_from = get_nick_from_full_jid(privatewin->fulljid);
|
char *display_from = get_nick_from_full_jid(privatewin->fulljid);
|
||||||
|
|
||||||
|
gboolean is_current = wins_is_current(window);
|
||||||
|
gboolean notify = prefs_get_notify_chat(is_current, message);
|
||||||
|
|
||||||
// currently viewing chat window with sender
|
// currently viewing chat window with sender
|
||||||
if (wins_is_current(window)) {
|
if (wins_is_current(window)) {
|
||||||
win_print_incoming_message(window, timestamp, display_from, message, PROF_MSG_PLAIN);
|
win_print_incoming_message(window, timestamp, display_from, message, PROF_MSG_PLAIN);
|
||||||
@ -62,6 +65,9 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
|
|||||||
// not currently viewing chat window with sender
|
// not currently viewing chat window with sender
|
||||||
} else {
|
} else {
|
||||||
privatewin->unread++;
|
privatewin->unread++;
|
||||||
|
if (notify) {
|
||||||
|
privatewin->notify = TRUE;
|
||||||
|
}
|
||||||
status_bar_new(num);
|
status_bar_new(num);
|
||||||
cons_show_incoming_message(display_from, num);
|
cons_show_incoming_message(display_from, num);
|
||||||
win_print_incoming_message(window, timestamp, display_from, message, PROF_MSG_PLAIN);
|
win_print_incoming_message(window, timestamp, display_from, message, PROF_MSG_PLAIN);
|
||||||
@ -75,18 +81,6 @@ privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message, GDat
|
|||||||
beep();
|
beep();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!prefs_get_boolean(PREF_NOTIFY_MESSAGE)) {
|
|
||||||
free(display_from);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean notify = FALSE;
|
|
||||||
|
|
||||||
gboolean is_current = wins_is_current(window);
|
|
||||||
if (!is_current || (is_current && prefs_get_boolean(PREF_NOTIFY_MESSAGE_CURRENT)) ) {
|
|
||||||
notify = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!notify) {
|
if (!notify) {
|
||||||
free(display_from);
|
free(display_from);
|
||||||
return;
|
return;
|
||||||
|
@ -319,6 +319,7 @@ ProfWin* win_create_muc_config(const char *const title, DataForm *form);
|
|||||||
ProfWin* win_create_private(const char *const fulljid);
|
ProfWin* win_create_private(const char *const fulljid);
|
||||||
void win_update_virtual(ProfWin *window);
|
void win_update_virtual(ProfWin *window);
|
||||||
void win_free(ProfWin *window);
|
void win_free(ProfWin *window);
|
||||||
|
gboolean win_notify(ProfWin *window);
|
||||||
int win_unread(ProfWin *window);
|
int win_unread(ProfWin *window);
|
||||||
void win_resize(ProfWin *window);
|
void win_resize(ProfWin *window);
|
||||||
void win_hide_subwin(ProfWin *window);
|
void win_hide_subwin(ProfWin *window);
|
||||||
|
@ -102,6 +102,7 @@ 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;
|
||||||
@ -116,6 +117,7 @@ typedef struct prof_muc_win_t {
|
|||||||
ProfWin window;
|
ProfWin window;
|
||||||
char *roomjid;
|
char *roomjid;
|
||||||
int unread;
|
int unread;
|
||||||
|
gboolean notify;
|
||||||
gboolean showjid;
|
gboolean showjid;
|
||||||
unsigned long memcheck;
|
unsigned long memcheck;
|
||||||
} ProfMucWin;
|
} ProfMucWin;
|
||||||
@ -131,6 +133,7 @@ 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;
|
||||||
} ProfPrivateWin;
|
} ProfPrivateWin;
|
||||||
|
|
||||||
|
@ -141,6 +141,7 @@ 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;
|
||||||
@ -180,6 +181,7 @@ win_create_muc(const char *const roomjid)
|
|||||||
|
|
||||||
new_win->roomjid = strdup(roomjid);
|
new_win->roomjid = strdup(roomjid);
|
||||||
new_win->unread = 0;
|
new_win->unread = 0;
|
||||||
|
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 {
|
||||||
@ -215,6 +217,7 @@ 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->memcheck = PROFPRIVATEWIN_MEMCHECK;
|
new_win->memcheck = PROFPRIVATEWIN_MEMCHECK;
|
||||||
|
|
||||||
@ -1245,6 +1248,26 @@ win_has_active_subwin(ProfWin *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
win_notify(ProfWin *window)
|
||||||
|
{
|
||||||
|
if (window->type == WIN_CHAT) {
|
||||||
|
ProfChatWin *chatwin = (ProfChatWin*) window;
|
||||||
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||||
|
return chatwin->notify;
|
||||||
|
} else if (window->type == WIN_MUC) {
|
||||||
|
ProfMucWin *mucwin = (ProfMucWin*) window;
|
||||||
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||||
|
return mucwin->notify;
|
||||||
|
} else if (window->type == WIN_PRIVATE) {
|
||||||
|
ProfPrivateWin *privatewin = (ProfPrivateWin*) window;
|
||||||
|
assert(privatewin->memcheck == PROFPRIVATEWIN_MEMCHECK);
|
||||||
|
return privatewin->notify;
|
||||||
|
} else {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
win_unread(ProfWin *window)
|
win_unread(ProfWin *window)
|
||||||
{
|
{
|
||||||
|
@ -189,13 +189,16 @@ 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->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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -382,6 +385,23 @@ wins_new_private(const char *const fulljid)
|
|||||||
return newwin;
|
return newwin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
wins_get_notify(void)
|
||||||
|
{
|
||||||
|
GList *values = g_hash_table_get_values(windows);
|
||||||
|
GList *curr = values;
|
||||||
|
|
||||||
|
while (curr) {
|
||||||
|
ProfWin *window = curr->data;
|
||||||
|
if (win_notify(window)) {
|
||||||
|
g_list_free(values);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
wins_get_total_unread(void)
|
wins_get_total_unread(void)
|
||||||
{
|
{
|
||||||
|
@ -67,6 +67,7 @@ int wins_get_current_num(void);
|
|||||||
void wins_close_current(void);
|
void wins_close_current(void);
|
||||||
void wins_close_by_num(int i);
|
void wins_close_by_num(int i);
|
||||||
gboolean wins_is_current(ProfWin *window);
|
gboolean wins_is_current(ProfWin *window);
|
||||||
|
gboolean wins_get_notify(void);
|
||||||
int wins_get_total_unread(void);
|
int wins_get_total_unread(void);
|
||||||
void wins_resize_all(void);
|
void wins_resize_all(void);
|
||||||
GSList* wins_get_chat_recipients(void);
|
GSList* wins_get_chat_recipients(void);
|
||||||
|
@ -486,6 +486,10 @@ ProfWin* win_create_private(const char * const fulljid)
|
|||||||
|
|
||||||
void win_update_virtual(ProfWin *window) {}
|
void win_update_virtual(ProfWin *window) {}
|
||||||
void win_free(ProfWin *window) {}
|
void win_free(ProfWin *window) {}
|
||||||
|
gboolean win_notify(ProfWin *window)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
int win_unread(ProfWin *window)
|
int win_unread(ProfWin *window)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user