--- a/src/eric7/RemoteServerInterface/EricServerInterface.py Mon Jan 29 19:50:44 2024 +0100 +++ b/src/eric7/RemoteServerInterface/EricServerInterface.py Fri Feb 02 11:29:08 2024 +0100 @@ -33,6 +33,8 @@ @signal connectionStateChanged(state:bool) emitted to indicate a change of the connection state + @signal aboutToDisconnect() emitted just befor the remote server is disconnected + @signal remoteReply(category:int, request:str, params:dict) emitted to deliver the reply of an unknown category @signal remoteDebuggerReply(request:str, params:dict) emitted to deliver the reply @@ -49,6 +51,7 @@ showMenu = pyqtSignal(str, QMenu) + aboutToDisconnect = pyqtSignal() connectionStateChanged = pyqtSignal(bool) remoteReply = pyqtSignal(int, str, dict) @@ -77,12 +80,43 @@ EricRequestCategory.Project: self.remoteProjectReply, EricRequestCategory.Server: self.remoteServerReply, } + self.__serviceInterfaces = {} + # no specific service interfaces have been created yet self.__connection = None self.__callbacks = {} # callback references indexed by UUID self.connectionStateChanged.connect(self.__connectionStateChanged) + def getServiceInterface(self, name): + """ + Public method to get a references to a specific service interface by + service name. + + @param name service name + @type str + @return reference to the service interface + @rtype QObject + """ + lname = name.lower() + try: + return self.__serviceInterfaces[lname] + except KeyError: + # instantiate the service interface + if lname == "filesystem": + from .EricServerFileSystemInterface import EricServerFileSystemInterface + self.__serviceInterfaces[lname] = EricServerFileSystemInterface(self) + elif lname == "debugger": + # TODO: not implemented yet + pass + elif lname == "project": + # TODO: not implemented yet + pass + else: + raise ValueError(f"no such service supported ({name})") + + return self.__serviceInterfaces[lname] + ####################################################################### ## Methods for handling the server connection. ####################################################################### @@ -143,6 +177,10 @@ Public method to disconnect from the eric remote server. """ if self.__connection is not None and self.__connection.isValid(): + # signal we are abouzt to disconnect + self.aboutToDisconnect.emit() + + # disconnect from the eric-ide server self.__connection.disconnectFromHost() if self.__connection is not None: # may have disconnected already