annotate packagekit.c @ 0:f5e03fc667f8

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