[PATCH] Add GSM registration status notification (V3)

2011-06-10 Thread Andrew Bird
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.
---
v1 - v2: Fix incorrect mapping of reg_state to mb_state.
v2 - v3: Ensure we preserve the meaning of info-reg_state.
  Use the gsm_state_to_mb_state mapping function.
  Also handle the reply of GetRegistrationInfo().

Signed-off-by: Andrew Bird a...@spheresystems.co.uk
---
 src/applet-device-gsm.c |   34 +++---
 1 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index 5d0d584..76fd81e 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -1083,6 +1083,25 @@ 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 +1120,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 +1139,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 +1304,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);
-- 
1.7.4.4

___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [PATCH] ModemManager: Enhancements to Icera error reporting and access technology reporting

2011-06-10 Thread Eric Shienbrood
According to the documentation I have, the connection state field is '-'
when not connected. To quote more specifically:

4) Response to AT%NWSTATE CR (execute command)
%NWSTATE: signal strength,MCC/MNC,access technology,connection
state,regulation

. . .

connection state possible values:
- for 2G access technologies and 3G access technology when not connected
R99 for 3G access technology when connected
HSDPA for 3G access technology when connected and HSDPA resource allocated
by the network
HSUPA for 3G access technology when connected and HSUPA resource allocated
by the network
HSDPA-HSUPA for 3G access technology when connected and both HSDPA and HSUPA
resources allocated
by the network


I interpret that to mean that if the field is not '-', it indicates the
technology that's actually in use for the connection, so that's what should
be reported for access technology. If the field is '-', then there's no
connection, so we should report what's in the access technology field
instead.

Also, sorry about missing the g_free() for the result of
g_match_info_fetch(). Do you want me to send a new patch, or do you want to
take care of it?

Eric

On Thu, Jun 9, 2011 at 5:47 PM, Dan Williams d...@redhat.com wrote:

 On Tue, 2011-06-07 at 10:35 -0400, Eric Shienbrood wrote:
  Thanks Aleksander! New patch file is attached.

 I split these up and pushed all hunks except the hunk for processing the
 match info for the NWSTATE response.  Two things there... first you need
 to make sure you free the result of g_match_info_fetch() since that's an
 allocated string.  Second, what does '-' mean again for the connected
 field?  I had the docs at some point but I appear to have lost them;
 what other values can be there, and why don't we want to update the
 access technology when that field is something other than '-'?

 Thanks!
 Dan

  Eric
 
 
 
  On Tue, Jun 7, 2011 at 2:56 AM, Aleksander Morgado
  aleksan...@lanedo.com wrote:
  Hi Eric,
 
 
   The additional error detail allows us to know that a
  connection failed
   because of an invalid APN. Also, when handling access
  technology
   changes, report the technology in use if we're connected.
  Finally,
   avoid using CFUN=0 when disabling the modem.
 
 
  A small thing to fix in the patch.
 
  All callbacks receiving a response from the AT serial port
  should check
  if the modem has already been removed, so in
  query_network_error_code_done(), this check is needed just
  before trying
  to parse any reply:
 
 /* If the modem has already been removed, return without
  * scheduling callback */
 if (mm_callback_info_check_modem_removed (info))
 return;
 
  See
 
 http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=9323daec015ecad65c39b6020b62e864c027d858
 
  Cheers!
 
  --
  Aleksander
 
 
 
  ___
  networkmanager-list mailing list
  networkmanager-list@gnome.org
  http://mail.gnome.org/mailman/listinfo/networkmanager-list



___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: How to Test NetworkManager 0.9

