From: epage Date: Tue, 22 Jul 2008 23:05:27 +0000 (+0000) Subject: Some minor cleanups X-Git-Url: http://git.maemo.org/git/?a=commitdiff_plain;h=ef7b85b68735984caabdf4d43f4b79b23a216a20;p=gc-dialer Some minor cleanups git-svn-id: file:///svnroot/gc-dialer/trunk@107 c39d3808-3fe2-4d86-a59f-b7f623ee9f21 --- diff --git a/src/gc_dialer.py b/src/gc_dialer.py index 48691ba..5461b83 100755 --- a/src/gc_dialer.py +++ b/src/gc_dialer.py @@ -299,7 +299,8 @@ class Dialpad(object): self._phoneTypeSelector = PhoneTypeSelector(self._widgetTree, self._gcBackend) - self.attempt_login(2) + if not self._gcBackend.is_authed(): + self.attempt_login(2) gobject.idle_add(self._init_grandcentral) gobject.idle_add(self._init_recent_view) gobject.idle_add(self._init_contacts_view) @@ -419,12 +420,12 @@ class Dialpad(object): return False def attempt_login(self, numOfAttempts = 1): + """ + @note Assumes that you are already logged in + """ assert 0 < numOfAttempts, "That was pointless having 0 or less login attempts" dialog = self._widgetTree.get_widget("login_dialog") - if self._gcBackend.is_authed(): - return True - for i in range(numOfAttempts): dialog.run() @@ -581,7 +582,9 @@ class Dialpad(object): """ @todo Potential blocking on web access, maybe we should defer parts of this or put up a dialog? """ - loggedIn = self.attempt_login(2) + if not self._gcBackend.is_authed(): + loggedIn = self.attempt_login(2) + if not loggedIn or not self._gcBackend.is_authed() or self._gcBackend.get_callback_number() == "": self.display_error_message("Backend link with grandcentral is not working, please try again") warnings.warn("Backend Status: Logged in? %s, Authenticated? %s, Callback=%s" % (loggedIn, self._gcBackend.is_authed(), self._gcBackend.get_callback_number()), UserWarning, 2) diff --git a/src/gcbackend.py b/src/gcbackend.py index 55e8c2e..2341f91 100644 --- a/src/gcbackend.py +++ b/src/gcbackend.py @@ -243,12 +243,12 @@ class GCDialer(object): def get_contacts(self): contactsPagesUrls = [GCDialer._contactsURL] for contactsPageUrl in contactsPagesUrls: - print contactsPageUrl contactsPage = self._browser.download(contactsPageUrl) for contact_match in self._contactsRe.finditer(contactsPage): contactId = contact_match.group(1) contactName = contact_match.group(2) yield contactId, contactName + next_match = self._contactsNextRe.match(contactsPage) if next_match is not None: newContactsPageUrl = self._contactsURL + next_match.group(1)