Author: remi
Date: 2009-03-13 13:13:59 +0100 (Fri, 13 Mar 2009)
New Revision: 4052

Added:
   software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/
   software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Gadget.py
   
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetDescription.py
   
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetParameter.py
   software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetToken.py
   
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetsContainer.py
   software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/__init__.py
Log:
* added Gadgets class

Added: software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Gadget.py
===================================================================
--- software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Gadget.py       
                        (rev 0)
+++ software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Gadget.py       
2009-03-13 12:13:59 UTC (rev 4052)
@@ -0,0 +1,118 @@
+#    Copyright (C) 2009 C2ME Sa
+#    Remi Jocaille <[email protected]>
+#    Distributed under the terms of the GNU General Public License
+#    http://www.gnu.org/copyleft/gpl.html
+
+from GadgetDescription import GadgetDescription
+from GadgetParameter import GadgetParameter
+from GadgetToken import GadgetToken
+
+# 
------------------------------------------------------------------------------
+# Gadget description.
+# 
------------------------------------------------------------------------------
+class Gadget(object):
+
+    # 
--------------------------------------------------------------------------
+    # Constructor of the class.
+    # 
--------------------------------------------------------------------------
+    def __init__(self, parent, infosStructure):
+        """Constructor of the class.
+        @param parent: Parent Gadgets container.
+        @param infosStructure: Gadget structure as dictionary.
+        """
+        self.__parent = parent
+        self.__description = GadgetDescription(self, 
infosStructure['description'])
+        self.__parameters = []
+        for key in infosStructure['parameters'].keys():
+            self.__parameters.append(GadgetParameter(self,
+                infosStructure['parameters'][key]))
+        self.__commands = []
+        for key in infosStructure['commands'].keys():
+            self.__commands.append(GadgetToken(self,
+                infosStructure['commands'][key]))
+
+    # 
--------------------------------------------------------------------------
+    # Get the parent gadgets container.
+    # 
--------------------------------------------------------------------------
+    def getContainer(self):
+        """Get the parent gadgets container.
+        @return: The parent gadgets container.
+        """
+        return self.__parent
+
+    # 
--------------------------------------------------------------------------
+    # Get the gadget description object.
+    # 
--------------------------------------------------------------------------
+    def getDescription(self):
+        """Get the gadget description object.
+        @return: The gadget description object.
+        """
+        return self.__description
+
+    # 
--------------------------------------------------------------------------
+    # Get the gadget commands objects list.
+    # 
--------------------------------------------------------------------------
+    def getCommands(self):
+        """Get the gadget command objects list.
+        @return: The gadget commands objects list.
+        """
+        return self.__commands
+
+    # 
--------------------------------------------------------------------------
+    # Get a command object by it name.
+    # 
--------------------------------------------------------------------------
+    def getCommand(self, commandName):
+        """Get a command object by it name.
+        @param commandName: The name of the command.
+        @return: The command object as GadgetToken or None.
+        """
+        for command in self.__commands:
+            if command.getName() == commandName:
+                return command
+        return None
+
+    # 
--------------------------------------------------------------------------
+    # Get the commands name list.
+    # 
--------------------------------------------------------------------------
+    def getCommandsName(self):
+        """Get the commands name list.
+        @return: A list of strings.
+        """
+        result = []
+        for command in self.__commands:
+            result.append(command.getName())
+        return result
+
+    # 
--------------------------------------------------------------------------
+    # Get the parameter objects list.
+    # 
--------------------------------------------------------------------------
+    def getParameters(self):
+        """Get the parameter objects list.
+        @return: The parameter objects list.
+        """
+        return self.__parameters
+
+    # 
--------------------------------------------------------------------------
+    # Get a parameter object by it name.
+    # 
--------------------------------------------------------------------------
+    def getParameter(self, parameterName):
+        """Get a parameter object by it name.
+        @param parameterName: The name of the parameter.
+        @return: The parameter object or None.
+        """
+        for parameter in self.__parameters:
+            if parameter.getName() == parameterName:
+                return parameter
+        return None
+
+    # 
--------------------------------------------------------------------------
+    # Get the parameters name list.
+    # 
--------------------------------------------------------------------------
+    def getParametersName(self):
+        """Get the parameters name list.
+        @return: A list of strings.
+        """
+        result = []
+        for parameter in self.__parameters:
+            result.append(parameter.getName())
+        return result


