Esempio n. 1
0
  /**
   * Called to accept an incoming invitation. Adds the invitation chat room to the list of chat
   * rooms and joins it.
   *
   * @param invitation the invitation to accept.
   */
  public void acceptInvitation(ChatRoomInvitation invitation) {
    ChatRoom chatRoom = invitation.getTargetChatRoom();
    byte[] password = invitation.getChatRoomPassword();

    String nickName = chatRoom.getParentProvider().getAccountID().getUserID();

    joinChatRoom(chatRoom, nickName, password);
  }
Esempio n. 2
0
  /**
   * Searches for chat room wrapper in chat room list by chat room.
   *
   * @param chatRoom the chat room.
   * @param create if <tt>true</tt> and the chat room wrapper is not found new chatRoomWrapper is
   *     created.
   * @return found chat room wrapper or the created chat room wrapper.
   */
  @Override
  public ChatRoomWrapper getChatRoomWrapperByChatRoom(ChatRoom chatRoom, boolean create) {
    ChatRoomWrapper chatRoomWrapper = chatRoomList.findChatRoomWrapperFromChatRoom(chatRoom);

    if ((chatRoomWrapper == null) && create) {
      ChatRoomProviderWrapper parentProvider =
          chatRoomList.findServerWrapperFromProvider(chatRoom.getParentProvider());

      chatRoomWrapper = new ChatRoomWrapperImpl(parentProvider, chatRoom);

      chatRoomList.addChatRoom(chatRoomWrapper);
    }
    return chatRoomWrapper;
  }
Esempio n. 3
0
  /**
   * Joins the given chat room and manages all the exceptions that could occur during the join
   * process.
   *
   * @param chatRoom the chat room to join
   * @param nickname the nickname we're using to join
   * @param password the password we're using to join
   */
  public void joinChatRoom(ChatRoom chatRoom, String nickname, byte[] password) {
    ChatRoomWrapper chatRoomWrapper = chatRoomList.findChatRoomWrapperFromChatRoom(chatRoom);

    if (chatRoomWrapper == null) {
      ChatRoomProviderWrapper parentProvider =
          chatRoomList.findServerWrapperFromProvider(chatRoom.getParentProvider());

      chatRoomWrapper = new ChatRoomWrapperImpl(parentProvider, chatRoom);

      chatRoomList.addChatRoom(chatRoomWrapper);

      fireChatRoomListChangedEvent(chatRoomWrapper, ChatRoomListChangeEvent.CHAT_ROOM_ADDED);
    }

    this.joinChatRoom(chatRoomWrapper, nickname, password);
  }
Esempio n. 4
0
  /**
   * Joins the room with the given name though the given chat room provider.
   *
   * @param chatRoomName the name of the room to join.
   * @param chatRoomProvider the chat room provider to join through.
   */
  public void joinChatRoom(String chatRoomName, ChatRoomProviderWrapper chatRoomProvider) {
    OperationSetMultiUserChat groupChatOpSet =
        chatRoomProvider.getProtocolProvider().getOperationSet(OperationSetMultiUserChat.class);

    ChatRoom chatRoom = null;
    try {
      chatRoom = groupChatOpSet.findRoom(chatRoomName);
    } catch (Exception e) {
      if (logger.isTraceEnabled())
        logger.trace("Un exception occurred while searching for room:" + chatRoomName, e);
    }

    if (chatRoom != null) {
      ChatRoomWrapper chatRoomWrapper = chatRoomList.findChatRoomWrapperFromChatRoom(chatRoom);

      if (chatRoomWrapper == null) {
        ChatRoomProviderWrapper parentProvider =
            chatRoomList.findServerWrapperFromProvider(chatRoom.getParentProvider());

        chatRoomWrapper = new ChatRoomWrapperImpl(parentProvider, chatRoom);

        chatRoomList.addChatRoom(chatRoomWrapper);

        fireChatRoomListChangedEvent(chatRoomWrapper, ChatRoomListChangeEvent.CHAT_ROOM_ADDED);
      }
      joinChatRoom(chatRoomWrapper);
    } else
      MUCActivator.getAlertUIService()
          .showAlertDialog(
              MUCActivator.getResources().getI18NString("service.gui.ERROR"),
              MUCActivator.getResources()
                  .getI18NString(
                      "service.gui.CHAT_ROOM_NOT_EXIST",
                      new String[] {
                        chatRoomName,
                        chatRoomProvider.getProtocolProvider().getAccountID().getService()
                      }));
  }