[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:23 UTC 2008


The following commit has been merged in the master branch:
commit eb275232dd6118261c890376bc1781e3a1f6287f
Author: Michael 'Mickey' Lauer <mickey at vanille-media.de>
Date:   Sat Aug 23 09:21:06 2008 +0200

    oevents: bring back AudioScenarioAction (first try)
    FIXME: leads to a audio scenario stack underflow if a call never reaches 'active'

diff --git a/docs/TODO b/docs/TODO
index 9ff400b..0f189f5 100644
--- a/docs/TODO
+++ b/docs/TODO
@@ -13,6 +13,9 @@
 * get more characteristics from the Display object
 
 == oeventd ==
+* put metadata for parser into actions, triggers, and filters, so
+a) we no longer need to specify the factories in the parser one-by-one, and
+b) they can be treated as plugins (just toss a new one into a directory and it will be found on next startup)
 
 == ousaged ==
 
diff --git a/etc/freesmartphone/oevents/rules.yaml b/etc/freesmartphone/oevents/rules.yaml
index 52e25c1..f579b89 100644
--- a/etc/freesmartphone/oevents/rules.yaml
+++ b/etc/freesmartphone/oevents/rules.yaml
@@ -31,4 +31,12 @@
 -
     trigger: Time(12,29)
     actions: Debug("A Test")
-
+-
+    trigger: CallStatus()
+    filters: HasAttr(status, "active")
+    actions: PushScenario()
+-
+    trigger: CallStatus()
+    filters: HasAttr(status, "release"))
+    actions: PullScenario()
+-
diff --git a/framework/subsystems/oeventsd/action.py b/framework/subsystems/oeventsd/action.py
index 8d8b8e5..fd42e98 100644
--- a/framework/subsystems/oeventsd/action.py
+++ b/framework/subsystems/oeventsd/action.py
@@ -17,17 +17,22 @@ import dbus
 #============================================================================#
 class Action(object):
 #============================================================================#
-    """An action is a functor object that is called by a rule"""
+    """
+    An action is a functor object that is called by a rule
+    """
     def __init__(self):
         pass
     def __call__(self, **kargs):
         logger.info("%s called", self)
     def __repr__(self):
         return "unamed action"
-    
+
 #============================================================================#
 class DebugAction(Action):
 #============================================================================#
+    """
+    A special action for debugging purposes
+    """
     def __init__(self, msg):
         self.msg = msg
     def __call__(self, **kargs):
@@ -38,7 +43,9 @@ class DebugAction(Action):
 #============================================================================#
 class DBusAction(Action):
 #============================================================================#
-    """A special action that will call a DBus method"""
+    """
+    A special action that will call a DBus method
+    """
     def __init__(self, bus, service, obj, interface, method, *args):
         super(DBusAction, self).__init__()
         self.bus = bus
@@ -78,6 +85,9 @@ class DBusAction(Action):
 #============================================================================#
 class AudioAction(DBusAction):
 #============================================================================#
+    """
+    A dbus action on the freesmartphone audio device
+    """
     def __init__(self, file = None, action = 'play'):
         bus = dbus.SystemBus()
         service = 'org.freesmartphone.odeviced'
@@ -87,8 +97,29 @@ class AudioAction(DBusAction):
         super(AudioAction, self).__init__(bus, service, obj, interface, method, file)
 
 #============================================================================#
+class AudioScenarioAction(DBusAction):
+#============================================================================#
+    """
+    A dbus action on the freesmartphone audio device
+    """
+    def __init__(self, file = None, action = 'push' ):
+        bus = dbus.SystemBus()
+        service = 'org.freesmartphone.odeviced'
+        obj = '/org/freesmartphone/Device/Audio'
+        interface = 'org.freesmartphone.Device.Audio'
+        if action == 'push':
+            # FIXME gsmhandset ugly ugly hardcoded
+            super(AudioScenarioAction, self).__init__(bus, service, obj, interface, "PushScenario", "gsmhandset")
+        else:
+            super(AudioScenarioAction, self).__init__(bus, service, obj, interface, "PullScenario" )
+
+#============================================================================#
 class VibratorAction(DBusAction):
 #============================================================================#
