[PATCH 2/2] cdma: 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 CDMA registration status changes to home or
to roaming.

Signed-off-by: Andrew Bird <ajb spheresystems co uk>
---
 src/applet-device-cdma.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index 7b0bf85..fe4cbaf 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -638,6 +638,26 @@ cdma_device_info_free (gpointer data)
 }
 
 static void
+notify_user_of_cdma_reg_change (CdmaDeviceInfo *info)
+{
+	guint32 mb_state = cdma_state_to_mb_state (info);
+
+	if (mb_state == MB_STATE_HOME) {
+		applet_do_notify_with_pref (info->applet,
+		                            _("CDMA network."),
+		                            _("You are now registered on the home network."),
+		                            "nm-signal-100",
+		                            PREF_DISABLE_CONNECTED_NOTIFICATIONS);
+	} else if (mb_state == MB_STATE_ROAMING) {
+		applet_do_notify_with_pref (info->applet,
+		                            _("CDMA network."),
+		                            _("You are now registered on a roaming network."),
+		                            "nm-signal-100",
+		                            PREF_DISABLE_CONNECTED_NOTIFICATIONS);
+	}
+}
+
+static void
 reg_state_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 {
 	CdmaDeviceInfo *info = user_data;
@@ -648,6 +668,9 @@ reg_state_reply (DBusGProxy *proxy, DBusGProxyCall *call, gpointer user_data)
 	                           G_TYPE_UINT, &cdma1x_state,
 	                           G_TYPE_UINT, &evdo_state,
 	                           G_TYPE_INVALID)) {
+		if ((info->cdma1x_state != cdma1x_state) || (info->evdo_state != evdo_state)) {
+			notify_user_of_cdma_reg_change (info);
+		}
 		info->cdma1x_state = cdma1x_state;
 		info->evdo_state = evdo_state;
 		applet_schedule_update_icon (info->applet);
@@ -837,6 +860,9 @@ reg_state_changed_cb (DBusGProxy *proxy,
 {
 	CdmaDeviceInfo *info = user_data;
 
+	if ((info->cdma1x_state != cdma1x_state) || (info->evdo_state != evdo_state)) {
+		notify_user_of_cdma_reg_change (info);
+	}
 	info->cdma1x_state = cdma1x_state;
 	info->evdo_state = evdo_state;
 	info->skip_reg_poll = TRUE;
-- 
1.7.4.4



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