Various bug fixes
authorepage <eopage@byu.net>
Tue, 18 Aug 2009 02:55:49 +0000 (02:55 +0000)
committerepage <eopage@byu.net>
Tue, 18 Aug 2009 02:55:49 +0000 (02:55 +0000)
git-svn-id: file:///svnroot/gc-dialer/trunk@394 c39d3808-3fe2-4d86-a59f-b7f623ee9f21

src/alarm_handler.py
src/alarm_notify.py
src/dc_glade.py
src/gc_views.py
src/null_views.py
support/builddeb.py

index bccd37f..6de0aec 100644 (file)
@@ -12,7 +12,7 @@ class AlarmHandler(object):
 
        _INVALID_COOKIE = -1
        _TITLE = "Dialcentral Notifications"
-       _LAUNCHER = os.abspath(os.path.join(os.path.dirname(__file__), "alarm_notify.py"))
+       _LAUNCHER = os.path.abspath(os.path.join(os.path.dirname(__file__), "alarm_notify.py"))
        _REPEAT_FOREVER = -1
        _DEFAULT_FLAGS = (
                alarmd.ALARM_EVENT_NO_DIALOG |
index c56e2ba..9cb42b8 100755 (executable)
@@ -11,24 +11,31 @@ import gv_backend
 
 def get_missed(backend):
        missedPage = backend._browser.download(backend._missedCallsURL)
-       missedJson = pprint.pformat(backend._grab_json(missedPage))
+       missedJson = backend._grab_json(missedPage)
        return missedJson
 
 
 def get_voicemail(backend):
        voicemailPage = backend._browser.download(backend._voicemailURL)
-       voicemailJson = pprint.pformat(backend._grab_json(voicemailPage))
+       voicemailJson = backend._grab_json(voicemailPage)
        return voicemailJson
 
 
 def get_sms(backend):
        smsPage = backend._browser.download(backend._smsURL)
-       smsJson = pprint.pformat(backend._grab_json(smsPage))
+       smsJson = backend._grab_json(smsPage)
        return smsJson
 
 
-def is_changed(backend, type, get_material):
-       currentMaterial = get_material(backend)
+def remove_reltime(data):
+       for messageData in data["messages"].itervalues():
+               del messageData["relativeStartTime"]
+
+
+def is_type_changed(backend, type, get_material):
+       jsonMaterial = get_material(backend)
+       unreadCount = jsonMaterial["unreadCounts"][type]
+
        previousSnapshotPath = os.path.join(constants._data_path_, "snapshot_%s.old.json" % type)
        currentSnapshotPath = os.path.join(constants._data_path_, "snapshot_%s.json" % type)
 
@@ -42,25 +49,27 @@ def is_changed(backend, type, get_material):
                os.rename(currentSnapshotPath, previousSnapshotPath)
                previousExists = True
        except OSError, e:
-               # check if failed purely because the old file didn't exist, which is fine
+               # check if failed purely because the new old file didn't exist, which is fine
                if e.errno != 2:
                        raise
                previousExists = False
 
+       remove_reltime(jsonMaterial)
+       textMaterial = pprint.pformat(jsonMaterial)
        currentSnapshot = file(currentSnapshotPath, "w")
        try:
-               currentSnapshot.write(currentMaterial)
+               currentSnapshot.write(textMaterial)
        finally:
                currentSnapshot.close()
 
-       if not previousExists:
+       if unreadCount == 0 or not previousExists:
                return False
 
        seemEqual = filecmp.cmp(previousSnapshotPath, currentSnapshotPath)
        return not seemEqual
 
 
-def notify():
+def is_changed():
        gvCookiePath = os.path.join(constants._data_path_, "gv_cookies.txt")
        backend = gv_backend.GVDialer(gvCookiePath)
 
@@ -113,8 +122,13 @@ def notify():
 
        notifyUser = False
        for type, get_material in notifySources:
-               if is_changed(backend, type, get_material):
+               if is_type_changed(backend, type, get_material):
                        notifyUser = True
+       return notifyUser
+
+
+def notify_on_change():
+       notifyUser = is_changed()
 
        if notifyUser:
                import led_handler
@@ -123,4 +137,4 @@ def notify():
 
 
 if __name__ == "__main__":
-       notify()
+       notify_on_change()
index 0d86b80..4334acb 100755 (executable)
@@ -215,6 +215,10 @@ class Dialcentral(object):
                                self._alarmHandler = alarm_handler.AlarmHandler()
                        except ImportError:
                                alarm_handler = None
+                       except Exception:
+                               with gtk_toolbox.gtk_lock():
+                                       self._errorDisplay.push_exception()
+                               alarm_handler = None
                        if hildon is not None:
                                import led_handler
                                self._ledHandler = led_handler.LedHandler()
@@ -679,6 +683,10 @@ class Dialcentral(object):
 
        def _on_notebook_switch_page(self, notebook, page, pageIndex):
                self._reset_tab_refresh()
+
+               didRecentUpdate = False
+               didMessagesUpdate = False
+
                if pageIndex == self.RECENT_TAB:
                        didRecentUpdate = self._recentViews[self._selectedBackendId].update()
                elif pageIndex == self.MESSAGES_TAB:
@@ -794,13 +802,13 @@ def run_doctest():
 
 def run_dialpad():
        _lock_file = os.path.join(constants._data_path_, ".lock")
-       with gtk_toolbox.flock(_lock_file, 0):
-               gtk.gdk.threads_init()
+       #with gtk_toolbox.flock(_lock_file, 0):
+       gtk.gdk.threads_init()
 
-               if hildon is not None:
-                       gtk.set_application_name(constants.__pretty_app_name__)
-               handle = Dialcentral()
-               gtk.main()
+       if hildon is not None:
+               gtk.set_application_name(constants.__pretty_app_name__)
+       handle = Dialcentral()
+       gtk.main()
 
 
 class DummyOptions(object):
index 94a202e..5f48097 100644 (file)
@@ -589,6 +589,9 @@ class AccountInfo(object):
                self._onCallbackentryChangedId = self._callbackCombo.get_child().connect("changed", self._on_callbackentry_changed)
 
                if self._alarmHandler is not None:
+                       self._minutesEntry.set_range(0, 60)
+                       self._minutesEntry.set_increments(1, 5)
+
                        self._notifyCheckbox.set_active(self._alarmHandler.isEnabled)
                        self._minutesEntry.set_value(self._alarmHandler.recurrence)
                        self._missedCheckbox.set_active(self._notifyOnMissed)
index 2412688..a8e8560 100644 (file)
@@ -73,7 +73,7 @@ class AccountInfo(object):
                self._voicemailCheckbox.set_sensitive(False)
                self._smsCheckbox.set_sensitive(False)
 
-               self._accountViewNumberDisplay.set_text("")
+               self._accountViewNumberDisplay.set_label("")
 
        def disable(self):
                self._callbackCombo.set_sensitive(True)
index 27d452f..3dcdcf9 100755 (executable)
@@ -16,7 +16,7 @@ __description__ = "Touch screen enhanced interface to the GoogleVoice/GrandCentr
 __author__ = "Ed Page"
 __email__ = "eopage@byu.net"
 __version__ = constants.__version__
-__build__ = 0
+__build__ = 4
 __changelog__ = '''
 1.0.4
 * "Back" button and tabs now visually indicate when they've entered a "hold" state