[pkg-fso-commits] [SCM] framworkd debian packageing branch, master, updated. milestone2-89-geb27523

Michael 'Mickey' Lauer mickey at vanille-media.de
Sat Aug 23 14:06:21 UTC 2008


The following commit has been merged in the master branch:
commit 3ef7db243cb2431b580f60e314713a4852092307
Author: Michael 'Mickey' Lauer <mickey at vanille-media.de>
Date:   Wed Aug 20 15:44:59 2008 +0200

    * stylize accessor method (we don't use 'get' as prefix) for controller and return None if not found
    * increase ringtone event robustness (if preferences object not found)

diff --git a/framework/controller.py b/framework/controller.py
index 610c927..689cec9 100644
--- a/framework/controller.py
+++ b/framework/controller.py
@@ -7,7 +7,7 @@ freesmartphone.org Framework Daemon
 GPLv2 or later
 """
 
-__version__ = "0.9.1"
+__version__ = "0.9.2"
 
 from framework.config import DBUS_BUS_NAME_PREFIX
 
@@ -70,15 +70,15 @@ class Controller( object ):
     """
     # We store all the DBUs object in a class attribute
     objects = {}
-    
+
     @classmethod
-    def get_object(cls, name):
-        """Return a DBus object -not proxy- from the list of registered objects.
-            
-           If there is no such object, raise a KeyError exception
+    def object( cls, name ):
+        """
+        Return a DBus object -not proxy- from the list of registered objects.
+        If there is no such object, return None
         """
-        return cls.objects[name]
-    
+        return cls.objects.get( name, None )
+
     def __init__( self, path ):
         # dbus & glib mainloop
         DBusGMainLoop( set_as_default=True )
diff --git a/framework/subsystems/oeventsd/ring_tone_action.py b/framework/subsystems/oeventsd/ring_tone_action.py
index faf96fe..f9a3106 100644
--- a/framework/subsystems/oeventsd/ring_tone_action.py
+++ b/framework/subsystems/oeventsd/ring_tone_action.py
@@ -7,38 +7,55 @@ The freesmartphone Events Module - Python Implementation
 (C) 2008 Guillaume 'Charlie' Chereau
 (C) 2008 Openmoko, Inc.
 GPLv2 or later
+
+Package: oeventsd
+Module: ring_tone_action
+
 """
 
 from action import Action, AudioAction, VibratorAction
+# from framework.subsystems.opreferencesd import PreferencesManager
+from framework.controller import Controller
+from framework.config import installprefix
+
 import dbus
 import os
 
 import logging
 logger = logging.getLogger('oeventsd')
 
-# from framework.subsystems.opreferencesd import PreferencesManager
-from framework.controller import Controller
 
+#=========================================================================#
 class RingToneAction(Action):
-    def __init__(self, cmd = 'play'):
+#=========================================================================#
+    def __init__( self, cmd = 'play' ):
         self.cmd = cmd
+
     def __call__(self, **kargs):
-        logger.info("RingToneAction %s", self.cmd)
+        logger.info( "RingToneAction %s", self.cmd )
 
         # We use the global Controller class to directly get the object
-        prefs = Controller.get_object('/org/freesmartphone/Preferences')
-        phone_prefs = prefs.GetService('phone')
-        ring_tone = phone_prefs.GetValue('ring-tone')
-        ring_volume = phone_prefs.GetValue('ring-volume')
-        sound_path = os.path.join("/usr/share/sounds/", ring_tone)
-
-        if self.cmd == 'play':
-            logger.info("Start ringing : tone=%s, volume=%s", ring_tone, ring_volume)
-            AudioAction(sound_path, 'play')()
-            VibratorAction(action='start')()
+        prefs = Controller.object( "/org/freesmartphone/Preferences" )
+        if prefs is None:
+            logger.error( "preferences not available and no default values defined." )
+            return
+        phone_prefs = prefs.GetService( "phone" )
+        ring_tone = phone_prefs.GetValue( "ring-tone" )
+        ring_volume = phone_prefs.GetValue( "ring-volume" )
+        sound_path = os.path.join( installprefix, "/usr/share/sounds/", ring_tone )
+
+        if self.cmd == "play":
+            logger.info( "Start ringing : tone=%s, volume=%s", ring_tone, ring_volume )
+            AudioAction(sound_path, "play")()
+            VibratorAction( action="start" )()
+
+        elif self.cmd == "stop":
+            logger.info( "Stop ringing : tone=%s, volume=%s", ring_tone, ring_volume )
+            AudioAction( sound_path, "stop" )()
+            VibratorAction( action="stop" )()
         else:
-            logger.info("Stop ringing : tone=%s, volume=%s", ring_tone, ring_volume)
-            AudioAction(sound_path, 'stop')()
-            VibratorAction(action='stop')()
+            logger.error( "Unknown RingToneAction!" )
+            assert False, "unknown ring tone action"
+
     def __repr__(self):
         return "RingToneAction(%s)" % self.cmd

-- 
framworkd debian packageing



More information about the pkg-fso-commits mailing list