Property changes on: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Gadget.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetDescription.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetDescription.py
                            (rev 0)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetDescription.py
    2009-03-13 12:13:59 UTC (rev 4052)
@@ -0,0 +1,112 @@
+#    Copyright (C) 2009 C2ME Sa
+#    Remi Jocaille <[email protected]>
+#    Distributed under the terms of the GNU General Public License
+#    http://www.gnu.org/copyleft/gpl.html
+
+# 
------------------------------------------------------------------------------
+# Gadget description.
+# 
------------------------------------------------------------------------------
+class GadgetDescription(object):
+    """Gadget description.
+    """
+
+    # 
--------------------------------------------------------------------------
+    # Constructor of the class.
+    # 
--------------------------------------------------------------------------
+    def __init__(self, parent, descriptionStruct):
+        """Constructor of the class.
+        @param parent: Parent gadget.
+        @param descriptionStruct: Description as dictionary.
+        """
+        self.__parent = parent
+        self.__structure = descriptionStruct
+
+    # 
--------------------------------------------------------------------------
+    # Get the parent gadget.
+    # 
--------------------------------------------------------------------------
+    def getParent(self):
+        """Get the parent gadget.
+        @return: A Gadget object.
+        """
+        return self.__parent
+
+    # 
--------------------------------------------------------------------------
+    # Get the gadget name.
+    # 
--------------------------------------------------------------------------
+    def getName(self):
+        """Get the gadget name.
+        @return: A string.
+        """
+        return self.__structure['name']
+
+    # 
--------------------------------------------------------------------------
+    # Get the translated name of the gadget.
+    # 
--------------------------------------------------------------------------
+    def getTranslatedName(self):
+        """Get the translated name of the gadget.
+        @return: A string.
+        """
+        return self.__structure['translated_name']
+
+    # 
--------------------------------------------------------------------------
+    # Get the uuid of the gadget.
+    # 
--------------------------------------------------------------------------
+    def getUuid(self):
+        """Get the uuid of the gadget.
+        @return: A string.
+        """
+        return self.__structure['uuid']
+
+    # 
--------------------------------------------------------------------------
+    # Get the author of the gadget.
+    # 
--------------------------------------------------------------------------
+    def getAuthor(self):
+        """Get the author of the gadget.
+        @return: A string.
+        """
+        return self.__structure['author']
+
+    # 
--------------------------------------------------------------------------
+    # Get the version of the gadget.
+    # 
--------------------------------------------------------------------------
+    def getVersion(self):
+        """Get the version of the gadget.
+        @return: A string.
+        """
+        return self.__structure['version']
+
+    # 
--------------------------------------------------------------------------
+    # Get the translated description of the gadget.
+    # 
--------------------------------------------------------------------------
+    def getDescription(self):
+        """Get the translated description of the gadget.
+        @return: A string.
+        """
+        return self.__structure['description']
+
+    # 
--------------------------------------------------------------------------
+    # Get the icon url of the gadget.
+    # 
--------------------------------------------------------------------------
+    def getIconFile(self):
+        """Get the icon url of the gadget.
+        @return: A string.
+        """
+        return self.__structure['icon_file']
+
+    # 
--------------------------------------------------------------------------
+    # Get the translated help url of the gadget.
+    # 
--------------------------------------------------------------------------
+    def getHelpFile(self):
+        """Get the translated help url of the gadget.
+        @return: A string.
+        """
+        return self.__structure['help_file']
+
+    # 
--------------------------------------------------------------------------
+    # Get the gadget tgf filename of the gadget.
+    # 
--------------------------------------------------------------------------
+    def getTgfFile(self):
+        """Get the gadget tgf filename of the gadget.
+        @return: A string.
+        """
+        return self.__structure['tgf_file']


