Exemplo n.º 1
0
 def init(self):
     self.__client = ClientDecorator()
     self.__contacts = ContactsManager()
     self.__connection = ConnectionHandler()
     self.__messages = MessagesManager()
     self.__logger = LogHandler()
     self.__nicknameResolver = NicknameResolver()
Exemplo n.º 2
0
class XmppPlugin(IProtoPlugin):

    def __init__(self):
        self.__client = ClientDecorator()
        self.__presence = PresenceHandler()
        self.__connection = ConnectionHandler()
        self.__logger = LogHandler()
        self.__updaters = UpdatersCollection()
        self.__isClientInited = False

    def __repr__(self):
        return 'XmppPlugin(id=0x{0:08X}, ro={1!r:s},'.format(id(self), ['client', 'logger'])

    @property
    def client(self):
        return self.__client

    @property
    def logger(self):
        return self.__logger

    def clear(self):
        self.__isClientInited = False
        self.__finiClientEnv()
        self.__connection.clear()
        self.__presence.clear()
        self.__logger.clear()

    def connect(self, scope):
        self.__presence.update(scope)

    def view(self, scope):
        if self.__client.isConnected():
            return
        if not self.__isClientInited:
            self.__isClientInited = True
            self.__initClientEnv()
        self.__connection.connect()

    def disconnect(self):
        self.__connection.disconnect()
        if self.__isClientInited:
            self.clear()

    def __initClientEnv(self):
        addDynStorage('xmppRoster', RosterItemStorage())
        self.__client.init()
        self.__updaters.init()
        self.__connection.registerHandlers()
        self.__presence.registerHandlers()
        self.__logger.registerHandlers()

    def __finiClientEnv(self):
        clearDynStorage('xmppRoster')
        self.__connection.unregisterHandlers()
        self.__presence.unregisterHandlers()
        self.__logger.unregisterHandlers()
        self.__updaters.fini()
        self.__client.fini()
Exemplo n.º 3
0
 def __init__(self):
     self.__client = ClientDecorator()
     self.__contacts = ContactsManager()
     self.__connection = ConnectionHandler()
     self.__messages = MessagesManager()
     self.__logger = LogHandler()
     self.__isClientInited = False
Exemplo n.º 4
0
 def __init__(self):
     self.__client = ClientDecorator()
     self.__presence = PresenceHandler()
     self.__connection = ConnectionHandler()
     self.__logger = LogHandler()
     self.__updaters = UpdatersCollection()
     self.__isClientInited = False
Exemplo n.º 5
0
 def __init__(self):
     self.__client = ClientDecorator()
     self.__contacts = ContactsManager()
     self.__connection = ConnectionHandler()
     self.__messages = MessagesManager()
     self.__logger = LogHandler()
     self.__nicknameResolver = NicknameResolver()
     self.__clanListener = None
     self.__isClientInited = False
     return
Exemplo n.º 6
0
class XmppPlugin(IProtoPlugin):
    __slots__ = ('__client', '__contacts', '__connection', '__logger', '__messages', '__isClientInited', '__nicknameResolver')

    def __init__(self):
        self.__client = ClientDecorator()
        self.__contacts = ContactsManager()
        self.__connection = ConnectionHandler()
        self.__messages = MessagesManager()
        self.__logger = LogHandler()
        self.__nicknameResolver = NicknameResolver()
        self.__isClientInited = False

    def __repr__(self):
        return 'XmppPlugin(id=0x{0:08X}, ro={1!r:s},'.format(id(self), ['client',
         'contacts',
         'messages',
         'logger'])

    @property
    def client(self):
        return self.__client

    @property
    def logger(self):
        return self.__logger

    @property
    def contacts(self):
        return self.__contacts

    @property
    def messages(self):
        return self.__messages

    @property
    def nicknames(self):
        return self.__nicknameResolver

    def isConnected(self):
        return self.__client.isConnected()

    def clear(self):
        if self.__isClientInited:
            self.__finiClientEnv()
        self.__isClientInited = False
        self.__connection.clear()
        self.__contacts.clear()
        self.__messages.clear()
        self.__logger.clear()
        self.__nicknameResolver.clear()

    def connect(self, scope):
        self.__contacts.switch(scope)

    def view(self, scope):
        if self.__client.isConnected():
            return
        if not self.__isClientInited:
            self.__initClientEnv()
            self.__isClientInited = True
        self.__connection.connect()

    def disconnect(self):
        self.__connection.disconnect()
        if self.__isClientInited:
            self.__isClientInited = False
            self.__finiClientEnv()
            self.__connection.clear()
            self.__logger.clear()
            self.__nicknameResolver.clear()

    def setFilters(self, msgFilterChain):
        if self.__messages:
            self.__messages.setFilters(msgFilterChain)

    def __initClientEnv(self):
        self.__client.init()
        self.__connection.registerHandlers()
        self.__contacts.registerHandlers()
        self.__messages.registerHandlers()
        self.__logger.registerHandlers()
        self.__nicknameResolver.registerHandlers()

    def __finiClientEnv(self):
        self.__connection.unregisterHandlers()
        self.__contacts.unregisterHandlers()
        self.__messages.unregisterHandlers()
        self.__logger.unregisterHandlers()
        self.__nicknameResolver.unregisterHandlers()
        self.__client.fini()
