Author: remi
Date: 2009-07-24 12:05:05 +0200 (Fri, 24 Jul 2009)
New Revision: 5156

Added:
   
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/global_configuration.xsl
Modified:
   
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/tools.xsl
   
software_suite_v3/smart-core/smart-server/trunk/resources/05_user_configurations/00_resourceUsers.py
   
software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py
   
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/default.pot
   software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/en.po
   software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/fr.po
   software_suite_v3/smart-core/smart-server/trunk/util/osl/TuxOSL.py
Log:
* Added "global settings" functionality in the "tools" page.

Added: 
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/global_configuration.xsl
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/global_configuration.xsl
                             (rev 0)
+++ 
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/global_configuration.xsl
     2009-07-24 10:05:05 UTC (rev 5156)
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+    xmlns:fo="http://www.w3.org/1999/XSL/Format";>
+
+<xsl:template match="/">
+<html>
+    <head>
+        <LINK href="/data/web_interface/user_01/css/gadget-configuration.css" 
rel="stylesheet" type="text/css"/>
+        <script src="/data/web_interface/user_01/js/hashtable.js" 
type="text/javascript"/>
+        <script src="/data/web_interface/user_01/js/common.js" 
type="text/javascript"/>
+        <script language="javascript">
+        <![CDATA[
+            function initialization()
+            {
+            }
+
+            /**
+             *
+             */
+            function applyGlobalConfiguration()
+            {
+                var language = document.getElementById("language").value;
+                var locutor = document.getElementById("voiceValue").value;
+                var pitch = document.getElementById("pitchValue").value;
+                var args = {
+                    "language" : language,
+                    "locutor" : locutor,
+                    "pitch" : pitch
+                }
+                res = postRequest("/wi_user_01/apply_global_configuration", 
args);
+            }
+        ]]>
+        </script>
+    </head>
+
+    <body bgcolor="#dcdadb" onLoad="initialization();">
+        <!-- SKIN STORAGE -->
+        <xsl:element name="input">
+            <xsl:attribute name="type">hidden</xsl:attribute>
+            <xsl:attribute name="id">skin</xsl:attribute>
+            <xsl:attribute name="value">
+                <xsl:value-of select="root/skin"/>
+            </xsl:attribute>
+        </xsl:element>
+        <!-- LANGUAGE STORAGE -->
+        <xsl:element name="input">
+            <xsl:attribute name="type">hidden</xsl:attribute>
+            <xsl:attribute name="id">language</xsl:attribute>
+            <xsl:attribute name="value">
+                <xsl:value-of select="root/language"/>
+            </xsl:attribute>
+        </xsl:element>
+        <!-- MAIN DIV FRAME -->
+        <div style="position:absolute;
+                    left:0px;
+                    top:0px;
+                    width:423px;
+                    height:388px;
+                    overflow-y:scroll;
+                    overflow-x:hidden;">
+            <!-- SETTINGS BAR -->
+            <div class="gadgetConfTitleBarSettings">
+                <span class="gadgetConfTitleBarLabel"><xsl:value-of 
select="root/translations/voice_settings"/></span>
+            </div>
+            <div class="gadgetConfTitleBarBottom1"></div>
+            <!-- VOICE -->
+            <div class="gadgetConfContentFrameMiddle">
+                <div class="gadgetConfContentFrameSep"></div>
+                <span class="gadgetConfParamName">
+                    <xsl:value-of 
select="root/translations/voice_param_title"/>
+                </span>
+                <span class="gadgetConfParamValue">
+                    <xsl:element name="select">
+                        <xsl:attribute name="class">select</xsl:attribute>
+                        <xsl:attribute name="id">voiceValue</xsl:attribute>
+                        <xsl:attribute name="name">voiceValue</xsl:attribute>
+                        <xsl:for-each select="root/data/availableLocutors/*">
+                            <xsl:element name="option">
+                                <xsl:attribute name="value">
+                                    <xsl:value-of select="."/>
+                                </xsl:attribute>
+                                <xsl:if test=". = ../../defaultLocutor">
+                                    <xsl:attribute 
name="selected">true</xsl:attribute>
+                                </xsl:if>
+                                <xsl:value-of select="."/>
+                            </xsl:element>
+                        </xsl:for-each>
+                    </xsl:element>
+                </span>
+            </div>
+            <!-- PITCH -->
+            <div class="gadgetConfContentFrameMiddle">
+                <div class="gadgetConfContentFrameSep"></div>
+                <span class="gadgetConfParamName">
+                    <xsl:value-of 
select="root/translations/pitch_param_title"/>
+                </span>
+                <span class="gadgetConfParamValue">
+                    <xsl:element name="select">
+                        <xsl:attribute name="class">select</xsl:attribute>
+                        <xsl:attribute name="id">pitchValue</xsl:attribute>
+                        <xsl:attribute name="name">pitchValue</xsl:attribute>
+                        <xsl:element name="option">
+                            <xsl:attribute name="value">120</xsl:attribute>
+                            <xsl:if test="root/data/defaultPitch = '120'">
+                                <xsl:attribute 
name="selected">true</xsl:attribute>
+                            </xsl:if>
+                            <xsl:value-of 
select="root/translations/pitch_tux_voice"/>
+                        </xsl:element>
+                        <xsl:element name="option">
+                            <xsl:attribute name="value">100</xsl:attribute>
+                            <xsl:if test="root/data/defaultPitch = '100'">
+                                <xsl:attribute 
name="selected">true</xsl:attribute>
+                            </xsl:if>
+                            <xsl:value-of 
select="root/translations/pitch_normal"/>
+                        </xsl:element>
+                        <xsl:element name="option">
+                            <xsl:attribute name="value">85</xsl:attribute>
+                            <xsl:if test="root/data/defaultPitch = '85'">
+                                <xsl:attribute 
name="selected">true</xsl:attribute>
+                            </xsl:if>
+                            <xsl:value-of 
select="root/translations/pitch_low"/>
+                        </xsl:element>
+                    </xsl:element>
+                </span>
+            </div>
+            <div class="gadgetConfContentFrameBottom"></div>
+        </div>
+    </body>
+</html>
+</xsl:template>
+</xsl:stylesheet>

