Author: remi
Date: 2009-03-18 13:03:48 +0100 (Wed, 18 Mar 2009)
New Revision: 4131

Modified:
   
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
Log:
* added auto-start of the framework.
* added the storage of the framework starting configuration.
  - If the framework was never explicitly started, the installation parameters 
(language, country, locutor)
    are set by default.
  - When you update the locales of the framework it are stored and 
automatically loaded at server start.

Modified: 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
 2009-03-18 12:00:35 UTC (rev 4130)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
 2009-03-18 12:03:48 UTC (rev 4131)
@@ -3,6 +3,9 @@
 # 
==============================================================================
 
 from util.gadgets.Framework import Framework
+from util.misc.tuxPaths import TUXDROID_LANGUAGE
+from util.misc.tuxPaths import TUXDROID_DEFAULT_LOCUTOR
+from util.misc.tuxPaths import USER_BASE_PATH
 
 # Framework events/statuses
 ST_NAME_FW_RUN = "framework_run"
@@ -61,8 +64,27 @@
             eventsHandler.insert(statusName)
             clientsManager.addDefaultExcludedEvent(statusName)
         eventsHandler.getEventHandler(ST_NAME_FW_RUN).updateState("False")
+        # Default configuration
+        splitedLC = TUXDROID_LANGUAGE.split("_")
+        language = splitedLC[0]
+        if len(splitedLC) > 1:
+            country = splitedLC[1]
+        else:
+            country = language.upper()
+        locutor = TUXDROID_DEFAULT_LOCUTOR
+        pitch = 130
+        gadgetsPath = os.path.join(USER_BASE_PATH, "MyTux", "MyTuxGadgets")
+        self.defaultConfiguration = {
+            'auto-start' : True,
+            'gadgets_path' : gadgetsPath,
+            'language' : language,
+            'country' : country,
+            'locutor' : locutor,
+            'pitch' : pitch,
+        }
 
     def stop(self):
+        self.getConfigurator().store()
         self.__framework.stop()
         self.__publishEvents(True, ST_NAME_FW_RUN, ["False",])
 
@@ -252,13 +274,33 @@
         self.name = "start"
         self.comment = "Start the gadget framework."
 
+    def start(self):
+        # Auto start of this service with the resource configuration.
+        config = resourceGadgetFramework.getConfigurator().load(
+            "resourceFramework.conf",
+            resourceGadgetFramework.defaultConfiguration)
+        if config['auto-start']:
+            
resourceGadgetFramework.getFramework().start(config['gadgets_path'],
+                config['language'], config['country'],
+                config['locutor'], config['pitch'])
+
     def execute(self, id, parameters):
         headersStruct = self.getDefaultHeadersStruct()
         contentStruct = self.getDefaultContentStruct()
         contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
+        # Start the framework
         
resourceGadgetFramework.getFramework().start(parameters['gadgets_path'],
             parameters['language'], parameters['country'],
             parameters['locutor'], parameters['pitch'])
+        # Store the configuration
+        configurator = resourceGadgetFramework.getConfigurator()
+        config = configurator.getConfiguration()
+        config['language'] = parameters['language']
+        config['country'] = parameters['country']
+        config['locutor'] = parameters['locutor']
+        config['pitch'] = parameters['pitch']
+        config['gadgets_path'] = parameters['gadgets_path']
+        configurator.store()
         return headersStruct, contentStruct
 
 # Register the service into the resource
@@ -288,6 +330,16 @@
         if not 
resourceGadgetFramework.getFramework().updateLocales(parameters['language'],
             parameters['country'], parameters['locutor'], parameters['pitch']):
             contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
+        else:
+            # Store the configuration
+            configurator = resourceGadgetFramework.getConfigurator()
+            config = configurator.getConfiguration()
+            config['language'] = parameters['language']
+            config['country'] = parameters['country']
+            config['locutor'] = parameters['locutor']
+            config['pitch'] = parameters['pitch']
+            config['gadgets_path'] = parameters['gadgets_path']
+            configurator.store()
         return headersStruct, contentStruct
 
 # Register the service into the resource


------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to