Merge lp:~cjcurran/indicator-session/apt-fixes into lp:indicator-session/0.1

Proposed by Conor Curran
Status: Merged
Merged at revision: 198
Proposed branch: lp:~cjcurran/indicator-session/apt-fixes
Merge into: lp:indicator-session/0.1
Diff against target: 325 lines (+91/-95)
5 files modified
src/apt-watcher.c (+87/-30)
src/device-menu-mgr.c (+0/-59)
src/indicator-session.c (+1/-2)
src/session-dbus.c (+3/-1)
src/session-dbus.xml (+0/-3)
To merge this branch: bzr merge lp:~cjcurran/indicator-session/apt-fixes
Reviewer Review Type Date Requested Status
Ted Gould Pending
Review via email: mp+73561@code.launchpad.net

Description of the change

restartrequired signal should now be sent when a restart was required.

To post a comment you must log in.
203. By Conor Curran

set the menuitem's disposition back to normal just in case

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/apt-watcher.c'
2--- src/apt-watcher.c 2011-08-23 17:17:54 +0000
3+++ src/apt-watcher.c 2011-08-31 17:22:36 +0000
4@@ -27,6 +27,7 @@
5 struct _AptWatcher
6 {
7 GObject parent_instance;
8+ guint reboot_query;
9 GCancellable * proxy_cancel;
10 GDBusProxy * proxy;
11 SessionDbus* session_dbus_interface;
12@@ -55,7 +56,7 @@
13
14 static void apt_watcher_show_apt_dialog (DbusmenuMenuitem* mi,
15 guint timestamp,
16- gchar * type);
17+ gpointer userdata);
18
19 static void apt_watcher_signal_cb (GDBusProxy* proxy,
20 gchar* sender_name,
21@@ -64,6 +65,7 @@
22 gpointer user_data);
23 static void apt_watcher_manage_transactions (AptWatcher* self,
24 gchar* transaction_id);
25+static gboolean apt_watcher_query_reboot_status (gpointer self);
26
27
28
29@@ -75,6 +77,7 @@
30 self->current_state = UP_TO_DATE;
31 self->proxy_cancel = g_cancellable_new();
32 self->proxy = NULL;
33+ self->reboot_query = 0;
34 self->current_transaction = NULL;
35 g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
36 G_DBUS_PROXY_FLAGS_NONE,
37@@ -141,7 +144,7 @@
38 g_signal_connect (self->proxy,
39 "g-signal",
40 G_CALLBACK(apt_watcher_signal_cb),
41- self);
42+ self);
43 }
44
45
46@@ -213,14 +216,32 @@
47 static void
48 apt_watcher_show_apt_dialog (DbusmenuMenuitem * mi,
49 guint timestamp,
50- gchar * type)
51+ gpointer userdata)
52 {
53 GError * error = NULL;
54- if (!g_spawn_command_line_async("update-manager", &error))
55- {
56- g_warning("Unable to show update-manager: %s", error->message);
57- g_error_free(error);
58- }
59+ g_return_if_fail (APT_IS_WATCHER (userdata));
60+ AptWatcher* self = APT_WATCHER (userdata);
61+ const gchar* disposition = NULL;
62+ disposition = dbusmenu_menuitem_property_get (self->apt_item,
63+ DBUSMENU_MENUITEM_PROP_DISPOSITION);
64+
65+ if (g_strcmp0 (disposition, DBUSMENU_MENUITEM_DISPOSITION_ALERT) == 0){
66+ gchar * helper = g_build_filename (LIBEXECDIR, "gtk-logout-helper", NULL);
67+ gchar * dialog_line = g_strdup_printf ("%s --%s", helper, "restart");
68+ g_free(helper);
69+ if (!g_spawn_command_line_async(dialog_line, &error)) {
70+ g_warning("Unable to show dialog: %s", error->message);
71+ g_error_free(error);
72+ }
73+ g_free(dialog_line);
74+ }
75+ else{
76+ if (!g_spawn_command_line_async("update-manager", &error))
77+ {
78+ g_warning("Unable to show update-manager: %s", error->message);
79+ g_error_free(error);
80+ }
81+ }
82 }
83
84 static void
85@@ -245,7 +266,16 @@
86 == SIMULATION){
87 g_object_unref (G_OBJECT(self->current_transaction));
88 self->current_transaction = NULL;
89- }
90+ }
91+ if (self->reboot_query != 0){
92+ g_source_remove (self->reboot_query);
93+ self->reboot_query = 0;
94+ }
95+ // Wait a sec before querying for reboot status,
96+ // race condition with Apt has been observed.
97+ self->reboot_query = g_timeout_add_seconds (1,
98+ apt_watcher_query_reboot_status,
99+ self);
100 }
101 else if (state == UPDATES_AVAILABLE){
102 dbusmenu_menuitem_property_set (self->apt_item,
103@@ -266,27 +296,20 @@
104 _("Updates Installing…"));
105 }
106 else if (state == FINISHED){
107- GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy,
108- "RebootRequired");
109- gboolean reboot;
110- g_variant_get (reboot_result, "b", &reboot);
111- if (reboot == FALSE){
112- dbusmenu_menuitem_property_set (self->apt_item,
113- DBUSMENU_MENUITEM_PROP_LABEL,
114- _("Software Up to Date"));
115- }
116- else{
117- dbusmenu_menuitem_property_set (self->apt_item,
118- DBUSMENU_MENUITEM_PROP_LABEL,
119- _("Reboot Required"));
120- dbusmenu_menuitem_property_set (self->apt_item,
121- DBUSMENU_MENUITEM_PROP_DISPOSITION,
122- DBUSMENU_MENUITEM_DISPOSITION_ALERT);
123- session_dbus_restart_required (self->session_dbus_interface);
124- }
125- g_debug ("Finished with a reboot value of %i", reboot);
126 g_object_unref (G_OBJECT(self->current_transaction));
127- self->current_transaction = NULL;
128+ self->current_transaction = NULL;
129+ if (self->reboot_query != 0){
130+ g_source_remove (self->reboot_query);
131+ self->reboot_query = 0;
132+ }
133+ // Wait a sec before querying for reboot status,
134+ // race condition with Apt has been observed.
135+ self->reboot_query = g_timeout_add_seconds (1,
136+ apt_watcher_query_reboot_status,
137+ self);
138+ dbusmenu_menuitem_property_set (self->apt_item,
139+ DBUSMENU_MENUITEM_PROP_LABEL,
140+ _("Finished Updating…"));
141 }
142 self->current_state = state;
143 }
144@@ -302,8 +325,42 @@
145 }
146 }
147
148+static gboolean
149+apt_watcher_query_reboot_status (gpointer data)
150+{
151+ g_return_val_if_fail (APT_IS_WATCHER (data), FALSE);
152+ AptWatcher* self = APT_WATCHER (data);
153+
154+ GVariant* reboot_result = g_dbus_proxy_get_cached_property (self->proxy,
155+ "RebootRequired");
156+ gboolean reboot;
157+ g_variant_get (reboot_result, "b", &reboot);
158+ g_debug ("apt_watcher_query_reboot_status: reboot prop = %i", reboot);
159+
160+ if (reboot == FALSE){
161+ dbusmenu_menuitem_property_set (self->apt_item,
162+ DBUSMENU_MENUITEM_PROP_LABEL,
163+ _("Software Up to Date"));
164+ dbusmenu_menuitem_property_set (self->apt_item,
165+ DBUSMENU_MENUITEM_PROP_DISPOSITION,
166+ DBUSMENU_MENUITEM_DISPOSITION_NORMAL);
167+
168+ }
169+ else{
170+ dbusmenu_menuitem_property_set (self->apt_item,
171+ DBUSMENU_MENUITEM_PROP_LABEL,
172+ _("Reboot Required"));
173+ dbusmenu_menuitem_property_set (self->apt_item,
174+ DBUSMENU_MENUITEM_PROP_DISPOSITION,
175+ DBUSMENU_MENUITEM_DISPOSITION_ALERT);
176+ session_dbus_restart_required (self->session_dbus_interface);
177+ }
178+ self->reboot_query = 0;
179+ return FALSE;
180+}
181+
182 // TODO - Ask MVO about this.
183-// Signal is of type s not sas which is on d-feet !!!
184+// Signal is of type s not sas which is on d-feet.
185 static void apt_watcher_signal_cb ( GDBusProxy* proxy,
186 gchar* sender_name,
187 gchar* signal_name,
188
189=== modified file 'src/device-menu-mgr.c'
190--- src/device-menu-mgr.c 2011-08-23 16:14:35 +0000
191+++ src/device-menu-mgr.c 2011-08-31 17:22:36 +0000
192@@ -61,7 +61,6 @@
193 static DbusmenuMenuitem * hibernate_mi = NULL;
194 static DbusmenuMenuitem * suspend_mi = NULL;
195 static DbusmenuMenuitem * logout_mi = NULL;
196-static DbusmenuMenuitem * restart_mi = NULL;
197 static DbusmenuMenuitem * shutdown_mi = NULL;
198
199 static gboolean can_hibernate = TRUE;
200@@ -73,7 +72,6 @@
201 static DBusGProxy * up_prop_proxy = NULL;
202
203 static void device_menu_mgr_ensure_settings_client (DeviceMenuMgr* self);
204-static void setup_restart_watch (DeviceMenuMgr* self);
205 static void setup_up (DeviceMenuMgr* self);
206 static void device_menu_mgr_rebuild_items (DeviceMenuMgr *self);
207 static void lock_if_possible (DeviceMenuMgr* self);
208@@ -106,7 +104,6 @@
209 {
210 self->apt_watcher = NULL;
211 self->root_item = dbusmenu_menuitem_new ();
212- setup_restart_watch(self);
213 setup_up(self);
214 g_idle_add(lock_screen_setup, NULL);
215 }
216@@ -751,62 +748,6 @@
217 can_suspend && allow_suspend);
218 }
219
220-/* When the directory changes we need to figure out how our menu
221- item should look. */
222-static void
223-restart_dir_changed (gpointer userdata)
224-{
225- DeviceMenuMgr* self = DEVICE_MENU_MGR (userdata);
226- gboolean restart_required = g_file_test("/var/run/reboot-required", G_FILE_TEST_EXISTS);
227-
228- if (restart_required) {
229- if (supress_confirmations()) {
230- dbusmenu_menuitem_property_set (restart_mi,
231- RESTART_ITEM_LABEL,
232- _("Restart to Complete Update"));
233- } else {
234- dbusmenu_menuitem_property_set (restart_mi,
235- RESTART_ITEM_LABEL,
236- _("Restart to Complete Update\342\200\246"));
237- }
238- dbusmenu_menuitem_property_set (restart_mi,
239- RESTART_ITEM_ICON,
240- "system-restart-panel");
241- if (self->session_dbus_interface != NULL) {
242- session_dbus_set_name (self->session_dbus_interface, ICON_RESTART);
243- }
244- } else {
245- if (supress_confirmations()) {
246- dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart"));
247- } else {
248- dbusmenu_menuitem_property_set(restart_mi, RESTART_ITEM_LABEL, _("Restart\342\200\246"));
249- }
250- dbusmenu_menuitem_property_remove(restart_mi, RESTART_ITEM_ICON);
251- if (self->session_dbus_interface != NULL) {
252- session_dbus_set_name(self->session_dbus_interface, ICON_DEFAULT);
253- }
254- }
255- return;
256-}
257-
258-/* Buids a file watcher for the directory so that when it
259- changes we can check to see if our reboot-required is
260- there. */
261-static void
262-setup_restart_watch (DeviceMenuMgr* self)
263-{
264- GFile * filedir = g_file_new_for_path("/var/run");
265- GFileMonitor * filemon = g_file_monitor_directory(filedir, G_FILE_MONITOR_NONE, NULL, NULL);
266- if (filemon != NULL) {
267- g_signal_connect (G_OBJECT(filemon),
268- "changed",
269- G_CALLBACK(restart_dir_changed),
270- self);
271- }
272- restart_dir_changed(self);
273- return;
274-}
275-
276 /* Ensures that we have a GConf client and if we build one
277 set up the signal handler. */
278 static void
279
280=== modified file 'src/indicator-session.c'
281--- src/indicator-session.c 2011-08-22 13:05:48 +0000
282+++ src/indicator-session.c 2011-08-31 17:22:36 +0000
283@@ -497,8 +497,7 @@
284 &self->users);
285 }
286 }
287- else if (g_strcmp0(signal_name, "RebootRequired") == 0) {
288- // TODO waiting on design to give me a name.
289+ else if (g_strcmp0(signal_name, "RestartRequired") == 0) {
290 self->devices.image = indicator_image_helper (ICON_RESTART);
291 }
292 }
293
294=== modified file 'src/session-dbus.c'
295--- src/session-dbus.c 2011-08-09 08:59:20 +0000
296+++ src/session-dbus.c 2011-08-31 17:22:36 +0000
297@@ -300,11 +300,13 @@
298 GError * error = NULL;
299
300 if (priv->bus != NULL) {
301+ g_debug("About to send RebootRequired signal");
302+
303 g_dbus_connection_emit_signal (priv->bus,
304 NULL,
305 INDICATOR_SESSION_SERVICE_DBUS_OBJECT,
306 INDICATOR_SESSION_SERVICE_DBUS_IFACE,
307- "RebootRequired",
308+ "RestartRequired",
309 NULL,
310 &error);
311
312
313=== modified file 'src/session-dbus.xml'
314--- src/session-dbus.xml 2011-08-09 08:59:20 +0000
315+++ src/session-dbus.xml 2011-08-31 17:22:36 +0000
316@@ -8,9 +8,6 @@
317 <method name="GetUserMenuVisibility">
318 <arg name="update" direction="out" type="b"/>
319 </method>
320- <method name="IsUpdateNeeded">
321- <arg name="update" direction="out" type="b"/>
322- </method>
323 <signal name="UserRealNameUpdated">
324 <arg name="name" type="s"/>
325 </signal>

Subscribers

People subscribed via source and target branches