Code refactoring

This commit is contained in:
speyrefitte
2014-06-23 15:51:18 +02:00
parent dc7d2d56c5
commit 6c298032c4
4 changed files with 33 additions and 73 deletions

View File

@@ -26,7 +26,6 @@ QRemoteDesktop is a widget use for render in rdpy
from PyQt4 import QtGui, QtCore
from rdpy.protocol.rfb.rfb import RFBClientObserver
from rdpy.protocol.rdp.rdp import RDPClientObserver
from rdpy.network.error import UnRegistredObject
class QAdaptor(object):
'''
@@ -230,9 +229,6 @@ class QRemoteDesktop(QtGui.QWidget):
call when button mouse is pressed
@param event: qMouseEvent
'''
if self._adaptor is None:
raise UnRegistredObject("No adaptor to send mouse press event")
self._adaptor.sendMouseEvent(event)
def keyPressEvent(self, event):
@@ -240,8 +236,5 @@ class QRemoteDesktop(QtGui.QWidget):
call when button key is pressed
@param event: qKeyEvent
'''
if self._adaptor is None:
raise UnRegistredObject("No adaptor to send key press event")
self._adaptor.sendKeyEvent(event)

View File

@@ -31,7 +31,7 @@ from PyQt4 import QtGui
from rdpy.display.qt import RFBClientQt
from rdpy.protocol.rfb import rfb
class RFBClientQtFactory(rfb.Factory):
class RFBClientQtFactory(rfb.ClientFactory):
"""
Factory create a VNC GUI client
"""

View File

@@ -22,89 +22,61 @@ All exceptions error use in RDPY
"""
class InvalidValue(Exception):
'''
raise when invalid value type occured
'''
"""
Raise when invalid value type occurred
"""
def __init__(self, message = ""):
'''
constructor with message
"""
@param message: message show when exception is raised
'''
"""
Exception.__init__(self, message)
class InvalidExpectedDataException(Exception):
'''
raise when expected data on network is invalid
'''
"""
Raise when expected data on network is invalid
"""
def __init__(self, message = ""):
'''
constructor with message
"""
@param message: message show when exception is raised
'''
"""
Exception.__init__(self, message)
class NegotiationFailure(Exception):
'''
raise when negotiation failure in different protocols
'''
"""
Raise when negotiation failure in different protocols
"""
def __init__(self, message = ""):
'''
constructor with message
"""
@param message: message show when exception is raised
'''
"""
Exception.__init__(self, message)
class InvalidType(Exception):
'''
raise when invalid value type occured
'''
"""
Raise when invalid value type occured
"""
def __init__(self, message = ""):
'''
constructor with message
"""
@param message: message show when exception is raised
'''
"""
Exception.__init__(self, message)
class InvalidSize(Exception):
'''
raise when invalid size is present in packet type occured
'''
"""
Raise when invalid size is present in packet type occured
"""
def __init__(self, message = ""):
'''
constructor with message
"""
@param message: message show when exception is raised
'''
"""
Exception.__init__(self, message)
class ErrorReportedFromPeer(Exception):
'''
raise when peer send an error
'''
"""
Raise when peer send an error
"""
def __init__(self, message = ""):
'''
constructor with message
"""
@param message: message show when exception is raised
'''
Exception.__init__(self, message)
class DisconnectLayer(Exception):
'''
raise when try to send on unconnect layer
'''
def __init__(self, message = ""):
'''
constructor with message
@param message: message show when exception is raised
'''
Exception.__init__(self, message)
class UnRegistredObject(Exception):
'''
raise when an object is not registred in other objet
'''
def __init__(self, message = ""):
'''
constructor with message
@param message: message show when exception is raised
'''
"""
Exception.__init__(self, message)

View File

@@ -30,7 +30,7 @@ from twisted.internet import protocol
from rdpy.network.layer import RawLayer, LayerMode
from rdpy.network.type import UInt8, UInt16Be, UInt32Be, SInt32Be, String, CompositeType
from rdpy.network.const import ConstAttributes, TypeAttributes
from rdpy.network.error import UnRegistredObject, InvalidValue
from rdpy.network.error import InvalidValue
@ConstAttributes
@TypeAttributes(String)
@@ -520,7 +520,7 @@ class RFBController(object):
print "Try to send an invalid pointer event"
class Factory(protocol.Factory):
class ClientFactory(protocol.Factory):
"""
Twisted Factory of RFB protocol
"""
@@ -560,9 +560,6 @@ class RFBClientObserver(object):
@param isPressed: state of key
@param key: ascii code of key
"""
if self._controller is None:
raise UnRegistredObject("RFBClientObserver need to be registred to a RFBController object")
self._controller.sendKeyEvent(isPressed, key)
def mouseEvent(self, button, x, y):
@@ -572,8 +569,6 @@ class RFBClientObserver(object):
@param x: x coordinate of mouse pointer
@param y: y coordinate of mouse pointer
"""
if self._controller is None:
raise UnRegistredObject("RFBClientObserver need to be registred to a RFBController object")
mask = 0
if button == 1:
mask = 1