Esempio n. 1
0
void
notify_remind(void)
{
    gdouble elapsed = g_timer_elapsed(remind_timer, NULL);
    gint remind_period = prefs_get_notify_remind();
    if (remind_period > 0 && elapsed >= remind_period) {
        gboolean notify = wins_do_notify_remind();
        gint unread = wins_get_total_unread();
        gint open = muc_invites_count();
        gint subs = presence_sub_request_count();

        GString *text = g_string_new("");

        if (notify && unread > 0) {
            if (unread == 1) {
                g_string_append(text, "1 unread message");
            } else {
                g_string_append_printf(text, "%d unread messages", unread);
            }

        }
        if (open > 0) {
            if (unread > 0) {
                g_string_append(text, "\n");
            }
            if (open == 1) {
                g_string_append(text, "1 room invite");
            } else {
                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 ((notify && unread > 0) || (open > 0) || (subs > 0)) {
            _notify(text->str, 5000, "Incoming message");
        }

        g_string_free(text, TRUE);

        g_timer_start(remind_timer);
    }
}
Esempio n. 2
0
static void
_notify_remind(void)
{
    gint unread = ui_unread();
    gint open = muc_invite_count();
    gint subs = presence_sub_request_count();

    GString *text = g_string_new("");

    if (unread > 0) {
        if (unread == 1) {
            g_string_append(text, "1 unread message");
        } else {
            g_string_append_printf(text, "%d unread messages", unread);
        }

    }
    if (open > 0) {
        if (unread > 0) {
            g_string_append(text, "\n");
        }
        if (open == 1) {
            g_string_append(text, "1 room invite");
        } else {
            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) || (subs > 0)) {
        _notify(text->str, 5000, "Incoming message");
    }

    g_string_free(text, TRUE);
}