Ticket #1759: 0001-Showing-Errors-Pallete-Mockup-V5.patch

File 0001-Showing-Errors-Pallete-Mockup-V5.patch, 23.1 KB (added by Dcastelo, 9 years ago)

Improvements based on comments made by James Cameron

  • extensions/deviceicon/network.py

    From 8b76b39bfcc29d1382c85a7c334e5e037d1487b9 Mon Sep 17 00:00:00 2001
    From: dcastelo <dcastelo@plan.ceibal.edu.uy>
    Date: Tue, 1 Jun 2010 11:36:35 -0300
    Subject: [PATCH] Showing-Errors-Pallete-Mockup-V5.patch
    
    ---
     extensions/deviceicon/network.py |  189 ++++++++++++++++++++++++++------------
     src/jarabe/model/network.py      |  160 ++++++++++++++++++++++++++++++--
     2 files changed, 280 insertions(+), 69 deletions(-)
    
    diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
    index 94a4293..d695fad 100644
    a b from sugar.graphics.tray import TrayIcon 
    3939from sugar.graphics import xocolor
    4040from sugar.util import unique_id
    4141from sugar import profile
     42from sugar.graphics.icon import Icon
     43from sugar.graphics.menuitem import MenuItem
    4244
    4345from jarabe.model import network
    4446from jarabe.model.network import Settings
    _GSM_STATE_NOT_READY = 0 
    6365_GSM_STATE_DISCONNECTED = 1
    6466_GSM_STATE_CONNECTING = 2
    6567_GSM_STATE_CONNECTED = 3
    66 _GSM_STATE_NEED_AUTH = 4
     68_GSM_STATE_FAILED = 4
    6769
    6870def frequency_to_channel(frequency):
    6971    ftoc = { 2412: 1, 2417: 2, 2422: 3, 2427: 4,
    class WiredPalette(Palette): 
    214216            ip_address_text = ""
    215217        self._ip_address_label.set_text(ip_address_text)
    216218
     219
    217220class GsmPalette(Palette):
    218221    __gtype_name__ = 'SugarGsmPalette'
    219222
    class GsmPalette(Palette): 
    227230    def __init__(self):
    228231
    229232        Palette.__init__(self, label=_('Wireless modem'))
    230 
    231233        self._current_state = None
     234        self._alert = False
    232235
    233         self._toggle_state_item = gtk.MenuItem('')
     236        self._toggle_state_item = MenuItem('')
    234237        self._toggle_state_item.connect('activate', self.__toggle_state_cb)
    235238        self.menu.append(self._toggle_state_item)
    236239        self._toggle_state_item.show()
    237240
    238         self.set_state(_GSM_STATE_NOT_READY)
    239 
    240241        self.info_box = gtk.VBox()
    241242
    242         self.data_label = gtk.Label()
    243         self.data_label.props.xalign = 0.0
    244         label_alignment = self._add_widget_with_padding(self.data_label)
    245         self.info_box.pack_start(label_alignment)
    246         self.data_label.show()
     243        self.error_description_label = gtk.Label("")
     244        self.error_description_label.set_line_wrap(True)
     245        self.info_box.pack_start(self.error_description_label)
     246
     247        self.connection_info_box = gtk.HBox()
     248
     249        icon = Icon(icon_name='data-upload', icon_size=gtk.ICON_SIZE_MENU)
     250        self.connection_info_box.pack_start(icon)
     251        icon.show()
     252        self._data_label_up = gtk.Label()
     253        self._data_label_up.props.xalign = 0.0
     254        label_alignment = self._add_widget_with_padding(self._data_label_up)
     255        self.connection_info_box.pack_start(label_alignment)
     256        self._data_label_up.show()
    247257        label_alignment.show()
    248258
    249         self.connection_time_label = gtk.Label()
    250         self.connection_time_label.props.xalign = 0.0
    251         label_alignment = self._add_widget_with_padding( \
    252                 self.connection_time_label)
    253         self.info_box.pack_start(label_alignment)
    254         self.connection_time_label.show()
     259        icon = Icon(icon_name='data-download', icon_size=gtk.ICON_SIZE_MENU)
     260        self.connection_info_box.pack_start(icon)
     261        icon.show()
     262        self._data_label_down = gtk.Label()
     263        self._data_label_down.props.xalign = 0.0
     264        label_alignment = self._add_widget_with_padding(self._data_label_down)
     265        self.connection_info_box.pack_start(label_alignment)
     266        self._data_label_down.show()
    255267        label_alignment.show()
     268       
     269        self.info_box.pack_start(self.connection_info_box)
    256270
     271        self._error_accept_item = MenuItem('')
     272        self._error_accept_item.connect('activate', self.__error_accept_cb)
     273        self.menu.append(self._error_accept_item)
     274       
    257275        self.info_box.show()
    258276        self.set_content(self.info_box)
    259277
     278        self.set_state(_GSM_STATE_NOT_READY)
     279
    260280    def _add_widget_with_padding(self, child, xalign=0, yalign=0.5):
    261281        alignment = gtk.Alignment(xalign=xalign, yalign=yalign,
    262282                                  xscale=1, yscale=0.33)
    class GsmPalette(Palette): 
    267287        alignment.add(child)
    268288        return alignment
    269289
    270     def set_state(self, state):
     290    def set_state(self, state, reason=0):
    271291        self._current_state = state
    272         self._update_label_and_text()
     292        self._update_label_and_text(reason)
    273293
    274     def _update_label_and_text(self):
     294    def _update_label_and_text(self, reason=0):
     295       
    275296        if self._current_state == _GSM_STATE_NOT_READY:
    276297            self._toggle_state_item.get_child().set_label('...')
    277298            self.props.secondary_text = _('Please wait...')
    278 
     299   
    279300        elif self._current_state == _GSM_STATE_DISCONNECTED:
    280301            self._toggle_state_item.get_child().set_label(_('Connect'))
    281             self.props.secondary_text = _('Disconnected')
    282 
     302            if not self._alert:
     303                self.props.secondary_text = _('Disconnected')
     304            icon = Icon(icon_name='dialog-ok', \
     305                        icon_size=gtk.ICON_SIZE_MENU)
     306            self._toggle_state_item.set_image(icon)
     307         
    283308        elif self._current_state == _GSM_STATE_CONNECTING:
    284309            self._toggle_state_item.get_child().set_label(_('Cancel'))
    285310            self.props.secondary_text = _('Connecting...')
     311            icon = Icon(icon_name='dialog-cancel', \
     312                        icon_size=gtk.ICON_SIZE_MENU)
     313            self._toggle_state_item.set_image(icon)           
    286314
    287315        elif self._current_state == _GSM_STATE_CONNECTED:
    288316            self._toggle_state_item.get_child().set_label(_('Disconnect'))
    289             self.props.secondary_text = _('Connected')
    290            
    291         elif self._current_state == _GSM_STATE_NEED_AUTH:
    292             self._toggle_state_item.get_child().set_label(_('Sim requires Pin/Puk'))
    293             self.props.secondary_text = _('Authentication Error')
    294            
     317            self.update_connection_time()
     318            icon = Icon(icon_name='media-eject', \
     319                        icon_size=gtk.ICON_SIZE_MENU)
     320            self._toggle_state_item.set_image(icon)
     321                       
     322        elif self._current_state == _GSM_STATE_FAILED:
     323            message_error = self._get_error_by_nm_reason(reason)
     324            self.add_alert(_('Error: %s') % message_error[0], \
     325                           message_error[1])
    295326        else:
    296327            raise ValueError('Invalid GSM state while updating label and ' \
    297328                             'text, %s' % str(self._current_state))
    298 
     329   
     330    def add_alert(self, title, message):
     331        self._alert = True
     332        self.props.secondary_text = _("Connection Error")
     333        self._error_accept_item.get_child().set_label(title)
     334        self._error_accept_item.show()
     335        self.error_description_label.set_text(message)
     336        self.error_description_label.show()
     337        self._toggle_state_item.set_sensitive(False)
     338
     339    def __error_accept_cb(self, alert):
     340        self._alert = False
     341        self._update_label_and_text()
     342        self._error_accept_item.get_child().set_label('')
     343        self._error_accept_item.hide()
     344        self.error_description_label.hide()
     345        self._toggle_state_item.set_sensitive(True)
     346        self._full_request = [0, 0]
     347                       
     348    def update_connection_time(self, connection_time=None):
     349        if (connection_time is not None):
     350            self.props.secondary_text = _('Connected for ' + \
     351                                      connection_time.strftime('%H:%M:%S'))
     352        else:
     353            self.props.secondary_text = _('Connected for ' \
     354                                          + '00:00:00')
     355             
     356    def update_stats(self, in_bytes, out_bytes):
     357        in_KBytes = in_bytes / 1024
     358        out_KBytes = out_bytes / 1024
     359        self._data_label_up.set_text(_("%d KB") % (out_KBytes))
     360        self._data_label_down.set_text(_("%d KB") % (in_KBytes))
     361       
     362    def _get_error_by_nm_reason(self, reason):
     363        if reason in [network.NM_DEVICE_STATE_REASON_NO_SECRETS, network.NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED]:
     364            message = _('Suggestion: Check your Pin/Puk configuration.')
     365        elif reason in [network.NM_DEVICE_STATE_REASON_PPP_DISCONNECT, network.NM_DEVICE_STATE_REASON_PPP_FAILED]:
     366            message = _('Suggestion: Check your Access Point Name (APN) configuration')
     367        elif reason in [network.NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER, network.NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT]:
     368            message = _('Suggestion: Check the Number configuration.')
     369        else:
     370            message = ''
     371        message_tuple = (network.NM_DEVICE_STATE_REASON_DESCRIPTION[reason], message)
     372        return message_tuple
     373   
    299374    def __toggle_state_cb(self, menuitem):
    300375        if self._current_state == _GSM_STATE_NOT_READY:
    301376            pass
    class GsmPalette(Palette): 
    305380            self.emit('gsm-disconnect')
    306381        elif self._current_state == _GSM_STATE_CONNECTED:
    307382            self.emit('gsm-disconnect')
    308         elif self._current_state == _GSM_STATE_NEED_AUTH:
    309             self.emit('gsm-disconnect')
    310383        else:
    311384            raise ValueError('Invalid GSM state while emitting signal, %s' % \
    312385                             str(self._current_state))
    313 
     386           
    314387
    315388class WirelessDeviceView(ToolButton):
    316389
    class GsmDeviceView(TrayIcon): 
    747820                                      signal_name='PppStats',
    748821                                      path=self._device.object_path,
    749822                                      dbus_interface=_NM_SERIAL_IFACE)
     823       
    750824    def create_palette(self):
    751825        palette = GsmPalette()
    752826
    class GsmDeviceView(TrayIcon): 
    774848                                        '/',
    775849                                        reply_handler=self.__connect_cb,
    776850                                        error_handler=self.__connect_error_cb)
     851        else:
     852            self._palette.add_alert(_('Connection Error'), \
     853                                    _('There is no gsm connection available'))
    777854
    778855    def __connect_cb(self, active_connection):
    779856        logging.debug('Connected successfully to gsm device, %s',
    class GsmDeviceView(TrayIcon): 
    807884
    808885    def __state_changed_cb(self, new_state, old_state, reason):
    809886        logging.debug('State: %s to %s, reason %s', old_state, new_state, reason)
    810         self._update_state(int(new_state))
     887        self._update_state(int(new_state), int(old_state), int(reason))
    811888
    812889    def __current_state_check_cb(self, properties):
    813         self._update_state(int(properties['State']))
     890        self._update_state(int(properties['State']), 0, 0)
    814891
    815892    def __current_state_check_error_cb(self, error):
    816893        raise RuntimeError('Error when checking gsm device state, %s' % error)
    817894
    818     def _update_state(self, state):
     895    def _update_state(self, state, old_state, reason):
    819896        gsm_state = None
    820897
    821898        if state is network.DEVICE_STATE_ACTIVATED:
    class GsmDeviceView(TrayIcon): 
    823900            connection = network.find_gsm_connection()
    824901            if connection is not None:
    825902                connection.set_connected()
    826                 self._connection_timestamp =  time.time() - \
     903                self._connection_timestamp = time.time() - \
    827904                        connection.get_settings().connection.timestamp
    828905                self._connection_time_handler = gobject.timeout_add_seconds( \
    829906                        1, self.__connection_timecount_cb)
    830                 self._update_stats(0, 0)
    831                 self._update_connection_time()               
    832                 self._palette.info_box.show()
     907                self._palette.update_connection_time()               
     908                self._palette.update_stats(0, 0)
     909                if self._palette is not None:     
     910                    self._palette.connection_info_box.show()
    833911
    834912        elif state is network.DEVICE_STATE_DISCONNECTED:
    835913            gsm_state = _GSM_STATE_DISCONNECTED
    836914            self._connection_timestamp = 0
    837915            if self._connection_time_handler is not None:
    838916                gobject.source_remove(self._connection_time_handler)
    839             self._palette.info_box.hide()
     917            if self._palette is not None:
     918                self._palette.connection_info_box.hide()
    840919
    841920        elif state in [network.DEVICE_STATE_UNMANAGED,
    842921                       network.DEVICE_STATE_UNAVAILABLE,
    class GsmDeviceView(TrayIcon): 
    845924
    846925        elif state in [network.DEVICE_STATE_PREPARE,
    847926                       network.DEVICE_STATE_CONFIG,
    848                        network.DEVICE_STATE_IP_CONFIG]:
     927                       network.DEVICE_STATE_IP_CONFIG,
     928                       network.DEVICE_STATE_NEED_AUTH]:
    849929            gsm_state = _GSM_STATE_CONNECTING
    850            
    851         elif state in [network.DEVICE_STATE_NEED_AUTH]:
    852             gsm_state = _GSM_STATE_NEED_AUTH
     930
     931        elif state == network.DEVICE_STATE_FAILED:
     932            gsm_state = _GSM_STATE_FAILED
    853933           
    854934        if self._palette is not None:
    855             self._palette.set_state(gsm_state)
     935            self._palette.set_state(gsm_state, reason)
    856936
    857937    def disconnect(self):
    858938        self._bus.remove_signal_receiver(self.__state_changed_cb,
    class GsmDeviceView(TrayIcon): 
    861941                                         dbus_interface=_NM_DEVICE_IFACE)
    862942
    863943    def __ppp_stats_changed_cb(self, in_bytes, out_bytes):
    864         self._update_stats(in_bytes, out_bytes)
    865 
    866     def _update_stats(self, in_bytes, out_bytes):
    867         in_KBytes = in_bytes / 1024
    868         out_KBytes = out_bytes / 1024
    869         text = _("Data sent %d KB / received %d KB") % (out_KBytes, in_KBytes)
    870         self._palette.data_label.set_text(text)
     944        self._palette.update_stats(in_bytes, out_bytes)
    871945
    872946    def __connection_timecount_cb(self):
    873947        self._connection_timestamp = self._connection_timestamp + 1
    874         self._update_connection_time()
     948        connection_time = \
     949            datetime.datetime.fromtimestamp(self._connection_timestamp)
     950        self._palette.update_connection_time(connection_time)
    875951        return True
    876952
    877     def _update_connection_time(self):
    878         connection_time = datetime.datetime.fromtimestamp( \
    879                 self._connection_timestamp)
    880         text = _("Connection time ") + connection_time.strftime('%H : %M : %S')
    881         self._palette.connection_time_label.set_text(text)
    882953
     954   
    883955class WirelessDeviceObserver(object):
    884956    def __init__(self, device, tray, device_type):
    885957        self._device = device
    class WiredDeviceObserver(object): 
    9501022                del self._device_view
    9511023                self._device_view = None
    9521024
     1025
    9531026class GsmDeviceObserver(object):
    9541027    def __init__(self, device, tray):
    9551028        self._device = device
  • src/jarabe/model/network.py

    diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
    index 3a949da..04391f8 100644
    a b  
    1818# along with this program; if not, write to the Free Software
    1919# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2020
     21from gettext import gettext as _
    2122import logging
    2223import os
    2324import time
    NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0 
    5455NM_ACTIVE_CONNECTION_STATE_ACTIVATING = 1
    5556NM_ACTIVE_CONNECTION_STATE_ACTIVATED = 2
    5657
     58
     59NM_DEVICE_STATE_REASON_UNKNOWN = 0
     60NM_DEVICE_STATE_REASON_NONE = 1
     61NM_DEVICE_STATE_REASON_NOW_MANAGED = 2
     62NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3
     63NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4
     64NM_DEVICE_STATE_REASON_CONFIG_UNAVAILABLE = 5
     65NM_DEVICE_STATE_REASON_CONFIG_EXPIRED = 6
     66NM_DEVICE_STATE_REASON_NO_SECRETS = 7
     67NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8
     68NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9
     69NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED = 10
     70NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT = 11
     71NM_DEVICE_STATE_REASON_PPP_START_FAILED = 12
     72NM_DEVICE_STATE_REASON_PPP_DISCONNECT = 13
     73NM_DEVICE_STATE_REASON_PPP_FAILED = 14
     74NM_DEVICE_STATE_REASON_DHCP_START_FAILED = 15
     75NM_DEVICE_STATE_REASON_DHCP_ERROR = 16
     76NM_DEVICE_STATE_REASON_DHCP_FAILED = 17
     77NM_DEVICE_STATE_REASON_SHARED_START_FAILED = 18
     78NM_DEVICE_STATE_REASON_SHARED_FAILED = 19
     79NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED = 20
     80NM_DEVICE_STATE_REASON_AUTOIP_ERROR = 21
     81NM_DEVICE_STATE_REASON_AUTOIP_FAILED = 22
     82NM_DEVICE_STATE_REASON_MODEM_BUSY = 23
     83NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE = 24
     84NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER = 25
     85NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT = 26
     86NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED = 27
     87NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED = 28
     88NM_DEVICE_STATE_REASON_GSM_APN_FAILED = 29
     89NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING = 30
     90NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED = 31
     91NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT = 32
     92NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED = 33
     93NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED = 34
     94NM_DEVICE_STATE_REASON_FIRMWARE_MISSING = 35
     95NM_DEVICE_STATE_REASON_REMOVED = 36
     96NM_DEVICE_STATE_REASON_SLEEPING = 37
     97NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38
     98NM_DEVICE_STATE_REASON_USER_REQUESTED = 39
     99NM_DEVICE_STATE_REASON_CARRIER = 40
     100
     101
     102
     103NM_DEVICE_STATE_REASON_DESCRIPTION = {
     104    NM_DEVICE_STATE_REASON_UNKNOWN: \
     105        _("The reason for the device state change \ is unknown"),
     106    NM_DEVICE_STATE_REASON_NONE: \
     107        _("The state change is normal."),
     108    NM_DEVICE_STATE_REASON_NOW_MANAGED: \
     109        _("The device is now managed."),
     110    NM_DEVICE_STATE_REASON_NOW_UNMANAGED: \
     111        _("The device is no longer managed."),
     112    NM_DEVICE_STATE_REASON_CONFIG_FAILED: \
     113        _("The device could not be readied for configuration."),
     114    NM_DEVICE_STATE_REASON_CONFIG_UNAVAILABLE : \
     115         _("IP configuration could not be reserved \
     116         (no available address, timeout, etc)."),
     117    NM_DEVICE_STATE_REASON_CONFIG_EXPIRED : \
     118        _("The IP configuration is no longer valid."),
     119    NM_DEVICE_STATE_REASON_NO_SECRETS : \
     120        _("Secrets were required, but not provided."),
     121    NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT : \
     122        _("The 802.1X supplicant disconnected from \
     123         the access point or authentication server."),
     124    NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED : \
     125         _("Configuration of the 802.1X supplicant failed."),
     126    NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED : \
     127        _("The 802.1X supplicant quit or failed unexpectedly."),
     128    NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT : \
     129        _("The 802.1X supplicant took too long to authenticate."),
     130    NM_DEVICE_STATE_REASON_PPP_START_FAILED : \
     131        _("The PPP service failed to start within the allowed time."),
     132    NM_DEVICE_STATE_REASON_PPP_DISCONNECT : \
     133        _("The PPP service disconnected unexpectedly."),
     134    NM_DEVICE_STATE_REASON_PPP_FAILED : \
     135        _("The PPP service quit or failed unexpectedly."),
     136    NM_DEVICE_STATE_REASON_DHCP_START_FAILED : \
     137         _("The DHCP service failed to start within the allowed time."),
     138    NM_DEVICE_STATE_REASON_DHCP_ERROR : \
     139         _("The DHCP service reported an unexpected error"),
     140    NM_DEVICE_STATE_REASON_DHCP_FAILED : \
     141        _("The DHCP service quit or failed unexpectedly."),
     142    NM_DEVICE_STATE_REASON_SHARED_START_FAILED : \
     143         _("The shared connection service failed to start."),
     144    NM_DEVICE_STATE_REASON_SHARED_FAILED : \
     145         _("The shared connection service quit or failed unexpectedly"),
     146    NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED : \
     147        _("The AutoIP service failed to start."),
     148    NM_DEVICE_STATE_REASON_AUTOIP_ERROR :
     149        _("The AutoIP service reported an unexpected error."),
     150    NM_DEVICE_STATE_REASON_AUTOIP_FAILED : \
     151         _("The AutoIP service quit or failed unexpectedly."),
     152    NM_DEVICE_STATE_REASON_MODEM_BUSY : \
     153         _("Dialing failed because the line was busy."),
     154    NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE : \
     155         _("Dialing failed because there was no dial tone.  "),
     156    NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER : \
     157        _("Dialing failed because there was carrier."),
     158    NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT : \
     159        _("Dialing timed out."),
     160    NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED : \
     161        _("Dialing failed."),
     162    NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED : \
     163        _("Modem initialization failed."),
     164    NM_DEVICE_STATE_REASON_GSM_APN_FAILED : \
     165        _("Failed to select the specified GSM APN."),
     166    NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING : \
     167        _("Not searching for networks."),
     168    NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED : \
     169        _("Network registration was denied."),
     170    NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT : \
     171        _("Network registration timed out."),
     172    NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED : \
     173        _("Failed to register with the requested GSM network."),
     174    NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED : \
     175        _("PIN check failed."),
     176    NM_DEVICE_STATE_REASON_FIRMWARE_MISSING : \
     177        _("Necessary firmware for the device may be missing."),
     178    NM_DEVICE_STATE_REASON_REMOVED : \
     179        _("The device was removed."),
     180    NM_DEVICE_STATE_REASON_SLEEPING : \
     181        _("NetworkManager went to sleep."),
     182    NM_DEVICE_STATE_REASON_CONNECTION_REMOVED : \
     183        _("The device's active connection was removed or disappeared."),
     184    NM_DEVICE_STATE_REASON_USER_REQUESTED :
     185        _("A user or client requested the disconnection."),
     186    NM_DEVICE_STATE_REASON_CARRIER :
     187        _("The device's carrier/link changed.")
     188}
     189
    57190NM_802_11_AP_FLAGS_NONE = 0x00000000
    58191NM_802_11_AP_FLAGS_PRIVACY = 0x00000001
    59192
    class NMSettingsConnection(dbus.service.Object): 
    444577    def GetSecrets(self, setting_name, hints, request_new, reply, error):
    445578        logging.debug('Secrets requested for connection %s request_new=%s',
    446579            self.path, request_new)
    447         if request_new or self._secrets is None:
    448             # request_new is for example the case when the pw on the AP changes
    449             response = SecretsResponse(self, reply, error)
    450             try:
    451                 self.secrets_request.send(self, response=response)
    452             except Exception:
    453                 logging.exception('Error requesting the secrets via dialog')
    454         else:
    455             reply(self._secrets.get_dict())
    456 
    457 
     580        if self._settings.connection.type is not 'gsm':
     581                if request_new or self._secrets is None:
     582                    # request_new is for example the case when the pw on the AP changes
     583                    response = SecretsResponse(self, reply, error)
     584                    try:
     585                        self.secrets_request.send(self, response=response)
     586                    except Exception:
     587                        logging.exception('Error requesting the secrets via dialog')
     588                else:
     589                    reply(self._secrets.get_dict())
     590        else:
     591                if not request_new:
     592                    reply(self._secrets.get_dict())
     593                else:
     594                    raise Exception('The stored GSM secret has already been supplied ')
     595                   
    458596class AccessPoint(gobject.GObject):
    459597    __gsignals__ = {
    460598        'props-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,