pcremote-client-n8x0 -> client sources
[remotepc] / pcremote-server-desktop / debian / pcremote-server / usr / share / pcremote-server / runserver.py
diff --git a/pcremote-server-desktop/debian/pcremote-server/usr/share/pcremote-server/runserver.py b/pcremote-server-desktop/debian/pcremote-server/usr/share/pcremote-server/runserver.py
new file mode 100755 (executable)
index 0000000..01ece58
--- /dev/null
@@ -0,0 +1,108 @@
+#!/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])