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)
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)
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
if __name__ == "__main__":
- notify()
+ notify_on_change()
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()
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:
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):
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)