Modified: 
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/tools.xsl
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/tools.xsl
    2009-07-24 10:04:43 UTC (rev 5155)
+++ 
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/tools.xsl
    2009-07-24 10:05:05 UTC (rev 5156)
@@ -88,17 +88,21 @@
                     icon2AlreadyPng = true;
                     
setpng(document.getElementById("windowGadgetConfigurationIcon"));
                 }
-                /*var skin = document.getElementById("skin").value;
+                var skin = document.getElementById("skin").value;
                 var language = document.getElementById("language").value;
                 var src = "/wi_user_01/global_configuration?";
                 src += "language=" + language;
                 src += "&skin=" + skin;
-                src += "&rndParam=" + Math.random();*/
-                
document.getElementById("windowGlobalSettingsContentIFrame").src = 
"http://127.0.0.1:270/";;
+                src += "&rndParam=" + Math.random();
+                
document.getElementById("windowGlobalSettingsContentIFrame").src = src;
             }
 
             function applyGlobalSettings()
             {
+                if (window.frames.windowGlobalSettingsContentIFrame && 
window.frames.windowGlobalSettingsContentIFrame.applyGlobalConfiguration)
+                {
+                    
window.frames.windowGlobalSettingsContentIFrame.applyGlobalConfiguration();
+                }
             }
         ]]>
         </script>

Modified: 
software_suite_v3/smart-core/smart-server/trunk/resources/05_user_configurations/00_resourceUsers.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/resources/05_user_configurations/00_resourceUsers.py
        2009-07-24 10:04:43 UTC (rev 5155)
+++ 
software_suite_v3/smart-core/smart-server/trunk/resources/05_user_configurations/00_resourceUsers.py
        2009-07-24 10:05:05 UTC (rev 5156)
@@ -2,6 +2,7 @@
 # Users resource.
 # 
==============================================================================
 
+from util.osl.TuxOSL import TUX_OSL_ACAPELA_LOCUTORS_BY_LANGUAGE_COUNTRY_DICT
 from util.misc.tuxPaths import TUXDROID_LANGUAGE
 from util.misc.tuxPaths import TUXDROID_LANGUAGE2
 from util.misc.tuxPaths import TUXDROID_DEFAULT_LOCUTOR
@@ -82,7 +83,7 @@
             locutor = TUXDROID_DEFAULT_LOCUTOR
             locutor2 = TUXDROID_SECOND_LOCUTOR
             # Todo : Get second language and locutor
