From 34217e4d44bef20ddac3aa454ce733ad73ddf769 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 27 Apr 2013 23:57:51 +0100 Subject: [PATCH] Include open subscription requests in desktop reminder notifications closes #167 --- src/ui/notifier.c | 13 ++++++++++++- src/xmpp/presence.c | 10 ++++++++++ src/xmpp/xmpp.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/ui/notifier.c b/src/ui/notifier.c index e3716e3d..0a4cd6d2 100644 --- a/src/ui/notifier.c +++ b/src/ui/notifier.c @@ -106,6 +106,7 @@ notify_remind(void) { gint unread = ui_unread(); gint open = muc_invite_count(); + gint subs = presence_sub_request_count(); GString *text = g_string_new(""); @@ -127,8 +128,18 @@ notify_remind(void) g_string_append_printf(text, "%d room invites", open); } } + if (subs > 0) { + if ((unread > 0) || (open > 0)) { + g_string_append(text, "\n"); + } + if (subs == 1) { + g_string_append(text, "1 subscription request"); + } else { + g_string_append_printf(text, "%d subscription requests", subs); + } + } - if ((unread > 0) || (open > 0)) { + if ((unread > 0) || (open > 0) || (subs > 0)) { _notify(text->str, 5000, "Incoming message"); } diff --git a/src/xmpp/presence.c b/src/xmpp/presence.c index 94ea5bb6..8dd0080b 100644 --- a/src/xmpp/presence.c +++ b/src/xmpp/presence.c @@ -129,6 +129,16 @@ presence_get_subscription_requests(void) return g_hash_table_get_keys(sub_requests); } +gint +presence_sub_request_count(void) +{ + if (sub_requests == NULL) { + return 0; + } else { + return g_hash_table_size(sub_requests); + } +} + void presence_free_sub_requests(void) { diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 0fa8cdf8..03b6ad85 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -103,6 +103,7 @@ void message_send_invite(const char * const room, const char * const contact, // presence functions void presence_subscription(const char * const jid, const jabber_subscr_t action); GList* presence_get_subscription_requests(void); +gint presence_sub_request_count(void); void presence_join_room(Jid *jid); void presence_change_room_nick(const char * const room, const char * const nick); void presence_leave_chat_room(const char * const room_jid);