Author: remi
Date: 2009-03-16 16:18:23 +0100 (Mon, 16 Mar 2009)
New Revision: 4088

Modified:
   
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
Log:
* added a service to show a web gadget
* added some informations in the gadget description

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-16 15:16:53 UTC (rev 4087)
+++ 
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/01_robot_system/resourceGadgetFramework.py
 2009-03-16 15:18:23 UTC (rev 4088)
@@ -100,6 +100,8 @@
         for gadget in self.__framework.getGadgetsContainer().getGadgets():
             description = gadget.getDescription()
             struct = description.getStructure()
+            workingPath = 
os.path.split(os.path.split(description.getIconFile())[0])[0]
+            struct['working_path'] = workingPath
             pngUrl = '/%s/gadget.png' % description.getUuid()
             helpUrl = '/%s/help.html' % description.getUuid()
             resourcesManager.addFileToServe(description.getIconFile(),
@@ -108,6 +110,14 @@
                 helpUrl)
             struct['icon_file'] = pngUrl
             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(), {})
+            resourcesManager.addContentToServe(googleGadgetCode,
+                googleGadgetUrl)
+            struct['web_gadget_url'] = self.getFramework().getWebGadgetUrl(
+                description.getUuid(), gadget.getCommands()[0].getName(), {})
             description.setStructure(struct)
         self.__publishEvents(True, ST_NAME_FW_CONTAINER_DEPLOYED, ["True",])
 
@@ -309,6 +319,45 @@
 resourceGadgetFramework.addService(TDSServiceGadgetFrameworkGadgetsInfos)
 
 # 
------------------------------------------------------------------------------
+# Declaration of the service "web_gadget".
+# 
------------------------------------------------------------------------------
+class TDSServiceGadgetFrameworkWebGadget(TDSService):
+
+    def configure(self):
+        self.parametersDict = {
+            'uuid' : 'string',
+            'command' : 'string',
+            'parameters' : 'string',
+        }
+        self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
+        self.exclusiveExecution = False
+        self.name = "web_gadget"
+        self.comment = "Web view of a gadget."
+        self.haveXsl = True
+        self.xslPath = "/data/xsl/web_gadget.xsl"
+
+    def execute(self, id, parameters):
+        headersStruct = self.getDefaultHeadersStruct()
+        contentStruct = self.getDefaultContentStruct()
+        contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
+        splParams = parameters['parameters'].split("|")
+        params = {}
+        for paramStruct in splParams:
+            param = paramStruct.split("=")
+            if len(param) == 2:
+                params[param[0]] = param[1]
+        structure = 
resourceGadgetFramework.getFramework().generateWebGadgetStructureByUuid(
+            parameters['uuid'], parameters['command'], params)
+        if structure == None:
+            contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
+        else:
+            contentStruct['root']['data'] = structure
+        return headersStruct, contentStruct
+
+# Register the service into the resource
+resourceGadgetFramework.addService(TDSServiceGadgetFrameworkWebGadget)
+
+# 
------------------------------------------------------------------------------
 # Declaration of the service "start_gadget_by_uuid".
 # 
------------------------------------------------------------------------------
 class TDSServiceGadgetFrameworkStartGadgetByUuid(TDSService):


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