2
|
1 /*
|
|
2 * Copyright (C) 2011 Pavol Rusnak <stick@gk2.sk>
|
|
3 *
|
|
4 * Licensed under the GNU General Public License Version 2
|
|
5 *
|
|
6 * This program is free software; you can redistribute it and/or modify
|
|
7 * it under the terms of the GNU General Public License as published by
|
|
8 * the Free Software Foundation; either version 2 of the License, or
|
|
9 * (at your option) any later version.
|
|
10 *
|
|
11 * This program is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 * GNU General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with this program; if not, write to the Free Software
|
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 */
|
|
20
|
0
|
21 #include <libnotify/notify.h>
|
|
22 #include "notify.h"
|
|
23
|
|
24 #define NOTIFY_NAME "Software Update"
|
|
25
|
|
26 void init_notify()
|
|
27 {
|
|
28 notify_init(NOTIFY_NAME);
|
|
29 }
|
|
30
|
|
31 void send_notify(int normal, int critical)
|
|
32 {
|
|
33 NotifyNotification *ntfy;
|
|
34 char buf[128];
|
|
35 if (critical > 0) {
|
|
36 snprintf(buf, sizeof(buf), "There are %d software updates available, %d of them critical.", normal + critical, critical);
|
|
37 } else {
|
|
38 snprintf(buf, sizeof(buf), "There are %d software updates available.", normal);
|
|
39 }
|
|
40 ntfy = notify_notification_new(NOTIFY_NAME, buf, critical > 0 ? "software-update-urgent" : "software-update-available");
|
|
41 notify_notification_set_timeout(ntfy, 3000);
|
|
42 notify_notification_set_urgency(ntfy, critical > 0 ? NOTIFY_URGENCY_CRITICAL : NOTIFY_URGENCY_NORMAL);
|
|
43 notify_notification_show(ntfy, NULL);
|
|
44 }
|