Mercurial > projects > pk-update-icon
annotate pkui-backend.c @ 52:fc48347a3dd9
Added tag version-2 for changeset f119075975e8
author | Guido Berhoerster <gber@opensuse.org> |
---|---|
date | Fri, 19 Jun 2015 13:09:45 +0200 |
parents | a29fbf0a7f6c |
children | 7de92a24e86c |
rev | line source |
---|---|
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
1 /* |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
2 * (C) 2011 Guido Berhoerster <gber@opensuse.org> |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
3 * |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
4 * Licensed under the GNU General Public License Version 2 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
5 * |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
9 * (at your option) any later version. |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
10 * |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
15 * |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
19 */ |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
20 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
21 #include <packagekit-glib2/packagekit.h> |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
22 #include "pkui-backend.h" |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
23 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
24 G_DEFINE_TYPE(PkuiBackend, pkui_backend, G_TYPE_OBJECT) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
25 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
26 #define PKUI_BACKEND_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
27 PKUI_TYPE_BACKEND, PkuiBackendPrivate)) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
28 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
29 struct _PkuiBackendPrivate |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
30 { |
39 | 31 PkuiBackend *backend; |
32 PkClient *pk_client; | |
33 guint periodic_check_id; | |
34 guint updates_normal; | |
35 guint updates_important; | |
36 guint previous_updates_normal; | |
37 guint previous_updates_important; | |
38 guint startup_delay; | |
39 guint check_interval; | |
40 gint64 last_check; | |
41 gboolean inhibit_check; | |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
42 }; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
43 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
44 enum |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
45 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
46 PROP_0, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
47 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
48 PROP_UPDATES_NORMAL, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
49 PROP_UPDATES_IMPORTANT, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
50 PROP_STARTUP_DELAY, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
51 PROP_CHECK_INTERVAL, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
52 PROP_INHIBIT_CHECK |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
53 }; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
54 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
55 enum |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
56 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
57 STATE_CHANGED_SIGNAL, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
58 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
59 LAST_SIGNAL |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
60 }; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
61 |
26 | 62 static guint pkui_backend_signals[LAST_SIGNAL] = { 0 }; |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
63 |
39 | 64 static gboolean periodic_check(gpointer data); |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
65 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
66 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
67 pkui_backend_set_property(GObject *object, guint property_id, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
68 const GValue *value, GParamSpec *pspec) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
69 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
70 PkuiBackend *self = PKUI_BACKEND(object); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
71 gboolean inhibit_check; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
72 gint64 time_to_check; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
73 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
74 switch (property_id) { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
75 case PROP_STARTUP_DELAY: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
76 self->priv->startup_delay = g_value_get_uint(value); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
77 |
45
a29fbf0a7f6c
Prevent calling g_source_remove() on an invalid source ID
Guido Berhoerster <gber@opensuse.org>
parents:
39
diff
changeset
|
78 if (self->priv->periodic_check_id != 0) { |
a29fbf0a7f6c
Prevent calling g_source_remove() on an invalid source ID
Guido Berhoerster <gber@opensuse.org>
parents:
39
diff
changeset
|
79 g_source_remove(self->priv->periodic_check_id); |
a29fbf0a7f6c
Prevent calling g_source_remove() on an invalid source ID
Guido Berhoerster <gber@opensuse.org>
parents:
39
diff
changeset
|
80 } |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
81 self->priv->periodic_check_id = |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
82 g_timeout_add_seconds(self->priv->startup_delay, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
83 (GSourceFunc)periodic_check, self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
84 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
85 case PROP_CHECK_INTERVAL: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
86 self->priv->check_interval = g_value_get_uint(value); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
87 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
88 /* |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
89 * reschedule only if the first run has been completed and |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
90 * checks are currently not inibited, otherwise the new |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
91 * interval will be picked up anyway |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
92 */ |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
93 if (!self->priv->inhibit_check && self->priv->last_check > 0) { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
94 time_to_check = g_get_real_time() - |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
95 self->priv->last_check; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
96 if (time_to_check <= 0) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
97 pkui_backend_check_now(self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
98 else { |
45
a29fbf0a7f6c
Prevent calling g_source_remove() on an invalid source ID
Guido Berhoerster <gber@opensuse.org>
parents:
39
diff
changeset
|
99 if (self->priv->periodic_check_id != 0) { |
a29fbf0a7f6c
Prevent calling g_source_remove() on an invalid source ID
Guido Berhoerster <gber@opensuse.org>
parents:
39
diff
changeset
|
100 g_source_remove(self->priv->periodic_check_id); |
a29fbf0a7f6c
Prevent calling g_source_remove() on an invalid source ID
Guido Berhoerster <gber@opensuse.org>
parents:
39
diff
changeset
|
101 } |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
102 self->priv->periodic_check_id = |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
103 g_timeout_add_seconds(time_to_check, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
104 periodic_check, self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
105 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
106 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
107 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
108 case PROP_INHIBIT_CHECK: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
109 inhibit_check = g_value_get_boolean(value); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
110 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
111 /* |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
112 * when changing self->priv->inhibit_check from FALSE to TRUE |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
113 * and the first run has been completed remove the periodic |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
114 * check, when changing from TRUE to FALSE either trigger a run |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
115 * immediately when more time than self->priv->check_interval |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
116 * has passed or just reschedule the next check |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
117 */ |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
118 if (!self->priv->inhibit_check && inhibit_check && |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
119 self->priv->periodic_check_id != 0) { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
120 g_source_remove(self->priv->periodic_check_id); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
121 self->priv->periodic_check_id = 0; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
122 } else if (self->priv->inhibit_check && !inhibit_check) { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
123 self->priv->periodic_check_id = |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
124 g_timeout_add_seconds(self->priv->check_interval, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
125 (GSourceFunc)periodic_check, self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
126 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
127 self->priv->inhibit_check = inhibit_check; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
128 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
129 default: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
130 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
131 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
132 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
133 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
134 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
135 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
136 pkui_backend_get_property(GObject *object, guint property_id, GValue *value, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
137 GParamSpec *pspec) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
138 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
139 PkuiBackend *self = PKUI_BACKEND(object); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
140 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
141 switch (property_id) { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
142 case PROP_UPDATES_NORMAL: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
143 g_value_set_uint(value, self->priv->updates_normal); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
144 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
145 case PROP_UPDATES_IMPORTANT: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
146 g_value_set_uint(value, self->priv->updates_important); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
147 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
148 case PROP_STARTUP_DELAY: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
149 g_value_set_uint(value, self->priv->startup_delay); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
150 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
151 case PROP_CHECK_INTERVAL: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
152 g_value_set_uint(value, self->priv->check_interval); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
153 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
154 case PROP_INHIBIT_CHECK: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
155 g_value_set_boolean(value, self->priv->inhibit_check); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
156 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
157 default: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
158 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
159 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
160 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
161 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
162 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
163 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
164 pkui_backend_finalize(GObject *gobject) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
165 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
166 PkuiBackend *self = PKUI_BACKEND(gobject); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
167 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
168 if (self->priv->pk_client != NULL) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
169 g_object_unref(self->priv->pk_client); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
170 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
171 G_OBJECT_CLASS(pkui_backend_parent_class)->finalize(gobject); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
172 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
173 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
174 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
175 pkui_backend_class_init(PkuiBackendClass *klass) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
176 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
177 GObjectClass *gobject_class = G_OBJECT_CLASS(klass); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
178 GParamSpec *pspec; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
179 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
180 gobject_class->set_property = pkui_backend_set_property; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
181 gobject_class->get_property = pkui_backend_get_property; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
182 gobject_class->finalize = pkui_backend_finalize; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
183 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
184 pspec = g_param_spec_uint("updates-normal", "Normal updates", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
185 "Number of normal package updates", 0, G_MAXUINT, 0, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
186 G_PARAM_READABLE); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
187 g_object_class_install_property(gobject_class, PROP_UPDATES_NORMAL, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
188 pspec); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
189 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
190 pspec = g_param_spec_uint("updates-important", "Important updates", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
191 "Number of important package updates", 0, G_MAXUINT, 0, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
192 G_PARAM_READABLE); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
193 g_object_class_install_property(gobject_class, PROP_UPDATES_IMPORTANT, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
194 pspec); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
195 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
196 pspec = g_param_spec_uint("startup-delay", "Startup delay", |
26 | 197 "Initial delay in seconds before the first check for new package " |
27
ed1457a4e2c8
increase default startup-delay to 5 min (bnc#729230)
Guido Berhoerster <gber@opensuse.org>
parents:
26
diff
changeset
|
198 "updates", 0, G_MAXUINT, 300, |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
199 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
200 g_object_class_install_property(gobject_class, PROP_STARTUP_DELAY, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
201 pspec); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
202 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
203 pspec = g_param_spec_uint("check-interval", "Check interval", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
204 "Interval in seconds for checking for new package updates", 1, |
31
f549b75c3c22
increase the default update interval and delay before checking for updates
Guido Berhoerster <gber@opensuse.org>
parents:
27
diff
changeset
|
205 G_MAXUINT, 86400, G_PARAM_READWRITE | G_PARAM_CONSTRUCT); |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
206 g_object_class_install_property(gobject_class, PROP_CHECK_INTERVAL, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
207 pspec); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
208 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
209 pspec = g_param_spec_boolean("inhibit-check", "Inhibit check", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
210 "Whether to inhibit checks for new package updates", FALSE, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
211 G_PARAM_READWRITE); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
212 g_object_class_install_property(gobject_class, PROP_INHIBIT_CHECK, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
213 pspec); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
214 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
215 pkui_backend_signals[STATE_CHANGED_SIGNAL] = |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
216 g_signal_newv("state-changed", G_TYPE_FROM_CLASS(gobject_class), |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
217 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, NULL, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
218 NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
219 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
220 g_type_class_add_private(klass, sizeof (PkuiBackendPrivate)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
221 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
222 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
223 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
224 pkui_backend_init(PkuiBackend *self) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
225 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
226 self->priv = PKUI_BACKEND_GET_PRIVATE(self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
227 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
228 self->priv->pk_client = pk_client_new(); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
229 self->priv->updates_normal = 0; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
230 self->priv->updates_important = 0; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
231 self->priv->periodic_check_id = |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
232 g_timeout_add_seconds(self->priv->startup_delay, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
233 (GSourceFunc)periodic_check, self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
234 self->priv->last_check = 0; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
235 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
236 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
237 static gboolean |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
238 periodic_check(gpointer data) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
239 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
240 PkuiBackend *self = PKUI_BACKEND(data); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
241 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
242 pkui_backend_check_now(self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
243 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
244 /* rescheduling happens after results are available */ |
45
a29fbf0a7f6c
Prevent calling g_source_remove() on an invalid source ID
Guido Berhoerster <gber@opensuse.org>
parents:
39
diff
changeset
|
245 self->priv->periodic_check_id = 0; |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
246 return (FALSE); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
247 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
248 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
249 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
250 process_pk_package_info(PkPackage *pkg, gpointer *user_data) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
251 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
252 PkuiBackend *self = PKUI_BACKEND(user_data); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
253 PkInfoEnum type_info = pk_package_get_info(pkg); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
254 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
255 switch (type_info) { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
256 case PK_INFO_ENUM_LOW: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
257 case PK_INFO_ENUM_ENHANCEMENT: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
258 case PK_INFO_ENUM_NORMAL: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
259 self->priv->updates_normal++; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
260 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
261 case PK_INFO_ENUM_BUGFIX: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
262 case PK_INFO_ENUM_IMPORTANT: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
263 case PK_INFO_ENUM_SECURITY: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
264 self->priv->updates_important++; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
265 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
266 default: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
267 break; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
268 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
269 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
270 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
271 static void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
272 get_updates_finished(GObject *object, GAsyncResult *res, gpointer user_data) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
273 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
274 PkClient *client = PK_CLIENT(object); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
275 PkuiBackend *self = PKUI_BACKEND(user_data); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
276 PkResults *results = NULL; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
277 GError *error = NULL; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
278 GPtrArray *list = NULL; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
279 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
280 g_debug("PackageKit finished checking for updates"); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
281 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
282 results = pk_client_generic_finish(PK_CLIENT(client), res, &error); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
283 if (results == NULL) { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
284 g_warning("error: %s\n", error->message); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
285 g_error_free(error); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
286 goto out; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
287 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
288 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
289 list = pk_results_get_package_array(results); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
290 if (list == NULL) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
291 goto out; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
292 self->priv->previous_updates_normal = self->priv->updates_normal; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
293 self->priv->previous_updates_important = self->priv->updates_important; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
294 self->priv->updates_normal = 0; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
295 self->priv->updates_important = 0; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
296 g_ptr_array_foreach(list, (GFunc)process_pk_package_info, self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
297 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
298 if (self->priv->updates_normal != self->priv->previous_updates_normal || |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
299 self->priv->updates_important != |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
300 self->priv->previous_updates_important) { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
301 g_debug("normal updates: %d, important updates: %d", |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
302 self->priv->updates_normal, self->priv->updates_important); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
303 g_debug("emit state-changed"); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
304 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
305 g_signal_emit(self, pkui_backend_signals[STATE_CHANGED_SIGNAL], |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
306 0); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
307 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
308 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
309 out: |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
310 if (results != NULL) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
311 g_object_unref(results); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
312 if (list != NULL) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
313 g_ptr_array_unref(list); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
314 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
315 self->priv->last_check = g_get_real_time(); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
316 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
317 if (!self->priv->inhibit_check) { |
45
a29fbf0a7f6c
Prevent calling g_source_remove() on an invalid source ID
Guido Berhoerster <gber@opensuse.org>
parents:
39
diff
changeset
|
318 if (self->priv->periodic_check_id != 0) { |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
319 g_source_remove(self->priv->periodic_check_id); |
45
a29fbf0a7f6c
Prevent calling g_source_remove() on an invalid source ID
Guido Berhoerster <gber@opensuse.org>
parents:
39
diff
changeset
|
320 } |
14
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
321 self->priv->periodic_check_id = |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
322 g_timeout_add_seconds(self->priv->check_interval, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
323 (GSourceFunc)periodic_check, self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
324 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
325 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
326 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
327 PkuiBackend * |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
328 pkui_backend_new(guint startup_delay, guint check_interval) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
329 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
330 g_return_val_if_fail(check_interval > 0, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
331 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
332 return (g_object_new(PKUI_TYPE_BACKEND, "startup-delay", startup_delay, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
333 "check-interval", check_interval, NULL)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
334 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
335 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
336 guint |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
337 pkui_backend_get_updates_normal(PkuiBackend *self) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
338 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
339 guint updates_normal; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
340 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
341 g_return_val_if_fail(PKUI_IS_BACKEND(self), 0); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
342 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
343 g_object_get(G_OBJECT(self), "updates-normal", &updates_normal, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
344 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
345 return (updates_normal); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
346 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
347 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
348 guint |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
349 pkui_backend_get_updates_important(PkuiBackend *self) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
350 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
351 guint updates_important; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
352 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
353 g_return_val_if_fail(PKUI_IS_BACKEND(self), 0); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
354 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
355 g_object_get(G_OBJECT(self), "updates-important", &updates_important, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
356 NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
357 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
358 return (updates_important); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
359 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
360 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
361 void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
362 pkui_backend_set_inhibit_check(PkuiBackend *self, gboolean inhibit_check) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
363 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
364 g_return_if_fail(PKUI_IS_BACKEND(self)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
365 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
366 g_object_set(G_OBJECT(self), "inhibit-check", inhibit_check, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
367 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
368 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
369 gboolean |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
370 pkui_backend_get_inhibit_check(PkuiBackend *self) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
371 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
372 gboolean inhibit_check; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
373 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
374 g_return_val_if_fail(PKUI_IS_BACKEND(self), FALSE); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
375 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
376 g_object_get(G_OBJECT(self), "inhibit-check", &inhibit_check, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
377 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
378 return (inhibit_check); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
379 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
380 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
381 guint |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
382 pkui_backend_get_startup_interval(PkuiBackend *self) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
383 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
384 guint startup_interval; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
385 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
386 g_return_val_if_fail(PKUI_IS_BACKEND(self), 0); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
387 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
388 g_object_get(G_OBJECT(self), "startup-interval", &startup_interval, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
389 NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
390 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
391 return (startup_interval); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
392 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
393 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
394 void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
395 pkui_backend_set_check_interval(PkuiBackend *self, guint check_interval) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
396 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
397 g_return_if_fail(PKUI_IS_BACKEND(self)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
398 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
399 g_object_set(G_OBJECT(self), "check-interval", check_interval, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
400 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
401 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
402 guint |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
403 pkui_backend_get_check_interval(PkuiBackend *self) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
404 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
405 guint check_interval; |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
406 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
407 g_return_val_if_fail(PKUI_IS_BACKEND(self), 0); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
408 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
409 g_object_get(G_OBJECT(self), "check-interval", &check_interval, NULL); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
410 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
411 return (check_interval); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
412 } |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
413 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
414 void |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
415 pkui_backend_check_now(PkuiBackend *self) |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
416 { |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
417 g_return_if_fail(PKUI_IS_BACKEND(self)); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
418 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
419 g_debug("querying PackageKit for updates"); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
420 |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
421 pk_client_get_updates_async(self->priv->pk_client, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
422 pk_bitfield_value(PK_FILTER_ENUM_NONE), NULL, NULL, NULL, |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
423 get_updates_finished, self); |
64f05992d8ec
GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff
changeset
|
424 } |