Author: remi
Date: 2009-03-17 11:28:31 +0100 (Tue, 17 Mar 2009)
New Revision: 4107

Modified:
   
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
   software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Framework.py
   software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Gadget.py
Log:
* moved web gadgets functionalities frame "Framework" to "Gadget"

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-17 09:48:08 UTC (rev 4106)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
 2009-03-17 10:28:31 UTC (rev 4107)
@@ -112,12 +112,12 @@
             struct['help_file'] = helpUrl
             googleGadgetUrl = '/%s/google_gadget_code.txt' % 
description.getUuid()
             struct['google_gadget_code'] = googleGadgetUrl
-            googleGadgetCode = self.getFramework().generateGoogleGadgetCode(
-                description.getUuid(), gadget.getCommands()[0].getName(), {})
+            googleGadgetCode = gadget.generateGoogleGadgetCode(
+                gadget.getCommands()[0].getName(), {})
             resourcesManager.addContentToServe(googleGadgetCode,
                 googleGadgetUrl)
-            struct['web_gadget_url'] = self.getFramework().getWebGadgetUrl(
-                description.getUuid(), gadget.getCommands()[0].getName(), {})
+            struct['web_gadget_url'] = gadget.getWebGadgetUrl(
+                gadget.getCommands()[0].getName(), {})
             description.setStructure(struct)
         self.__publishEvents(True, ST_NAME_FW_CONTAINER_DEPLOYED, ["True",])
 
@@ -346,8 +346,12 @@
             param = paramStruct.split("=")
             if len(param) == 2:
                 params[param[0]] = param[1]
-        structure = 
resourceGadgetFramework.getFramework().generateWebGadgetStructureByUuid(
-            parameters['uuid'], parameters['command'], params)
+        uuid = parameters['uuid']
+        gadget = 
resourceGadgetFramework.getFramework().getGadgetsContainer().getGadgetByUuid(uuid)
+        structure = None
+        if gadget != None:
+            structure = 
gadget.generateWebGadgetStructure(parameters['command'],
+                params)
         if structure == None:
             contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
         else:

Modified: 
software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Framework.py
===================================================================
--- software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Framework.py    
2009-03-17 09:48:08 UTC (rev 4106)
+++ software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Framework.py    
2009-03-17 10:28:31 UTC (rev 4107)
@@ -11,27 +11,6 @@
 from GadgetsContainer import GadgetsContainer
 from util.logger.SimpleLogger import *
 
-GOOGLE_GADGET_BASE_CODE = '''<?xml version="1.0" encoding="UTF-8"?>
-<Module>
-<ModulePrefs
-    title="Tux Droid : %s"
-    title_url="http://www.kysoh.com";
-    height="300"
-    scaling="false"
-    author="%s"
-    author_link="http://www.kysoh.com";
-    description="%s"
-    screenshot="http://127.0.0.1:270%s";
-    thumbnail="http://127.0.0.1:270%s";>
-</ModulePrefs>
-<Content type="html"><![CDATA[
-<body>
-    <iframe src='%s' width=800 height=300 frameborder=0 scrolling=false>
-</body>
-]]></Content>
-</Module>
-'''
-
 # 
------------------------------------------------------------------------------
 # Framework class.
 # 
------------------------------------------------------------------------------
@@ -317,92 +296,6 @@
         self.__onGagdetStoppedCallback = funct
 
     # 
--------------------------------------------------------------------------
-    # Generate a web gadget structure.
-    # TODO : Move this to the Gadget class.
-    # 
--------------------------------------------------------------------------
-    def generateWebGadgetStructureByUuid(self, gadgetUuid, gadgetCommand,
-        parameters = {}):
-        """Generate a web gadget structure.
-        @param gadgetUuid: Gadget uuid.
-        @param gadgetCommand: Gadget command.
-        @param parameters: Parameters dictionary.
-        """
-        if not self.__frameworkBridge.isStarted():
-            return None
-        gadget = self.getGadgetsContainer().getGadgetByUuid(gadgetUuid)
-        if gadget == None:
-            return None
-        import copy
-        structure = copy.deepcopy(gadget.getStructure())
-        del structure['commands']
-        # Serialize enum values
-        for key in structure['parameters']:
-            param = structure['parameters'][key]
-            if param['type'] == 'enum':
-                values = param['enum_values'].split(",")
-                enums = {}
-                for i, value in enumerate(values):
-                    dName = "enum_%.2d" % i
-                    if value != '':
-                        enums[dName] = value
-                param['enum_values'] = enums
-        # Insert the command
-        structure['command'] = gadgetCommand
-        # Fill the parameters
-        for key in parameters:
-            if key in gadget.getParametersName():
-                for sKey in structure['parameters']:
-                    param = structure['parameters'][sKey]
-                    if param['name'] == key:
-                        param['default_value'] = parameters[key]
-                        param['category'] = 'internals'
-        return structure
-
-    # 
--------------------------------------------------------------------------
-    # Get the url for a web gadget.
-    # TODO : Move this to the Gadget class.
-    # 
--------------------------------------------------------------------------
-    def getWebGadgetUrl(self, gadgetUuid, gadgetCommand,
-        parameters = {}):
-        """Get the url for a web gadget.
-        @param gadgetUuid: Gadget uuid.
-        @param gadgetCommand: Gadget command.
-        @param parameters: Parameters dictionary.
-        """
-        params = ""
-        for key in parameters:
-            params += "%s=%s|" % (key, parameters[key])
-        url = 
"http://127.0.0.1:270/gadget_framework/web_gadget?uuid=%s&command=%s&parameters=%s";
 % (
-            gadgetUuid, gadgetCommand, params)
-        return url
-
-    # 
--------------------------------------------------------------------------
-    # Generate the code of a google gadget.
-    # TODO : Move this to the Gadget class.
-    # 
--------------------------------------------------------------------------
-    def generateGoogleGadgetCode(self, gadgetUuid, gadgetCommand,
-        parameters = {}):
-        """Generate the code of a google gadget.
-        @param gadgetUuid: Gadget uuid.
-        @param gadgetCommand: Gadget command.
-        @param parameters: Parameters dictionary.
-        """
-        if not self.__frameworkBridge.isStarted():
-            return None
-        gadget = self.getGadgetsContainer().getGadgetByUuid(gadgetUuid)
-        if gadget == None:
-            return None
-        url = self.getWebGadgetUrl(gadgetUuid, gadgetCommand, parameters)
-        result = GOOGLE_GADGET_BASE_CODE % (
-            gadget.getDescription().getName(),
-            gadget.getDescription().getAuthor(),
-            gadget.getDescription().getDescription(),
-            gadget.getDescription().getIconFile(),
-            gadget.getDescription().getIconFile(),
-            url)
-        return result
-
-    # 
--------------------------------------------------------------------------
     # Kill sub-process of a gadget.
     # TODO : This functionality must be moved to the java gadget-framework,
     # directly at the method "abort" of the "GadgetInstance.java" source.

