src/eric7/RemoteServerInterface/EricServerInterface.py

branch
server
changeset 10539
4274f189ff78
parent 10531
3308e8349e4c
child 10546
300487f5f517
equal deleted inserted replaced
10531:3308e8349e4c 10539:4274f189ff78
31 @signal showMenu(name:str, menu:QMenu) emitted when a menu is about to be shown. 31 @signal showMenu(name:str, menu:QMenu) emitted when a menu is about to be shown.
32 The name of the menu and a reference to the menu are given. 32 The name of the menu and a reference to the menu are given.
33 33
34 @signal connectionStateChanged(state:bool) emitted to indicate a change of the 34 @signal connectionStateChanged(state:bool) emitted to indicate a change of the
35 connection state 35 connection state
36 @signal aboutToDisconnect() emitted just befor the remote server is disconnected
37
36 @signal remoteReply(category:int, request:str, params:dict) emitted to deliver the 38 @signal remoteReply(category:int, request:str, params:dict) emitted to deliver the
37 reply of an unknown category 39 reply of an unknown category
38 @signal remoteDebuggerReply(request:str, params:dict) emitted to deliver the reply 40 @signal remoteDebuggerReply(request:str, params:dict) emitted to deliver the reply
39 of a remote server debugger request 41 of a remote server debugger request
40 @signal remoteEchoReply(request:str, params:dict) emitted to deliver the reply of 42 @signal remoteEchoReply(request:str, params:dict) emitted to deliver the reply of
47 of a remote server control request 49 of a remote server control request
48 """ 50 """
49 51
50 showMenu = pyqtSignal(str, QMenu) 52 showMenu = pyqtSignal(str, QMenu)
51 53
54 aboutToDisconnect = pyqtSignal()
52 connectionStateChanged = pyqtSignal(bool) 55 connectionStateChanged = pyqtSignal(bool)
53 56
54 remoteReply = pyqtSignal(int, str, dict) 57 remoteReply = pyqtSignal(int, str, dict)
55 58
56 remoteDebuggerReply = pyqtSignal(str, dict) 59 remoteDebuggerReply = pyqtSignal(str, dict)
75 EricRequestCategory.Echo: self.remoteEchoReply, 78 EricRequestCategory.Echo: self.remoteEchoReply,
76 EricRequestCategory.FileSystem: self.remoteFileSystemReply, 79 EricRequestCategory.FileSystem: self.remoteFileSystemReply,
77 EricRequestCategory.Project: self.remoteProjectReply, 80 EricRequestCategory.Project: self.remoteProjectReply,
78 EricRequestCategory.Server: self.remoteServerReply, 81 EricRequestCategory.Server: self.remoteServerReply,
79 } 82 }
83 self.__serviceInterfaces = {}
84 # no specific service interfaces have been created yet
80 85
81 self.__connection = None 86 self.__connection = None
82 self.__callbacks = {} # callback references indexed by UUID 87 self.__callbacks = {} # callback references indexed by UUID
83 88
84 self.connectionStateChanged.connect(self.__connectionStateChanged) 89 self.connectionStateChanged.connect(self.__connectionStateChanged)
90
91 def getServiceInterface(self, name):
92 """
93 Public method to get a references to a specific service interface by
94 service name.
95
96 @param name service name
97 @type str
98 @return reference to the service interface
99 @rtype QObject
100 """
101 lname = name.lower()
102 try:
103 return self.__serviceInterfaces[lname]
104 except KeyError:
105 # instantiate the service interface
106 if lname == "filesystem":
107 from .EricServerFileSystemInterface import EricServerFileSystemInterface
108 self.__serviceInterfaces[lname] = EricServerFileSystemInterface(self)
109 elif lname == "debugger":
110 # TODO: not implemented yet
111 pass
112 elif lname == "project":
113 # TODO: not implemented yet
114 pass
115 else:
116 raise ValueError(f"no such service supported ({name})")
117
118 return self.__serviceInterfaces[lname]
85 119
86 ####################################################################### 120 #######################################################################
87 ## Methods for handling the server connection. 121 ## Methods for handling the server connection.
88 ####################################################################### 122 #######################################################################
89 123
141 def disconnectFromServer(self): 175 def disconnectFromServer(self):
142 """ 176 """
143 Public method to disconnect from the eric remote server. 177 Public method to disconnect from the eric remote server.
144 """ 178 """
145 if self.__connection is not None and self.__connection.isValid(): 179 if self.__connection is not None and self.__connection.isValid():
180 # signal we are abouzt to disconnect
181 self.aboutToDisconnect.emit()
182
183 # disconnect from the eric-ide server
146 self.__connection.disconnectFromHost() 184 self.__connection.disconnectFromHost()
147 if self.__connection is not None: 185 if self.__connection is not None:
148 # may have disconnected already 186 # may have disconnected already
149 self.__connection.waitForDisconnected( 187 self.__connection.waitForDisconnected(
150 Preferences.getEricServer("ConnectionTimeout") * 1000 188 Preferences.getEricServer("ConnectionTimeout") * 1000

eric ide

mercurial