AnemoneLabs / unmessage

Privacy enhanced instant messenger
GNU General Public License v3.0
43 stars 7 forks source link

Create an interface for managers #56

Open felipedau opened 7 years ago

felipedau commented 7 years ago

While working on the file transfer I noticed I had not created an interface for managers. If a new manager was to be created, the following interface would have to be used (based on the attributes/methods created to implement FileSession):

class IManager:
    type_ = None
    element_classes = list()

    conversation = None
    connection = None

    def send_data(self, data):
        pass

    def receive_data(self, data, connection=None):
        pass

    def stop(self):
        pass

    def notify_disconnect(self):
        pass

This still has to be improved as these attributes/methods are not abstract enough and might cause issues in the future.

Another change is that parse class methods should be created so that the logic of parsing received elements move from ElementParser to their respective manager. ElementParser should be used just as a mapper from element to manager, like the new _parse_file*_element methods.

Finally, these managers should be renamed from *Session to *Manager and leave it up to each manager if they support single or multiple sessions.