2011-06-10 Thread Lamarque Vieira Souza
Em Friday 10 June 2011, David Narvaez escreveu:
 On Thu, Jun 9, 2011 at 11:19 AM, Dan Williams d...@redhat.com wrote:
  On Thu, 2011-06-09 at 15:12 +0200, Jirka Klimes wrote:
  On Thursday 09 of June 2011 14:00:29 David Narvaez wrote:
  First, basically you don't need any client (KDE plasma or nm-applet or
  gnome- shell applet or whatever) to run NetworkManager. You can edit
  connection files and everything will work.
  
  To list available APs use:
  nm-tool
  or
  nmcli dev wifi
  
   nmcli nm shows Wifi and Wifi-Hardware are both enabled but I can't see
   a list of the networks. Any ideas from this point?
  
  There could be a problem with WiFi driver or wireless could be disabled
  by rfkill switch (either hardware or software). Can you show the output
  of 'nm- tool' and 'rfkill list' commands? Also attach /var/log/messages
  or /var/log/daemon.log, or whatever file contains NetworkManager logs
  in your distro.
  
  After that, try a manual wifi scan:
  
  iw dev wlan0 scan trigger
  
  or if your card is really old:
  
  iwlist wlan0 scan
  
  and see what happens.  If that's working, the next thing we need to do
  is enable wpa_supplicant debugging to see why the scan requests are
  getting rejected by the driver.
 
 Thanks for the replies,
 
 I had an awfully busy night and didn't have much time to hack NM but
 just wanted to give quick updates on the commands above:
 
 * nm-tool shows no wireless networks
 * rfkill shows everything is unblocked
 * I can scan wireless networks with iwlist
 
 * This is something relevant I found on messages:
  (wlan0): device state change: unavailable - disconnected (reason
  'supplicant-available')
 
 I am not able to copy the exact outputs right now (they are in the
 laptop, without wireless), but that should give us a bit of an idea of
 what the situation looks like. I searched around and found some
 strikingly similar bugs in Fedora 15[0][1], which uses NM 0.9 so my
 issue could be along those lines. I didn't have time to read through
 all of them, but I'll try that tomorrow. If needed, I could still post
 the output of the commands tomorrow to help debugging

What wpa_supplicant and NetworkManager versions do you use? I use 
wpa_supplicant -0.7.3 and NetworkManager 0.8.9997.

-- 
Lamarque V. Souza
http://www.geographicguide.com/brazil.htm
Linux User #57137 - http://counter.li.org/
http://planetkde.org/pt-br
___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: How to Test NetworkManager 0.9

2011-06-10 Thread David Narvaez
On Fri, Jun 10, 2011 at 7:09 PM, Lamarque Vieira Souza
lamar...@gmail.com wrote:
 What wpa_supplicant and NetworkManager versions do you use? I use 
 wpa_supplicant -0.7.3 and NetworkManager 0.8.9997.

Same thing here, wpa_supplicant-0.7.3-r2 from Gentoo and NM 0.8.9997 from git.

David E. Narváez
___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: How to Test NetworkManager 0.9

2011-06-10 Thread Lamarque Vieira Souza
Em Friday 10 June 2011, David Narvaez escreveu:
 On Fri, Jun 10, 2011 at 7:09 PM, Lamarque Vieira Souza
 
 lamar...@gmail.com wrote:
  What wpa_supplicant and NetworkManager versions do you use? I use
  wpa_supplicant -0.7.3 and NetworkManager 0.8.9997.
 
 Same thing here, wpa_supplicant-0.7.3-r2 from Gentoo and NM 0.8.9997 from
 git.

This is odd, I also use Gentoo. What is your wireless card? Send the 
output of lspci please (or lsusb if your card is usb).

-- 
Lamarque V. Souza
http://www.geographicguide.com/brazil.htm
Linux User #57137 - http://counter.li.org/
http://planetkde.org/pt-br
___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: How to Test NetworkManager 0.9

2011-06-10 Thread David Narvaez
On Fri, Jun 10, 2011 at 8:15 PM, Lamarque Vieira Souza
lamar...@gmail.com wrote:
 This is odd, I also use Gentoo. What is your wireless card? Send the output
 of lspci please (or lsusb if your card is usb).

Just to add some precision to my previous post, I use Sabayon Linux.
Furthermore, as I can't remove the NetworkManager package (it's a
dependency for many other packages), what I do is I compile the NM 0.9
code and install that over the old NM files (0.8.2) which could mean
I'm messing up the configuration. I'm now downloading a Fedora 15
LiveCD, which I understand includes the NM 0.9 package just to discard
configuration issues.

About the wireless card, this is lspci's output for my wireless card:

 Network controler: Broadcom Corporation BCM4312 802.11b/g (rev 01)

I've tried with both the b43 driver and Broadcom's one, no luck. I
also saw some results saying that for some Acer laptops, removing the
acer_wmi module did the trick, so I removed dell_wmi module (and
dell_laptop too), still no luck.

I'll let you know if it works fine on F15. Thanks again.

David E. Narváez
___
networkmanager-list mailing list
networkmanager-list@gnome.org
http://mail.gnome.org/mailman/listinfo/networkmanager-list