diff --git a/README.md b/README.md index 53462a8..962f9ac 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Remote Desktop Protocol in Twisted Python ## Requirements * python2.7 * python-twisted +* python-openssl ## Requirements for examples * python-qt4 @@ -15,5 +16,6 @@ Remote Desktop Protocol in Twisted Python * Packet redirection * License * Most common orders +* FastPath messages this project is still in progress. diff --git a/rdpy/display/qt.py b/rdpy/display/qt.py index 3e60b7e..5e0f525 100644 --- a/rdpy/display/qt.py +++ b/rdpy/display/qt.py @@ -61,8 +61,11 @@ class RFBClientQt(RFBClientObserver, QAdaptor): QAdaptor for specific RFB protocol stack is to an RFB observer ''' - def __init__(self): - RFBClientObserver.__init__(self) + def __init__(self, controller): + """ + @param controller: controller for obser + """ + RFBClientObserver.__init__(self, controller) self._widget = QRemoteDesktop(self) def getWidget(self): @@ -118,8 +121,11 @@ class RDPClientQt(RDPClientObserver, QAdaptor): ''' Adaptor for RDP client ''' - def __init__(self): - RDPClientObserver.__init__(self) + def __init__(self, controller): + """ + @param controller: RDP controller + """ + RDPClientObserver.__init__(self, controller) self._widget = QRemoteDesktop(self) def getWidget(self): diff --git a/rdpy/examples/rdpclient.py b/rdpy/examples/rdpclient.py index e28e0ac..909875f 100644 --- a/rdpy/examples/rdpclient.py +++ b/rdpy/examples/rdpclient.py @@ -31,16 +31,17 @@ from PyQt4 import QtGui from rdpy.display.qt import RDPClientQt from rdpy.protocol.rdp import rdp -class RDPClientQtFactory(rdp.Factory): - ''' +class RDPClientQtFactory(rdp.ClientFactory): + """ Factory create a RDP GUI client - ''' - def buildObserver(self): - ''' - build RFB observer - ''' + """ + def buildObserver(self, controller): + """ + Build RFB observer + @param controller: build factory and needed by observer + """ #create client observer - client = RDPClientQt() + client = RDPClientQt(controller) #create qt widget self._w = client.getWidget() self._w.resize(1024, 800) @@ -52,21 +53,21 @@ class RDPClientQtFactory(rdp.Factory): pass def clientConnectionLost(self, connector, reason): - ''' - connection lost event + """ + Connection lost event @param connector: twisted connector use for rdp connection (use reconnect to restart connection) @param reason: str use to advertise reason of lost connection - ''' + """ QtGui.QMessageBox.warning(self._w, "Warning", "Lost connection : %s"%reason) reactor.stop() app.exit() def clientConnectionFailed(self, connector, reason): - ''' - connection failed event + """ + Connection failed event @param connector: twisted connector use for rdp connection (use reconnect to restart connection) @param reason: str use to advertise reason of lost connection - ''' + """ QtGui.QMessageBox.warning(self._w, "Warning", "Connection failed : %s"%reason) reactor.stop() app.exit() diff --git a/rdpy/examples/vncclient.py b/rdpy/examples/vncclient.py index 82436d3..544dd11 100644 --- a/rdpy/examples/vncclient.py +++ b/rdpy/examples/vncclient.py @@ -35,12 +35,13 @@ class RFBClientQtFactory(rfb.Factory): """ Factory create a VNC GUI client """ - def buildObserver(self): + def buildObserver(self, controller): """ Build RFB Client observer + @param controller: build by factory """ #create client observer - client = RFBClientQt() + client = RFBClientQt(controller) #create qt widget self._w = client.getWidget() self._w.resize(1024, 800) diff --git a/rdpy/protocol/rdp/rdp.py b/rdpy/protocol/rdp/rdp.py index 19cc108..7d21a2e 100644 --- a/rdpy/protocol/rdp/rdp.py +++ b/rdpy/protocol/rdp/rdp.py @@ -43,7 +43,7 @@ class RDPController(object): for rectangle in bitmapUpdateData.rectangles._array: observer.onBitmapUpdate(rectangle.destLeft.value, rectangle.destTop.value, rectangle.destRight.value, rectangle.destBottom.value, rectangle.width.value, rectangle.height.value, rectangle.bitsPerPixel.value, (rectangle.flags & pdu.BitmapFlag.BITMAP_COMPRESSION).value, rectangle.bitmapDataStream.value) -class Factory(protocol.Factory): +class ClientFactory(protocol.Factory): ''' Factory of Client RDP protocol ''' @@ -52,9 +52,11 @@ class Factory(protocol.Factory): Function call from twisted and build rdp protocol stack @param addr: destination address ''' - return tpkt.TPKT(tpdu.createClient(mcs.createClient(self.buildObserver().getController()))); + controller = RDPController(LayerMode.CLIENT) + self.buildObserver(controller) + return tpkt.TPKT(tpdu.createClient(mcs.createClient(controller))); - def buildObserver(self): + def buildObserver(self, controller): ''' build observer use for connection ''' @@ -92,16 +94,13 @@ class RDPClientObserver(object): ''' class use to inform all rdp event handle by RDPY ''' - def __init__(self): - self._controller = RDPController(LayerMode.CLIENT) + def __init__(self, controller): + """ + @param controller: RDP controller use to interact with protocol + """ + self._controller = controller self._controller.addClientObserver(self) - def getController(self): - """ - @return: RDP controller use by observer - """ - return self._controller - def onBitmapUpdate(self, destLeft, destTop, destRight, destBottom, width, height, bitsPerPixel, isCompress, data): ''' notify bitmap update diff --git a/rdpy/protocol/rfb/rfb.py b/rdpy/protocol/rfb/rfb.py index 930d7e6..c87ac7f 100644 --- a/rdpy/protocol/rfb/rfb.py +++ b/rdpy/protocol/rfb/rfb.py @@ -529,9 +529,11 @@ class Factory(protocol.Factory): Function call by twisted on connection @param addr: address where client try to connect """ - return self.buildObserver().getController().getRFBLayer() + controller = RFBController(LayerMode.CLIENT) + self.buildObserver(controller) + return controller.getRFBLayer() - def buildObserver(self): + def buildObserver(self, controller): """ Build an RFB observer object """ @@ -542,8 +544,8 @@ class RFBClientObserver(object): """ RFB client protocol observer """ - def __init__(self): - self._controller = RFBController(LayerMode.CLIENT) + def __init__(self, controller): + self._controller = controller self._controller.addClientObserver(self) def getController(self):