Exemple #1
0
    def __handleIQ(self, iqID, iqType, pyGlooxTag):
        if iqID != self.__iqID:
            return
        else:
            result, error = self.__cached.copy(), None
            self.__cached.clear()
            self.__iqID = ''
            if iqType == IQ_TYPE.RESULT:
                handler = spa_resolver.SpaResolverHandler()
                getter = self.usersStorage.getUser
                setter = self.usersStorage.addUser
                errorOutput = g_logOutput.error
                for dbID, name, error in handler.handleTag(pyGlooxTag):
                    if error:
                        errorOutput(CLIENT_LOG_AREA.PY_WRAPPER,
                                    'Item is invalid', dbID, name, error)
                        continue
                    user = getter(dbID)
                    if not user:
                        user = SharedUserEntity(dbID, name)
                        setter(user)
                    else:
                        user.update(name=name)
                    result[dbID] = name

            elif iqType == IQ_TYPE.ERROR:
                error = createServerIQError(pyGlooxTag)
            self.__doCallback(result=result, error=error)
            return
    def __handleIQ(self, iqID, iqType, pyGlooxTag):
        if iqID != self.__iqID:
            return
        else:
            result, error = self.__cached.copy(), None
            self.__cached.clear()
            self.__iqID = ''
            if iqType == IQ_TYPE.RESULT:
                handler = spa_resolver.SpaResolverHandler()
                getter = self.usersStorage.getUser
                setter = self.usersStorage.addUser
                errorOutput = g_logOutput.error
                for dbID, name, error in handler.handleTag(pyGlooxTag):
                    if error:
                        errorOutput(CLIENT_LOG_AREA.PY_WRAPPER, 'Item is invalid', dbID, name, error)
                        continue
                    user = getter(dbID)
                    if not user:
                        user = SharedUserEntity(dbID, name)
                        setter(user)
                    else:
                        user.update(name=name)
                    result[dbID] = name

            elif iqType == IQ_TYPE.ERROR:
                error = createServerIQError(pyGlooxTag)
            self.__doCallback(result=result, error=error)
            return
Exemple #3
0
 def __onIQReceived(self, iqID, iqType, pyGlooxTag):
     if self._lastRequestID != iqID:
         return
     if iqType == IQ_TYPE.ERROR:
         error = createServerIQError(pyGlooxTag)
         if error:
             reason = error.getMessage()
         else:
             reason = ''
             LOG_WARNING('Search error is not resolved on the client', pyGlooxTag.getXml())
         self._onSearchFailed(reason)
     else:
         users = self.__OnSuccesResponse(pyGlooxTag)
         self._onSearchTokenComplete(iqID, users)
 def __onIQReceived(self, iqID, iqType, pyGlooxTag):
     """
     Process iq response form xmpp server
     :param iqID: iq id sequence number
     :param iqType: iq type (get/set)
     :param pyGlooxTag: xmpp parser wrapper
     :return: None
     """
     if self._lastRequestID != iqID:
         return
     if iqType == IQ_TYPE.ERROR:
         error = createServerIQError(pyGlooxTag)
         if error:
             reason = error.getMessage()
         else:
             reason = ''
             LOG_WARNING('Search error is not resolved on the client', pyGlooxTag.getXml())
         self._onSearchFailed(reason)
     else:
         users = self.__OnSuccesResponse(pyGlooxTag)
         self._onSearchTokenComplete(iqID, users)