2 # -*- coding: utf-8 -*-
4 # ****************************************************************************
5 # Copyright (c) 2008 INdT/Fucapi.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Lesser General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # ============================================================================
20 # Project Name : PC Remote
21 # Author : Nilson ; Jonatas Izvi; Andre Portela
22 # Email : fergus.mao@gmail.com ; nona@gmail.com ;
23 # andre_portela_@hotmail.com;
25 # Class : Server File - This is the main script of the server
26 # ============================================================================
28 from connection.iconnection import *
29 from services.service import *
31 from utils.messages import *
35 def __init__(self, AppName):
36 self.msgbox = Message(AppName)
37 self.msgbox.show_message("Server Initialized...")
39 def start(self, servername):
42 iconn = Iconnection('blue')
43 iconn.bluetooth_create_server('l2cap', 0x1001)
45 address = iconn.get_client_address()
47 self.msgbox.show_message("Accepted connection from " + address[0])
51 data = iconn.received_message()
53 if data == 'Tablet:#start':
55 self.msgbox.show_message('Service Tablet initialized...')
58 service.set_service('Tablet')
61 data = iconn.received_message()
62 if data == 'Tablet:#stop':
64 self.msgbox.show_message('Service Tablet stoped')
68 elif data == 'Slideshow:#start':
70 self.msgbox.show_message('Service Slideshow initialized...')
73 service.set_service('Slideshow')
76 data = iconn.received_message()
77 if data == 'Slideshow:#stop':
79 self.msgbox.show_message('Service Slideshow stoped')
84 elif data == 'Player:#start':
86 self.msgbox.show_message('Service Player initialized...')
89 service.set_service('Player')
92 data = iconn.received_message()
93 if data == 'Player:#stop':
94 self.msgbox.show_message('Service Player stoped')
96 elif data == 'Player:#download':
97 service.set_address_to_download(address[0])
98 elif data == 'Player:#load_playlist':
99 # e preciso criar um metodo de transferencia
100 # no caso de carregar uma playlist para o cliente
101 service.execute_transfer(data)
103 service.execute(data)
107 self.msgbox.show_message('Desconected from ' + address[0])