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
def _validateAccountName(name): errorID = validateAccountName(name)[1] if errorID: error = ClientError(errorID, strArg1=name) else: error = None return error
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)
def wrapper(*args, **kwargs): if not self.sessionProvider.arenaVisitor.isArenaInWaiting(): func(*args, **kwargs) else: g_messengerEvents.onErrorReceived( ClientError(CLIENT_ERROR_ID.WAITING_BEFORE_START))
def _validateDatabaseID(dbID): if not dbID: return ClientError(CLIENT_ERROR_ID.DBID_INVALID) else: return None
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)
def wrapper(*args, **kwargs): if not isArenaInWaiting(): func(*args, **kwargs) else: g_messengerEvents.onErrorReceived( ClientError(CLIENT_ERROR_ID.WAITING_BEFORE_START))