Beispiel #1
0
    def resolve(self, dbIDs, callback=None):
        self.__callback = callback
        if not self.__isRegistered:
            self.__doCallback(error=ClientError(CLIENT_ERROR_ID.GENERIC))
            return False
        if self.__iqID:
            self.__doCallback(error=ClientError(CLIENT_ERROR_ID.LOCKED))
            return False
        getter = self.usersStorage.getUser
        result, required = {}, []
        for dbID in dbIDs:
            user = getter(dbID)
            if user and user.hasValidName():
                result[dbID] = user.getName()
            required.append(dbID)

        if not required:
            self.__doCallback(result=result)
            return False
        client = self.client()
        if not client or not client.isConnected():
            self.__doCallback(error=ClientError(CLIENT_ERROR_ID.NOT_CONNECTED))
            return False
        self.__cached = result
        self.__callback = callback
        self.__iqID = client.sendIQ(
            spa_resolver.SpaResolverByIDsQuery(required))
        return True
Beispiel #2
0
def _validateAccountName(name):
    errorID = validateAccountName(name)[1]
    if errorID:
        error = ClientError(errorID, strArg1=name)
    else:
        error = None
    return error
Beispiel #3
0
    def _validate(self, *args):
        if not self._sign:
            return None
        data = args[1:]
        if len(self._sign) > len(data):
            seq = list(self._sign)
            while len(seq) > len(data):
                sign = seq.pop()
                if sign not in _QUERY_OPT_SIGNS:
                    return ClientError(CLIENT_ERROR_ID.WRONG_ARGS)

        else:
            seq = self._sign[:]
        for index, sign in enumerate(seq):
            if sign in _QUERY_SIGN_VALIDATORS:
                validator = _QUERY_SIGN_VALIDATORS[sign]
                if validator and callable(validator):
                    error = validator(data[index])
                    if error:
                        return error
 def canCancelFriendship(self, contact):
     return (False, ClientError(CLIENT_ERROR_ID.NOT_CONNECTED)
             ) if not self.client() or not self.client().isConnected(
             ) else self.__subsRestrictions.canCancelFriendship(contact)
Beispiel #5
0
 def wrapper(*args, **kwargs):
     if not self.sessionProvider.arenaVisitor.isArenaInWaiting():
         func(*args, **kwargs)
     else:
         g_messengerEvents.onErrorReceived(
             ClientError(CLIENT_ERROR_ID.WAITING_BEFORE_START))
Beispiel #6
0
def _validateDatabaseID(dbID):
    if not dbID:
        return ClientError(CLIENT_ERROR_ID.DBID_INVALID)
    else:
        return None
Beispiel #7
0
 def _validate(self, *args):
     client = self.client()
     if not client or not client.isConnected():
         return ClientError(CLIENT_ERROR_ID.NOT_CONNECTED)
     return super(xmpp_query, self)._validate(*args)
Beispiel #8
0
 def wrapper(*args, **kwargs):
     if not isArenaInWaiting():
         func(*args, **kwargs)
     else:
         g_messengerEvents.onErrorReceived(
             ClientError(CLIENT_ERROR_ID.WAITING_BEFORE_START))