1.0.8-6 Fixing a bug preventing christexaport from logging in
authorepage <eopage@byu.net>
Tue, 1 Dec 2009 00:40:44 +0000 (00:40 +0000)
committerepage <eopage@byu.net>
Tue, 1 Dec 2009 00:40:44 +0000 (00:40 +0000)
git-svn-id: file:///svnroot/gc-dialer/trunk@579 c39d3808-3fe2-4d86-a59f-b7f623ee9f21

src/backends/gv_backend.py
src/backends/null_backend.py
src/constants.py
src/dc_glade.py
support/builddeb.py

index bc98467..1a1fc1e 100644 (file)
@@ -31,6 +31,7 @@ import os
 import re
 import urllib
 import urllib2
+import cookielib
 import time
 import datetime
 import itertools
@@ -115,8 +116,17 @@ class GVDialer(object):
                if cookieFile is None:
                        cookieFile = os.path.join(os.path.expanduser("~"), ".gv_cookies.txt")
                self._browser.cookies.filename = cookieFile
-               if os.path.isfile(cookieFile):
+               try:
                        self._browser.cookies.load()
+                       self._loadedFromCookies = True
+               except cookielib.LoadError:
+                       _moduleLogger.exception("Bad cookie file")
+                       self._loadedFromCookies = False
+               except IOError:
+                       _moduleLogger.exception("No cookie file")
+                       self._loadedFromCookies = False
+               except Exception, e:
+                       self._loadedFromCookies = False
 
                self._token = ""
                self._accountNum = ""
@@ -166,6 +176,12 @@ class GVDialer(object):
                self._smsTimeRegex = re.compile(r"""<span class="gc-message-sms-time">(.*?)</span>""", re.MULTILINE | re.DOTALL)
                self._smsTextRegex = re.compile(r"""<span class="gc-message-sms-text">(.*?)</span>""", re.MULTILINE | re.DOTALL)
 
+       def is_quick_login_possible(self):
+               """
+               @returns True then is_authed might be enough to login, else full login is required
+               """
+               return self._loadedFromCookies or 0.0 < self._lastAuthed
+
        def is_authed(self, force = False):
                """
                Attempts to detect a current session
@@ -708,10 +724,10 @@ def test_backend(username, password):
        #       print contact
        #       pprint.pprint(list(backend.get_contact_details(contact[0])))
 
-       print "Messages: ",
-       for message in backend.get_messages():
-               message["messageParts"] = list(message["messageParts"])
-               pprint.pprint(message)
+       #print "Messages: ",
+       #for message in backend.get_messages():
+       #       message["messageParts"] = list(message["messageParts"])
+       #       pprint.pprint(message)
        #for message in sort_messages(backend.get_messages()):
        #       pprint.pprint(decorate_message(message))
 
@@ -796,5 +812,7 @@ def grab_debug_info(username, password):
 if __name__ == "__main__":
        import sys
        logging.basicConfig(level=logging.DEBUG)
-       #test_backend(sys.argv[1], sys.argv[2])
-       grab_debug_info(sys.argv[1], sys.argv[2])
+       if True:
+               grab_debug_info(sys.argv[1], sys.argv[2])
+       else:
+               test_backend(sys.argv[1], sys.argv[2])
index c07f724..4fca554 100644 (file)
@@ -25,6 +25,9 @@ class NullDialer(object):
        def __init__(self):
                pass
 
+       def is_quick_login_possible(self):
+               return False
+
        def is_authed(self, force = False):
                return False
 
index d4e9d2d..28004ff 100644 (file)
@@ -3,7 +3,7 @@ import os
 __pretty_app_name__ = "DialCentral"
 __app_name__ = "dialcentral"
 __version__ = "1.0.8"
-__build__ = 5
+__build__ = 6
 __app_magic__ = 0xdeadbeef
 _data_path_ = os.path.join(os.path.expanduser("~"), ".dialcentral")
 _user_settings_ = "%s/settings.ini" % _data_path_
index 22d7eee..9cc9899 100755 (executable)
@@ -416,12 +416,11 @@ class Dialcentral(object):
                @note Thread agnostic
                """
                loggedIn = False
-               if self._credentials == ("", ""):
-                       # Disallow logging in by cookie alone, without credentials
-                       loggedIn = False
 
-               if not loggedIn:
-                       loggedIn = self._phoneBackends[self._defaultBackendId].is_authed()
+               isQuickLoginPossible = self._phoneBackends[self._defaultBackendId].is_quick_login_possible()
+               if self._credentials != ("", "") and isQuickLoginPossible:
+                       if not loggedIn:
+                               loggedIn = self._phoneBackends[self._defaultBackendId].is_authed()
 
                if loggedIn:
                        _moduleLogger.info("Logged into %r through cookies" % self._phoneBackends[self._defaultBackendId])
index f2c6f5b..91cf21d 100755 (executable)
@@ -28,10 +28,13 @@ __build__ = constants.__build__
 __changelog__ = """
 1.0.8
 * Sped up login time by delay loading contact list
+* Sped up login when you do not have a cookie file (first launch)
 * Ability to narrow down messages either by type or status
 * Fremantle: Notification Support including testing of custom notifications
 * UI Tweak: Cut down the number of times the login dialog is needlessly displayed
 * Bug Fix: Switching to accounts tab when callback is blank
+* Bug Fix: Corrupt cookie files prevent login
+* Bug Fix: Logging in without credentials through cookies
 * Debugging: Log contents now accessible through Ctrl+l
 
 1.0.7