removi um montão de coisas
[remotepc] / pcremote-server-desktop / services / ObjectServers.py
diff --git a/pcremote-server-desktop/services/ObjectServers.py b/pcremote-server-desktop/services/ObjectServers.py
deleted file mode 100755 (executable)
index dfbe76c..0000000
+++ /dev/null
@@ -1,294 +0,0 @@
-# -*- coding: utf-8 -*-
-
-# ****************************************************************************
-# Copyright (c) 2008 INdT/Fucapi.
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-# ============================================================================
-# Project Name : PC Remote
-# Author       : Nilson Silva, Jonatas Isvi, Andre Portela
-# Email        : fergus.mao@gmail.com, jonatas.nona@gmail.com,
-#               andre_portela_@hotmail.com
-# Reviewer     : Jônatas Isvi
-# Email        : 
-# Version      : 1.0
-# Package      : services
-# Description  : Mouse Server, Keyboard Server
-# ============================================================================
-
-import time
-from utils.labels import *
-from ServerHandlers import *
-from players import amarok
-
-class Mouse_Server:
-
-    """ Mouse Server
-    Defines all mouse behaviors.
-    Clicks and coordinates.
-    """
-
-    #Initialize the class
-    def __init__(self, service):
-        self._service_name = service
-        self.mouse  = Mouse()
-        self.labels = Labels()
-       self.timer  = time
-        self.timerclick = 0
-        
-        self.fg_dbclick = False
-        self.fg_move = True
-        self.x = 0      
-        self.y = 0
-
-    #Executes the action requested by the Service Manager
-    def execute(self, command):
-
-        self.mouse_counter_lclick()
-
-        if (command == self.labels.CLICK):
-            self.mouse_click()
-        elif (command == self.labels.DOUBLE_CLICK):
-            self.mouse_press_dbclick()
-        elif (command == self.labels.TRIPLE_CLICK):
-            self.mouse_release_dbclick()
-        elif (command == self.labels.LEFT_CLICK):
-            self.mouse_lclick()
-        elif (command == self.labels.MIDDLE_CLICK):
-            self.mouse_mclick()
-        elif (command == self.labels.RIGHT_CLICK):
-            self.mouse_rclick()
-        elif (command[0] == "#"):
-            self.mouse_fator(command)
-        else:
-            self.mouse_move(command)
-
-    #Gets the time the mouse pointer is pressed. If It is greater than (or equal to) 2s, The Mouse Left Click is activated.
-    def mouse_counter_lclick(self):
-                 
-        if ((not self.fg_move) and ((int(self.timer.time()) - self.timerclick) >= 2)):
-            self.mouse.right_click(True)
-            self.mouse.right_click(False)
-            self.timerclick = 0
-            self.fg_move = True
-
-    #Mouse Pointer - Single Click
-    def mouse_click(self):
-        self.timerclick = int(self.timer.time())
-        self.fg_move = False
-
-    #Mouse Pointer - Double Click
-    def mouse_press_dbclick(self):
-        self.mouse.left_click(True)
-        self.fg_dbclick = True
-
-    #Mouse Pointer - Released after a Double Click
-    def mouse_release_dbclick(self):
-        if self.fg_dbclick:
-            self.mouse.left_click(False)
-            self.fg_dbclick = False
-
-    #Mouse Left Click
-    def mouse_lclick(self):
-        self.mouse.left_click()
-
-    #Mouse Middle Click
-    def mouse_mclick(self):
-        self.mouse.middle_click()
-
-    #Mouse Right Click
-    def mouse_rclick(self):
-        self.mouse.right_click()
-
-    #Sets the factor of the Mouse Pointer Move
-    def mouse_fator(self, command):
-        num = ""
-        for i in range(1, len(command)):
-            num = num + command(i)
-
-        self.mouse.set_fator(int(num))
-
-    #Moves the Mouse Pointer
-    def mouse_move(self, command):
-        coord = command.split(",")
-
-        i = int(coord[0]) - self.x
-        if ((abs(i) == 1) or (abs(i) >= 20)):
-            i = 0
-
-        j = int(coord[1]) - self.y
-        if ((abs(j) == 1) or (abs(j) >= 20)):
-            j = 0
-
-        if not ((i == 0) and (j == 0)):            
-            if ((i >= 4) or (j >= 4)):
-                self.fg_move = True
-            if self._service_name == "Tablet":
-                self.mouse.position(i, j)
-            else:
-                self.mouse.position(-j, i)
-
-        self.x = int(coord[0])
-        self.y = int(coord[1])
-
-    def clean_up(self):
-       self.mouse.clean_up()
-
-class KeyBoard_Server:
-
-    """ Keyboard Server
-    Defines all keyboard behaviors.
-    Map keys and events.
-    """    
-
-    def __init__(self, service):
-       self.keyboard = Keyboard()
-       self.shift_flag = False
-       self.control_flag = False
-       self.alt_flag = False
-        self._service_name = service
-
-    # execute key command
-    def execute(self, command):
-       
-       print "\n", command
-
-       if(command == 'F8'):
-           self.keyboard.reproduce_key_press('Control_L')
-           self.keyboard.reproduce_key_press('z')
-           self.keyboard.reproduce_key_release('z')
-           self.keyboard.reproduce_key_release('Control_L')
-        elif(self._service_name == 'Slideshow' and command == 'F6'):
-            self.keyboard.reproduce_key_press('F5')
-            self.keyboard.reproduce_key_release('F5')
-       elif(command == 'Control_R'):
-           self.control_flag = True
-           self.keyboard.reproduce_key_press('Control_R')
-           #self.keys.append(command)
-       elif(command == 'Shift_L'):
-           self.shift_flag = True
-           self.keyboard.reproduce_key_press('Shift_L')
-           #self.keys.append(command)
-       elif(command == 'Alt_L'):
-           self.alt_flag = True
-           self.keyboard.reproduce_key_press('Alt_L')
-       elif(command == 'F7'):
-           self.keyboard.reproduce_key_press('Control_L')
-           self.keyboard.reproduce_key_press('y')
-           self.keyboard.reproduce_key_release('y')
-           self.keyboard.reproduce_key_release('Control_L')
-       elif(command == 'Alt+F1'):
-           self.keyboard.reproduce_key_press('Alt_L')
-           self.keyboard.reproduce_key_press('F1')
-           self.keyboard.reproduce_key_release('F1')
-           self.keyboard.reproduce_key_release('Alt_L')
-        elif(command == 'Alt+F2'):
-           self.keyboard.reproduce_key_press('Alt_L')
-           self.keyboard.reproduce_key_press('F2')
-           self.keyboard.reproduce_key_release('F2')
-           self.keyboard.reproduce_key_release('Alt_L')
-       elif(command == 'Alt+F4'):
-           self.keyboard.reproduce_key_press('Alt_L')
-           self.keyboard.reproduce_key_press('F4')
-           self.keyboard.reproduce_key_release('F4')
-           self.keyboard.reproduce_key_release('Alt_L')
-       elif(command == 'Alt+F9'):
-           self.keyboard.reproduce_key_press('Alt_L')
-           self.keyboard.reproduce_key_press('F9')
-           self.keyboard.reproduce_key_release('F9')
-           self.keyboard.reproduce_key_release('Alt_L')
-       elif(command == 'Alt+F0'):
-           self.keyboard.reproduce_key_press('Alt_L')
-           self.keyboard.reproduce_key_press('F10')
-           self.keyboard.reproduce_key_release('F10')
-           self.keyboard.reproduce_key_release('Alt_L')
-       elif(command == 'Alt+Space'):
-           self.keyboard.reproduce_key_press('Alt_L')
-           self.keyboard.reproduce_key_press('space')
-           self.keyboard.reproduce_key_release('space')
-           self.keyboard.reproduce_key_release('Alt_L')
-       elif(command == 'Tab'):
-           self.keyboard.reproduce_key_press('Tab')
-           self.keyboard.reproduce_key_release('Tab')
-       else:
-           self.keyboard.reproduce_key_press(command)
-           self.keyboard.reproduce_key_release(command)
-                       
-           if self.shift_flag:
-               self.keyboard.reproduce_key_release('Shift_L')
-               #self.keys.remove('Shift_L')
-               self.shift_flag = False
-           elif self.control_flag:
-               self.keyboard.reproduce_key_release('Control_R')
-               #self.keys.remove('Control_R')
-               self.control_flag = False
-           elif self.alt_flag:
-               self.keyboard.reproduce_key_release('Alt_L')
-               self.alt_flag = False
-       
-    # clean all keys pressed                   
-    def clean_up(self):
-       self.keyboard.clean_up()
-
-class Player_Server():
-
-    def __init__(self):
-        if not amarok.isRunning():
-            self.player = amarok.AmarokPlayer()
-        else:
-            amarok.start()
-            self.player = amarok.AmarokPlayer()
-        self.labels = Labels()
-
-    def execute(self, command):
-        if len(command) > 2:
-            if command[1] == self.labels.PLAY:
-                if command[2] and command[3]:
-                    self.player.play(track=int(command[2]), rmd=bool(command[3]))      
-                elif command[2]:
-                    arg = int(command[2])
-                    if isinstance(arg, int):
-                        self.player.play(track=arg)
-                    else:
-                        arg = bool(command[2])
-                        self.player.play(rmd=arg)
-                else:
-                    pass
-        else:
-            if command[1] == self.labels.STOP:
-                self.player.stop()
-            elif command[1] == self.labels.PLAY:
-                self.player.play()
-            elif command[1] == self.labels.PAUSE:
-                self.player.pause()
-            elif command[1] == self.labels.NEXT:
-                self.player.next()
-            elif command[1] == self.labels.PREVIOUS:
-                self.player.prev()
-            elif command[1] == self.labels.VOL_UP:
-                self.player.volume_up()
-            elif command[1] == self.labels.VOL_DOWN:
-                self.player.volume_down()
-            elif command[1] == self.labels.SEEK:
-                self.player.seek(int(command[2]))
-            elif command[1] == self.labels.DOWNLOAD:
-                path = self.player.file_properties()
-                addr = command[2]
-                amarok.send_file(addr, path)
-                pass
-            elif command[1] == self.labels.LOAD_PLAYLIST:
-                # falta o metodo de trasnferencia
-                pass
-            else:
-                pass