Author: remi
Date: 2009-07-17 17:59:53 +0200 (Fri, 17 Jul 2009)
New Revision: 5124

Modified:
   
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/gadget_configuration.xsl
   
software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/00_resourceAttituneManager.py
   
software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/01_resourcePluginsServer.py
   
software_suite_v3/smart-core/smart-server/trunk/resources/04_robot_content_interactions/00_resourceRobotContentInteractions.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/applicationserver/gadget/GadgetGenerator.py
   
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py
   
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py
Log:
* Added introduction of alerts with Attitunes
* Fixed bug with "Attitunes" page. (Start/Edit of attitunes with special chars 
in the name)

Modified: 
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/gadget_configuration.xsl
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/gadget_configuration.xsl
     2009-07-17 09:54:43 UTC (rev 5123)
+++ 
software_suite_v3/smart-core/smart-server/trunk/data/web_interface/user_01/xsl/gadget_configuration.xsl
     2009-07-17 15:59:53 UTC (rev 5124)
@@ -107,6 +107,39 @@
                     </div>
                 </xsl:if>
             </xsl:for-each>
+            <!-- GADGET ALERT ATTITUNE -->
+            <xsl:if test="root/data/showAlertAttitune = 'True'">
+                <div class="gadgetConfContentFrameMiddle">
+                    <div class="gadgetConfContentFrameSep"></div>
+                    <xsl:element name="input">
+                        <xsl:attribute name="class">text</xsl:attribute>
+                        <xsl:attribute name="type">hidden</xsl:attribute>
+                        <xsl:attribute name="id">req_param_<xsl:value-of 
select="name"/>_visible</xsl:attribute>
+                        <xsl:attribute name="value">true</xsl:attribute>
+                    </xsl:element>
+                    <span class="gadgetConfParamName">
+                        <xsl:value-of 
select="root/translations/introduction_alerts"/>
+                    </span>
+                    <span class="gadgetConfParamValue">
+                        <xsl:element name="select">
+                            <xsl:attribute name="class">select</xsl:attribute>
+                            <xsl:attribute 
name="id">req_alertAttitune</xsl:attribute>
+                            <xsl:attribute 
name="name">AlertAttitune</xsl:attribute>
+                            <xsl:for-each 
select="root/data/availableAttitunes/*">
+                                <xsl:element name="option">
+                                    <xsl:attribute name="value">
+                                        <xsl:value-of select="."/>
+                                    </xsl:attribute>
+                                    <xsl:if test=". = ../../alertAttitune">
+                                        <xsl:attribute 
name="selected">true</xsl:attribute>
+                                    </xsl:if>
+                                    <xsl:value-of select="."/>
+                                </xsl:element>
+                            </xsl:for-each>
+                        </xsl:element>
+                    </span>
+                </div>
+            </xsl:if>
             <div class="gadgetConfContentFrameBottom"></div>
             <!-- ON DEMAND -->
             <xsl:choose>

Modified: 
software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/00_resourceAttituneManager.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/00_resourceAttituneManager.py
  2009-07-17 09:54:43 UTC (rev 5123)
+++ 
software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/00_resourceAttituneManager.py
  2009-07-17 15:59:53 UTC (rev 5124)
@@ -260,8 +260,14 @@
             return False
         attituneExists = False
         attitunes = self.getAttitunesContainer().getAttitunes()
+        reencodedName = name
+        try:
+            tmp = reencodedName.decode("latin-1")
+            reencodedName = tmp.encode("utf-8")
+        except:
+            pass
         for attitune in attitunes:
-            if attitune.getDescription().getName() == name:
+            if attitune.getDescription().getName() in [name, reencodedName]:
                 attituneExists = True
                 break
         if not attituneExists:
@@ -299,8 +305,14 @@
             return False
         attituneExists = False
         attitunes = self.getAttitunesContainer().getAttitunes()
+        reencodedName = name
+        try:
+            tmp = reencodedName.decode("latin-1")
+            reencodedName = tmp.encode("utf-8")
+        except:
+            pass
         for attitune in attitunes:
-            if attitune.getDescription().getName() == name:
+            if attitune.getDescription().getName() in [name, reencodedName]:
                 attituneExists = True
                 break
         if not attituneExists:
@@ -337,6 +349,17 @@
         t = threading.Thread(target = async)
         t.start()
 
+    def getAttitunesNameByObserversList(self, observersList):
+        """
+        """
+        attitunes = self.getAttitunesContainer().getAttitunes()
+        namesList = []
+        for attitune in attitunes:
+            if attitune.getObserverName() in observersList:
+                namesList.append(attitune.getDescription().getName())
+        namesList.sort()
+        return namesList
+
     def getAttitunesDictAll(self):
         """
         """
@@ -344,12 +367,7 @@
             self.__setAttituneRunName("0")
         result = {}
         count = 0
