/**
     * Extract values from <tt>EventObject</tt>.
     *
     * @param source
     */
    public void update(EventObject source) {
      this.eventObject = source;

      if (source instanceof MessageDeliveredEvent) {
        MessageDeliveredEvent e = (MessageDeliveredEvent) source;

        this.contact = e.getDestinationContact();

        this.address = contact.getAddress();
        this.ppService = contact.getProtocolProvider();
        this.timestamp = e.getTimestamp();
      } else if (source instanceof MessageReceivedEvent) {
        MessageReceivedEvent e = (MessageReceivedEvent) source;

        this.contact = e.getSourceContact();

        this.address = contact.getAddress();
        this.ppService = contact.getProtocolProvider();
        this.timestamp = e.getTimestamp();
      } else if (source instanceof ChatRoomMessageDeliveredEvent) {
        ChatRoomMessageDeliveredEvent e = (ChatRoomMessageDeliveredEvent) source;

        this.room = e.getSourceChatRoom();

        this.address = room.getIdentifier();
        this.ppService = room.getParentProvider();
        this.timestamp = e.getTimestamp();
      } else if (source instanceof ChatRoomMessageReceivedEvent) {
        ChatRoomMessageReceivedEvent e = (ChatRoomMessageReceivedEvent) source;

        this.room = e.getSourceChatRoom();

        this.address = room.getIdentifier();
        this.ppService = room.getParentProvider();
        this.timestamp = e.getTimestamp();
      }
    }
Example #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);
      }
    }
  }
Example #3
0
 /**
  * Test equality of contact to chat room. This test recognizes that chat rooms may have equal
  * names but connected to different accounts.
  *
  * @param contact the contact
  * @param chatRoom the chat room
  * @return returns <tt>true</tt> if they are equal, or <tt>false</tt> if they are different
  */
 private boolean contactEqualsChatRoom(
     final ChatRoomSourceContact contact, final ChatRoom chatRoom) {
   return contact.getProvider() == chatRoom.getParentProvider()
       && chatRoom.getIdentifier().equals(contact.getContactAddress());
 }
Example #4
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;
  }