annotate pkui-backend.c @ 58:017b0a4b6ec5 version-3

Release version 3
author Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
date Mon, 02 Jul 2018 13:25:11 +0200
parents 63347002d746
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
1 /*
53
7de92a24e86c Update email address
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 45
diff changeset
2 * (C) 2011 Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
14
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
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
31 PkuiBackend *backend;
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
32 PkClient *pk_client;
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
33 guint periodic_check_id;
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
34 guint updates_normal;
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
35 guint updates_important;
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
36 guint previous_updates_normal;
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
37 guint previous_updates_important;
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
38 guint startup_delay;
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
39 guint check_interval;
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
40 gint64 last_check;
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
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
a8d8fba520ec fix some typos
Guido Berhoerster <gber@opensuse.org>
parents: 14
diff changeset
62 static guint pkui_backend_signals[LAST_SIGNAL] = { 0 };
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
63
39
f6edbee6441f Stylistic fixes
Guido Berhoerster <gber@opensuse.org>
parents: 31
diff changeset
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 case PROP_CHECK_INTERVAL:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
78 self->priv->check_interval = g_value_get_uint(value);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
79 break;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
80 case PROP_INHIBIT_CHECK:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
81 inhibit_check = g_value_get_boolean(value);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
82
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
83 /*
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
84 * when changing self->priv->inhibit_check from FALSE to TRUE
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
85 * and the first run has been completed remove the periodic
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
86 * check, when changing from TRUE to FALSE either trigger a run
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
87 * immediately when more time than self->priv->check_interval
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
88 * has passed or just reschedule the next check
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
89 */
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
90 if (!self->priv->inhibit_check && inhibit_check &&
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
91 self->priv->periodic_check_id != 0) {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
92 g_source_remove(self->priv->periodic_check_id);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
93 self->priv->periodic_check_id = 0;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
94 } else if (self->priv->inhibit_check && !inhibit_check) {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
95 self->priv->periodic_check_id =
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
96 g_timeout_add_seconds(self->priv->check_interval,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
97 (GSourceFunc)periodic_check, self);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
98 }
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
99 self->priv->inhibit_check = inhibit_check;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
100 break;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
101 default:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
102 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
103 break;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
104 }
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 static void
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
108 pkui_backend_get_property(GObject *object, guint property_id, GValue *value,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
109 GParamSpec *pspec)
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 PkuiBackend *self = PKUI_BACKEND(object);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
112
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
113 switch (property_id) {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
114 case PROP_UPDATES_NORMAL:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
115 g_value_set_uint(value, self->priv->updates_normal);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
116 break;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
117 case PROP_UPDATES_IMPORTANT:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
118 g_value_set_uint(value, self->priv->updates_important);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
119 break;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
120 case PROP_STARTUP_DELAY:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
121 g_value_set_uint(value, self->priv->startup_delay);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
122 break;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
123 case PROP_CHECK_INTERVAL:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
124 g_value_set_uint(value, self->priv->check_interval);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
125 break;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
126 case PROP_INHIBIT_CHECK:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
127 g_value_set_boolean(value, self->priv->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
56
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
136 pkui_backend_constructed(GObject *gobject)
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
137 {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
138 PkuiBackend *self = PKUI_BACKEND(gobject);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
139
56
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
140 self->priv->periodic_check_id =
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
141 g_timeout_add_seconds(self->priv->startup_delay,
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
142 (GSourceFunc)periodic_check, self);
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
143 }
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
144
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
145 static void
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
146 pkui_backend_dispose(GObject *gobject)
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
147 {
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
148 PkuiBackend *self = PKUI_BACKEND(gobject);
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
149
56
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
150 if (self->priv->pk_client != NULL) {
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
151 g_clear_object(&self->priv->pk_client);
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
152 }
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
153
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
154 if (self->priv->periodic_check_id != 0) {
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
155 g_source_remove(self->priv->periodic_check_id);
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
156 self->priv->periodic_check_id = 0;
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
157 }
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
158
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
159 G_OBJECT_CLASS(pkui_backend_parent_class)->dispose(gobject);
14
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 static void
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
163 pkui_backend_class_init(PkuiBackendClass *klass)
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
164 {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
165 GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
166 GParamSpec *pspec;
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 gobject_class->set_property = pkui_backend_set_property;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
169 gobject_class->get_property = pkui_backend_get_property;
56
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
170 gobject_class->constructed = pkui_backend_constructed;
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
171 gobject_class->dispose = pkui_backend_dispose;
14
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 pspec = g_param_spec_uint("updates-normal", "Normal updates",
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
174 "Number of normal package updates", 0, G_MAXUINT, 0,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
175 G_PARAM_READABLE);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
176 g_object_class_install_property(gobject_class, PROP_UPDATES_NORMAL,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
177 pspec);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
178
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
179 pspec = g_param_spec_uint("updates-important", "Important updates",
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
180 "Number of important package updates", 0, G_MAXUINT, 0,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
181 G_PARAM_READABLE);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
182 g_object_class_install_property(gobject_class, PROP_UPDATES_IMPORTANT,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
183 pspec);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
184
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
185 pspec = g_param_spec_uint("startup-delay", "Startup delay",
26
a8d8fba520ec fix some typos
Guido Berhoerster <gber@opensuse.org>
parents: 14
diff changeset
186 "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
187 "updates", 0, G_MAXUINT, 300,
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
188 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
189 g_object_class_install_property(gobject_class, PROP_STARTUP_DELAY,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
190 pspec);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
191
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
192 pspec = g_param_spec_uint("check-interval", "Check interval",
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
193 "Interval in seconds for checking for new package updates", 1,
56
63347002d746 Simplify PkuiBackend
Guido Berhoerster <guido+pk-update-icon@berhoerster.name>
parents: 53
diff changeset
194 G_MAXUINT, 86400, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
195 g_object_class_install_property(gobject_class, PROP_CHECK_INTERVAL,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
196 pspec);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
197
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
198 pspec = g_param_spec_boolean("inhibit-check", "Inhibit check",
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
199 "Whether to inhibit checks for new package updates", FALSE,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
200 G_PARAM_READWRITE);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
201 g_object_class_install_property(gobject_class, PROP_INHIBIT_CHECK,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
202 pspec);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
203
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
204 pkui_backend_signals[STATE_CHANGED_SIGNAL] =
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
205 g_signal_newv("state-changed", G_TYPE_FROM_CLASS(gobject_class),
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
206 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
207 NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0, NULL);
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 g_type_class_add_private(klass, sizeof (PkuiBackendPrivate));
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
210 }
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
211
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
212 static void
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
213 pkui_backend_init(PkuiBackend *self)
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 self->priv = PKUI_BACKEND_GET_PRIVATE(self);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
216
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
217 self->priv->pk_client = pk_client_new();
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
218 }
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 static gboolean
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
221 periodic_check(gpointer data)
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 PkuiBackend *self = PKUI_BACKEND(data);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
224
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
225 pkui_backend_check_now(self);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
226
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
227 /* 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
228 self->priv->periodic_check_id = 0;
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
229 return (FALSE);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
230 }
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
231
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
232 static void
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
233 process_pk_package_info(PkPackage *pkg, gpointer *user_data)
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
234 {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
235 PkuiBackend *self = PKUI_BACKEND(user_data);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
236 PkInfoEnum type_info = pk_package_get_info(pkg);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
237
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
238 switch (type_info) {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
239 case PK_INFO_ENUM_LOW:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
240 case PK_INFO_ENUM_ENHANCEMENT:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
241 case PK_INFO_ENUM_NORMAL:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
242 self->priv->updates_normal++;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
243 break;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
244 case PK_INFO_ENUM_BUGFIX:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
245 case PK_INFO_ENUM_IMPORTANT:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
246 case PK_INFO_ENUM_SECURITY:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
247 self->priv->updates_important++;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
248 break;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
249 default:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
250 break;
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 }
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
253
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
254 static void
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
255 get_updates_finished(GObject *object, GAsyncResult *res, gpointer user_data)
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
256 {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
257 PkClient *client = PK_CLIENT(object);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
258 PkuiBackend *self = PKUI_BACKEND(user_data);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
259 PkResults *results = NULL;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
260 GError *error = NULL;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
261 GPtrArray *list = NULL;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
262
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
263 g_debug("PackageKit finished checking for updates");
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
264
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
265 results = pk_client_generic_finish(PK_CLIENT(client), res, &error);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
266 if (results == NULL) {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
267 g_warning("error: %s\n", error->message);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
268 g_error_free(error);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
269 goto out;
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
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
272 list = pk_results_get_package_array(results);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
273 if (list == NULL)
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
274 goto out;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
275 self->priv->previous_updates_normal = self->priv->updates_normal;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
276 self->priv->previous_updates_important = self->priv->updates_important;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
277 self->priv->updates_normal = 0;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
278 self->priv->updates_important = 0;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
279 g_ptr_array_foreach(list, (GFunc)process_pk_package_info, self);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
280
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
281 if (self->priv->updates_normal != self->priv->previous_updates_normal ||
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
282 self->priv->updates_important !=
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
283 self->priv->previous_updates_important) {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
284 g_debug("normal updates: %d, important updates: %d",
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
285 self->priv->updates_normal, self->priv->updates_important);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
286 g_debug("emit state-changed");
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 g_signal_emit(self, pkui_backend_signals[STATE_CHANGED_SIGNAL],
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
289 0);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
290 }
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
291
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
292 out:
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
293 if (results != NULL)
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
294 g_object_unref(results);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
295 if (list != NULL)
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
296 g_ptr_array_unref(list);
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 self->priv->last_check = g_get_real_time();
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
299
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
300 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
301 if (self->priv->periodic_check_id != 0) {
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
302 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
303 }
14
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
304 self->priv->periodic_check_id =
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
305 g_timeout_add_seconds(self->priv->check_interval,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
306 (GSourceFunc)periodic_check, self);
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
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
310 PkuiBackend *
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
311 pkui_backend_new(guint startup_delay, guint check_interval)
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
312 {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
313 g_return_val_if_fail(check_interval > 0, NULL);
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 return (g_object_new(PKUI_TYPE_BACKEND, "startup-delay", startup_delay,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
316 "check-interval", check_interval, NULL));
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
317 }
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
318
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
319 guint
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
320 pkui_backend_get_updates_normal(PkuiBackend *self)
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
321 {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
322 guint updates_normal;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
323
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
324 g_return_val_if_fail(PKUI_IS_BACKEND(self), 0);
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 g_object_get(G_OBJECT(self), "updates-normal", &updates_normal, NULL);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
327
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
328 return (updates_normal);
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
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
331 guint
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
332 pkui_backend_get_updates_important(PkuiBackend *self)
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
333 {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
334 guint updates_important;
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 g_return_val_if_fail(PKUI_IS_BACKEND(self), 0);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
337
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
338 g_object_get(G_OBJECT(self), "updates-important", &updates_important,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
339 NULL);
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 return (updates_important);
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
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
344 void
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
345 pkui_backend_set_inhibit_check(PkuiBackend *self, gboolean inhibit_check)
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 g_return_if_fail(PKUI_IS_BACKEND(self));
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
348
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
349 g_object_set(G_OBJECT(self), "inhibit-check", inhibit_check, NULL);
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
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
352 gboolean
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
353 pkui_backend_get_inhibit_check(PkuiBackend *self)
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 gboolean inhibit_check;
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
356
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
357 g_return_val_if_fail(PKUI_IS_BACKEND(self), FALSE);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
358
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
359 g_object_get(G_OBJECT(self), "inhibit-check", &inhibit_check, NULL);
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 return (inhibit_check);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
362 }
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 void
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
365 pkui_backend_check_now(PkuiBackend *self)
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
366 {
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
367 g_return_if_fail(PKUI_IS_BACKEND(self));
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 g_debug("querying PackageKit for updates");
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
370
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
371 pk_client_get_updates_async(self->priv->pk_client,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
372 pk_bitfield_value(PK_FILTER_ENUM_NONE), NULL, NULL, NULL,
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
373 get_updates_finished, self);
64f05992d8ec GObject-based rewrite
Guido Berhoerster <guido@berhoerster.name>
parents:
diff changeset
374 }