Exemplo n.º 7
0
class XmppPlugin(IProtoPlugin):
    __slots__ = ('__client', '__contacts', '__connection', '__logger',
                 '__messages', '__isClientInited', '__nicknameResolver',
                 '__clanListener')

    def __init__(self):
        self.__client = None
        self.__contacts = None
        self.__connection = None
        self.__messages = None
        self.__logger = None
        self.__nicknameResolver = None
        self.__clanListener = None
        self.__isClientInited = False
        return

    def __repr__(self):
        return 'XmppPlugin(id=0x{0:08X}, ro={1!r:s},'.format(
            id(self), ['client', 'contacts', 'messages', 'logger'])

    @property
    def client(self):
        return self.__client

    @property
    def logger(self):
        return self.__logger

    @property
    def contacts(self):
        return self.__contacts

    @property
    def messages(self):
        return self.__messages

    @property
    def nicknames(self):
        return self.__nicknameResolver

    @property
    def clanListener(self):
        return self.__clanListener

    def isConnected(self):
        return self.__client.isConnected()

    def init(self):
        self.__client = ClientDecorator()
        self.__contacts = ContactsManager()
        self.__connection = ConnectionHandler()
        self.__messages = MessagesManager()
        self.__logger = LogHandler()
        self.__nicknameResolver = NicknameResolver()

    def clear(self):
        if self.__isClientInited:
            self.__finiClientEnv()
        self.__isClientInited = False
        self.__connection.clear()
        self.__contacts.clear()
        self.__messages.clear()
        self.__logger.clear()
        self.__nicknameResolver.clear()
        if self.__clanListener is not None:
            self.__clanListener.clear()
        return

    def connect(self, scope):
        self.__contacts.switch(scope)
        self.__clanListener = self.__getClanListener()

    def view(self, scope):
        if self.__client.isConnected():
            return
        if not self.__isClientInited:
            self.__initClientEnv()
            self.__isClientInited = True
        self.__connection.connect()

    def disconnect(self):
        self.__connection.disconnect()
        if self.__isClientInited:
            self.__isClientInited = False
            self.__finiClientEnv()
            self.__connection.clear()
            self.__logger.clear()
            self.__nicknameResolver.clear()
            if self.__clanListener is not None:
                self.__clanListener.clear()
        return

    def setFilters(self, msgFilterChain):
        if self.__messages:
            self.__messages.setFilters(msgFilterChain)

    def __initClientEnv(self):
        self.__client.init()
        self.__connection.registerHandlers()
        self.__contacts.registerHandlers()
        self.__messages.registerHandlers()
        self.__logger.registerHandlers()
        self.__nicknameResolver.registerHandlers()
        if self.__clanListener:
            self.__clanListener.registerHandlers()

    def __finiClientEnv(self):
        self.__connection.unregisterHandlers()
        self.__contacts.unregisterHandlers()
        self.__messages.unregisterHandlers()
        self.__logger.unregisterHandlers()
        self.__nicknameResolver.unregisterHandlers()
        if self.__clanListener is not None:
            self.__clanListener.unregisterHandlers()
        self.__client.fini()
        return

    @classmethod
    def __getClanListener(cls):
        """Gets ClanListener instance
        :return: Instance of XmppClanListener, None if xmpp clan channels aren't enabled
        :rtype XmppClanListener
        """
        if g_settings.server.isXmppClansEnabled():
            return XmppClanListener()
        else:
            return None
