[network-manager-applet] gsm: add registration status notification



commit a331d07a03a0f4e575fb86f0e4c93f1f50a9e918
Author: Andrew Bird <ajb spheresystems co uk>
Date:   Fri Jun 10 16:13:23 2011 +0100

    gsm: add registration status notification
    
    The current UI requires the user to mouse-over and reveal a tool
    tip (or click an indicator) to discover the registration state
    (aka polling). If the user inadvertently re-registers on a
    roaming network, the operation is silent until the user decides
    to check the applet for network status, possibly incurring
    expensive roaming tariffs in the mean time.
    
    So to prevent silent registration changes, alert the user with a
    notification when the GSM registration status changes to home or
    to roaming.

 src/applet-device-gsm.c |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 5d0d584..206bb0b 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -1083,6 +1083,26 @@ parse_op_name (GsmDeviceInfo *info, const char *orig, const char *op_code)
 	return find_provider_for_mcc_mnc (info->providers, orig);
 }
 
+static void
+notify_user_of_gsm_reg_change (GsmDeviceInfo *info)
+{
+	guint32 mb_state = gsm_state_to_mb_state (info);
+
+	if (mb_state == MB_STATE_HOME) {
+		applet_do_notify_with_pref (info->applet,
+		                            _("GSM network."),
+		                            _("You are now registered on the home network."),
+		                            "notification-gsm-high",
+		                            PREF_DISABLE_CONNECTED_NOTIFICATIONS);
+	} else if (mb_state == MB_STATE_ROAMING) {
+		applet_do_notify_with_pref (info->applet,
+		                            _("GSM network."),
+		                            _("You are now registered on a roaming network."),
+		                            "notification-gsm-high",
+		                            PREF_DISABLE_CONNECTED_NOTIFICATIONS);
+	}
+}
+
 #define REG_INFO_TYPE (dbus_g_type_get_struct ("GValueArray", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID))
 #define DBUS_TYPE_G_MAP_OF_VARIANT (dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE))
 
@@ -1101,7 +1121,7 @@ reg_info_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 		if (array->n_values == 3) {
 			value = g_value_array_get_nth (array, 0);
 			if (G_VALUE_HOLDS_UINT (value))
-				new_state = g_value_get_uint (value);
+				new_state = g_value_get_uint (value) + 1;
 
 			value = g_value_array_get_nth (array, 1);
 			if (G_VALUE_HOLDS_STRING (value)) {
@@ -1120,7 +1140,11 @@ reg_info_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 		g_value_array_free (array);
 	}
 
-	info->reg_state = new_state + 1;
+	if (info->reg_state != new_state) {
+		info->reg_state = new_state;
+		notify_user_of_gsm_reg_change (info);
+	}
+
 	info->op_code = new_op_code;
 	info->op_name = new_op_name;
 
@@ -1281,8 +1305,13 @@ reg_info_changed_cb (DBusGProxy *proxy,
                      gpointer user_data)
 {
 	GsmDeviceInfo *info = user_data;
+	guint32 new_state = reg_state + 1;
+
+	if (info->reg_state != new_state) {
+		info->reg_state = new_state;
+		notify_user_of_gsm_reg_change (info);
+	}
 
-	info->reg_state = reg_state + 1;
 	g_free (info->op_code);
 	info->op_code = strlen (op_code) ? g_strdup (op_code) : NULL;
 	g_free (info->op_name);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]