Mercurial > projects > pk-update-icon
comparison packagekit.c @ 0:f5e03fc667f8
initial commit
author | Pavol Rusnak <stick@gk2.sk> |
---|---|
date | Mon, 26 Sep 2011 18:52:04 +0200 |
parents | |
children | 847ae02bc13b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f5e03fc667f8 |
---|---|
1 #include <packagekit-glib2/packagekit.h> | |
2 #include "packagekit.h" | |
3 | |
4 void process(PkPackage *pkg, struct UpdatesInfo *info) | |
5 { | |
6 PkInfoEnum e = pk_package_get_info(pkg); | |
7 switch (e) { | |
8 case PK_INFO_ENUM_LOW: | |
9 case PK_INFO_ENUM_ENHANCEMENT: | |
10 case PK_INFO_ENUM_NORMAL: | |
11 info->normal++; | |
12 break; | |
13 case PK_INFO_ENUM_BUGFIX: | |
14 case PK_INFO_ENUM_IMPORTANT: | |
15 case PK_INFO_ENUM_SECURITY: | |
16 info->critical++; | |
17 break; | |
18 default: | |
19 break; | |
20 } | |
21 } | |
22 | |
23 void query_packagekit(struct UpdatesInfo *info) | |
24 { | |
25 PkClient *client = NULL; | |
26 PkResults *res = NULL; | |
27 GPtrArray *list = NULL; | |
28 GFunc process_func = (GFunc)process; | |
29 client = pk_client_new(); | |
30 res = pk_client_get_updates(client, pk_bitfield_value(PK_FILTER_ENUM_NEWEST), NULL, NULL, NULL, NULL); | |
31 if (!res) { | |
32 goto out; | |
33 } | |
34 list = pk_results_get_package_array(res); | |
35 if (!list) { | |
36 goto out; | |
37 } | |
38 info->normal = 0; | |
39 info->critical = 0; | |
40 g_ptr_array_foreach(list, process_func, info); | |
41 out: | |
42 if (list != NULL) | |
43 g_ptr_array_unref(list); | |
44 if(res != NULL) | |
45 g_object_unref(res); | |
46 if(client != NULL) | |
47 g_object_unref(client); | |
48 } |