annotate packagekit.c @ 4:9126094c5ef0

use GTK2 as Xfce/LXDE are not yet using GTK3
author Pavol Rusnak <stick@gk2.sk>
date Thu, 06 Oct 2011 15:31:50 +0200
parents 847ae02bc13b
children
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 <packagekit-glib2/packagekit.h>
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
22 #include "packagekit.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 void process(PkPackage *pkg, struct UpdatesInfo *info)
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
25 {
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
26 PkInfoEnum e = pk_package_get_info(pkg);
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
27 switch (e) {
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
28 case PK_INFO_ENUM_LOW:
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
29 case PK_INFO_ENUM_ENHANCEMENT:
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
30 case PK_INFO_ENUM_NORMAL:
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
31 info->normal++;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
32 break;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
33 case PK_INFO_ENUM_BUGFIX:
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
34 case PK_INFO_ENUM_IMPORTANT:
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
35 case PK_INFO_ENUM_SECURITY:
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
36 info->critical++;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
37 break;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
38 default:
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
39 break;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
40 }
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
41 }
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
42
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
43 void query_packagekit(struct UpdatesInfo *info)
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
44 {
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
45 PkClient *client = NULL;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
46 PkResults *res = NULL;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
47 GPtrArray *list = NULL;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
48 GFunc process_func = (GFunc)process;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
49 client = pk_client_new();
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
50 res = pk_client_get_updates(client, pk_bitfield_value(PK_FILTER_ENUM_NEWEST), NULL, NULL, NULL, NULL);
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
51 if (!res) {
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
52 goto out;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
53 }
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
54 list = pk_results_get_package_array(res);
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
55 if (!list) {
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
56 goto out;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
57 }
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
58 info->normal = 0;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
59 info->critical = 0;
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
60 g_ptr_array_foreach(list, process_func, info);
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
61 out:
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
62 if (list != NULL)
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
63 g_ptr_array_unref(list);
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
64 if(res != NULL)
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
65 g_object_unref(res);
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
66 if(client != NULL)
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
67 g_object_unref(client);
f5e03fc667f8 initial commit
Pavol Rusnak <stick@gk2.sk>
parents:
diff changeset
68 }