Property changes on: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetDescription.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetParameter.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetParameter.py  
                            (rev 0)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetParameter.py  
    2009-03-13 12:13:59 UTC (rev 4052)
@@ -0,0 +1,108 @@
+#    Copyright (C) 2009 C2ME Sa
+#    Remi Jocaille <[email protected]>
+#    Distributed under the terms of the GNU General Public License
+#    http://www.gnu.org/copyleft/gpl.html
+
+# 
------------------------------------------------------------------------------
+# Gadget parameter.
+# 
------------------------------------------------------------------------------
+class GadgetParameter(object):
+
+    # 
--------------------------------------------------------------------------
+    # Constructor of the class.
+    # 
--------------------------------------------------------------------------
+    def __init__(self, parent, parametersStruct):
+        """Constructor of the class.
+        """
+        self.__parent = parent
+        self.__structure = parametersStruct
+
+    # 
--------------------------------------------------------------------------
+    # Get the parent gadget.
+    # 
--------------------------------------------------------------------------
+    def getParent(self):
+        """Get the parent gadget.
+        @return: The parent gadget.
+        """
+        return self.__parent
+
+    # 
--------------------------------------------------------------------------
+    # Get the name.
+    # 
--------------------------------------------------------------------------
+    def getName(self):
+        """Get the name.
+        @return: A string.
+        """
+        return self.__structure['name']
+
+    # 
--------------------------------------------------------------------------
+    # Get the type.
+    # 
--------------------------------------------------------------------------
+    def getType(self):
+        """Get the type.
+        @return: A string.
+        """
+        return self.__structure['type']
+
+    # 
--------------------------------------------------------------------------
+    # Get the default value.
+    # 
--------------------------------------------------------------------------
+    def getDefaultValue(self):
+        """Get the default value.
+        @return: A string.
+        """
+        return self.__structure['default_value']
+
+    # 
--------------------------------------------------------------------------
+    # Get the description.
+    # 
--------------------------------------------------------------------------
+    def getDescription(self):
+        """Get the description.
+        @return: A string.
+        """
+        return self.__structure['description']
+
+    # 
--------------------------------------------------------------------------
+    # Get the translated name.
+    # 
--------------------------------------------------------------------------
+    def getTranslatedName(self):
+        """Get the translated name.
+        @return: A string.
+        """
+        return self.__structure['translated_name']
+
+    # 
--------------------------------------------------------------------------
+    # Get the category.
+    # 
--------------------------------------------------------------------------
+    def getCategory(self):
+        """Get the category.
+        @return: A string.
+        """
+        return self.__structure['category']
+
+    # 
--------------------------------------------------------------------------
+    # Get the enumerated values.
+    # 
--------------------------------------------------------------------------
+    def getEnumValues(self):
+        """Get the enumerated values.
+        @return: A string.
+        """
+        return self.__structure['enum_values']
+
+    # 
--------------------------------------------------------------------------
+    # Get the minimal value.
+    # 
--------------------------------------------------------------------------
+    def getMinValue(self):
+        """Get the minimal value.
+        @return: A string.
+        """
+        return self.__structure['min_value']
+
+    # 
--------------------------------------------------------------------------
+    # Get the maximal value.
+    # 
--------------------------------------------------------------------------
+    def getMaxValue(self):
+        """Get the maximal value.
+        @return: A string.
+        """
+        return self.__structure['max_value']


Property changes on: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetParameter.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetToken.py
===================================================================
--- software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetToken.py  
                        (rev 0)
