+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Description : BluetoothConnectionManager
-# ============================================================================
-
-
-import bluetooth
-from exceptions import *
-from genericconnectionmanager import *
-
-class BluetoothConnectionError(Exception):
- pass
-
-class BluetoothConnectionManager(GenericConnectionManager):
-
- def __init__(self):
- GenericConnectionManager.__init__(self)
- print "BluetoothConnectionManager iniciado."
- # globals data variables
- self.sock = None
- self.port = None
- self.address = None
- self.client_sock = None
- self.client_address = None
-
- # fast way to create a simple server
- def create_server(self, protocol, port):
- self.create_socket(protocol)
- self.set_port(port)
- self.bind()
- self.listen()
- self.accept()
-
- # fast way to create a simple client
- def create_client(self, protocol, address, port):
- self.create_socket(protocol)
- self.set_address(address)
- self.set_port(port)
- self.connect()
-
- # search for all devices
- def find_devices(self, time=8):
- list_devices = bluetooth.discover_devices(lookup_names = True, duration=time)
- if list_devices:
- return list_devices
- else:
- raise BluetoothConnectionError, "Device were not found."
-
- # search the device port
- def find_port(self, addr):
- port = None
- aux = addr.split(":")
- if len(aux) == 6:
- services = bluetooth.find_service(address=addr)
- for i in range(len(services)):
- port = services[i]['port']
-
- if port != None:
- return port
- else:
- raise BluetoothConnectionError, "Port not found."
-
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # search device services
- def find_services(self, service=None, addr=None):
- if service == None and addr == None:
- list = bluetooth.find_service()
- # returns all services
- return list
- elif service != None and addr == None:
- list = bluetooth.find_service(name=service)
- # returns only the device services indicated by name
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Name of the service does not exist."
- elif service == None and addr != None:
- number = addr.split(":")
- # returns only the device services indicated by address
- if(len(number) == 6):
- list = bluetooth.find_service(address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
- elif service != None and addr != None:
- number = addr.split(":")
- # returns only the device service indicated by address
- if(len(number) == 6):
- list = bluetooth.find_service(name=service, address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
-
-
- # search the device indicated by name
- def find_device_address_by_name(self, device_name):
- list = bluetooth.discover_devices()
- addr = None
-
- for address in list:
- if device_name == bluetooth.lookup_name(address):
- addr = address
- break
- if addr:
- return addr
- else:
- raise BluetoothConnectionError, "Device name not found."
-
-
- def find_devices_only_names(self):
- list = self.find_devices()
- list_names = []
- for address, names in list:
- list_names += [names]
-
- if list_names:
- return list_names
- else:
- raise BluetoothConnectionError, "Devices were not found."
-
- # get the client address
- def get_client_address(self):
- return self.client_address
-
- # set the port to communicate
- def set_port(self, port):
- self.port = port
-
- # get the port to communicate
- def get_port(self):
- return self.port
-
- # set the device address
- def set_address(self, address):
- aux = address.split(":")
- if len(aux) == 6:
- self.address = address
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # get the device address
- def get_address(self):
- return self.address
-
- # create a socket with a determinated protocol
- def create_socket(self, protocol=None):
- if protocol == 'rfcomm' or protocol == 'RFCOMM':
- self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
- elif protocol == 'l2cap' or protocol == 'L2CAP':
- self.sock = bluetooth.BluetoothSocket(bluetooth.L2CAP)
- else:
- raise BluetoothConnectionError, "Undefined Protocol."
-
- # bind the communication
- def bind(self):
- self.sock.bind(("", self.get_port()))
-
- # just listen the tube, only to server
- def listen(self):
- self.sock.listen(1)
-
- # accept the client communication
- # returns an object
- def accept(self):
- self.client_sock, self.client_address = self.sock.accept()
-
- # connect devices
- def connect(self):
- self.sock.connect((self.get_address(), self.get_port()))
-
- # send string message
- def send_message(self, msg=None):
- self.sock.send(msg)
-
- # receive string message
- def received_message(self):
- return self.client_sock.recv(1024)
-
- # close connection
- def close(self):
- if self.sock != None and self.client_sock != None:
- self.client_sock.close()
- self.sock.close()
- elif self.sock != None and self.client_sock == None:
- self.sock.close()
- else:
- self.client_sock.close()
-
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela@hotmail.com
-# Version : 1.0
-# Description : GenericConnectionManager Class
-# ============================================================================
-
-
-class GenericConnectionManager:
-
- def __init__(self):
- print "GenericConnectionManager iniciado."
- self.tipo = "generico"
-
- def identify_app(self):
- print "identify_app"
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Description : Interface Class, connection manager
-# ============================================================================
-
-from wirelessconnectionmanager import *
-from bluetoothconnectionmanager import *
-from exceptions import *
-
-
-# connections aliases
-_btconst = ['bluetooth', 'BLUETOOTH', 'blue']
-_wificonst = ['wireless', 'WIRELESS', 'wifi']
-
-class Iconnection:
- def __init__(self, string):
- self.string = string
- if(self.string in _btconst):
- self.obj = BluetoothConnectionManager()
- elif(self.string in _wificonst):
- self.obj = WirelessConnectionManager()
- else:
- raise IconnectionError, "Undefined type."
-
-
- # ********************************************************************************
- # Generic methods -> Wireless and Bluetooth *
- # ********************************************************************************
-
- # create a socket with defined protocol
- def create_socket(self, protocol=None):
- self.obj.create_socket(protocol)
-
- # connect device
- def connect(self):
- self.obj.connect()
-
- # accept the connection
- def accept(self):
- return self.obj.accept()
-
- # send a message to device
- def send_message(self, msg=None):
- self.obj.send_message(msg)
-
- # received a message
- def received_message(self):
- return self.obj.received_message()
-
- # bind the connection
- def bind(self):
- self.obj.bind()
-
- # listen the connection
- def listen(self):
- self.obj.listen()
-
- # close connection
- def close(self):
- self.obj.close()
-
- # set the port to communicate
- def set_port(self, port):
- self.obj.set_port(port)
-
- # get the port to communicate
- def get_port(self):
- return self.obj.get_port()
-
- # set the device address
- def set_address(self, address):
- self.obj.set_address(address)
-
- # get the device address
- def get_address(self):
- return self.obj.get_address()
-
- # get the client address
- def get_client_address(self):
- return self.obj.get_client_address()
-
- # ************************************************************************************
- # Bluetooth methods - All methods for bluetooth services *
- # ************************************************************************************
-
- # fast way to create a simple server
- def bt_create_server(self, protocol, port):
- if self.string in _btconst:
- return self.obj.create_server(protocol, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # fast way to create a simple client
- def bt_create_client(self, protocol, address, port):
- if self.string in _btconst:
- return self.obj.create_client(protocol, address, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search for all devices
- def bt_find_devices(self, time=8):
- if self.string in _btconst:
- return self.obj.find_devices(time)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search only devices names
- def bt_find_devices_only_names(self):
- if self.string in _btconst:
- return self.obj.find_devices_only_names()
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
- # search the device port
- def bt_find_port(self, addr):
- if self.string in _btconst:
- return self.obj.find_port(addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
- # search device services
- def bt_find_services(self, service=None, addr=None):
- if self.string in _btconst:
- return self.obj.find_services(service, addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
- # search the device indicated by name
- def bt_find_device_address_by_name(self, device_name=None):
- if self.string in _btconst:
- return self.obj.find_device_address_by_name(device_name)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
-
- # ***********************************************************************************
- # Wireless method - All methods for wireless services *
- # ***********************************************************************************
+++ /dev/null
-#!/usr/bin/env python
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Version : 0.1
-# Description : Tablet Application Wireless Connection Manager Class
-# ============================================================================
-
-from genericconnectionmanager import *
-
-class WirelessConnectionManager(GenericConnectionManager):
- def __init__(self):
- GenericConnectionManager.__init__(self)
- #para acessar facilmente qualquer metodo generico
- #self.super = generico()
- print "init do Wireless"
- self.tipo = "wireless"
-
- def metodo(self):
- print "(Wireless)Metodo do", self.tipo
-
-
+++ /dev/null
-pcremote-client for Debian
-----------------------
-
-<possible notes regarding this package - if none, delete this file>
-
- -- Jonatas Isvi <jonatas.nona@gmail.com> Mon, 30 Mar 2009 18:53:24 -0400
+++ /dev/null
-pcremote-client (0.60-1) unstable; urgency=low
-
- * Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>
-
- -- Jonatas Isvi <jonatas.nona@gmail.com> Mon, 30 Mar 2009 18:53:24 -0400
-
+++ /dev/null
-Source: pcremote-client
-Section: user/other
-Priority: optional
-Maintainer: Jonatas Isvi <jonatas.nona@gmail.com>, Andre Portela <andre_portela_@hotmail.com>, Nilson Silva <fergus.mao@gmail.com>
-Build-Depends: debhelper (>= 5)
-Standards-Version: 3.7.2
-
-Package: pcremote-client
-Architecture: armel
-Depends: python2.5, python2.5-efl-utils (>=0.1.3), python2.5-efl-core (>=0.9.1), python2.5-bluez (>=0.9.1)
-Description: A client application to let you control a mouse and keyboard of a desktop server
+++ /dev/null
-Copyright (c) 2009 Zagaia Lab (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 Client
- Author(s) <email>: Jonatas Isvi <jonatas.nona@gmail.com>, Andre Portela <andre_portela_@hotmail.com>,
- Nilson Silva <fergus.mao@gmail.com>
+++ /dev/null
-usr/bin
-usr/share/pcremote-client
-usr/share/applications/hildon
-usr/share/icons/hicolor/26x26/hildon
-
+++ /dev/null
-pcremote-client_0.60-1_armel.deb user/other optional
+++ /dev/null
-Package: pcremote-client
-Version: 0.60-1
-Architecture: armel
-Maintainer: Jonatas Isvi <jonatas.nona@gmail.com>, Andre Portela <andre_portela_@hotmail.com>, Nilson Silva <fergus.mao@gmail.com>
-Installed-Size: 1700
-Depends: python2.5, python2.5-bluez (>= 0.9.1), python2.5-efl-core (>= 0.9.1), python2.5-efl-utils (>= 0.1.3)
-Section: user/other
-Priority: optional
-Description: A client application to let you control a mouse and keyboard of a desktop server
+++ /dev/null
-3fd5b4d9e25d31363a8059d09c200f41 usr/share/applications/hildon/pcremote-client.desktop
-58bf2e5a7c200824c5aeb54c62488405 usr/share/pcremote-client/pcremote-client.py
-50a7074d0b24fa0252802218e950e628 usr/share/pcremote-client/kineticlist.py
-ad592c024fc19766d7bcc5c37f98619b usr/share/pcremote-client/screenmanager.py
-c550a42e4e4839bd5d2911e2792f0203 usr/share/pcremote-client/tablet.edj
-03144240717eaaaf1b69cc63172dec10 usr/share/pcremote-client/connection/bluetoothconnectionmanager.py
-49c1b5c3a6725fea02760a16fab55d6c usr/share/pcremote-client/connection/wirelessconnectionmanager.pyc
-70e8942077f305d0dc2efc6fd13a7d19 usr/share/pcremote-client/connection/iconnection.py
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-client/connection/__init__.py
-cec93922a80076d075d473a671b1b32e usr/share/pcremote-client/connection/genericconnectionmanager.py
-048e6ffb26374c4f80d7698dbad247a9 usr/share/pcremote-client/connection/__init__.pyc
-2fa68f3f626f6da9ace3785a6fb8a843 usr/share/pcremote-client/connection/genericconnectionmanager.pyc
-a9a199485e01894676c9c207c1d7ac7d usr/share/pcremote-client/connection/bluetoothconnectionmanager.pyc
-71b6cd7b7f5a0f015ac3ea28c146dcfd usr/share/pcremote-client/connection/wirelessconnectionmanager.py
-368ec39fb0bd97b83e676c5eb570a504 usr/share/pcremote-client/connection/iconnection.pyc
-a29eb978df91c3c7bc9f880d9279fe18 usr/share/pcremote-client/edje_objects.py
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-client/utils/__init__.py
-b3ce6c1b4dde39f132c6fea0c0f32812 usr/share/pcremote-client/utils/labels.py
-8d63834377110f7cac90eef4b9b95e78 usr/share/pcremote-client/slide.edj
-02a89fa5764dedbd7a3b24f17cdef5cc usr/share/pcremote-client/pcremote.edj
-a45cefda3455e840e85003b8b01fab75 usr/share/doc/pcremote-client/README.Debian
-05c8914575af590a1c2a0e0febed2903 usr/share/doc/pcremote-client/changelog.Debian.gz
-002c11b08af0369742751c02cbf1fbe8 usr/share/doc/pcremote-client/copyright
-194dc850c98759d2b2f4fa7faf62f37b usr/share/icons/hicolor/26x26/hildon/pcremote.png
-432c8381b94e37a4a618c8930bce54e6 usr/bin/pcremote-client
+++ /dev/null
-#!/bin/sh -e
-
-gtk-update-icon-cache -f /usr/share/icons/hicolor
-maemo-select-menu-location pcremote-client.desktop
-
+++ /dev/null
-#!/bin/sh -e
-
-# remove configuration
-
-# Delete the .desktop file in case the app-installer didn't.
-rm -f /usr/share/applications/hildon/pcremote-client.desktop
-
-# Delete the pcremoteclt directory in case the app-installer didn't
-rm -fr /usr/share/pcremote-client
-
-# Delete the symbolics links files in case the app-installer didn't.
-rm -f /usr/bin/pcremote-client
-
-
-exit 0
+++ /dev/null
-#!/bin/sh
-
-python /usr/share/pcremote-client/pcremote-client.py
+++ /dev/null
-[Desktop Entry]
-Encoding=UTF-8
-Version=0.60
-Type=Application
-Icon=pcremote
-Name=PCRemote Client
-Exec=pcremote-client
-X-Window-Icon=pcremote
-X-Window-Icon-Dimmed=pcremote
-Terminal=false
-Categories=Application;Network;
-StartupNotify=false
+++ /dev/null
-pcremote-client for Debian
-----------------------
-
-<possible notes regarding this package - if none, delete this file>
-
- -- Jonatas Isvi <jonatas.nona@gmail.com> Mon, 30 Mar 2009 18:53:24 -0400
+++ /dev/null
-Copyright (c) 2009 Zagaia Lab (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 Client
- Author(s) <email>: Jonatas Isvi <jonatas.nona@gmail.com>, Andre Portela <andre_portela_@hotmail.com>,
- Nilson Silva <fergus.mao@gmail.com>
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Description : BluetoothConnectionManager
-# ============================================================================
-
-
-import bluetooth
-from exceptions import *
-from genericconnectionmanager import *
-
-class BluetoothConnectionError(Exception):
- pass
-
-class BluetoothConnectionManager(GenericConnectionManager):
-
- def __init__(self):
- GenericConnectionManager.__init__(self)
- print "BluetoothConnectionManager iniciado."
- # globals data variables
- self.sock = None
- self.port = None
- self.address = None
- self.client_sock = None
- self.client_address = None
-
- # fast way to create a simple server
- def create_server(self, protocol, port):
- self.create_socket(protocol)
- self.set_port(port)
- self.bind()
- self.listen()
- self.accept()
-
- # fast way to create a simple client
- def create_client(self, protocol, address, port):
- self.create_socket(protocol)
- self.set_address(address)
- self.set_port(port)
- self.connect()
-
- # search for all devices
- def find_devices(self, time=8):
- list_devices = bluetooth.discover_devices(lookup_names = True, duration=time)
- if list_devices:
- return list_devices
- else:
- raise BluetoothConnectionError, "Device were not found."
-
- # search the device port
- def find_port(self, addr):
- port = None
- aux = addr.split(":")
- if len(aux) == 6:
- services = bluetooth.find_service(address=addr)
- for i in range(len(services)):
- port = services[i]['port']
-
- if port != None:
- return port
- else:
- raise BluetoothConnectionError, "Port not found."
-
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # search device services
- def find_services(self, service=None, addr=None):
- if service == None and addr == None:
- list = bluetooth.find_service()
- # returns all services
- return list
- elif service != None and addr == None:
- list = bluetooth.find_service(name=service)
- # returns only the device services indicated by name
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Name of the service does not exist."
- elif service == None and addr != None:
- number = addr.split(":")
- # returns only the device services indicated by address
- if(len(number) == 6):
- list = bluetooth.find_service(address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
- elif service != None and addr != None:
- number = addr.split(":")
- # returns only the device service indicated by address
- if(len(number) == 6):
- list = bluetooth.find_service(name=service, address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
-
-
- # search the device indicated by name
- def find_device_address_by_name(self, device_name):
- list = bluetooth.discover_devices()
- addr = None
-
- for address in list:
- if device_name == bluetooth.lookup_name(address):
- addr = address
- break
- if addr:
- return addr
- else:
- raise BluetoothConnectionError, "Device name not found."
-
-
- def find_devices_only_names(self):
- list = self.find_devices()
- list_names = []
- for address, names in list:
- list_names += [names]
-
- if list_names:
- return list_names
- else:
- raise BluetoothConnectionError, "Devices were not found."
-
- # get the client address
- def get_client_address(self):
- return self.client_address
-
- # set the port to communicate
- def set_port(self, port):
- self.port = port
-
- # get the port to communicate
- def get_port(self):
- return self.port
-
- # set the device address
- def set_address(self, address):
- aux = address.split(":")
- if len(aux) == 6:
- self.address = address
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # get the device address
- def get_address(self):
- return self.address
-
- # create a socket with a determinated protocol
- def create_socket(self, protocol=None):
- if protocol == 'rfcomm' or protocol == 'RFCOMM':
- self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
- elif protocol == 'l2cap' or protocol == 'L2CAP':
- self.sock = bluetooth.BluetoothSocket(bluetooth.L2CAP)
- else:
- raise BluetoothConnectionError, "Undefined Protocol."
-
- # bind the communication
- def bind(self):
- self.sock.bind(("", self.get_port()))
-
- # just listen the tube, only to server
- def listen(self):
- self.sock.listen(1)
-
- # accept the client communication
- # returns an object
- def accept(self):
- self.client_sock, self.client_address = self.sock.accept()
-
- # connect devices
- def connect(self):
- self.sock.connect((self.get_address(), self.get_port()))
-
- # send string message
- def send_message(self, msg=None):
- self.sock.send(msg)
-
- # receive string message
- def received_message(self):
- return self.client_sock.recv(1024)
-
- # close connection
- def close(self):
- if self.sock != None and self.client_sock != None:
- self.client_sock.close()
- self.sock.close()
- elif self.sock != None and self.client_sock == None:
- self.sock.close()
- else:
- self.client_sock.close()
-
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela@hotmail.com
-# Version : 1.0
-# Description : GenericConnectionManager Class
-# ============================================================================
-
-
-class GenericConnectionManager:
-
- def __init__(self):
- print "GenericConnectionManager iniciado."
- self.tipo = "generico"
-
- def identify_app(self):
- print "identify_app"
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Description : Interface Class, connection manager
-# ============================================================================
-
-from wirelessconnectionmanager import *
-from bluetoothconnectionmanager import *
-from exceptions import *
-
-
-# connections aliases
-_btconst = ['bluetooth', 'BLUETOOTH', 'blue']
-_wificonst = ['wireless', 'WIRELESS', 'wifi']
-
-class Iconnection:
- def __init__(self, string):
- self.string = string
- if(self.string in _btconst):
- self.obj = BluetoothConnectionManager()
- elif(self.string in _wificonst):
- self.obj = WirelessConnectionManager()
- else:
- raise IconnectionError, "Undefined type."
-
-
- # ********************************************************************************
- # Generic methods -> Wireless and Bluetooth *
- # ********************************************************************************
-
- # create a socket with defined protocol
- def create_socket(self, protocol=None):
- self.obj.create_socket(protocol)
-
- # connect device
- def connect(self):
- self.obj.connect()
-
- # accept the connection
- def accept(self):
- return self.obj.accept()
-
- # send a message to device
- def send_message(self, msg=None):
- self.obj.send_message(msg)
-
- # received a message
- def received_message(self):
- return self.obj.received_message()
-
- # bind the connection
- def bind(self):
- self.obj.bind()
-
- # listen the connection
- def listen(self):
- self.obj.listen()
-
- # close connection
- def close(self):
- self.obj.close()
-
- # set the port to communicate
- def set_port(self, port):
- self.obj.set_port(port)
-
- # get the port to communicate
- def get_port(self):
- return self.obj.get_port()
-
- # set the device address
- def set_address(self, address):
- self.obj.set_address(address)
-
- # get the device address
- def get_address(self):
- return self.obj.get_address()
-
- # get the client address
- def get_client_address(self):
- return self.obj.get_client_address()
-
- # ************************************************************************************
- # Bluetooth methods - All methods for bluetooth services *
- # ************************************************************************************
-
- # fast way to create a simple server
- def bt_create_server(self, protocol, port):
- if self.string in _btconst:
- return self.obj.create_server(protocol, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # fast way to create a simple client
- def bt_create_client(self, protocol, address, port):
- if self.string in _btconst:
- return self.obj.create_client(protocol, address, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search for all devices
- def bt_find_devices(self, time=8):
- if self.string in _btconst:
- return self.obj.find_devices(time)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search only devices names
- def bt_find_devices_only_names(self):
- if self.string in _btconst:
- return self.obj.find_devices_only_names()
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
- # search the device port
- def bt_find_port(self, addr):
- if self.string in _btconst:
- return self.obj.find_port(addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
- # search device services
- def bt_find_services(self, service=None, addr=None):
- if self.string in _btconst:
- return self.obj.find_services(service, addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
- # search the device indicated by name
- def bt_find_device_address_by_name(self, device_name=None):
- if self.string in _btconst:
- return self.obj.find_device_address_by_name(device_name)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
-
- # ***********************************************************************************
- # Wireless method - All methods for wireless services *
- # ***********************************************************************************
+++ /dev/null
-#!/usr/bin/env python
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Version : 0.1
-# Description : Tablet Application Wireless Connection Manager Class
-# ============================================================================
-
-from genericconnectionmanager import *
-
-class WirelessConnectionManager(GenericConnectionManager):
- def __init__(self):
- GenericConnectionManager.__init__(self)
- #para acessar facilmente qualquer metodo generico
- #self.super = generico()
- print "init do Wireless"
- self.tipo = "wireless"
-
- def metodo(self):
- print "(Wireless)Metodo do", self.tipo
-
-
+++ /dev/null
-#!/usr/bin/env python
-# -*- 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 :André Portela
-# Email :andre_portela_@hotmail.com
-# Version :1.0
-# Module :main
-# Class :PCRemote custom Edje object with it's own call backs for the
-# main screen
-# ============================================================================
-
-import thread
-import ecore
-import ecore.evas
-import evas.decorators
-import edje
-import edje.decorators
-import time
-from connection.iconnection import Iconnection
-from kineticlist import *
-
-class EvasCanvas(object):
-
- def __init__(self, fullscreen, engine, size):
- #f = ecore.evas.SoftwareX11
- self.evas_obj = engine(w=size[0], h=size[1])
- self.evas_obj.callback_delete_request = self.on_delete_request
- self.evas_obj.callback_resize = self.on_resize
-
- self.evas_obj.title = "PCRemote"
- self.evas_obj.name_class = ('PC Remote', 'main')
- self.evas_obj.fullscreen = fullscreen
- self.evas_obj.size = size
- self.evas_obj.show()
-
- def on_resize(self, evas_obj):
- x, y, w, h = evas_obj.evas.viewport
- size = (w, h)
- for key in evas_obj.data.keys():
- evas_obj.data[key].size = size
-
- def on_delete_request(self, evas_obj):
- ecore.main_loop_quit()
-
- def show(self):
- self.evas_obj.show()
-
-class EdjeObject(edje.Edje):
-
- def __init__(self, canvas_class, file, group='main',name='edje'):
- self.canvas_class = canvas_class
- self.x11 = canvas_class.evas_obj
- self.canvas = self.x11.evas
- edje.Edje.__init__(self, self.canvas, file = file, group = group)
- self.size = self.canvas.size
- self.x11.data[name] = self
-
-class MainScreen(EdjeObject):
-
- def __init__(self, canvas, file, group, name, connection):
- EdjeObject.__init__(self, canvas, file = file, group = group,name = name)
-
- self.file = file
- self.on_key_down_add(self.key_down_cb, self.x11)
- self.sock_address = None
- #flag that sync the discovery device's thread
- self.flag = False
- #flag that sync the connecting device's thread
- self.connecting_flag = False
- #lista de dispositivos descobertos
- self.lista_dispositivos = []
- #objeto que cria a conexao bluetooth
- self.conexao = connection
- self.kineticlist = False
- #portela mock object
- self.lista_teste = ['Andre Portela', 'Juliana Dias', 'Victor Hugo', 'Lucina Dias', 'Rosa Dias', 'James Italiano', 'Nona Izvi', 'Fergus Mao', 'Mauricio Brilhante', 'Edward Ordonez', 'Brankinhu', 'Banco Real', 'Banco Itaú', 'ABN-AMRO BANK']
-
- def key_down_cb(self, bg, event, ee):
- k = event.key
- if k == "Escape":
- ecore.main_loop_quit()
- elif k == "F6":
- ee.fullscreen = not ee.fullscreen
- elif k == "F8":
- print "-"
- elif k == "F7":
- print "+"
-
- def mkKineticList(self):
- #kinetic list (the item values are tied with the part "item_background" of the "list_item" group)
- #self.kineticlist = KineticList(self.canvas, file=self.file, item_width=407, item_height=38, father=self)
- self.kineticlist = KineticList(self.canvas, file=self.file, item_height=57, father=self)
- self.kineticlist.freeze()
- #portela - test kinetic list with several devices
- #for item in self.lista_teste:
- #populates the list with the device's names
- for item in self.lista_dispositivos:
- self.kineticlist.row_add(item)
- #reorganize and draw the list
- self.kineticlist.thaw()
- #embed the list in the edje object
- self.part_swallow("list", self.kineticlist);
-
- @edje.decorators.signal_callback("connect_to","choice")
- def connect_to(self, emission, source):
- self.sock_address = self.part_text_get(source)
- #flag that sync the connecting device's thread
- self.connecting_flag = False
- self.signal_emit("start","device_connect")
- thread.start_new_thread(MainScreen.threaded_connection,(self,))
-
- def threaded_connection(self):
- self.conexao.create_socket('l2cap')
- print 'connecting to: %s' % self.sock_address
- self.conexao.set_address(self.conexao.bt_find_device_address_by_name(self.sock_address))
- self.conexao.set_port(0x1001)
- self.conexao.connect()
- self.connecting_flag = True
-
- @edje.decorators.signal_callback("connecting","device")
- def connecting_check(self, emission, source):
- if self.connecting_flag:
- self.connecting_flag = False
- self.signal_emit("stop","device_connect")
- #we are sending a signal to main edje (there is time to animate the device locking)
- self.signal_emit("begin","init")
-
- @edje.decorators.signal_callback("animation_still_loading", "loading")
- def still_loading_cb(self, emission, source):
- if self.flag:
- self.flag = False
- self.signal_emit("program,stop","loading")
- if self.lista_dispositivos != []:
- self.mkKineticList()
- else:
- self.no_device_found()
-
- @edje.decorators.signal_callback("animation_sair_ended", "sair")
- def saida(self, signal, source):
- ecore.main_loop_quit()
-
- @edje.decorators.signal_callback("animation_rastrear_ended", "rastrear")
- def rastrear_key_down(self, signal, source):
- thread.start_new_thread(MainScreen.rastrear_dispositivos,(self,None))
-
- @edje.decorators.signal_callback("program,start", "novodevice")
- def search_devices_again(self, signal, source):
- self.part_unswallow(self.kineticlist)
- del self.kineticlist
- MainScreen.rastrear_key_down(self, None, None)
-
- def rastrear_dispositivos(self,arg):
- try:
- self.lista_dispositivos = self.conexao.bt_find_devices_only_names()
- except:
- self.lista_dispositivos = []
- self.flag = True
-
- def no_device_found(self):
- self.signal_emit("program,start","no_device")
-
-class TabletScreen(EdjeObject):
-
- def __init__(self, canvas, file, group,name, connection):
- EdjeObject.__init__(self, canvas, file = file, group = group,name = name)
- self.on_key_down_add(self.key_down_cb, self.x11)
- #emitt events only if the mouse is inside the touch object area
- (self.part_object_get('touch')).pointer_mode_set(evas.EVAS_OBJECT_POINTER_MODE_NOGRAB)
- #assign the mouse_move_cb method as a mouse move callback for the touch part of the edje object
- (self.part_object_get('touch')).on_mouse_move_add(self.mouse_move_cb)
- #self.on_mouse_move_add(TabletScreen.mouse_move_cb)
- self.sock = connection
- #this flag indicates either the user are grabing something or not on the target
- self.drag_flag = False
- #this float indicates the wich the method left_click_down was called, and will be
- #calculated against lcu_time in left_click_up method
- self.lcd_time = 0.0
- self.key_flag = False
-
- @edje.decorators.signal_callback('mouse,down,1', 'tablet_bt-L_area')
- def left_click_down(self, signal, source):
- self.lcd_time = time.time()
- #if the user are grabing something, release it
- if self.drag_flag:
- self.drag_flag = False
- self.sock.send_message("Mouse:#left_click")
-
- @edje.decorators.signal_callback('mouse,up,1', 'tablet_bt-L_area')
- def left_click_up(self, signal, source):
- lcu_time = time.time()
- #threshold of 0.5 seconds to grab something on the target
- elapsed_time = lcu_time - self.lcd_time
- if elapsed_time < 0.5:
- #do a simple click
- self.sock.send_message("Mouse:#left_click")
- self.sock.send_message("Mouse:#left_click")
- else:
- #do mouse grab
- self.sock.send_message("Mouse:#left_click")
- self.drag_flag = True
-
- @edje.decorators.signal_callback('mouse,up,1', 'tablet_bt-R_area')
- def rigth_click(self, signal, source):
- self.sock.send_message("Mouse:#right_click")
- self.sock.send_message("Mouse:#right_click")
-
- def key_down_cb(self, bg, event, ee):
- k = event.key
- print k
- if k == "Escape":
- self.sock.send_message("Tablet:#stop")
- self.sock.close()
- ecore.main_loop_quit()
- elif k == "F6":
- ee.fullscreen = not ee.fullscreen
- elif k == "F8":
- self.sock.send_message("Keyboard:Up")
- elif k == "F7":
- self.sock.send_message("Keyboard:Down")
- elif k == "Return":
- self.sock.send_message("Keyboard:Alt+F1")
- elif k == "ISO_Level3_Shift":
- self.sock.send_message("Keyboard:Alt+F2")
- else:
- self.sock.send_message("Keyboard:%s" % k)
-
- def mouse_move_cb(self, part, event):
- x, y = event.position.output[0], event.position.output[1]
- self.sock.send_message("Mouse:"+str(x)+","+str(y))
-
-class SlideScreen(EdjeObject):
-
- def __init__(self, canvas, file, group,name, connection):
- EdjeObject.__init__(self, canvas, file = file, group = group,name = name)
- self.on_key_down_add(self.key_down_cb, self.x11)
- #emitt events only if the mouse is inside the touch object area
- (self.part_object_get('touch')).pointer_mode_set(evas.EVAS_OBJECT_POINTER_MODE_NOGRAB)
- #assign the mouse_move_cb method as a mouse move callback for the touch part of the edje object
- (self.part_object_get('touch')).on_mouse_move_add(self.mouse_move_cb)
- #self.on_mouse_move_add(TabletScreen.mouse_move_cb)
- self.sock = connection
- #this flag indicates either the user are grabing something or not on the target
- self.drag_flag = False
- #helps to coordenate presentation
- self.keyboard_flag = True
- #this float indicates the wich the method left_click_down was called, and will be
- #calculated against lcu_time in left_click_up method
- self.lcd_time = 0.0
-
- @edje.decorators.signal_callback('mouse,down,1', 'slide_bt-left_area')
- def left_click_down(self, signal, source):
- if self.keyboard_flag:
- self.lcd_time = time.time()
- #if the user are grabing something, release it
- if self.drag_flag:
- self.drag_flag = False
- self.sock.send_message("Mouse:#left_click")
-
- @edje.decorators.signal_callback('mouse,up,1', 'slide_bt-left_area')
- def left_click_up(self, signal, source):
- if self.keyboard_flag:
- lcu_time = time.time()
- #threshold of 0.5 seconds to grab something on the target
- elapsed_time = lcu_time - self.lcd_time
- if elapsed_time < 0.5:
- #do a simple click
- self.sock.send_message("Mouse:#left_click")
- self.sock.send_message("Mouse:#left_click")
- else:
- #do mouse grab
- self.sock.send_message("Mouse:#left_click")
- self.drag_flag = True
- else:
- self.sock.send_message("Keyboard:%s" % "Left")
-
- @edje.decorators.signal_callback('mouse,up,1', 'slide_bt-right_area')
- def rigth_click(self, signal, source):
- if self.keyboard_flag:
- self.sock.send_message("Mouse:#right_click")
- self.sock.send_message("Mouse:#right_click")
- else:
- self.sock.send_message("Keyboard:%s" % "Right")
-
- def key_down_cb(self, bg, event, ee):
- k = event.key
- print k
- if k == "Escape":
- self.sock.send_message("Slideshow:#stop")
- self.sock.close()
- ecore.main_loop_quit()
- elif k == "F6":
- self.keyboard_flag = not self.keyboard_flag
- self.sock.send_message("Keyboard:F5")
- elif k == "F8":
- self.sock.send_message("Keyboard:Up")
- elif k == "F7":
- self.sock.send_message("Keyboard:Down")
- else:
- self.sock.send_message("Keyboard:%s" % k)
-
- def mouse_move_cb(self, part, event):
- x, y = event.position.output[0], event.position.output[1]
- self.sock.send_message("Mouse:"+str(x)+","+str(y))
+++ /dev/null
-#!/usr/bin/env python
-# -*- 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 :Gustavo Sverzut Barbieri ; André Luiz do Canto Portela
-# Email :barbieri@gmail.com ; andre_portela_@hotmail.com
-# Version :1.0
-# Module :main
-# Class :This class are an adaptation of barbieri's demo 03 of edje
-# :python-bindings
-# ============================================================================
-
-import evas
-import edje
-import ecore
-import time
-
-class KineticList(evas.ClippedSmartObject):
- (
- SCROLL_PAGE_FORWARD,
- SCROLL_PAGE_BACKWARD,
- SCROLL_STEP_FORWARD,
- SCROLL_STEP_BACKWARD,
- SCROLL_PIXELS_DOWN,
- SCROLL_PIXELS_UP
- ) = range(6)
-
-
- def __init__(self, ecanvas, file, item_width=-1, item_height=-1, father=None):
- '''
- if item_width or item_height is left out the width (resp. height)
- of the List element is used.
- '''
- self.father = father
- evas.ClippedSmartObject.__init__(self, ecanvas)
- self.elements = []
- self.objects = []
- self.w = 32
- self.h = 32
-
- self.realized = False
-
- self.top_pos = 0
- self.last_top_pos = 0
- self.last_start_row = -1
-
- self.canvas = ecanvas
- self.edje_file = file
-
- self.row_width = item_width
- self.row_height = item_height
-
- self.__manage_objects()
-
- self.mouse_down = False
- self.last_y_pos = 0
- self.start_pos = 0
- self.mouse_moved = False
- self.continue_scrolling = False
- self.is_scrolling = False
- self.do_freeze = False
-
- def freeze(self):
- self.do_freeze = True
-
- def thaw(self):
- self.do_freeze = False
- if self.realized:
- self.__update_variables_after_new_elements()
- self.__update_screen()
-
- def scroll(self, scroll_type, amount=1):
- self.continue_scrolling = False
-
- if scroll_type == self.SCROLL_PAGE_FORWARD:
- self.top_pos += amount * self.row_height * self.max_visible_rows
- elif scroll_type == self.SCROLL_PAGE_BACKWARD:
- self.top_pos -= amount * self.row_height * self.max_visible_rows
- elif scroll_type == self.SCROLL_STEP_FORWARD:
- self.top_pos += amount * self.row_height
- elif scroll_type == self.SCROLL_STEP_BACKWARD:
- self.top_pos -= amount * self.row_height
- elif scroll_type == self.SCROLL_PIXELS_DOWN:
- self.top_pos += amount
- elif scroll_type == self.SCROLL_PIXELS_UP:
- self.top_pos -= amount
- else:
- return
-
- self.__update_screen()
-
- def __on_mouse_clicked(self, edje_obj, emission, source, data=None):
- #for obj in self.objects:
- # if obj != edje_obj:
- # obj.signal_emit("fadeout", "")
-
- #edje_obj.signal_emit("open", "")
- #TODO:portela - it works! :D
- edje_obj.signal_emit("program,start","label")
- #we are setting up the choice's text on the main edje object
- self.parent_get().part_text_set("choice",edje_obj.part_text_get("label"))
-
- def __on_mouse_move(self, edje_obj, emission, source, data=None):
- if self.mouse_down:
- x_pos, y_pos = self.canvas.pointer_canvas_xy
- diff = int(self.last_y_pos - y_pos)
-
- if diff == 0:
- return
-
- self.mouse_moved = True
-
- # Reset the data if the direction of the mouse move is changed
- if self.last_diff != -1 and (diff < 0) != (self.last_diff < 0):
- self.last_y_pos = y_pos
- self.start_pos = y_pos
- self.start_time = time.time()
-
- self.last_diff = diff
- self.top_pos += diff
-
- self.last_y_pos = y_pos
- self.__update_screen()
- self.last_update_time = time.time()
-
- #TODO: portela mod
- def __on_blink_ended(self, edje_obj, emission, source, data=None):
- for obj in self.objects:
- obj.signal_emit("program,start,fade,out","label")
- #we are sending a signal for the application connect the target
- self.parent_get().signal_emit("connect_to","choice")
-
- #TODO: portela mod
-
- def show_list(self):
- for obj in self.objects:
- obj.signal_emit("program,start,fade,in","label")
-
- def __on_mouse_down(self, edje_obj, emission, source, data=None):
- if not self.is_scrolling:
- self.mouse_moved = False
-
- self.continue_scrolling = False
- self.mouse_down = True
-
- x_pos, y_pos = self.canvas.pointer_canvas_xy
-
- self.last_diff = -1
- self.last_y_pos = y_pos
- self.start_pos = y_pos
- self.start_time = time.time()
- self.last_update_time = time.time()
-
- def __on_mouse_up(self, edje_obj, emission, source, data=None):
- if self.mouse_down:
- self.mouse_down = False
-
- x_pos, end_pos = self.canvas.pointer_canvas_xy
-
- if not self.mouse_moved and not self.is_scrolling:
- #self.__on_mouse_clicked(edje_obj, emission, source)
- return
-
- self.mouse_moved = False
- self.is_scrolling = False
-
- # do not scroll automatically if the finger was paused
- if time.time() - self.last_update_time > 0.1:
- return
-
- end_time = time.time()
-
- pos_diff = end_pos - self.start_pos
- time_diff = end_time - self.start_time
-
- self.pixel_per_sec = pos_diff / time_diff
- self.continue_scrolling = True
- self.__do_scroll()
-
- def __do_scroll(self):
- self.is_scrolling = True
-
- if self.continue_scrolling == False:
- return
-
- diff = int(self.pixel_per_sec / 10)
-
- if abs(self.pixel_per_sec) - diff <= self.row_height:
- offset = self.top_pos % self.row_height
-
- if offset >= self.row_height / 2:
- self.sign = 1
- offset = self.row_height - offset
- else:
- self.sign = -1
-
- self.pixels_left = offset
- self.__do_magnetic_scroll()
-
- return
-
- if diff != 0:
- self.top_pos -= diff
- self.pixel_per_sec -= self.pixel_per_sec / 10
- self.__update_screen()
-
- ecore.timer_add(0.02, self.__do_scroll)
-
- def __do_magnetic_scroll(self):
- if self.pixels_left <= 0 or abs(self.pixel_per_sec) < 1:
- self.mouse_moved = False
- self.is_scrolling = False
- return
-
- self.pixel_per_sec -= (self.pixel_per_sec / 10)
-
- pixels_to_substract = int(abs(self.pixel_per_sec / 10))
- if abs(pixels_to_substract) < 1:
- pixels_to_substract = 1
-
- if self.pixels_left - pixels_to_substract > 0:
- self.pixels_left -= pixels_to_substract
- self.top_pos += self.sign * pixels_to_substract
- else:
- self.top_pos += self.sign * self.pixels_left
- self.pixels_left = 0
-
- self.__update_screen()
- ecore.timer_add(0.1, self.__do_magnetic_scroll)
-
- def row_add(self, label):
- self.elements.append(label)
-
- if not self.do_freeze:
- self.__update_variables_after_new_elements()
- self.__update_screen()
-
- def __manage_objects(self):
- remain = (self.h % self.row_height) > 1
- needed_objects = ((self.h / self.row_height) + 1 + remain) * (self.w / self.row_width)
- current_objects = len(self.objects)
-
- if current_objects < needed_objects:
- for i in range(current_objects, needed_objects):
- obj = edje.Edje(self.canvas);
- obj.file_set(self.edje_file, "list_item");
-
- obj.signal_callback_add("mouse,move", "*",
- self.__on_mouse_move)
- obj.signal_callback_add("mouse,down,*", "*",
- self.__on_mouse_down)
- obj.signal_callback_add("mouse,up,*", "*",
- self.__on_mouse_up)
- #TODO: portela mod
- obj.signal_callback_add("animation_blink_ended", "label",
- self.__on_blink_ended)
- obj.signal_callback_add("mouse,clicked,*", "label",
- self.__on_mouse_clicked)
- obj.size = (self.row_width, self.row_height)
- obj.clip = self
- self.objects.append(obj)
-
- elif needed_objects < current_objects:
- for i in range(needed_objects, current_objects):
- pass # Make this work, it throws exception that makes
- # things stop working properly
- #del self.objects[i]
-
- def __update_variables_after_resize(self):
- self.max_visible_rows = (self.h / self.row_height) + 1
- self.max_horiz_elements = (self.w / self.row_width)
- self.max_visible_elements = self.max_visible_rows * \
- self.max_horiz_elements
-
- # Invalidate variable in order to repaint all rows
- # Some might not have been painted before (Didn't
- # fit on the screen
- self.last_start_row = -1
-
- self.__update_variables_after_new_elements()
-
- def __update_variables_after_new_elements(self):
- if not self.realized:
- return
-
- self.min_pos = 0
- remainer1 = (len(self.elements) % self.max_horiz_elements) > 0
- remainer2 = (self.h % self.row_height) > 0
- self.row_amount = (len(self.elements) / self.max_horiz_elements) + \
- remainer1 + remainer2
- self.max_pos = self.row_height * \
- (self.row_amount - self.max_visible_rows + 1)
-
- def __update_screen(self):
- remainer = (self.h % self.row_height) > 0
- row_offset = (self.top_pos / self.row_height)
- pixel_offset = - (self.top_pos % self.row_height)
- start_row = row_offset
- end_row = self.max_visible_rows + row_offset + remainer
-
- SCROLL_DOWN = self.top_pos > self.last_top_pos
- SCROLL_UP = self.top_pos < self.last_top_pos
-
- # Let's not move over the last element
- if SCROLL_DOWN and self.last_top_pos >= self.max_pos:
- self.top_pos = self.max_pos
- self.last_top_pos = self.top_pos
- self.continue_scrolling = False
- return
-
- # Let's not move over the first element
- if SCROLL_UP and self.last_top_pos <= self.min_pos:
- self.top_pos = self.min_pos
- self.last_top_pos = self.top_pos
- self.continue_scrolling = False
- return
-
- # Overflow scrolling down
- if SCROLL_DOWN and end_row > self.row_amount:
- offset = end_row - self.row_amount
- end_row -= offset
- start_row -= offset
- row_offset -= offset - 1
- self.top_pos = self.max_pos
- pixel_offset = 0
-
- # Overflow scrolling up
- if SCROLL_UP and start_row < 0:
- self.top_pos = self.min_pos
- end_row -= start_row
- start_row = 0
- row_offset = 0
- pixel_offset = 0
-
- self.last_top_pos = self.top_pos
-
- if start_row != self.last_start_row:
- for i in range(0, len(self.objects)):
- self.objects[i].hide()
-
- for i in range(start_row, end_row):
- row_iter = i - start_row
-
- for k in range(self.max_horiz_elements):
- obj_iter = row_iter * self.max_horiz_elements + k
- data_iter = i * self.max_horiz_elements + k
-
- try:
- label = self.elements[data_iter]
- except Exception, e:
- break;
-
- offset = (self.w %
- (self.row_width * self.max_horiz_elements)) / 2
- x = self.row_width * k + self.top_left[0] + offset
- y = self.top_left[1] + self.row_height * (i - row_offset) - \
- 5 + pixel_offset
-
- self.objects[obj_iter].move(x, y)
-
- if start_row != self.last_start_row:
- self.objects[obj_iter].part_text_set("label", label)
- self.objects[obj_iter].show()
-
- self.last_start_row = start_row
-
- def resize(self, w, h):
- if self.row_width == -1 or self.row_width == self.w:
- self.row_width = w
-
- if self.row_height == -1 or self.row_height == self.h:
- self.row_height = h
-
- self.w = w
- self.h = h
-
- self.__manage_objects()
-
- for obj in self.objects:
- obj.size = (self.row_width, self.row_height)
-
- self.realized = True
- self.__update_variables_after_resize()
- self.__update_screen()
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# ****************************************************************************
-# Copyright (c) 2008 Zagaia - 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 :Andre Portela
-# Email :andre_portela_@hotmail.com
-# Version :1.0
-# Module :main
-# Class :PCRemote custom Edje object with it's own call backs for the
-# main screen
-# ============================================================================
-
-from ecore import main_loop_begin
-import ecore.evas
-import sys
-import os
-from edje_objects import *
-from connection.iconnection import Iconnection
-from screenmanager import ScreenManager
-
-width, height = 800, 480
-
-#any argument deactivates fullscreen
-if sys.argv.__len__() > 1:
- screen = False
-else:
- screen = True
-#if x11_16 is present, get it, otherwise get x11
-if ecore.evas.engine_type_supported_get("software_x11_16"):
- engine = ecore.evas.SoftwareX11_16
-else:
- engine = ecore.evas.SoftwareX11
-#create the evas canvas
-canvas = EvasCanvas(fullscreen=screen,engine=engine,size=(width, height))
-#main .edj path
-edje_file = os.path.join(os.path.dirname(sys.argv[0]), "pcremote.edj")
-#the bluetooth socket object shared by all screens
-sock = Iconnection('bluetooth')
-#main edje object
-main = MainScreen(canvas=canvas, file=edje_file, group="Main",name="Main", connection = sock)
-main.show()
-#future edje objects
-tablet, slide, player, torrent = None, None, None, None
-#focus on main edje object
-main.focus = True
-#this object connects all screens together
-manager = ScreenManager(main, tablet, slide, player, torrent, sock)
-
-ecore.main_loop_begin()
-
+++ /dev/null
-#!/usr/bin/env python
-# -*- 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 :André Portela
-# Email :andre_portela_@hotmail.com
-# Version :1.0
-# Module :main
-# Class :PCRemote ScreenManager handles the finite state machine which
-# controls the navigation between screens.
-# ============================================================================
-
-from edje_objects import *
-import os
-import sys
-
-class ScreenManager(object):
- '''
- classdocs
- '''
- def __init__(self, main, tablet, slide, player, torrent,socket):
- '''
- Constructor
- '''
- self.main = main
- self.tablet = tablet
- self.slide = slide
- self.player = player
- self.torrent = torrent
- self.sock = socket
- main.signal_callback_add("mouse,up,1", "Tablet",self.run_tablet)
- main.signal_callback_add("mouse,up,1", "Slideshow",self.run_slide)
- main.signal_callback_add("mouse,up,1", "Player",self.run_player)
- main.signal_callback_add("mouse,up,1", "Torrent",self.run_torrent)
-
- def run_tablet(self, edje, emission, source):
- self.sock.send_message(source+":#start")
- print 'entrou no tablet'
- #main edje object
- edje.focus_set(False)
- edje.hide()
- if self.tablet is None:
- edje_file = os.path.join(os.path.dirname(sys.argv[0]), "tablet.edj")
- self.tablet = TabletScreen(edje.canvas_class, edje_file, 'main', 'tablet', self.sock)
- self.tablet.signal_callback_add("mouse,up,1","tablet_bt-voltar_area",self.tablet_back)
- self.tablet.part_text_set('pc_name',edje.sock_address)
- self.tablet.show()
- self.tablet.focus_set(True)
-
- def tablet_back(self, edje, emission, source):
- #tablet edje object
- edje.focus_set(False)
- edje.hide()
- self.sock.send_message("Tablet:#stop")
- self.main.show()
- self.main.focus_set(True)
-
- def run_slide(self, edje, emission, source):
- self.sock.send_message(source+":#start")
- print 'entrou no slide'
- #main edje object
- edje.focus_set(False)
- edje.hide()
- if self.slide is None:
- edje_file = os.path.join(os.path.dirname(sys.argv[0]), "slide.edj")
- self.slide = SlideScreen(edje.canvas_class, edje_file, 'main', 'slide', self.sock)
- self.slide.signal_callback_add("unselected","slide_bt-voltar",self.slide_back)
- #self.slide.part_text_set('pc_name',edje.sock_address)
- #this rotates the screen 90 degrees (to fit text in vertical orientation)
- #self.slide.x11.rotation_set(90)
- self.slide.show()
- self.slide.focus_set(True)
-
- def slide_back(self, edje, emission, source):
- #slide edje object
- edje.focus_set(False)
- edje.hide()
- self.sock.send_message("Slideshow:#stop")
- #this rotates the screen from 90 to 0 degrees (to fit text in horizontal orientation again)
- #self.main.x11.rotation_set(0)
- self.main.show()
- self.main.focus_set(True)
-
- def run_player(self, edje, emission, source):
- print 'not implemented yet'
-
- def player_back(self, edje, emission, source):
- print 'not implemented yet'
-
- def run_torrent(self, edje, emission, source):
- print 'not implemented yet'
-
- def torrent_back(self, edje, emission, source):
- print 'not implemented yet'
-
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Description : Labels
-# ============================================================================
-
-
-# GENERIC LABELS FOR MULTIMEDIA APPLICATIONS
-
-PLAY = "#play"
-STOP = "#stop"
-PAUSE = "#pause"
-NEXT = "#next"
-PREVIOUS = "#previous"
-VOL_UP = "#vol_up"
-VOL_DOWN = "#vol_down"
-TLINE_LEFT = "#tline_left"
-TLINE_RIGHT = "#tline_right"
-RECORD = "#record"
-#------------------------------------------>
-
-# GENERIC LABELS FOR APPLICATIONS
-
-START = "#start"
-CLOSE = "#close"
-FULL = "#fullscreen"
-UPLOAD = "#upload"
-DOWNLOAD = "#download"
-SAVE = "#save"
-DELETE = "#delete"
-#-------------------------------->
-
-# GENERAL MOUSE LABELS
-
-CLICK = "#click"
-DOUBLE_CLICK = "#double_click"
-TRIPLE_CLICK = "#triple_click"
-LEFT_CLICK = "#left_click"
-RIGHT_CLICK = "#right_click"
-MIDDLE_CLICK = "#middle_click"
-#-------------------------------->
-
-
+++ /dev/null
-#!/bin/sh -e
-
-gtk-update-icon-cache -f /usr/share/icons/hicolor
-maemo-select-menu-location pcremote-client.desktop
-
+++ /dev/null
-#!/bin/sh -e
-
-# remove configuration
-
-# Delete the .desktop file in case the app-installer didn't.
-rm -f /usr/share/applications/hildon/pcremote-client.desktop
-
-# Delete the pcremoteclt directory in case the app-installer didn't
-rm -fr /usr/share/pcremote-client
-
-# Delete the symbolics links files in case the app-installer didn't.
-rm -f /usr/bin/pcremote-client
-
-
-exit 0
+++ /dev/null
-#!/usr/bin/make -f
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # Add here commands to configure the package.
-
- touch configure-stamp
-
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
-
- # Add here commands to compile the package.
- ##$(MAKE)
- #docbook-to-man debian/pcremote-client.sgml > pcremote-client.1
-
- touch build-stamp
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
- dh_clean
-
- # Add here commands to clean up after the build process.
- -$(MAKE) clean
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/pcremote-client.
- #$(MAKE) install DESTDIR=$(CURDIR)/debian/pcremote-client
- mkdir -p $(CURDIR)/debian/pcremote-client
-
- ###insert your commands here
- cp *.py *.edj $(CURDIR)/debian/pcremote-client/usr/share/pcremote-client
- cp -r connection/ $(CURDIR)/debian/pcremote-client/usr/share/pcremote-client
- cp -r utils/ $(CURDIR)/debian/pcremote-client/usr/share/pcremote-client
- cp pcremote26.png $(CURDIR)/debian/pcremote-client/usr/share/icons/hicolor/26x26/hildon/pcremote.png
-
- ### Installing menufile
- # copy the file with the menu entry into /usr/share/applications
- cp pcremote-client.desktop $(CURDIR)/debian/pcremote-client/usr/share/applications/hildon
- cp pcremote-client $(CURDIR)/debian/pcremote-client/usr/bin
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
-# dh_install
-# dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
-# dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
+++ /dev/null
-#!/usr/bin/env python
-# -*- 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 :André Portela
-# Email :andre_portela_@hotmail.com
-# Version :1.0
-# Module :main
-# Class :PCRemote custom Edje object with it's own call backs for the
-# main screen
-# ============================================================================
-
-import thread
-import ecore
-import ecore.evas
-import evas.decorators
-import edje
-import edje.decorators
-import time
-from connection.iconnection import Iconnection
-from kineticlist import *
-
-class EvasCanvas(object):
-
- def __init__(self, fullscreen, engine, size):
- #f = ecore.evas.SoftwareX11
- self.evas_obj = engine(w=size[0], h=size[1])
- self.evas_obj.callback_delete_request = self.on_delete_request
- self.evas_obj.callback_resize = self.on_resize
-
- self.evas_obj.title = "PCRemote"
- self.evas_obj.name_class = ('PC Remote', 'main')
- self.evas_obj.fullscreen = fullscreen
- self.evas_obj.size = size
- self.evas_obj.show()
-
- def on_resize(self, evas_obj):
- x, y, w, h = evas_obj.evas.viewport
- size = (w, h)
- for key in evas_obj.data.keys():
- evas_obj.data[key].size = size
-
- def on_delete_request(self, evas_obj):
- ecore.main_loop_quit()
-
- def show(self):
- self.evas_obj.show()
-
-class EdjeObject(edje.Edje):
-
- def __init__(self, canvas_class, file, group='main',name='edje'):
- self.canvas_class = canvas_class
- self.x11 = canvas_class.evas_obj
- self.canvas = self.x11.evas
- edje.Edje.__init__(self, self.canvas, file = file, group = group)
- self.size = self.canvas.size
- self.x11.data[name] = self
-
-class MainScreen(EdjeObject):
-
- def __init__(self, canvas, file, group, name, connection):
- EdjeObject.__init__(self, canvas, file = file, group = group,name = name)
-
- self.file = file
- self.on_key_down_add(self.key_down_cb, self.x11)
- self.sock_address = None
- #flag that sync the discovery device's thread
- self.flag = False
- #flag that sync the connecting device's thread
- self.connecting_flag = False
- #lista de dispositivos descobertos
- self.lista_dispositivos = []
- #objeto que cria a conexao bluetooth
- self.conexao = connection
- self.kineticlist = False
- #portela mock object
- self.lista_teste = ['Andre Portela', 'Juliana Dias', 'Victor Hugo', 'Lucina Dias', 'Rosa Dias', 'James Italiano', 'Nona Izvi', 'Fergus Mao', 'Mauricio Brilhante', 'Edward Ordonez', 'Brankinhu', 'Banco Real', 'Banco Itaú', 'ABN-AMRO BANK']
-
- def key_down_cb(self, bg, event, ee):
- k = event.key
- if k == "Escape":
- ecore.main_loop_quit()
- elif k == "F6":
- ee.fullscreen = not ee.fullscreen
- elif k == "F8":
- print "-"
- elif k == "F7":
- print "+"
-
- def mkKineticList(self):
- #kinetic list (the item values are tied with the part "item_background" of the "list_item" group)
- #self.kineticlist = KineticList(self.canvas, file=self.file, item_width=407, item_height=38, father=self)
- self.kineticlist = KineticList(self.canvas, file=self.file, item_height=57, father=self)
- self.kineticlist.freeze()
- #portela - test kinetic list with several devices
- #for item in self.lista_teste:
- #populates the list with the device's names
- for item in self.lista_dispositivos:
- self.kineticlist.row_add(item)
- #reorganize and draw the list
- self.kineticlist.thaw()
- #embed the list in the edje object
- self.part_swallow("list", self.kineticlist);
-
- @edje.decorators.signal_callback("connect_to","choice")
- def connect_to(self, emission, source):
- self.sock_address = self.part_text_get(source)
- #flag that sync the connecting device's thread
- self.connecting_flag = False
- self.signal_emit("start","device_connect")
- thread.start_new_thread(MainScreen.threaded_connection,(self,))
-
- def threaded_connection(self):
- self.conexao.create_socket('l2cap')
- print 'connecting to: %s' % self.sock_address
- self.conexao.set_address(self.conexao.bt_find_device_address_by_name(self.sock_address))
- self.conexao.set_port(0x1001)
- self.conexao.connect()
- self.connecting_flag = True
-
- @edje.decorators.signal_callback("connecting","device")
- def connecting_check(self, emission, source):
- if self.connecting_flag:
- self.connecting_flag = False
- self.signal_emit("stop","device_connect")
- #we are sending a signal to main edje (there is time to animate the device locking)
- self.signal_emit("begin","init")
-
- @edje.decorators.signal_callback("animation_still_loading", "loading")
- def still_loading_cb(self, emission, source):
- if self.flag:
- self.flag = False
- self.signal_emit("program,stop","loading")
- if self.lista_dispositivos != []:
- self.mkKineticList()
- else:
- self.no_device_found()
-
- @edje.decorators.signal_callback("animation_sair_ended", "sair")
- def saida(self, signal, source):
- ecore.main_loop_quit()
-
- @edje.decorators.signal_callback("animation_rastrear_ended", "rastrear")
- def rastrear_key_down(self, signal, source):
- thread.start_new_thread(MainScreen.rastrear_dispositivos,(self,None))
-
- @edje.decorators.signal_callback("program,start", "novodevice")
- def search_devices_again(self, signal, source):
- self.part_unswallow(self.kineticlist)
- del self.kineticlist
- MainScreen.rastrear_key_down(self, None, None)
-
- def rastrear_dispositivos(self,arg):
- try:
- self.lista_dispositivos = self.conexao.bt_find_devices_only_names()
- except:
- self.lista_dispositivos = []
- self.flag = True
-
- def no_device_found(self):
- self.signal_emit("program,start","no_device")
-
-class TabletScreen(EdjeObject):
-
- def __init__(self, canvas, file, group,name, connection):
- EdjeObject.__init__(self, canvas, file = file, group = group,name = name)
- self.on_key_down_add(self.key_down_cb, self.x11)
- #emitt events only if the mouse is inside the touch object area
- (self.part_object_get('touch')).pointer_mode_set(evas.EVAS_OBJECT_POINTER_MODE_NOGRAB)
- #assign the mouse_move_cb method as a mouse move callback for the touch part of the edje object
- (self.part_object_get('touch')).on_mouse_move_add(self.mouse_move_cb)
- #self.on_mouse_move_add(TabletScreen.mouse_move_cb)
- self.sock = connection
- #this flag indicates either the user are grabing something or not on the target
- self.drag_flag = False
- #this float indicates the wich the method left_click_down was called, and will be
- #calculated against lcu_time in left_click_up method
- self.lcd_time = 0.0
- #tecla alt
- self.alt_flag = False
- #tecla shift
- self.iso_shift_flag = False
- #lista de aliases das teclas de comando Alt+F(x)
- #self.fletters = ['p', 'q', 'w', '', 'r', '', '', '', '', 'o']
- self.keys_dict = {'q':1, 'w':2, 'e':3, 'r':4, 't':5, 'y':6, 'u':7, 'i':8, 'o':9, 'p':0, \
- 'a':'Shift_L+1', 's':'', 'd':'Shift_L+2', 'f':'Shift_L+3', 'g':'backslash', \
- 'h':'slash', 'j':'Shift_L+9', 'k': 'Shift_L+0', 'l':'Shift_L+8', '\'':'Shift_L+slash',\
- 'z':'', 'x':'Shift_L+6', 'c':'', 'v':'Shift_L+5', 'b':'Shift_L+7', 'n':'Shift_L+4', \
- 'm':'', ';':'', '-':'Shift_L+minus', '+':'equal'}
-
- @edje.decorators.signal_callback('mouse,down,1', 'tablet_bt-L_area')
- def left_click_down(self, signal, source):
- self.lcd_time = time.time()
- #if the user are grabing something, release it
- if self.drag_flag:
- self.drag_flag = False
- self.sock.send_message("Mouse:#left_click")
-
- @edje.decorators.signal_callback('mouse,up,1', 'tablet_bt-L_area')
- def left_click_up(self, signal, source):
- lcu_time = time.time()
- #threshold of 0.5 seconds to grab something on the target
- elapsed_time = lcu_time - self.lcd_time
- if elapsed_time < 0.5:
- #do a simple click
- self.sock.send_message("Mouse:#left_click")
- self.sock.send_message("Mouse:#left_click")
- else:
- #do mouse grab
- self.sock.send_message("Mouse:#left_click")
- self.drag_flag = True
-
- @edje.decorators.signal_callback('mouse,up,1', 'tablet_bt-R_area')
- def rigth_click(self, signal, source):
- self.sock.send_message("Mouse:#right_click")
- self.sock.send_message("Mouse:#right_click")
-
- def key_down_cb(self, bg, event, ee):
- k = event.key
- print k
- if k == "Escape":
- self.sock.send_message("Keyboard:Escape")
- elif k == "F6":
- ee.fullscreen = not ee.fullscreen
- elif k == "F8":
- self.sock.send_message("Keyboard:Up")
- elif k == "F7":
- self.sock.send_message("Keyboard:Down")
- elif k == "Return":
- self.alt_flag = True
- elif k == "ISO_Level3_Shift":
- self.iso_shift_flag = True
- else:
- if self.alt_flag:
- #if k in self.fletters:
- # self.sock.send_message("Keyboard:Alt+F%s" % (self.fletters.index(k)))
- # self.alt_flag = False
- #elif k == 'space':
- # self.sock.send_message("Keyboard:Alt+Space")
- # self.alt_flag = False
- #else:
- # self.alt_flag = False
- if self.keys_dict.has_key(k) and isinstance(self.keys_dict[k], int):
- self.sock.send_message("Keyboard:Alt_L")
- self.sock.send_message("Keyboard:F%s" % (self.keys_dict[k]))
- self.alt_flag = False
- elif k == 'space':
- self.sock.send_message("Keyboard:Alt_L")
- self.sock.send_message("Keyboard:space")
- self.alt_flag = False
- else:
- self.alt_flag = False
- #else:
- #self.sock.send_message("Keyboard:%s" % k)
- elif self.iso_shift_flag:
- if self.keys_dict.has_key(k) and self.keys_dict[k] and isinstance(self.keys_dict[k], str):
- lst = self.keys_dict[k].split('+')
- for cmd in lst:
- self.sock.send_message("Keyboard:%s" % cmd)
- self.iso_shift_flag = False
- elif self.keys_dict.has_key(k) and self.keys_dict and isinstance(self.keys_dict[k], int):
- self.sock.send_message("Keyboard:%s" % self.keys_dict[k])
- self.iso_shift_flag = False
- else:
- self.iso_shift_flag = False
- else:
- self.sock.send_message("Keyboard:%s" % k)
-
- def mouse_move_cb(self, part, event):
- x, y = event.position.output[0], event.position.output[1]
- self.sock.send_message("Mouse:"+str(x)+","+str(y))
-
-class SlideScreen(EdjeObject):
-
- def __init__(self, canvas, file, group,name, connection):
- EdjeObject.__init__(self, canvas, file = file, group = group,name = name)
- self.on_key_down_add(self.key_down_cb, self.x11)
- #emitt events only if the mouse is inside the touch object area
- (self.part_object_get('touch')).pointer_mode_set(evas.EVAS_OBJECT_POINTER_MODE_NOGRAB)
- #assign the mouse_move_cb method as a mouse move callback for the touch part of the edje object
- (self.part_object_get('touch')).on_mouse_move_add(self.mouse_move_cb)
- #self.on_mouse_move_add(TabletScreen.mouse_move_cb)
- self.sock = connection
- #this flag indicates either the user are grabing something or not on the target
- self.drag_flag = False
- #helps to coordenate presentation
- self.keyboard_flag = True
- #this float indicates the wich the method left_click_down was called, and will be
- #calculated against lcu_time in left_click_up method
- self.lcd_time = 0.0
-
- @edje.decorators.signal_callback('mouse,down,1', 'slide_bt-left_area')
- def left_click_down(self, signal, source):
- if self.keyboard_flag:
- self.lcd_time = time.time()
- #if the user are grabing something, release it
- if self.drag_flag:
- self.drag_flag = False
- self.sock.send_message("Mouse:#left_click")
-
- @edje.decorators.signal_callback('mouse,up,1', 'slide_bt-left_area')
- def left_click_up(self, signal, source):
- if self.keyboard_flag:
- lcu_time = time.time()
- #threshold of 0.5 seconds to grab something on the target
- elapsed_time = lcu_time - self.lcd_time
- if elapsed_time < 0.5:
- #do a simple click
- self.sock.send_message("Mouse:#left_click")
- self.sock.send_message("Mouse:#left_click")
- else:
- #do mouse grab
- self.sock.send_message("Mouse:#left_click")
- self.drag_flag = True
- else:
- self.sock.send_message("Keyboard:%s" % "Left")
-
- @edje.decorators.signal_callback('mouse,up,1', 'slide_bt-right_area')
- def rigth_click(self, signal, source):
- if self.keyboard_flag:
- self.sock.send_message("Mouse:#right_click")
- self.sock.send_message("Mouse:#right_click")
- else:
- self.sock.send_message("Keyboard:%s" % "Right")
-
- def key_down_cb(self, bg, event, ee):
- k = event.key
- print k
- if k == "Escape":
- self.sock.send_message("Keyboard:Escape")
- elif k == "F6":
- self.keyboard_flag = not self.keyboard_flag
- self.sock.send_message("Keyboard:F5")
- elif k == "F8":
- self.sock.send_message("Keyboard:Up")
- elif k == "F7":
- self.sock.send_message("Keyboard:Down")
- else:
- self.sock.send_message("Keyboard:%s" % k)
-
- def mouse_move_cb(self, part, event):
- x, y = event.position.output[0], event.position.output[1]
- self.sock.send_message("Mouse:"+str(x)+","+str(y))
+++ /dev/null
-#!/usr/bin/env python
-# -*- 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 :Gustavo Sverzut Barbieri ; André Luiz do Canto Portela
-# Email :barbieri@gmail.com ; andre_portela_@hotmail.com
-# Version :1.0
-# Module :main
-# Class :This class are an adaptation of barbieri's demo 03 of edje
-# :python-bindings
-# ============================================================================
-
-import evas
-import edje
-import ecore
-import time
-
-class KineticList(evas.ClippedSmartObject):
- (
- SCROLL_PAGE_FORWARD,
- SCROLL_PAGE_BACKWARD,
- SCROLL_STEP_FORWARD,
- SCROLL_STEP_BACKWARD,
- SCROLL_PIXELS_DOWN,
- SCROLL_PIXELS_UP
- ) = range(6)
-
-
- def __init__(self, ecanvas, file, item_width=-1, item_height=-1, father=None):
- '''
- if item_width or item_height is left out the width (resp. height)
- of the List element is used.
- '''
- self.father = father
- evas.ClippedSmartObject.__init__(self, ecanvas)
- self.elements = []
- self.objects = []
- self.w = 32
- self.h = 32
-
- self.realized = False
-
- self.top_pos = 0
- self.last_top_pos = 0
- self.last_start_row = -1
-
- self.canvas = ecanvas
- self.edje_file = file
-
- self.row_width = item_width
- self.row_height = item_height
-
- self.__manage_objects()
-
- self.mouse_down = False
- self.last_y_pos = 0
- self.start_pos = 0
- self.mouse_moved = False
- self.continue_scrolling = False
- self.is_scrolling = False
- self.do_freeze = False
-
- def freeze(self):
- self.do_freeze = True
-
- def thaw(self):
- self.do_freeze = False
- if self.realized:
- self.__update_variables_after_new_elements()
- self.__update_screen()
-
- def scroll(self, scroll_type, amount=1):
- self.continue_scrolling = False
-
- if scroll_type == self.SCROLL_PAGE_FORWARD:
- self.top_pos += amount * self.row_height * self.max_visible_rows
- elif scroll_type == self.SCROLL_PAGE_BACKWARD:
- self.top_pos -= amount * self.row_height * self.max_visible_rows
- elif scroll_type == self.SCROLL_STEP_FORWARD:
- self.top_pos += amount * self.row_height
- elif scroll_type == self.SCROLL_STEP_BACKWARD:
- self.top_pos -= amount * self.row_height
- elif scroll_type == self.SCROLL_PIXELS_DOWN:
- self.top_pos += amount
- elif scroll_type == self.SCROLL_PIXELS_UP:
- self.top_pos -= amount
- else:
- return
-
- self.__update_screen()
-
- def __on_mouse_clicked(self, edje_obj, emission, source, data=None):
- #for obj in self.objects:
- # if obj != edje_obj:
- # obj.signal_emit("fadeout", "")
-
- #edje_obj.signal_emit("open", "")
- #TODO:portela - it works! :D
- edje_obj.signal_emit("program,start","label")
- #we are setting up the choice's text on the main edje object
- self.parent_get().part_text_set("choice",edje_obj.part_text_get("label"))
-
- def __on_mouse_move(self, edje_obj, emission, source, data=None):
- if self.mouse_down:
- x_pos, y_pos = self.canvas.pointer_canvas_xy
- diff = int(self.last_y_pos - y_pos)
-
- if diff == 0:
- return
-
- self.mouse_moved = True
-
- # Reset the data if the direction of the mouse move is changed
- if self.last_diff != -1 and (diff < 0) != (self.last_diff < 0):
- self.last_y_pos = y_pos
- self.start_pos = y_pos
- self.start_time = time.time()
-
- self.last_diff = diff
- self.top_pos += diff
-
- self.last_y_pos = y_pos
- self.__update_screen()
- self.last_update_time = time.time()
-
- #TODO: portela mod
- def __on_blink_ended(self, edje_obj, emission, source, data=None):
- for obj in self.objects:
- obj.signal_emit("program,start,fade,out","label")
- #we are sending a signal for the application connect the target
- self.parent_get().signal_emit("connect_to","choice")
-
- #TODO: portela mod
-
- def show_list(self):
- for obj in self.objects:
- obj.signal_emit("program,start,fade,in","label")
-
- def __on_mouse_down(self, edje_obj, emission, source, data=None):
- if not self.is_scrolling:
- self.mouse_moved = False
-
- self.continue_scrolling = False
- self.mouse_down = True
-
- x_pos, y_pos = self.canvas.pointer_canvas_xy
-
- self.last_diff = -1
- self.last_y_pos = y_pos
- self.start_pos = y_pos
- self.start_time = time.time()
- self.last_update_time = time.time()
-
- def __on_mouse_up(self, edje_obj, emission, source, data=None):
- if self.mouse_down:
- self.mouse_down = False
-
- x_pos, end_pos = self.canvas.pointer_canvas_xy
-
- if not self.mouse_moved and not self.is_scrolling:
- #self.__on_mouse_clicked(edje_obj, emission, source)
- return
-
- self.mouse_moved = False
- self.is_scrolling = False
-
- # do not scroll automatically if the finger was paused
- if time.time() - self.last_update_time > 0.1:
- return
-
- end_time = time.time()
-
- pos_diff = end_pos - self.start_pos
- time_diff = end_time - self.start_time
-
- self.pixel_per_sec = pos_diff / time_diff
- self.continue_scrolling = True
- self.__do_scroll()
-
- def __do_scroll(self):
- self.is_scrolling = True
-
- if self.continue_scrolling == False:
- return
-
- diff = int(self.pixel_per_sec / 10)
-
- if abs(self.pixel_per_sec) - diff <= self.row_height:
- offset = self.top_pos % self.row_height
-
- if offset >= self.row_height / 2:
- self.sign = 1
- offset = self.row_height - offset
- else:
- self.sign = -1
-
- self.pixels_left = offset
- self.__do_magnetic_scroll()
-
- return
-
- if diff != 0:
- self.top_pos -= diff
- self.pixel_per_sec -= self.pixel_per_sec / 10
- self.__update_screen()
-
- ecore.timer_add(0.02, self.__do_scroll)
-
- def __do_magnetic_scroll(self):
- if self.pixels_left <= 0 or abs(self.pixel_per_sec) < 1:
- self.mouse_moved = False
- self.is_scrolling = False
- return
-
- self.pixel_per_sec -= (self.pixel_per_sec / 10)
-
- pixels_to_substract = int(abs(self.pixel_per_sec / 10))
- if abs(pixels_to_substract) < 1:
- pixels_to_substract = 1
-
- if self.pixels_left - pixels_to_substract > 0:
- self.pixels_left -= pixels_to_substract
- self.top_pos += self.sign * pixels_to_substract
- else:
- self.top_pos += self.sign * self.pixels_left
- self.pixels_left = 0
-
- self.__update_screen()
- ecore.timer_add(0.1, self.__do_magnetic_scroll)
-
- def row_add(self, label):
- self.elements.append(label)
-
- if not self.do_freeze:
- self.__update_variables_after_new_elements()
- self.__update_screen()
-
- def __manage_objects(self):
- remain = (self.h % self.row_height) > 1
- needed_objects = ((self.h / self.row_height) + 1 + remain) * (self.w / self.row_width)
- current_objects = len(self.objects)
-
- if current_objects < needed_objects:
- for i in range(current_objects, needed_objects):
- obj = edje.Edje(self.canvas);
- obj.file_set(self.edje_file, "list_item");
-
- obj.signal_callback_add("mouse,move", "*",
- self.__on_mouse_move)
- obj.signal_callback_add("mouse,down,*", "*",
- self.__on_mouse_down)
- obj.signal_callback_add("mouse,up,*", "*",
- self.__on_mouse_up)
- #TODO: portela mod
- obj.signal_callback_add("animation_blink_ended", "label",
- self.__on_blink_ended)
- obj.signal_callback_add("mouse,clicked,*", "label",
- self.__on_mouse_clicked)
- obj.size = (self.row_width, self.row_height)
- obj.clip = self
- self.objects.append(obj)
-
- elif needed_objects < current_objects:
- for i in range(needed_objects, current_objects):
- pass # Make this work, it throws exception that makes
- # things stop working properly
- #del self.objects[i]
-
- def __update_variables_after_resize(self):
- self.max_visible_rows = (self.h / self.row_height) + 1
- self.max_horiz_elements = (self.w / self.row_width)
- self.max_visible_elements = self.max_visible_rows * \
- self.max_horiz_elements
-
- # Invalidate variable in order to repaint all rows
- # Some might not have been painted before (Didn't
- # fit on the screen
- self.last_start_row = -1
-
- self.__update_variables_after_new_elements()
-
- def __update_variables_after_new_elements(self):
- if not self.realized:
- return
-
- self.min_pos = 0
- remainer1 = (len(self.elements) % self.max_horiz_elements) > 0
- remainer2 = (self.h % self.row_height) > 0
- self.row_amount = (len(self.elements) / self.max_horiz_elements) + \
- remainer1 + remainer2
- self.max_pos = self.row_height * \
- (self.row_amount - self.max_visible_rows + 1)
-
- def __update_screen(self):
- remainer = (self.h % self.row_height) > 0
- row_offset = (self.top_pos / self.row_height)
- pixel_offset = - (self.top_pos % self.row_height)
- start_row = row_offset
- end_row = self.max_visible_rows + row_offset + remainer
-
- SCROLL_DOWN = self.top_pos > self.last_top_pos
- SCROLL_UP = self.top_pos < self.last_top_pos
-
- # Let's not move over the last element
- if SCROLL_DOWN and self.last_top_pos >= self.max_pos:
- self.top_pos = self.max_pos
- self.last_top_pos = self.top_pos
- self.continue_scrolling = False
- return
-
- # Let's not move over the first element
- if SCROLL_UP and self.last_top_pos <= self.min_pos:
- self.top_pos = self.min_pos
- self.last_top_pos = self.top_pos
- self.continue_scrolling = False
- return
-
- # Overflow scrolling down
- if SCROLL_DOWN and end_row > self.row_amount:
- offset = end_row - self.row_amount
- end_row -= offset
- start_row -= offset
- row_offset -= offset - 1
- self.top_pos = self.max_pos
- pixel_offset = 0
-
- # Overflow scrolling up
- if SCROLL_UP and start_row < 0:
- self.top_pos = self.min_pos
- end_row -= start_row
- start_row = 0
- row_offset = 0
- pixel_offset = 0
-
- self.last_top_pos = self.top_pos
-
- if start_row != self.last_start_row:
- for i in range(0, len(self.objects)):
- self.objects[i].hide()
-
- for i in range(start_row, end_row):
- row_iter = i - start_row
-
- for k in range(self.max_horiz_elements):
- obj_iter = row_iter * self.max_horiz_elements + k
- data_iter = i * self.max_horiz_elements + k
-
- try:
- label = self.elements[data_iter]
- except Exception, e:
- break;
-
- offset = (self.w %
- (self.row_width * self.max_horiz_elements)) / 2
- x = self.row_width * k + self.top_left[0] + offset
- y = self.top_left[1] + self.row_height * (i - row_offset) - \
- 5 + pixel_offset
-
- self.objects[obj_iter].move(x, y)
-
- if start_row != self.last_start_row:
- self.objects[obj_iter].part_text_set("label", label)
- self.objects[obj_iter].show()
-
- self.last_start_row = start_row
-
- def resize(self, w, h):
- if self.row_width == -1 or self.row_width == self.w:
- self.row_width = w
-
- if self.row_height == -1 or self.row_height == self.h:
- self.row_height = h
-
- self.w = w
- self.h = h
-
- self.__manage_objects()
-
- for obj in self.objects:
- obj.size = (self.row_width, self.row_height)
-
- self.realized = True
- self.__update_variables_after_resize()
- self.__update_screen()
+++ /dev/null
-#!/bin/sh
-
-python /usr/share/pcremote-client/pcremote-client.py
+++ /dev/null
-[Desktop Entry]
-Encoding=UTF-8
-Version=0.60
-Type=Application
-Icon=pcremote
-Name=PCRemote Client
-Exec=pcremote-client
-X-Window-Icon=pcremote
-X-Window-Icon-Dimmed=pcremote
-Terminal=false
-Categories=Application;Network;
-StartupNotify=false
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-# ****************************************************************************
-# Copyright (c) 2008 Zagaia - 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 :Andre Portela
-# Email :andre_portela_@hotmail.com
-# Version :1.0
-# Module :main
-# Class :PCRemote custom Edje object with it's own call backs for the
-# main screen
-# ============================================================================
-
-from ecore import main_loop_begin
-import ecore.evas
-import sys
-import os
-from edje_objects import *
-from connection.iconnection import Iconnection
-from screenmanager import ScreenManager
-
-width, height = 800, 480
-
-#any argument deactivates fullscreen
-if sys.argv.__len__() > 1:
- screen = False
-else:
- screen = True
-#if x11_16 is present, get it, otherwise get x11
-if ecore.evas.engine_type_supported_get("software_x11_16"):
- engine = ecore.evas.SoftwareX11_16
-else:
- engine = ecore.evas.SoftwareX11
-#create the evas canvas
-canvas = EvasCanvas(fullscreen=screen,engine=engine,size=(width, height))
-#main .edj path
-edje_file = os.path.join(os.path.dirname(sys.argv[0]), "pcremote.edj")
-#the bluetooth socket object shared by all screens
-sock = Iconnection('bluetooth')
-#main edje object
-main = MainScreen(canvas=canvas, file=edje_file, group="Main",name="Main", connection = sock)
-main.show()
-#future edje objects
-tablet, slide, player, torrent = None, None, None, None
-#focus on main edje object
-main.focus = True
-#this object connects all screens together
-manager = ScreenManager(main, tablet, slide, player, torrent, sock)
-
-ecore.main_loop_begin()
-
+++ /dev/null
-#!/usr/bin/env python
-# -*- 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 :André Portela
-# Email :andre_portela_@hotmail.com
-# Version :1.0
-# Module :main
-# Class :PCRemote ScreenManager handles the finite state machine which
-# controls the navigation between screens.
-# ============================================================================
-
-from edje_objects import *
-import os
-import sys
-
-class ScreenManager(object):
- '''
- classdocs
- '''
- def __init__(self, main, tablet, slide, player, torrent,socket):
- '''
- Constructor
- '''
- self.main = main
- self.tablet = tablet
- self.slide = slide
- self.player = player
- self.torrent = torrent
- self.sock = socket
- main.signal_callback_add("mouse,up,1", "Tablet",self.run_tablet)
- main.signal_callback_add("mouse,up,1", "Slideshow",self.run_slide)
- main.signal_callback_add("mouse,up,1", "Player",self.run_player)
- main.signal_callback_add("mouse,up,1", "Torrent",self.run_torrent)
-
- def run_tablet(self, edje, emission, source):
- self.sock.send_message(source+":#start")
- print 'entrou no tablet'
- #main edje object
- edje.focus_set(False)
- edje.hide()
- if self.tablet is None:
- edje_file = os.path.join(os.path.dirname(sys.argv[0]), "tablet.edj")
- self.tablet = TabletScreen(edje.canvas_class, edje_file, 'main', 'tablet', self.sock)
- self.tablet.signal_callback_add("mouse,up,1","tablet_bt-voltar_area",self.tablet_back)
- self.tablet.part_text_set('pc_name',edje.sock_address)
- self.tablet.show()
- self.tablet.focus_set(True)
-
- def tablet_back(self, edje, emission, source):
- #tablet edje object
- edje.focus_set(False)
- edje.hide()
- self.sock.send_message("Tablet:#stop")
- self.main.show()
- self.main.focus_set(True)
-
- def run_slide(self, edje, emission, source):
- self.sock.send_message(source+":#start")
- print 'entrou no slide'
- #main edje object
- edje.focus_set(False)
- edje.hide()
- if self.slide is None:
- edje_file = os.path.join(os.path.dirname(sys.argv[0]), "slide.edj")
- self.slide = SlideScreen(edje.canvas_class, edje_file, 'main', 'slide', self.sock)
- self.slide.signal_callback_add("unselected","slide_bt-voltar",self.slide_back)
- #self.slide.part_text_set('pc_name',edje.sock_address)
- #this rotates the screen 90 degrees (to fit text in vertical orientation)
- #self.slide.x11.rotation_set(90)
- self.slide.show()
- self.slide.focus_set(True)
-
- def slide_back(self, edje, emission, source):
- #slide edje object
- edje.focus_set(False)
- edje.hide()
- self.sock.send_message("Slideshow:#stop")
- #this rotates the screen from 90 to 0 degrees (to fit text in horizontal orientation again)
- #self.main.x11.rotation_set(0)
- self.main.show()
- self.main.focus_set(True)
-
- def run_player(self, edje, emission, source):
- print 'not implemented yet'
-
- def player_back(self, edje, emission, source):
- print 'not implemented yet'
-
- def run_torrent(self, edje, emission, source):
- print 'not implemented yet'
-
- def torrent_back(self, edje, emission, source):
- print 'not implemented yet'
-
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Description : Labels
-# ============================================================================
-
-
-# GENERIC LABELS FOR MULTIMEDIA APPLICATIONS
-
-PLAY = "#play"
-STOP = "#stop"
-PAUSE = "#pause"
-NEXT = "#next"
-PREVIOUS = "#previous"
-VOL_UP = "#vol_up"
-VOL_DOWN = "#vol_down"
-TLINE_LEFT = "#tline_left"
-TLINE_RIGHT = "#tline_right"
-RECORD = "#record"
-#------------------------------------------>
-
-# GENERIC LABELS FOR APPLICATIONS
-
-START = "#start"
-CLOSE = "#close"
-FULL = "#fullscreen"
-UPLOAD = "#upload"
-DOWNLOAD = "#download"
-SAVE = "#save"
-DELETE = "#delete"
-#-------------------------------->
-
-# GENERAL MOUSE LABELS
-
-CLICK = "#click"
-DOUBLE_CLICK = "#double_click"
-TRIPLE_CLICK = "#triple_click"
-LEFT_CLICK = "#left_click"
-RIGHT_CLICK = "#right_click"
-MIDDLE_CLICK = "#middle_click"
-#-------------------------------->
-
-
+++ /dev/null
-8
-
-dir
-42
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn/remote_server/trunk/remote_server/src/connection
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn
-
-
-
-2008-11-24T19:21:45.815695Z
-31
-aportela
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-fe65f2a5-7a5f-4c8d-90e7-f011580d4f26
-\f
-iconnection.py
-file
-
-
-
-
-2008-11-24T19:10:09.000000Z
-5a23a701cbe84644991072a94b636f35
-2008-11-24T19:08:20.539642Z
-24
-aportela
-has-props
-\f
-wirelessconnectionmanager.py
-file
-
-
-
-
-2008-11-24T19:21:26.000000Z
-518124236f6ddf6a0c67621853cd7229
-2008-11-24T19:21:45.815695Z
-31
-aportela
-has-props
-\f
-__init__.py
-file
-
-
-
-
-2008-10-31T23:33:24.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2008-10-31T22:34:59.880000Z
-4
-aportela
-has-props
-\f
-bluetoothconnectionmanager.py
-file
-
-
-
-
-2008-11-24T19:09:16.000000Z
-67af5797d41770d8801ca335f011ea7f
-2008-11-24T19:09:43.908566Z
-25
-aportela
-has-props
-\f
-genericconnectionmanager.py
-file
-
-
-
-
-2008-11-24T19:11:06.000000Z
-159366919bc6213b7f6fae65dc603afa
-2008-11-24T19:11:23.207768Z
-26
-aportela
-has-props
-\f
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 14
-svn:executable
-V 1
-*
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : connection
-# Description : BluetoothConnectionManager
-# ============================================================================
-
-import bluetooth
-from exceptions import *
-from genericconnectionmanager import *
-
-class BluetoothConnectionManager(GenericConnectionManager):
-
- """ BluetoothConnectionManager
- manages objects and operations for bluetooth connection.
- Subclass of GerericConnectionManager.
- """
-
- def __init__(self):
- GenericConnectionManager.__init__(self)
- self.sock = None
- self.port = None
- self.address = None
- self.client_sock = None
- self.client_address = None
-
- # fast way to create a simple server
- def create_server(self, protocol, port):
- self.create_socket(protocol)
- self.set_port(port)
- self.bind()
- self.listen()
- self.accept()
-
- # fast way to create a simple client
- def create_client(self, protocol, address, port):
- self.create_socket(protocol)
- self.set_address(address)
- self.set_port(port)
- self.connect()
-
- # search for all devices
- def find_devices(self, time=8):
- list_devices = bluetooth.discover_devices(lookup_names = True, duration=time)
- if list_devices:
- return list_devices
- else:
- raise BluetoothConnectionError, "Device were not found."
-
- # search the device port
- def find_port(self, addr):
- port = None
- aux = addr.split(":")
- if len(aux) == 6:
- services = bluetooth.find_service(address=addr)
- for i in range(len(services)):
- port = services[i]['port']
-
- if port != None:
- return port
- else:
- raise BluetoothConnectionError, "Port not found."
-
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # search device services
- def find_services(self, service=None, addr=None):
- if service == None and addr == None:
- list = bluetooth.find_service()
- return list
- elif service != None and addr == None:
- list = bluetooth.find_service(name=service)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Name of the service does not exist."
- elif service == None and addr != None:
- number = addr.split(":")
- if(len(number) == 6):
- list = bluetooth.find_service(address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
- elif service != None and addr != None:
- number = addr.split(":")
- if(len(number) == 6):
- list = bluetooth.find_service(name=service, address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
-
-
- # search the device indicated by name
- def find_device_address_by_name(self, device_name):
- list = bluetooth.discover_devices()
- addr = None
-
- for address in list:
- if device_name == bluetooth.lookup_name(address):
- addr = address
- break
- if addr:
- return addr
- else:
- raise BluetoothConnectionError, "Device name not found."
-
- # search only device names
- def find_devices_only_names(self):
- list = self.find_devices()
- list_names = []
- for address, names in list:
- list_names += [names]
-
- if list_names:
- return list_names
- else:
- raise BluetoothConnectionError, "Devices were not found."
-
- # get the client address
- def get_client_address(self):
- return self.client_address
-
- # set the port to communicate
- def set_port(self, port):
- self.port = port
-
- # get the port to communicate
- def get_port(self):
- return self.port
-
- # set the device address
- def set_address(self, address):
- aux = address.split(":")
- if len(aux) == 6:
- self.address = address
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # get the device address
- def get_address(self):
- return self.address
-
- # create a socket with a determinated protocol
- def create_socket(self, protocol=None):
- if protocol == 'rfcomm' or protocol == 'RFCOMM':
- self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
- elif protocol == 'l2cap' or protocol == 'L2CAP':
- self.sock = bluetooth.BluetoothSocket(bluetooth.L2CAP)
- else:
- raise BluetoothConnectionError, "Undefined Protocol."
-
- # bind the communication
- def bind(self):
- self.sock.bind(("", self.get_port()))
-
- # just listen the tube, only to server
- def listen(self):
- self.sock.listen(1)
-
- # accept the client communication
- def accept(self):
- self.client_sock, self.client_address = self.sock.accept()
-
- # connect devices
- def connect(self):
- self.sock.connect((self.get_address(), self.get_port()))
-
- # send string message
- def send_message(self, msg=None):
- self.sock.send(msg)
-
- # receive string message
- def received_message(self):
- return self.client_sock.recv(1024)
-
- # close connection
- def close(self):
- if self.sock != None and self.client_sock != None:
- self.client_sock.close()
- self.sock.close()
- elif self.sock != None and self.client_sock == None:
- self.sock.close()
- else:
- self.client_sock.close()
-
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : connection
-# Description : GenericConnectionManager
-# ============================================================================
-
-
-class GenericConnectionManager:
-
- """ GenericConnectionManager
- Superclass of connections
- """
-
- def __init__(self):
- print "GenericConnectionManager iniciado."
- self.tipo = "generico"
-
- # current service running
- def identify_app(self):
- print "identify_app"
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : connection
-# Description : Iconnection Interface Class
-# ============================================================================
-
-from wirelessconnectionmanager import *
-from bluetoothconnectionmanager import *
-from exceptions import *
-
-# connections aliases
-_btconst = ['bluetooth', 'BLUETOOTH', 'blue']
-_wificonst = ['wireless', 'WIRELESS', 'wifi']
-
-class Iconnection:
-
- """ Iconnection
- Interface for wireless and bluetooth connections.
- Manages all commonalities operations between entities.
- """
- def __init__(self, string):
- self.string = string
- if(self.string in _btconst):
- self.obj = BluetoothConnectionManager()
- elif(self.string in _wificonst):
- self.obj = WirelessConnectionManager()
- else:
- raise IconnectionError, "Undefined type."
-
-
- # +---------------------------------------------+
- # | Generic methods -> Wireless and Bluetooth |
- # +---------------------------------------------+
-
- # create a socket with defined protocol
- def create_socket(self, protocol=None):
- self.obj.create_socket(protocol)
-
- # connect device
- def connect(self):
- self.obj.connect()
-
- # accept the connection
- def accept(self):
- return self.obj.accept()
-
- # send a message to device
- def send_message(self, msg=None):
- self.obj.send_message(msg)
-
- # received a message
- def received_message(self):
- return self.obj.received_message()
-
- # bind the connection
- def bind(self):
- self.obj.bind()
-
- # listen the connection
- def listen(self):
- self.obj.listen()
-
- # close connection
- def close(self):
- self.obj.close()
-
- # set the port to communicate
- def set_port(self, port):
- self.obj.set_port(port)
-
- # get the port to communicate
- def get_port(self):
- return self.obj.get_port()
-
- # set the device address
- def set_address(self, address):
- self.obj.set_address(address)
-
- # get the device address
- def get_address(self):
- return self.obj.get_address()
-
- # get the client address
- def get_client_address(self):
- return self.obj.get_client_address()
-
- # +------------------------------------------+
- # | Bluetooth: particular behaviors |
- # +------------------------------------------+
-
- # fast way to create a simple server
- def bluetooth_create_server(self, protocol, port):
- if self.string in _btconst:
- return self.obj.create_server(protocol, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # fast way to create a simple client
- def bluetooth_create_client(self, protocol, address, port):
- if self.string in _btconst:
- return self.obj.create_client(protocol, address, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search for all devices
- def bluetooth_find_devices(self, time=8):
- if self.string in _btconst:
- return self.obj.find_devices(time)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search only devices names
- def bluetooth_find_devices_only_names(self):
- if self.string in _btconst:
- return self.obj.find_devices_only_names()
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search the device port
- def bluetooth_find_port(self, addr):
- if self.string in _btconst:
- return self.obj.find_port(addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search device services
- def bluetooth_find_services(self, service=None, addr=None):
- if self.string in _btconst:
- return self.obj.find_services(service, addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
- # search the device indicated by name
- def bluetooth_find_device_address_by_name(self, device_name=None):
- if self.string in _btconst:
- return self.obj.find_device_address_by_name(device_name)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
-
- # +---------------------------------+
- # | Wireless: particular behaviors |
- # +---------------------------------+
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 0.1
-# Package : connection
-# Description : Wireless Connection Manager Class
-# ============================================================================
-
-from genericconnectionmanager import *
-
-class WirelessConnectionManager(GenericConnectionManager):
-
- """ WirelessConnectionManager
- Manages objects and operations for wireless connection.
- Subclass of GenericConnectionManager.
- """
-
- def __init__(self):
- GenericConnectionManager.__init__(self)
- self.tipo = "wireless"
-
-
-
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : connection
-# Description : BluetoothConnectionManager
-# ============================================================================
-
-import bluetooth
-from exceptions import *
-from genericconnectionmanager import *
-
-class BluetoothConnectionManager(GenericConnectionManager):
-
- """ BluetoothConnectionManager
-
- manages objects and operations for bluetooth connection.
- Subclass of GerericConnectionManager.
- """
-
- def __init__(self):
- GenericConnectionManager.__init__(self)
- self.sock = None
- self.port = None
- self.address = None
- self.client_sock = None
- self.client_address = None
-
- # fast way to create a simple server
- def create_server(self, protocol, port):
- self.create_socket(protocol)
- self.set_port(port)
- self.bind()
- self.listen()
- self.accept()
-
- # fast way to create a simple client
- def create_client(self, protocol, address, port):
- self.create_socket(protocol)
- self.set_address(address)
- self.set_port(port)
- self.connect()
-
- # search for all devices
- def find_devices(self, time=8):
- list_devices = bluetooth.discover_devices(lookup_names = True, duration=time)
- if list_devices:
- print list_devices
- return list_devices
- else:
- raise BluetoothConnectionError, "Device were not found."
-
- # search the device port
- def find_port(self, addr):
- port = None
- aux = addr.split(":")
- if len(aux) == 6:
- services = bluetooth.find_service(address=addr)
- for i in range(len(services)):
- port = services[i]['port']
-
- if port != None:
- return port
- else:
- raise BluetoothConnectionError, "Port not found."
-
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # search device services
- def find_services(self, service=None, addr=None):
- if service == None and addr == None:
- list = bluetooth.find_service()
- return list
- elif service != None and addr == None:
- list = bluetooth.find_service(name=service)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Name of the service does not exist."
- elif service == None and addr != None:
- number = addr.split(":")
- if(len(number) == 6):
- list = bluetooth.find_service(address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
- elif service != None and addr != None:
- number = addr.split(":")
- if(len(number) == 6):
- list = bluetooth.find_service(name=service, address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
-
-
- # search the device indicated by name
- def find_device_address_by_name(self, device_name):
- list = bluetooth.discover_devices()
- addr = None
-
- for address in list:
- if device_name == bluetooth.lookup_name(address):
- addr = address
- break
- if addr:
- return addr
- else:
- raise BluetoothConnectionError, "Device name not found."
-
- # search only device names
- def find_devices_only_names(self):
- list = self.find_devices()
- list_names = []
- for address, names in list:
- list_names += [names]
-
- if list_names:
- return list_names
- else:
- raise BluetoothConnectionError, "Devices were not found."
-
- # get the client address
- def get_client_address(self):
- return self.client_address
-
- # set the port to communicate
- def set_port(self, port):
- self.port = port
-
- # get the port to communicate
- def get_port(self):
- return self.port
-
- # set the device address
- def set_address(self, address):
- aux = address.split(":")
- if len(aux) == 6:
- self.address = address
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # get the device address
- def get_address(self):
- return self.address
-
- # create a socket with a determinated protocol
- def create_socket(self, protocol=None):
- if protocol == 'rfcomm' or protocol == 'RFCOMM':
- self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
- elif protocol == 'l2cap' or protocol == 'L2CAP':
- self.sock = bluetooth.BluetoothSocket(bluetooth.L2CAP)
- else:
- raise BluetoothConnectionError, "Undefined Protocol."
-
- # bind the communication
- def bind(self):
- self.sock.bind(("", self.get_port()))
-
- # just listen the tube, only to server
- def listen(self):
- self.sock.listen(1)
-
- # accept the client communication
- def accept(self):
- self.client_sock, self.client_address = self.sock.accept()
-
- # connect devices
- def connect(self):
- self.sock.connect((self.get_address(), self.get_port()))
-
- # send string message
- def send_message(self, msg=None):
- self.sock.send(msg)
-
- # receive string message
- def received_message(self):
- return self.client_sock.recv(1024)
-
- # close connection
- def close(self):
- if self.sock != None and self.client_sock != None:
- self.client_sock.close()
- self.sock.close()
- elif self.sock != None and self.client_sock == None:
- self.sock.close()
- else:
- self.client_sock.close()
-
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : connection
-# Description : GenericConnectionManager
-# ============================================================================
-
-
-class GenericConnectionManager:
-
- """ GenericConnectionManager
- Superclass of connections
- """
-
- def __init__(self):
- print "GenericConnectionManager iniciado."
- self.tipo = "generico"
-
- # current service running
- def identify_app(self):
- print "identify_app"
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : connection
-# Description : Iconnection Interface Class
-# ============================================================================
-
-from wirelessconnectionmanager import *
-from bluetoothconnectionmanager import *
-from exceptions import *
-
-# connections aliases
-_btconst = ['bluetooth', 'BLUETOOTH', 'blue']
-_wificonst = ['wireless', 'WIRELESS', 'wifi']
-
-class Iconnection:
-
- """ Iconnection
- Interface for wireless and bluetooth connections.
- Manages all commonalities operations between entities.
- """
- def __init__(self, string):
- self.string = string
- if(self.string in _btconst):
- self.obj = BluetoothConnectionManager()
- elif(self.string in _wificonst):
- self.obj = WirelessConnectionManager()
- else:
- raise IconnectionError, "Undefined type."
-
-
- # +---------------------------------------------+
- # | Generic methods -> Wireless and Bluetooth |
- # +---------------------------------------------+
-
- # create a socket with defined protocol
- def create_socket(self, protocol=None):
- self.obj.create_socket(protocol)
-
- # connect device
- def connect(self):
- self.obj.connect()
-
- # accept the connection
- def accept(self):
- return self.obj.accept()
-
- # send a message to device
- def send_message(self, msg=None):
- self.obj.send_message(msg)
-
- # received a message
- def received_message(self):
- return self.obj.received_message()
-
- # bind the connection
- def bind(self):
- self.obj.bind()
-
- # listen the connection
- def listen(self):
- self.obj.listen()
-
- # close connection
- def close(self):
- self.obj.close()
-
- # set the port to communicate
- def set_port(self, port):
- self.obj.set_port(port)
-
- # get the port to communicate
- def get_port(self):
- return self.obj.get_port()
-
- # set the device address
- def set_address(self, address):
- self.obj.set_address(address)
-
- # get the device address
- def get_address(self):
- return self.obj.get_address()
-
- # get the client address
- def get_client_address(self):
- return self.obj.get_client_address()
-
- # +------------------------------------------+
- # | Bluetooth: particular behaviors |
- # +------------------------------------------+
-
- # fast way to create a simple server
- def bluetooth_create_server(self, protocol, port):
- if self.string in _btconst:
- return self.obj.create_server(protocol, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # fast way to create a simple client
- def bluetooth_create_client(self, protocol, address, port):
- if self.string in _btconst:
- return self.obj.create_client(protocol, address, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search for all devices
- def bluetooth_find_devices(self, time=8):
- if self.string in _btconst:
- return self.obj.find_devices(time)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search only devices names
- def bluetooth_find_devices_only_names(self):
- if self.string in _btconst:
- return self.obj.find_devices_only_names()
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search the device port
- def bluetooth_find_port(self, addr):
- if self.string in _btconst:
- return self.obj.find_port(addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search device services
- def bluetooth_find_services(self, service=None, addr=None):
- if self.string in _btconst:
- return self.obj.find_services(service, addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
- # search the device indicated by name
- def bluetooth_find_device_address_by_name(self, device_name=None):
- if self.string in _btconst:
- return self.obj.find_device_address_by_name(device_name)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
-
- # +---------------------------------+
- # | Wireless: particular behaviors |
- # +---------------------------------+
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 0.1
-# Package : connection
-# Description : Wireless Connection Manager Class
-# ============================================================================
-
-from genericconnectionmanager import *
-
-class WirelessConnectionManager(GenericConnectionManager):
-
- """ WirelessConnectionManager
- Manages objects and operations for wireless connection.
- Subclass of GenericConnectionManager.
- """
-
- def __init__(self):
- GenericConnectionManager.__init__(self)
- self.tipo = "wireless"
-
-
-
+++ /dev/null
-pcremote-server for Debian
-----------------------
-
-<possible notes regarding this package - if none, delete this file>
-
- -- Jonatas Isvi <jonatas.nona@gmail.com> Mon, 30 Mar 2009 18:53:24 -0400
+++ /dev/null
-pcremote-server (0.60-1) unstable; urgency=low
-
- * Initial release (Closes: #nnnn) <nnnn is the bug number of your ITP>
-
- -- Jonatas Isvi <jonatas.nona@gmail.com> Mon, 30 Mar 2009 18:53:24 -0400
-
+++ /dev/null
-Source: pcremote-server
-Section: net
-Priority: optional
-Maintainer: Jonatas Isvi <jonatas.nona@gmail.com>, Andre Portela <andre_portela_@hotmail.com>, Nilson Silva <fergus.mao@gmail.com>
-Build-Depends: debhelper (>= 5)
-Standards-Version: 3.7.2
-
-Package: pcremote-server
-Architecture: all
-Depends: python2.5, python2.5-gtk2, python-bluetooth, python-xlib, python2.5-notify, python-dcop
-Description: A server application of PCRemote Client
+++ /dev/null
-Copyright (c) 2009 Zagaia Lab (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 Server
- Author(s) <email>: Jonatas Isvi <jonatas.nona@gmail.com>, Andre Portela <andre_portela_@hotmail.com>,
- Nilson Silva <fergus.mao@gmail.com>
+++ /dev/null
-usr/bin
-usr/share/pcremote-server
-usr/share/pcremote-server/images
-usr/share/applications
-usr/share/icons/hicolor/48x48/
-usr/share/menu
-
+++ /dev/null
-pcremote-server_0.60-1_all.deb net optional
+++ /dev/null
-Package: pcremote-server
-Version: 0.50-1
-Architecture: all
-Maintainer: Jonatas Isvi <jonatas.nona@gmail.com>, Andre Portela <andre_portela_@hotmail.com>, Nilson Silva <fergus.mao@gmail.com>
-Installed-Size: 461
-Depends: python-bluetooth, python-dcop, python-xlib, python2.5, python2.5-gtk2, python2.5-notify
-Section: net
-Priority: optional
-Description: A server application of PCRemote Client
+++ /dev/null
-1753f2a532e9218207f37d8deab8d559 usr/bin/pcremote-server
-a45cefda3455e840e85003b8b01fab75 usr/share/doc/pcremote-server/README.Debian
-c8953c952799be3f2e28d1144864b68a usr/share/doc/pcremote-server/copyright
-76f32feb0e14910d0ba95ec54e235fb2 usr/share/doc/pcremote-server/changelog.Debian.gz
-edfe58d9bcd05825af84b80c77794cc9 usr/share/menu/pcremote-server-menu
-2553d9134379e7199e7bb4c8995467f9 usr/share/icons/pcremote.png
-c228a4f323d17e3a589b979e11f2cbc6 usr/share/pcremote-server/pcremote-server.py
-e2f5948c1c71348f50834f5579aa2448 usr/share/pcremote-server/utils/.svn/entries
-c30f7472766d25af1dc80b3ffc9a58c7 usr/share/pcremote-server/utils/.svn/format
-606a6ee70138fd606222cd4c3162cc3f usr/share/pcremote-server/utils/.svn/text-base/plistparser.py.svn-base
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-server/utils/.svn/text-base/__init__.py.svn-base
-6c9741bd79bbd0f1ac82d2d98614032d usr/share/pcremote-server/utils/.svn/text-base/labels.py.svn-base
-4160c74de5f4e580dc15660c798ff9fc usr/share/pcremote-server/utils/.svn/prop-base/plistparser.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/utils/.svn/prop-base/__init__.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/utils/.svn/prop-base/labels.py.svn-base
-5eed0b1df833b280b647cf2e6d5a8e98 usr/share/pcremote-server/utils/messages.py
-e611e04d448a689e17eb788c910721f1 usr/share/pcremote-server/utils/labels.py
-7b7040ac3d2fed14a34e738957629dc1 usr/share/pcremote-server/utils/labels.pyc
-63a0bef02a2757c61ead56bf6796d60f usr/share/pcremote-server/utils/plistparser.pyc
-a7e8dfcbaa82ac40a6bf395d517cbddc usr/share/pcremote-server/utils/__init__.pyc
-8923dc021f420a77b5a28f721c232cbf usr/share/pcremote-server/utils/.messages.py.swp
-606a6ee70138fd606222cd4c3162cc3f usr/share/pcremote-server/utils/plistparser.py
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-server/utils/__init__.py
-59724740128fb59b5dd1273401874252 usr/share/pcremote-server/utils/messages.pyc
-c5110a93e1ffa5b18c635ded207d76fb usr/share/pcremote-server/runserver.py
-19faca80edd182a92fe6f64d73aebb42 usr/share/pcremote-server/exceptions/.svn/entries
-c30f7472766d25af1dc80b3ffc9a58c7 usr/share/pcremote-server/exceptions/.svn/format
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-server/exceptions/.svn/text-base/__init__.py.svn-base
-41e514c3297ce38f7bd5d4f687fcaa9b usr/share/pcremote-server/exceptions/.svn/text-base/exception.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/exceptions/.svn/prop-base/__init__.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/exceptions/.svn/prop-base/exception.py.svn-base
-41e514c3297ce38f7bd5d4f687fcaa9b usr/share/pcremote-server/exceptions/exception.py
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-server/exceptions/__init__.py
-524491cd9ca8dea18f30ef233cb8978e usr/share/pcremote-server/connection/.svn/entries
-c30f7472766d25af1dc80b3ffc9a58c7 usr/share/pcremote-server/connection/.svn/format
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-server/connection/.svn/text-base/__init__.py.svn-base
-5a23a701cbe84644991072a94b636f35 usr/share/pcremote-server/connection/.svn/text-base/iconnection.py.svn-base
-159366919bc6213b7f6fae65dc603afa usr/share/pcremote-server/connection/.svn/text-base/genericconnectionmanager.py.svn-base
-518124236f6ddf6a0c67621853cd7229 usr/share/pcremote-server/connection/.svn/text-base/wirelessconnectionmanager.py.svn-base
-67af5797d41770d8801ca335f011ea7f usr/share/pcremote-server/connection/.svn/text-base/bluetoothconnectionmanager.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/connection/.svn/prop-base/__init__.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/connection/.svn/prop-base/iconnection.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/connection/.svn/prop-base/genericconnectionmanager.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/connection/.svn/prop-base/wirelessconnectionmanager.py.svn-base
-40c3baa616b5b755cc1cecd8a5f1b3ad usr/share/pcremote-server/connection/.svn/prop-base/bluetoothconnectionmanager.py.svn-base
-d1482494e6bb3303ce0429ffa850dc35 usr/share/pcremote-server/connection/bluetoothconnectionmanager.pyc
-159366919bc6213b7f6fae65dc603afa usr/share/pcremote-server/connection/genericconnectionmanager.py
-5a23a701cbe84644991072a94b636f35 usr/share/pcremote-server/connection/iconnection.py
-9a80f72334e101112f47fa9ec901112f usr/share/pcremote-server/connection/iconnection.pyc
-5bc7343620d48d1ecea605b8af19ec84 usr/share/pcremote-server/connection/genericconnectionmanager.pyc
-a5321f2c5c98bd3c8450df64a004583c usr/share/pcremote-server/connection/__init__.pyc
-518124236f6ddf6a0c67621853cd7229 usr/share/pcremote-server/connection/wirelessconnectionmanager.py
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-server/connection/__init__.py
-04c9700d63f069c392d0a0dc50a6f86a usr/share/pcremote-server/connection/wirelessconnectionmanager.pyc
-41b5d259ee21e96f37d46057de1286b9 usr/share/pcremote-server/connection/bluetoothconnectionmanager.py
-2e2252560040d89f8e5f2d1be0fa5fd0 usr/share/pcremote-server/images/28x.png
-bd14172f103bc22fd71d207f73288798 usr/share/pcremote-server/images/PCR_off.bmp
-78b30ee0922a6dea20e4994d55138f94 usr/share/pcremote-server/images/remote48x.png
-c2b65883ae6c4abe9f4c07ed14fe2a14 usr/share/pcremote-server/images/PCR_on.bmp
-2553d9134379e7199e7bb4c8995467f9 usr/share/pcremote-server/images/64x.png
-377847b28c4975963ce8219842ce8aea usr/share/pcremote-server/services/.svn/entries
-c30f7472766d25af1dc80b3ffc9a58c7 usr/share/pcremote-server/services/.svn/format
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-server/services/.svn/text-base/__init__.py.svn-base
-61fef10722e4d9d7faac93a03ac1ceb1 usr/share/pcremote-server/services/.svn/text-base/ObjectServers.py.svn-base
-5c25986a6c09a7313d8f5f51b509a5e6 usr/share/pcremote-server/services/.svn/text-base/ServerHandlers.py.svn-base
-10874c65035a891cb60e1ccb8b2bdb4f usr/share/pcremote-server/services/.svn/text-base/service.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/services/.svn/prop-base/__init__.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/services/.svn/prop-base/ObjectServers.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/services/.svn/prop-base/ServerHandlers.py.svn-base
-f2ea0bdf4310dae3aef66de358bcb0e1 usr/share/pcremote-server/services/.svn/prop-base/service.py.svn-base
-e3bc8888bb26adc2ae1080f7fcf17775 usr/share/pcremote-server/services/ObjectServers.pyc
-8ad0339242867f55475269131c4583fb usr/share/pcremote-server/services/ObjectServers.py
-d2fa096c8b7a13f49b951b095c56a488 usr/share/pcremote-server/services/service.py
-92eb3a43b65d8623450a4da25a3253c5 usr/share/pcremote-server/services/__init__.pyc
-e51233968b28ef0cc4432ac5f0551bc6 usr/share/pcremote-server/services/service.pyc
-e17b75b7195bde77678f182c9c3d6c75 usr/share/pcremote-server/services/ServerHandlers.pyc
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-server/services/__init__.py
-9f1fa958a013f07a15371fa87c86db61 usr/share/pcremote-server/services/ServerHandlers.py
-9c5bd8128615edd69f3305403d986d0b usr/share/pcremote-server/players/.svn/entries
-c30f7472766d25af1dc80b3ffc9a58c7 usr/share/pcremote-server/players/.svn/format
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-server/players/.svn/text-base/__init__.py.svn-base
-094e2893e7aec596fb90a6607a859c75 usr/share/pcremote-server/players/.svn/text-base/playlist.py.svn-base
-b34d77d5e136ac5cb2fb4c25d9de4d05 usr/share/pcremote-server/players/.svn/text-base/amarok.py.svn-base
-4160c74de5f4e580dc15660c798ff9fc usr/share/pcremote-server/players/.svn/prop-base/playlist.py.svn-base
-4160c74de5f4e580dc15660c798ff9fc usr/share/pcremote-server/players/.svn/prop-base/amarok.py.svn-base
-8b5f2d28c14e6692bba63297265922bb usr/share/pcremote-server/players/amarok.py
-54de8542cfadb0d06ed031f99708b188 usr/share/pcremote-server/players/plistparser.pyc
-f48363745edc09905b10e795e20e3b93 usr/share/pcremote-server/players/__init__.pyc
-a9c843b72e72ba346236f98a9f5e7e44 usr/share/pcremote-server/players/playlist.pyc
-a0b92dcdc153c3de2ba3b56cb2a2d9b2 usr/share/pcremote-server/players/amarok.pyc
-85eaeb39ee8b3d24aae6a12fcfe63bbf usr/share/pcremote-server/players/run-amarok.py
-606a6ee70138fd606222cd4c3162cc3f usr/share/pcremote-server/players/plistparser.py
-d41d8cd98f00b204e9800998ecf8427e usr/share/pcremote-server/players/__init__.py
-36827397437058edc107018640a1c2bc usr/share/pcremote-server/players/playlist.py
-9aa2031a03c14f89f570789b8abebaa8 usr/share/applications/pcremote-server.desktop
+++ /dev/null
-#!/bin/sh -e
-set -e
-
-if which update-icon-caches >/dev/null 2>&1 ; then
- update-icon-caches /usr/share/icons/hicolor
-fi
-
-#ln -s /usr/share/pcremote-server/pcremote-server.py /usr/bin/pcremote-server.py
-#chmod +x /usr/bin/pcremote-server.py
+++ /dev/null
-#!/bin/sh -e
-set -e
-
-if which update-icon-caches >/dev/null 2>&1 ; then
- update-icon-caches /usr/share/icons/hicolor
-fi
-
-# remove configuration
-
-# Delete the .desktop file in case the app-installer didn't.
-rm -f /usr/share/applications/pcremote-server.desktop
-
-# Delete the pcremoteclt directory in case the app-installer didn't
-rm -fr /usr/share/pcremote-server
-
-# Delete the symbolics links files in case the app-installer didn't.
-rm -f /usr/bin/pcremote-server
-
-# Delete the pcremote icon
-rm -f /usr/share/icons/hicolor/48x48/pcremote.png
-
-# Delete the pcremote menu
-rm -f /usr/share/menu/pcremote-server-menu
-
-exit 0
+++ /dev/null
-#!/bin/sh
-
-python /usr/share/pcremote-server/pcremote-server.py
+++ /dev/null
-[Desktop Entry]
-Encoding=UTF-8
-Version=0.50
-Type=Application
-Icon=/usr/share/hicolor/48x48/pcremote.png
-Name=PCRemote Server
-Exec=pcremote-server
-Terminal=false
-Categories=Application;Network;GTK;
-StartupNotify=true
+++ /dev/null
-pcremote-client for Debian
-----------------------
-
-<possible notes regarding this package - if none, delete this file>
-
- -- Jonatas Isvi <jonatas.nona@gmail.com> Mon, 30 Mar 2009 18:53:24 -0400
+++ /dev/null
-Copyright (c) 2009 Zagaia Lab (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 Server
- Author(s) <email>: Jonatas Isvi <jonatas.nona@gmail.com>, Andre Portela <andre_portela_@hotmail.com>,
- Nilson Silva <fergus.mao@gmail.com>
+++ /dev/null
-?package(pcremote-server): \
- needs="X11" \
- section:"Applications/Network" \
- title="PCRemote Server" \
- command="pcremote-server" \
- icon="/usr/share/icons/hicolor/48x48/pcremote.png"
+++ /dev/null
-8
-
-dir
-42
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn/remote_server/trunk/remote_server/src/connection
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn
-
-
-
-2008-11-24T19:21:45.815695Z
-31
-aportela
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-fe65f2a5-7a5f-4c8d-90e7-f011580d4f26
-\f
-iconnection.py
-file
-
-
-
-
-2008-11-24T19:10:09.000000Z
-5a23a701cbe84644991072a94b636f35
-2008-11-24T19:08:20.539642Z
-24
-aportela
-has-props
-\f
-wirelessconnectionmanager.py
-file
-
-
-
-
-2008-11-24T19:21:26.000000Z
-518124236f6ddf6a0c67621853cd7229
-2008-11-24T19:21:45.815695Z
-31
-aportela
-has-props
-\f
-__init__.py
-file
-
-
-
-
-2008-10-31T23:33:24.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2008-10-31T22:34:59.880000Z
-4
-aportela
-has-props
-\f
-bluetoothconnectionmanager.py
-file
-
-
-
-
-2008-11-24T19:09:16.000000Z
-67af5797d41770d8801ca335f011ea7f
-2008-11-24T19:09:43.908566Z
-25
-aportela
-has-props
-\f
-genericconnectionmanager.py
-file
-
-
-
-
-2008-11-24T19:11:06.000000Z
-159366919bc6213b7f6fae65dc603afa
-2008-11-24T19:11:23.207768Z
-26
-aportela
-has-props
-\f
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 14
-svn:executable
-V 1
-*
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : connection
-# Description : BluetoothConnectionManager
-# ============================================================================
-
-import bluetooth
-from exceptions import *
-from genericconnectionmanager import *
-
-class BluetoothConnectionManager(GenericConnectionManager):
-
- """ BluetoothConnectionManager
- manages objects and operations for bluetooth connection.
- Subclass of GerericConnectionManager.
- """
-
- def __init__(self):
- GenericConnectionManager.__init__(self)
- self.sock = None
- self.port = None
- self.address = None
- self.client_sock = None
- self.client_address = None
-
- # fast way to create a simple server
- def create_server(self, protocol, port):
- self.create_socket(protocol)
- self.set_port(port)
- self.bind()
- self.listen()
- self.accept()
-
- # fast way to create a simple client
- def create_client(self, protocol, address, port):
- self.create_socket(protocol)
- self.set_address(address)
- self.set_port(port)
- self.connect()
-
- # search for all devices
- def find_devices(self, time=8):
- list_devices = bluetooth.discover_devices(lookup_names = True, duration=time)
- if list_devices:
- return list_devices
- else:
- raise BluetoothConnectionError, "Device were not found."
-
- # search the device port
- def find_port(self, addr):
- port = None
- aux = addr.split(":")
- if len(aux) == 6:
- services = bluetooth.find_service(address=addr)
- for i in range(len(services)):
- port = services[i]['port']
-
- if port != None:
- return port
- else:
- raise BluetoothConnectionError, "Port not found."
-
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # search device services
- def find_services(self, service=None, addr=None):
- if service == None and addr == None:
- list = bluetooth.find_service()
- return list
- elif service != None and addr == None:
- list = bluetooth.find_service(name=service)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Name of the service does not exist."
- elif service == None and addr != None:
- number = addr.split(":")
- if(len(number) == 6):
- list = bluetooth.find_service(address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
- elif service != None and addr != None:
- number = addr.split(":")
- if(len(number) == 6):
- list = bluetooth.find_service(name=service, address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
-
-
- # search the device indicated by name
- def find_device_address_by_name(self, device_name):
- list = bluetooth.discover_devices()
- addr = None
-
- for address in list:
- if device_name == bluetooth.lookup_name(address):
- addr = address
- break
- if addr:
- return addr
- else:
- raise BluetoothConnectionError, "Device name not found."
-
- # search only device names
- def find_devices_only_names(self):
- list = self.find_devices()
- list_names = []
- for address, names in list:
- list_names += [names]
-
- if list_names:
- return list_names
- else:
- raise BluetoothConnectionError, "Devices were not found."
-
- # get the client address
- def get_client_address(self):
- return self.client_address
-
- # set the port to communicate
- def set_port(self, port):
- self.port = port
-
- # get the port to communicate
- def get_port(self):
- return self.port
-
- # set the device address
- def set_address(self, address):
- aux = address.split(":")
- if len(aux) == 6:
- self.address = address
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # get the device address
- def get_address(self):
- return self.address
-
- # create a socket with a determinated protocol
- def create_socket(self, protocol=None):
- if protocol == 'rfcomm' or protocol == 'RFCOMM':
- self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
- elif protocol == 'l2cap' or protocol == 'L2CAP':
- self.sock = bluetooth.BluetoothSocket(bluetooth.L2CAP)
- else:
- raise BluetoothConnectionError, "Undefined Protocol."
-
- # bind the communication
- def bind(self):
- self.sock.bind(("", self.get_port()))
-
- # just listen the tube, only to server
- def listen(self):
- self.sock.listen(1)
-
- # accept the client communication
- def accept(self):
- self.client_sock, self.client_address = self.sock.accept()
-
- # connect devices
- def connect(self):
- self.sock.connect((self.get_address(), self.get_port()))
-
- # send string message
- def send_message(self, msg=None):
- self.sock.send(msg)
-
- # receive string message
- def received_message(self):
- return self.client_sock.recv(1024)
-
- # close connection
- def close(self):
- if self.sock != None and self.client_sock != None:
- self.client_sock.close()
- self.sock.close()
- elif self.sock != None and self.client_sock == None:
- self.sock.close()
- else:
- self.client_sock.close()
-
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : connection
-# Description : GenericConnectionManager
-# ============================================================================
-
-
-class GenericConnectionManager:
-
- """ GenericConnectionManager
- Superclass of connections
- """
-
- def __init__(self):
- print "GenericConnectionManager iniciado."
- self.tipo = "generico"
-
- # current service running
- def identify_app(self):
- print "identify_app"
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : connection
-# Description : Iconnection Interface Class
-# ============================================================================
-
-from wirelessconnectionmanager import *
-from bluetoothconnectionmanager import *
-from exceptions import *
-
-# connections aliases
-_btconst = ['bluetooth', 'BLUETOOTH', 'blue']
-_wificonst = ['wireless', 'WIRELESS', 'wifi']
-
-class Iconnection:
-
- """ Iconnection
- Interface for wireless and bluetooth connections.
- Manages all commonalities operations between entities.
- """
- def __init__(self, string):
- self.string = string
- if(self.string in _btconst):
- self.obj = BluetoothConnectionManager()
- elif(self.string in _wificonst):
- self.obj = WirelessConnectionManager()
- else:
- raise IconnectionError, "Undefined type."
-
-
- # +---------------------------------------------+
- # | Generic methods -> Wireless and Bluetooth |
- # +---------------------------------------------+
-
- # create a socket with defined protocol
- def create_socket(self, protocol=None):
- self.obj.create_socket(protocol)
-
- # connect device
- def connect(self):
- self.obj.connect()
-
- # accept the connection
- def accept(self):
- return self.obj.accept()
-
- # send a message to device
- def send_message(self, msg=None):
- self.obj.send_message(msg)
-
- # received a message
- def received_message(self):
- return self.obj.received_message()
-
- # bind the connection
- def bind(self):
- self.obj.bind()
-
- # listen the connection
- def listen(self):
- self.obj.listen()
-
- # close connection
- def close(self):
- self.obj.close()
-
- # set the port to communicate
- def set_port(self, port):
- self.obj.set_port(port)
-
- # get the port to communicate
- def get_port(self):
- return self.obj.get_port()
-
- # set the device address
- def set_address(self, address):
- self.obj.set_address(address)
-
- # get the device address
- def get_address(self):
- return self.obj.get_address()
-
- # get the client address
- def get_client_address(self):
- return self.obj.get_client_address()
-
- # +------------------------------------------+
- # | Bluetooth: particular behaviors |
- # +------------------------------------------+
-
- # fast way to create a simple server
- def bluetooth_create_server(self, protocol, port):
- if self.string in _btconst:
- return self.obj.create_server(protocol, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # fast way to create a simple client
- def bluetooth_create_client(self, protocol, address, port):
- if self.string in _btconst:
- return self.obj.create_client(protocol, address, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search for all devices
- def bluetooth_find_devices(self, time=8):
- if self.string in _btconst:
- return self.obj.find_devices(time)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search only devices names
- def bluetooth_find_devices_only_names(self):
- if self.string in _btconst:
- return self.obj.find_devices_only_names()
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search the device port
- def bluetooth_find_port(self, addr):
- if self.string in _btconst:
- return self.obj.find_port(addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search device services
- def bluetooth_find_services(self, service=None, addr=None):
- if self.string in _btconst:
- return self.obj.find_services(service, addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
- # search the device indicated by name
- def bluetooth_find_device_address_by_name(self, device_name=None):
- if self.string in _btconst:
- return self.obj.find_device_address_by_name(device_name)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
-
- # +---------------------------------+
- # | Wireless: particular behaviors |
- # +---------------------------------+
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 0.1
-# Package : connection
-# Description : Wireless Connection Manager Class
-# ============================================================================
-
-from genericconnectionmanager import *
-
-class WirelessConnectionManager(GenericConnectionManager):
-
- """ WirelessConnectionManager
- Manages objects and operations for wireless connection.
- Subclass of GenericConnectionManager.
- """
-
- def __init__(self):
- GenericConnectionManager.__init__(self)
- self.tipo = "wireless"
-
-
-
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : connection
-# Description : BluetoothConnectionManager
-# ============================================================================
-
-import bluetooth
-from exceptions import *
-from genericconnectionmanager import *
-
-class BluetoothConnectionManager(GenericConnectionManager):
-
- """ BluetoothConnectionManager
-
- manages objects and operations for bluetooth connection.
- Subclass of GerericConnectionManager.
- """
-
- def __init__(self):
- GenericConnectionManager.__init__(self)
- self.sock = None
- self.port = None
- self.address = None
- self.client_sock = None
- self.client_address = None
-
- # fast way to create a simple server
- def create_server(self, protocol, port):
- self.create_socket(protocol)
- self.set_port(port)
- self.bind()
- self.listen()
- self.accept()
-
- # fast way to create a simple client
- def create_client(self, protocol, address, port):
- self.create_socket(protocol)
- self.set_address(address)
- self.set_port(port)
- self.connect()
-
- # search for all devices
- def find_devices(self, time=8):
- list_devices = bluetooth.discover_devices(lookup_names = True, duration=time)
- if list_devices:
- print list_devices
- return list_devices
- else:
- raise BluetoothConnectionError, "Device were not found."
-
- # search the device port
- def find_port(self, addr):
- port = None
- aux = addr.split(":")
- if len(aux) == 6:
- services = bluetooth.find_service(address=addr)
- for i in range(len(services)):
- port = services[i]['port']
-
- if port != None:
- return port
- else:
- raise BluetoothConnectionError, "Port not found."
-
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # search device services
- def find_services(self, service=None, addr=None):
- if service == None and addr == None:
- list = bluetooth.find_service()
- return list
- elif service != None and addr == None:
- list = bluetooth.find_service(name=service)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Name of the service does not exist."
- elif service == None and addr != None:
- number = addr.split(":")
- if(len(number) == 6):
- list = bluetooth.find_service(address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
- elif service != None and addr != None:
- number = addr.split(":")
- if(len(number) == 6):
- list = bluetooth.find_service(name=service, address=addr)
- if list != []:
- return list
- else:
- raise BluetoothConnectionError, "Services not found."
- else:
- raise BluetoothConnectionError, "Invalid address."
-
-
- # search the device indicated by name
- def find_device_address_by_name(self, device_name):
- list = bluetooth.discover_devices()
- addr = None
-
- for address in list:
- if device_name == bluetooth.lookup_name(address):
- addr = address
- break
- if addr:
- return addr
- else:
- raise BluetoothConnectionError, "Device name not found."
-
- # search only device names
- def find_devices_only_names(self):
- list = self.find_devices()
- list_names = []
- for address, names in list:
- list_names += [names]
-
- if list_names:
- return list_names
- else:
- raise BluetoothConnectionError, "Devices were not found."
-
- # get the client address
- def get_client_address(self):
- return self.client_address
-
- # set the port to communicate
- def set_port(self, port):
- self.port = port
-
- # get the port to communicate
- def get_port(self):
- return self.port
-
- # set the device address
- def set_address(self, address):
- aux = address.split(":")
- if len(aux) == 6:
- self.address = address
- else:
- raise BluetoothConnectionError, "Invalid address."
-
- # get the device address
- def get_address(self):
- return self.address
-
- # create a socket with a determinated protocol
- def create_socket(self, protocol=None):
- if protocol == 'rfcomm' or protocol == 'RFCOMM':
- self.sock = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
- elif protocol == 'l2cap' or protocol == 'L2CAP':
- self.sock = bluetooth.BluetoothSocket(bluetooth.L2CAP)
- else:
- raise BluetoothConnectionError, "Undefined Protocol."
-
- # bind the communication
- def bind(self):
- self.sock.bind(("", self.get_port()))
-
- # just listen the tube, only to server
- def listen(self):
- self.sock.listen(1)
-
- # accept the client communication
- def accept(self):
- self.client_sock, self.client_address = self.sock.accept()
-
- # connect devices
- def connect(self):
- self.sock.connect((self.get_address(), self.get_port()))
-
- # send string message
- def send_message(self, msg=None):
- self.sock.send(msg)
-
- # receive string message
- def received_message(self):
- return self.client_sock.recv(1024)
-
- # close connection
- def close(self):
- if self.sock != None and self.client_sock != None:
- self.client_sock.close()
- self.sock.close()
- elif self.sock != None and self.client_sock == None:
- self.sock.close()
- else:
- self.client_sock.close()
-
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : connection
-# Description : GenericConnectionManager
-# ============================================================================
-
-
-class GenericConnectionManager:
-
- """ GenericConnectionManager
- Superclass of connections
- """
-
- def __init__(self):
- print "GenericConnectionManager iniciado."
- self.tipo = "generico"
-
- # current service running
- def identify_app(self):
- print "identify_app"
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : connection
-# Description : Iconnection Interface Class
-# ============================================================================
-
-from wirelessconnectionmanager import *
-from bluetoothconnectionmanager import *
-from exceptions import *
-
-# connections aliases
-_btconst = ['bluetooth', 'BLUETOOTH', 'blue']
-_wificonst = ['wireless', 'WIRELESS', 'wifi']
-
-class Iconnection:
-
- """ Iconnection
- Interface for wireless and bluetooth connections.
- Manages all commonalities operations between entities.
- """
- def __init__(self, string):
- self.string = string
- if(self.string in _btconst):
- self.obj = BluetoothConnectionManager()
- elif(self.string in _wificonst):
- self.obj = WirelessConnectionManager()
- else:
- raise IconnectionError, "Undefined type."
-
-
- # +---------------------------------------------+
- # | Generic methods -> Wireless and Bluetooth |
- # +---------------------------------------------+
-
- # create a socket with defined protocol
- def create_socket(self, protocol=None):
- self.obj.create_socket(protocol)
-
- # connect device
- def connect(self):
- self.obj.connect()
-
- # accept the connection
- def accept(self):
- return self.obj.accept()
-
- # send a message to device
- def send_message(self, msg=None):
- self.obj.send_message(msg)
-
- # received a message
- def received_message(self):
- return self.obj.received_message()
-
- # bind the connection
- def bind(self):
- self.obj.bind()
-
- # listen the connection
- def listen(self):
- self.obj.listen()
-
- # close connection
- def close(self):
- self.obj.close()
-
- # set the port to communicate
- def set_port(self, port):
- self.obj.set_port(port)
-
- # get the port to communicate
- def get_port(self):
- return self.obj.get_port()
-
- # set the device address
- def set_address(self, address):
- self.obj.set_address(address)
-
- # get the device address
- def get_address(self):
- return self.obj.get_address()
-
- # get the client address
- def get_client_address(self):
- return self.obj.get_client_address()
-
- # +------------------------------------------+
- # | Bluetooth: particular behaviors |
- # +------------------------------------------+
-
- # fast way to create a simple server
- def bluetooth_create_server(self, protocol, port):
- if self.string in _btconst:
- return self.obj.create_server(protocol, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # fast way to create a simple client
- def bluetooth_create_client(self, protocol, address, port):
- if self.string in _btconst:
- return self.obj.create_client(protocol, address, port)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search for all devices
- def bluetooth_find_devices(self, time=8):
- if self.string in _btconst:
- return self.obj.find_devices(time)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search only devices names
- def bluetooth_find_devices_only_names(self):
- if self.string in _btconst:
- return self.obj.find_devices_only_names()
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search the device port
- def bluetooth_find_port(self, addr):
- if self.string in _btconst:
- return self.obj.find_port(addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
- # search device services
- def bluetooth_find_services(self, service=None, addr=None):
- if self.string in _btconst:
- return self.obj.find_services(service, addr)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
- # search the device indicated by name
- def bluetooth_find_device_address_by_name(self, device_name=None):
- if self.string in _btconst:
- return self.obj.find_device_address_by_name(device_name)
- else:
- raise IconnectionError, "Only method used by Bluetooth connections."
-
-
-
- # +---------------------------------+
- # | Wireless: particular behaviors |
- # +---------------------------------+
+++ /dev/null
-# -*- 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 : André Portela
-# Email : andre_portela_@hotmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 0.1
-# Package : connection
-# Description : Wireless Connection Manager Class
-# ============================================================================
-
-from genericconnectionmanager import *
-
-class WirelessConnectionManager(GenericConnectionManager):
-
- """ WirelessConnectionManager
- Manages objects and operations for wireless connection.
- Subclass of GenericConnectionManager.
- """
-
- def __init__(self):
- GenericConnectionManager.__init__(self)
- self.tipo = "wireless"
-
-
-
+++ /dev/null
-8
-
-dir
-42
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn/remote_server/trunk/remote_server/src/exceptions
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn
-
-
-
-2008-11-24T19:15:49.820782Z
-27
-aportela
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-fe65f2a5-7a5f-4c8d-90e7-f011580d4f26
-\f
-exception.py
-file
-
-
-
-
-2008-11-24T19:15:30.000000Z
-41e514c3297ce38f7bd5d4f687fcaa9b
-2008-11-24T19:15:49.820782Z
-27
-aportela
-has-props
-\f
-__init__.py
-file
-
-
-
-
-2008-10-31T23:33:24.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2008-10-31T22:34:59.880000Z
-4
-aportela
-has-props
-\f
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# package : exceptions
-# Description : Exceptions
-# ============================================================================
-
-class BluetoothConnectionError(Exception):
- ''' Treatment of errors bluetooth connections '''
- pass
-
-class WirelessConnectionError(Exception):
- ''' Treatment of errors wireless connections '''
- pass
-
-class IconnectionError(Exception):
- ''' Treatment of errors Iconnection class '''
- pass
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# package : exceptions
-# Description : Exceptions
-# ============================================================================
-
-class BluetoothConnectionError(Exception):
- ''' Treatment of errors bluetooth connections '''
- pass
-
-class WirelessConnectionError(Exception):
- ''' Treatment of errors wireless connections '''
- pass
-
-class IconnectionError(Exception):
- ''' Treatment of errors Iconnection class '''
- pass
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-#!/usr/bin/env python
-
-from runserver import Server
-import gtk
-import thread
-import sys
-
-class Service:
-
- def start_server(self, widget):
-
- if self.connected == False:
- imagepath = self.images.replace('pcremote-server.py','images/PCR_on.bmp')
- self.staticon.set_from_file(imagepath)
- self.staticon.set_tooltip("PC Remote Server - Online")
-
- img = gtk.Image()
- img.set_from_stock(gtk.STOCK_DISCONNECT, gtk.ICON_SIZE_MENU)
- self.menuItemCon.set_image(img)
-
- self.srv = Server("PC Remote")
- thread.start_new_thread(Server.start,(self.srv,"server"))
-
- else:
- imagepath = self.images.replace('pcremote-server.py','images/PCR_off.bmp')
- self.staticon.set_from_file(imagepath)
- self.staticon.set_tooltip("PC Remote Server - Offline")
-
- img = gtk.Image()
- img.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU)
-
- self.menuItemCon.set_image(img)
-
- thread.exit_thread()
-
- self.connected = not self.connected
-
- def destroyer(self, widget,response_id, data= None):
- if response_id == gtk.RESPONSE_OK:
- gtk.main_quit()
- else:
- widget.hide()
-
- def popup(self, widget):
- dialog = gtk.MessageDialog(
- parent = None,
- flags = gtk.DIALOG_DESTROY_WITH_PARENT,
- type = gtk.MESSAGE_INFO,
- buttons = gtk.BUTTONS_OK_CANCEL,
- message_format = "Do you want to shut the server down?")
- dialog.set_title('PC Remote Server')
- dialog.connect('response', self.destroyer)
- dialog.show()
-
- def popup_menu_cb(self, widget, button, time, data = None):
- if button == 3:
- if data:
- data.show_all()
- data.popup(None, None, None, 3, time)
-
-
- def __init__(self):
-
- self.images = sys.argv[0]
- self.connected = False
-
- self.staticon = gtk.StatusIcon()
- imagepath = self.images.replace('pcremote-server.py','images/PCR_off.bmp')
- self.staticon.set_from_file(imagepath)
- self.staticon.set_tooltip("PC Remote Server(offline)")
-
- self.menu = gtk.Menu()
-
- self.menuItemCon = gtk.ImageMenuItem(gtk.STOCK_EXECUTE)
- self.menuItemCon.connect('activate', self.start_server)
-
- self.menuItemExit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
- self.menuItemExit.connect('activate', self.popup)
-
- self.menu.append(self.menuItemCon)
- self.menu.append(self.menuItemExit)
-
- self.staticon.connect('popup-menu', self.popup_menu_cb, self.menu)
-
- self.staticon.set_visible(True)
-
- gtk.gdk.threads_init()
- gtk.gdk.threads_enter()
-
- gtk.main()
-
- gtk.gdk.threads_leave()
-
-print sys.argv
-Srv = Service()
-
+++ /dev/null
-8
-
-dir
-42
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn/remote_server/trunk/remote_server/src/players
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn
-
-
-
-2008-11-24T22:19:59.926000Z
-42
-aportela
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-fe65f2a5-7a5f-4c8d-90e7-f011580d4f26
-\f
-amarok.py
-file
-
-
-
-
-2008-11-24T19:22:32.000000Z
-b34d77d5e136ac5cb2fb4c25d9de4d05
-2008-11-24T19:22:46.499502Z
-32
-aportela
-has-props
-\f
-__init__.py
-file
-
-
-
-
-2008-11-21T20:05:30.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2008-11-21T20:06:45.989300Z
-12
-aportela
-\f
-playlist.py
-file
-
-
-
-
-2008-11-24T19:23:01.000000Z
-094e2893e7aec596fb90a6607a859c75
-2008-11-24T19:23:20.208723Z
-33
-aportela
-has-props
-\f
+++ /dev/null
-K 14
-svn:executable
-V 1
-*
-END
+++ /dev/null
-K 14
-svn:executable
-V 1
-*
-END
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Packge : players
-# Description : Amarok Player
-# ============================================================================
-
-import os
-import commands
-import random
-from playlist import Playlist
-import pydcop
-
-# command line
-def shell(command):
- return commands.getoutput(command)
-
-# starts the amarok player application
-def start():
- os.popen('amarok')
-
-# close the amarok player application
-def shutdown():
- shell('dcop amarok player stop')
- pid = shell('pidof amarokapp')
- shell('kill -9 %s' % pid)
-
-# verifies if the amarok is running
-def isRunning():
- pid = shell('pidof amarokapp')
- if pid > 0:
- return True
- else:
- return False
-
-class AmarokPlayer():
-
- """ Amarok
- Define all states and functions of amarok player.
- This class will build to support PCRemote Player,
- receiving messages from any devices with a bluetooth
- connection.
- """
-
- # some importants variables
- def __init__(self):
- self.amarok = pydcop.anyAppCalled("amarok")
- self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist())
- self.isPlaying()
-
- # refresh playlist, accessing the Playlist class instance
- def refresh_playlist(self):
- self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist())
- self.isPlaying()
-
- # get all songs of playlist
- def song_list(self):
- self.playlist.show()
-
- # show current song, acessing the Playlist class instance
- def current_song(self):
- self.isPlaying()
-
- # verifies if this amarok app is running
- def isRunning(self):
- aux = pydcop.anyAppCalled("amarok")
- if aux:
- return aux
- else:
- return None
-
- # verifies if this amarok app is playing and update the
- # Playlist with current song
- def isPlaying(self):
- if not self.amarok.player.isPlaying() == 'true':
- self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
- return True
- else:
- return False
-
- # get the players name
- def getName(self):
- return "Amarok"
-
- # send audio files to the N810 device
- def audio_file_properties(self, index=None):
- audiofile = (self.playlist.song_filename(index),\
- self.playlist.song_size(index))
- return audiofile
-
- # next button and sets current song
- def next(self):
- self.amarok.player.next()
- self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # prev button and sets current song
- def prev(self):
- self.amarok.player.prev()
- self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # play button and sets current song
- def play(self):
- self.amarok.player.play()
- self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # play button with index song and sets current song
- def play_track(self, index):
- self.amarok.playlist.playByIndex(index-1)
- self.playlist.update(index, \
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(),\
- )
-
- # random play songs
- def play_random(self):
- index = random.randint(0, self.playlist.length() - 1)
- self.amarok.playlist.playByIndex(index)
- self.playlist.update(index+1, \
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(),\
- )
-
- # pause button
- def pause(self):
- self.amarok.player.pause()
-
- # mute button
- def mute(self):
- self.amarok.player.mute()
-
- # stop button
- def stop(self):
- self.amarok.player.stop()
-
- # get the current volume value
- def get_volume(self):
- return self.amarok.player.getVolume()
-
- # set up volume
- def volume_up(self, increase=1):
- if (self.get_volume() + increase) <= 100:
- up = self.get_volume() + increase
- self.amarok.player.setVolume(up)
- else:
- print "erro!"
-
- # set down volume
- def volume_down(self, decrement=1):
- if (self.get_volume() - decrement) >= 0:
- down = self.get_volume() - decrement
- self.amarok.player.setVolume(down)
- else:
- print "erro!"
-
- # set seek value
- def seek(self, value):
- self.amarok.player.seek(value)
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : players
-# Description : Playlist
-# ============================================================================
-
-import plistparser
-import pydcop
-
-class Playlist():
-
- """ Playlist
- make the interpreter and manipulation
- of the player playlist, creates a composite
- with any player class.
- """
-
- # some importants variables
- # analyze if file is a playlist
- def __init__(self, file):
- if self.isPlaylist(file):
- self.file = file
- self.songs = self.load()
- self.currentSong = 0
- self.fix()
- else:
- raise("Argument is not a playlist file")
-
- # analyzes the file
- def isPlaylist(self, file):
- if not file:
- return False
- else:
- return True
-
- # make a list of dicts songs
- def load(self):
- self.songs = plistparser._request(self.file)
- return self.songs
-
- # get the length of the current playlist
- def length(self):
- return len(self.songs)
-
- # update the current song in songs list and return a song dict
- def update(self, track, title, artist, path, ext):
- self.currentSong = track
- if self.songs[self.currentSong - 1]['title'] == 'Unknown Title':
- self.songs[self.currentSong - 1]['title'] = title
- if self.songs[self.currentSong - 1]['artist'] == 'Unknown Artist':
- self.songs[self.currentSong - 1]['artist'] = artist
- self.songs[self.currentSong - 1]['path'] = path
- self.songs[self.currentSong - 1]['extension'] = ext
- print self.songs[self.currentSong - 1]
-
-
- # show the current song
- def show_playing_now(self):
- return ('TITLE: %s' % self.songs[self.currentSong - 1]['title'], \
- 'ARTIST: %s' % self.songs[self.currentSong - 1]['artist'],\
- 'TRACK: %s' % self.songs[self.currentSong - 1]['track']
- )
-
- # get the current song filename if index is None
- def song_filename(self, index=None):
- if index == None:
- return self.songs[self.currentSong-1]['title'] +" - "+\
- self.songs[self.currentSong-1]['artist'] + \
- self.songs[self.currentSong-1]['extension']
-
- else:
- return self.songs[index-1]['title'] +" - "+\
- self.songs[index-1]['artist'] + \
- self.songs[index-1]['extension']
-
- # get thr current song filesize if index is None
- def song_size(self, index=None):
- if index == None:
- return int(self.songs[self.currentSong-1]['filesize'])
- else:
- return int(self.songs[index-1]['filesize'])
-
- # show all songs of the playlist
- def show(self):
- for i in range(self.length()):
- print self.songs[i]['track'], " - ", \
- self.songs[i]['title'], " | ", \
- self.songs[i]['artist'], \
- "\n"
-
- # fix some problems of musics tags
- def fix(self):
- for i in range(self.length()):
- if self.songs[i]['title'] == None:
- self.songs[i]['title'] = 'Unknown Title'
- elif self.songs[i]['artist'] == None:
- self.songs[i]['artist'] = 'Unknown Artist'
-
-
- # get the porperties of any song of ther playlist
- def song_properties(self, index=None, track=False, title=False,\
- artist=False, ext=False, filesize=False, \
- duration=False, path=False):
- props = {}
- if index == None:
- if track:
- props['track'] = self.songs[self.currentSong-1]['track']
- if title:
- props['title'] = self.songs[self.currentSong-1]['title']
- if artist:
- props['artist'] = self.songs[self.currentSong-1]['artist']
- if ext:
- props['ext'] = self.songs[self.currentSong-1]['extension']
- if filesize:
- props['filesize'] = self.songs[self.currentSong-1]['filesize']
- if duration:
- props['duration'] = self.songs[self.currentSong-1]['duration']
- if path:
- props['path'] = self.songs[self.currentSong-1]['path']
-
- return props
- else:
- if track:
- props['track'] = self.songs[index-1]['track']
- if title:
- props['title'] = self.songs[index-1]['title']
- if artist:
- props['artist'] = self.songs[index-1]['artist']
- if ext:
- props['ext'] = self.songs[index-1]['extension']
- if filesize:
- props['filesize'] = self.songs[index-1]['filesize']
- if duration:
- props['duration'] = self.songs[index-1]['duration']
- if path:
- props['path'] = self.songs[index-1]['path']
-
- return props
-
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Packge : players
-# Description : Amarok Player
-# ============================================================================
-
-import os
-import commands
-import random
-from playlist import Playlist
-import pydcop
-
-# command line
-def shell(command):
- return commands.getoutput(command)
-
-
-# starts the amarok player application
-def start():
- os.popen('amarok')
-
-
-# close the amarok player application
-def shutdown():
- shell('dcop amarok player stop')
- pid = shell('pidof amarokapp')
- shell('kill -9 %s' % pid)
-
-
-# verifies if the amarok is running
-def isRunning():
- pid = shell('pidof amarokapp')
- if pid > 0:
- return True
- else:
- return False
-
-def send_file(addr, path):
- shell("bluetooth-sendto --dest=%s %s" + (addr, path))
-
-class AmarokPlayer():
-
- """ Amarok
- Define all states and functions of amarok player.
- This class will build to support PCRemote Player,
- receiving messages from any devices with a bluetooth
- connection.
- """
-
- # some importants variables
- def __init__(self):
- self.amarok = pydcop.anyAppCalled("amarok")
- self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist())
- self.isPlaying()
-
- # refresh playlist, accessing the Playlist class instance
- def refresh_playlist(self):
- self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist())
- self.isPlaying()
-
- # get all songs of playlist
- def song_list(self):
- self.playlist.show()
-
- # show current song, acessing the Playlist class instance
- def current_song(self):
- self.isPlaying()
-
- # verifies if this amarok app is running
- def isRunning(self):
- aux = pydcop.anyAppCalled("amarok")
- if aux:
- return aux
- else:
- return None
-
- # verifies if this amarok app is playing and update the
- # Playlist with current song
- def isPlaying(self):
- if not self.amarok.player.isPlaying() == 'true':
- self.playlist.update(self.amarok.playlist.getActiveIndex(),\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
- return True
- else:
- return False
-
- # get the players name
- def getName(self):
- return "Amarok"
-
- # send audio files to the N810 device
- def file_properties(self, index=None):
- track = self.amarok.playlist.getActiveIndex()
- audiofile = self.playlist.song_properties(index=track, path=True)
- #audiofile = (self.playlist.song_filename(index),\
- # self.playlist.song_size(index))
- return audiofile
-
- # next button and sets current song
- def next(self):
- self.amarok.player.next()
- self.playlist.update(self.amarok.playlist.getActiveIndex(),\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # prev button and sets current song
- def prev(self):
- self.amarok.player.prev()
- self.playlist.update(self.amarok.playlist.getActiveIndex(),\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # play button and sets current song
- #def play(self):
- #self.amarok.player.play()
- #self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- # self.amarok.player.title(), \
- # self.amarok.player.artist(), \
- # self.amarok.player.path(), \
- # "." + self.amarok.player.type(), \
- # )
-
- # play button and sets current song
- # receive track or random form
- # the argument track has intended to manipulate
- # the playlist form when the user indicate a song track
- # in client application
- def play(self, track=-1, rdm=False):
- if rdm:
- index = random.randint(0, self.playlist.length() - 1)
- self.amarok.playlist.playByIndex(index)
- self.playlist.update(index + 1, \
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(),\
- )
- elif track != -1:
- self.amarok.playlist.playByIndex(track)
- self.playlist.update(track-1, \
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(),\
- )
- else:
- self.amarok.player.play()
- self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # play button with index song and sets current song
- #def play_track(self, index):
- # self.amarok.playlist.playByIndex(index-1)
- # self.playlist.update(index, \
- # self.amarok.player.title(), \
- # self.amarok.player.artist(), \
- # self.amarok.player.path(), \
- # "." + self.amarok.player.type(),\
- # )
-
- # random play songs
- #def play_random(self):
- # index = random.randint(0, self.playlist.length() - 1)
- # self.amarok.playlist.playByIndex(index)
- # self.playlist.update(index+1, \
- # self.amarok.player.title(), \
- # self.amarok.player.artist(), \
- # self.amarok.player.path(), \
- # "." + self.amarok.player.type(),\
- # )
-
- # pause button
- def pause(self):
- self.amarok.player.pause()
-
- # mute button
- def mute(self):
- self.amarok.player.mute()
-
- # stop button
- def stop(self):
- self.amarok.player.stop()
-
- # get the current volume value
- def get_volume(self):
- return self.amarok.player.getVolume()
-
- # set up volume
- def volume_up(self, increase=1):
- if (self.get_volume() + increase) <= 100:
- up = self.get_volume() + increase
- self.amarok.player.setVolume(up)
- else:
- print "erro!"
-
- # set down volume
- def volume_down(self, decrement=1):
- if (self.get_volume() - decrement) >= 0:
- down = self.get_volume() - decrement
- self.amarok.player.setVolume(down)
- else:
- print "erro!"
-
- # set seek value
- def seek(self, value):
- self.amarok.player.seek(value)
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : players
-# Description : Playlist
-# ============================================================================
-
-import plistparser
-import pydcop
-
-class Playlist():
-
- """ Playlist
- make the interpreter and manipulation
- of the player playlist, creates a composite
- with any player class.
- """
-
- # some importants variables
- # analyze if file is a playlist
- def __init__(self, file):
- if self.isPlaylist(file):
- self.file = file
- self.songs = self.load()
- self.currentSong = 0
- self.fix()
- else:
- raise("Argument is not a playlist file")
-
- # analyzes the file
- def isPlaylist(self, file):
- if not file:
- return False
- else:
- return True
-
- # make a list of dicts songs
- def load(self):
- self.songs = plistparser._request(self.file)
- return self.songs
-
- # get the length of the current playlist
- def length(self):
- return len(self.songs)
-
- # update the current song in songs list and return a song dict
- def update(self, track, title, artist, path, ext):
- self.currentSong = track
- if self.songs[self.currentSong]['title'] == 'Unknown Title':
- self.songs[self.currentSong]['title'] = title
- if self.songs[self.currentSong]['artist'] == 'Unknown Artist':
- self.songs[self.currentSong]['artist'] = artist
- self.songs[self.currentSong]['path'] = path
- self.songs[self.currentSong]['extension'] = ext
- print self.songs[self.currentSong]
-
-
- # show the current song
- def show_playing_now(self):
- return ('TITLE: %s' % self.songs[self.currentSong]['title'], \
- 'ARTIST: %s' % self.songs[self.currentSong]['artist'],\
- 'TRACK: %s' % self.songs[self.currentSong]['track']
- )
-
- # get the current song filename if index is None
- def song_filename(self, index=None):
- if index == None:
- return self.songs[self.currentSong]['title'] +" - "+\
- self.songs[self.currentSong]['artist'] + \
- self.songs[self.currentSong]['extension']
-
- else:
- return self.songs[index]['title'] +" - "+\
- self.songs[index]['artist'] + \
- self.songs[index]['extension']
-
- # get thr current song filesize if index is None
- def song_size(self, index=None):
- if index == None:
- return int(self.songs[self.currentSong]['filesize'])
- else:
- return int(self.songs[index]['filesize'])
-
- # show all songs of the playlist
- def show(self):
- for i in range(self.length()):
- print self.songs[i]['track'], " - ", \
- self.songs[i]['title'], " | ", \
- self.songs[i]['artist'], \
- "\n"
-
- # fix some problems of musics tags
- def fix(self):
- for i in range(self.length()):
- if self.songs[i]['title'] == None:
- self.songs[i]['title'] = 'Unknown Title'
- elif self.songs[i]['artist'] == None:
- self.songs[i]['artist'] = 'Unknown Artist'
-
-
- # get the porperties of any song of ther playlist
- def song_properties(self, index=None, track=False, title=False,\
- artist=False, ext=False, filesize=False, \
- duration=False, path=False):
- props = {}
- if index == None:
- if track:
- props['track'] = self.songs[self.currentSong]['track']
- if title:
- props['title'] = self.songs[self.currentSong]['title']
- if artist:
- props['artist'] = self.songs[self.currentSong]['artist']
- if ext:
- props['ext'] = self.songs[self.currentSong]['extension']
- if filesize:
- props['filesize'] = self.songs[self.currentSong]['filesize']
- if duration:
- props['duration'] = self.songs[self.currentSong]['duration']
- if path:
- props['path'] = self.songs[self.currentSong]['path']
-
- return props
- else:
- if track:
- props['track'] = self.songs[index]['track']
- if title:
- props['title'] = self.songs[index]['title']
- if artist:
- props['artist'] = self.songs[index]['artist']
- if ext:
- props['ext'] = self.songs[index]['extension']
- if filesize:
- props['filesize'] = self.songs[index]['filesize']
- if duration:
- props['duration'] = self.songs[index]['duration']
- if path:
- props['path'] = self.songs[index]['path']
-
- return props
-
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : utils
-# Description : plisparser
-# ============================================================================
-
-from xml.etree import cElementTree as ElementTree
-
-# get the file
-def _request(url):
- xml = url
- return parse_playlist_file(xml)
-
-# parser the file
-def parse_playlist_file(xml):
- tree = ElementTree.parse(xml)
- listsongs = []
- dictsongs = {}
- count = duration = filesize = 0
- title = artist = path = ''
-
- for child in tree.getiterator():
- if child.tag == 'Title':
- title = child.text
- elif child.tag == 'Artist':
- artist = child.text
- elif child.tag == 'Length':
- duration = child.text
- elif child.tag == 'Filesize':
- filesize = child.text
- count = count + 1
- dictsongs = {'track' : count,
- 'title' : title,
- 'artist' : artist,
- 'duration' : duration,
- 'filesize' : filesize,
- 'path' : None,
- 'extension' : None,
- }
- listsongs.append(dictsongs)
-
- return listsongs
-
-
-
-
-
-
-
-
+++ /dev/null
-import amarok
-
-if not amarok.isRunning():
- player = amarok.AmarokPlayer()
-else:
- print "entrou aqui"
- amarok.start()
- player = amarok.AmarokPlayer()
-
-while(1):
- data = raw_input(">>> ")
- if data == '#exit' or data == '#quit' or data == '#close':
- print "Application closed."
- amarok.shutdown()
- break
- elif data == 'next':
- player.next()
- elif data == 'prev':
- player.prev()
- elif data == 'play':
- player.play()
- elif data == 'pause':
- player.pause()
- elif data == 'stop':
- player.stop()
- elif data == 'mute':
- player.mute()
- elif data == 'volume-up':
- player.volume_up()
- elif data == 'volume-down':
- player.volume_down()
- elif data == 'current_song':
- print player.current_song()
- elif data == 'random':
- player.play_random()
- elif data == 'play-track':
- index = input('track: ')
- player.play_track(index)
- elif data == 'refresh':
- player.refresh_playlist()
- elif data == 'show':
- player.song_list()
-
+++ /dev/null
-#!/usr/bin/env python
-# -*- 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 ; Jonatas Izvi; Andre Portela
-# Email : fergus.mao@gmail.com ; nona@gmail.com ;
-# andre_portela_@hotmail.com;
-# Version : 1.0
-# Class : Server File - This is the main script of the server
-# ============================================================================
-
-from connection.iconnection import *
-from services.service import *
-from utils import *
-from utils.messages import *
-
-class Server():
-
- def __init__(self, AppName):
- self.msgbox = Message(AppName)
- self.msgbox.show_message("Server Initialized...")
-
- def start(self, servername):
-
- label = Labels()
- iconn = Iconnection('blue')
- iconn.bluetooth_create_server('l2cap', 0x1001)
-
- address = iconn.get_client_address()
-
- self.msgbox.show_message("Accepted connection from " + address[0])
-
- while (1):
-
- data = iconn.received_message()
-
- if data == 'Tablet:#start':
-
- self.msgbox.show_message('Service Tablet initialized...')
-
- service = Service()
- service.set_service('Tablet')
-
- while(1):
- data = iconn.received_message()
- if data == 'Tablet:#stop':
- service.clean_all()
- self.msgbox.show_message('Service Tablet stoped')
- break
- service.execute(data)
-
- elif data == 'Slideshow:#start':
-
- self.msgbox.show_message('Service Slideshow initialized...')
-
- service = Service()
- service.set_service('Slideshow')
-
- while(1):
- data = iconn.received_message()
- if data == 'Slideshow:#stop':
- service.clean_all()
- self.msgbox.show_message('Service Slideshow stoped')
- break
- print data, "\n"
- service.execute(data)
-
- elif data == 'Player:#start':
-
- self.msgbox.show_message('Service Player initialized...')
-
- service = Service()
- service.set_service('Player')
-
- while(1):
- data = iconn.received_message()
- if data == 'Player:#stop':
- self.msgbox.show_message('Service Player stoped')
- break
- elif data == 'Player:#download':
- service.set_address_to_download(address[0])
- elif data == 'Player:#load_playlist':
- # e preciso criar um metodo de transferencia
- # no caso de carregar uma playlist para o cliente
- service.execute_transfer(data)
-
- service.execute(data)
-
- else:
- exit(1)
-
- self.msgbox.show_message('Desconected from ' + address[0])
+++ /dev/null
-8
-
-dir
-42
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn/remote_server/trunk/remote_server/src/services
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn
-
-
-
-2008-11-24T21:43:13.543262Z
-39
-aportela
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-fe65f2a5-7a5f-4c8d-90e7-f011580d4f26
-\f
-__init__.py
-file
-
-
-
-
-2008-10-31T23:33:24.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2008-10-31T22:34:59.880000Z
-4
-aportela
-has-props
-\f
-ObjectServers.py
-file
-
-
-
-
-2008-11-24T21:42:50.000000Z
-61fef10722e4d9d7faac93a03ac1ceb1
-2008-11-24T21:43:13.543262Z
-39
-aportela
-has-props
-\f
-service.py
-file
-
-
-
-
-2008-11-24T21:41:33.000000Z
-10874c65035a891cb60e1ccb8b2bdb4f
-2008-11-24T21:41:51.237514Z
-37
-aportela
-has-props
-\f
-ServerHandlers.py
-file
-
-
-
-
-2008-11-24T21:42:13.000000Z
-5c25986a6c09a7313d8f5f51b509a5e6
-2008-11-24T21:42:30.576563Z
-38
-aportela
-has-props
-\f
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-# -*- 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 *
-
-class Mouse_Server:
-
- """ Mouse Server
- Defines all mouse behaviors.
- Clicks and coordinates.
- """
-
- #Initialize the class
- def __init__(self):
-
- 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
- self.mouse.position(i, j)
-
- self.x = int(coord[0])
- self.y = int(coord[1])
-
- def clean_up_mouse(self):
- self.mouse.clean_up_mouse()
-
-class KeyBoard_Server:
-
- """ Keyboard Server
- Defines all keyboard behaviors.
- Map keys and events.
- """
-
- def __init__(self):
- self.keyboard = Keyboard()
- self.shift_flag = False
- self.control_flag = False
- self.keys = []
-
- # 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(command == 'ISO_Level3_Shift'):
- self.keyboard.reproduce_key_press('Escape')
- self.keyboard.reproduce_key_release('Escape')
- pass
- 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 == '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')
- 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
-
- # clean all keys pressed
- def clean_up_keyboard(self):
- print "\nkeys -> ", self.keys
- list = self.keys
- print "\nlist ->", list
- for i in list:
- self.keyboard.reproduce_key_release(i)
- self.keys.remove(i)
- print "\nkey --> ", i, " removed."
-
- print self.keys
+++ /dev/null
-# -*- 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
-# Email : fergus.mao@gmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : service
-# Description : Singleton, Mouse and Keyboard
-# ============================================================================
-
-import Xlib
-from Xlib import display, X, XK
-
-class Singleton_Xlib():
-
- """ Singleton
- defines a singleton.
- """
- def __init__(self):
- self.display = display.Display()
- self.screen = self.display.screen()
-
-xlib_srv = Singleton_Xlib()
-
-class Mouse(object):
-
- """ Mouse
- pass mouse information to Xorg
- """
-
- #Initialize the class
- def __init__(self):
- self.disp = xlib_srv.display
- self.screen = xlib_srv.screen
- self.fator = 10
- self.lbutton = False
- self.mbutton = False
- self.rbutton = False
- self.buttons = []
-
- #Set the mouse pointer position
- def position(self,x=None,y=None):
-
- if (x == None):
- x = self.fator
-
- if (y == None):
- y = self.fator
-
- #Get the current mouse pointer position
- current_x = self.screen.root.query_pointer()._data["root_x"]
- current_y = self.screen.root.query_pointer()._data["root_y"]
-
- def absolute(ax = None, ay = None):
- if (ax == None):
- ax = x
- if (ay == None):
- ay = y
-
- self.screen.root.warp_pointer(ax, ay)
- self.disp.sync()
-
- def relative():
- rX = current_x + x
- rY = current_y + y
- absolute(rX,rY)
-
- relative()
-
- #Returns the current X position
- def get_x(self):
- return self.screen.root.query_pointer()._data["root_x"]
-
- #Returns the current Y position
- def get_y(self):
- return self.screen.root.query_pointer()._data["root_y"]
-
- #Defines the factor(px) of the mouse pointer move
- def set_fator(self,fator):
- self.fator = fator
-
- #Returns the factor
- def get_fator(self):
- return self.fator
-
- #Mouse Left Click
- def left_click(self, fg_lbutton = None):
-
- if (fg_lbutton != None):
- self.lbutton = not fg_lbutton
-
- if not self.lbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 1, 0)
- self.buttons.append('left_button')
- self.lbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 1, 5)
- self.buttons.remove('left_button')
- self.lbutton = False
-
- self.disp.flush()
-
- #Mouse Middle Click
- def middle_click(self):
- if not self.mbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 2, 0)
- self.buttons.append('middle_button')
- self.mbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 2, 5)
- self.buttons.remove('middle_button')
- self.mbutton = False
-
- self.disp.flush()
-
- #Mouse Right Click
- def right_click(self, fg_rbutton = None):
-
- if (fg_rbutton != None):
- self.rbutton = not fg_rbutton
-
- if not self.rbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 3, 0)
- self.buttons.append('right_button')
- self.rbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
- self.buttons.remove('right_button')
- self.rbutton = False
-
- self.disp.flush()
-
- def clean_up_mouse(self):
- list = self.buttons
- print list
- for i in list:
- if i == 'left_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 1, 5)
- self.disp.xtest_fake_input(X.ButtonPress, 3, 5)
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
- self.buttons.remove(i)
- print "\nleft_button -> release."
- elif i == 'middle_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 2, 5)
- self.buttons.remove(i)
- print "\nmiddle_button -> release."
- elif i == 'right_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
- self.buttons.remove(i)
- print "\nright_button -> release."
-
- print self.buttons
-
-class Keyboard():
-
- """ Keyboard
- pass keyboard information to Xorg
- """
-
- def __init__(self):
- self.display = xlib_srv.display
- self.screen = xlib_srv.screen
-
- # encode key
- def __key_to_code(self,key):
- new_key = getattr(XK, "XK_" + key)
- code = self.display.keysym_to_keycode(new_key)
- return code
-
- # reproduce key pressed
- def reproduce_key_press(self, key):
- Xlib.ext.xtest.fake_input(self.display, Xlib.X.KeyPress, self.__key_to_code(key))
- self.display.sync()
-
- # reproduce key release
- def reproduce_key_release(self, key):
- Xlib.ext.xtest.fake_input(self.display, Xlib.X.KeyRelease, self.__key_to_code(key))
- self.display.sync()
-
+++ /dev/null
-# -*- 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
-# Email : fergus.mao@gmail.com, jonatas.nona@gmail.com
-# Reviewer : Jônatas Isvi
-# Email :
-# Version : 1.0
-# Package : Main Application
-# Description : Service Application
-# ============================================================================
-
-from ObjectServers import *
-
-class Service:
-
- """ Service
- supports all services applications
- """
-
- def __init__(self):
- self.mouse_srv = None
- self.keyboard_srv = None
- self.service = ""
-
- #Set the Service requested by the Service Manager
- def set_service(self, command):
-
- self.service = command
-
- if self.service == 'Tablet':
- self.mouse_srv = Mouse_Server()
- self.keyboard_srv = KeyBoard_Server()
- elif self.service == 'Slideshow':
- self.mouse_srv = Mouse_Server()
- self.keyboard_srv = KeyBoard_Server()
- elif self.service == 'Player':
- print "player service."
- elif self.service == 'Torrent':
- print "torrent service."
-
- #Returns the Service which is being executed
- def get_service(self):
- return self.service
-
- #Executes the action requested by the Service Manager
- def execute(self, command):
-
- cmd = command.split(":")
-
- if cmd[0] == "Mouse":
- self.mouse_srv.execute(cmd[1])
- elif cmd[0] == "Keyboard":
- self.keyboard_srv.execute(cmd[1])
-
- # clean all button and keys pressed
- def clean_all(self):
- self.mouse_srv.clean_up_mouse()
- self.keyboard_srv.clean_up_keyboard()
+++ /dev/null
-# -*- 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._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 == 'ISO_Level3_Shift'):
- self.keyboard.reproduce_key_press('Escape')
- self.keyboard.reproduce_key_release('Escape')
- pass
- 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 == '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')
- 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
-
- # 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
+++ /dev/null
-# -*- 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
-# Email : fergus.mao@gmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : service
-# Description : Singleton, Mouse and Keyboard
-# ============================================================================
-
-import Xlib
-from Xlib import display, X, XK
-
-class Singleton_Xlib():
-
- """ Singleton
- defines a singleton.
- """
- def __init__(self):
- self.display = display.Display()
- self.screen = self.display.screen()
-
-xlib_srv = Singleton_Xlib()
-
-class Mouse(object):
-
- """ Mouse
- pass mouse information to Xorg
- """
-
- #Initialize the class
- def __init__(self):
- self.disp = xlib_srv.display
- self.screen = xlib_srv.screen
- self.fator = 10
- self.lbutton = False
- self.mbutton = False
- self.rbutton = False
- self.buttons = []
-
- #Set the mouse pointer position
- def position(self,x=None,y=None):
-
- if (x == None):
- x = self.fator
-
- if (y == None):
- y = self.fator
-
- #Get the current mouse pointer position
- current_x = self.screen.root.query_pointer()._data["root_x"]
- current_y = self.screen.root.query_pointer()._data["root_y"]
-
- def absolute(ax = None, ay = None):
- if (ax == None):
- ax = x
- if (ay == None):
- ay = y
-
- self.screen.root.warp_pointer(ax, ay)
- self.disp.sync()
-
- def relative():
- rX = current_x + x
- rY = current_y + y
- absolute(rX,rY)
-
- relative()
-
- #Returns the current X position
- def get_x(self):
- return self.screen.root.query_pointer()._data["root_x"]
-
- #Returns the current Y position
- def get_y(self):
- return self.screen.root.query_pointer()._data["root_y"]
-
- #Defines the factor(px) of the mouse pointer move
- def set_fator(self,fator):
- self.fator = fator
-
- #Returns the factor
- def get_fator(self):
- return self.fator
-
- #Mouse Left Click
- def left_click(self, fg_lbutton = None):
-
- if (fg_lbutton != None):
- self.lbutton = not fg_lbutton
-
- if not self.lbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 1, 0)
- self.buttons.append('left_button')
- self.lbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 1, 5)
- self.buttons.remove('left_button')
- self.lbutton = False
-
- self.disp.flush()
-
- #Mouse Middle Click
- def middle_click(self):
- if not self.mbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 2, 0)
- self.buttons.append('middle_button')
- self.mbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 2, 5)
- self.buttons.remove('middle_button')
- self.mbutton = False
-
- self.disp.flush()
-
- #Mouse Right Click
- def right_click(self, fg_rbutton = None):
-
- if (fg_rbutton != None):
- self.rbutton = not fg_rbutton
-
- if not self.rbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 3, 0)
- self.buttons.append('right_button')
- self.rbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
- self.buttons.remove('right_button')
- self.rbutton = False
-
- self.disp.flush()
-
- def clean_up(self):
- if self.buttons:
- while self.buttons:
- button = self.buttons.pop()
- if button == 'left_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 1, 5)
- self.disp.xtest_fake_input(X.ButtonPress, 3, 5)
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
- elif button == 'middle_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 2, 5)
- elif button == 'right_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
-
- print self.buttons
-
-class Keyboard():
-
- """ Keyboard
- pass keyboard information to Xorg
- """
-
- def __init__(self):
- self.display = xlib_srv.display
- self.screen = xlib_srv.screen
- self.keys = []
-
- # encode key
- def __key_to_code(self,key):
- new_key = getattr(XK, "XK_" + key)
- code = self.display.keysym_to_keycode(new_key)
- return code
-
- # reproduce key pressed
- def reproduce_key_press(self, key):
- Xlib.ext.xtest.fake_input(self.display, Xlib.X.KeyPress, self.__key_to_code(key))
- self.display.sync()
- self.keys.append(key)
-
- # reproduce key release
- def reproduce_key_release(self, key):
- Xlib.ext.xtest.fake_input(self.display, Xlib.X.KeyRelease, self.__key_to_code(key))
- self.display.sync()
- self.keys.remove(key)
-
- # clean all pressed keys
- def clean_up(self):
- if self.keys:
- while self.keys:
- key = self.keys.pop()
- self.reproduce_key_release(key)
-
+++ /dev/null
-# -*- 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
-# Email : fergus.mao@gmail.com, jonatas.nona@gmail.com
-# Reviewer : Jônatas Isvi
-# Email :
-# Version : 1.0
-# Package : Main Application
-# Description : Service Application
-# ============================================================================
-
-from ObjectServers import *
-
-class Service:
-
- """ Service
- supports all services applications
- """
-
- def __init__(self):
- self.mouse_srv = None
- self.keyboard_srv = None
- self.player = None
- self.service = ""
- self.addr = None
-
- #Set the Service requested by the Service Manager
- def set_service(self, command):
-
- self.service = command
-
- if self.service == 'Tablet':
- self.mouse_srv = Mouse_Server(self.service)
- self.keyboard_srv = KeyBoard_Server(self.service)
- elif self.service == 'Slideshow':
- self.mouse_srv = Mouse_Server(self.service)
- self.keyboard_srv = KeyBoard_Server(self.service)
- elif self.service == 'Player':
- self.player_srv = Player_Server()
- elif self.service == 'Torrent':
- print "torrent service."
-
- #Returns the Service which is being executed
- def get_service(self):
- return self.service
-
- #Executes the action requested by the Service Manager
- def execute(self, command):
-
- cmd = command.split(":")
-
- if cmd[0] == "Mouse":
- self.mouse_srv.execute(cmd[1])
- elif cmd[0] == "Keyboard":
- self.keyboard_srv.execute(cmd[1])
- elif cmd[0] == "Player":
- if self.addr:
- cmd += self.addr
- self.player_srv.execute(cmd)
- else:
- self.player_srv.execute(cmd)
-
- def set_address_to_download(self, addr):
- self.addr = addr
-
- # clean all button and keys pressed
- def clean_all(self):
- self.mouse_srv.clean_up()
- self.keyboard_srv.clean_up()
-
-#teste unitario
-if __name__ == '__main__':
- import utils.plistparser
+++ /dev/null
-8
-
-dir
-42
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn/remote_server/trunk/remote_server/src/utils
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn
-
-
-
-2008-11-24T22:06:21.176771Z
-40
-aportela
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-fe65f2a5-7a5f-4c8d-90e7-f011580d4f26
-\f
-plistparser.py
-file
-
-
-
-
-2008-11-24T21:52:13.000000Z
-606a6ee70138fd606222cd4c3162cc3f
-2008-11-24T22:06:21.176771Z
-40
-aportela
-has-props
-\f
-__init__.py
-file
-
-
-
-
-2008-10-31T23:33:24.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2008-10-31T22:34:59.880000Z
-4
-aportela
-has-props
-\f
-labels.py
-file
-
-
-
-
-2008-11-03T19:55:46.000000Z
-6c9741bd79bbd0f1ac82d2d98614032d
-2008-11-03T20:22:42.774109Z
-5
-aportela
-has-props
-\f
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 14
-svn:executable
-V 1
-*
-END
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Description : Labels
-# ============================================================================
-
-class Labels():
-
- def __init__(self):
- pass
-
- # GENERIC LABELS FOR MULTIMEDIA APPLICATIONS
-
- PLAY = "#play"
- STOP = "#stop"
- PAUSE = "#pause"
- NEXT = "#next"
- PREVIOUS = "#previous"
- VOL_UP = "#vol_up"
- VOL_DOWN = "#vol_down"
- TLINE_LEFT = "#tline_left"
- TLINE_RIGHT = "#tline_right"
- RECORD = "#record"
- #------------------------------------------>
-
- # GENERIC LABELS FOR APPLICATIONS
-
- START = "#start"
- CLOSE = "#close"
- FULL = "#fullscreen"
- UPLOAD = "#upload"
- DOWNLOAD = "#download"
- SAVE = "#save"
- DELETE = "#delete"
- #-------------------------------->
-
- # GENERAL MOUSE LABELS
-
- CLICK = "#click"
- DOUBLE_CLICK = "#double_click"
- TRIPLE_CLICK = "#triple_click"
- LEFT_CLICK = "#left_click"
- RIGHT_CLICK = "#right_click"
- MIDDLE_CLICK = "#middle_click"
- #-------------------------------->
-
-
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : utils
-# Description : plisparser
-# ============================================================================
-
-from xml.etree import cElementTree as ElementTree
-
-# get the file
-def _request(url):
- xml = url
- return parse_playlist_file(xml)
-
-# parser the file
-def parse_playlist_file(xml):
- tree = ElementTree.parse(xml)
- listsongs = []
- dictsongs = {}
- count = duration = filesize = 0
- title = artist = path = ''
-
- for child in tree.getiterator():
- if child.tag == 'Title':
- title = child.text
- elif child.tag == 'Artist':
- artist = child.text
- elif child.tag == 'Length':
- duration = child.text
- elif child.tag == 'Filesize':
- filesize = child.text
- count = count + 1
- dictsongs = {'track' : count,
- 'title' : title,
- 'artist' : artist,
- 'duration' : duration,
- 'filesize' : filesize,
- 'path' : None,
- 'extension' : None,
- }
- listsongs.append(dictsongs)
-
- return listsongs
-
-
-
-
-
-
-
-
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Description : Labels
-# ============================================================================
-
-class Labels():
-
- def __init__(self):
- pass
-
- # SERVICES SUPPORTED
- TABLET = "Tablet"
- SLIDESHOW = "Slideshow"
- PLAYER = "Player"
- TORRENT = "Torrent"
-
- # GENERIC LABELS FOR MULTIMEDIA APPLICATIONS
-
- PLAY = "#play"
- STOP = "#stop"
- PAUSE = "#pause"
- NEXT = "#next"
- PREVIOUS = "#previous"
- VOL_UP = "#vol_up"
- VOL_DOWN = "#vol_down"
- TLINE_LEFT = "#tline_left"
- TLINE_RIGHT = "#tline_right"
- RECORD = "#record"
- SEEK = "#seek"
- LOAD_PLAYLIST = "#load_playlist"
- PLAYLIST = "#playlist"
- #------------------------------------------>
-
- # GENERIC LABELS FOR APPLICATIONS
-
- START = "#start"
- CLOSE = "#close"
- FULL_SRC = "#fullscreen"
- UPLOAD = "#upload"
- DOWNLOAD = "#download"
- SAVE = "#save"
- DELETE = "#delete"
- #-------------------------------->
-
- # GENERAL MOUSE LABELS
-
- CLICK = "#click"
- DOUBLE_CLICK = "#double_click"
- TRIPLE_CLICK = "#triple_click"
- LEFT_CLICK = "#left_click"
- RIGHT_CLICK = "#right_click"
- MIDDLE_CLICK = "#middle_click"
- #-------------------------------->
-
-
+++ /dev/null
-import pynotify
-import Image
-import StringIO
-import gtk
-
-class Message():
- def __init__(self, AppName):
- pynotify.init(AppName)
- self.AppName = AppName
- self.msgbox = pynotify.Notification(self.AppName, self.AppName, "PCR_on.bmp")
- self.msgbox.set_urgency(pynotify.URGENCY_CRITICAL)
- self.msgbox.set_timeout(5000)
-
- def show_message(self, message):
- self.msgbox = pynotify.Notification(self.AppName, message)
- self.msgbox.show()
-
- def set_image(self, img):
-# image = Image.open(img)
-# image = gtk.gdk.pixbuf_new_from_file(img)
-# self.msgbox.set_icon_from_pixbuf(self.image2pixbuf(image))
- pass
-
- def image2pixbuf(self, img):
- file1 = StringIO.StringIO()
-
- img.save(file1, "ppm")
- contents = file1.getvalue()
- file1.close()
-
- loader = gtk.gdk.PixbufLoader("pnm")
- loader.write(contents, len(contents))
-
- pixbuf = loader.get_pixbuf()
- loader.close()
-
- return pixbuf
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : utils
-# Description : plisparser
-# ============================================================================
-
-from xml.etree import cElementTree as ElementTree
-
-# get the file
-def _request(url):
- xml = url
- return parse_playlist_file(xml)
-
-# parser the file
-def parse_playlist_file(xml):
- tree = ElementTree.parse(xml)
- listsongs = []
- dictsongs = {}
- count = duration = filesize = 0
- title = artist = path = ''
-
- for child in tree.getiterator():
- if child.tag == 'Title':
- title = child.text
- elif child.tag == 'Artist':
- artist = child.text
- elif child.tag == 'Length':
- duration = child.text
- elif child.tag == 'Filesize':
- filesize = child.text
- count = count + 1
- dictsongs = {'track' : count,
- 'title' : title,
- 'artist' : artist,
- 'duration' : duration,
- 'filesize' : filesize,
- 'path' : None,
- 'extension' : None,
- }
- listsongs.append(dictsongs)
-
- return listsongs
-
-
-
-
-
-
-
-
+++ /dev/null
-#!/bin/sh -e
-set -e
-
-if which update-icon-caches >/dev/null 2>&1 ; then
- update-icon-caches /usr/share/icons/hicolor
-fi
-
+++ /dev/null
-#!/bin/sh -e
-set -e
-
-if which update-icon-caches >/dev/null 2>&1 ; then
- update-icon-caches /usr/share/icons/hicolor
-fi
-
-# remove configuration
-
-# Delete the .desktop file in case the app-installer didn't.
-rm -f /usr/share/applications/pcremote-server.desktop
-
-# Delete the pcremoteclt directory in case the app-installer didn't
-rm -fr /usr/share/pcremote-server
-
-# Delete the symbolics links files in case the app-installer didn't.
-rm -f /usr/bin/pcremote-server
-
-# Delete the pcremote icon
-rm -f /usr/share/icons/hicolor/48x48/pcremote.png
-
-# Delete the pcremote menu
-rm -f /usr/share/menu/pcremote-server-menu
-
-exit 0
+++ /dev/null
-#!/usr/bin/make -f
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # Add here commands to configure the package.
-
- touch configure-stamp
-
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
-
- # Add here commands to compile the package.
- ##$(MAKE)
- #docbook-to-man debian/pcremote-server.sgml > pcremote-server.1
-
- touch build-stamp
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
- dh_clean
-
- # Add here commands to clean up after the build process.
- -$(MAKE) clean
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
- dh_installmenu
- dh_icons
- # Add here commands to install the package into debian/pcremote-server.
- #$(MAKE) install DESTDIR=$(CURDIR)/debian/pcremote-server
- mkdir -p $(CURDIR)/debian/pcremote-server
-
- ###insert your commands here
- cp *.py $(CURDIR)/debian/pcremote-server/usr/share/pcremote-server
- cp -r exceptions/ $(CURDIR)/debian/pcremote-server/usr/share/pcremote-server
- cp -r images/ $(CURDIR)/debian/pcremote-server/usr/share/pcremote-server
- cp -r services/ $(CURDIR)/debian/pcremote-server/usr/share/pcremote-server
- cp -r players/ $(CURDIR)/debian/pcremote-server/usr/share/pcremote-server
- cp -r connection/ $(CURDIR)/debian/pcremote-server/usr/share/pcremote-server
- cp -r utils/ $(CURDIR)/debian/pcremote-server/usr/share/pcremote-server
-
- ### Installing menufile
- # copy the file with the menu entry into /usr/share/applications
- cp pcremote-server.desktop $(CURDIR)/debian/pcremote-server/usr/share/applications
- cp pcremote.png $(CURDIR)/debian/pcremote-server/usr/share/icons
- cp pcremote-server-menu $(CURDIR)/debian/pcremote-server/usr/share/menu
- cp pcremote-server $(CURDIR)/debian/pcremote-server/usr/bin
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
- dh_installchangelogs
- dh_installdocs
- dh_installexamples
-# dh_install
- dh_installmenu
-# dh_installdebconf
-# dh_installlogrotate
-# dh_installemacsen
-# dh_installpam
-# dh_installmime
-# dh_python
-# dh_installinit
-# dh_installcron
-# dh_installinfo
- dh_installman
- dh_link
- dh_strip
- dh_compress
- dh_fixperms
-# dh_perl
-# dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
+++ /dev/null
-8
-
-dir
-42
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn/remote_server/trunk/remote_server/src/exceptions
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn
-
-
-
-2008-11-24T19:15:49.820782Z
-27
-aportela
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-fe65f2a5-7a5f-4c8d-90e7-f011580d4f26
-\f
-exception.py
-file
-
-
-
-
-2008-11-24T19:15:30.000000Z
-41e514c3297ce38f7bd5d4f687fcaa9b
-2008-11-24T19:15:49.820782Z
-27
-aportela
-has-props
-\f
-__init__.py
-file
-
-
-
-
-2008-10-31T23:33:24.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2008-10-31T22:34:59.880000Z
-4
-aportela
-has-props
-\f
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# package : exceptions
-# Description : Exceptions
-# ============================================================================
-
-class BluetoothConnectionError(Exception):
- ''' Treatment of errors bluetooth connections '''
- pass
-
-class WirelessConnectionError(Exception):
- ''' Treatment of errors wireless connections '''
- pass
-
-class IconnectionError(Exception):
- ''' Treatment of errors Iconnection class '''
- pass
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# package : exceptions
-# Description : Exceptions
-# ============================================================================
-
-class BluetoothConnectionError(Exception):
- ''' Treatment of errors bluetooth connections '''
- pass
-
-class WirelessConnectionError(Exception):
- ''' Treatment of errors wireless connections '''
- pass
-
-class IconnectionError(Exception):
- ''' Treatment of errors Iconnection class '''
- pass
-
-
-
-
-
-
-
-
-
-
-
-
-
+++ /dev/null
-#!/bin/sh
-
-python /usr/share/pcremote-server/pcremote-server.py
+++ /dev/null
-?package(pcremote-server): \
- needs="X11" \
- section:"Applications/Network" \
- title="PCRemote Server" \
- command="pcremote-server" \
- icon="/usr/share/icons/hicolor/48x48/pcremote.png"
+++ /dev/null
-[Desktop Entry]
-Encoding=UTF-8
-Version=0.60
-Type=Application
-Icon=/usr/share/hicolor/48x48/pcremote.png
-Name=PCRemote Server
-Exec=pcremote-server
-Terminal=false
-Categories=Application;Network;GTK;
-StartupNotify=true
+++ /dev/null
-#!/usr/bin/env python
-
-from runserver import Server
-import gtk
-import thread
-import sys
-
-class Service:
-
- def start_server(self, widget):
-
- if self.connected == False:
- imagepath = self.images.replace('pcremote-server.py','images/PCR_on.bmp')
- self.staticon.set_from_file(imagepath)
- self.staticon.set_tooltip("PC Remote Server - Online")
-
- img = gtk.Image()
- img.set_from_stock(gtk.STOCK_DISCONNECT, gtk.ICON_SIZE_MENU)
- self.menuItemCon.set_image(img)
-
- self.srv = Server("PC Remote")
- thread.start_new_thread(Server.start,(self.srv,"server"))
-
- else:
- imagepath = self.images.replace('pcremote-server.py','images/PCR_off.bmp')
- self.staticon.set_from_file(imagepath)
- self.staticon.set_tooltip("PC Remote Server - Offline")
-
- img = gtk.Image()
- img.set_from_stock(gtk.STOCK_EXECUTE, gtk.ICON_SIZE_MENU)
-
- self.menuItemCon.set_image(img)
-
- thread.exit_thread()
-
- self.connected = not self.connected
-
- def destroyer(self, widget,response_id, data= None):
- if response_id == gtk.RESPONSE_OK:
- gtk.main_quit()
- else:
- widget.hide()
-
- def popup(self, widget):
- dialog = gtk.MessageDialog(
- parent = None,
- flags = gtk.DIALOG_DESTROY_WITH_PARENT,
- type = gtk.MESSAGE_INFO,
- buttons = gtk.BUTTONS_OK_CANCEL,
- message_format = "Do you want to shut down the server?")
- dialog.set_title('PC Remote Server')
- dialog.connect('response', self.destroyer)
- dialog.show()
-
- def popup_menu_cb(self, widget, button, time, data = None):
- if button == 3:
- if data:
- data.show_all()
- data.popup(None, None, None, 3, time)
-
-
- def __init__(self):
-
- self.images = sys.argv[0]
- self.connected = False
-
- self.staticon = gtk.StatusIcon()
- imagepath = self.images.replace('pcremote-server.py','images/PCR_off.bmp')
- self.staticon.set_from_file(imagepath)
- self.staticon.set_tooltip("PC Remote Server(offline)")
-
- self.menu = gtk.Menu()
-
- self.menuItemCon = gtk.ImageMenuItem(gtk.STOCK_EXECUTE)
- self.menuItemCon.connect('activate', self.start_server)
-
- self.menuItemExit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
- self.menuItemExit.connect('activate', self.popup)
-
- self.menu.append(self.menuItemCon)
- self.menu.append(self.menuItemExit)
-
- self.staticon.connect('popup-menu', self.popup_menu_cb, self.menu)
-
- self.staticon.set_visible(True)
-
- gtk.gdk.threads_init()
- gtk.gdk.threads_enter()
-
- gtk.main()
-
- gtk.gdk.threads_leave()
-
-print sys.argv
-Srv = Service()
+++ /dev/null
-8
-
-dir
-42
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn/remote_server/trunk/remote_server/src/players
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn
-
-
-
-2008-11-24T22:19:59.926000Z
-42
-aportela
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-fe65f2a5-7a5f-4c8d-90e7-f011580d4f26
-\f
-amarok.py
-file
-
-
-
-
-2008-11-24T19:22:32.000000Z
-b34d77d5e136ac5cb2fb4c25d9de4d05
-2008-11-24T19:22:46.499502Z
-32
-aportela
-has-props
-\f
-__init__.py
-file
-
-
-
-
-2008-11-21T20:05:30.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2008-11-21T20:06:45.989300Z
-12
-aportela
-\f
-playlist.py
-file
-
-
-
-
-2008-11-24T19:23:01.000000Z
-094e2893e7aec596fb90a6607a859c75
-2008-11-24T19:23:20.208723Z
-33
-aportela
-has-props
-\f
+++ /dev/null
-K 14
-svn:executable
-V 1
-*
-END
+++ /dev/null
-K 14
-svn:executable
-V 1
-*
-END
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Packge : players
-# Description : Amarok Player
-# ============================================================================
-
-import os
-import commands
-import random
-from playlist import Playlist
-import pydcop
-
-# command line
-def shell(command):
- return commands.getoutput(command)
-
-# starts the amarok player application
-def start():
- os.popen('amarok')
-
-# close the amarok player application
-def shutdown():
- shell('dcop amarok player stop')
- pid = shell('pidof amarokapp')
- shell('kill -9 %s' % pid)
-
-# verifies if the amarok is running
-def isRunning():
- pid = shell('pidof amarokapp')
- if pid > 0:
- return True
- else:
- return False
-
-class AmarokPlayer():
-
- """ Amarok
- Define all states and functions of amarok player.
- This class will build to support PCRemote Player,
- receiving messages from any devices with a bluetooth
- connection.
- """
-
- # some importants variables
- def __init__(self):
- self.amarok = pydcop.anyAppCalled("amarok")
- self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist())
- self.isPlaying()
-
- # refresh playlist, accessing the Playlist class instance
- def refresh_playlist(self):
- self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist())
- self.isPlaying()
-
- # get all songs of playlist
- def song_list(self):
- self.playlist.show()
-
- # show current song, acessing the Playlist class instance
- def current_song(self):
- self.isPlaying()
-
- # verifies if this amarok app is running
- def isRunning(self):
- aux = pydcop.anyAppCalled("amarok")
- if aux:
- return aux
- else:
- return None
-
- # verifies if this amarok app is playing and update the
- # Playlist with current song
- def isPlaying(self):
- if not self.amarok.player.isPlaying() == 'true':
- self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
- return True
- else:
- return False
-
- # get the players name
- def getName(self):
- return "Amarok"
-
- # send audio files to the N810 device
- def audio_file_properties(self, index=None):
- audiofile = (self.playlist.song_filename(index),\
- self.playlist.song_size(index))
- return audiofile
-
- # next button and sets current song
- def next(self):
- self.amarok.player.next()
- self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # prev button and sets current song
- def prev(self):
- self.amarok.player.prev()
- self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # play button and sets current song
- def play(self):
- self.amarok.player.play()
- self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # play button with index song and sets current song
- def play_track(self, index):
- self.amarok.playlist.playByIndex(index-1)
- self.playlist.update(index, \
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(),\
- )
-
- # random play songs
- def play_random(self):
- index = random.randint(0, self.playlist.length() - 1)
- self.amarok.playlist.playByIndex(index)
- self.playlist.update(index+1, \
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(),\
- )
-
- # pause button
- def pause(self):
- self.amarok.player.pause()
-
- # mute button
- def mute(self):
- self.amarok.player.mute()
-
- # stop button
- def stop(self):
- self.amarok.player.stop()
-
- # get the current volume value
- def get_volume(self):
- return self.amarok.player.getVolume()
-
- # set up volume
- def volume_up(self, increase=1):
- if (self.get_volume() + increase) <= 100:
- up = self.get_volume() + increase
- self.amarok.player.setVolume(up)
- else:
- print "erro!"
-
- # set down volume
- def volume_down(self, decrement=1):
- if (self.get_volume() - decrement) >= 0:
- down = self.get_volume() - decrement
- self.amarok.player.setVolume(down)
- else:
- print "erro!"
-
- # set seek value
- def seek(self, value):
- self.amarok.player.seek(value)
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : players
-# Description : Playlist
-# ============================================================================
-
-import plistparser
-import pydcop
-
-class Playlist():
-
- """ Playlist
- make the interpreter and manipulation
- of the player playlist, creates a composite
- with any player class.
- """
-
- # some importants variables
- # analyze if file is a playlist
- def __init__(self, file):
- if self.isPlaylist(file):
- self.file = file
- self.songs = self.load()
- self.currentSong = 0
- self.fix()
- else:
- raise("Argument is not a playlist file")
-
- # analyzes the file
- def isPlaylist(self, file):
- if not file:
- return False
- else:
- return True
-
- # make a list of dicts songs
- def load(self):
- self.songs = plistparser._request(self.file)
- return self.songs
-
- # get the length of the current playlist
- def length(self):
- return len(self.songs)
-
- # update the current song in songs list and return a song dict
- def update(self, track, title, artist, path, ext):
- self.currentSong = track
- if self.songs[self.currentSong - 1]['title'] == 'Unknown Title':
- self.songs[self.currentSong - 1]['title'] = title
- if self.songs[self.currentSong - 1]['artist'] == 'Unknown Artist':
- self.songs[self.currentSong - 1]['artist'] = artist
- self.songs[self.currentSong - 1]['path'] = path
- self.songs[self.currentSong - 1]['extension'] = ext
- print self.songs[self.currentSong - 1]
-
-
- # show the current song
- def show_playing_now(self):
- return ('TITLE: %s' % self.songs[self.currentSong - 1]['title'], \
- 'ARTIST: %s' % self.songs[self.currentSong - 1]['artist'],\
- 'TRACK: %s' % self.songs[self.currentSong - 1]['track']
- )
-
- # get the current song filename if index is None
- def song_filename(self, index=None):
- if index == None:
- return self.songs[self.currentSong-1]['title'] +" - "+\
- self.songs[self.currentSong-1]['artist'] + \
- self.songs[self.currentSong-1]['extension']
-
- else:
- return self.songs[index-1]['title'] +" - "+\
- self.songs[index-1]['artist'] + \
- self.songs[index-1]['extension']
-
- # get thr current song filesize if index is None
- def song_size(self, index=None):
- if index == None:
- return int(self.songs[self.currentSong-1]['filesize'])
- else:
- return int(self.songs[index-1]['filesize'])
-
- # show all songs of the playlist
- def show(self):
- for i in range(self.length()):
- print self.songs[i]['track'], " - ", \
- self.songs[i]['title'], " | ", \
- self.songs[i]['artist'], \
- "\n"
-
- # fix some problems of musics tags
- def fix(self):
- for i in range(self.length()):
- if self.songs[i]['title'] == None:
- self.songs[i]['title'] = 'Unknown Title'
- elif self.songs[i]['artist'] == None:
- self.songs[i]['artist'] = 'Unknown Artist'
-
-
- # get the porperties of any song of ther playlist
- def song_properties(self, index=None, track=False, title=False,\
- artist=False, ext=False, filesize=False, \
- duration=False, path=False):
- props = {}
- if index == None:
- if track:
- props['track'] = self.songs[self.currentSong-1]['track']
- if title:
- props['title'] = self.songs[self.currentSong-1]['title']
- if artist:
- props['artist'] = self.songs[self.currentSong-1]['artist']
- if ext:
- props['ext'] = self.songs[self.currentSong-1]['extension']
- if filesize:
- props['filesize'] = self.songs[self.currentSong-1]['filesize']
- if duration:
- props['duration'] = self.songs[self.currentSong-1]['duration']
- if path:
- props['path'] = self.songs[self.currentSong-1]['path']
-
- return props
- else:
- if track:
- props['track'] = self.songs[index-1]['track']
- if title:
- props['title'] = self.songs[index-1]['title']
- if artist:
- props['artist'] = self.songs[index-1]['artist']
- if ext:
- props['ext'] = self.songs[index-1]['extension']
- if filesize:
- props['filesize'] = self.songs[index-1]['filesize']
- if duration:
- props['duration'] = self.songs[index-1]['duration']
- if path:
- props['path'] = self.songs[index-1]['path']
-
- return props
-
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Packge : players
-# Description : Amarok Player
-# ============================================================================
-
-import os
-import commands
-import random
-from playlist import Playlist
-import pydcop
-
-# command line
-def shell(command):
- return commands.getoutput(command)
-
-
-# starts the amarok player application
-def start():
- os.popen('amarok')
-
-
-# close the amarok player application
-def shutdown():
- shell('dcop amarok player stop')
- pid = shell('pidof amarokapp')
- shell('kill -9 %s' % pid)
-
-
-# verifies if the amarok is running
-def isRunning():
- pid = shell('pidof amarokapp')
- if pid > 0:
- return True
- else:
- return False
-
-def send_file(addr, path):
- shell("bluetooth-sendto --dest=%s %s" + (addr, path))
-
-class AmarokPlayer():
-
- """ Amarok
- Define all states and functions of amarok player.
- This class will build to support PCRemote Player,
- receiving messages from any devices with a bluetooth
- connection.
- """
-
- # some importants variables
- def __init__(self):
- self.amarok = pydcop.anyAppCalled("amarok")
- self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist())
- self.isPlaying()
-
- # refresh playlist, accessing the Playlist class instance
- def refresh_playlist(self):
- self.playlist = Playlist(self.amarok.playlist.saveCurrentPlaylist())
- self.isPlaying()
-
- # get all songs of playlist
- def song_list(self):
- self.playlist.show()
-
- # show current song, acessing the Playlist class instance
- def current_song(self):
- self.isPlaying()
-
- # verifies if this amarok app is running
- def isRunning(self):
- aux = pydcop.anyAppCalled("amarok")
- if aux:
- return aux
- else:
- return None
-
- # verifies if this amarok app is playing and update the
- # Playlist with current song
- def isPlaying(self):
- if not self.amarok.player.isPlaying() == 'true':
- self.playlist.update(self.amarok.playlist.getActiveIndex(),\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
- return True
- else:
- return False
-
- # get the players name
- def getName(self):
- return "Amarok"
-
- # send audio files to the N810 device
- def file_properties(self, index=None):
- track = self.amarok.playlist.getActiveIndex()
- audiofile = self.playlist.song_properties(index=track, path=True)
- #audiofile = (self.playlist.song_filename(index),\
- # self.playlist.song_size(index))
- return audiofile
-
- # next button and sets current song
- def next(self):
- self.amarok.player.next()
- self.playlist.update(self.amarok.playlist.getActiveIndex(),\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # prev button and sets current song
- def prev(self):
- self.amarok.player.prev()
- self.playlist.update(self.amarok.playlist.getActiveIndex(),\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # play button and sets current song
- #def play(self):
- #self.amarok.player.play()
- #self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- # self.amarok.player.title(), \
- # self.amarok.player.artist(), \
- # self.amarok.player.path(), \
- # "." + self.amarok.player.type(), \
- # )
-
- # play button and sets current song
- # receive track or random form
- # the argument track has intended to manipulate
- # the playlist form when the user indicate a song track
- # in client application
- def play(self, track=-1, rdm=False):
- if rdm:
- index = random.randint(0, self.playlist.length() - 1)
- self.amarok.playlist.playByIndex(index)
- self.playlist.update(index + 1, \
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(),\
- )
- elif track != -1:
- self.amarok.playlist.playByIndex(track)
- self.playlist.update(track-1, \
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(),\
- )
- else:
- self.amarok.player.play()
- self.playlist.update(self.amarok.playlist.getActiveIndex() + 1,\
- self.amarok.player.title(), \
- self.amarok.player.artist(), \
- self.amarok.player.path(), \
- "." + self.amarok.player.type(), \
- )
-
- # play button with index song and sets current song
- #def play_track(self, index):
- # self.amarok.playlist.playByIndex(index-1)
- # self.playlist.update(index, \
- # self.amarok.player.title(), \
- # self.amarok.player.artist(), \
- # self.amarok.player.path(), \
- # "." + self.amarok.player.type(),\
- # )
-
- # random play songs
- #def play_random(self):
- # index = random.randint(0, self.playlist.length() - 1)
- # self.amarok.playlist.playByIndex(index)
- # self.playlist.update(index+1, \
- # self.amarok.player.title(), \
- # self.amarok.player.artist(), \
- # self.amarok.player.path(), \
- # "." + self.amarok.player.type(),\
- # )
-
- # pause button
- def pause(self):
- self.amarok.player.pause()
-
- # mute button
- def mute(self):
- self.amarok.player.mute()
-
- # stop button
- def stop(self):
- self.amarok.player.stop()
-
- # get the current volume value
- def get_volume(self):
- return self.amarok.player.getVolume()
-
- # set up volume
- def volume_up(self, increase=1):
- if (self.get_volume() + increase) <= 100:
- up = self.get_volume() + increase
- self.amarok.player.setVolume(up)
- else:
- print "erro!"
-
- # set down volume
- def volume_down(self, decrement=1):
- if (self.get_volume() - decrement) >= 0:
- down = self.get_volume() - decrement
- self.amarok.player.setVolume(down)
- else:
- print "erro!"
-
- # set seek value
- def seek(self, value):
- self.amarok.player.seek(value)
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : players
-# Description : Playlist
-# ============================================================================
-
-import plistparser
-import pydcop
-
-class Playlist():
-
- """ Playlist
- make the interpreter and manipulation
- of the player playlist, creates a composite
- with any player class.
- """
-
- # some importants variables
- # analyze if file is a playlist
- def __init__(self, file):
- if self.isPlaylist(file):
- self.file = file
- self.songs = self.load()
- self.currentSong = 0
- self.fix()
- else:
- raise("Argument is not a playlist file")
-
- # analyzes the file
- def isPlaylist(self, file):
- if not file:
- return False
- else:
- return True
-
- # make a list of dicts songs
- def load(self):
- self.songs = plistparser._request(self.file)
- return self.songs
-
- # get the length of the current playlist
- def length(self):
- return len(self.songs)
-
- # update the current song in songs list and return a song dict
- def update(self, track, title, artist, path, ext):
- self.currentSong = track
- if self.songs[self.currentSong]['title'] == 'Unknown Title':
- self.songs[self.currentSong]['title'] = title
- if self.songs[self.currentSong]['artist'] == 'Unknown Artist':
- self.songs[self.currentSong]['artist'] = artist
- self.songs[self.currentSong]['path'] = path
- self.songs[self.currentSong]['extension'] = ext
- print self.songs[self.currentSong]
-
-
- # show the current song
- def show_playing_now(self):
- return ('TITLE: %s' % self.songs[self.currentSong]['title'], \
- 'ARTIST: %s' % self.songs[self.currentSong]['artist'],\
- 'TRACK: %s' % self.songs[self.currentSong]['track']
- )
-
- # get the current song filename if index is None
- def song_filename(self, index=None):
- if index == None:
- return self.songs[self.currentSong]['title'] +" - "+\
- self.songs[self.currentSong]['artist'] + \
- self.songs[self.currentSong]['extension']
-
- else:
- return self.songs[index]['title'] +" - "+\
- self.songs[index]['artist'] + \
- self.songs[index]['extension']
-
- # get thr current song filesize if index is None
- def song_size(self, index=None):
- if index == None:
- return int(self.songs[self.currentSong]['filesize'])
- else:
- return int(self.songs[index]['filesize'])
-
- # show all songs of the playlist
- def show(self):
- for i in range(self.length()):
- print self.songs[i]['track'], " - ", \
- self.songs[i]['title'], " | ", \
- self.songs[i]['artist'], \
- "\n"
-
- # fix some problems of musics tags
- def fix(self):
- for i in range(self.length()):
- if self.songs[i]['title'] == None:
- self.songs[i]['title'] = 'Unknown Title'
- elif self.songs[i]['artist'] == None:
- self.songs[i]['artist'] = 'Unknown Artist'
-
-
- # get the porperties of any song of ther playlist
- def song_properties(self, index=None, track=False, title=False,\
- artist=False, ext=False, filesize=False, \
- duration=False, path=False):
- props = {}
- if index == None:
- if track:
- props['track'] = self.songs[self.currentSong]['track']
- if title:
- props['title'] = self.songs[self.currentSong]['title']
- if artist:
- props['artist'] = self.songs[self.currentSong]['artist']
- if ext:
- props['ext'] = self.songs[self.currentSong]['extension']
- if filesize:
- props['filesize'] = self.songs[self.currentSong]['filesize']
- if duration:
- props['duration'] = self.songs[self.currentSong]['duration']
- if path:
- props['path'] = self.songs[self.currentSong]['path']
-
- return props
- else:
- if track:
- props['track'] = self.songs[index]['track']
- if title:
- props['title'] = self.songs[index]['title']
- if artist:
- props['artist'] = self.songs[index]['artist']
- if ext:
- props['ext'] = self.songs[index]['extension']
- if filesize:
- props['filesize'] = self.songs[index]['filesize']
- if duration:
- props['duration'] = self.songs[index]['duration']
- if path:
- props['path'] = self.songs[index]['path']
-
- return props
-
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : utils
-# Description : plisparser
-# ============================================================================
-
-from xml.etree import cElementTree as ElementTree
-
-# get the file
-def _request(url):
- xml = url
- return parse_playlist_file(xml)
-
-# parser the file
-def parse_playlist_file(xml):
- tree = ElementTree.parse(xml)
- listsongs = []
- dictsongs = {}
- count = duration = filesize = 0
- title = artist = path = ''
-
- for child in tree.getiterator():
- if child.tag == 'Title':
- title = child.text
- elif child.tag == 'Artist':
- artist = child.text
- elif child.tag == 'Length':
- duration = child.text
- elif child.tag == 'Filesize':
- filesize = child.text
- count = count + 1
- dictsongs = {'track' : count,
- 'title' : title,
- 'artist' : artist,
- 'duration' : duration,
- 'filesize' : filesize,
- 'path' : None,
- 'extension' : None,
- }
- listsongs.append(dictsongs)
-
- return listsongs
-
-
-
-
-
-
-
-
+++ /dev/null
-import amarok
-
-if not amarok.isRunning():
- player = amarok.AmarokPlayer()
-else:
- print "entrou aqui"
- amarok.start()
- player = amarok.AmarokPlayer()
-
-while(1):
- data = raw_input(">>> ")
- if data == '#exit' or data == '#quit' or data == '#close':
- print "Application closed."
- amarok.shutdown()
- break
- elif data == 'next':
- player.next()
- elif data == 'prev':
- player.prev()
- elif data == 'play':
- player.play()
- elif data == 'pause':
- player.pause()
- elif data == 'stop':
- player.stop()
- elif data == 'mute':
- player.mute()
- elif data == 'volume-up':
- player.volume_up()
- elif data == 'volume-down':
- player.volume_down()
- elif data == 'current_song':
- print player.current_song()
- elif data == 'random':
- player.play_random()
- elif data == 'play-track':
- index = input('track: ')
- player.play_track(index)
- elif data == 'refresh':
- player.refresh_playlist()
- elif data == 'show':
- player.song_list()
-
+++ /dev/null
-#!/usr/bin/env python
-# -*- 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 ; Jonatas Izvi; Andre Portela
-# Email : fergus.mao@gmail.com ; nona@gmail.com ;
-# andre_portela_@hotmail.com;
-# Version : 1.0
-# Class : Server File - This is the main script of the server
-# ============================================================================
-
-from connection.iconnection import *
-from services.service import *
-from utils import *
-from utils.messages import *
-
-class Server():
-
- def __init__(self, AppName):
- self.msgbox = Message(AppName)
- self.msgbox.show_message("Server Initialized...")
-
- def start(self, servername):
-
- label = Labels()
- iconn = Iconnection('blue')
- iconn.bluetooth_create_server('l2cap', 0x1001)
-
- address = iconn.get_client_address()
-
- self.msgbox.show_message("Accepted connection from " + address[0])
-
- while (1):
-
- data = iconn.received_message()
-
- if data == 'Tablet:#start':
-
- self.msgbox.show_message('Service Tablet initialized...')
-
- service = Service()
- service.set_service('Tablet')
-
- while(1):
- data = iconn.received_message()
- if data == 'Tablet:#stop':
- service.clean_all()
- self.msgbox.show_message('Service Tablet stoped')
- break
- service.execute(data)
-
- elif data == 'Slideshow:#start':
-
- self.msgbox.show_message('Service Slideshow initialized...')
-
- service = Service()
- service.set_service('Slideshow')
-
- while(1):
- data = iconn.received_message()
- if data == 'Slideshow:#stop':
- service.clean_all()
- self.msgbox.show_message('Service Slideshow stoped')
- break
- print data, "\n"
- service.execute(data)
-
- elif data == 'Player:#start':
-
- self.msgbox.show_message('Service Player initialized...')
-
- service = Service()
- service.set_service('Player')
-
- while(1):
- data = iconn.received_message()
- if data == 'Player:#stop':
- self.msgbox.show_message('Service Player stoped')
- break
- elif data == 'Player:#download':
- service.set_address_to_download(address[0])
- elif data == 'Player:#load_playlist':
- # e preciso criar um metodo de transferencia
- # no caso de carregar uma playlist para o cliente
- service.execute_transfer(data)
-
- service.execute(data)
-
- else:
- iconn.close()
- self.msgbox.show_message('Desconected from ' + address[0])
- break
+++ /dev/null
-8
-
-dir
-42
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn/remote_server/trunk/remote_server/src/services
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn
-
-
-
-2008-11-24T21:43:13.543262Z
-39
-aportela
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-fe65f2a5-7a5f-4c8d-90e7-f011580d4f26
-\f
-__init__.py
-file
-
-
-
-
-2008-10-31T23:33:24.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2008-10-31T22:34:59.880000Z
-4
-aportela
-has-props
-\f
-ObjectServers.py
-file
-
-
-
-
-2008-11-24T21:42:50.000000Z
-61fef10722e4d9d7faac93a03ac1ceb1
-2008-11-24T21:43:13.543262Z
-39
-aportela
-has-props
-\f
-service.py
-file
-
-
-
-
-2008-11-24T21:41:33.000000Z
-10874c65035a891cb60e1ccb8b2bdb4f
-2008-11-24T21:41:51.237514Z
-37
-aportela
-has-props
-\f
-ServerHandlers.py
-file
-
-
-
-
-2008-11-24T21:42:13.000000Z
-5c25986a6c09a7313d8f5f51b509a5e6
-2008-11-24T21:42:30.576563Z
-38
-aportela
-has-props
-\f
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-# -*- 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 *
-
-class Mouse_Server:
-
- """ Mouse Server
- Defines all mouse behaviors.
- Clicks and coordinates.
- """
-
- #Initialize the class
- def __init__(self):
-
- 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
- self.mouse.position(i, j)
-
- self.x = int(coord[0])
- self.y = int(coord[1])
-
- def clean_up_mouse(self):
- self.mouse.clean_up_mouse()
-
-class KeyBoard_Server:
-
- """ Keyboard Server
- Defines all keyboard behaviors.
- Map keys and events.
- """
-
- def __init__(self):
- self.keyboard = Keyboard()
- self.shift_flag = False
- self.control_flag = False
- self.keys = []
-
- # 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(command == 'ISO_Level3_Shift'):
- self.keyboard.reproduce_key_press('Escape')
- self.keyboard.reproduce_key_release('Escape')
- pass
- 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 == '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')
- 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
-
- # clean all keys pressed
- def clean_up_keyboard(self):
- print "\nkeys -> ", self.keys
- list = self.keys
- print "\nlist ->", list
- for i in list:
- self.keyboard.reproduce_key_release(i)
- self.keys.remove(i)
- print "\nkey --> ", i, " removed."
-
- print self.keys
+++ /dev/null
-# -*- 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
-# Email : fergus.mao@gmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : service
-# Description : Singleton, Mouse and Keyboard
-# ============================================================================
-
-import Xlib
-from Xlib import display, X, XK
-
-class Singleton_Xlib():
-
- """ Singleton
- defines a singleton.
- """
- def __init__(self):
- self.display = display.Display()
- self.screen = self.display.screen()
-
-xlib_srv = Singleton_Xlib()
-
-class Mouse(object):
-
- """ Mouse
- pass mouse information to Xorg
- """
-
- #Initialize the class
- def __init__(self):
- self.disp = xlib_srv.display
- self.screen = xlib_srv.screen
- self.fator = 10
- self.lbutton = False
- self.mbutton = False
- self.rbutton = False
- self.buttons = []
-
- #Set the mouse pointer position
- def position(self,x=None,y=None):
-
- if (x == None):
- x = self.fator
-
- if (y == None):
- y = self.fator
-
- #Get the current mouse pointer position
- current_x = self.screen.root.query_pointer()._data["root_x"]
- current_y = self.screen.root.query_pointer()._data["root_y"]
-
- def absolute(ax = None, ay = None):
- if (ax == None):
- ax = x
- if (ay == None):
- ay = y
-
- self.screen.root.warp_pointer(ax, ay)
- self.disp.sync()
-
- def relative():
- rX = current_x + x
- rY = current_y + y
- absolute(rX,rY)
-
- relative()
-
- #Returns the current X position
- def get_x(self):
- return self.screen.root.query_pointer()._data["root_x"]
-
- #Returns the current Y position
- def get_y(self):
- return self.screen.root.query_pointer()._data["root_y"]
-
- #Defines the factor(px) of the mouse pointer move
- def set_fator(self,fator):
- self.fator = fator
-
- #Returns the factor
- def get_fator(self):
- return self.fator
-
- #Mouse Left Click
- def left_click(self, fg_lbutton = None):
-
- if (fg_lbutton != None):
- self.lbutton = not fg_lbutton
-
- if not self.lbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 1, 0)
- self.buttons.append('left_button')
- self.lbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 1, 5)
- self.buttons.remove('left_button')
- self.lbutton = False
-
- self.disp.flush()
-
- #Mouse Middle Click
- def middle_click(self):
- if not self.mbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 2, 0)
- self.buttons.append('middle_button')
- self.mbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 2, 5)
- self.buttons.remove('middle_button')
- self.mbutton = False
-
- self.disp.flush()
-
- #Mouse Right Click
- def right_click(self, fg_rbutton = None):
-
- if (fg_rbutton != None):
- self.rbutton = not fg_rbutton
-
- if not self.rbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 3, 0)
- self.buttons.append('right_button')
- self.rbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
- self.buttons.remove('right_button')
- self.rbutton = False
-
- self.disp.flush()
-
- def clean_up_mouse(self):
- list = self.buttons
- print list
- for i in list:
- if i == 'left_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 1, 5)
- self.disp.xtest_fake_input(X.ButtonPress, 3, 5)
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
- self.buttons.remove(i)
- print "\nleft_button -> release."
- elif i == 'middle_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 2, 5)
- self.buttons.remove(i)
- print "\nmiddle_button -> release."
- elif i == 'right_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
- self.buttons.remove(i)
- print "\nright_button -> release."
-
- print self.buttons
-
-class Keyboard():
-
- """ Keyboard
- pass keyboard information to Xorg
- """
-
- def __init__(self):
- self.display = xlib_srv.display
- self.screen = xlib_srv.screen
-
- # encode key
- def __key_to_code(self,key):
- new_key = getattr(XK, "XK_" + key)
- code = self.display.keysym_to_keycode(new_key)
- return code
-
- # reproduce key pressed
- def reproduce_key_press(self, key):
- Xlib.ext.xtest.fake_input(self.display, Xlib.X.KeyPress, self.__key_to_code(key))
- self.display.sync()
-
- # reproduce key release
- def reproduce_key_release(self, key):
- Xlib.ext.xtest.fake_input(self.display, Xlib.X.KeyRelease, self.__key_to_code(key))
- self.display.sync()
-
+++ /dev/null
-# -*- 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
-# Email : fergus.mao@gmail.com, jonatas.nona@gmail.com
-# Reviewer : Jônatas Isvi
-# Email :
-# Version : 1.0
-# Package : Main Application
-# Description : Service Application
-# ============================================================================
-
-from ObjectServers import *
-
-class Service:
-
- """ Service
- supports all services applications
- """
-
- def __init__(self):
- self.mouse_srv = None
- self.keyboard_srv = None
- self.service = ""
-
- #Set the Service requested by the Service Manager
- def set_service(self, command):
-
- self.service = command
-
- if self.service == 'Tablet':
- self.mouse_srv = Mouse_Server()
- self.keyboard_srv = KeyBoard_Server()
- elif self.service == 'Slideshow':
- self.mouse_srv = Mouse_Server()
- self.keyboard_srv = KeyBoard_Server()
- elif self.service == 'Player':
- print "player service."
- elif self.service == 'Torrent':
- print "torrent service."
-
- #Returns the Service which is being executed
- def get_service(self):
- return self.service
-
- #Executes the action requested by the Service Manager
- def execute(self, command):
-
- cmd = command.split(":")
-
- if cmd[0] == "Mouse":
- self.mouse_srv.execute(cmd[1])
- elif cmd[0] == "Keyboard":
- self.keyboard_srv.execute(cmd[1])
-
- # clean all button and keys pressed
- def clean_all(self):
- self.mouse_srv.clean_up_mouse()
- self.keyboard_srv.clean_up_keyboard()
+++ /dev/null
-# -*- 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
+++ /dev/null
-# -*- 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
-# Email : fergus.mao@gmail.com
-# Reviewer : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Package : service
-# Description : Singleton, Mouse and Keyboard
-# ============================================================================
-
-import Xlib
-from Xlib import display, X, XK
-
-class Singleton_Xlib():
-
- """ Singleton
- defines a singleton.
- """
- def __init__(self):
- self.display = display.Display()
- self.screen = self.display.screen()
-
-xlib_srv = Singleton_Xlib()
-
-class Mouse(object):
-
- """ Mouse
- pass mouse information to Xorg
- """
-
- #Initialize the class
- def __init__(self):
- self.disp = xlib_srv.display
- self.screen = xlib_srv.screen
- self.fator = 10
- self.lbutton = False
- self.mbutton = False
- self.rbutton = False
- self.buttons = []
-
- #Set the mouse pointer position
- def position(self,x=None,y=None):
-
- if (x == None):
- x = self.fator
-
- if (y == None):
- y = self.fator
-
- #Get the current mouse pointer position
- current_x = self.screen.root.query_pointer()._data["root_x"]
- current_y = self.screen.root.query_pointer()._data["root_y"]
-
- def absolute(ax = None, ay = None):
- if (ax == None):
- ax = x
- if (ay == None):
- ay = y
-
- self.screen.root.warp_pointer(ax, ay)
- self.disp.sync()
-
- def relative():
- rX = current_x + x
- rY = current_y + y
- absolute(rX,rY)
-
- relative()
-
- #Returns the current X position
- def get_x(self):
- return self.screen.root.query_pointer()._data["root_x"]
-
- #Returns the current Y position
- def get_y(self):
- return self.screen.root.query_pointer()._data["root_y"]
-
- #Defines the factor(px) of the mouse pointer move
- def set_fator(self,fator):
- self.fator = fator
-
- #Returns the factor
- def get_fator(self):
- return self.fator
-
- #Mouse Left Click
- def left_click(self, fg_lbutton = None):
-
- if (fg_lbutton != None):
- self.lbutton = not fg_lbutton
-
- if not self.lbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 1, 0)
- self.buttons.append('left_button')
- self.lbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 1, 5)
- self.buttons.remove('left_button')
- self.lbutton = False
-
- self.disp.flush()
-
- #Mouse Middle Click
- def middle_click(self):
- if not self.mbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 2, 0)
- self.buttons.append('middle_button')
- self.mbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 2, 5)
- self.buttons.remove('middle_button')
- self.mbutton = False
-
- self.disp.flush()
-
- #Mouse Right Click
- def right_click(self, fg_rbutton = None):
-
- if (fg_rbutton != None):
- self.rbutton = not fg_rbutton
-
- if not self.rbutton:
- self.disp.xtest_fake_input(X.ButtonPress, 3, 0)
- self.buttons.append('right_button')
- self.rbutton = True
- else:
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
- self.buttons.remove('right_button')
- self.rbutton = False
-
- self.disp.flush()
-
- def clean_up(self):
- if self.buttons:
- while self.buttons:
- button = self.buttons.pop()
- if button == 'left_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 1, 5)
- self.disp.xtest_fake_input(X.ButtonPress, 3, 5)
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
- elif button == 'middle_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 2, 5)
- elif button == 'right_button':
- self.disp.xtest_fake_input(X.ButtonRelease, 3, 5)
-
- print self.buttons
-
-class Keyboard():
-
- """ Keyboard
- pass keyboard information to Xorg
- """
-
- def __init__(self):
- self.display = xlib_srv.display
- self.screen = xlib_srv.screen
- self.keys = []
-
- # encode key
- def __key_to_code(self,key):
- new_key = getattr(XK, "XK_" + key)
- code = self.display.keysym_to_keycode(new_key)
- return code
-
- # reproduce key pressed
- def reproduce_key_press(self, key):
- Xlib.ext.xtest.fake_input(self.display, Xlib.X.KeyPress, self.__key_to_code(key))
- self.display.sync()
- self.keys.append(key)
-
- # reproduce key release
- def reproduce_key_release(self, key):
- Xlib.ext.xtest.fake_input(self.display, Xlib.X.KeyRelease, self.__key_to_code(key))
- self.display.sync()
- self.keys.remove(key)
-
- # clean all pressed keys
- def clean_up(self):
- if self.keys:
- while self.keys:
- key = self.keys.pop()
- self.reproduce_key_release(key)
-
+++ /dev/null
-# -*- 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
-# Email : fergus.mao@gmail.com, jonatas.nona@gmail.com
-# Reviewer : Jônatas Isvi
-# Email :
-# Version : 1.0
-# Package : Main Application
-# Description : Service Application
-# ============================================================================
-
-from ObjectServers import *
-
-class Service:
-
- """ Service
- supports all services applications
- """
-
- def __init__(self):
- self.mouse_srv = None
- self.keyboard_srv = None
- self.player = None
- self.service = ""
- self.addr = None
-
- #Set the Service requested by the Service Manager
- def set_service(self, command):
-
- self.service = command
-
- if self.service == 'Tablet':
- self.mouse_srv = Mouse_Server(self.service)
- self.keyboard_srv = KeyBoard_Server(self.service)
- elif self.service == 'Slideshow':
- self.mouse_srv = Mouse_Server(self.service)
- self.keyboard_srv = KeyBoard_Server(self.service)
- elif self.service == 'Player':
- self.player_srv = Player_Server()
- elif self.service == 'Torrent':
- print "torrent service."
-
- #Returns the Service which is being executed
- def get_service(self):
- return self.service
-
- #Executes the action requested by the Service Manager
- def execute(self, command):
-
- cmd = command.split(":")
-
- if cmd[0] == "Mouse":
- self.mouse_srv.execute(cmd[1])
- elif cmd[0] == "Keyboard":
- self.keyboard_srv.execute(cmd[1])
- elif cmd[0] == "Player":
- if self.addr:
- cmd += self.addr
- self.player_srv.execute(cmd)
- else:
- self.player_srv.execute(cmd)
-
- def set_address_to_download(self, addr):
- self.addr = addr
-
- # clean all button and keys pressed
- def clean_all(self):
- self.mouse_srv.clean_up()
- self.keyboard_srv.clean_up()
-
-#teste unitario
-if __name__ == '__main__':
- import utils.plistparser
+++ /dev/null
-8
-
-dir
-42
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn/remote_server/trunk/remote_server/src/utils
-svn+ssh://aportela@10.0.50.3/home/aportela/remote_control_svn
-
-
-
-2008-11-24T22:06:21.176771Z
-40
-aportela
-
-
-svn:special svn:externals svn:needs-lock
-
-
-
-
-
-
-
-
-
-
-
-fe65f2a5-7a5f-4c8d-90e7-f011580d4f26
-\f
-plistparser.py
-file
-
-
-
-
-2008-11-24T21:52:13.000000Z
-606a6ee70138fd606222cd4c3162cc3f
-2008-11-24T22:06:21.176771Z
-40
-aportela
-has-props
-\f
-__init__.py
-file
-
-
-
-
-2008-10-31T23:33:24.000000Z
-d41d8cd98f00b204e9800998ecf8427e
-2008-10-31T22:34:59.880000Z
-4
-aportela
-has-props
-\f
-labels.py
-file
-
-
-
-
-2008-11-03T19:55:46.000000Z
-6c9741bd79bbd0f1ac82d2d98614032d
-2008-11-03T20:22:42.774109Z
-5
-aportela
-has-props
-\f
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 13
-svn:mime-type
-V 10
-text/plain
-END
+++ /dev/null
-K 14
-svn:executable
-V 1
-*
-END
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Description : Labels
-# ============================================================================
-
-class Labels():
-
- def __init__(self):
- pass
-
- # GENERIC LABELS FOR MULTIMEDIA APPLICATIONS
-
- PLAY = "#play"
- STOP = "#stop"
- PAUSE = "#pause"
- NEXT = "#next"
- PREVIOUS = "#previous"
- VOL_UP = "#vol_up"
- VOL_DOWN = "#vol_down"
- TLINE_LEFT = "#tline_left"
- TLINE_RIGHT = "#tline_right"
- RECORD = "#record"
- #------------------------------------------>
-
- # GENERIC LABELS FOR APPLICATIONS
-
- START = "#start"
- CLOSE = "#close"
- FULL = "#fullscreen"
- UPLOAD = "#upload"
- DOWNLOAD = "#download"
- SAVE = "#save"
- DELETE = "#delete"
- #-------------------------------->
-
- # GENERAL MOUSE LABELS
-
- CLICK = "#click"
- DOUBLE_CLICK = "#double_click"
- TRIPLE_CLICK = "#triple_click"
- LEFT_CLICK = "#left_click"
- RIGHT_CLICK = "#right_click"
- MIDDLE_CLICK = "#middle_click"
- #-------------------------------->
-
-
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : utils
-# Description : plisparser
-# ============================================================================
-
-from xml.etree import cElementTree as ElementTree
-
-# get the file
-def _request(url):
- xml = url
- return parse_playlist_file(xml)
-
-# parser the file
-def parse_playlist_file(xml):
- tree = ElementTree.parse(xml)
- listsongs = []
- dictsongs = {}
- count = duration = filesize = 0
- title = artist = path = ''
-
- for child in tree.getiterator():
- if child.tag == 'Title':
- title = child.text
- elif child.tag == 'Artist':
- artist = child.text
- elif child.tag == 'Length':
- duration = child.text
- elif child.tag == 'Filesize':
- filesize = child.text
- count = count + 1
- dictsongs = {'track' : count,
- 'title' : title,
- 'artist' : artist,
- 'duration' : duration,
- 'filesize' : filesize,
- 'path' : None,
- 'extension' : None,
- }
- listsongs.append(dictsongs)
-
- return listsongs
-
-
-
-
-
-
-
-
+++ /dev/null
-# -*- 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 : Jônatas Isvi
-# Email : jonatas.nona@gmail.com
-# Version : 1.0
-# Description : Labels
-# ============================================================================
-
-class Labels():
-
- def __init__(self):
- pass
-
- # SERVICES SUPPORTED
- TABLET = "Tablet"
- SLIDESHOW = "Slideshow"
- PLAYER = "Player"
- TORRENT = "Torrent"
-
- # GENERIC LABELS FOR MULTIMEDIA APPLICATIONS
-
- PLAY = "#play"
- STOP = "#stop"
- PAUSE = "#pause"
- NEXT = "#next"
- PREVIOUS = "#previous"
- VOL_UP = "#vol_up"
- VOL_DOWN = "#vol_down"
- TLINE_LEFT = "#tline_left"
- TLINE_RIGHT = "#tline_right"
- RECORD = "#record"
- SEEK = "#seek"
- LOAD_PLAYLIST = "#load_playlist"
- PLAYLIST = "#playlist"
- #------------------------------------------>
-
- # GENERIC LABELS FOR APPLICATIONS
-
- START = "#start"
- CLOSE = "#close"
- FULL_SRC = "#fullscreen"
- UPLOAD = "#upload"
- DOWNLOAD = "#download"
- SAVE = "#save"
- DELETE = "#delete"
- #-------------------------------->
-
- # GENERAL MOUSE LABELS
-
- CLICK = "#click"
- DOUBLE_CLICK = "#double_click"
- TRIPLE_CLICK = "#triple_click"
- LEFT_CLICK = "#left_click"
- RIGHT_CLICK = "#right_click"
- MIDDLE_CLICK = "#middle_click"
- #-------------------------------->
-
-
+++ /dev/null
-import pynotify
-import Image
-import StringIO
-import gtk
-
-class Message():
- def __init__(self, AppName):
- pynotify.init(AppName)
- self.AppName = AppName
- self.msgbox = pynotify.Notification(self.AppName, self.AppName, "PCR_on.bmp")
- self.msgbox.set_urgency(pynotify.URGENCY_CRITICAL)
- self.msgbox.set_timeout(5000)
-
- def show_message(self, message):
- self.msgbox = pynotify.Notification(self.AppName, message)
- self.msgbox.show()
-
- def set_image(self, img):
-# image = Image.open(img)
-# image = gtk.gdk.pixbuf_new_from_file(img)
-# self.msgbox.set_icon_from_pixbuf(self.image2pixbuf(image))
- pass
-
- def image2pixbuf(self, img):
- file1 = StringIO.StringIO()
-
- img.save(file1, "ppm")
- contents = file1.getvalue()
- file1.close()
-
- loader = gtk.gdk.PixbufLoader("pnm")
- loader.write(contents, len(contents))
-
- pixbuf = loader.get_pixbuf()
- loader.close()
-
- return pixbuf
+++ /dev/null
-# -*- 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 : Jonatas Isvi
-# Email : jonatas.nona@gmail.com
-# Reviewer :
-# Email :
-# Version : 1.0
-# Package : utils
-# Description : plisparser
-# ============================================================================
-
-from xml.etree import cElementTree as ElementTree
-
-# get the file
-def _request(url):
- xml = url
- return parse_playlist_file(xml)
-
-# parser the file
-def parse_playlist_file(xml):
- tree = ElementTree.parse(xml)
- listsongs = []
- dictsongs = {}
- count = duration = filesize = 0
- title = artist = path = ''
-
- for child in tree.getiterator():
- if child.tag == 'Title':
- title = child.text
- elif child.tag == 'Artist':
- artist = child.text
- elif child.tag == 'Length':
- duration = child.text
- elif child.tag == 'Filesize':
- filesize = child.text
- count = count + 1
- dictsongs = {'track' : count,
- 'title' : title,
- 'artist' : artist,
- 'duration' : duration,
- 'filesize' : filesize,
- 'path' : None,
- 'extension' : None,
- }
- listsongs.append(dictsongs)
-
- return listsongs
-
-
-
-
-
-
-
-