Allowing a custom launcher and preventing DoSing the alarmd service
authorepage <eopage@byu.net>
Wed, 19 Aug 2009 01:35:35 +0000 (01:35 +0000)
committerepage <eopage@byu.net>
Wed, 19 Aug 2009 01:35:35 +0000 (01:35 +0000)
git-svn-id: file:///svnroot/gc-dialer/trunk@396 c39d3808-3fe2-4d86-a59f-b7f623ee9f21

src/alarm_handler.py
src/gc_views.py
support/builddeb.py

index 98da6dc..b3e015d 100644 (file)
@@ -3,6 +3,7 @@
 import os
 import time
 import datetime
+import ConfigParser
 
 import dbus
 import osso.alarmd as alarmd
@@ -26,14 +27,23 @@ class AlarmHandler(object):
                bus = dbus.SystemBus()
                self._alarmdDBus = bus.get_object("com.nokia.alarmd", "/com/nokia/alarmd");
                self._alarmCookie = self._INVALID_COOKIE
+               self._launcher = self._LAUNCHER
 
        def load_settings(self, config, sectionName):
                self._recurrence = config.getint(sectionName, "recurrence")
                self._alarmCookie = config.getint(sectionName, "alarmCookie")
+               try:
+                       launcher = config.get(sectionName, "notifier")
+                       if launcher:
+                               self._launcher = launcher
+               except ConfigParser.NoOptionError:
+                       pass
 
        def save_settings(self, config, sectionName):
                config.set(sectionName, "recurrence", str(self._recurrence))
                config.set(sectionName, "alarmCookie", str(self._alarmCookie))
+               launcher = self._launcher if self._launcher != self._LAUNCHER else ""
+               config.set(sectionName, "notifier", launcher)
 
        def apply_settings(self, enabled, recurrence):
                if recurrence != self._recurrence or enabled != self.isEnabled:
@@ -66,7 +76,7 @@ class AlarmHandler(object):
                action = []
                action.extend(['flags', self._DEFAULT_FLAGS])
                action.extend(['title', self._TITLE])
-               action.extend(['path', self._LAUNCHER])
+               action.extend(['path', self._launcher])
                action.extend([
                        'arguments',
                        dbus.Array(
index f2576b1..dc96129 100644 (file)
@@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 from __future__ import with_statement
 
-import threading
 import warnings
 
 import gobject
@@ -576,6 +575,7 @@ class AccountInfo(object):
                self._onMissedToggled = 0
                self._onVoicemailToggled = 0
                self._onSmsToggled = 0
+               self._applyAlarmTimeoutId = None
 
                self._defaultCallback = ""
 
@@ -745,10 +745,22 @@ class AccountInfo(object):
                self.save_everything()
 
        def _on_notify_toggled(self, *args):
-               self._update_alarm_settings()
+               if self._applyAlarmTimeoutId is not None:
+                       gobject.source_remove(self._applyAlarmTimeoutId)
+                       self._applyAlarmTimeoutId = None
+               self._applyAlarmTimeoutId = gobject.timeout_add(500, self._on_apply_timeout)
 
        def _on_minutes_changed(self, *args):
+               if self._applyAlarmTimeoutId is not None:
+                       gobject.source_remove(self._applyAlarmTimeoutId)
+                       self._applyAlarmTimeoutId = None
+               self._applyAlarmTimeoutId = gobject.timeout_add(500, self._on_apply_timeout)
+
+       def _on_apply_timeout(self, *args):
+               self._applyAlarmTimeoutId = None
+
                self._update_alarm_settings()
+               return False
 
        def _on_missed_toggled(self, *args):
                self._notifyOnMissed = self._missedCheckbox.get_active()
index 3dcdcf9..23880a7 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__ = 4
+__build__ = 5
 __changelog__ = '''
 1.0.4
 * "Back" button and tabs now visually indicate when they've entered a "hold" state