-        attitunes = self.getAttitunesContainer().getAttitunes()
-        namesList = []
-        for attitune in attitunes:
-            if attitune.getObserverName() in ["attitunes", "userAttitunes"]:
-                namesList.append(attitune.getDescription().getName())
-        namesList.sort()
+        namesList = self.getAttitunesNameByObserversList(["attitunes", 
"userAttitunes"])
         for attName in namesList:
             attitune = self.getAttitunesContainer().getAttitune(attName)
             result["attitune_%d_name" % count] = attName
@@ -358,7 +376,7 @@
             count += 1
         result['count'] = count
         return result
-        
+
     def checkForUpdates(self):
         """
         """

Modified: 
software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/01_resourcePluginsServer.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/01_resourcePluginsServer.py
    2009-07-17 09:54:43 UTC (rev 5123)
+++ 
software_suite_v3/smart-core/smart-server/trunk/resources/03_content_servers/01_resourcePluginsServer.py
    2009-07-17 15:59:53 UTC (rev 5124)
@@ -116,7 +116,7 @@
             "attitunes")
         if os.path.isdir(pluginAttPath):
             resourceAttituneManager.getAttitunesContainer().addDirectory(
-                pluginAttPath)
+                pluginAttPath, uuid)
         self.logger.logDebug("Plugin deployed [%s] to [%s]" % (
             plugin.getDescription().getName(), pluginWorkingPath))
         self.__publishEvents(False, ST_NAME_PS_PLUGIN_LOADED, [uuid,])

Modified: 
software_suite_v3/smart-core/smart-server/trunk/resources/04_robot_content_interactions/00_resourceRobotContentInteractions.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/resources/04_robot_content_interactions/00_resourceRobotContentInteractions.py
      2009-07-17 09:54:43 UTC (rev 5123)
+++ 
software_suite_v3/smart-core/smart-server/trunk/resources/04_robot_content_interactions/00_resourceRobotContentInteractions.py
      2009-07-17 15:59:53 UTC (rev 5124)
