[nm-applet][PATCH v2 2/2] add CDMA registration status notification
- From: Alex Chiang <achiang canonical com>
- To: networkmanager-list gnome org
- Subject: [nm-applet][PATCH v2 2/2] add CDMA registration status notification
- Date: Thu, 9 Jun 2011 22:44:27 -0600
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, alert the user with a notification when the CDMA registration
status changes, either from home to roaming or vice versa, to
prevent silent registration changes.
Refactor internal function cdma_state_to_mb_state so it calls
helper function reg_state_to_mb_state.
The new helper function can be re-used to convert the EVDO and
CDMA1x registration states to an internal mb_state in
reg_info_changed_cb().
---
v1 -> v2, no change in CDMA patch
note, I haven't actually tested this patch, since I do
not have any CDMA devices, nor do I understand CDMA
registration priority very well, so would appreciate a
sanity check on my assumption below.
src/applet-device-cdma.c | 47 ++++++++++++++++++++++++++++++++++------------
1 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index 7b0bf85..9fd4fbd 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -287,23 +287,24 @@ add_connection_item (NMDevice *device,
}
static guint32
+reg_state_to_mb_state (guint32 evdo_state, guint32 cdma1x_state)
+{
+ /* EVDO state overrides 1X state for now */
+ if (evdo_state)
+ return (evdo_state == 3) ? MB_STATE_ROAMING : MB_STATE_HOME;
+ else if (cdma1x_state)
+ return (cdma1x_state == 3) ? MB_STATE_ROAMING : MB_STATE_HOME;
+
+ return MB_STATE_UNKNOWN;
+}
+
+static guint32
cdma_state_to_mb_state (CdmaDeviceInfo *info)
{
if (!info->modem_enabled)
return MB_STATE_UNKNOWN;
- /* EVDO state overrides 1X state for now */
- if (info->evdo_state) {
- if (info->evdo_state == 3)
- return MB_STATE_ROAMING;
- return MB_STATE_HOME;
- } else if (info->cdma1x_state) {
- if (info->cdma1x_state == 3)
- return MB_STATE_ROAMING;
- return MB_STATE_HOME;
- }
-
- return MB_STATE_UNKNOWN;
+ return reg_state_to_mb_state(info->evdo_state, info->cdma1x_state);
}
static guint32
@@ -836,7 +837,29 @@ reg_state_changed_cb (DBusGProxy *proxy,
gpointer user_data)
{
CdmaDeviceInfo *info = user_data;
+ guint32 mb_state;
+
+ /* Since we prefer EVDO over 1x, bail if EVDO state hasn't changed */
+ if (evdo_state && info->evdo_state == evdo_state)
+ goto out;
+
+ if (info->evdo_state != evdo_state || info->cdma1x_state != cdma1x_state) {
+ mb_state = reg_state_to_mb_state(evdo_state, cdma1x_state);
+ if (mb_state == MB_STATE_HOME)
+ applet_do_notify_with_pref (info->applet,
+ _("CDMA 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,
+ _("CDMA network."),
+ _("You are now registered on a roaming network."),
+ "notification-gsm-high",
+ PREF_DISABLE_CONNECTED_NOTIFICATIONS);
+ }
+out:
info->cdma1x_state = cdma1x_state;
info->evdo_state = evdo_state;
info->skip_reg_poll = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]