Ejemplo n.º 1
0
 def _setIQResult(self, tag):
     if self._step == ENTRY_STEP.GET_DISCO_INFO:
         identity, features = disco.DiscoInfoHandler().handleTag(tag)
         if identity is None or identity.category != 'conference':
             g_logOutput.warning(_LOG.MESSAGE, 'Room info is not found', tag.getXml())
             self.clear()
             return
         self._room.setName(identity.name)
         self._step = ENTRY_STEP.SEND_PRESENCE
         self._sendPresence(chat_ext.MUCEntryQuery(self._getUserJID()))
     return
Ejemplo n.º 2
0
 def registerHandler(self, event, handler):
     if event in GLOOX_EVENT.ALL:
         handlers = self.__handlers[event]
         if handler in handlers:
             g_logOutput.warning(CLIENT_LOG_AREA.PY_WRAPPER, 'handler already exists', event, handler)
         elif not hasattr(handler, '__self__') or not isinstance(handler.__self__, ClientEventsHandler):
             g_logOutput.error(CLIENT_LOG_AREA.PY_WRAPPER, 'Class of handler is not subclass of ClientEventsHandler', handler)
             return 
         if callable(handler):
             handlers.add(handler)
         else:
             g_logOutput.error(CLIENT_LOG_AREA.PY_WRAPPER, 'Handler is invalid', handler)
     else:
         g_logOutput.error(CLIENT_LOG_AREA.PY_WRAPPER, 'Event is not found', event)
Ejemplo n.º 3
0
 def __doConnect(self):
     client = self.client()
     if not client.isDisconnected():
         g_logOutput.warning(CLIENT_LOG_AREA.CONNECTION, 'Client already is connected(ing)', client.getConnectionAddress(), client.getConnectionState())
         return
     jid = self.__connectionsInfo.getPlayerFullJID()
     if jid:
         cType, host, port = self.__connectionsInfo.getNextConnection()
         g_logOutput.debug(CLIENT_LOG_AREA.CONNECTION, 'Connect to XMPP sever', jid, host, port)
         if cType == CONNECTION_IMPL_TYPE.TCP:
             client.connect(str(jid), host, port)
         elif cType == CONNECTION_IMPL_TYPE.BOSH:
             client.connectBosh(str(jid), host, port, '/bosh/')
         else:
             g_logOutput.error(CLIENT_LOG_AREA.CONNECTION, 'This type of connection is not supported', cType)
     else:
         g_logOutput.error(CLIENT_LOG_AREA.CONNECTION, 'JID is empty')
Ejemplo n.º 4
0
    def init(self):
        client = self.__client
        ClientHolder._clearClient()
        for (handlerName, listenerName,) in _GLOOX_EVENTS_LISTENERS:
            if not hasattr(client, handlerName):
                g_logOutput.error(CLIENT_LOG_AREA.PY_WRAPPER, 'Handler no is found', handlerName)
                continue
            handler = getattr(client, handlerName)
            if handler:
                g_logOutput.warning(CLIENT_LOG_AREA.PY_WRAPPER, 'Handler already is set', handlerName)
                continue
            listener = getattr(self, listenerName, None)
            if listener is None or not callable(listener):
                g_logOutput.error(CLIENT_LOG_AREA.PY_WRAPPER, 'Listener no is found', listenerName)
                continue
            setattr(client, handlerName, listener)

        ClientEventsHandler._setClient(self)
Ejemplo n.º 5
0
 def __doLogin(self):
     client = self.client()
     if not client.isConnecting():
         g_logOutput.warning(CLIENT_LOG_AREA.LOGIN, 'Client is not connecting', client.getConnectionAddress(), client.getConnectionState())
         yield lambda callback: callback(None)
         return
     g_logOutput.debug(CLIENT_LOG_AREA.TOKEN, 'Sends request to SPA')
     response = yield self.__tokenRequester.request()
     g_logOutput.debug(CLIENT_LOG_AREA.TOKEN, 'Response is received from SPA', response)
     if not response:
         g_logOutput.error(CLIENT_LOG_AREA.TOKEN, 'Received chat token is empty')
         return
     if response.isValid():
         if response.getDatabaseID() == getPlayerDatabaseID():
             g_logOutput.debug(CLIENT_LOG_AREA.LOGIN, 'Login to XMPP sever')
             client.login(response.getCredential())
         else:
             g_logOutput.error(CLIENT_LOG_AREA.LOGIN, "Player's database ID mismatch", getPlayerDatabaseID())
     else:
         g_logOutput.warning(CLIENT_LOG_AREA.TOKEN, 'Received chat token is not valid', response)
         self.__handleTokenError()
Ejemplo n.º 6
0
 def registerHandler(self, event, handler):
     if event in GLOOX_EVENT.ALL:
         handlers = self.__handlers[event]
         if handler in handlers:
             g_logOutput.warning(CLIENT_LOG_AREA.PY_WRAPPER,
                                 'handler already exists', event, handler)
         else:
             if not hasattr(handler, '__self__') or not isinstance(
                     handler.__self__, ClientEventsHandler):
                 g_logOutput.error(
                     CLIENT_LOG_AREA.PY_WRAPPER,
                     'Class of handler is not subclass of ClientEventsHandler',
                     handler)
                 return
             if callable(handler):
                 handlers.add(handler)
             else:
                 g_logOutput.error(CLIENT_LOG_AREA.PY_WRAPPER,
                                   'Handler is invalid', handler)
     else:
         g_logOutput.error(CLIENT_LOG_AREA.PY_WRAPPER, 'Event is not found',
                           event)
Ejemplo n.º 7
0
 def __doConnect(self):
     client = self.client()
     if not client.isDisconnected():
         g_logOutput.warning(CLIENT_LOG_AREA.CONNECTION,
                             'Client already is connected(ing)',
                             client.getConnectionAddress(),
                             client.getConnectionState())
         return
     jid = self.__connectionsInfo.getPlayerFullJID()
     if jid:
         cType, host, port = self.__connectionsInfo.getNextConnection()
         g_logOutput.debug(CLIENT_LOG_AREA.CONNECTION,
                           'Connect to XMPP sever', jid, host, port)
         if cType == CONNECTION_IMPL_TYPE.TCP:
             client.connect(str(jid), host, port)
         elif cType == CONNECTION_IMPL_TYPE.BOSH:
             client.connectBosh(str(jid), host, port, '/bosh/')
         else:
             g_logOutput.error(CLIENT_LOG_AREA.CONNECTION,
                               'This type of connection is not supported',
                               cType)
     else:
         g_logOutput.error(CLIENT_LOG_AREA.CONNECTION, 'JID is empty')
Ejemplo n.º 8
0
 def __removeFromLocalXmppRoster(self, jid):
     if self.xmppRoster.hasItem(jid):
         g_logOutput.debug(CLIENT_LOG_AREA.SYNC, 'Contact is removed from local XMPP roster', jid, self.xmppRoster[jid].name)
         self.xmppRoster.pop(jid).clear()
     else:
         g_logOutput.warning(CLIENT_LOG_AREA.SYNC, 'Roster item is not found', jid)