Example #1
0
  /**
   * Leaves the given chat room.
   *
   * @param chatRoomWrapper the chat room to leave.
   * @return <tt>ChatRoomWrapper</tt> instance associated with the chat room.
   */
  public ChatRoomWrapper leaveChatRoom(ChatRoomWrapper chatRoomWrapper) {
    ChatRoom chatRoom = chatRoomWrapper.getChatRoom();

    if (chatRoom == null) {
      ResourceManagementService resources = MUCActivator.getResources();

      MUCActivator.getAlertUIService()
          .showAlertDialog(
              resources.getI18NString("service.gui.WARNING"),
              resources.getI18NString("service.gui.CHAT_ROOM_LEAVE_NOT_CONNECTED"));

      return null;
    }

    if (chatRoom.isJoined()) chatRoom.leave();

    ChatRoomWrapper existChatRoomWrapper = chatRoomList.findChatRoomWrapperFromChatRoom(chatRoom);

    if (existChatRoomWrapper == null) return null;

    // We save the choice of the user, before the chat room is really
    // joined, because even the join fails we want the next time when
    // we login to join this chat room automatically.
    ConfigurationUtils.updateChatRoomStatus(
        chatRoomWrapper.getParentProvider().getProtocolProvider(),
        chatRoomWrapper.getChatRoomID(),
        GlobalStatusEnum.OFFLINE_STATUS);

    return existChatRoomWrapper;
  }
    /**
     * Checks if the menu item should be enabled or disabled.
     *
     * @param contact the contact associated with the menu item.
     * @return <tt>true</tt> if the item should be enabled and <tt>false</tt> if not.
     */
    public boolean check(SourceContact contact) {
      ChatRoomWrapper chatRoomWrapper =
          MUCActivator.getMUCService().findChatRoomWrapperFromSourceContact(contact);
      ChatRoom chatRoom = null;
      if (chatRoomWrapper != null) {
        chatRoom = chatRoomWrapper.getChatRoom();
      }

      if ((chatRoom != null) && chatRoom.isJoined()) return false;
      return true;
    }