+++ software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetToken.py  
2009-03-13 12:13:59 UTC (rev 4052)
@@ -0,0 +1,56 @@
+#    Copyright (C) 2009 C2ME Sa
+#    Remi Jocaille <[email protected]>
+#    Distributed under the terms of the GNU General Public License
+#    http://www.gnu.org/copyleft/gpl.html
+
+# 
------------------------------------------------------------------------------
+# Gadget description.
+# 
------------------------------------------------------------------------------
+class GadgetToken(object):
+
+    # 
--------------------------------------------------------------------------
+    # Constructor of the class.
+    # 
--------------------------------------------------------------------------
+    def __init__(self, parent, tokenStructure):
+        """Constructor of the class.
+        @param parent: Parent Gadget.
+        @param tokenStructure: Token structure as dictionary.
+        """
+        self.__parent = parent
+        self.__structure = tokenStructure
+
+    # 
--------------------------------------------------------------------------
+    # Get the parent gadget.
+    # 
--------------------------------------------------------------------------
+    def getParent(self):
+        """Get the parent gadget.
+        @return: The parent gadget.
+        """
+        return self.__parent
+
+    # 
--------------------------------------------------------------------------
+    # Get the name.
+    # 
--------------------------------------------------------------------------
+    def getName(self):
+        """Get the name.
+        @return: A string.
+        """
+        return self.__structure['name']
+
+    # 
--------------------------------------------------------------------------
+    # Get the translated name.
+    # 
--------------------------------------------------------------------------
+    def getTranslatedName(self):
+        """Get the translated name.
+        @return: A string.
+        """
+        return self.__structure['translated_name']
+
+    # 
--------------------------------------------------------------------------
+    # Get the description.
+    # 
--------------------------------------------------------------------------
+    def getDescription(self):
+        """Get the description.
+        @return: A string.
+        """
+        return self.__structure['description']


Property changes on: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetToken.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetsContainer.py
===================================================================
--- 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetsContainer.py 
                            (rev 0)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetsContainer.py 
    2009-03-13 12:13:59 UTC (rev 4052)
