"""
For org.freedesktop.telepathy.Connection
"""
+ self.StatusChanged(
+ telepathy.CONNECTION_STATUS_CONNECTING,
+ telepathy.CONNECTION_STATUS_REASON_REQUESTED
+ )
try:
- self.StatusChanged(
- telepathy.CONNECTION_STATUS_CONNECTING,
- telepathy.CONNECTION_STATUS_REASON_REQUESTED
- )
self._backend.login(*self._credentials)
+ except gv_backend.NetworkError:
self.StatusChanged(
- telepathy.CONNECTION_STATUS_CONNECTED,
- telepathy.CONNECTION_STATUS_REASON_REQUESTED
+ telepathy.CONNECTION_STATUS_DISCONNECTED,
+ telepathy.CONNECTION_STATUS_REASON_NETWORK_ERROR
)
except Exception:
self.StatusChanged(
telepathy.CONNECTION_STATUS_DISCONNECTED,
telepathy.CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED
)
+ else:
+ self.StatusChanged(
+ telepathy.CONNECTION_STATUS_CONNECTED,
+ telepathy.CONNECTION_STATUS_REASON_REQUESTED
+ )
def Disconnect(self):
"""
logging.info("Disconnected")
except Exception:
logging.exception("Disconnecting Failed")
+ self.StatusChanged(
+ telepathy.CONNECTION_STATUS_DISCONNECTED,
+ telepathy.CONNECTION_STATUS_REASON_REQUESTED
+ )
def RequestChannel(self, type, handleType, handleId, suppressHandler):
"""
return itertools.izip(*nIterators)
+class NetworkError(RuntimeError):
+ pass
+
+
class GVDialer(object):
"""
This class encapsulates all of the knowledge necessary to interact with the GoogleVoice servers
loginSuccessOrFailurePage = self._browser.download(self._loginURL, loginPostData)
except urllib2.URLError, e:
logging.exception(str(e))
- raise RuntimeError("%s is not accesible" % self._loginURL)
+ raise NetworkError("%s is not accesible" % self._loginURL)
return self.is_authed()
callSuccessPage = self._browser.download(self._clicktocallURL, clickToCallData, None, otherData)
except urllib2.URLError, e:
logging.exception(str(e))
- raise RuntimeError("%s is not accesible" % self._clicktocallURL)
+ raise NetworkError("%s is not accesible" % self._clicktocallURL)
if self._gvDialingStrRe.search(callSuccessPage) is None:
raise RuntimeError("Google Voice returned an error")
smsSuccessPage = self._browser.download(self._sendSmsURL, smsData, None, otherData)
except urllib2.URLError, e:
logging.exception(str(e))
- raise RuntimeError("%s is not accesible" % self._sendSmsURL)
+ raise NetworkError("%s is not accesible" % self._sendSmsURL)
return True
contactsPage = self._browser.download(contactsPageUrl)
except urllib2.URLError, e:
logging.exception(str(e))
- raise RuntimeError("%s is not accesible" % contactsPageUrl)
+ raise NetworkError("%s is not accesible" % contactsPageUrl)
for contact_match in self._contactsRe.finditer(contactsPage):
contactId = contact_match.group(1)
contactName = saxutils.unescape(contact_match.group(2))
detailPage = self._browser.download(self._contactDetailURL + '/' + contactId)
except urllib2.URLError, e:
logging.exception(str(e))
- raise RuntimeError("%s is not accesible" % self._contactDetailURL)
+ raise NetworkError("%s is not accesible" % self._contactDetailURL)
for detail_match in self._contactDetailPhoneRe.finditer(detailPage):
phoneNumber = detail_match.group(1)
voicemailPage = self._browser.download(self._voicemailURL)
except urllib2.URLError, e:
logging.exception(str(e))
- raise RuntimeError("%s is not accesible" % self._voicemailURL)
+ raise NetworkError("%s is not accesible" % self._voicemailURL)
voicemailHtml = self._grab_html(voicemailPage)
parsedVoicemail = self._parse_voicemail(voicemailHtml)
decoratedVoicemails = self._decorate_voicemail(parsedVoicemail)
smsPage = self._browser.download(self._smsURL)
except urllib2.URLError, e:
logging.exception(str(e))
- raise RuntimeError("%s is not accesible" % self._smsURL)
+ raise NetworkError("%s is not accesible" % self._smsURL)
smsHtml = self._grab_html(smsPage)
parsedSms = self._parse_sms(smsHtml)
decoratedSms = self._decorate_sms(parsedSms)
flatXml = self._browser.download(url)
except urllib2.URLError, e:
logging.exception(str(e))
- raise RuntimeError("%s is not accesible" % url)
+ raise NetworkError("%s is not accesible" % url)
allRecentHtml = self._grab_html(flatXml)
allRecentData = self._parse_voicemail(allRecentHtml)