@@ -308,10 +308,21 @@
         """
         if not self.getPluginCommand().isNotifier():
             if self.getContextLayer() == PGU_CONTEXT_LAYER_SCHEDULER:
-                resourceTuxDriver.playSound(14, 100.0)
+                introAtt = None
+                try:
+                    introAtt = self.getPguObject().getAlertAttitune()
+                    if introAtt == "----":
+                        introAtt = None
+                except:
+                    pass
+                if introAtt != None:
+                    self.__executeAttitune(introAtt)
+                else:
+                    resourceTuxDriver.playSound(14, 100.0)
+                    time.sleep(0.5)
             else:
                 resourceTuxDriver.playSound(13, 100.0)
-            time.sleep(0.5)
+                time.sleep(0.5)
         while self.executionIsStarted():
             while self.executionIsPaused():
                 time.sleep(0.1)

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-17 09:54:43 UTC (rev 5123)
+++ 
software_suite_v3/smart-core/smart-server/trunk/resources/07_web_interfaces/01_resourceWIUser01.py
  2009-07-17 15:59:53 UTC (rev 5124)
@@ -362,6 +362,28 @@
         if data == None:
             contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
         else:
+            # Complete data with available alert attitunes
+            # Check for alert type
+            showAttitunes = False
+            ugc = resourceUgcServer.getUgcContainer().getUgcByUuid(uuid)
+            parentPlugin = ugc.getParentGadget().getParentPlugin()
+            tasks = ugc.getTasks()
+            for task in tasks:
+                parentTask = parentPlugin.getTask(task.getName())
+                if parentTask != None:
+                    parentCommand = 
parentPlugin.getCommand(parentTask.getCommand())
+                    if parentCommand != None:
+                        if not parentCommand.isNotifier():
+                            showAttitunes = True
+                            break
+            data['showAlertAttitune'] = showAttitunes
+            parentUuid = parentPlugin.getDescription().getUuid()
+            attitunesList = 
resourceAttituneManager.getAttitunesNameByObserversList([parentUuid, 
"userAttitunes"])
+            attitunesList.insert(0, "----")
+            data['availableAttitunes'] = {}
+            for i, attName in enumerate(attitunesList):
+                nodeName = "att_%d" % i
+                data['availableAttitunes'][nodeName] = attName
             contentStruct['root']['data'] = data
             contentStruct['root']['skin'] = skin
             contentStruct['root']['language'] = language
@@ -512,11 +534,17 @@
         contentStruct = self.getDefaultContentStruct()
         contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
         name = parameters['name']
+        reencodedName = name
+        try:
+            tmp = reencodedName.decode("latin-1")
+            reencodedName = tmp.encode("utf-8")
+        except:
+            pass
         language = parameters['language']
         attitunesContainer = resourceAttituneManager.getAttitunesContainer()
         attitunes = attitunesContainer.getAttitunes()
         for attitune in attitunes:
-            if attitune.getDescription().getName() == name:
+            if attitune.getDescription().getName() in [name, reencodedName]:
                 attitunePath = attitune.getAttFile()
                 t = threading.Thread(target = 
resourcePluginsServer.startPlugin,
                     args = (

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-17 09:54:43 UTC (rev 5123)
+++ 
software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/default.pot 
    2009-07-17 15:59:53 UTC (rev 5124)
@@ -156,3 +156,6 @@
 
 msgid "global_settings"
 msgstr ""
+
+msgid "introduction_alerts"
+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-17 09:54:43 UTC (rev 5123)
+++ software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/en.po   
2009-07-17 15:59:53 UTC (rev 5124)
@@ -156,3 +156,6 @@
 
 msgid "global_settings"
 msgstr "Global settings"
+
+msgid "introduction_alerts"
+msgstr "Introduction alerts"

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-17 09:54:43 UTC (rev 5123)
+++ software_suite_v3/smart-core/smart-server/trunk/translation/wi_user/fr.po   
2009-07-17 15:59:53 UTC (rev 5124)
@@ -156,3 +156,6 @@
 
 msgid "global_settings"
 msgstr "Configuration globale"
+
+msgid "introduction_alerts"
+msgstr "Introduction des alertes"

Modified: 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetGenerator.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetGenerator.py
    2009-07-17 09:54:43 UTC (rev 5123)
+++ 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/gadget/GadgetGenerator.py
    2009-07-17 15:59:53 UTC (rev 5124)
@@ -69,6 +69,12 @@
         # Remove "req_" prefix
         for i, e in enumerate(requestData):
             requestData[i][0] = e[0].replace("req_", "")
+        # ALERT ATTITUNE section 
-----------------------------------------------
+        for e in requestData:
+            if e[0].find("alertAttitune") == 0:
+                value = e[1]
+                result["alertAttitune"] = value
+                break
         # DESCRIPTION section 
--------------------------------------------------
         # Get gadget description elements
         gadgetDescription = {}
@@ -95,6 +101,8 @@
         affinedGadgetParameters = {}
         i = 0
         for parameterName in gadgetParameters.keys():
+            if parameterName.replace(" ", "") == "":
+                continue
             parameterData = gadgetParameters[parameterName]
             nodeName = "param_%.2d" % i
             i += 1
@@ -566,6 +574,8 @@
         ugcDataDict = {}
         # Creation time
         ugcDataDict['creationTime'] = time.time()
+        # Default attitune for alerts introduction
+        ugcDataDict['alertAttitune'] = "----"
         # Parent Gadget
         ugcDataDict['parentGadget'] = {
             'uuid' : gadget.getDescription().getUuid(),
@@ -659,6 +669,11 @@
         }
         # Creation time
         ugcDataDict['creationTime'] = ugc.getUgcFileCreationTime()
+        # Default attitune for alerts introduction
+        if tmpDataDict.has_key("alertAttitune"):
+            ugcDataDict['alertAttitune'] = tmpDataDict['alertAttitune']
+        else:
+            ugcDataDict['alertAttitune'] = "----"
         # Description
         ugcDataDict['description'] = {
             'uuid' : ugcUuid,

Modified: 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py
   2009-07-17 09:54:43 UTC (rev 5123)
+++ 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/Ugc.py
   2009-07-17 15:59:53 UTC (rev 5124)
@@ -36,6 +36,8 @@
         self.__parentGadget = parentGadget
         # Creation time of the ugc file
         self.__ugcFileCreationTime = dictionary['creationTime']
+        # Alert attitune
+        self.__alertAttitune = dictionary['alertAttitune']
         # Create descriptor
         self.__description = UgcDescription(self, dictionary['description'])
         # Create ugc parameters
@@ -84,6 +86,8 @@
         @return a dictionary.
         """
         data = {}
+        # Alert attitune
+        data['alertAttitune'] = self.__alertAttitune
         # Description
         description = self.getDescription()
         parentDescription = self.getParentGadget().getDescription()
@@ -295,6 +299,15 @@
         return self.__ugcFileCreationTime
 
     # 
--------------------------------------------------------------------------
+    # Get the selected attitune for alerts introduction.
+    # 
--------------------------------------------------------------------------
+    def getAlertAttitune(self):
+        """Get the selected attitune for alerts introduction.
+        @return: A string.
+        """
+        return self.__alertAttitune
+
+    # 
--------------------------------------------------------------------------
     # Get the parent UGCs container.
     # 
--------------------------------------------------------------------------
     def getContainer(self):

Modified: 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py
  2009-07-17 09:54:43 UTC (rev 5123)
+++ 
software_suite_v3/smart-core/smart-server/trunk/util/applicationserver/ugc/UgcContainer.py
  2009-07-17 15:59:53 UTC (rev 5124)
@@ -212,6 +212,9 @@
                     f.close()
             except:
                 pass
+        # Add alert attitune if not exists
+        if not ugcDataDict.has_key("alertAttitune"):
+            ugcDataDict["alertAttitune"] = "----"
         # Get the parent gadget
         if not ugcDataDict.has_key('parentGadget'):
             if self.__onUgcDeploymentErrorCallback != None:


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to