예제 #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);
        }
      }
    }
예제 #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);
      }
    }
  }
예제 #3
0
  /**
   * Creates a <tt>ChatRoomWrapper</tt> by specifying the corresponding chat room.
   *
   * @param chatRoom the chat room to which this wrapper corresponds.
   */
  public ChatRoomWrapper(ChatRoom chatRoom) {
    this(chatRoom.getParentProvider(), chatRoom.getIdentifier(), chatRoom.getName());

    this.chatRoom = chatRoom;
  }
예제 #4
0
 public static ChatRoom getChatRoom(String name) {
   for (ChatRoom room : chatRooms) {
     if (name.equals(room.getName())) return room;
   }
   return null;
 }