[Sugar-devel] [sugar 0.96, NM 0.9 PATCH] sl#3727: Return cached secrets, present in 'settings' themselves.

Ajay Garg ajay at activitycentral.com
Sun Jun 24 07:00:37 EDT 2012


NM may request the secrets in the following cases ::

a)
Wifi connection is lost.

b)
After being lost, the wifi connection is again within the range.

c)
When the credentials for the wifi network change.


In every case, secrets were being requested via the popup dialog.

However, case c) is rare (and when it does happens, usually the system-administrator, or the like,
has the responsibility for issuing the changes publically).

Thus, due to case c) (which is rare), cases a) and b) were suffering (these cases are generally
very plausible cases in everyday life).


So now, the intended solution is :::


1.
Always return the cached secrets (present in 'settings' themselves).
This would make the irritating dialog-box go away, for cases a) and b).


2.
For case c), the user would ::

    (i)   "Discard Network History".
    (ii)  Click on the wifi icon (in the neighborhood-view).
    (iii) Enter the new (publically broadcasted) credentials.



 src/jarabe/model/network.py |   34 ++++++++++++++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/jarabe/model/network.py b/src/jarabe/model/network.py
index cc02b58..d2f8656 100644
--- a/src/jarabe/model/network.py
+++ b/src/jarabe/model/network.py
@@ -591,8 +591,38 @@ class SecretAgent(dbus.service.Object):
         if uid != 0:
             raise Exception("UID %d not authorized" % (uid,))
 
-        response = SecretsResponse(reply, error)
-        self.secrets_request.send(self, settings=settings, response=response)
+        # http://bugs.sugarlabs.org/ticket/3727
+        # https://dev.laptop.org.au/issues/1305
+        #
+        # 1. See if the secrets are already present in the settings. If they are present,
+        #    do not re-prompt the user with the (irritating) popup dialog.
+        #
+        # 2. There might be the thought, as to why at all the 'GetSecrets' method is called
+        #    at first place, when the secrets are already a part of the settings. However,
+        #    that is the way it is - specifically, this method is called whenever the AP
+        #    is out of range. In that case, the  user must not be re-prompted with the
+        #    popup dialog.
+        if not self.are_secrets_present_in_settings(settings):
+            response = SecretsResponse(reply, error)
+            self.secrets_request.send(self, settings=settings, response=response)
+        else:
+            secrets = {}
+            secrets['802-11-wireless-security'] = settings['802-11-wireless-security']
+            reply(secrets)
+
+    def are_secrets_present_in_settings(self, settings):
+	# The secrets are present in the settings, if
+        #
+        # 1. 'settings' has a dict, keyed by '802-11-wireless-security' AND
+        #
+        # 2. settings['802-11-wireless-security']['key-mgmt'] is present AND
+        #
+        # 3. There is at least one more element in settings['802-11-wireless-security']
+        #    (in addition to settings['802-11-wireless-security']['key-mgmt'].
+        if ( '802-11-wireless-security' in settings.keys() ) and \
+           ( len(settings['802-11-wireless-security']) > 1 ):
+            return True
+        return False
 
 
 class AccessPoint(gobject.GObject):
-- 
1.7.10.2



More information about the Sugar-devel mailing list