[pkg-fso-commits] [SCM] framworkd debian packageing branch, master, updated. milestone2-89-geb27523
Guillaume Chereau (none)
charlie at nikopol.
Sat Aug 23 14:06:18 UTC 2008
The following commit has been merged in the master branch:
commit 69ebcf73680d16686a39df530294096e8ce605d5
Author: Guillaume Chereau <charlie at nikopol.(none)>
Date: Mon Aug 18 11:28:51 2008 +0800
Added a 'get_object' class method to Controller
So that the subsystems can retrieve any registered DBus object without making a DBUs call.
diff --git a/framework/controller.py b/framework/controller.py
index ecc1b85..610c927 100644
--- a/framework/controller.py
+++ b/framework/controller.py
@@ -68,10 +68,18 @@ class Controller( object ):
"""
Loading and registering plugins.
"""
+ # 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
+ """
+ return cls.objects[name]
+
def __init__( self, path ):
- # FIXME remove
- self.objects = {}
-
# dbus & glib mainloop
DBusGMainLoop( set_as_default=True )
self.mainloop = MainLoop()
@@ -89,7 +97,7 @@ class Controller( object ):
self._handleOverrides()
self._subsystems["frameworkd"] = subsystem.Framework( self.bus, path, self )
- self.objects.update( self._subsystems["frameworkd"].objects() )
+ Controller.objects.update( self._subsystems["frameworkd"].objects() )
# walk subsystems and find 'em
systemstolaunch = self.options.values.subsystems.split( ',' )
@@ -110,7 +118,7 @@ class Controller( object ):
self._subsystems[s] = subsystem.Subsystem( s, self.bus, path, self )
else:
self._subsystems[s] = subsystem.Subsystem( s, self.bus, path, self )
- self.objects.update( self._subsystems[s].objects() )
+ Controller.objects.update( self._subsystems[s].objects() )
# do we have any subsystems left?
if not self.options.values.debug:
@@ -119,10 +127,10 @@ class Controller( object ):
sys.exit( -1 )
logger.info( "================== objects registered ===================" )
- objectnames = self.objects.keys()
+ objectnames = Controller.objects.keys()
objectnames.sort()
for obj in objectnames:
- logger.info( "%s [%s]" % ( obj, self.objects[obj].interface ) )
+ logger.info( "%s [%s]" % ( obj, Controller.objects[obj].interface ) )
def subsystems( self ):
return self._subsystems
diff --git a/framework/subsystems/oeventsd/ring_tone_action.py b/framework/subsystems/oeventsd/ring_tone_action.py
index 70c0ec0..faf96fe 100644
--- a/framework/subsystems/oeventsd/ring_tone_action.py
+++ b/framework/subsystems/oeventsd/ring_tone_action.py
@@ -16,7 +16,8 @@ import os
import logging
logger = logging.getLogger('oeventsd')
-from framework.subsystems.opreferencesd import PreferencesManager
+# from framework.subsystems.opreferencesd import PreferencesManager
+from framework.controller import Controller
class RingToneAction(Action):
def __init__(self, cmd = 'play'):
@@ -24,10 +25,8 @@ class RingToneAction(Action):
def __call__(self, **kargs):
logger.info("RingToneAction %s", self.cmd)
- # First we need to get the ring-tone music :
- # TODO: as soon as we have some sort of global get_object('Preferences')
- # method we should use it instead of PreferencesManager.singleton
- prefs = PreferencesManager.singleton
+ # 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')
diff --git a/framework/subsystems/opreferencesd/opreferences.py b/framework/subsystems/opreferencesd/opreferences.py
index 994899a..edf1997 100644
--- a/framework/subsystems/opreferencesd/opreferences.py
+++ b/framework/subsystems/opreferencesd/opreferences.py
@@ -30,10 +30,6 @@ 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
@@ -54,8 +50,6 @@ 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