10 sys.path.append("../../src")
15 _forwardselectURL = "http://www.grandcentral.com/mobile/settings/forwarding_select"
16 _loginURL = "https://www.grandcentral.com/mobile/account/login"
17 _setforwardURL = "http://www.grandcentral.com/mobile/settings/set_forwarding?from=settings"
18 _clicktocallURL = "http://www.grandcentral.com/mobile/calls/click_to_call?a_t=%s&destno=%s"
19 _inboxallURL = "http://www.grandcentral.com/mobile/messages/inbox?types=all"
20 _contactsURL = "http://www.grandcentral.com/mobile/contacts"
21 _contactDetailURL = "http://www.grandcentral.com/mobile/contacts/detail"
23 ("forward", gc_backend.GCDialer._forwardselectURL),
24 ("login", gc_backend.GCDialer._loginURL),
25 ("setforward", gc_backend.GCDialer._setforwardURL),
26 ("clicktocall", gc_backend.GCDialer._clicktocallURL),
27 ("recent", gc_backend.GCDialer._inboxallURL),
28 ("contacts", gc_backend.GCDialer._contactsURL),
29 ("contactdetails", gc_backend.GCDialer._contactDetailURL),
33 browser = browser_emu.MozillaEmulator(1)
34 for name, url in webpages:
36 page = browser.download(url)
37 except StandardError, e:
40 with open("not_loggedin_%s.txt" % name, "w") as f:
43 username = sys.argv[1]
44 password = sys.argv[2]
46 loginPostData = urllib.urlencode({
49 'service': "grandcentral",
52 "PersistentCookie": "yes",
56 loginSuccessOrFailurePage = browser.download(gc_backend.GCDialer._loginURL, loginPostData)
57 except urllib2.URLError, e:
58 warnings.warn(traceback.format_exc())
59 raise RuntimeError("%s is not accesible" % gc_backend.GCDialer._loginURL)
61 forwardPage = browser.download(gc_backend.GCDialer._forwardURL)
63 tokenGroup = gc_backend.GCDialer._tokenRe.search(forwardPage)
64 if tokenGroup is None:
66 raise RuntimeError("Could not extract authentication token from GoogleVoice")
67 token = tokenGroup.group(1)
69 browser = browser_emu.MozillaEmulator(1)
70 for name, url in webpages:
72 #data = urllib.urlencode({
75 #page = browser.download(url, data)
76 page = browser.download(url)
77 except StandardError, e:
78 warnings.warn(traceback.format_exc())
80 print "Writing to file"
81 with open("loggedin_%s.txt" % name, "w") as f: