Пример #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;
    }
Пример #3
0
  /**
   * Determines whether a specific <code>ChatRoom</code> is private i.e. represents a one-to-one
   * conversation which is not a channel. Since the interface {@link ChatRoom} does not expose the
   * private property, an heuristic is used as a workaround: (1) a system <code>ChatRoom</code> is
   * obviously not private and (2) a <code>ChatRoom</code> is private if it has only one <code>
   * ChatRoomMember</code> who is not the local user.
   *
   * @param chatRoom the <code>ChatRoom</code> to be determined as private or not
   * @return <tt>true</tt> if the specified <code>ChatRoom</code> is private; otherwise,
   *     <tt>false</tt>
   */
  public static boolean isPrivate(ChatRoom chatRoom) {
    if (!chatRoom.isSystem() && chatRoom.isJoined() && (chatRoom.getMembersCount() == 1)) {
      String nickname = chatRoom.getUserNickname();

      if (nickname != null) {
        for (ChatRoomMember member : chatRoom.getMembers())
          if (nickname.equals(member.getName())) return false;
        return true;
      }
    }
    return false;
  }