@@ -0,0 +1,167 @@
+#    Copyright (C) 2009 C2ME Sa
+#    Remi Jocaille <[email protected]>
+#    Distributed under the terms of the GNU General Public License
+#    http://www.gnu.org/copyleft/gpl.html
+
+import threading
+
+from Gadget import Gadget
+
+# 
------------------------------------------------------------------------------
+# Gadgets container.
+# 
------------------------------------------------------------------------------
+class GadgetsContainer(object):
+
+    # 
--------------------------------------------------------------------------
+    # Constructor of the class.
+    # 
--------------------------------------------------------------------------
+    def __init__(self, structure):
+        """Constructor of the class.
+        @param structure: Gadget container structure as dictionary.
+        """
+        self.__language = "en"
+        self.__country = "US"
+        self.__locutor = "Ryan"
+        self.__pitch = 130
+        self.__mutex = threading.Lock()
+        self._update(structure)
+
+    # 
--------------------------------------------------------------------------
+    # Get the current container language.
+    # 
--------------------------------------------------------------------------
+    def getLanguage(self):
+        """Get the current container language.
+        @return: A string.
+        """
+        self.__mutex.acquire()
+        result = self.__language
+        self.__mutex.release()
+        return result
+
+    # 
--------------------------------------------------------------------------
+    # Get the current container country.
+    # 
--------------------------------------------------------------------------
+    def getCountry(self):
+        """Get the current container country.
+        @return: A string.
+        """
+        self.__mutex.acquire()
+        result = self.__country
+        self.__mutex.release()
+        return result
+
+    # 
--------------------------------------------------------------------------
+    # Get the current container locutor.
+    # 
--------------------------------------------------------------------------
+    def getLocutor(self):
+        """Get the current container locutor.
+        @return: A string.
+        """
+        self.__mutex.acquire()
+        result = self.__locutor
+        self.__mutex.release()
+        return result
+
+    # 
--------------------------------------------------------------------------
+    # Get the current container pitch.
+    # 
--------------------------------------------------------------------------
+    def getPitch(self):
+        """Get the current container pitch.
+        @return: An integer.
+        """
+        self.__mutex.acquire()
+        result = self.__pitch
+        self.__mutex.release()
+        return result
+
+    # 
--------------------------------------------------------------------------
+    # Update the container structure.
+    # 
--------------------------------------------------------------------------
+    def _update(self, structure):
+        """Update the container structure.
+        @param structure: The new container structure dictionary.
+        """
+        self.__mutex.acquire()
+        self.__gadgets = []
+        for key in structure.keys():
+            self.__gadgets.append(Gadget(self, structure[key]))
+        if len(self.__gadgets) > 0:
+            param = self.__gadgets[0].getParameter("language")
+            if param != None:
+                self.__language = param.getDefaultValue()
+            param = self.__gadgets[0].getParameter("country")
+            if param != None:
+                self.__country = param.getDefaultValue()
+            param = self.__gadgets[0].getParameter("locutor")
+            if param != None:
+                self.__locutor = param.getDefaultValue()
+            param = self.__gadgets[0].getParameter("pitch")
+            if param != None:
+                self.__pitch = int(param.getDefaultValue())
+        self.__mutex.release()
+
+    # 
--------------------------------------------------------------------------
+    # Get the gadget objects list.
+    # 
--------------------------------------------------------------------------
+    def getGadgets(self):
+        """Get the gadget objects list.
+        @return: A list of Gadget objects.
+        """
+        self.__mutex.acquire()
+        result = self.__gadgets
+        self.__mutex.release()
+        return result
+
+    # 
--------------------------------------------------------------------------
+    # Get the number of gadgets contains in the container.
+    # 
--------------------------------------------------------------------------
+    def getCount(self):
+        """Get the number of gadgets contains in the container.
+        @return: An integer.
+        """
+        self.__mutex.acquire()
+        result = len(self.__gadgets)
+        self.__mutex.release()
+        return result
+
+    # 
--------------------------------------------------------------------------
+    # Get a gadget object by it name.
+    # 
--------------------------------------------------------------------------
+    def getGadgetByName(self, gadgetName):
+        """Get a gadget object by it name.
+        @param gadgetName: The name of the gadget.
+        @return: A Gadget object or None.
+        """
+        self.__mutex.acquire()
+        for gadget in self.__gadgets:
+            if gadget.getDescription().getName() == gadgetName:
+                self.__mutex.release()
+                return gadget
+        self.__mutex.release()
+        return None
+
+    # 
--------------------------------------------------------------------------
+    # Get a gadget object by it uuid.
+    # 
--------------------------------------------------------------------------
+    def getGadgetByUuid(self, gadgetUuid):
+        """Get a gadget object by it uuid.
+        @param gadgetName: The uuid of the gadget.
+        @return: A Gadget object or None.
+        """
+        self.__mutex.acquire()
+        for gadget in self.__gadgets:
+            if gadget.getDescription().getUuid() == gadgetUuid:
+                self.__mutex.release()
+                return gadget
+        self.__mutex.release()
+        return None
+
+    # 
--------------------------------------------------------------------------
+    # Get a gadget object by it name.
+    # 
--------------------------------------------------------------------------
+    def getGadget(self, gadgetName):
+        """Get a gadget object by it name.
+        @param gadgetName: The name of the gadget.
+        @return: A Gadget object or None.
+        """
+        return self.getGadgetByName(gadgetName)


Property changes on: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/GadgetsContainer.py
___________________________________________________________________
Name: svn:keywords
   + Id

Added: software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/__init__.py
===================================================================


Property changes on: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/__init__.py
___________________________________________________________________
Name: svn:keywords
   + Id


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