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

Guillaume Chereau (none) charlie at nikopol.
Sat Aug 23 14:06:16 UTC 2008


The following commit has been merged in the master branch:
commit 7736468a81a1429c3df7302767aca102cb7653ce
Author: Guillaume Chereau <charlie at nikopol.(none)>
Date:   Thu Aug 14 16:14:24 2008 +0800

    [oeventsd] Added RingTone action that takes the preferences into account
    It only considers the ring-tone (not the ring-volume yet)
    I had to rely on a smal hack to retrieve opreferences service without using DBus
    I hope Mickey will add some sort of 'get_object' method so that we can retrieve any registered object without using
    DBus

diff --git a/etc/freesmartphone/oevents/rules.yaml b/etc/freesmartphone/oevents/rules.yaml
index 9bb3a8c..73711ce 100644
--- a/etc/freesmartphone/oevents/rules.yaml
+++ b/etc/freesmartphone/oevents/rules.yaml
@@ -16,19 +16,13 @@
 # - StopSound(file)         : Action that stop an audio file
 # - StartVibration
 # - StopVibration
-
+# - RingTone(cmd)           : cmd can be 'start' or 'stop'
 
 -
-    # This rule will play a ring tone when a call is incoming
     trigger: CallStatus()
     filters: HasAttr(status, "incoming")
-    actions:
-        - PlaySound("/usr/share/sounds/Arkanoid_PSID.sid")
-        - StartVibration()
+    actions: RingTone(play)
 -
-    # This one will stop the ring tone when the call is in an other state
     trigger: CallStatus()
     filters: Not(HasAttr(status, "incoming"))
-    actions:
-        - StopSound("/usr/share/sounds/Arkanoid_PSID.sid")
-        - StopVibration()
+    actions: RingTone(stop)
diff --git a/etc/freesmartphone/opreferences/conf/phone/default.yaml b/etc/freesmartphone/opreferences/conf/phone/default.yaml
index 34b86ff..d0969dc 100644
--- a/etc/freesmartphone/opreferences/conf/phone/default.yaml
+++ b/etc/freesmartphone/opreferences/conf/phone/default.yaml
@@ -1,6 +1,5 @@
 
-# Those values are just here to test the preferences service,
-# They are not actually used yet
-ring-tone: "music1"
+
+ring-tone: "Arkanoid_PSID.sid"
 ring-volume: 10
 
diff --git a/framework/subsystems/oeventsd/action.py b/framework/subsystems/oeventsd/action.py
index 141145c..a1fdb72 100644
--- a/framework/subsystems/oeventsd/action.py
+++ b/framework/subsystems/oeventsd/action.py
@@ -62,21 +62,21 @@ class DBusAction(Action):
         return "%s(%s)" % (self.method, self.args)
         
 class AudioAction(DBusAction):
-    def __init__(self, file = None, action = 'Play'):
+    def __init__(self, file = None, action = 'play'):
         bus = dbus.SystemBus()
         service = 'org.freesmartphone.odeviced'
         obj = '/org/freesmartphone/Device/Audio'
         interface = 'org.freesmartphone.Device.Audio'
-        method = '%sSound' % action # could be PlaySound or StopSound
+        method = 'PlaySound' if action == 'play' else 'StopSound'
         super(AudioAction, self).__init__(bus, service, obj, interface, method, file)
         
 class VibratorAction(DBusAction):
-    def __init__(self, target = 'neo1973_vibrator', action = 'Start'):
+    def __init__(self, target = 'neo1973_vibrator', action = 'start'):
         bus = dbus.SystemBus()
         service = 'org.freesmartphone.odeviced'
         obj = '/org/freesmartphone/Device/LED/%s' % target
         interface = 'org.freesmartphone.Device.LED'
-        if action == 'Start':
+        if action == 'start':
             super(VibratorAction, self).__init__(bus, service, obj, interface, 'SetBlinking', 300, 700)
         else:
             super(VibratorAction, self).__init__(bus, service, obj, interface, 'SetBrightness', 0)
diff --git a/framework/subsystems/oeventsd/parser.py b/framework/subsystems/oeventsd/parser.py
index d6eab17..31bbc7a 100644
--- a/framework/subsystems/oeventsd/parser.py
+++ b/framework/subsystems/oeventsd/parser.py
@@ -10,12 +10,16 @@ The freesmartphone Events Module - Python Implementation
 GPLv2 or later
 """
 
+import logging
+logger = logging.getLogger('oeventsd')
+
 import yaml
 import re
 
 from trigger import Trigger, CallStatusTrigger
 from filter import Filter, AttributeFilter
 from action import Action, AudioAction, VibratorAction
+from ring_tone_action import RingToneAction
 from rule import Rule
 
 class FunctionMetaClass(type):
@@ -23,6 +27,7 @@ class FunctionMetaClass(type):
     def __init__(cls, name, bases, dict):
         super(FunctionMetaClass, cls).__init__(name, bases, dict)
         if 'name' in dict:
+            logger.debug("register function %s", dict['name'])
             Function.functions[dict['name']] = cls
 
 class Function(object):
@@ -80,6 +85,11 @@ class StopSound(Function):
     def __call__(self, file):
         return AudioAction(file, 'Stop')
         
+class RingTone(Function):
+    name = 'RingTone'
+    def __call__(self, cmd):
+        return RingToneAction(cmd)
+        
 class StartVibration(Function):
     name = 'StartVibration'
     def __call__(self):
@@ -111,8 +121,13 @@ def as_rule(r):
 class Parser(object):
     def parse_rules(self, src):
         rules = yaml.load(src)
-        rules = [as_rule(r) for r in rules]
-        return rules
+        ret = []
+        for r in rules:
+            try:
+                ret.append(as_rule(r))
+            except Exception, e:
+                logger.Error("can't parse rule : %s", e)
+        return ret
 
 if __name__ == '__main__':
     src = """
diff --git a/framework/subsystems/opreferencesd/__init__.py b/framework/subsystems/opreferencesd/__init__.py
index 87b201a..f49436d 100644
--- a/framework/subsystems/opreferencesd/__init__.py
+++ b/framework/subsystems/opreferencesd/__init__.py
@@ -1,3 +1,4 @@
 
 # The opreferencesd module
 
+from opreferences import PreferencesManager
diff --git a/framework/subsystems/opreferencesd/opreferences.py b/framework/subsystems/opreferencesd/opreferences.py
index edf1997..994899a 100644
--- a/framework/subsystems/opreferencesd/opreferences.py
+++ b/framework/subsystems/opreferencesd/opreferences.py
@@ -30,6 +30,10 @@ class DBusNoServiceError(dbus.DBusException):
 class PreferencesManager(dbus.service.Object):
     """This is the class for the main object from wich we access the configuration services
     """
+    # I use this value so that I can get the PreferencesManager
+    # from other subsystems without using DBus
+    # TODO: this should be supported by the the framework for any registered objects
+    singleton = None
     def __init__(self, bus, schema_dir = './schema', conf_dir = './conf'):
         """Create a PreferencesManager object
            
@@ -50,6 +54,8 @@ class PreferencesManager(dbus.service.Object):
         logger.info("using conf path : %s", conf_dir)
         logger.info("initialized, services : %s", self.GetServices()) 
         
+        PreferencesManager.singleton = self
+        
     @dbus.service.method("org.freesmartphone.Preferences", in_signature='', out_signature='as')
     def GetServices(self):
         """Return the list of all available services"""

-- 
framworkd debian packageing



More information about the pkg-fso-commits mailing list