1 === modified file 'src/applet-device-wifi.c'
3 src/applet-device-wifi.c | 4 +
4 src/applet.c | 136 +++++++++++++++++++++++++++++++++++++++++++++--
6 3 files changed, 138 insertions(+), 5 deletions(-)
8 Index: network-manager-applet-0.8.1~beta3~git.20100601t071733.8665dfe/src/applet-device-wifi.c
9 ===================================================================
10 --- network-manager-applet-0.8.1~beta3~git.20100601t071733.8665dfe.orig/src/applet-device-wifi.c 2010-06-02 22:00:39.000000000 -0400
11 +++ network-manager-applet-0.8.1~beta3~git.20100601t071733.8665dfe/src/applet-device-wifi.c 2010-06-02 22:00:58.398889073 -0400
12 @@ -1242,8 +1242,10 @@
14 const GByteArray *ssid = nm_access_point_get_ssid (new);
18 esc_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
19 + g_object_set_data_full (G_OBJECT(device), "canonical-last-essid", g_strdup (esc_ssid), (GDestroyNotify) g_free);
22 /* Save this BSSID to seen-bssids list */
23 connection = applet_get_exported_connection_for_device (device, applet);
24 Index: network-manager-applet-0.8.1~beta3~git.20100601t071733.8665dfe/src/applet.c
25 ===================================================================
26 --- network-manager-applet-0.8.1~beta3~git.20100601t071733.8665dfe.orig/src/applet.c 2010-06-02 22:00:31.000000000 -0400
27 +++ network-manager-applet-0.8.1~beta3~git.20100601t071733.8665dfe/src/applet.c 2010-06-02 22:00:58.398889073 -0400
29 #include <sys/socket.h>
31 #include <NetworkManagerVPN.h>
32 +#include <nm-device.h>
33 #include <nm-device-ethernet.h>
34 #include <nm-device-wifi.h>
35 #include <nm-gsm-device.h>
38 G_DEFINE_TYPE(NMApplet, nma, G_TYPE_OBJECT)
40 +struct _OfflineNotificationContextInfo {
42 + NMDeviceState device_state;
43 + NMDeviceStateReason device_state_reason;
44 + NMDeviceType device_type;
48 + NotifyUrgency urgency;
51 +typedef struct _OfflineNotificationContextInfo OfflineNotificationContextInfo;
53 static NMActiveConnection *
54 applet_get_best_activating_connection (NMApplet *applet, NMDevice **device)
56 @@ -2004,6 +2018,59 @@
61 +select_merged_notification_text (OfflineNotificationContextInfo *info)
63 + info->urgency = NOTIFY_URGENCY_LOW;
64 + /* only do something if this is about full offline state */
65 + if(info->state != NM_STATE_UNKNOWN || info->device_state != NM_STATE_UNKNOWN) {
66 + info->urgency = NOTIFY_URGENCY_NORMAL;
68 + info->title = g_strdup (_("Network"));
69 + if (info->state == NM_STATE_DISCONNECTED || info->state == NM_STATE_ASLEEP) {
70 + info->urgency = NOTIFY_URGENCY_CRITICAL;
71 + info->text = _("Disconnected - you are now offline");
73 + info->text = _("Disconnected");
75 + switch (info->device_type) {
76 + case NM_DEVICE_TYPE_ETHERNET:
77 + info->icon = "notification-network-ethernet-disconnected";
79 + case NM_DEVICE_TYPE_WIFI:
80 + info->icon = "notification-network-wireless-disconnected";
82 + case NM_DEVICE_TYPE_GSM:
83 + info->icon = "notification-gsm-disconnected";
86 + info->icon = "nm-no-connection";
89 + g_debug("going for offline with icon: %s", info->icon);
96 +foo_online_offline_deferred_notify (gpointer user_data)
98 + NMApplet *applet = NM_APPLET (user_data);
99 + OfflineNotificationContextInfo *info = applet->notification_queue_data;
100 + if(select_merged_notification_text (info))
101 + applet_do_notify (applet, info->urgency, info->title, info->text, info->icon, NULL, NULL, NULL, applet);
103 + g_debug("no notification because merged found that we have nothing to say (e.g. not offline)");
105 + g_free (info->title);
106 + info->title = NULL;
107 + g_free (applet->notification_queue_data);
108 + applet->notification_queue_data = NULL;
109 + applet->deferred_id = 0;
114 applet_common_device_state_changed (NMDevice *device,
115 NMDeviceState new_state,
116 @@ -2019,6 +2086,54 @@
117 vpn_activating = applet_is_any_vpn_activating (applet);
120 + case NM_DEVICE_STATE_FAILED:
121 + case NM_DEVICE_STATE_DISCONNECTED:
122 + case NM_DEVICE_STATE_UNMANAGED:
123 + case NM_DEVICE_STATE_UNAVAILABLE:
125 + if (old_state != NM_DEVICE_STATE_FAILED &&
126 + old_state != NM_DEVICE_STATE_UNKNOWN &&
127 + old_state != NM_DEVICE_STATE_DISCONNECTED &&
128 + old_state != NM_DEVICE_STATE_UNMANAGED &&
129 + old_state != NM_DEVICE_STATE_UNAVAILABLE) {
130 + OfflineNotificationContextInfo *info = applet->notification_queue_data;
132 + info = g_new0(OfflineNotificationContextInfo, 1);
133 + applet->notification_queue_data = info;
136 + info->device_state = new_state;
137 + info->device_state_reason = reason;
139 + g_free(info->title);
140 + info->title = NULL;
142 + if (NM_IS_DEVICE_WIFI (device)) {
143 + info->device_type = NM_DEVICE_TYPE_WIFI;
144 + info->title = g_strdup(g_object_get_data (G_OBJECT(device), "canonical-last-essid"));
146 + info->title = g_strdup (_("Wireless network"));
147 + } else if (NM_IS_DEVICE_ETHERNET (device)) {
148 + info->device_type = NM_DEVICE_TYPE_ETHERNET;
149 + info->title = g_strdup(_("Wired network"));
150 + } else if (NM_IS_GSM_DEVICE (device)) {
151 + info->device_type = NM_DEVICE_TYPE_GSM;
152 + info->title = g_strdup (_("GSM network"));
154 + info->device_type = NM_DEVICE_TYPE_UNKNOWN;
155 + info->title = g_strdup (_("Network"));
158 + if (applet->deferred_id)
159 + g_source_remove (applet->deferred_id);
160 + applet->deferred_id = g_timeout_add (1000, foo_online_offline_deferred_notify, applet);
162 + clear_animation_timeout (applet);
164 + g_debug ("old state indicates that this was not a disconnect %d", old_state);
168 case NM_DEVICE_STATE_PREPARE:
169 case NM_DEVICE_STATE_CONFIG:
170 case NM_DEVICE_STATE_NEED_AUTH:
171 @@ -2096,13 +2211,26 @@
173 NMApplet *applet = NM_APPLET (user_data);
175 + g_debug("foo_client_state_changed_cb");
176 switch (nm_client_get_state (client)) {
177 case NM_STATE_DISCONNECTED:
178 - applet_do_notify_with_pref (applet, _("Disconnected"),
179 - _("The network connection has been disconnected."),
180 - "nm-no-connection",
181 - PREF_DISABLE_DISCONNECTED_NOTIFICATIONS);
182 + case NM_STATE_ASLEEP:
184 + OfflineNotificationContextInfo *info = applet->notification_queue_data;
186 + info = g_new0(OfflineNotificationContextInfo, 1);
187 + applet->notification_queue_data = info;
190 + info->state = nm_client_get_state (client);
191 + select_merged_notification_text (info);
193 + if (applet->deferred_id)
194 + g_source_remove (applet->deferred_id);
195 + applet->deferred_id = g_timeout_add (1000, foo_online_offline_deferred_notify, applet);
202 Index: network-manager-applet-0.8.1~beta3~git.20100601t071733.8665dfe/src/applet.h
203 ===================================================================
204 --- network-manager-applet-0.8.1~beta3~git.20100601t071733.8665dfe.orig/src/applet.h 2010-06-02 21:27:49.000000000 -0400
205 +++ network-manager-applet-0.8.1~beta3~git.20100601t071733.8665dfe/src/applet.h 2010-06-02 22:02:28.888889469 -0400
207 GladeXML * info_dialog_xml;
208 NotifyNotification* notification;
209 gboolean notify_actions;
211 + gpointer notification_queue_data;
215 typedef void (*AppletNewAutoConnectionCallback) (NMConnection *connection,