1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Include open subscription requests in desktop reminder notifications

closes #167
This commit is contained in:
James Booth 2013-04-27 23:57:51 +01:00
parent 441422ddc8
commit 34217e4d44
3 changed files with 23 additions and 1 deletions

View File

@ -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");
}

View File

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

View File

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