-            pitch = 130
+            pitch = 120
             defaultConfDict = {
                 'name' : userName,
                 'login' : None,
@@ -136,6 +137,75 @@
         userName = self.__userConfiguration['name']
         return os.path.join(TDS_USERS_CONF_PATH, userName)
 
+    def getCurrentFirstLocutor(self):
+        """
+        """
+        return self.__userConfiguration['locutor1'].replace("8k", "")
+
+    def setNewFirstLocutor(self, locutor):
+        """
+        """
+        if locutor.find("8k") == -1:
+            locutor += "8k"
+        if locutor == self.getCurrentFirstLocutor():
+            return
+        self.__userConfiguration['locutor1'] = locutor
+        # Set locales in the plugins server
+        resourcePluginsServer.getPluginsContainer().setLocales(
+            self.__userConfiguration['language1'], 
self.__userConfiguration['country'],
+            self.__userConfiguration['locutor1'], 
self.__userConfiguration['pitch'])
+
+    def getCurrentFirstLanguage(self):
+        """
+        """
+        return self.__userConfiguration['language1']
+
+    def getCurrentSecondLocutor(self):
+        """
+        """
+        return self.__userConfiguration['locutor2'].replace("8k", "")
+
+    def getCurrentSecondLanguage(self):
+        """
+        """
+        return self.__userConfiguration['language2']
+
+    def getLocutorsFromFirstLanguage(self):
+        """
+        """
+        firstLocutor = self.getCurrentFirstLocutor()
+        locDict = TUX_OSL_ACAPELA_LOCUTORS_BY_LANGUAGE_COUNTRY_DICT
+        for key in locDict.keys():
+            if firstLocutor in locDict[key]:
+                return locDict[key]
+        return []
+
+    def getCurrentPitch(self):
+        """
+        """
+        return self.__userConfiguration['pitch']
+
+    def setNewPitch(self, pitch):
+        """
+        """
+        if pitch == self.getCurrentPitch():
+            return
+        self.__userConfiguration['pitch'] = pitch
+        # Set locales in the plugins server
+        resourcePluginsServer.getPluginsContainer().setLocales(
+            self.__userConfiguration['language1'], 
self.__userConfiguration['country'],
+            self.__userConfiguration['locutor1'], 
self.__userConfiguration['pitch'])
+
+    def storeUserConfiguration(self):
+        """
+        """
+        # Update configuration file
+        userConfFile = os.path.join(TDS_USERS_CONF_PATH, self.__lastUser,
+            "user.conf")
+        f = open(userConfFile, "w")
+        f.write(str(self.__userConfiguration))
+        f.close()
+
     def updateCurrentUserConfiguration(self, userConfiguration):
         """Update the current user configuration.
         @param userConfiguration: New configuration as dictionary.

Modified: 
software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py
  2009-07-24 10:04:43 UTC (rev 5155)
+++ 
software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py
  2009-07-24 10:05:05 UTC (rev 5156)
@@ -563,3 +563,80 @@
 
 # Register the service into the resource
 resourceWIUser01.addService(TDSServiceWIUser01EditAttitune)
+
+# 
------------------------------------------------------------------------------
+# Declaration of the service "global_configuration".
+# 
------------------------------------------------------------------------------
+class TDSServiceWIUser01GlobalConfiguration(TDSService):
+
+    def configure(self):
+        self.parametersDict = {
+            'language' : 'string',
+            'skin' : 'string',
+        }
+        self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
+        self.exclusiveExecution = False
+        self.name = "global_configuration"
+        self.comment = "Show the global configuration."
+
+    def execute(self, id, parameters):
+        headersStruct = self.getDefaultHeadersStruct()
+        contentStruct = self.getDefaultContentStruct()
+        contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
+        language = parameters['language']
+        skin = parameters['skin']
+        data = {}
+        data['availableLocutors'] = {}
+        for i, locutor in 
enumerate(resourceUsers.getLocutorsFromFirstLanguage()):
+            data['availableLocutors']['loc_%d' % i] = locutor
+        data['defaultLocutor'] = resourceUsers.getCurrentFirstLocutor()
+        data['defaultPitch'] = resourceUsers.getCurrentPitch()
+        contentStruct['root']['data'] = data
+        contentStruct['root']['skin'] = skin
+        contentStruct['root']['language'] = language
+        contentStruct['root']['translations'] = 
resourceWIUser01.translations.getTranslations(language)
+        self.haveXsl = True
+        self.xslPath = "/data/web_interface/%s/xsl/global_configuration.xsl" % 
skin
+        return headersStruct, contentStruct
+
+# Register the service into the resource
+resourceWIUser01.addService(TDSServiceWIUser01GlobalConfiguration)
+
+# 
------------------------------------------------------------------------------
+# Declaration of the service "apply_global_configuration".
+# 
------------------------------------------------------------------------------
+class TDSServiceWIUser01ApplyGlobalConfiguration(TDSService):
+
+    def configure(self):
+        self.parametersDict = {
+            'language' : 'string',
+            'locutor' : 'string',
+            'pitch' : 'uint8',
+        }
+        self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
+        self.exclusiveExecution = False
+        self.name = "apply_global_configuration"
+        self.comment = "Apply the global configuration."
+
+    def execute(self, id, parameters):
+        headersStruct = self.getDefaultHeadersStruct()
+        contentStruct = self.getDefaultContentStruct()
+        contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
+        language = parameters['language']
+        locutor = parameters['locutor']
+        pitch = parameters['pitch']
+        oldLocutor = resourceUsers.getCurrentFirstLocutor()
+        resourceUsers.setNewFirstLocutor(locutor)
+        resourceUsers.setNewPitch(pitch)
+        resourceUsers.storeUserConfiguration()
+        for ugc in resourceUgcServer.getUgcContainer().getUgcs():
+            if ugc.getParameter('locutor') != None:
+                if ugc.getParameter('locutor').getValue() == oldLocutor:
+                    ugc.getParameter('locutor').setValue(locutor)
+            if ugc.getParameter('pitch') != None:
+                ugc.getParameter('pitch').setValue(pitch)
+        return headersStruct, contentStruct
+
+# Register the service into the resource
+resourceWIUser01.addService(TDSServiceWIUser01ApplyGlobalConfiguration)
+

Modified: 
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/default.pot
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/default.pot 
    2009-07-24 10:04:43 UTC (rev 5155)
+++ 
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/default.pot 
    2009-07-24 10:05:05 UTC (rev 5156)
@@ -159,3 +159,24 @@
 
 msgid "introduction_alerts"
 msgstr ""
+
+msgid "voice_settings"
+msgstr ""
+
+msgid "voice_param_title"
+msgstr ""
+
+msgid "pitch_param_title"
+msgstr ""
+
+msgid "test"
+msgstr ""
+
+msgid "pitch_tux_voice"
+msgstr ""
+
+msgid "pitch_normal"
+msgstr ""
+
+msgid "pitch_low"
+msgstr ""

Modified: 
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/en.po
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/en.po   
2009-07-24 10:04:43 UTC (rev 5155)
+++ software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/en.po   
2009-07-24 10:05:05 UTC (rev 5156)
@@ -159,3 +159,24 @@
 
 msgid "introduction_alerts"
 msgstr "Introduction alerts"
+
+msgid "voice_settings"
+msgstr "Voice settings"
+
+msgid "voice_param_title"
+msgstr "Voice"
+
+msgid "pitch_param_title"
+msgstr "Pitch"
+
+msgid "test"
+msgstr "Test"
+
+msgid "pitch_tux_voice"
+msgstr "Tux voice"
+
+msgid "pitch_normal"
+msgstr "Normal"
+
+msgid "pitch_low"
+msgstr "Low"

Modified: 
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/fr.po
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/fr.po   
2009-07-24 10:04:43 UTC (rev 5155)
+++ software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/fr.po   
2009-07-24 10:05:05 UTC (rev 5156)
@@ -159,3 +159,24 @@
 
 msgid "introduction_alerts"
 msgstr "Introduction des alertes"
+
+msgid "voice_settings"
+msgstr "Configuration de la voix"
+
+msgid "voice_param_title"
+msgstr "Voix"
+
+msgid "pitch_param_title"
+msgstr "Tonalité"
+
+msgid "test"
+msgstr "Tester"
+
+msgid "pitch_tux_voice"
+msgstr "Voix de Tux"
+
+msgid "pitch_normal"
+msgstr "Voix normale"
+
+msgid "pitch_low"
+msgstr "Voix grave"

Modified: software_suite_v3/smart-core/smart-server/trunk/util/osl/TuxOSL.py
===================================================================
--- software_suite_v3/smart-core/smart-server/trunk/util/osl/TuxOSL.py  
2009-07-24 10:04:43 UTC (rev 5155)
+++ software_suite_v3/smart-core/smart-server/trunk/util/osl/TuxOSL.py  
2009-07-24 10:05:05 UTC (rev 5156)
@@ -116,6 +116,23 @@
     ST_NAME_WAV_CHANNEL_START,
 ]
 
+# Locutors languages dictionary
+TUX_OSL_ACAPELA_LOCUTORS_BY_LANGUAGE_COUNTRY_DICT = {
+    'en_US' : ["Ryan", "Heather"],
+    'en_GB' : ["Graham", "Lucy"],
+    'fr' : ["Bruno", "Julie"],
+    'de' : ["Klaus", "Sarah"],
+    'nl_BE' : ["Sofie"],
+    'nl' : ["Femke"],
+    'ar' : ["Salma"],
+    'da' : ["Mette"],
+    'no' : ["Kari"],
+    'pt' : ["Celia"],
+    'sv' : ["Erik", "Emma"],
+    'it' : ["Chiara"],
+    'es' : ["Maria"],
+}
+
 # Callback type defines
 TUX_OSL_STATUS_CALLBACK = CFUNCTYPE(None, c_char_p)
 TUX_OSL_BUFFER_CALLBACK = CFUNCTYPE(c_int, c_int, c_char_p)
@@ -224,7 +241,7 @@
         if self.getStarted():
             self.__startingMutex.release()
             return E_TUXOSL_NOERROR
-            
+
         if self.tux_osl_lib == None:
             self.__startingMutex.release()
             return E_TUXOSL_NOTRUNNING


------------------------------------------------------------------------------
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to