git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@8378 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-05-22 23:21:41 +00:00
committed by derek
parent 80d374b00b
commit 2c61fa6f56
5 changed files with 50 additions and 6 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,44 @@
/**
* $Revision$
* $Date$
*
* Copyright (C) 1999-2005 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.spark.ui;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet;
/**
* Filters for packets where the "from" field contains a specified value.
*
* @author Matt Tucker
*/
public class FromJIDFilter implements PacketFilter {
private String from;
/**
* Creates a "from" contains filter using the "from" field part.
*
* @param from the from field value the packet must contain.
*/
public FromJIDFilter(String from) {
if (from == null) {
throw new IllegalArgumentException("Parameter cannot be null.");
}
this.from = from.toLowerCase();
}
public boolean accept(Packet packet) {
if (packet.getFrom() == null) {
return false;
}
else {
return packet.getFrom().toLowerCase().startsWith(from);
}
}
}

View File

@ -16,7 +16,6 @@ import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.RosterEntry; import org.jivesoftware.smack.RosterEntry;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.AndFilter; import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.FromContainsFilter;
import org.jivesoftware.smack.filter.OrFilter; import org.jivesoftware.smack.filter.OrFilter;
import org.jivesoftware.smack.filter.PacketFilter; import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter; import org.jivesoftware.smack.filter.PacketTypeFilter;
@ -34,6 +33,7 @@ import org.jivesoftware.spark.ui.ChatRoom;
import org.jivesoftware.spark.ui.ChatRoomButton; import org.jivesoftware.spark.ui.ChatRoomButton;
import org.jivesoftware.spark.ui.ContactItem; import org.jivesoftware.spark.ui.ContactItem;
import org.jivesoftware.spark.ui.ContactList; import org.jivesoftware.spark.ui.ContactList;
import org.jivesoftware.spark.ui.FromJIDFilter;
import org.jivesoftware.spark.ui.MessageEventListener; import org.jivesoftware.spark.ui.MessageEventListener;
import org.jivesoftware.spark.ui.RosterDialog; import org.jivesoftware.spark.ui.RosterDialog;
import org.jivesoftware.spark.ui.VCardPanel; import org.jivesoftware.spark.ui.VCardPanel;
@ -47,6 +47,10 @@ import org.jivesoftware.sparkimpl.profile.VCardManager;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences; import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager; import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import javax.swing.Icon;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import java.awt.GridBagConstraints; import java.awt.GridBagConstraints;
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -59,10 +63,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.TimerTask; import java.util.TimerTask;
import javax.swing.Icon;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
/** /**
* This is the Person to Person implementation of <code>ChatRoom</code> * This is the Person to Person implementation of <code>ChatRoom</code>
* This room only allows for 1 to 1 conversations. * This room only allows for 1 to 1 conversations.
@ -109,7 +109,7 @@ public class ChatRoomImpl extends ChatRoom {
loadHistory(); loadHistory();
// Register PacketListeners // Register PacketListeners
PacketFilter fromFilter = new FromContainsFilter(participantJID); PacketFilter fromFilter = new FromJIDFilter(participantJID);
PacketFilter orFilter = new OrFilter(new PacketTypeFilter(Presence.class), new PacketTypeFilter(Message.class)); PacketFilter orFilter = new OrFilter(new PacketTypeFilter(Presence.class), new PacketTypeFilter(Message.class));
PacketFilter andFilter = new AndFilter(orFilter, fromFilter); PacketFilter andFilter = new AndFilter(orFilter, fromFilter);