Mercurial > projects > package-update-indicator
annotate pui-backend.c @ 32:b9c65915cc54
Reduce delay before checking for updates after an "updates-changed" signal
author | Guido Berhoerster <guido+pui@berhoerster.name> |
---|---|
date | Thu, 29 Aug 2019 17:41:06 +0200 |
parents | 9905d4ae351c |
children | 4a859595eabd |
rev | line source |
---|---|
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
1 /* |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
2 * Copyright (C) 2018 Guido Berhoerster <guido+pui@berhoerster.name> |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
3 * |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
4 * Permission is hereby granted, free of charge, to any person obtaining |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
5 * a copy of this software and associated documentation files (the |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
6 * "Software"), to deal in the Software without restriction, including |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
7 * without limitation the rights to use, copy, modify, merge, publish, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
8 * distribute, sublicense, and/or sell copies of the Software, and to |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
9 * permit persons to whom the Software is furnished to do so, subject to |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
10 * the following conditions: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
11 * |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
12 * The above copyright notice and this permission notice shall be included |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
13 * in all copies or substantial portions of the Software. |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
14 * |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
22 */ |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
23 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
24 #include <errno.h> |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
25 #include <fcntl.h> |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
26 #include <packagekit-glib2/packagekit.h> |
6
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
27 #include <polkit/polkit.h> |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
28 #include <string.h> |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
29 #include <sys/stat.h> |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
30 #include <sys/types.h> |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
31 #include <upower.h> |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
32 #include <utime.h> |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
33 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
34 #include "pui-common.h" |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
35 #include "pui-backend.h" |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
36 #include "pui-get-updates.h" |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
37 #include "pui-types.h" |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
38 |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
39 #define LOW_BATTERY_THRESHOLD 10.0 /* % */ |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
40 #define UPDATES_CHANGED_UNBLOCK_DELAY 4 /* s */ |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
41 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
42 struct _PuiBackend { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
43 GObject parent_instance; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
44 PkControl *pk_control; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
45 GCancellable *cancellable; |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
46 PkClient *pk_client; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
47 PkTransactionList *transaction_list; |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
48 UpClient *up_client; |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
49 UpDevice *up_device; |
6
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
50 gchar *proxy_http; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
51 gchar *proxy_https; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
52 gchar *proxy_ftp; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
53 gchar *proxy_socks; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
54 gchar *no_proxy; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
55 gchar *pac; |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
56 gint64 last_check; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
57 PkNetworkEnum network_state; |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
58 gboolean inhibited; |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
59 gboolean is_battery_low; |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
60 guint check_id; |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
61 guint unblock_updates_changed_id; |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
62 guint refresh_interval; |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
63 gboolean use_mobile_connection; |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
64 guint important_updates; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
65 guint normal_updates; |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
66 PuiRestart restart_type; |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
67 }; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
68 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
69 static void pui_backend_async_initable_iface_init(gpointer, gpointer); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
70 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
71 G_DEFINE_TYPE_WITH_CODE(PuiBackend, pui_backend, G_TYPE_OBJECT, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
72 G_IMPLEMENT_INTERFACE(G_TYPE_ASYNC_INITABLE, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
73 pui_backend_async_initable_iface_init)) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
74 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
75 enum { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
76 STATE_CHANGED, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
77 RESTART_REQUIRED, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
78 SIGNAL_LAST |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
79 }; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
80 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
81 enum { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
82 PROP_0, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
83 PROP_IMPORTANT_UPDATES, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
84 PROP_NORMAL_UPDATES, |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
85 PROP_RESTART_TYPE, |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
86 PROP_REFRESH_INTERVAL, |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
87 PROP_USE_MOBILE_CONNECTION, |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
88 PROP_LAST |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
89 }; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
90 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
91 static guint signals[SIGNAL_LAST] = { 0 }; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
92 static GParamSpec *properties[PROP_LAST] = { NULL }; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
93 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
94 static gboolean periodic_check(gpointer); |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
95 static void on_updates_changed(PkControl *, gpointer); |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
96 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
97 GQuark |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
98 pui_backend_error_quark(void) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
99 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
100 return (g_quark_from_static_string("pui-backend-error-quark")); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
101 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
102 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
103 static void |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
104 process_pk_package(gpointer data, gpointer user_data) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
105 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
106 PkPackage *package = data; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
107 PuiBackend *self = user_data; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
108 PkInfoEnum type_info = pk_package_get_info(package); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
109 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
110 switch (type_info) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
111 case PK_INFO_ENUM_LOW: /* FALLTHROUGH */ |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
112 case PK_INFO_ENUM_ENHANCEMENT: /* FALLTHROUGH */ |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
113 case PK_INFO_ENUM_NORMAL: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
114 self->normal_updates++; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
115 break; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
116 case PK_INFO_ENUM_BUGFIX: /* FALLTHROUGH */ |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
117 case PK_INFO_ENUM_IMPORTANT: /* FALLTHROUGH */ |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
118 case PK_INFO_ENUM_SECURITY: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
119 self->important_updates++; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
120 break; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
121 default: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
122 break; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
123 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
124 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
125 |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
126 static gboolean |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
127 unblock_updates_changed(gpointer user_data) |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
128 { |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
129 PuiBackend *self = user_data; |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
130 |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
131 g_signal_handlers_unblock_by_func(self->pk_control, on_updates_changed, |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
132 self); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
133 self->unblock_updates_changed_id = 0; |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
134 |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
135 return (G_SOURCE_REMOVE); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
136 } |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
137 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
138 static void |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
139 on_get_updates_finished(GObject *source_object, GAsyncResult *async_result, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
140 gpointer user_data) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
141 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
142 PuiBackend *self = user_data; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
143 GPtrArray *package_list = NULL; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
144 GError *error = NULL; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
145 guint prev_normal_updates = self->normal_updates; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
146 guint prev_important_updates = self->important_updates; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
147 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
148 package_list = pui_get_updates_finish(async_result, &error); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
149 if (package_list == NULL) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
150 if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED) || |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
151 g_error_matches(error, PUI_GET_UPDATES_ERROR, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
152 PUI_GET_UPDATES_ERROR_CANCELLED)) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
153 /* cancelled */ |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
154 g_debug("cancelled checking for updates"); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
155 } else { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
156 g_warning("failed to check for updates: %s", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
157 error->message); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
158 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
159 g_error_free(error); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
160 goto out; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
161 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
162 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
163 self->normal_updates = 0; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
164 self->important_updates = 0; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
165 g_ptr_array_foreach(package_list, process_pk_package, self); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
166 g_debug("normal updates: %u, important updates: %u", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
167 self->normal_updates, self->important_updates); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
168 if (self->normal_updates != prev_normal_updates) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
169 g_object_notify_by_pspec(G_OBJECT(self), |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
170 properties[PROP_NORMAL_UPDATES]); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
171 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
172 if (self->important_updates != prev_important_updates) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
173 g_object_notify_by_pspec(G_OBJECT(self), |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
174 properties[PROP_IMPORTANT_UPDATES]); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
175 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
176 if ((self->normal_updates != prev_normal_updates) || |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
177 (self->important_updates != prev_important_updates)) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
178 g_debug("emitting signal state-changed"); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
179 g_signal_emit(self, signals[STATE_CHANGED], 0); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
180 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
181 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
182 /* last successful check */ |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
183 self->last_check = g_get_monotonic_time(); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
184 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
185 out: |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
186 g_clear_object(&self->cancellable); |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
187 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
188 /* reschedule periodic check */ |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
189 if (!self->inhibited) { |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
190 self->check_id = |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
191 g_timeout_add_seconds(PUI_CHECK_UPDATES_INTERVAL, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
192 periodic_check, self); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
193 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
194 |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
195 /* handle get-updates signals again after a short delay */ |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
196 self->unblock_updates_changed_id = |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
197 g_timeout_add_seconds(UPDATES_CHANGED_UNBLOCK_DELAY, |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
198 unblock_updates_changed, self); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
199 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
200 if (package_list != NULL) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
201 g_ptr_array_unref(package_list); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
202 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
203 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
204 |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
205 static void |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
206 run_check(PuiBackend *self, gboolean refresh_cache) |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
207 { |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
208 /* block any get-updates signals emitted when refreshing the cache */ |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
209 if (self->unblock_updates_changed_id != 0) { |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
210 /* still blocked */ |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
211 g_source_remove(self->unblock_updates_changed_id); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
212 self->unblock_updates_changed_id = 0; |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
213 } else { |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
214 g_signal_handlers_block_by_func(self->pk_control, |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
215 G_CALLBACK(on_updates_changed), self); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
216 } |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
217 |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
218 self->cancellable = g_cancellable_new(); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
219 pui_get_updates_async(self->pk_control, |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
220 refresh_cache ? self->refresh_interval : G_MAXUINT, |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
221 self->cancellable, on_get_updates_finished, self); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
222 |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
223 /* next periodic check will be scheduled after completion */ |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
224 self->check_id = 0; |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
225 } |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
226 |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
227 static gboolean |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
228 irregular_check(gpointer user_data) |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
229 { |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
230 PuiBackend *self = user_data; |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
231 |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
232 g_debug("running check"); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
233 |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
234 run_check(self, FALSE); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
235 |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
236 return (G_SOURCE_REMOVE); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
237 } |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
238 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
239 static gboolean |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
240 periodic_check(gpointer user_data) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
241 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
242 PuiBackend *self = user_data; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
243 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
244 g_debug("running periodic check"); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
245 |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
246 run_check(self, TRUE); |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
247 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
248 return (G_SOURCE_REMOVE); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
249 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
250 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
251 static void |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
252 check_inhibit(PuiBackend *self) |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
253 { |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
254 gboolean inhibited; |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
255 guint elapsed_time; |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
256 guint remaining_time; |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
257 |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
258 inhibited = ((self->network_state == PK_NETWORK_ENUM_OFFLINE) || |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
259 (!self->use_mobile_connection && |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
260 (self->network_state == PK_NETWORK_ENUM_MOBILE)) || |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
261 self->is_battery_low); |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
262 if (self->inhibited == inhibited) { |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
263 return; |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
264 } |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
265 |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
266 self->inhibited = inhibited; |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
267 if (inhibited) { |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
268 /* cancel periodic checks */ |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
269 if (self->check_id != 0) { |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
270 g_source_remove(self->check_id); |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
271 } |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
272 |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
273 /* cancel running operation */ |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
274 if ((self->cancellable != NULL) && |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
275 !g_cancellable_is_cancelled(self->cancellable)) { |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
276 g_cancellable_cancel(self->cancellable); |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
277 g_clear_object(&self->cancellable); |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
278 } |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
279 } else { |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
280 /* schedule periodic checks when no longer inhibited */ |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
281 elapsed_time = (g_get_monotonic_time() - self->last_check) / |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
282 G_USEC_PER_SEC; |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
283 /* |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
284 * if more time that the check interval has passed since the |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
285 * last check, schedule a check after a short delay, otherwise |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
286 * wait until the interval has passed |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
287 */ |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
288 remaining_time = (elapsed_time < PUI_CHECK_UPDATES_INTERVAL) ? |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
289 PUI_CHECK_UPDATES_INTERVAL - elapsed_time : |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
290 PUI_STARTUP_DELAY; |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
291 self->check_id = g_timeout_add_seconds(remaining_time, |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
292 periodic_check, self); |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
293 } |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
294 } |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
295 |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
296 static void |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
297 pui_backend_set_property(GObject *object, guint property_id, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
298 const GValue *value, GParamSpec *pspec) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
299 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
300 PuiBackend *self = PUI_BACKEND(object); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
301 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
302 switch (property_id) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
303 case PROP_REFRESH_INTERVAL: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
304 self->refresh_interval = g_value_get_uint(value); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
305 g_debug("property \"refresh-interval\" set to %u", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
306 self->refresh_interval); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
307 break; |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
308 case PROP_USE_MOBILE_CONNECTION: |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
309 self->use_mobile_connection = g_value_get_boolean(value); |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
310 g_debug("property \"use-mobile-connection\" set to %s", |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
311 self->use_mobile_connection ? "true" : "false"); |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
312 check_inhibit(self); |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
313 break; |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
314 default: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
315 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
316 break; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
317 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
318 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
319 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
320 static void |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
321 pui_backend_get_property(GObject *object, guint property_id, GValue *value, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
322 GParamSpec *pspec) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
323 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
324 PuiBackend *self = PUI_BACKEND(object); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
325 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
326 switch (property_id) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
327 case PROP_IMPORTANT_UPDATES: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
328 g_value_set_uint(value, self->important_updates); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
329 break; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
330 case PROP_NORMAL_UPDATES: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
331 g_value_set_uint(value, self->normal_updates); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
332 break; |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
333 case PROP_RESTART_TYPE: |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
334 g_value_set_enum(value, self->restart_type); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
335 break; |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
336 case PROP_REFRESH_INTERVAL: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
337 g_value_set_uint(value, self->refresh_interval); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
338 break; |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
339 case PROP_USE_MOBILE_CONNECTION: |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
340 g_value_set_boolean(value, self->use_mobile_connection); |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
341 break; |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
342 default: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
343 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
344 break; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
345 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
346 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
347 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
348 static void |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
349 pui_backend_dispose(GObject *object) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
350 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
351 PuiBackend *self = PUI_BACKEND(object); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
352 |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
353 if (self->check_id != 0) { |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
354 g_source_remove(self->check_id); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
355 self->check_id = 0; |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
356 } |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
357 |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
358 if (self->unblock_updates_changed_id != 0) { |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
359 g_source_remove(self->unblock_updates_changed_id); |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
360 self->unblock_updates_changed_id = 0; |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
361 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
362 |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
363 if (self->transaction_list != NULL) { |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
364 g_clear_object(&self->transaction_list); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
365 } |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
366 |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
367 if (self->pk_client != NULL) { |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
368 g_clear_object(&self->pk_client); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
369 } |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
370 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
371 if (self->cancellable != NULL) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
372 g_cancellable_cancel(self->cancellable); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
373 g_clear_object(&self->cancellable); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
374 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
375 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
376 if (self->pk_control != NULL) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
377 g_clear_object(&self->pk_control); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
378 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
379 |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
380 if (self->up_device != NULL) { |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
381 g_clear_object(&self->up_device); |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
382 } |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
383 |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
384 if (self->up_client != NULL) { |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
385 g_clear_object(&self->up_client); |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
386 } |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
387 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
388 G_OBJECT_CLASS(pui_backend_parent_class)->dispose(object); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
389 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
390 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
391 static void |
6
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
392 pui_backend_finalize(GObject *object) |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
393 { |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
394 PuiBackend *self = PUI_BACKEND(object); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
395 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
396 g_free(self->proxy_http); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
397 g_free(self->proxy_https); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
398 g_free(self->proxy_ftp); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
399 g_free(self->proxy_socks); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
400 g_free(self->no_proxy); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
401 g_free(self->pac); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
402 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
403 G_OBJECT_CLASS(pui_backend_parent_class)->finalize(object); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
404 } |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
405 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
406 static void |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
407 pui_backend_class_init(PuiBackendClass *klass) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
408 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
409 GObjectClass *object_class = G_OBJECT_CLASS(klass); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
410 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
411 object_class->set_property = pui_backend_set_property; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
412 object_class->get_property = pui_backend_get_property; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
413 object_class->dispose = pui_backend_dispose; |
6
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
414 object_class->finalize = pui_backend_finalize; |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
415 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
416 properties[PROP_IMPORTANT_UPDATES] = |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
417 g_param_spec_uint("important-updates", "Important updates", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
418 "Number of available important updates", 0, G_MAXUINT, 0, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
419 G_PARAM_READABLE); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
420 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
421 properties[PROP_NORMAL_UPDATES] = |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
422 g_param_spec_uint("normal-updates", "Normal updates", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
423 "Number of available normal updates", 0, G_MAXUINT, 0, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
424 G_PARAM_READABLE); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
425 |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
426 properties[PROP_RESTART_TYPE] = |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
427 g_param_spec_enum("restart-type", "Type of restart required", |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
428 "The Type of restart required", PUI_TYPE_RESTART, PUI_RESTART_NONE, |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
429 G_PARAM_READABLE); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
430 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
431 properties[PROP_REFRESH_INTERVAL] = |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
432 g_param_spec_uint("refresh-interval", "Refresh interval", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
433 "Interval in seconds for refreshing the package cache", 0, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
434 G_MAXUINT, PUI_DEFAULT_REFRESH_INTERVAL, G_PARAM_READWRITE); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
435 |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
436 properties[PROP_USE_MOBILE_CONNECTION] = |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
437 g_param_spec_boolean("use-mobile-connection", |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
438 "Whether to use a mobile connection", "Whether to use a mobile " |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
439 "connection for refreshing the package cache", FALSE, |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
440 G_PARAM_READWRITE); |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
441 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
442 g_object_class_install_properties(object_class, PROP_LAST, properties); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
443 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
444 signals[STATE_CHANGED] = g_signal_new("state-changed", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
445 G_TYPE_FROM_CLASS(object_class), |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
446 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
447 NULL, NULL, NULL, G_TYPE_NONE, 0); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
448 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
449 signals[RESTART_REQUIRED] = g_signal_new("restart-required", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
450 G_TYPE_FROM_CLASS(object_class), |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
451 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
452 NULL, NULL, NULL, G_TYPE_NONE, 0); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
453 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
454 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
455 static void |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
456 pui_backend_init(PuiBackend *self) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
457 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
458 self->pk_control = pk_control_new(); |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
459 |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
460 self->pk_client = pk_client_new(); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
461 |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
462 self->inhibited = TRUE; |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
463 |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
464 self->up_client = up_client_new(); |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
465 if (self->up_client) { |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
466 self->up_device = up_client_get_display_device(self->up_client); |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
467 } |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
468 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
469 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
470 static void |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
471 on_get_properties_finished(GObject *object, GAsyncResult *result, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
472 gpointer user_data) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
473 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
474 PkControl *control = PK_CONTROL(object); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
475 PuiBackend *self; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
476 GTask *task = user_data; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
477 GError *error = NULL; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
478 gchar *backend_name = NULL; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
479 PkBitfield roles = 0; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
480 gchar *roles_str = NULL; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
481 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
482 self = g_task_get_task_data(task); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
483 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
484 if (!pk_control_get_properties_finish(control, result, &error)) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
485 g_task_return_error(task, error); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
486 goto out; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
487 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
488 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
489 /* check whether the backend supports GetUpdates */ |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
490 g_object_get(control, "backend-name", &backend_name, "roles", &roles, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
491 "network-state", &self->network_state, NULL); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
492 g_debug("backend: %s", backend_name); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
493 roles_str = pk_role_bitfield_to_string(roles); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
494 g_debug("roles: %s", roles_str); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
495 g_debug("network-state: %s", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
496 pk_network_enum_to_string(self->network_state)); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
497 if (!pk_bitfield_contain(roles, PK_ROLE_ENUM_GET_UPDATES)) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
498 error = g_error_new(PUI_BACKEND_ERROR, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
499 PUI_BACKEND_ERROR_GET_UPDATES_NOT_IMPLEMENTED, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
500 "Getting updates is not implemented in the %s PackageKit " |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
501 "backend", backend_name); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
502 g_task_return_error(task, error); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
503 goto out; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
504 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
505 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
506 g_task_return_boolean(task, TRUE); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
507 out: |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
508 g_free(roles_str); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
509 g_free(backend_name); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
510 g_object_unref(task); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
511 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
512 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
513 static void |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
514 on_notify_device_charge_percentage(UpDevice *device, GParamSpec *pspec, |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
515 gpointer user_data) |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
516 { |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
517 PuiBackend *self = user_data; |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
518 UpDeviceKind kind; |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
519 gdouble percentage; |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
520 |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
521 g_object_get(device, "kind", &kind, "percentage", &percentage, NULL); |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
522 if ((kind != UP_DEVICE_KIND_BATTERY) && (kind != UP_DEVICE_KIND_UPS)) { |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
523 return; |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
524 } |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
525 g_debug("charge percentage changed: %.0f%%\n", percentage); |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
526 if ((self->is_battery_low && (percentage > LOW_BATTERY_THRESHOLD)) || |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
527 (!self->is_battery_low && (percentage < LOW_BATTERY_THRESHOLD))) { |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
528 self->is_battery_low = !self->is_battery_low; |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
529 check_inhibit(self); |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
530 } |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
531 } |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
532 |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
533 static void |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
534 on_notify_network_state(PkControl *pk_control, GParamSpec *pspec, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
535 gpointer user_data) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
536 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
537 PuiBackend *self = user_data; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
538 |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
539 g_object_get(pk_control, "network-state", &self->network_state, NULL); |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
540 g_debug("network state changed: %s", |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
541 pk_network_enum_to_string(self->network_state)); |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
542 check_inhibit(self); |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
543 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
544 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
545 static void |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
546 on_updates_changed(PkControl *control, gpointer user_data) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
547 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
548 PuiBackend *self = user_data; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
549 |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
550 g_debug("package metatdata cache invalidated"); |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
551 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
552 /* |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
553 * schedule a check after a short delay so that a rapid succession of |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
554 * signals is coalesced |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
555 */ |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
556 if (!self->inhibited) { |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
557 if (self->check_id != 0) { |
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
558 g_source_remove(self->check_id); |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
559 } |
32
b9c65915cc54
Reduce delay before checking for updates after an "updates-changed" signal
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
31
diff
changeset
|
560 self->check_id = |
b9c65915cc54
Reduce delay before checking for updates after an "updates-changed" signal
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
31
diff
changeset
|
561 g_timeout_add_seconds(PUI_UPDATES_CHANGED_DELAY, |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
562 irregular_check, self); |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
563 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
564 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
565 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
566 static void |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
567 on_restart_schedule(PkControl *control, gpointer user_data) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
568 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
569 PuiBackend *self = user_data; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
570 |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
571 /* |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
572 * do not restart package-update-indicator if a session or system |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
573 * restart is required since that iformation would be lost across the |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
574 * restart, rather keep running and risk errors when interacting with |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
575 * a newer version of the PackageKit daemon |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
576 */ |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
577 if (self->restart_type > PUI_RESTART_NONE) { |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
578 return; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
579 } |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
580 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
581 g_debug("emitting signal restart-required"); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
582 g_signal_emit(self, signals[RESTART_REQUIRED], 0); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
583 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
584 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
585 static void |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
586 on_transaction_adopt_finish(GObject *source_object, GAsyncResult *result, |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
587 gpointer user_data) |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
588 { |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
589 PuiBackend *self = user_data; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
590 PkClient *pk_client = PK_CLIENT(source_object); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
591 PkResults *results; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
592 GError *error = NULL; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
593 PkRestartEnum restart; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
594 |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
595 results = pk_client_generic_finish(pk_client, result, &error); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
596 if (results == NULL) { |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
597 g_warning("failed to get transaction results: %s", |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
598 error->message); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
599 g_error_free(error); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
600 goto out; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
601 } |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
602 |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
603 /* check if transaction requires a restart */ |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
604 restart = pk_results_get_require_restart_worst(results); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
605 switch (restart) { |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
606 case PK_RESTART_ENUM_SESSION: /* FALLTHROUGH */ |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
607 case PK_RESTART_ENUM_SECURITY_SESSION: |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
608 if (self->restart_type < PUI_RESTART_SESSION) { |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
609 self->restart_type = PUI_RESTART_SESSION; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
610 g_object_notify_by_pspec(G_OBJECT(self), |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
611 properties[PROP_RESTART_TYPE]); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
612 g_signal_emit(self, signals[STATE_CHANGED], 0); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
613 } |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
614 break; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
615 case PK_RESTART_ENUM_SYSTEM: /* FALLTHROUGH */ |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
616 case PK_RESTART_ENUM_SECURITY_SYSTEM: |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
617 if (self->restart_type < PUI_RESTART_SYSTEM) { |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
618 self->restart_type = PUI_RESTART_SYSTEM; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
619 g_object_notify_by_pspec(G_OBJECT(self), |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
620 properties[PROP_RESTART_TYPE]); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
621 g_signal_emit(self, signals[STATE_CHANGED], 0); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
622 } |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
623 break; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
624 default: |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
625 /* do nothing */ |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
626 break; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
627 } |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
628 |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
629 g_debug("transaction finished, required restart: %s", |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
630 pk_restart_enum_to_string(restart)); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
631 |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
632 out: |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
633 if (results != NULL) { |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
634 g_object_unref(results); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
635 } |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
636 } |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
637 |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
638 static void |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
639 on_transaction_list_added(PkTransactionList *transaction_list, |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
640 const gchar *transaction_id, gpointer user_data) |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
641 { |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
642 PuiBackend *self = user_data; |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
643 |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
644 /* adopt transaction in order to monitor it for restart requirements */ |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
645 pk_client_adopt_async(self->pk_client, transaction_id, NULL, NULL, |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
646 NULL, on_transaction_adopt_finish, user_data); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
647 } |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
648 |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
649 static void |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
650 pui_backend_init_async(GAsyncInitable *initable, int io_priority, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
651 GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
652 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
653 PuiBackend *self = PUI_BACKEND(initable); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
654 GTask *task; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
655 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
656 task = g_task_new(G_OBJECT(initable), cancellable, callback, user_data); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
657 g_task_set_priority(task, io_priority); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
658 g_task_set_task_data(task, g_object_ref(self), |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
659 (GDestroyNotify)g_object_unref); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
660 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
661 pk_control_get_properties_async(self->pk_control, cancellable, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
662 on_get_properties_finished, task); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
663 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
664 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
665 static gboolean |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
666 pui_backend_init_finish(GAsyncInitable *initable, GAsyncResult *result, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
667 GError **errorp) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
668 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
669 PuiBackend *self = PUI_BACKEND(initable); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
670 GTask *task = G_TASK(result); |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
671 UpDeviceKind kind; |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
672 gdouble percentage; |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
673 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
674 if (!g_task_propagate_boolean(task, errorp)) { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
675 return (FALSE); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
676 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
677 |
5
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
678 if (self->up_device != NULL) { |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
679 /* get the kind of device and charge percentage */ |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
680 g_object_get(self->up_device, "kind", &kind, "percentage", |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
681 &percentage, NULL); |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
682 if ((kind == UP_DEVICE_KIND_BATTERY) || |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
683 (kind == UP_DEVICE_KIND_UPS)) { |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
684 self->is_battery_low = |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
685 (percentage < LOW_BATTERY_THRESHOLD); |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
686 } |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
687 |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
688 /* get notification if the charge percentage changes */ |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
689 g_signal_connect(self->up_device, "notify::percentage", |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
690 G_CALLBACK(on_notify_device_charge_percentage), self); |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
691 } |
a4020e99e550
Do not check for updates if the battery is low
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
4
diff
changeset
|
692 |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
693 /* get notification when the network state changes */ |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
694 g_signal_connect(self->pk_control, "notify::network-state", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
695 G_CALLBACK(on_notify_network_state), self); |
31
9905d4ae351c
Fix continuos loop of update checks if the refresh cache interval is 0
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
10
diff
changeset
|
696 /* get notifications when the package metatdata cache is invalidated */ |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
697 g_signal_connect(self->pk_control, "updates-changed", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
698 G_CALLBACK(on_updates_changed), self); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
699 /* get notifications when an application restart is required */ |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
700 g_signal_connect(self->pk_control, "restart-schedule", |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
701 G_CALLBACK(on_restart_schedule), self); |
10
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
702 /* get notifications when a transactions are added */ |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
703 self->transaction_list = pk_transaction_list_new(); |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
704 g_signal_connect(self->transaction_list, "added", |
adba37525ee5
Notify about required session or system restarts
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
6
diff
changeset
|
705 G_CALLBACK(on_transaction_list_added), self); |
4
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
706 |
3d72ca76538d
Add setting to control whether to use a mobile connection
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
0
diff
changeset
|
707 check_inhibit(self); |
0
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
708 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
709 return (TRUE); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
710 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
711 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
712 static void |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
713 pui_backend_async_initable_iface_init(gpointer g_iface, gpointer iface_data) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
714 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
715 GAsyncInitableIface *iface = g_iface; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
716 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
717 iface->init_async = pui_backend_init_async; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
718 iface->init_finish = pui_backend_init_finish; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
719 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
720 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
721 void |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
722 pui_backend_new_async(GCancellable *cancellable, GAsyncReadyCallback callback, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
723 gpointer user_data) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
724 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
725 g_async_initable_new_async(PUI_TYPE_BACKEND, G_PRIORITY_DEFAULT, |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
726 cancellable, callback, user_data, NULL); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
727 } |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
728 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
729 PuiBackend * |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
730 pui_backend_new_finish(GAsyncResult *result, GError **errorp) |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
731 { |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
732 GObject *object; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
733 GObject *source_object; |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
734 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
735 source_object = g_async_result_get_source_object(result); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
736 object = g_async_initable_new_finish(G_ASYNC_INITABLE(source_object), |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
737 result, errorp); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
738 g_object_unref(source_object); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
739 |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
740 return ((object != NULL) ? PUI_BACKEND(object) : NULL); |
6884bb8130ca
Initial revision
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
diff
changeset
|
741 } |
6
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
742 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
743 static void |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
744 on_set_proxy_finished(GObject *source_object, GAsyncResult *result, |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
745 gpointer user_data) |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
746 { |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
747 PuiBackend *self = user_data; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
748 GError *error = NULL; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
749 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
750 if (!pk_control_set_proxy_finish(self->pk_control, result, &error)) { |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
751 g_warning("failed to set proxies: %s", error->message); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
752 g_error_free(error); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
753 } |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
754 } |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
755 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
756 static void |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
757 on_polkit_permission_finished(GObject *source_object, GAsyncResult *result, |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
758 gpointer user_data) |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
759 { |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
760 PuiBackend *self = user_data; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
761 GPermission *permission; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
762 GError *error = NULL; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
763 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
764 permission = polkit_permission_new_finish(result, &error); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
765 if (permission == NULL) { |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
766 g_warning("failed to create PolKit permission for setting the " |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
767 "network proxies: %s", error->message); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
768 g_error_free(error); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
769 return; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
770 } |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
771 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
772 if (!g_permission_get_allowed(permission)) { |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
773 /* setting the proxy requires authentication or is disallowed */ |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
774 g_debug("setting the network proxy is not allowed"); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
775 return; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
776 } |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
777 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
778 g_debug("setting HTTP proxy to \"%s\"", (self->proxy_http != NULL) ? |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
779 self->proxy_http : "(null)"); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
780 g_debug("setting HTTPS proxy to \"%s\"", (self->proxy_https != NULL) ? |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
781 self->proxy_https : "(null)"); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
782 g_debug("setting FTP proxy to \"%s\"", (self->proxy_ftp != NULL) ? |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
783 self->proxy_ftp : "(null)"); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
784 g_debug("setting SOCKS proxy to \"%s\"", (self->proxy_socks != NULL) ? |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
785 self->proxy_socks : "(null)"); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
786 g_debug("setting the list of download IPs which should not go through " |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
787 "a proxy to \"%s\"", (self->no_proxy != NULL) ? self->no_proxy : |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
788 "(null)"); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
789 g_debug("setting the PAC string to \"%s\"", (self->pac != NULL) ? |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
790 self->pac : "(null)"); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
791 pk_control_set_proxy2_async(self->pk_control, self->proxy_http, |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
792 self->proxy_https, self->proxy_ftp, self->proxy_socks, |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
793 self->no_proxy, self->pac, NULL, on_set_proxy_finished, self); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
794 } |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
795 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
796 void |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
797 pui_backend_set_proxy(PuiBackend *self, const gchar *proxy_http, |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
798 const gchar *proxy_https, const gchar *proxy_ftp, const gchar *proxy_socks, |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
799 const gchar *no_proxy, const gchar *pac) |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
800 { |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
801 g_free(self->proxy_http); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
802 self->proxy_http = (proxy_http != NULL) ? g_strdup(proxy_http) : NULL; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
803 g_free(self->proxy_https); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
804 self->proxy_https = (proxy_https != NULL) ? g_strdup(proxy_https) : |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
805 NULL; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
806 g_free(self->proxy_ftp); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
807 self->proxy_ftp = (proxy_ftp != NULL) ? g_strdup(proxy_ftp) : NULL; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
808 g_free(self->proxy_socks); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
809 self->proxy_socks = (proxy_socks != NULL) ? g_strdup(proxy_socks) : |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
810 NULL; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
811 g_free(self->no_proxy); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
812 self->no_proxy = (no_proxy != NULL) ? g_strdup(no_proxy) : NULL; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
813 g_free(self->pac); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
814 self->pac = (pac != NULL) ? g_strdup(pac) : NULL; |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
815 |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
816 polkit_permission_new("org.freedesktop.packagekit." |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
817 "system-network-proxy-configure", NULL, NULL, |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
818 on_polkit_permission_finished, self); |
2477a6151087
Make PackagKit use the user's network proxies
Guido Berhoerster <guido+pui@berhoerster.name>
parents:
5
diff
changeset
|
819 } |