2003-01-13 17:58:47 +01:00
|
|
|
/**
|
|
|
|
* $RCSfile$
|
|
|
|
* $Revision$
|
|
|
|
* $Date$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002-2003 Jive Software. All rights reserved.
|
|
|
|
* ====================================================================
|
|
|
|
* The Jive Software License (based on Apache Software License, Version 1.1)
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* 3. The end-user documentation included with the redistribution,
|
|
|
|
* if any, must include the following acknowledgment:
|
|
|
|
* "This product includes software developed by
|
|
|
|
* Jive Software (http://www.jivesoftware.com)."
|
|
|
|
* Alternately, this acknowledgment may appear in the software itself,
|
|
|
|
* if and wherever such third-party acknowledgments normally appear.
|
|
|
|
*
|
|
|
|
* 4. The names "Smack" and "Jive Software" must not be used to
|
|
|
|
* endorse or promote products derived from this software without
|
|
|
|
* prior written permission. For written permission, please
|
2003-01-17 21:34:50 +01:00
|
|
|
* contact webmaster@jivesoftware.com.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
|
|
|
* 5. Products derived from this software may not be called "Smack",
|
|
|
|
* nor may "Smack" appear in their name, without prior written
|
|
|
|
* permission of Jive Software.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL JIVE SOFTWARE OR
|
|
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
|
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
* ====================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.jivesoftware.smack;
|
|
|
|
|
|
|
|
import org.xmlpull.v1.*;
|
2003-04-08 17:32:26 +02:00
|
|
|
|
2003-01-13 17:58:47 +01:00
|
|
|
import java.util.*;
|
2003-05-01 04:06:21 +02:00
|
|
|
import java.util.List;
|
2003-01-16 02:00:55 +01:00
|
|
|
import java.io.ObjectInputStream;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
2003-01-13 17:58:47 +01:00
|
|
|
import org.jivesoftware.smack.packet.*;
|
2003-03-07 20:47:49 +01:00
|
|
|
import org.jivesoftware.smack.packet.XMPPError;
|
2003-01-13 17:58:47 +01:00
|
|
|
import org.jivesoftware.smack.filter.PacketFilter;
|
2004-03-29 23:37:24 +02:00
|
|
|
import org.jivesoftware.smack.util.*;
|
2003-01-16 02:00:55 +01:00
|
|
|
import org.jivesoftware.smack.util.StringUtils;
|
2003-05-08 17:55:06 +02:00
|
|
|
import org.jivesoftware.smack.provider.*;
|
2003-01-13 17:58:47 +01:00
|
|
|
|
|
|
|
/**
|
2003-05-01 04:06:21 +02:00
|
|
|
* Listens for XML traffic from the XMPP server and parses it into packet objects.
|
|
|
|
* The packet reader also manages all packet listeners and collectors.<p>
|
|
|
|
*
|
2003-01-13 17:58:47 +01:00
|
|
|
* @see PacketCollector
|
2003-01-17 08:11:33 +01:00
|
|
|
* @see PacketListener
|
2003-01-13 17:58:47 +01:00
|
|
|
* @author Matt Tucker
|
|
|
|
*/
|
2003-01-17 08:11:33 +01:00
|
|
|
class PacketReader {
|
2003-01-13 17:58:47 +01:00
|
|
|
|
2003-02-10 06:01:01 +01:00
|
|
|
/**
|
|
|
|
* Namespace used to store packet properties.
|
|
|
|
*/
|
2003-01-16 02:00:55 +01:00
|
|
|
private static final String PROPERTIES_NAMESPACE =
|
|
|
|
"http://www.jivesoftware.com/xmlns/xmpp/properties";
|
|
|
|
|
2003-01-13 17:58:47 +01:00
|
|
|
private Thread readerThread;
|
|
|
|
private Thread listenerThread;
|
|
|
|
|
|
|
|
private XMPPConnection connection;
|
|
|
|
private XmlPullParser parser;
|
|
|
|
private boolean done = false;
|
|
|
|
protected List collectors = new ArrayList();
|
2003-01-17 19:26:14 +01:00
|
|
|
private List listeners = new ArrayList();
|
2003-07-09 18:05:43 +02:00
|
|
|
protected List connectionListeners = new ArrayList();
|
2003-01-13 17:58:47 +01:00
|
|
|
|
|
|
|
private String connectionID = null;
|
|
|
|
private Object connectionIDLock = new Object();
|
|
|
|
|
|
|
|
protected PacketReader(XMPPConnection connection) {
|
|
|
|
this.connection = connection;
|
|
|
|
|
|
|
|
readerThread = new Thread() {
|
|
|
|
public void run() {
|
|
|
|
parsePackets();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
readerThread.setName("Smack Packet Reader");
|
|
|
|
readerThread.setDaemon(true);
|
|
|
|
|
|
|
|
listenerThread = new Thread() {
|
|
|
|
public void run() {
|
|
|
|
processListeners();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
listenerThread.setName("Smack Listener Processor");
|
|
|
|
listenerThread.setDaemon(true);
|
|
|
|
|
|
|
|
try {
|
2003-06-06 17:07:55 +02:00
|
|
|
XmlPullParserFactory factory = XmlPullParserFactory.newInstance(
|
|
|
|
"org.xmlpull.mxp1.MXParserFactory", null);
|
2003-05-28 20:15:33 +02:00
|
|
|
factory.setNamespaceAware(true);
|
|
|
|
parser = factory.newPullParser();
|
2003-01-13 17:58:47 +01:00
|
|
|
parser.setInput(connection.reader);
|
|
|
|
}
|
|
|
|
catch (XmlPullParserException xppe) {
|
|
|
|
xppe.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-17 19:26:14 +01:00
|
|
|
/**
|
|
|
|
* Creates a new packet collector for this reader. A packet filter determines
|
|
|
|
* which packets will be accumulated by the collector.
|
|
|
|
*
|
|
|
|
* @param packetFilter the packet filter to use.
|
|
|
|
* @return a new packet collector.
|
|
|
|
*/
|
2003-01-13 17:58:47 +01:00
|
|
|
public PacketCollector createPacketCollector(PacketFilter packetFilter) {
|
2003-01-17 19:26:14 +01:00
|
|
|
PacketCollector packetCollector = new PacketCollector(this, packetFilter);
|
|
|
|
return packetCollector;
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
2003-01-17 19:26:14 +01:00
|
|
|
/**
|
|
|
|
* Registers a packet listener with this reader. A packet filter determines
|
|
|
|
* which packets will be delivered to the listener.
|
|
|
|
*
|
|
|
|
* @param packetListener the packet listener to notify of new packets.
|
|
|
|
* @param packetFilter the packet filter to use.
|
|
|
|
*/
|
2003-01-13 17:58:47 +01:00
|
|
|
public void addPacketListener(PacketListener packetListener, PacketFilter packetFilter) {
|
2003-01-17 19:26:14 +01:00
|
|
|
ListenerWrapper wrapper = new ListenerWrapper(this, packetListener,
|
|
|
|
packetFilter);
|
|
|
|
synchronized (listeners) {
|
|
|
|
listeners.add(wrapper);
|
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
2003-01-17 19:26:14 +01:00
|
|
|
/**
|
2003-04-07 07:39:44 +02:00
|
|
|
* Removes a packet listener.
|
2003-01-17 19:26:14 +01:00
|
|
|
*
|
|
|
|
* @param packetListener the packet listener to remove.
|
|
|
|
*/
|
2003-01-13 17:58:47 +01:00
|
|
|
public void removePacketListener(PacketListener packetListener) {
|
2003-01-17 19:26:14 +01:00
|
|
|
synchronized (listeners) {
|
2003-04-07 07:39:44 +02:00
|
|
|
for (int i=0; i<listeners.size(); i++) {
|
|
|
|
ListenerWrapper wrapper = (ListenerWrapper)listeners.get(i);
|
2003-04-09 00:22:57 +02:00
|
|
|
if (wrapper != null && wrapper.packetListener.equals(packetListener)) {
|
2003-04-07 07:39:44 +02:00
|
|
|
listeners.set(i, null);
|
|
|
|
}
|
|
|
|
}
|
2003-01-17 19:26:14 +01:00
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Starts the packet reader thread and returns once a connection to the server
|
|
|
|
* has been established. A connection will be attempted for a maximum of five
|
|
|
|
* seconds. An XMPPException will be thrown if the connection fails.
|
|
|
|
*
|
|
|
|
* @throws XMPPException if the server fails to send an opening stream back
|
|
|
|
* for more than five seconds.
|
|
|
|
*/
|
|
|
|
public void startup() throws XMPPException {
|
|
|
|
readerThread.start();
|
|
|
|
listenerThread.start();
|
|
|
|
// Wait for stream tag before returing. We'll wait a maximum of five seconds before
|
|
|
|
// giving up and throwing an error.
|
|
|
|
try {
|
|
|
|
synchronized(connectionIDLock) {
|
|
|
|
connectionIDLock.wait(5000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (InterruptedException ie) { }
|
|
|
|
if (connectionID == null) {
|
|
|
|
throw new XMPPException("Connection failed. No response from server.");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
connection.connectionID = connectionID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shuts the packet reader down.
|
|
|
|
*/
|
|
|
|
public void shutdown() {
|
2003-08-20 18:29:46 +02:00
|
|
|
// Notify connection listeners of the connection closing if done hasn't already been set.
|
|
|
|
if (!done) {
|
|
|
|
synchronized (connectionListeners) {
|
|
|
|
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
|
|
|
ConnectionListener listener = (ConnectionListener)i.next();
|
|
|
|
listener.connectionClosed();
|
|
|
|
}
|
2003-07-16 04:49:43 +02:00
|
|
|
}
|
|
|
|
}
|
2003-08-20 18:29:46 +02:00
|
|
|
done = true;
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
2003-09-19 00:35:42 +02:00
|
|
|
/**
|
|
|
|
* Sends out a notification that there was an error with the connection
|
|
|
|
* and closes the connection.
|
|
|
|
*
|
|
|
|
* @param e the exception that causes the connection close event.
|
|
|
|
*/
|
|
|
|
void notifyConnectionError(Exception e) {
|
|
|
|
done = true;
|
|
|
|
connection.close();
|
|
|
|
// Notify connection listeners of the error.
|
|
|
|
synchronized (connectionListeners) {
|
|
|
|
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
|
|
|
ConnectionListener listener = (ConnectionListener)i.next();
|
|
|
|
listener.connectionClosedOnError(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-15 16:01:30 +01:00
|
|
|
/**
|
|
|
|
* Process listeners.
|
|
|
|
*/
|
2003-01-13 17:58:47 +01:00
|
|
|
private void processListeners() {
|
|
|
|
boolean processedPacket = false;
|
2003-01-17 19:26:14 +01:00
|
|
|
while (!done) {
|
|
|
|
synchronized (listeners) {
|
2003-04-07 07:39:44 +02:00
|
|
|
if (listeners.size() > 0) {
|
|
|
|
for (int i=listeners.size()-1; i>=0; i--) {
|
|
|
|
if (listeners.get(i) == null) {
|
|
|
|
listeners.remove(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-01-17 19:26:14 +01:00
|
|
|
}
|
|
|
|
processedPacket = false;
|
|
|
|
int size = listeners.size();
|
|
|
|
for (int i=0; i<size; i++) {
|
|
|
|
ListenerWrapper wrapper = (ListenerWrapper)listeners.get(i);
|
|
|
|
if (wrapper != null) {
|
|
|
|
processedPacket = processedPacket || wrapper.notifyListener();
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!processedPacket) {
|
|
|
|
try {
|
|
|
|
Thread.sleep(100);
|
2003-09-19 00:35:42 +02:00
|
|
|
}
|
|
|
|
catch (InterruptedException ie) { }
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse top-level packets in order to process them further.
|
|
|
|
*/
|
|
|
|
private void parsePackets() {
|
|
|
|
try {
|
|
|
|
int eventType = parser.getEventType();
|
|
|
|
do {
|
2003-04-08 17:32:26 +02:00
|
|
|
if (eventType == XmlPullParser.START_TAG) {
|
2003-01-13 17:58:47 +01:00
|
|
|
if (parser.getName().equals("message")) {
|
|
|
|
processPacket(parseMessage(parser));
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("iq")) {
|
|
|
|
processPacket(parseIQ(parser));
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("presence")) {
|
|
|
|
processPacket(parsePresence(parser));
|
|
|
|
}
|
|
|
|
// We found an opening stream. Record information about it, then notify
|
|
|
|
// the connectionID lock so that the packet reader startup can finish.
|
|
|
|
else if (parser.getName().equals("stream")) {
|
|
|
|
// Ensure the correct jabber:client namespace is being used.
|
|
|
|
if ("jabber:client".equals(parser.getNamespace(null))) {
|
|
|
|
// Get the connection id.
|
|
|
|
for (int i=0; i<parser.getAttributeCount(); i++) {
|
|
|
|
if (parser.getAttributeName(i).equals("id")) {
|
|
|
|
// Save the connectionID and notify that we've gotten it.
|
|
|
|
connectionID = parser.getAttributeValue(i);
|
|
|
|
synchronized(connectionIDLock) {
|
|
|
|
connectionIDLock.notifyAll();
|
|
|
|
}
|
|
|
|
}
|
2003-10-03 02:47:45 +02:00
|
|
|
else if (parser.getAttributeName(i).equals("from")) {
|
|
|
|
// Use the server name that the server says that it is.
|
|
|
|
connection.host = parser.getAttributeValue(i);
|
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-04-08 17:32:26 +02:00
|
|
|
else if (eventType == XmlPullParser.END_TAG) {
|
2003-01-13 17:58:47 +01:00
|
|
|
if (parser.getName().equals("stream")) {
|
2003-07-16 04:49:43 +02:00
|
|
|
// Close the connection.
|
2003-01-13 17:58:47 +01:00
|
|
|
connection.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eventType = parser.next();
|
2003-07-16 04:49:43 +02:00
|
|
|
} while (!done && eventType != XmlPullParser.END_DOCUMENT);
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
if (!done) {
|
2003-09-19 00:35:42 +02:00
|
|
|
// Close the connection and notify connection listeners of the
|
|
|
|
// error.
|
|
|
|
notifyConnectionError(e);
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processes a packet after it's been fully parsed by looping through the installed
|
2003-01-17 19:26:14 +01:00
|
|
|
* packet collectors and listeners and letting them examine the packet to see if
|
|
|
|
* they are a match with the filter.
|
2003-01-13 17:58:47 +01:00
|
|
|
*
|
|
|
|
* @param packet the packet to process.
|
|
|
|
*/
|
|
|
|
private void processPacket(Packet packet) {
|
2003-01-15 16:01:30 +01:00
|
|
|
if (packet == null) {
|
|
|
|
return;
|
|
|
|
}
|
2003-01-17 19:26:14 +01:00
|
|
|
|
2003-04-07 07:39:44 +02:00
|
|
|
// Remove all null values from the collectors list.
|
|
|
|
synchronized (collectors) {
|
2003-04-08 23:22:09 +02:00
|
|
|
for (int i=collectors.size()-1; i>=0; i--) {
|
2003-04-07 07:39:44 +02:00
|
|
|
if (collectors.get(i) == null) {
|
|
|
|
collectors.remove(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-01-17 19:26:14 +01:00
|
|
|
|
2003-01-13 17:58:47 +01:00
|
|
|
// Loop through all collectors and notify the appropriate ones.
|
2003-01-17 19:26:14 +01:00
|
|
|
int size = collectors.size();
|
|
|
|
for (int i=0; i<size; i++) {
|
|
|
|
PacketCollector collector = (PacketCollector)collectors.get(i);
|
|
|
|
if (collector != null) {
|
|
|
|
// Have the collector process the packet to see if it wants to handle it.
|
|
|
|
collector.processPacket(packet);
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parses an IQ packet.
|
|
|
|
*
|
|
|
|
* @param parser the XML parser, positioned at the start of an IQ packet.
|
|
|
|
* @return an IQ object.
|
|
|
|
* @throws Exception if an exception occurs while parsing the packet.
|
|
|
|
*/
|
2003-10-21 19:39:04 +02:00
|
|
|
private IQ parseIQ(XmlPullParser parser) throws Exception {
|
2003-01-15 16:01:30 +01:00
|
|
|
IQ iqPacket = null;
|
|
|
|
|
|
|
|
String id = parser.getAttributeValue("", "id");
|
|
|
|
String to = parser.getAttributeValue("", "to");
|
|
|
|
String from = parser.getAttributeValue("", "from");
|
|
|
|
IQ.Type type = IQ.Type.fromString(parser.getAttributeValue("", "type"));
|
2003-03-07 20:47:49 +01:00
|
|
|
XMPPError error = null;
|
2003-01-15 16:01:30 +01:00
|
|
|
|
2003-01-13 17:58:47 +01:00
|
|
|
boolean done = false;
|
|
|
|
while (!done) {
|
|
|
|
int eventType = parser.next();
|
2003-05-08 17:55:06 +02:00
|
|
|
|
2003-04-08 17:32:26 +02:00
|
|
|
if (eventType == XmlPullParser.START_TAG) {
|
2003-05-08 17:55:06 +02:00
|
|
|
String elementName = parser.getName();
|
|
|
|
String namespace = parser.getNamespace();
|
|
|
|
if (elementName.equals("error")) {
|
2003-01-15 16:01:30 +01:00
|
|
|
error = parseError(parser);
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
2003-05-08 17:55:06 +02:00
|
|
|
else if (elementName.equals("query") && namespace.equals("jabber:iq:auth")) {
|
|
|
|
iqPacket = parseAuthentication(parser);
|
|
|
|
}
|
|
|
|
else if (elementName.equals("query") && namespace.equals("jabber:iq:roster")) {
|
|
|
|
iqPacket = parseRoster(parser);
|
|
|
|
}
|
|
|
|
else if (elementName.equals("query") && namespace.equals("jabber:iq:register")) {
|
|
|
|
iqPacket = parseRegistration(parser);
|
|
|
|
}
|
|
|
|
// Otherwise, see if there is a registered provider for
|
|
|
|
// this element name and namespace.
|
|
|
|
else {
|
|
|
|
Object provider = ProviderManager.getIQProvider(elementName, namespace);
|
|
|
|
if (provider != null) {
|
|
|
|
if (provider instanceof IQProvider) {
|
|
|
|
iqPacket = ((IQProvider)provider).parseIQ(parser);
|
|
|
|
}
|
|
|
|
else if (provider instanceof Class) {
|
2004-03-29 23:37:24 +02:00
|
|
|
iqPacket = (IQ)PacketParserUtils.parseWithIntrospection(elementName,
|
2003-05-08 18:17:48 +02:00
|
|
|
(Class)provider, parser);
|
2003-05-08 17:55:06 +02:00
|
|
|
}
|
|
|
|
}
|
2003-01-16 02:00:55 +01:00
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
2003-04-08 17:32:26 +02:00
|
|
|
else if (eventType == XmlPullParser.END_TAG) {
|
2003-01-13 17:58:47 +01:00
|
|
|
if (parser.getName().equals("iq")) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-01-29 23:02:50 +01:00
|
|
|
// Decide what to do when an IQ packet was not understood
|
2003-01-15 16:01:30 +01:00
|
|
|
if (iqPacket == null) {
|
2004-01-29 23:02:50 +01:00
|
|
|
if (IQ.Type.GET == type || IQ.Type.SET == type ) {
|
|
|
|
// If the IQ stanza is of type "get" or "set" containing a child element
|
|
|
|
// qualified by a namespace it does not understand, then answer an IQ of
|
|
|
|
// type "error" with code 501 ("feature-not-implemented")
|
|
|
|
iqPacket = new IQ() {
|
|
|
|
public String getChildElementXML() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
iqPacket.setPacketID(id);
|
|
|
|
iqPacket.setTo(from);
|
|
|
|
iqPacket.setFrom(to);
|
|
|
|
iqPacket.setType(IQ.Type.ERROR);
|
|
|
|
iqPacket.setError(new XMPPError(501, "feature-not-implemented"));
|
|
|
|
connection.sendPacket(iqPacket);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// If an IQ packet wasn't created above, create an empty IQ packet.
|
|
|
|
iqPacket = new IQ() {
|
|
|
|
public String getChildElementXML() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2003-01-15 16:01:30 +01:00
|
|
|
}
|
2004-01-29 23:02:50 +01:00
|
|
|
|
|
|
|
// Set basic values on the iq packet.
|
2003-01-15 16:01:30 +01:00
|
|
|
iqPacket.setPacketID(id);
|
|
|
|
iqPacket.setTo(to);
|
|
|
|
iqPacket.setFrom(from);
|
|
|
|
iqPacket.setType(type);
|
|
|
|
iqPacket.setError(error);
|
2003-08-04 23:58:31 +02:00
|
|
|
|
2003-01-15 16:01:30 +01:00
|
|
|
return iqPacket;
|
|
|
|
}
|
|
|
|
|
2003-05-01 04:06:21 +02:00
|
|
|
private Authentication parseAuthentication(XmlPullParser parser) throws Exception {
|
2003-01-15 16:01:30 +01:00
|
|
|
Authentication authentication = new Authentication();
|
|
|
|
boolean done = false;
|
|
|
|
while (!done) {
|
|
|
|
int eventType = parser.next();
|
2003-04-08 17:32:26 +02:00
|
|
|
if (eventType == XmlPullParser.START_TAG) {
|
2003-01-15 16:01:30 +01:00
|
|
|
if (parser.getName().equals("username")) {
|
|
|
|
authentication.setUsername(parser.nextText());
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("password")) {
|
|
|
|
authentication.setPassword(parser.nextText());
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("digest")) {
|
|
|
|
authentication.setDigest(parser.nextText());
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("resource")) {
|
|
|
|
authentication.setResource(parser.nextText());
|
|
|
|
}
|
|
|
|
}
|
2003-04-08 17:32:26 +02:00
|
|
|
else if (eventType == XmlPullParser.END_TAG) {
|
2003-01-15 16:01:30 +01:00
|
|
|
if (parser.getName().equals("query")) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return authentication;
|
|
|
|
}
|
|
|
|
|
2003-05-01 04:06:21 +02:00
|
|
|
private RosterPacket parseRoster(XmlPullParser parser) throws Exception {
|
2003-02-10 06:01:01 +01:00
|
|
|
RosterPacket roster = new RosterPacket();
|
|
|
|
boolean done = false;
|
|
|
|
RosterPacket.Item item = null;
|
|
|
|
while (!done) {
|
|
|
|
int eventType = parser.next();
|
2003-04-08 17:32:26 +02:00
|
|
|
if (eventType == XmlPullParser.START_TAG) {
|
2003-02-10 06:01:01 +01:00
|
|
|
if (parser.getName().equals("item")) {
|
|
|
|
String jid = parser.getAttributeValue("", "jid");
|
|
|
|
String name = parser.getAttributeValue("", "name");
|
2003-06-17 22:22:43 +02:00
|
|
|
// Create packet.
|
2003-02-10 06:01:01 +01:00
|
|
|
item = new RosterPacket.Item(jid, name);
|
2003-06-17 22:22:43 +02:00
|
|
|
// Set status.
|
|
|
|
String ask = parser.getAttributeValue("", "ask");
|
|
|
|
RosterPacket.ItemStatus status = RosterPacket.ItemStatus.fromString(ask);
|
|
|
|
item.setItemStatus(status);
|
|
|
|
// Set type.
|
|
|
|
String subscription = parser.getAttributeValue("", "subscription");
|
2003-04-25 22:18:49 +02:00
|
|
|
RosterPacket.ItemType type = RosterPacket.ItemType.fromString(subscription);
|
2003-06-17 22:22:43 +02:00
|
|
|
item.setItemType(type);
|
2003-02-10 06:01:01 +01:00
|
|
|
}
|
|
|
|
if (parser.getName().equals("group")) {
|
|
|
|
String groupName = parser.nextText();
|
|
|
|
item.addGroupName(groupName);
|
|
|
|
}
|
|
|
|
}
|
2003-04-08 17:32:26 +02:00
|
|
|
else if (eventType == XmlPullParser.END_TAG) {
|
2003-02-10 06:01:01 +01:00
|
|
|
if (parser.getName().equals("item")) {
|
|
|
|
roster.addRosterItem(item);
|
|
|
|
}
|
|
|
|
if (parser.getName().equals("query")) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return roster;
|
|
|
|
}
|
|
|
|
|
2003-05-01 04:06:21 +02:00
|
|
|
private Registration parseRegistration(XmlPullParser parser) throws Exception {
|
2003-03-09 00:09:48 +01:00
|
|
|
Registration registration = new Registration();
|
|
|
|
Map fields = null;
|
|
|
|
boolean done = false;
|
|
|
|
while (!done) {
|
|
|
|
int eventType = parser.next();
|
2003-04-08 17:32:26 +02:00
|
|
|
if (eventType == XmlPullParser.START_TAG) {
|
2003-03-09 00:09:48 +01:00
|
|
|
if (parser.getName().equals("username")) {
|
|
|
|
registration.setUsername(parser.nextText());
|
|
|
|
}
|
|
|
|
else if (parser.getName().equals("password")) {
|
|
|
|
registration.setPassword(parser.nextText());
|
|
|
|
}
|
2003-09-27 19:27:40 +02:00
|
|
|
// Else if any other element that's in the jabber:iq:register namespace,
|
|
|
|
// attempt to parse it if it's in the form <name>value</name>.
|
|
|
|
else if (parser.getNamespace().equals("jabber:iq:register")) {
|
2003-03-09 00:09:48 +01:00
|
|
|
String name = parser.getName();
|
2003-09-27 19:27:40 +02:00
|
|
|
if (parser.next() == XmlPullParser.TEXT) {
|
|
|
|
String value = parser.getText();
|
|
|
|
// Ignore instructions, but anything else should be added to the map.
|
|
|
|
if (!name.equals("instructions")) {
|
|
|
|
if (fields == null) {
|
|
|
|
fields = new HashMap();
|
|
|
|
}
|
|
|
|
fields.put(name, value);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
registration.setInstructions(value);
|
2003-03-09 00:09:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-03-29 23:37:24 +02:00
|
|
|
// Otherwise, it must be a packet extension.
|
|
|
|
else {
|
|
|
|
registration.addExtension(
|
|
|
|
PacketParserUtils.parsePacketExtension(
|
|
|
|
parser.getName(),
|
|
|
|
parser.getNamespace(),
|
|
|
|
parser));
|
|
|
|
}
|
2003-03-09 00:09:48 +01:00
|
|
|
}
|
2003-04-08 17:32:26 +02:00
|
|
|
else if (eventType == XmlPullParser.END_TAG) {
|
2003-03-09 00:09:48 +01:00
|
|
|
if (parser.getName().equals("query")) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
registration.setAttributes(fields);
|
|
|
|
return registration;
|
|
|
|
}
|
|
|
|
|
2003-03-24 15:53:55 +01:00
|
|
|
/**
|
|
|
|
* Parses error sub-packets.
|
|
|
|
*
|
|
|
|
* @param parser the XML parser.
|
|
|
|
* @return an error sub-packet.
|
|
|
|
* @throws Exception if an exception occurs while parsing the packet.
|
|
|
|
*/
|
2003-05-01 04:06:21 +02:00
|
|
|
private XMPPError parseError(XmlPullParser parser) throws Exception {
|
2003-01-15 16:01:30 +01:00
|
|
|
String errorCode = null;
|
2003-11-05 17:47:32 +01:00
|
|
|
String message = null;
|
2003-01-15 16:01:30 +01:00
|
|
|
for (int i=0; i<parser.getAttributeCount(); i++) {
|
|
|
|
if (parser.getAttributeName(i).equals("code")) {
|
|
|
|
errorCode = parser.getAttributeValue("", "code");
|
|
|
|
}
|
|
|
|
}
|
2003-11-05 17:47:32 +01:00
|
|
|
// Get the error text in a safe way since we are not sure about the error message format
|
|
|
|
try {
|
|
|
|
message = parser.nextText();
|
|
|
|
}
|
|
|
|
catch (XmlPullParserException ex) {}
|
2003-01-15 16:01:30 +01:00
|
|
|
while (true) {
|
2003-04-08 17:32:26 +02:00
|
|
|
if (parser.getEventType() == XmlPullParser.END_TAG && parser.getName().equals("error")) {
|
2003-01-15 16:01:30 +01:00
|
|
|
break;
|
|
|
|
}
|
2003-11-05 17:47:32 +01:00
|
|
|
parser.next();
|
2003-01-15 16:01:30 +01:00
|
|
|
}
|
2003-03-07 20:47:49 +01:00
|
|
|
return new XMPPError(Integer.parseInt(errorCode), message);
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parses a message packet.
|
|
|
|
*
|
|
|
|
* @param parser the XML parser, positioned at the start of a message packet.
|
2003-10-21 19:39:04 +02:00
|
|
|
* @return a Message packet.
|
2003-01-13 17:58:47 +01:00
|
|
|
* @throws Exception if an exception occurs while parsing the packet.
|
|
|
|
*/
|
2003-05-01 04:06:21 +02:00
|
|
|
private Packet parseMessage(XmlPullParser parser) throws Exception {
|
2003-01-13 17:58:47 +01:00
|
|
|
Message message = new Message();
|
2004-02-10 16:39:36 +01:00
|
|
|
String id = parser.getAttributeValue("", "id");
|
|
|
|
message.setPacketID(id == null ? Packet.ID_NOT_AVAILABLE : id);
|
2003-01-15 16:01:30 +01:00
|
|
|
message.setTo(parser.getAttributeValue("", "to"));
|
|
|
|
message.setFrom(parser.getAttributeValue("", "from"));
|
|
|
|
message.setType(Message.Type.fromString(parser.getAttributeValue("", "type")));
|
|
|
|
|
|
|
|
// Parse sub-elements. We include extra logic to make sure the values
|
|
|
|
// are only read once. This is because it's possible for the names to appear
|
|
|
|
// in arbitrary sub-elements.
|
2003-01-13 17:58:47 +01:00
|
|
|
boolean done = false;
|
|
|
|
String subject = null;
|
|
|
|
String body = null;
|
|
|
|
String thread = null;
|
2003-01-16 02:00:55 +01:00
|
|
|
Map properties = null;
|
2003-01-13 17:58:47 +01:00
|
|
|
while (!done) {
|
|
|
|
int eventType = parser.next();
|
2003-04-08 17:32:26 +02:00
|
|
|
if (eventType == XmlPullParser.START_TAG) {
|
2003-05-08 17:55:06 +02:00
|
|
|
String elementName = parser.getName();
|
|
|
|
String namespace = parser.getNamespace();
|
|
|
|
if (elementName.equals("subject")) {
|
2003-01-13 17:58:47 +01:00
|
|
|
if (subject == null) {
|
|
|
|
subject = parser.nextText();
|
|
|
|
}
|
|
|
|
}
|
2003-05-08 17:55:06 +02:00
|
|
|
else if (elementName.equals("body")) {
|
2003-01-13 17:58:47 +01:00
|
|
|
if (body == null) {
|
|
|
|
body = parser.nextText();
|
|
|
|
}
|
|
|
|
}
|
2003-05-08 17:55:06 +02:00
|
|
|
else if (elementName.equals("thread")) {
|
2003-01-13 17:58:47 +01:00
|
|
|
if (thread == null) {
|
|
|
|
thread = parser.nextText();
|
|
|
|
}
|
|
|
|
}
|
2003-05-08 17:55:06 +02:00
|
|
|
else if (elementName.equals("error")) {
|
2003-03-09 00:09:48 +01:00
|
|
|
message.setError(parseError(parser));
|
|
|
|
}
|
2003-05-08 17:55:06 +02:00
|
|
|
else if (elementName.equals("properties") &&
|
|
|
|
namespace.equals(PROPERTIES_NAMESPACE))
|
2003-01-16 02:00:55 +01:00
|
|
|
{
|
|
|
|
properties = parseProperties(parser);
|
|
|
|
}
|
2003-05-08 18:17:48 +02:00
|
|
|
// Otherwise, it must be a packet extension.
|
2003-05-08 17:55:06 +02:00
|
|
|
else {
|
2004-03-29 23:37:24 +02:00
|
|
|
message.addExtension(
|
|
|
|
PacketParserUtils.parsePacketExtension(elementName, namespace, parser));
|
2003-05-08 17:55:06 +02:00
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
2003-04-08 17:32:26 +02:00
|
|
|
else if (eventType == XmlPullParser.END_TAG) {
|
2003-01-13 17:58:47 +01:00
|
|
|
if (parser.getName().equals("message")) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
message.setSubject(subject);
|
|
|
|
message.setBody(body);
|
|
|
|
message.setThread(thread);
|
2003-01-16 02:00:55 +01:00
|
|
|
// Set packet properties.
|
|
|
|
if (properties != null) {
|
|
|
|
for (Iterator i=properties.keySet().iterator(); i.hasNext(); ) {
|
|
|
|
String name = (String)i.next();
|
|
|
|
message.setProperty(name, properties.get(name));
|
|
|
|
}
|
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parses a presence packet.
|
|
|
|
*
|
|
|
|
* @param parser the XML parser, positioned at the start of a presence packet.
|
2003-10-21 19:39:04 +02:00
|
|
|
* @return a Presence packet.
|
2003-01-13 17:58:47 +01:00
|
|
|
* @throws Exception if an exception occurs while parsing the packet.
|
|
|
|
*/
|
2003-10-21 19:39:04 +02:00
|
|
|
private Presence parsePresence(XmlPullParser parser) throws Exception {
|
2003-01-16 16:41:57 +01:00
|
|
|
Presence.Type type = Presence.Type.fromString(parser.getAttributeValue("", "type"));
|
|
|
|
|
|
|
|
Presence presence = new Presence(type);
|
2003-01-15 16:01:30 +01:00
|
|
|
presence.setTo(parser.getAttributeValue("", "to"));
|
|
|
|
presence.setFrom(parser.getAttributeValue("", "from"));
|
2004-02-10 16:39:36 +01:00
|
|
|
String id = parser.getAttributeValue("", "id");
|
|
|
|
presence.setPacketID(id == null ? Packet.ID_NOT_AVAILABLE : id);
|
2003-01-13 17:58:47 +01:00
|
|
|
|
|
|
|
// Parse sub-elements
|
|
|
|
boolean done = false;
|
|
|
|
while (!done) {
|
|
|
|
int eventType = parser.next();
|
2003-04-08 17:32:26 +02:00
|
|
|
if (eventType == XmlPullParser.START_TAG) {
|
2003-05-08 18:17:48 +02:00
|
|
|
String elementName = parser.getName();
|
|
|
|
String namespace = parser.getNamespace();
|
|
|
|
if (elementName.equals("status")) {
|
2003-01-13 17:58:47 +01:00
|
|
|
presence.setStatus(parser.nextText());
|
|
|
|
}
|
2003-05-08 18:17:48 +02:00
|
|
|
else if (elementName.equals("priority")) {
|
2003-01-13 17:58:47 +01:00
|
|
|
try {
|
|
|
|
int priority = Integer.parseInt(parser.nextText());
|
|
|
|
presence.setPriority(priority);
|
|
|
|
}
|
|
|
|
catch (NumberFormatException nfe) { }
|
|
|
|
}
|
2003-05-08 18:17:48 +02:00
|
|
|
else if (elementName.equals("show")) {
|
2003-01-13 17:58:47 +01:00
|
|
|
presence.setMode(Presence.Mode.fromString(parser.nextText()));
|
|
|
|
}
|
2003-05-08 18:17:48 +02:00
|
|
|
else if (elementName.equals("error")) {
|
2003-03-09 00:09:48 +01:00
|
|
|
presence.setError(parseError(parser));
|
|
|
|
}
|
2003-05-08 18:17:48 +02:00
|
|
|
else if (elementName.equals("properties") &&
|
|
|
|
namespace.equals(PROPERTIES_NAMESPACE))
|
2003-01-16 02:00:55 +01:00
|
|
|
{
|
|
|
|
Map properties = parseProperties(parser);
|
|
|
|
// Set packet properties.
|
|
|
|
for (Iterator i=properties.keySet().iterator(); i.hasNext(); ) {
|
|
|
|
String name = (String)i.next();
|
|
|
|
presence.setProperty(name, properties.get(name));
|
|
|
|
}
|
|
|
|
}
|
2003-05-08 18:17:48 +02:00
|
|
|
// Otherwise, it must be a packet extension.
|
|
|
|
else {
|
2004-03-29 23:37:24 +02:00
|
|
|
presence.addExtension(
|
|
|
|
PacketParserUtils.parsePacketExtension(elementName, namespace, parser));
|
2003-05-08 18:17:48 +02:00
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
2003-04-08 17:32:26 +02:00
|
|
|
else if (eventType == XmlPullParser.END_TAG) {
|
2003-01-13 17:58:47 +01:00
|
|
|
if (parser.getName().equals("presence")) {
|
|
|
|
done = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return presence;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Parse a properties sub-packet. If any errors occur while de-serializing Java object
|
|
|
|
* properties, an exception will be printed and not thrown since a thrown
|
|
|
|
* exception will shut down the entire connection. ClassCastExceptions will occur
|
|
|
|
* when both the sender and receiver of the packet don't have identical versions
|
|
|
|
* of the same class.
|
|
|
|
*
|
|
|
|
* @param parser the XML parser, positioned at the start of a properties sub-packet.
|
2003-01-16 02:00:55 +01:00
|
|
|
* @return a map of the properties.
|
2003-01-13 17:58:47 +01:00
|
|
|
* @throws Exception if an error occurs while parsing the properties.
|
|
|
|
*/
|
2003-05-01 04:06:21 +02:00
|
|
|
private Map parseProperties(XmlPullParser parser) throws Exception {
|
2003-01-16 02:00:55 +01:00
|
|
|
Map properties = new HashMap();
|
|
|
|
while (true) {
|
2003-01-13 17:58:47 +01:00
|
|
|
int eventType = parser.next();
|
2003-04-08 17:32:26 +02:00
|
|
|
if (eventType == XmlPullParser.START_TAG && parser.getName().equals("property")) {
|
2003-03-07 20:47:49 +01:00
|
|
|
// Advance to name element.
|
2004-06-03 18:18:30 +02:00
|
|
|
// Skip CRs
|
|
|
|
parser.next();
|
2003-03-07 20:47:49 +01:00
|
|
|
parser.next();
|
2003-01-16 02:00:55 +01:00
|
|
|
String name = parser.nextText();
|
|
|
|
parser.next();
|
2004-06-03 18:18:30 +02:00
|
|
|
// Skip CRs
|
|
|
|
parser.next();
|
2003-01-16 02:00:55 +01:00
|
|
|
String type = parser.getAttributeValue("", "type");
|
|
|
|
String valueText = parser.nextText();
|
|
|
|
Object value = null;
|
|
|
|
if ("integer".equals(type)) {
|
|
|
|
value = new Integer(valueText);
|
|
|
|
}
|
|
|
|
else if ("long".equals(type)) {
|
|
|
|
value = new Long(valueText);
|
|
|
|
}
|
|
|
|
else if ("float".equals(type)) {
|
|
|
|
value = new Float(valueText);
|
|
|
|
}
|
|
|
|
else if ("double".equals(type)) {
|
|
|
|
value = new Double(valueText);
|
|
|
|
}
|
|
|
|
else if ("boolean".equals(type)) {
|
|
|
|
value = new Boolean(valueText);
|
|
|
|
}
|
2003-03-07 20:47:49 +01:00
|
|
|
else if ("string".equals(type)) {
|
|
|
|
value = valueText;
|
|
|
|
}
|
2003-01-16 02:00:55 +01:00
|
|
|
else if ("java-object".equals(type)) {
|
|
|
|
try {
|
2003-05-28 20:15:33 +02:00
|
|
|
byte [] bytes = StringUtils.decodeBase64(valueText);
|
2003-01-16 02:00:55 +01:00
|
|
|
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
|
|
|
|
value = in.readObject();
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (name != null && value != null) {
|
|
|
|
properties.put(name, value);
|
|
|
|
}
|
|
|
|
}
|
2003-04-08 17:32:26 +02:00
|
|
|
else if (eventType == XmlPullParser.END_TAG) {
|
2003-05-08 17:55:06 +02:00
|
|
|
if (parser.getName().equals("properties")) {
|
2003-01-16 02:00:55 +01:00
|
|
|
break;
|
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
}
|
2003-01-16 02:00:55 +01:00
|
|
|
return properties;
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
|
|
|
|
2003-01-15 16:01:30 +01:00
|
|
|
/**
|
|
|
|
* A wrapper class to associate a packet collector with a listener.
|
|
|
|
*/
|
2003-01-17 19:26:14 +01:00
|
|
|
private static class ListenerWrapper {
|
2003-01-13 17:58:47 +01:00
|
|
|
|
|
|
|
private PacketListener packetListener;
|
|
|
|
private PacketCollector packetCollector;
|
|
|
|
|
2003-01-17 19:26:14 +01:00
|
|
|
public ListenerWrapper(PacketReader packetReader, PacketListener packetListener,
|
2003-01-13 17:58:47 +01:00
|
|
|
PacketFilter packetFilter)
|
|
|
|
{
|
|
|
|
this.packetListener = packetListener;
|
|
|
|
this.packetCollector = new PacketCollector(packetReader, packetFilter);
|
|
|
|
}
|
2003-01-17 19:26:14 +01:00
|
|
|
|
|
|
|
public boolean equals(Object object) {
|
|
|
|
if (object == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (object instanceof ListenerWrapper) {
|
|
|
|
return ((ListenerWrapper)object).packetListener.equals(this.packetListener);
|
|
|
|
}
|
|
|
|
else if (object instanceof PacketListener) {
|
|
|
|
return object.equals(this.packetListener);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean notifyListener() {
|
|
|
|
Packet packet = packetCollector.pollResult();
|
|
|
|
if (packet != null) {
|
|
|
|
packetListener.processPacket(packet);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void cancel() {
|
|
|
|
packetCollector.cancel();
|
|
|
|
packetCollector = null;
|
|
|
|
packetListener = null;
|
|
|
|
}
|
2003-01-13 17:58:47 +01:00
|
|
|
}
|
2003-10-21 19:39:04 +02:00
|
|
|
}
|