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)
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()
"""
@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)
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)