Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorlatu <latu@localhost.localdomain>2010-02-11 12:43:52 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2010-02-15 19:36:55 (GMT)
commit2d968cc618425867b6544f55c3ff059286d974cc (patch)
tree2e66c91b75df0ce78ed329ae4554468e8820fd85 /extensions
parentc811d3291b90e8a81aa23e56f5a387e6e643caaf (diff)
Pin Puk Configuration
Diffstat (limited to 'extensions')
-rwxr-xr-x[-rw-r--r--]extensions/cpsection/modemconfiguration/model.py19
-rw-r--r--extensions/cpsection/modemconfiguration/view.py51
-rw-r--r--extensions/deviceicon/network.py14
3 files changed, 76 insertions, 8 deletions
diff --git a/extensions/cpsection/modemconfiguration/model.py b/extensions/cpsection/modemconfiguration/model.py
index f96e88f..2545ce1 100644..100755
--- a/extensions/cpsection/modemconfiguration/model.py
+++ b/extensions/cpsection/modemconfiguration/model.py
@@ -17,7 +17,8 @@
import gconf
from jarabe.model.network import GSM_USERNAME_PATH, GSM_PASSWORD_PATH, \
- GSM_NUMBER_PATH, GSM_APN_PATH
+ GSM_NUMBER_PATH, GSM_APN_PATH, GSM_PIN_PATH, \
+ GSM_PUK_PATH
def get_username():
client = gconf.client_get_default()
@@ -35,6 +36,14 @@ def get_apn():
client = gconf.client_get_default()
return client.get_string(GSM_APN_PATH) or ''
+def get_pin():
+ client = gconf.client_get_default()
+ return client.get_string(GSM_PIN_PATH) or ''
+
+def get_puk():
+ client = gconf.client_get_default()
+ return client.get_string(GSM_PUK_PATH) or ''
+
def set_username(username):
client = gconf.client_get_default()
client.set_string(GSM_USERNAME_PATH, username)
@@ -51,3 +60,11 @@ def set_apn(apn):
client = gconf.client_get_default()
client.set_string(GSM_APN_PATH, apn)
+def set_pin(pin):
+ client = gconf.client_get_default()
+ client.set_string(GSM_PIN_PATH, pin)
+
+def set_puk(puk):
+ client = gconf.client_get_default()
+ client.set_string(GSM_PUK_PATH, puk)
+
diff --git a/extensions/cpsection/modemconfiguration/view.py b/extensions/cpsection/modemconfiguration/view.py
index d66f1d5..2445005 100644
--- a/extensions/cpsection/modemconfiguration/view.py
+++ b/extensions/cpsection/modemconfiguration/view.py
@@ -94,7 +94,7 @@ class UsernameEntry(EntryWithLabel):
return self._model.get_username()
def set_value(self, username):
- return self._model.set_username(username)
+ self._model.set_username(username)
class PasswordEntry(EntryWithLabel):
def __init__(self, model):
@@ -105,7 +105,7 @@ class PasswordEntry(EntryWithLabel):
return self._model.get_password()
def set_value(self, password):
- return self._model.set_password(password)
+ self._model.set_password(password)
class NumberEntry(EntryWithLabel):
def __init__(self, model):
@@ -116,7 +116,7 @@ class NumberEntry(EntryWithLabel):
return self._model.get_number()
def set_value(self, number):
- return self._model.set_number(number)
+ self._model.set_number(number)
class ApnEntry(EntryWithLabel):
def __init__(self, model):
@@ -127,7 +127,30 @@ class ApnEntry(EntryWithLabel):
return self._model.get_apn()
def set_value(self, apn):
- return self._model.set_apn(apn)
+ self._model.set_apn(apn)
+
+class PinEntry(EntryWithLabel):
+ def __init__(self, model):
+ EntryWithLabel.__init__(self, _('PIN:'))
+ self._model = model
+
+ def get_value(self):
+ return self._model.get_pin()
+
+ def set_value(self, pin):
+ self._model.set_pin(pin)
+
+class PukEntry(EntryWithLabel):
+ def __init__(self, model):
+ EntryWithLabel.__init__(self, _('PUK:'))
+ self._model = model
+
+ def get_value(self):
+ return self._model.get_puk()
+
+ def set_value(self, puk):
+ self._model.set_puk(puk)
+
class ModemConfiguration(SectionView):
def __init__(self, model, alerts=None):
@@ -163,6 +186,18 @@ class ModemConfiguration(SectionView):
self.pack_start(self._apn_entry, expand=False)
self._apn_entry.show()
+ self._pin_entry = PinEntry(model)
+ self._pin_entry.connect('notify::is-valid',
+ self.__notify_is_valid_cb)
+ self.pack_start(self._pin_entry, expand=False)
+ self._pin_entry.show()
+
+ self._puk_entry = PukEntry(model)
+ self._puk_entry.connect('notify::is-valid',
+ self.__notify_is_valid_cb)
+ self.pack_start(self._puk_entry, expand=False)
+ self._puk_entry.show()
+
self.setup()
def setup(self):
@@ -170,6 +205,8 @@ class ModemConfiguration(SectionView):
self._password_entry.set_text_from_model()
self._number_entry.set_text_from_model()
self._apn_entry.set_text_from_model()
+ self._pin_entry.set_text_from_model()
+ self._puk_entry.set_text_from_model()
self.needs_restart = False
@@ -180,8 +217,10 @@ class ModemConfiguration(SectionView):
if self._username_entry.is_valid and \
self._password_entry.is_valid and \
self._number_entry.is_valid and \
- self._apn_entry.is_valid:
- self.props.is_valid = True
+ self._apn_entry.is_valid and \
+ self._pin_entry.is_valid and \
+ self._puk_entry.is_valid:
+ self.props.is_valid = True
else:
self.props.is_valid = False
diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index 6b60edf..94a4293 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -63,6 +63,7 @@ _GSM_STATE_NOT_READY = 0
_GSM_STATE_DISCONNECTED = 1
_GSM_STATE_CONNECTING = 2
_GSM_STATE_CONNECTED = 3
+_GSM_STATE_NEED_AUTH = 4
def frequency_to_channel(frequency):
ftoc = { 2412: 1, 2417: 2, 2422: 3, 2427: 4,
@@ -286,6 +287,11 @@ class GsmPalette(Palette):
elif self._current_state == _GSM_STATE_CONNECTED:
self._toggle_state_item.get_child().set_label(_('Disconnect'))
self.props.secondary_text = _('Connected')
+
+ elif self._current_state == _GSM_STATE_NEED_AUTH:
+ self._toggle_state_item.get_child().set_label(_('Sim requires Pin/Puk'))
+ self.props.secondary_text = _('Authentication Error')
+
else:
raise ValueError('Invalid GSM state while updating label and ' \
'text, %s' % str(self._current_state))
@@ -299,6 +305,8 @@ class GsmPalette(Palette):
self.emit('gsm-disconnect')
elif self._current_state == _GSM_STATE_CONNECTED:
self.emit('gsm-disconnect')
+ elif self._current_state == _GSM_STATE_NEED_AUTH:
+ self.emit('gsm-disconnect')
else:
raise ValueError('Invalid GSM state while emitting signal, %s' % \
str(self._current_state))
@@ -798,6 +806,7 @@ class GsmDeviceView(TrayIcon):
raise RuntimeError('Error when disconnecting gsm device, %s' % error)
def __state_changed_cb(self, new_state, old_state, reason):
+ logging.debug('State: %s to %s, reason %s', old_state, new_state, reason)
self._update_state(int(new_state))
def __current_state_check_cb(self, properties):
@@ -838,7 +847,10 @@ class GsmDeviceView(TrayIcon):
network.DEVICE_STATE_CONFIG,
network.DEVICE_STATE_IP_CONFIG]:
gsm_state = _GSM_STATE_CONNECTING
-
+
+ elif state in [network.DEVICE_STATE_NEED_AUTH]:
+ gsm_state = _GSM_STATE_NEED_AUTH
+
if self._palette is not None:
self._palette.set_state(gsm_state)