@Override
    public boolean isVisible(SourceContact actionSource) {
      if (!(actionSource instanceof ChatRoomSourceContact)) return false;

      if (name.equals("autojoin") || name.equals("autojoin_pressed")) {
        ChatRoomSourceContact contact = (ChatRoomSourceContact) actionSource;
        ChatRoomWrapper room =
            MUCActivator.getMUCService().findChatRoomWrapperFromSourceContact(contact);
        if (name.equals("autojoin")) return !room.isAutojoin();

        if (name.equals("autojoin_pressed")) return room.isAutojoin();
      }
      return true;
    }
    @Override
    public boolean isVisible(SourceContact actionSource) {
      if (actionSource instanceof ChatRoomSourceContact) {
        if (name.equals("leave")) {
          return actionsEnabledCheckers[3].check(actionSource);
        } else if (name.equals("join")) {
          return actionsEnabledCheckers[1].check(actionSource);
        } else {
          ChatRoomSourceContact contact = (ChatRoomSourceContact) actionSource;
          ChatRoomWrapper room =
              MUCActivator.getMUCService().findChatRoomWrapperFromSourceContact(contact);
          if (room == null) return false;

          if (name.equals("autojoin")) return room.isAutojoin();
          else if (name.equals("autojoin_pressed")) return !room.isAutojoin();
        }
      }
      return false;
    }
Exemplo n.º 3
0
  /**
   * Handles adding a chat room provider.
   *
   * @param provider the provider.
   * @param addQueryResult indicates whether we should add the chat room to the query results or
   *     fire an event without adding it to the results.
   */
  private void providerAdded(ChatRoomProviderWrapper provider, boolean addQueryResult) {

    for (int i = 0; i < provider.countChatRooms(); i++) {
      ChatRoomWrapper chatRoom = provider.getChatRoom(i);
      addChatRoom(
          provider.getProtocolProvider(),
          chatRoom.getChatRoomName(),
          chatRoom.getChatRoomID(),
          addQueryResult,
          chatRoom.isAutojoin());
    }
  }
Exemplo n.º 4
0
  /**
   * Indicates that a change has occurred in the chat room data list.
   *
   * @param evt the event that describes the change.
   */
  @Override
  public void contentChanged(final ChatRoomListChangeEvent evt) {
    ChatRoomWrapper chatRoom = evt.getSourceChatRoom();
    switch (evt.getEventID()) {
      case ChatRoomListChangeEvent.CHAT_ROOM_ADDED:
        addChatRoom(chatRoom.getChatRoom(), false, chatRoom.isAutojoin());
        break;
      case ChatRoomListChangeEvent.CHAT_ROOM_REMOVED:
        LinkedList<ChatRoomSourceContact> tmpContactResults;
        synchronized (contactResults) {
          tmpContactResults = new LinkedList<ChatRoomSourceContact>(contactResults);

          for (ChatRoomSourceContact contact : tmpContactResults) {
            if (contactEqualsChatRoom(contact, chatRoom)) {
              contactResults.remove(contact);
              fireContactRemoved(contact);
              break;
            }
          }
        }
        break;
      case ChatRoomListChangeEvent.CHAT_ROOM_CHANGED:
        synchronized (contactResults) {
          for (ChatRoomSourceContact contact : contactResults) {
            if (contactEqualsChatRoom(contact, chatRoom.getChatRoom())) {
              if (chatRoom.isAutojoin() != contact.isAutoJoin()) {
                contact.setAutoJoin(chatRoom.isAutojoin());
                fireContactChanged(contact);
              }
              break;
            }
          }
        }
        break;
      default:
        break;
    }
  }
Exemplo n.º 5
0
  /**
   * Handles chat room presence status updates.
   *
   * @param evt the <tt>LocalUserChatRoomPresenceChangeEvent</tt> instance containing the chat room
   *     and the type, and reason of the change
   */
  @Override
  public void localUserPresenceChanged(LocalUserChatRoomPresenceChangeEvent evt) {
    ChatRoom sourceChatRoom = evt.getChatRoom();

    String eventType = evt.getEventType();

    boolean existingContact = false;
    ChatRoomSourceContact foundContact = null;
    synchronized (contactResults) {
      for (ChatRoomSourceContact contact : contactResults) {
        if (contactEqualsChatRoom(contact, sourceChatRoom)) {
          existingContact = true;
          foundContact = contact;
          contactResults.remove(contact);
          break;
        }
      }
    }

    if (LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_JOINED.equals(eventType)) {
      if (existingContact) {
        foundContact.setPresenceStatus(ChatRoomPresenceStatus.CHAT_ROOM_ONLINE);
        synchronized (contactResults) {
          contactResults.add(foundContact);
        }
        fireContactChanged(foundContact);
      } else {
        ChatRoomWrapper chatRoom =
            MUCActivator.getMUCService().findChatRoomWrapperFromChatRoom(sourceChatRoom);
        if (chatRoom != null) addChatRoom(sourceChatRoom, false, chatRoom.isAutojoin());
      }
    } else if ((LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_LEFT.equals(eventType)
        || LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_KICKED.equals(eventType)
        || LocalUserChatRoomPresenceChangeEvent.LOCAL_USER_DROPPED.equals(eventType))) {
      if (existingContact) {
        foundContact.setPresenceStatus(ChatRoomPresenceStatus.CHAT_ROOM_OFFLINE);
        synchronized (contactResults) {
          contactResults.add(foundContact);
        }
        fireContactChanged(foundContact);
      }
    }
  }
 @Override
 public boolean isSelected(SourceContact contact) {
   ChatRoomWrapper chatRoomWrapper =
       MUCActivator.getMUCService().findChatRoomWrapperFromSourceContact(contact);
   return chatRoomWrapper.isAutojoin();
 }