+    """
+    A dbus action on the Neo1973 vibrator device
+    """
+    # FIXME device specific, needs to go away from here
     def __init__(self, target = 'neo1973_vibrator', action = 'start'):
         bus = dbus.SystemBus()
         service = 'org.freesmartphone.odeviced'
diff --git a/framework/subsystems/oeventsd/oevents.py b/framework/subsystems/oeventsd/oevents.py
index 437198f..609e4ed 100644
--- a/framework/subsystems/oeventsd/oevents.py
+++ b/framework/subsystems/oeventsd/oevents.py
@@ -16,6 +16,7 @@ __version__ = "0.2.0"
 
 from framework.config import config
 
+# FIXME: treat triggers, actions, and filters as plugins and load them on demand
 from trigger import Trigger, CallStatusTrigger
 from filter import Filter, AttributeFilter
 from action import Action, AudioAction
diff --git a/framework/subsystems/oeventsd/parser.py b/framework/subsystems/oeventsd/parser.py
index e848d14..1742729 100644
--- a/framework/subsystems/oeventsd/parser.py
+++ b/framework/subsystems/oeventsd/parser.py
@@ -17,7 +17,7 @@ import re
 
 from trigger import Trigger, CallStatusTrigger, TimeTrigger
 from filter import Filter, AttributeFilter
-from action import Action, AudioAction, VibratorAction, DebugAction
+from action import Action, AudioAction, AudioScenarioAction, VibratorAction, DebugAction
 from ring_tone_action import RingToneAction
 from rule import Rule
 
@@ -73,6 +73,8 @@ def function_constructor(loader, node):
 yaml.add_constructor(u'!Function', function_constructor)
 yaml.add_implicit_resolver(u'!Function', pattern)
 
+# FIXME compute these from the actual triggers and actions
+
 class CallStatus(Function):
     name = 'CallStatus'
     def __call__(self):
@@ -88,6 +90,16 @@ class StopSound(Function):
     def __call__(self, file):
         return AudioAction(file, 'stop')
 
+class PushScenario(Function):
+    name = 'PushScenario'
+    def __call__(self):
+        return AudioScenarioAction(file, 'push')
+
+class PullScenario(Function):
+    name = 'PullScenario'
+    def __call__(self):
+        return AudioScenarioAction(file, 'pull')
+
 class RingTone(Function):
     name = 'RingTone'
     def __call__(self, cmd):
diff --git a/framework/subsystems/oeventsd/ring_tone_action.py b/framework/subsystems/oeventsd/ring_tone_action.py
index 0227cd7..ddd9a3e 100644
--- a/framework/subsystems/oeventsd/ring_tone_action.py
+++ b/framework/subsystems/oeventsd/ring_tone_action.py
@@ -24,7 +24,6 @@ import os
 import logging
 logger = logging.getLogger('oeventsd')
 
-
 #=========================================================================#
 class RingToneAction(Action):
 #=========================================================================#
diff --git a/framework/subsystems/oeventsd/trigger.py b/framework/subsystems/oeventsd/trigger.py
index 27e2284..0f98e30 100644
--- a/framework/subsystems/oeventsd/trigger.py
+++ b/framework/subsystems/oeventsd/trigger.py
@@ -57,14 +57,14 @@ class DBusTrigger(Trigger):
     """A special trigger that wait for a given DBus signal to trigger its rules"""
     def __init__(self, bus, service, obj, interface, signal):
         """Create the DBus trigger
-        
+
         arguments:
         - bus       the DBus bus name
         - service   the DBus name of the service
         - obj       the DBus path of the object
         - interface the Dbus interface of the signal
         - signal    the DBus name of the signal
-        
+
         """
         super(DBusTrigger, self).__init__()
         # some arguments checking
@@ -109,7 +109,7 @@ class CallStatusTrigger(DBusTrigger):
 
     def __repr__(self):
         return "CallStatus"
-        
+
 #============================================================================#
 class TimeTrigger(DBusTrigger):
 #============================================================================#

-- 
framworkd debian packageing



More information about the pkg-fso-commits mailing list