Modified: software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Gadget.py
===================================================================
--- software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Gadget.py       
2009-03-17 09:48:08 UTC (rev 4106)
+++ software_suite_v2/tuxware/tuxdroidserver/trunk/util/gadgets/Gadget.py       
2009-03-17 10:28:31 UTC (rev 4107)
@@ -7,6 +7,28 @@
 from GadgetParameter import GadgetParameter
 from GadgetToken import GadgetToken
 
+# Base code of a google gadget
+GOOGLE_GADGET_BASE_CODE = '''<?xml version="1.0" encoding="UTF-8"?>
+<Module>
+<ModulePrefs
+    title="Tux Droid : %s"
+    title_url="http://www.kysoh.com";
+    height="300"
+    scaling="false"
+    author="%s"
+    author_link="http://www.kysoh.com";
+    description="%s"
+    screenshot="http://127.0.0.1:270%s";
+    thumbnail="http://127.0.0.1:270%s";>
+</ModulePrefs>
+<Content type="html"><![CDATA[
+<body>
+    <iframe src='%s' width=800 height=300 frameborder=0 scrolling=false>
+</body>
+]]></Content>
+</Module>
+'''
+
 # 
------------------------------------------------------------------------------
 # Gadget class.
 # 
------------------------------------------------------------------------------
@@ -177,3 +199,81 @@
             # TODO : Will be removed
             framework._killSubProcessOfAGadget(self.getDescription().getUuid())
             return True
+
+    # 
==========================================================================
+    # WEB GADGET Generators
+    # 
==========================================================================
+
+    # 
--------------------------------------------------------------------------
+    # Generate a web gadget structure.
+    # 
--------------------------------------------------------------------------
+    def generateWebGadgetStructure(self, command, parameters = {}):
+        """Generate a web gadget structure.
+        @param command: Gadget command.
+        @param parameters: Parameters dictionary.
+        """
+        framework = self.getContainer().getFramework()
+        if not framework.isStarted():
+            return None
+        import copy
+        structure = copy.deepcopy(self.getStructure())
+        del structure['commands']
+        # Serialize enum values
+        for key in structure['parameters']:
+            param = structure['parameters'][key]
+            if param['type'] == 'enum':
+                values = param['enum_values'].split(",")
+                enums = {}
+                for i, value in enumerate(values):
+                    dName = "enum_%.2d" % i
+                    if value != '':
+                        enums[dName] = value
+                param['enum_values'] = enums
+        # Insert the command
+        structure['command'] = command
+        # Fill the parameters
+        for key in parameters:
+            if key in self.getParametersName():
+                for sKey in structure['parameters']:
+                    param = structure['parameters'][sKey]
+                    if param['name'] == key:
+                        param['default_value'] = parameters[key]
+                        param['category'] = 'internals'
+        return structure
+
+    # 
--------------------------------------------------------------------------
+    # Get the url for a web gadget.
+    # 
--------------------------------------------------------------------------
+    def getWebGadgetUrl(self, command, parameters = {}):
+        """Get the url for a web gadget.
+        @param command: Gadget command.
+        @param parameters: Parameters dictionary.
+        """
+        params = ""
+        for key in parameters:
+            params += "%s=%s|" % (key, parameters[key])
+        uuid = self.getDescription().getUuid()
+        url = 
"http://127.0.0.1:270/gadget_framework/web_gadget?uuid=%s&command=%s&parameters=%s";
 % (
+            uuid, command, params)
+        return url
+
+    # 
--------------------------------------------------------------------------
+    # Generate the code of a google gadget.
+    # 
--------------------------------------------------------------------------
+    def generateGoogleGadgetCode(self, command, parameters = {}):
+        """Generate the code of a google gadget.
+        @param command: Gadget command.
+        @param parameters: Parameters dictionary.
+        """
+        framework = self.getContainer().getFramework()
+        if not framework.isStarted():
+            return None
+        url = self.getWebGadgetUrl(command, parameters)
+        result = GOOGLE_GADGET_BASE_CODE % (
+            self.getDescription().getName(),
+            self.getDescription().getAuthor(),
+            self.getDescription().getDescription(),
+            self.getDescription().getIconFile(),
+            self.getDescription().getIconFile(),
+            url)
+        return result


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