Author: remi
Date: 2009-04-06 18:06:04 +0200 (Mon, 06 Apr 2009)
New Revision: 4360
Modified:
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/03_advanced_api/resourceTaskCreation.py
Log:
* added a method and a service to schedule an attitune
* fixed typo
Modified:
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/03_advanced_api/resourceTaskCreation.py
===================================================================
---
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/03_advanced_api/resourceTaskCreation.py
2009-04-06 16:05:08 UTC (rev 4359)
+++
software_suite_v2/tuxware/tuxdroidserver/trunk/resources/03_advanced_api/resourceTaskCreation.py
2009-04-06 16:06:04 UTC (rev 4360)
@@ -72,6 +72,30 @@
return resourceScheduler.createTask(command, arguments, taskType,
taskName, weekMask, hour, minute, second, year, month, day, data)
+ def createTaskPlayAttitune(self, attituneName, taskType, taskName,
weekMask,
+ hour, minute, second, year, month, day):
+ """Create a task to start a gadget.
+ @param attituneName: Attitune name.
+ @param taskType: <EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE AT|
+ ONCE DELAYED>
+ @param taskName: Task name.
+ @param weekMask: Week mask. [True, True, True, True, True, True, True]
+ @param hour: <0..23>
+ @param minute: <0..59>
+ @param second: <0..59>
+ @param year: Year.
+ @param month: <1..12>
+ @param day: <1..31>
+ """
+ command = "resourceAttituneManager.playAttitune"
+ arguments = (attituneName, 0.0)
+ data = {
+ 'commandType' : 'attitune_play',
+ 'attituneName' : attituneName,
+ }
+ return resourceScheduler.createTask(command, arguments, taskType,
+ taskName, weekMask, hour, minute, second, year, month, day, data)
+
# Create an instance of the resource
resourceTaskCreation = TDSResourceTaskCreation("resourceTaskCreation")
# Register the resource into the resources manager
@@ -100,7 +124,7 @@
self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
self.exclusiveExecution = False
self.name = "start_gadget"
- self.comment = "Create a sheduled task to start a gadget."
+ self.comment = "Create a scheduled task to start a gadget."
def execute(self, id, parameters):
headersStruct = self.getDefaultHeadersStruct()
@@ -159,7 +183,7 @@
self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
self.exclusiveExecution = False
self.name = "stop_gadget"
- self.comment = "Create a sheduled task to stop a gadget."
+ self.comment = "Create a scheduled task to stop a gadget."
def execute(self, id, parameters):
headersStruct = self.getDefaultHeadersStruct()
@@ -189,3 +213,55 @@
# Register the service into the resource
resourceTaskCreation.addService(TDSServiceTaskCreationStopGadgetTask)
+
+#
------------------------------------------------------------------------------
+# Declaration of the service "play_attitune".
+#
------------------------------------------------------------------------------
+class TDSServiceTaskCreationPlayAttitune(TDSService):
+
+ def configure(self):
+ self.parametersDict = {
+ 'attitune_name' : 'string',
+ 'task_type' : '<EVERY X|EVERY X FROM FULL HOUR|DAILY AT|ONCE
AT|ONCE DELAYED>',
+ 'task_name' : 'string',
+ 'week_mask' : 'string',
+ 'hour' : 'uint8',
+ 'minute' : 'uint8',
+ 'second' : 'uint8',
+ 'year' : 'int',
+ 'month' : 'int8',
+ 'day' : 'int8',
+ }
+ self.minimalUserLevel = TDS_CLIENT_LEVEL_ANONYMOUS
+ self.exclusiveExecution = False
+ self.name = "play_attitune"
+ self.comment = "Create a scheduled task to play an attitune."
+
+ def execute(self, id, parameters):
+ headersStruct = self.getDefaultHeadersStruct()
+ contentStruct = self.getDefaultContentStruct()
+ contentStruct['root']['result'] = getStrError(E_TDREST_SUCCESS)
+ attituneName = parameters['attitune_name']
+ taskType = parameters['task_type']
+ taskName = parameters['task_name']
+ weekMask =
resourceScheduler.weekMaskStringToList(parameters['week_mask'])
+ hour = parameters['hour']
+ minute = parameters['minute']
+ second = parameters['second']
+ year = parameters['year']
+ month = parameters['month']
+ day = parameters['day']
+ id, name = resourceTaskCreation.createTaskPlayAttitune(attituneName,
+ taskType, taskName, weekMask, hour, minute, second, year, month,
+ day)
+ if id != None:
+ contentStruct['root']['data'] = {
+ 'id' : id,
+ 'name' : name,
+ }
+ else:
+ contentStruct['root']['result'] = getStrError(E_TDREST_FAILED)
+ return headersStruct, contentStruct
+
+# Register the service into the resource
+resourceTaskCreation.addService(TDSServiceTaskCreationPlayAttitune)
------------------------------------------------------------------------------
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn