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

Ajay Garg ajay at activitycentral.com
Wed Jun 27 05:00:04 EDT 2012


Changes of version-2 over version-1 ::
======================================

* Adding comparative analysis of the behaviour
  netween Gnome-F14, Sugar-F14, Gnome-F17, Sugar-F17.

* Note that there is no change of code.




=========================================================================================================================



For providing the explanation, let's do a comparative analysis of the behaviour
netween Gnome-F14, Sugar-F14, Gnome-F17, Sugar-F17.

Note that the bahaviour (especially on Sugar-F17) is WITHOUT applying this patch.


======================================================================================================================================================
S.No.||       Environment         ||            Action         ||      Gnome-F14     ||     Sugar-F14     ||     Gnome-F17     ||      Sugar-F17
=====================================================================================================================================================
     ||                           ||                           ||                    ||                   ||                   ||
1.   ||  No connection attempt    ||  CORRECT credentials are  ||    Connection is   ||   Connection is   ||   Connection is   ||   Connection is 
     ||  has been made. Wifi AP   ||  entered on first popup.  ||     successful.    ||     successful.   ||     successful.   ||    successfull.
     ||  is within range.         ||                           ||                    ||                   ||                   ||
     ||                           ||                           ||                    ||                   ||                   ||
=====================================================================================================================================================
     ||                           ||                           ||                    ||                   ||                   ||
2.   ||  No connection attempt    || INCORRECT credentials are ||    Connection is   ||   Connection is   ||   Connection is   ||   Connection is
     ||  has been made. Wifi AP   ||  entered on first popup.  ||    unsuccessful.   ||   unsuccessful.   ||   unsuccessful.   ||   unsuccessful.
     ||  is within range.         ||                           ||  Popup re-appears, || Popup re-appears, || Popup DOES NOT re-|| Popup DOES NOT re-
     ||		                  ||			       ||  expecting secrets.|| expecting secrets.|| appear; NM keeps  || appear; NM keeps
     ||                           ||                           ||                    ||                   || trying with the   || trying with the 
     ||                           ||                           ||                    ||                   ||    (INCORRECT)    ||    (INCORRECT)
     || 	                  ||		               ||                    ||		          ||     secrets.      ||      secrets.
     ||                           ||                           ||                    ||                   ||                   ||
=====================================================================================================================================================
     ||                           ||                           ||                    ||                   ||                   ||
3.   ||  No connection attempt    ||  CORRECT credentials are  ||    Connection is   ||   Connection is   ||   Connection is   ||   Connection is
     ||  has been made. Wifi AP   ||  entered on first popup.  ||    unsuccessful.   ||   unsuccessful.   ||   unsuccessful.   ||   unsuccessful.
     ||  is NOT within range.     ||                           ||  Popup re-appears, || Popup re-appears, || Popup re-appears, || Popup re-appears,
     ||			          ||                           ||  expecting secrets.|| expecting secrets.|| expecting secrets.|| expecting secrets.
     ||                           ||                           ||                    ||                   ||                   ||
======================================================================================================================================================
     ||                           ||                           ||                    ||                   ||                   ||
4.   ||  No connection attempt    || INCORRECT credentials are ||    Connection is   ||   Connection is   ||   Connection is   ||   Connection is
     ||  has been made. Wifi AP   ||  entered on first popup.  ||    unsuccessful.   ||   unsuccessful.   ||   unsuccessful.   ||   unsuccessful.
     ||  is NOT within range.     ||                           ||  Popup re-appears, || Popup re-appears, || Popup re-appears, || Popup re-appears,
     ||			          ||                           ||  expecting secrets.|| expecting secrets.|| expecting secrets.|| expecting secrets.
     ||                           ||                           ||                    ||                   ||                   ||
====================================================================================================================================================
     ||                           ||                           ||                    ||                   ||                   ||
5.   ||  Wifi is out of range.    ||  Wifi comes within range. ||    Connection is   ||   Connection is   ||   Connection is   ||   Connection is
     ||  CORRECT credentials      ||                           ||     successful.    ||    successful.    ||    successful.    ||     successful.
     ||  have been provided on    ||			       ||                    ||                   ||                   ||
     ||  the last popup.          ||                           ||		     ||                   ||                   ||
     ||                           ||                           ||                    ||                   ||                   ||
====================================================================================================================================================
     ||                           ||                           ||                    ||                   ||                   ||
6.   ||  Wifi is out of range.    ||  Wifi comes within range. ||    Connection is   ||   Connection is   ||   Connection is   ||   Connection is
     ||  INCORRECT credentials    ||                           ||    unsuccessful.   ||   unsuccessful.   ||   unsuccessful.   ||   unsuccessful.
     ||  have been provided on    ||   			       ||  Popup re-appears, || Popup re-appears, || Popup DOES NOT re-|| Popup DOES NOT re-
     ||  the last popup.          ||			       ||  expecting secrets.|| expecting secrets.|| appear; NM keeps  || appear; NM keeps
     ||                           ||                           ||                    ||                   || trying with the   || trying with the 
     ||                           ||                           ||                    ||                   ||    (INCORRECT)    ||    (INCORRECT)
     ||			          ||			       ||                    ||                   ||	   secrets.    ||      secrets.
     ||                           ||                           ||                    ||                   ||                   ||
====================================================================================================================================================	      
     ||                           ||                           ||                    ||                   ||                   ||
7.   ||  Connection is connected. ||  Wifi goes out of range.  ||   Connection is    ||   Connection is   ||   Connection is   ||   Connection is    
     ||  (Obviously, Wifi is      ||                           ||   disconnected.    ||   disconnected.   ||   disconnected.   ||   disconnected.   
     ||   within range).          ||                           ||  Popup re-appears, || Popup re-appears, || Popup re-appears, || Popup re-appears,
     ||                           ||                           ||  expecting secrets.|| expecting secrets.|| expecting secrets.|| expecting secrets.
     ||                           ||                           ||                    ||                   ||                   ||
====================================================================================================================================================



Feelings ::
============


a)
Case 1 works as expected on all platforms.


b)
Case 2 works as expected on Gnome-F14 and Sugar-F14.
However, just the feeling that the behaviour is a bug on Gnome-F17 and Sugar-F17.


c)
Case 3 seems to be a bug on all platforms.
NM should keep trying with the same secrets, till the time AP comes in range.

THIS PATCH SOLVES THIS FOR GNOME-F17 AND SUGAR-F17.


d)
Case 4 is also a bug on all platforms.
NM should keep trying with the same (although incorrect) secrets, till the time AP comes in range.

THIS PATCH SOLVES THIS FOR GNOME-F17 AND SUGAR-F17.


e)
Case 5 works as expected on all platforms.


f)
Case 6 works as expected on Gnome-F14 and Sugar-F14.
However, just the feeling that the behaviour is a bug on Gnome-F17 and Sugar-F17.


g)
Case 7 seems to be a bug on all platforms.
NM should keep trying with the same secrets, till the time AP comes in range.

THIS PATCH SOLVES THIS FOR GNOME-F17 AND SUGAR-F17.




Conclusions ::
==============


1.
For Gnome-F17 and Sugar-F17, NM never ever pops up the dialog to re-enter the secrets, as long
as the wifi is within range.

Thus, entering wrong credentials is not an option.

If wrong options are entered (with AP having the capability to disable  access due to wrong
credentials), that would happen anyways - with or without this patch.


2.
What this patch does solve is the prevention of entering the same (correct/incorrect) credentials, 
whenever the wifi goes out of range.





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 (which appears
only when the  wifi  is out of range).


2.
Whenever the credentials need to changed,

    (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