Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
authorAndrew Flegg <andrew@bleb.org>
Mon, 7 Jun 2010 06:55:32 +0000 (07:55 +0100)
committerAndrew Flegg <andrew@bleb.org>
Mon, 7 Jun 2010 06:55:32 +0000 (07:55 +0100)
informing the callback that a user-entered value is required to
continue.

package/src/org/maemo/hermes/engine/__init__.py
package/src/org/maemo/hermes/engine/linkedin/api.py
package/src/org/maemo/hermes/gui/console.py
package/src/org/maemo/hermes/gui/gtkui.py

index 5067091..d896b86 100644 (file)
@@ -20,8 +20,11 @@ class Hermes:
              need_auth() - called to indicate an external login is about to occur.
                            The user should be informed.
                            
-             block_for_auth() - prompt the user to take some action once they have
-                                successfully logged in to Facebook.
+             block_for_auth(prompt = False) - prompt the user to take some action
+                                once they have successfully logged in via the
+                                external login. If 'prompt' is true, a text entry
+                                box will be shown and the user-entered value returned.
+                                If the user cancels the dialogue, None is returned.
                               
              progress(i, j) - the application is currently processing friend 'i' of
                               'j'. Should be used to provide the user a progress bar.
index 7188214..19b7785 100644 (file)
@@ -44,11 +44,12 @@ class LinkedInApi():
         self._verify_access_token()
         
 
+    # -----------------------------------------------------------------------
     def authenticate(self, need_auth, block_for_auth):
         need_auth()
         token = self._get_request_token()
         url = self._get_authorize_url(token)
-        verifier = block_for_auth(url)
+        verifier = block_for_auth(True)
         self._verify_verifier(verifier)
     
     
index 8b4f887..be8e56f 100644 (file)
@@ -10,8 +10,8 @@ class ConsoleUICallback:
         print 'Need authentication...'
 
     # -----------------------------------------------------------------------
-    def block_for_auth(self):
-        print 'Press enter when logged in...'
+    def block_for_auth(self, prompt = False):
+        print 'Press enter when logged in...', prompt
         raw_input()
     
     # -----------------------------------------------------------------------
index 79b9fa4..54567ff 100644 (file)
@@ -176,30 +176,40 @@ class HermesGUI(WimpWorks):
         """Part of the GUI callback API."""
         
         if main:
-            hildon.hildon_banner_show_information(self.main_window, '', _("Need to authenticate with Facebook"))
+            hildon.hildon_banner_show_information(self.main_window, '', _("Need to authenticate via browser"))
         else:
             gobject.idle_add(self.need_auth, True)
       
     
     # -----------------------------------------------------------------------
-    def block_for_auth(self, main = False, lock = None):
+    def block_for_auth(self, prompt = False, main = False, lock = None):
         """Part of the GUI callback API."""
 
         if main:
-            note = gtk.Dialog(_('Facebook authorisation'), self.main_window)
+            note = gtk.Dialog(_('Service authorisation'), self.main_window)
             note.add_button(_("Validate"), gtk.RESPONSE_OK)
-            note.vbox.add(gtk.Label(_("\nPress 'Validate' once Facebook has\nbeen authenticated in web browser.\n")))
+            if prompt:
+                input = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT)
+                input.set_placeholder(_("Verification code from web browser"))
+                input.set_property('is-focus', False)
+                note.vbox.add(input)
+            else:
+                note.vbox.add(gtk.Label(_("\nPress 'Validate' once account has\nbeen authorised in web browser.\n")))
     
             note.show_all()
             result = note.run()
             note.hide()
             lock.release()
+            if prompt and result == gtk.RESPONSE_OK:
+                return input.get_text()
+            else:
+                return None
         
         else:
             time.sleep(2)
             lock = thread.allocate_lock()
             lock.acquire()
-            gobject.idle_add(self.block_for_auth, True, lock)
+            gobject.idle_add(self.block_for_auth, prompt, True, lock)
             lock.acquire()
             lock.release()
                       

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment