778745b42214430db5d787ae4a0891e348b2e2fc
[remotepc] / pcremote-server-desktop-60 / debian / pcremote-server / usr / share / pcremote-server / services / service.py
1 # -*- coding: utf-8 -*-
2
3 # ****************************************************************************
4 # Copyright (c) 2008 INdT/Fucapi.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 #  This program is distributed in the hope that it will be useful,
11 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #  GNU Lesser General Public License for more details.
14 #
15 #  You should have received a copy of the GNU Lesser General Public License
16 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #
18 # ============================================================================
19 # Project Name : PC Remote
20 # Author       : Nilson Silva, Jonatas Isvi
21 # Email        : fergus.mao@gmail.com, jonatas.nona@gmail.com
22 # Reviewer     : Jônatas Isvi
23 # Email        :
24 # Version      : 1.0
25 # Package      : Main Application
26 # Description  : Service Application
27 # ============================================================================
28
29 from ObjectServers import *
30
31 class Service:
32     
33     """ Service
34     supports all services applications
35     """    
36
37     def __init__(self):
38         self.mouse_srv = None
39         self.keyboard_srv = None
40         self.player = None
41         self.service = ""
42         self.addr = None
43
44     #Set the Service requested by the Service Manager
45     def set_service(self, command):
46
47         self.service = command
48
49         if self.service == 'Tablet':
50             self.mouse_srv    = Mouse_Server(self.service)
51             self.keyboard_srv = KeyBoard_Server(self.service)
52         elif self.service == 'Slideshow':
53             self.mouse_srv     = Mouse_Server(self.service)
54             self.keyboard_srv = KeyBoard_Server(self.service)   
55         elif self.service == 'Player':
56             self.player_srv = Player_Server()
57         elif self.service == 'Torrent':
58             print "torrent service."
59
60     #Returns the Service which is being executed
61     def get_service(self):
62         return self.service
63
64     #Executes the action requested by the Service Manager
65     def execute(self, command):
66         
67         cmd = command.split(":")
68
69         if cmd[0] == "Mouse":
70             self.mouse_srv.execute(cmd[1])
71         elif cmd[0] == "Keyboard":
72             self.keyboard_srv.execute(cmd[1])
73         elif cmd[0] == "Player":
74             if self.addr:
75                 cmd += self.addr
76                 self.player_srv.execute(cmd)
77             else:
78                 self.player_srv.execute(cmd)
79
80     def set_address_to_download(self, addr):
81         self.addr = addr
82    
83     # clean all button and keys pressed
84     def clean_all(self):
85         self.mouse_srv.clean_up()
86         self.keyboard_srv.clean_up()
87
88 #teste unitario
89 if __name__ == '__main__':
90     import utils.plistparser