Exemplo n.º 8
0
class XmppPlugin(IProtoPlugin):
    __slots__ = ('__client', '__contacts', '__connection', '__logger', '__messages', '__isClientInited', '__nicknameResolver', '__clanListener')

    def __init__(self):
        self.__client = ClientDecorator()
        self.__contacts = ContactsManager()
        self.__connection = ConnectionHandler()
        self.__messages = MessagesManager()
        self.__logger = LogHandler()
        self.__nicknameResolver = NicknameResolver()
        self.__clanListener = None
        self.__isClientInited = False
        return

    def __repr__(self):
        return 'XmppPlugin(id=0x{0:08X}, ro={1!r:s},'.format(id(self), ['client',
         'contacts',
         'messages',
         'logger'])

    @property
    def client(self):
        return self.__client

    @property
    def logger(self):
        return self.__logger

    @property
    def contacts(self):
        return self.__contacts

    @property
    def messages(self):
        return self.__messages

    @property
    def nicknames(self):
        return self.__nicknameResolver

    @property
    def clanListener(self):
        return self.__clanListener

    def isConnected(self):
        return self.__client.isConnected()

    def clear(self):
        if self.__isClientInited:
            self.__finiClientEnv()
        self.__isClientInited = False
        self.__connection.clear()
        self.__contacts.clear()
        self.__messages.clear()
        self.__logger.clear()
        self.__nicknameResolver.clear()
        if self.__clanListener is not None:
            self.__clanListener.clear()
        return

    def connect(self, scope):
        self.__contacts.switch(scope)
        self.__clanListener = self.__getClanListener()

    def view(self, scope):
        if self.__client.isConnected():
            return
        if not self.__isClientInited:
            self.__initClientEnv()
            self.__isClientInited = True
        self.__connection.connect()

    def disconnect(self):
        self.__connection.disconnect()
        if self.__isClientInited:
            self.__isClientInited = False
            self.__finiClientEnv()
            self.__connection.clear()
            self.__logger.clear()
            self.__nicknameResolver.clear()
            if self.__clanListener is not None:
                self.__clanListener.clear()
        return

    def setFilters(self, msgFilterChain):
        if self.__messages:
            self.__messages.setFilters(msgFilterChain)

    def __initClientEnv(self):
        self.__client.init()
        self.__connection.registerHandlers()
        self.__contacts.registerHandlers()
        self.__messages.registerHandlers()
        self.__logger.registerHandlers()
        self.__nicknameResolver.registerHandlers()
        if self.__clanListener:
            self.__clanListener.registerHandlers()

    def __finiClientEnv(self):
        self.__connection.unregisterHandlers()
        self.__contacts.unregisterHandlers()
        self.__messages.unregisterHandlers()
        self.__logger.unregisterHandlers()
        self.__nicknameResolver.unregisterHandlers()
        if self.__clanListener is not None:
            self.__clanListener.unregisterHandlers()
        self.__client.fini()
        return

    @classmethod
    def __getClanListener(cls):
        """Gets ClanListener instance
        :return: Instance of XmppClanListener, None if xmpp clan channels aren't enabled
        :rtype XmppClanListener
        """
        if g_settings.server.isXmppClansEnabled():
            return XmppClanListener()
        else:
            return None
            return None
Exemplo n.º 9
0
class XmppPlugin(IProtoPlugin):
    __slots__ = ('__client', '__contacts', '__connection', '__logger',
                 '__messages', '__isClientInited', '__nicknameResolver')

    def __init__(self):
        self.__client = ClientDecorator()
        self.__contacts = ContactsManager()
        self.__connection = ConnectionHandler()
        self.__messages = MessagesManager()
        self.__logger = LogHandler()
        self.__nicknameResolver = NicknameResolver()
        self.__isClientInited = False

    def __repr__(self):
        return 'XmppPlugin(id=0x{0:08X}, ro={1!r:s},'.format(
            id(self), ['client', 'contacts', 'messages', 'logger'])

    @property
    def client(self):
        return self.__client

    @property
    def logger(self):
        return self.__logger

    @property
    def contacts(self):
        return self.__contacts

    @property
    def messages(self):
        return self.__messages

    @property
    def nicknames(self):
        return self.__nicknameResolver

    def isConnected(self):
        return self.__client.isConnected()

    def clear(self):
        if self.__isClientInited:
            self.__finiClientEnv()
        self.__isClientInited = False
        self.__connection.clear()
        self.__contacts.clear()
        self.__messages.clear()
        self.__logger.clear()
        self.__nicknameResolver.clear()

    def connect(self, scope):
        self.__contacts.switch(scope)

    def view(self, scope):
        if self.__client.isConnected():
            return
        if not self.__isClientInited:
            self.__initClientEnv()
            self.__isClientInited = True
        self.__connection.connect()

    def disconnect(self):
        self.__connection.disconnect()
        if self.__isClientInited:
            self.__isClientInited = False
            self.__finiClientEnv()
            self.__connection.clear()
            self.__logger.clear()
            self.__nicknameResolver.clear()

    def setFilters(self, msgFilterChain):
        if self.__messages:
            self.__messages.setFilters(msgFilterChain)

    def __initClientEnv(self):
        self.__client.init()
        self.__connection.registerHandlers()
        self.__contacts.registerHandlers()
        self.__messages.registerHandlers()
        self.__logger.registerHandlers()
        self.__nicknameResolver.registerHandlers()

    def __finiClientEnv(self):
        self.__connection.unregisterHandlers()
        self.__contacts.unregisterHandlers()
        self.__messages.unregisterHandlers()
        self.__logger.unregisterHandlers()
        self.__nicknameResolver.unregisterHandlers()
        self.__client.fini()