Example #1
0
    /** @override {@link Thread}{@link #run()} to perform all asynchronous tasks. */
    @Override
    public void run() {
      ChatRoom chatRoom = chatRoomWrapper.getChatRoom();

      try {
        if (password != null && password.length > 0) chatRoom.joinAs(nickName, password);
        else if (nickName != null) chatRoom.joinAs(nickName);
        else chatRoom.join();

        done(JOIN_SUCCESS_PROP);
      } catch (OperationFailedException e) {
        if (logger.isTraceEnabled())
          logger.trace("Failed to join chat room: " + chatRoom.getName(), e);

        switch (e.getErrorCode()) {
          case OperationFailedException.AUTHENTICATION_FAILED:
            done(JOIN_AUTHENTICATION_FAILED_PROP);
            break;
          case OperationFailedException.REGISTRATION_REQUIRED:
            done(JOIN_REGISTRATION_REQUIRED_PROP);
            break;
          case OperationFailedException.PROVIDER_NOT_REGISTERED:
            done(JOIN_PROVIDER_NOT_REGISTERED_PROP);
            break;
          case OperationFailedException.SUBSCRIPTION_ALREADY_EXISTS:
            done(JOIN_SUBSCRIPTION_ALREADY_EXISTS_PROP);
            break;
          default:
            done(JOIN_UNKNOWN_ERROR_PROP);
        }
      }
    }
Example #2
0
  /**
   * Adds found result to the query results.
   *
   * @param room the chat room.
   * @param addQueryResult indicates whether we should add the chat room to the query results or
   *     fire an event without adding it to the results.
   * @param isAutoJoin the auto join state of the contact.
   */
  private void addChatRoom(ChatRoom room, boolean addQueryResult, boolean isAutoJoin) {
    if (queryString == null
        || ((room.getName().contains(queryString) || room.getIdentifier().contains(queryString)))) {
      ChatRoomSourceContact contact = new ChatRoomSourceContact(room, this, isAutoJoin);
      synchronized (contactResults) {
        contactResults.add(contact);
      }

      if (addQueryResult) {
        addQueryResult(contact, false);
      } else {
        fireContactReceived(contact, false);
      }
    }
  }