annotate notify.c @ 2:847ae02bc13b

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