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.
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)
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()
# -----------------------------------------------------------------------
"""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()