Author: remi
Date: 2009-03-14 16:28:56 +0100 (Sat, 14 Mar 2009)
New Revision: 4076

Modified:
   
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
   
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/02_robot_api/resourceTTS.py
Log:
* added a function to flush the TTS stack excepted the ones from a specific 
uuid.
* applied the removing of the pushed texts in the TTS stack by a gadget when 
the user request a stop.

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-14 15:22:22 UTC (rev 4075)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
 2009-03-14 15:28:56 UTC (rev 4076)
@@ -401,6 +401,8 @@
         uuid = parameters['uuid']
         if not resourceGadgetFramework.getFramework().stopGadgetByUuid(uuid):
             contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
+        else:
+            resourceTTS.stackRemoveByUuid(uuid)
         return headersStruct, contentStruct
 
 # Register the service into the resource
@@ -427,6 +429,9 @@
         name = parameters['name']
         if not resourceGadgetFramework.getFramework().stopGadgetByName(name):
             contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
+        else:
+            gadget = 
resourceGadgetFramework.getFramework().getGadgetsContainer().getGadget(name)
+            resourceTTS.stackRemoveByUuid(gadget.getDescription().getUuid())
         return headersStruct, contentStruct
 
 # Register the service into the resource
@@ -450,6 +455,8 @@
         contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
         if not resourceGadgetFramework.getFramework().stopAllGadgets():
             contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
+        else:
+            resourceTTS.stackFlushExceptedUuid("0")
         return headersStruct, contentStruct
 
 # Register the service into the resource

Modified: 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/02_robot_api/resourceTTS.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/02_robot_api/resourceTTS.py
        2009-03-14 15:22:22 UTC (rev 4075)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/02_robot_api/resourceTTS.py
        2009-03-14 15:28:56 UTC (rev 4076)
@@ -180,6 +180,33 @@
                     eventsHandler.emit(ST_NAME_TTS_SOUND_STATE, ("OFF", 0.0))
             eventsHandler.emit(ST_NAME_TTS_STACK_EMPTY, (uuid, 0.0))
 
+    def stackFlushExceptedUuid(self, uuid):
+        """Remove elements from the TTS stack excepted the ones from an uuid.
+        @param uuid: Uuid.
+        """
+        uuidElementsList = []
+        self.__stackMutex.acquire()
+        for e in self.__stack:
+            if e[3] != uuid:
+                if e[3] not in uuidElementsList:
+                    uuidElementsList.append(e[3])
+        currentUuid = self.__getCurrentUuid()
+        if currentUuid != None:
+            if currentUuid not in uuidElementsList:
+                if currentUuid != uuid:
+                    uuidElementsList.append(currentUuid)
+        newStack = []
+        for e in self.__stack:
+            if e[3] == uuid:
+                newStack.append(e)
+        self.__stack = newStack
+        self.__stackMutex.release()
+        if len(uuidElementsList) > 0:
+            resourceTuxOSL.ttsStop()
+            eventsHandler.emit(ST_NAME_TTS_SOUND_STATE, ("OFF", 0.0))
+            for uuid in uuidElementsList:
+                eventsHandler.emit(ST_NAME_TTS_STACK_EMPTY, (uuid, 0.0))
+
     def stackPush(self, text, locutor, pitch, uuid = "0"):
         """Push a speech in the stack.
         @param text: Text to speak.


------------------------------------------------------------------------------
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