1
=== modified file 'src/applet-device-wifi.c'
3
src/applet-device-wifi.c | 4 +
4
src/applet.c | 126 +++++++++++++++++++++++++++++++++++++++++++++--
6
3 files changed, 127 insertions(+), 5 deletions(-)
8
Index: network-manager-applet-0.7.1~rc3/src/applet-device-wifi.c
9
===================================================================
10
--- network-manager-applet-0.7.1~rc3.orig/src/applet-device-wifi.c
11
+++ network-manager-applet-0.7.1~rc3/src/applet-device-wifi.c
12
@@ -1164,18 +1164,20 @@
13
queue_avail_access_point_notification (device);
15
if (new_state != NM_DEVICE_STATE_ACTIVATED)
19
const GByteArray *ssid = nm_access_point_get_ssid (new);
23
esc_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
24
+ g_object_set_data_full (G_OBJECT(device), "canonical-last-essid", g_strdup (esc_ssid), (GDestroyNotify) g_free);
27
/* Save this BSSID to seen-bssids list */
28
gconf_connection = applet_get_exported_connection_for_device (device, applet);
29
if (gconf_connection && add_seen_bssid (gconf_connection, new))
30
nma_gconf_connection_save (gconf_connection);
33
applet_do_notify_with_pref (applet,
34
Index: network-manager-applet-0.7.1~rc3/src/applet.c
35
===================================================================
36
--- network-manager-applet-0.7.1~rc3.orig/src/applet.c
37
+++ network-manager-applet-0.7.1~rc3/src/applet.c
41
#include <glib/gi18n.h>
42
#include "wireless-helper.h"
44
#include <sys/socket.h>
46
#include <NetworkManagerVPN.h>
47
+#include <nm-device.h>
48
#include <nm-device-ethernet.h>
49
#include <nm-device-wifi.h>
50
#include <nm-gsm-device.h>
51
#include <nm-cdma-device.h>
53
#include <nm-connection.h>
54
#include <nm-vpn-connection.h>
55
#include <nm-setting-connection.h>
57
#include "applet-dbus-manager.h"
59
#include "gconf-helpers.h"
61
#define NOTIFY_CAPS_ACTIONS_KEY "actions"
63
G_DEFINE_TYPE(NMApplet, nma, G_TYPE_OBJECT)
65
+struct _OfflineNotificationContextInfo {
67
+ NMDeviceState device_state;
68
+ NMDeviceStateReason device_state_reason;
69
+ NMDeviceType device_type;
75
+typedef struct _OfflineNotificationContextInfo OfflineNotificationContextInfo;
77
static NMActiveConnection *
78
applet_get_best_activating_connection (NMApplet *applet, NMDevice **device)
80
NMActiveConnection *best = NULL;
81
NMDevice *best_dev = NULL;
82
const GPtrArray *connections;
85
@@ -1634,27 +1647,119 @@
86
if (!gconf_connection || !nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (gconf_connection)))
89
return gconf_connection;
95
+select_merged_notification_text (OfflineNotificationContextInfo *info)
97
+ /* only do something if this is about full offline state */
98
+ if(info->state != NM_STATE_UNKNOWN) {
100
+ info->title = g_strdup (_("Network"));
101
+ if (info->state == NM_STATE_DISCONNECTED || info->state == NM_STATE_ASLEEP)
102
+ info->text = _("Disconnected - you are now offline");
104
+ info->text = _("Disconnected");
106
+ switch (info->device_type) {
107
+ case NM_DEVICE_TYPE_ETHERNET:
108
+ info->icon = "notification-network-wired-disconnected";
110
+ case NM_DEVICE_TYPE_WIFI:
111
+ info->icon = "notification-network-wireless-disconnected";
113
+ case NM_DEVICE_TYPE_GSM:
114
+ info->icon = "notification-network-gsm-disconnected";
117
+ info->icon = "nm-no-connection";
120
+ g_debug("going for offline with icon: %s", info->icon);
127
+foo_online_offline_deferred_notify (gpointer user_data)
129
+ NMApplet *applet = NM_APPLET (user_data);
130
+ OfflineNotificationContextInfo *info = applet->notification_queue_data;
131
+ if(select_merged_notification_text (info))
132
+ applet_do_notify (applet, NOTIFY_URGENCY_LOW, info->title, info->text, info->icon, NULL, NULL, NULL, applet);
134
+ g_debug("no notification because merged found that we have nothing to say (e.g. not offline)");
136
+ g_free (info->title);
137
+ info->title = NULL;
138
+ g_free (applet->notification_queue_data);
139
+ applet->notification_queue_data = NULL;
140
+ applet->deferred_id = 0;
146
applet_common_device_state_changed (NMDevice *device,
147
NMDeviceState new_state,
148
NMDeviceState old_state,
149
NMDeviceStateReason reason,
152
NMConnection *connection;
153
NMActiveConnection *active = NULL;
154
+ g_debug("applet_common_device_state_changed");
157
+ case NM_DEVICE_STATE_FAILED:
158
+ case NM_DEVICE_STATE_DISCONNECTED:
159
+ case NM_DEVICE_STATE_UNMANAGED:
160
+ case NM_DEVICE_STATE_UNAVAILABLE:
162
+ OfflineNotificationContextInfo *info = applet->notification_queue_data;
164
+ info = g_new0(OfflineNotificationContextInfo, 1);
165
+ applet->notification_queue_data = info;
168
+ info->device_state = new_state;
169
+ info->device_state_reason = reason;
171
+ g_free(info->title);
172
+ info->title = NULL;
174
+ if (NM_IS_DEVICE_WIFI (device)) {
175
+ info->device_type = NM_DEVICE_TYPE_WIFI;
176
+ info->title = g_strdup(g_object_get_data (G_OBJECT(device), "canonical-last-essid"));
178
+ info->title = g_strdup (_("Wireless network"));
179
+ } else if (NM_IS_DEVICE_ETHERNET (device)) {
180
+ info->device_type = NM_DEVICE_TYPE_ETHERNET;
181
+ info->title = g_strdup(_("Wired network"));
182
+ } else if (NM_IS_GSM_DEVICE (device)) {
183
+ info->device_type = NM_DEVICE_TYPE_GSM;
184
+ info->title = g_strdup (_("GSM network"));
186
+ info->device_type = NM_DEVICE_TYPE_UNKNOWN;
187
+ info->title = g_strdup (_("Network"));
190
+ if (applet->deferred_id)
191
+ g_source_remove (applet->deferred_id);
192
+ applet->deferred_id = g_timeout_add (1000, foo_online_offline_deferred_notify, applet);
194
+ clear_animation_timeout (applet);
197
case NM_DEVICE_STATE_PREPARE:
198
case NM_DEVICE_STATE_CONFIG:
199
case NM_DEVICE_STATE_NEED_AUTH:
200
case NM_DEVICE_STATE_IP_CONFIG:
201
start_animation_timeout (applet);
203
case NM_DEVICE_STATE_ACTIVATED:
204
/* If the device activation was successful, update the corresponding
205
@@ -1712,23 +1817,36 @@
210
foo_client_state_changed_cb (NMClient *client, GParamSpec *pspec, gpointer user_data)
212
NMApplet *applet = NM_APPLET (user_data);
214
+ g_debug("foo_client_state_changed_cb");
215
switch (nm_client_get_state (client)) {
216
case NM_STATE_DISCONNECTED:
217
- applet_do_notify_with_pref (applet, _("Disconnected"),
218
- _("The network connection has been disconnected."),
219
- "nm-no-connection",
220
- PREF_DISABLE_DISCONNECTED_NOTIFICATIONS);
221
+ case NM_STATE_ASLEEP:
223
+ OfflineNotificationContextInfo *info = applet->notification_queue_data;
225
+ info = g_new0(OfflineNotificationContextInfo, 1);
226
+ applet->notification_queue_data = info;
229
+ info->state = nm_client_get_state (client);
230
+ select_merged_notification_text (info);
232
+ if (applet->deferred_id)
233
+ g_source_remove (applet->deferred_id);
234
+ applet->deferred_id = g_timeout_add (1000, foo_online_offline_deferred_notify, applet);
242
applet_schedule_update_icon (applet);
246
Index: network-manager-applet-0.7.1~rc3/src/applet.h
247
===================================================================
248
--- network-manager-applet-0.7.1~rc3.orig/src/applet.h
249
+++ network-manager-applet-0.7.1~rc3/src/applet.h
250
@@ -153,16 +153,18 @@
251
GtkWidget * info_menu_item;
252
GtkWidget * connections_menu_item;
254
GladeXML * info_dialog_xml;
255
NotifyNotification* notification;
257
/* Notification stuff */
258
gboolean notify_with_actions;
259
+ gpointer notification_queue_data;
263
GSList *mbca_assistants; /* list of UdiAssistant */
264
GModule *mbca_module;
265
void (*mbca_assistant_abort_func) (MBCAAssistant*);
266
void (*mbca_assistant_present_func) (MBCAAssistant*);
267
MBCAAssistant* (*mbca_assistant_new_func) ();
268
gint (*mbca_assistant_run_for_device_func) (MBCAAssistant*,