mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 03:52:06 +01:00
Rename PacketFilter (and implementing classes) and PacketExtension
to StanzaFilter and ExtensionElement.
This commit is contained in:
parent
2250ac20ed
commit
d4a6d8e653
233 changed files with 1175 additions and 895 deletions
|
@ -42,9 +42,9 @@ connection. The window will contain the following information:
|
|||
|
||||
* XMPPConnection tabs -- each tab shows debugging information related to the connection.
|
||||
* Smack info tab -- shows information about Smack (e.g. Smack version, installed components, etc.). The connection tab will contain the following information:
|
||||
* All Packets -- shows sent and received packets information parsed by Smack.
|
||||
* Raw Sent Packets -- raw XML traffic generated by Smack and sent to the server.
|
||||
* Raw Received Packets -- raw XML traffic sent by the server to the client.
|
||||
* All Stanzas -- shows sent and received packets information parsed by Smack.
|
||||
* Raw Sent Stanzas -- raw XML traffic generated by Smack and sent to the server.
|
||||
* Raw Received Stanzas -- raw XML traffic sent by the server to the client.
|
||||
* Ad-hoc message -- allows to send ad-hoc packets of any type.
|
||||
* Information -- shows connection state and statistics.
|
||||
|
||||
|
@ -57,6 +57,6 @@ contain the following information:
|
|||
|
||||
* Client Traffic (red text) -- raw XML traffic generated by Smack and sent to the server.
|
||||
* Server Traffic (blue text) -- raw XML traffic sent by the server to the client.
|
||||
* Interpreted Packets (green text) -- shows XML packets from the server as parsed by Smack. Right click on any of the panes to bring up a menu with the choices to copy of the contents to the system clipboard or to clear the contents of the pane.
|
||||
* Interpreted Stanzas (green text) -- shows XML packets from the server as parsed by Smack. Right click on any of the panes to bring up a menu with the choices to copy of the contents to the system clipboard or to clear the contents of the pane.
|
||||
|
||||
Copyright (C) Jive Software 2002-2008
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PacketExtension
|
||||
===============
|
||||
|
||||
The static `from(Packet)` Method
|
||||
The static `from(Stanza)` Method
|
||||
--------------------------------
|
||||
|
||||
Every PacketExtension class must have a static `from()` method that retrieves that extension for a given Stanza (if any).
|
||||
|
@ -9,7 +9,7 @@ Every PacketExtension class must have a static `from()` method that retrieves th
|
|||
Sample Code
|
||||
|
||||
```java
|
||||
public static RSMSet from(Packet) {
|
||||
public static RSMSet from(Stanza) {
|
||||
return packet.getExtension(ELEMENT, NAMESPACE);
|
||||
}
|
||||
```
|
||||
|
|
|
@ -89,7 +89,7 @@ req.setTo("juliet@capulet.com/balcony");
|
|||
|
||||
// send it
|
||||
connection.sendIqWithResponseCallback(req, new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
public void processPacket(Stanza packet) {
|
||||
HttpOverXmppResp resp = (HttpOverXmppResp) iq;
|
||||
// check HTTP response code
|
||||
if (resp.getStatusCode() == 200) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Group Chat Invitations
|
||||
======================
|
||||
|
||||
The group chat invitation packet extension is used to invite other users to a
|
||||
The group chat invitation extension is used to invite other users to a
|
||||
group chat room.
|
||||
|
||||
* Inviting Other Users
|
||||
|
@ -20,7 +20,7 @@ appropriately, as in the following code example:
|
|||
Message message = new Message("user@chat.example.com");
|
||||
message.setBody("Join me for a group chat!");
|
||||
message.addExtension(new GroupChatInvitation("room@chat.example.com"));
|
||||
con.sendPacket(message);
|
||||
con.sendStanza(message);
|
||||
```
|
||||
|
||||
The XML generated for the invitation portion of the code above would be:
|
||||
|
@ -32,11 +32,11 @@ The XML generated for the invitation portion of the code above would be:
|
|||
Listening for Invitations
|
||||
-------------------------
|
||||
|
||||
To listen for group chat invitations, use a PacketExtensionFilter for the `x`
|
||||
To listen for group chat invitations, use a StanzaExtensionFilter for the `x`
|
||||
element name and `jabber:x:conference` namespace, as in the following code
|
||||
example:
|
||||
|
||||
```
|
||||
PacketFilter filter = new PacketExtensionFilter("x", "jabber:x:conference");
|
||||
StanzaFilter filter = new StanzaExtensionFilter("x", "jabber:x:conference");
|
||||
// Create a packet collector or packet listeners using the filter...
|
||||
```
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Packet Properties
|
||||
Stanza Properties
|
||||
=================
|
||||
|
||||
Smack provides an easy mechanism for attaching arbitrary properties to
|
||||
|
@ -20,7 +20,7 @@ jpe.setProperty("favoriteColor", new Color(0, 0, 255));
|
|||
// Add an int as a property._
|
||||
jpe.setProperty("favoriteNumber", 4);
|
||||
// Add the JivePropertiesExtension to the message packet_
|
||||
message.addPacketExtension(jpe);
|
||||
message.addStanzaExtension(jpe);
|
||||
chat.sendMessage(message);
|
||||
```
|
||||
|
||||
|
@ -39,8 +39,8 @@ int favoriteNumber = ((Integer)jpe.getProperty("favoriteNumber")).intValue();
|
|||
```
|
||||
|
||||
For convenience `JivePropertiesManager` contains two helper methods namely
|
||||
`addProperty(Packet packet, String name, Object value)` and
|
||||
`getProperty(Packet packet, String name)`.
|
||||
`addProperty(Stanza packet, String name, Object value)` and
|
||||
`getProperty(Stanza packet, String name)`.
|
||||
|
||||
Objects as Properties
|
||||
---------------------
|
||||
|
|
|
@ -98,7 +98,7 @@ done. The last step is to send the message as you do with any other message.
|
|||
An XHTML message is like any regular message, therefore to send the message
|
||||
you can follow the usual steps you do in order to send a message. For example,
|
||||
to send a message as part of a chat just use the message **#send(Message)** of
|
||||
_**Chat**_ or you can use the message **#send(Packet)** of
|
||||
_**Chat**_ or you can use the message **#send(Stanza)** of
|
||||
_**XMPPConnection**_.
|
||||
|
||||
**Example**
|
||||
|
@ -143,7 +143,7 @@ XHTML bodies of any received message.
|
|||
```
|
||||
// Create a listener for the chat and display any XHTML content
|
||||
PacketListener packetListener = new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
public void processPacket(Stanza packet) {
|
||||
Message message = (Message) packet;
|
||||
// Obtain the XHTML bodies of the message
|
||||
List<CharSequence> bodies = XHTMLManager.getBodies(message);
|
||||
|
|
|
@ -83,7 +83,7 @@ Retrieve the roster using the `Roster.getInstanceFor(XMPPConnection)` method. Th
|
|||
class allows you to find all the roster entries, the groups they belong to,
|
||||
and the current presence status of each entry.
|
||||
|
||||
Reading and Writing Packets
|
||||
Reading and Writing Stanzas
|
||||
|
||||
Each message to the XMPP server from a client is called a packet and is sent
|
||||
as XML. The `org.jivesoftware.smack.packet` package contains classes that
|
||||
|
@ -102,7 +102,7 @@ con.sendPacket(presence);
|
|||
```
|
||||
|
||||
Smack provides two ways to read incoming packets: `PacketListener`, and
|
||||
`PacketCollector`. Both use `PacketFilter` instances to determine which
|
||||
`PacketCollector`. Both use `StanzaFilter` instances to determine which
|
||||
packets should be processed. A packet listener is used for event style
|
||||
programming, while a packet collector has a result queue of packets that you
|
||||
can do polling and blocking operations on. So, a packet listener is useful
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* [Managing Connections](connections.html)
|
||||
* [Messaging Basics](messaging.html)
|
||||
* [Roster and Presence](roster.html)
|
||||
* [Processing Incoming Packets](processing.html)
|
||||
* [Processing Incoming Stanzas](processing.html)
|
||||
* [Provider Architecture](providers.html)
|
||||
* [Debugging with Smack](debugging.html)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Processing Incoming Packets
|
||||
Processing Incoming Stanzas
|
||||
===========================
|
||||
|
||||
[Back](index.html)
|
||||
|
@ -9,7 +9,7 @@ constructs:
|
|||
* `org.jivesoftware.smack.PacketCollector` -- a class that lets you synchronously wait for new packets.
|
||||
* `org.jivesoftware.smack.PacketListener` -- an interface for asynchronously notifying you of incoming packets. A packet listener is used for event style programming, while a packet collector has a result queue of packets that you can do polling and blocking operations on. So, a packet listener is useful when you want to take some action whenever a packet happens to come in, while a packet collector is useful when you want to wait for a specific packet to arrive. Packet collectors and listeners can be created using an `XMPPConnection` instance.
|
||||
|
||||
The `org.jivesoftware.smack.filter.PacketFilter` interface determines which
|
||||
The `org.jivesoftware.smack.filter.StanzaFilter` interface determines which
|
||||
specific packets will be delivered to a `PacketCollector` or `PacketListener`.
|
||||
Many pre-defined filters can be found in the `org.jivesoftware.smack.filter`
|
||||
package.
|
||||
|
@ -20,7 +20,7 @@ and a packet listener:
|
|||
```
|
||||
// Create a packet filter to listen for new messages from a particular
|
||||
// user. We use an AndFilter to combine two other filters._
|
||||
PacketFilter filter = new AndFilter(new PacketTypeFilter(Message.class),
|
||||
StanzaFilter filter = new AndFilter(new StanzaTypeFilter(Message.class),
|
||||
new FromContainsFilter("mary@jivesoftware.com"));
|
||||
// Assume we've created an XMPPConnection name "connection".
|
||||
|
||||
|
@ -38,19 +38,19 @@ PacketListener myListener = new PacketListener() {
|
|||
connection.addPacketListener(myListener, filter);
|
||||
```
|
||||
|
||||
Standard Packet Filters
|
||||
Standard Stanza Filters
|
||||
-----------------------
|
||||
|
||||
A rich set of packet filters are included with Smack, or you can create your
|
||||
own filters by coding to the `PacketFilter` interface. The default set of
|
||||
own filters by coding to the `StanzaFilter` interface. The default set of
|
||||
filters includes:
|
||||
|
||||
* `PacketTypeFilter` -- filters for packets that are a particular Class type.
|
||||
* `StanzaTypeFilter` -- filters for packets that are a particular Class type.
|
||||
* `StanzaIdFilter` -- filters for packets with a particular packet ID.
|
||||
* `ThreadFilter` -- filters for message packets with a particular thread ID.
|
||||
* `ToContainsFilter` -- filters for packets that are sent to a particular address.
|
||||
* `FromContainsFilter` -- filters for packets that are sent to a particular address.
|
||||
* `PacketExtensionFilter` -- filters for packets that have a particular packet extension.
|
||||
* `StanzaExtensionFilter` -- filters for packets that have a particular packet extension.
|
||||
* `AndFilter` -- implements the logical AND operation over two filters.
|
||||
* `OrFilter` -- implements the logical OR operation over two filters.
|
||||
* `NotFilter` -- implements the logical NOT operation on a filter.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Provider Architecture: Packet Extensions and Custom IQ's
|
||||
Provider Architecture: Stanza Extensions and Custom IQ's
|
||||
========================================================
|
||||
|
||||
[Back](index.html)
|
||||
|
@ -73,7 +73,7 @@ an XMPP time packet resembles the following:
|
|||
|
||||
### Introspection
|
||||
|
||||
_Time Packet_
|
||||
_Time Stanza_
|
||||
|
||||
|
||||
<iq type='result' to='joe@example.com' from='mary@example.com' id='time_1'>
|
||||
|
@ -190,7 +190,7 @@ public class MyIQProvider extends IQProvider<MyIQ> {
|
|||
|
||||
### DiscoItemsProvider
|
||||
|
||||
_Disco Items Packet_
|
||||
_Disco Items Stanza_
|
||||
|
||||
|
||||
|
||||
|
@ -264,11 +264,11 @@ _Disco Items IQProvider_
|
|||
Extension Providers
|
||||
-------------------
|
||||
|
||||
Packet extension providers are responsible for parsing packet extensions,
|
||||
Stanza extension providers are responsible for parsing packet extensions,
|
||||
which are child elements in a custom namespace of IQ, message and presence
|
||||
packets.
|
||||
|
||||
_Pubsub Subscription Packet_
|
||||
_Pubsub Subscription Stanza_
|
||||
|
||||
|
||||
<iq type='result' from='pubsub.shakespeare.lit' to='francisco@denmark.lit/barracks' id='sub1'>
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.jivesoftware.smack;
|
|||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.test.SmackTestCase;
|
||||
import org.jivesoftware.smackx.packet.Version;
|
||||
|
@ -51,7 +51,7 @@ public class IQTest extends SmackTestCase {
|
|||
};
|
||||
|
||||
PacketFilter filter = new AndFilter(new PacketIDFilter(iq.getStanzaId()),
|
||||
new PacketTypeFilter(IQ.class));
|
||||
new StanzaTypeFilter(IQ.class));
|
||||
PacketCollector collector = getConnection(0).createPacketCollector(filter);
|
||||
// Send the iq packet with an invalid namespace
|
||||
getConnection(0).sendPacket(iq);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smack;
|
|||
|
||||
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.*;
|
||||
import org.jivesoftware.smack.test.SmackTestCase;
|
||||
|
@ -143,7 +143,7 @@ public class PacketReaderTest extends SmackTestCase {
|
|||
message.setBody("HELLO");
|
||||
getConnection(1).sendPacket(message);
|
||||
}
|
||||
}, new PacketTypeFilter(Message.class));
|
||||
}, new StanzaTypeFilter(Message.class));
|
||||
|
||||
// User0 listen for replies from user1
|
||||
PacketCollector collector = getConnection(0).createPacketCollector(
|
||||
|
|
|
@ -21,9 +21,9 @@ import junit.framework.TestCase;
|
|||
import org.jivesoftware.smack.packet.*;
|
||||
|
||||
/**
|
||||
* Test cases for the PacketTypeFilter class.
|
||||
* Test cases for the StanzaTypeFilter class.
|
||||
*/
|
||||
public class PacketTypeFilterTest extends TestCase {
|
||||
public class StanzaTypeFilterTest extends TestCase {
|
||||
|
||||
private class InnerClassDummy {
|
||||
public class DummyPacket extends Packet {
|
||||
|
@ -48,20 +48,20 @@ public class PacketTypeFilterTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test case for the constructor of PacketTypeFilter objects.
|
||||
* Test case for the constructor of StanzaTypeFilter objects.
|
||||
*/
|
||||
public void testConstructor() {
|
||||
// We dont need to test this since PacketTypeFilter(Class<? extends Packet> packetType) only excepts Packets
|
||||
// We dont need to test this since StanzaTypeFilter(Class<? extends Packet> packetType) only excepts Packets
|
||||
// Test a class that is not a subclass of Packet
|
||||
// try {
|
||||
// new PacketTypeFilter(Dummy.class);
|
||||
// new StanzaTypeFilter(Dummy.class);
|
||||
// fail("Parameter must be a subclass of Packet.");
|
||||
// }
|
||||
// catch (IllegalArgumentException e) {}
|
||||
|
||||
// Test a class that is a subclass of Packet
|
||||
try {
|
||||
new PacketTypeFilter(MockPacket.class);
|
||||
new StanzaTypeFilter(MockPacket.class);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
fail();
|
||||
|
@ -69,7 +69,7 @@ public class PacketTypeFilterTest extends TestCase {
|
|||
|
||||
// Test another class which is a subclass of Packet
|
||||
try {
|
||||
new PacketTypeFilter(IQ.class);
|
||||
new StanzaTypeFilter(IQ.class);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
fail();
|
||||
|
@ -77,7 +77,7 @@ public class PacketTypeFilterTest extends TestCase {
|
|||
|
||||
// Test an internal class which is a subclass of Packet
|
||||
try {
|
||||
new PacketTypeFilter(InnerClassDummy.DummyPacket.class);
|
||||
new StanzaTypeFilter(InnerClassDummy.DummyPacket.class);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
fail();
|
||||
|
@ -85,7 +85,7 @@ public class PacketTypeFilterTest extends TestCase {
|
|||
|
||||
// Test an internal static class which is a static subclass of Packet
|
||||
try {
|
||||
new PacketTypeFilter(StaticInnerClassDummy.StaticDummyPacket.class);
|
||||
new StanzaTypeFilter(StaticInnerClassDummy.StaticDummyPacket.class);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
fail();
|
||||
|
@ -93,19 +93,19 @@ public class PacketTypeFilterTest extends TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test case to test the accept() method of PacketTypeFilter objects.
|
||||
* Test case to test the accept() method of StanzaTypeFilter objects.
|
||||
*/
|
||||
public void testAccept() {
|
||||
Packet packet = new MockPacket();
|
||||
PacketTypeFilter filter = new PacketTypeFilter(MockPacket.class);
|
||||
StanzaTypeFilter filter = new PacketTypeFilter(MockPacket.class);
|
||||
assertTrue(filter.accept(packet));
|
||||
|
||||
packet = (new InnerClassDummy()).getInnerInstance();
|
||||
filter = new PacketTypeFilter(InnerClassDummy.DummyPacket.class);
|
||||
filter = new StanzaTypeFilter(InnerClassDummy.DummyPacket.class);
|
||||
assertTrue(filter.accept(packet));
|
||||
|
||||
packet = StaticInnerClassDummy.getInnerInstance();
|
||||
filter = new PacketTypeFilter(StaticInnerClassDummy.StaticDummyPacket.class);
|
||||
filter = new StanzaTypeFilter(StaticInnerClassDummy.StaticDummyPacket.class);
|
||||
assertTrue(filter.accept(packet));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ import org.jivesoftware.smack.compress.packet.Compress;
|
|||
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
|
||||
import org.jivesoftware.smack.debugger.SmackDebugger;
|
||||
import org.jivesoftware.smack.filter.IQReplyFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaIdFilter;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
|
||||
import org.jivesoftware.smack.packet.Bind;
|
||||
|
@ -64,7 +64,7 @@ import org.jivesoftware.smack.packet.ErrorIQ;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Mechanisms;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Session;
|
||||
import org.jivesoftware.smack.packet.StartTls;
|
||||
|
@ -72,7 +72,7 @@ import org.jivesoftware.smack.packet.PlainStreamElement;
|
|||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.parsing.ParsingExceptionCallback;
|
||||
import org.jivesoftware.smack.parsing.UnparsablePacket;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
import org.jivesoftware.smack.util.DNSUtil;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
|
@ -154,7 +154,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
|
||||
protected final Lock connectionLock = new ReentrantLock();
|
||||
|
||||
protected final Map<String, PacketExtension> streamFeatures = new HashMap<String, PacketExtension>();
|
||||
protected final Map<String, ExtensionElement> streamFeatures = new HashMap<String, ExtensionElement>();
|
||||
|
||||
/**
|
||||
* The full JID of the authenticated user, as returned by the resource binding response of the server.
|
||||
|
@ -716,14 +716,14 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
|
||||
@Override
|
||||
public PacketCollector createPacketCollectorAndSend(IQ packet) throws NotConnectedException {
|
||||
PacketFilter packetFilter = new IQReplyFilter(packet, this);
|
||||
StanzaFilter packetFilter = new IQReplyFilter(packet, this);
|
||||
// Create the packet collector before sending the packet
|
||||
PacketCollector packetCollector = createPacketCollectorAndSend(packetFilter, packet);
|
||||
return packetCollector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketCollector createPacketCollectorAndSend(PacketFilter packetFilter, Stanza packet)
|
||||
public PacketCollector createPacketCollectorAndSend(StanzaFilter packetFilter, Stanza packet)
|
||||
throws NotConnectedException {
|
||||
// Create the packet collector before sending the packet
|
||||
PacketCollector packetCollector = createPacketCollector(packetFilter);
|
||||
|
@ -739,8 +739,8 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PacketCollector createPacketCollector(PacketFilter packetFilter) {
|
||||
PacketCollector.Configuration configuration = PacketCollector.newConfiguration().setPacketFilter(packetFilter);
|
||||
public PacketCollector createPacketCollector(StanzaFilter packetFilter) {
|
||||
PacketCollector.Configuration configuration = PacketCollector.newConfiguration().setStanzaFilter(packetFilter);
|
||||
return createPacketCollector(configuration);
|
||||
}
|
||||
|
||||
|
@ -759,7 +759,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void addPacketListener(PacketListener packetListener, PacketFilter packetFilter) {
|
||||
public void addPacketListener(PacketListener packetListener, StanzaFilter packetFilter) {
|
||||
addAsyncPacketListener(packetListener, packetFilter);
|
||||
}
|
||||
|
||||
|
@ -770,7 +770,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addSyncPacketListener(PacketListener packetListener, PacketFilter packetFilter) {
|
||||
public void addSyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter) {
|
||||
if (packetListener == null) {
|
||||
throw new NullPointerException("Packet listener is null.");
|
||||
}
|
||||
|
@ -788,7 +788,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addAsyncPacketListener(PacketListener packetListener, PacketFilter packetFilter) {
|
||||
public void addAsyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter) {
|
||||
if (packetListener == null) {
|
||||
throw new NullPointerException("Packet listener is null.");
|
||||
}
|
||||
|
@ -806,7 +806,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addPacketSendingListener(PacketListener packetListener, PacketFilter packetFilter) {
|
||||
public void addPacketSendingListener(PacketListener packetListener, StanzaFilter packetFilter) {
|
||||
if (packetListener == null) {
|
||||
throw new NullPointerException("Packet listener is null.");
|
||||
}
|
||||
|
@ -862,7 +862,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
|
||||
@Override
|
||||
public void addPacketInterceptor(PacketListener packetInterceptor,
|
||||
PacketFilter packetFilter) {
|
||||
StanzaFilter packetFilter) {
|
||||
if (packetInterceptor == null) {
|
||||
throw new NullPointerException("Packet interceptor is null.");
|
||||
}
|
||||
|
@ -1244,7 +1244,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
protected static class ListenerWrapper {
|
||||
|
||||
private final PacketListener packetListener;
|
||||
private final PacketFilter packetFilter;
|
||||
private final StanzaFilter packetFilter;
|
||||
|
||||
/**
|
||||
* Create a class which associates a packet filter with a listener.
|
||||
|
@ -1252,7 +1252,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
* @param packetListener the packet listener.
|
||||
* @param packetFilter the associated filter or null if it listen for all packets.
|
||||
*/
|
||||
public ListenerWrapper(PacketListener packetListener, PacketFilter packetFilter) {
|
||||
public ListenerWrapper(PacketListener packetListener, StanzaFilter packetFilter) {
|
||||
this.packetListener = packetListener;
|
||||
this.packetFilter = packetFilter;
|
||||
}
|
||||
|
@ -1272,7 +1272,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
protected static class InterceptorWrapper {
|
||||
|
||||
private final PacketListener packetInterceptor;
|
||||
private final PacketFilter packetFilter;
|
||||
private final StanzaFilter packetFilter;
|
||||
|
||||
/**
|
||||
* Create a class which associates a packet filter with an interceptor.
|
||||
|
@ -1280,7 +1280,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
* @param packetInterceptor the interceptor.
|
||||
* @param packetFilter the associated filter or null if it intercepts all packets.
|
||||
*/
|
||||
public InterceptorWrapper(PacketListener packetInterceptor, PacketFilter packetFilter) {
|
||||
public InterceptorWrapper(PacketListener packetInterceptor, StanzaFilter packetFilter) {
|
||||
this.packetInterceptor = packetInterceptor;
|
||||
this.packetFilter = packetFilter;
|
||||
}
|
||||
|
@ -1339,7 +1339,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
int eventType = parser.next();
|
||||
|
||||
if (eventType == XmlPullParser.START_TAG && parser.getDepth() == initialDepth + 1) {
|
||||
PacketExtension streamFeature = null;
|
||||
ExtensionElement streamFeature = null;
|
||||
String name = parser.getName();
|
||||
String namespace = parser.getNamespace();
|
||||
switch (name) {
|
||||
|
@ -1359,7 +1359,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
streamFeature = PacketParserUtils.parseCompressionFeature(parser);
|
||||
break;
|
||||
default:
|
||||
PacketExtensionProvider<PacketExtension> provider = ProviderManager.getStreamFeatureProvider(name, namespace);
|
||||
ExtensionElementProvider<ExtensionElement> provider = ProviderManager.getStreamFeatureProvider(name, namespace);
|
||||
if (provider != null) {
|
||||
streamFeature = provider.parse(parser);
|
||||
}
|
||||
|
@ -1401,7 +1401,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <F extends PacketExtension> F getFeature(String element, String namespace) {
|
||||
public <F extends ExtensionElement> F getFeature(String element, String namespace) {
|
||||
return (F) streamFeatures.get(XmppStringUtils.generateKey(element, namespace));
|
||||
}
|
||||
|
||||
|
@ -1410,19 +1410,19 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
return getFeature(element, namespace) != null;
|
||||
}
|
||||
|
||||
private void addStreamFeature(PacketExtension feature) {
|
||||
private void addStreamFeature(ExtensionElement feature) {
|
||||
String key = XmppStringUtils.generateKey(feature.getElementName(), feature.getNamespace());
|
||||
streamFeatures.put(key, feature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter,
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||
PacketListener callback) throws NotConnectedException {
|
||||
sendStanzaWithResponseCallback(stanza, replyFilter, callback, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter,
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||
PacketListener callback, ExceptionCallback exceptionCallback)
|
||||
throws NotConnectedException {
|
||||
sendStanzaWithResponseCallback(stanza, replyFilter, callback, exceptionCallback,
|
||||
|
@ -1430,7 +1430,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, final PacketFilter replyFilter,
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, final StanzaFilter replyFilter,
|
||||
final PacketListener callback, final ExceptionCallback exceptionCallback,
|
||||
long timeout) throws NotConnectedException {
|
||||
Objects.requireNonNull(stanza, "stanza must not be null");
|
||||
|
@ -1487,12 +1487,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
public void sendIqWithResponseCallback(IQ iqRequest, final PacketListener callback,
|
||||
final ExceptionCallback exceptionCallback, long timeout)
|
||||
throws NotConnectedException {
|
||||
PacketFilter replyFilter = new IQReplyFilter(iqRequest, this);
|
||||
StanzaFilter replyFilter = new IQReplyFilter(iqRequest, this);
|
||||
sendStanzaWithResponseCallback(iqRequest, replyFilter, callback, exceptionCallback, timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOneTimeSyncCallback(final PacketListener callback, final PacketFilter packetFilter) {
|
||||
public void addOneTimeSyncCallback(final PacketListener callback, final StanzaFilter packetFilter) {
|
||||
final PacketListener packetListener = new PacketListener() {
|
||||
@Override
|
||||
public void processPacket(Stanza packet) throws NotConnectedException {
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.logging.Logger;
|
|||
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
/**
|
||||
|
@ -38,14 +38,14 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
* older packets are automatically dropped. The default number is retrieved by
|
||||
* {@link SmackConfiguration#getPacketCollectorSize()}.
|
||||
*
|
||||
* @see XMPPConnection#createPacketCollector(PacketFilter)
|
||||
* @see XMPPConnection#createPacketCollector(StanzaFilter)
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class PacketCollector {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(PacketCollector.class.getName());
|
||||
|
||||
private final PacketFilter packetFilter;
|
||||
private final StanzaFilter packetFilter;
|
||||
private final ArrayBlockingQueue<Stanza> resultQueue;
|
||||
|
||||
/**
|
||||
|
@ -89,8 +89,20 @@ public class PacketCollector {
|
|||
* filter is used to determine what packets are queued as results.
|
||||
*
|
||||
* @return the packet filter.
|
||||
* @deprecated use {@link #getStanzaFilter()} instead.
|
||||
*/
|
||||
public PacketFilter getPacketFilter() {
|
||||
@Deprecated
|
||||
public StanzaFilter getPacketFilter() {
|
||||
return getStanzaFilter();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stanza filter associated with this stanza collector. The stanza
|
||||
* filter is used to determine what stanzas are queued as results.
|
||||
*
|
||||
* @return the stanza filter.
|
||||
*/
|
||||
public StanzaFilter getStanzaFilter() {
|
||||
return packetFilter;
|
||||
}
|
||||
|
||||
|
@ -266,7 +278,7 @@ public class PacketCollector {
|
|||
}
|
||||
|
||||
public static class Configuration {
|
||||
private PacketFilter packetFilter;
|
||||
private StanzaFilter packetFilter;
|
||||
private int size = SmackConfiguration.getPacketCollectorSize();
|
||||
private PacketCollector collectorToReset;
|
||||
|
||||
|
@ -279,9 +291,22 @@ public class PacketCollector {
|
|||
*
|
||||
* @param packetFilter
|
||||
* @return a reference to this configuration.
|
||||
* @deprecated use {@link #setStanzaFilter(StanzaFilter)} instead.
|
||||
*/
|
||||
public Configuration setPacketFilter(PacketFilter packetFilter) {
|
||||
this.packetFilter = packetFilter;
|
||||
@Deprecated
|
||||
public Configuration setPacketFilter(StanzaFilter packetFilter) {
|
||||
return setStanzaFilter(packetFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the stanza filter used by this collector. If <code>null</code>, then all stanzas will
|
||||
* get collected by this collector.
|
||||
*
|
||||
* @param stanzaFilter
|
||||
* @return a reference to this configuration.
|
||||
*/
|
||||
public Configuration setStanzaFilter(StanzaFilter stanzaFilter) {
|
||||
this.packetFilter = stanzaFilter;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
* Additionally you are able to intercept Packets that are going to be send and
|
||||
* make modifications to them. You can register a PacketListener as interceptor
|
||||
* by using {@link XMPPConnection#addPacketInterceptor(PacketListener,
|
||||
* org.jivesoftware.smack.filter.PacketFilter)}
|
||||
* org.jivesoftware.smack.filter.StanzaFilter)}
|
||||
* </p>
|
||||
*
|
||||
* @see XMPPConnection#addAsyncPacketListener(PacketListener, org.jivesoftware.smack.filter.PacketFilter)
|
||||
* @see XMPPConnection#addAsyncPacketListener(PacketListener, org.jivesoftware.smack.filter.StanzaFilter)
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public interface PacketListener {
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smack;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.util.dns.HostAddress;
|
||||
|
||||
/**
|
||||
|
@ -65,9 +65,9 @@ public class SmackException extends Exception {
|
|||
*/
|
||||
private static final long serialVersionUID = -6523363748984543636L;
|
||||
|
||||
private final PacketFilter filter;
|
||||
private final StanzaFilter filter;
|
||||
|
||||
private NoResponseException(String message, PacketFilter filter) {
|
||||
private NoResponseException(String message, StanzaFilter filter) {
|
||||
super(message);
|
||||
this.filter = filter;
|
||||
}
|
||||
|
@ -77,20 +77,20 @@ public class SmackException extends Exception {
|
|||
*
|
||||
* @return the used filter or <code>null</code>.
|
||||
*/
|
||||
public PacketFilter getFilter() {
|
||||
public StanzaFilter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
public static NoResponseException newWith(XMPPConnection connection) {
|
||||
return newWith(connection, (PacketFilter) null);
|
||||
return newWith(connection, (StanzaFilter) null);
|
||||
}
|
||||
|
||||
public static NoResponseException newWith(XMPPConnection connection,
|
||||
PacketCollector collector) {
|
||||
return newWith(connection, collector.getPacketFilter());
|
||||
return newWith(connection, collector.getStanzaFilter());
|
||||
}
|
||||
|
||||
public static NoResponseException newWith(XMPPConnection connection, PacketFilter filter) {
|
||||
public static NoResponseException newWith(XMPPConnection connection, StanzaFilter filter) {
|
||||
final long replyTimeout = connection.getPacketReplyTimeout();
|
||||
final StringBuilder sb = new StringBuilder(256);
|
||||
sb.append("No response received within reply timeout. Timeout was "
|
||||
|
|
|
@ -20,11 +20,11 @@ package org.jivesoftware.smack;
|
|||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.filter.IQReplyFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.PlainStreamElement;
|
||||
|
||||
/**
|
||||
|
@ -211,7 +211,7 @@ public interface XMPPConnection {
|
|||
* @param packet the packet to send right after the collector got created
|
||||
* @return a new packet collector.
|
||||
*/
|
||||
public PacketCollector createPacketCollectorAndSend(PacketFilter packetFilter, Stanza packet)
|
||||
public PacketCollector createPacketCollectorAndSend(StanzaFilter packetFilter, Stanza packet)
|
||||
throws NotConnectedException;
|
||||
|
||||
/**
|
||||
|
@ -222,7 +222,7 @@ public interface XMPPConnection {
|
|||
* <p>
|
||||
* <b>Note:</b> If you send a Packet right after using this method, then
|
||||
* consider using
|
||||
* {@link #createPacketCollectorAndSend(PacketFilter, Stanza)} instead.
|
||||
* {@link #createPacketCollectorAndSend(StanzaFilter, Stanza)} instead.
|
||||
* Otherwise make sure cancel the PacketCollector in every case, e.g. even
|
||||
* if an exception is thrown, or otherwise you may leak the PacketCollector.
|
||||
* </p>
|
||||
|
@ -230,13 +230,13 @@ public interface XMPPConnection {
|
|||
* @param packetFilter the packet filter to use.
|
||||
* @return a new packet collector.
|
||||
*/
|
||||
public PacketCollector createPacketCollector(PacketFilter packetFilter);
|
||||
public PacketCollector createPacketCollector(StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Create a new packet collector with the given packet collector configuration.
|
||||
* <p>
|
||||
* Please make sure to cancel the collector when it is no longer required. See also
|
||||
* {@link #createPacketCollector(PacketFilter)}.
|
||||
* {@link #createPacketCollector(StanzaFilter)}.
|
||||
* </p>
|
||||
*
|
||||
* @param configuration the packet collector configuration.
|
||||
|
@ -257,17 +257,17 @@ public interface XMPPConnection {
|
|||
* <p>
|
||||
* This method has been deprecated. It is important to differentiate between using an asynchronous packet listener
|
||||
* (preferred where possible) and a synchronous packet lister. Refer
|
||||
* {@link #addAsyncPacketListener(PacketListener, PacketFilter)} and
|
||||
* {@link #addSyncPacketListener(PacketListener, PacketFilter)} for more information.
|
||||
* {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} and
|
||||
* {@link #addSyncPacketListener(PacketListener, StanzaFilter)} for more information.
|
||||
* </p>
|
||||
*
|
||||
* @param packetListener the packet listener to notify of new received packets.
|
||||
* @param packetFilter the packet filter to use.
|
||||
* @deprecated use {@link #addAsyncPacketListener(PacketListener, PacketFilter)} or
|
||||
* {@link #addSyncPacketListener(PacketListener, PacketFilter)}.
|
||||
* @deprecated use {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} or
|
||||
* {@link #addSyncPacketListener(PacketListener, StanzaFilter)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void addPacketListener(PacketListener packetListener, PacketFilter packetFilter);
|
||||
public void addPacketListener(PacketListener packetListener, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Removes a packet listener for received packets from this connection.
|
||||
|
@ -286,17 +286,17 @@ public interface XMPPConnection {
|
|||
* <p>
|
||||
* <b>Important:</b> This packet listeners will be called in the same <i>single</i> thread that processes all
|
||||
* incoming stanzas. Only use this kind of packet filter if it does not perform any XMPP activity that waits for a
|
||||
* response. Consider using {@link #addAsyncPacketListener(PacketListener, PacketFilter)} when possible, i.e. when
|
||||
* response. Consider using {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} when possible, i.e. when
|
||||
* the invocation order doesn't have to be the same as the order of the arriving packets. If the order of the
|
||||
* arriving packets, consider using a {@link PacketCollector} when possible.
|
||||
* </p>
|
||||
*
|
||||
* @param packetListener the packet listener to notify of new received packets.
|
||||
* @param packetFilter the packet filter to use.
|
||||
* @see #addPacketInterceptor(PacketListener, PacketFilter)
|
||||
* @see #addPacketInterceptor(PacketListener, StanzaFilter)
|
||||
* @since 4.1
|
||||
*/
|
||||
public void addSyncPacketListener(PacketListener packetListener, PacketFilter packetFilter);
|
||||
public void addSyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Removes a packet listener for received packets from this connection.
|
||||
|
@ -312,17 +312,17 @@ public interface XMPPConnection {
|
|||
* when an incoming packet is received. A packet filter determines which packets will be delivered to the listener.
|
||||
* If the same packet listener is added again with a different filter, only the new filter will be used.
|
||||
* <p>
|
||||
* Unlike {@link #addAsyncPacketListener(PacketListener, PacketFilter)} packet listeners added with this method will be
|
||||
* Unlike {@link #addAsyncPacketListener(PacketListener, StanzaFilter)} packet listeners added with this method will be
|
||||
* invoked asynchronously in their own thread. Use this method if the order of the packet listeners must not depend
|
||||
* on the order how the stanzas where received.
|
||||
* </p>
|
||||
*
|
||||
* @param packetListener the packet listener to notify of new received packets.
|
||||
* @param packetFilter the packet filter to use.
|
||||
* @see #addPacketInterceptor(PacketListener, PacketFilter)
|
||||
* @see #addPacketInterceptor(PacketListener, StanzaFilter)
|
||||
* @since 4.1
|
||||
*/
|
||||
public void addAsyncPacketListener(PacketListener packetListener, PacketFilter packetFilter);
|
||||
public void addAsyncPacketListener(PacketListener packetListener, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Removes an <b>asynchronous</b> packet listener for received packets from this connection.
|
||||
|
@ -344,7 +344,7 @@ public interface XMPPConnection {
|
|||
* @param packetListener the packet listener to notify of sent packets.
|
||||
* @param packetFilter the packet filter to use.
|
||||
*/
|
||||
public void addPacketSendingListener(PacketListener packetListener, PacketFilter packetFilter);
|
||||
public void addPacketSendingListener(PacketListener packetListener, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Removes a packet listener for sending packets from this connection.
|
||||
|
@ -360,12 +360,12 @@ public interface XMPPConnection {
|
|||
* will be delivered to the interceptor.
|
||||
*
|
||||
* <p>
|
||||
* NOTE: For a similar functionality on incoming packets, see {@link #addAsyncPacketListener(PacketListener, PacketFilter)}.
|
||||
* NOTE: For a similar functionality on incoming packets, see {@link #addAsyncPacketListener(PacketListener, StanzaFilter)}.
|
||||
*
|
||||
* @param packetInterceptor the packet interceptor to notify of packets about to be sent.
|
||||
* @param packetFilter the packet filter to use.
|
||||
*/
|
||||
public void addPacketInterceptor(PacketListener packetInterceptor, PacketFilter packetFilter);
|
||||
public void addPacketInterceptor(PacketListener packetInterceptor, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Removes a packet interceptor.
|
||||
|
@ -439,7 +439,7 @@ public interface XMPPConnection {
|
|||
* @param namespace
|
||||
* @return a packet extensions of the feature or <code>null</code>
|
||||
*/
|
||||
public <F extends PacketExtension> F getFeature(String element, String namespace);
|
||||
public <F extends ExtensionElement> F getFeature(String element, String namespace);
|
||||
|
||||
/**
|
||||
* Return true if the server supports the given stream feature.
|
||||
|
@ -463,7 +463,7 @@ public interface XMPPConnection {
|
|||
* @param callback the callback invoked if there is a response (required)
|
||||
* @throws NotConnectedException
|
||||
*/
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter,
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||
PacketListener callback) throws NotConnectedException;
|
||||
|
||||
/**
|
||||
|
@ -480,7 +480,7 @@ public interface XMPPConnection {
|
|||
* @param exceptionCallback the callback invoked if there is an exception (optional)
|
||||
* @throws NotConnectedException
|
||||
*/
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter, PacketListener callback,
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter, PacketListener callback,
|
||||
ExceptionCallback exceptionCallback) throws NotConnectedException;
|
||||
|
||||
/**
|
||||
|
@ -498,7 +498,7 @@ public interface XMPPConnection {
|
|||
* @param timeout the timeout in milliseconds to wait for a response
|
||||
* @throws NotConnectedException
|
||||
*/
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, PacketFilter replyFilter,
|
||||
public void sendStanzaWithResponseCallback(Stanza stanza, StanzaFilter replyFilter,
|
||||
final PacketListener callback, final ExceptionCallback exceptionCallback,
|
||||
long timeout) throws NotConnectedException;
|
||||
|
||||
|
@ -554,7 +554,7 @@ public interface XMPPConnection {
|
|||
* @param callback the callback invoked once the packet filter matches a stanza.
|
||||
* @param packetFilter the filter to match stanzas or null to match all.
|
||||
*/
|
||||
public void addOneTimeSyncCallback(PacketListener callback, PacketFilter packetFilter);
|
||||
public void addOneTimeSyncCallback(PacketListener callback, StanzaFilter packetFilter);
|
||||
|
||||
/**
|
||||
* Register an IQ request handler with this connection.
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.FullStreamElement;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public class Compress extends FullStreamElement {
|
||||
|
@ -53,7 +53,7 @@ public class Compress extends FullStreamElement {
|
|||
return xml;
|
||||
}
|
||||
|
||||
public static class Feature implements PacketExtension {
|
||||
public static class Feature implements ExtensionElement {
|
||||
public static final String ELEMENT = "compression";
|
||||
|
||||
public final List<String> methods;
|
||||
|
|
|
@ -27,18 +27,18 @@ import org.jivesoftware.smack.util.Objects;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractListFilter implements PacketFilter {
|
||||
public abstract class AbstractListFilter implements StanzaFilter {
|
||||
|
||||
/**
|
||||
* The list of filters.
|
||||
*/
|
||||
protected final List<PacketFilter> filters;
|
||||
protected final List<StanzaFilter> filters;
|
||||
|
||||
/**
|
||||
* Creates an empty filter.
|
||||
*/
|
||||
protected AbstractListFilter() {
|
||||
filters = new ArrayList<PacketFilter>();
|
||||
filters = new ArrayList<StanzaFilter>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,12 +46,12 @@ public abstract class AbstractListFilter implements PacketFilter {
|
|||
*
|
||||
* @param filters the filters to add.
|
||||
*/
|
||||
protected AbstractListFilter(PacketFilter... filters) {
|
||||
protected AbstractListFilter(StanzaFilter... filters) {
|
||||
Objects.requireNonNull(filters, "Parameter must not be null.");
|
||||
for(PacketFilter filter : filters) {
|
||||
for(StanzaFilter filter : filters) {
|
||||
Objects.requireNonNull(filter, "Parameter must not be null.");
|
||||
}
|
||||
this.filters = new ArrayList<PacketFilter>(Arrays.asList(filters));
|
||||
this.filters = new ArrayList<StanzaFilter>(Arrays.asList(filters));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,7 +60,7 @@ public abstract class AbstractListFilter implements PacketFilter {
|
|||
*
|
||||
* @param filter a filter to add to the filter list.
|
||||
*/
|
||||
public void addFilter(PacketFilter filter) {
|
||||
public void addFilter(StanzaFilter filter) {
|
||||
Objects.requireNonNull(filter, "Parameter must not be null.");
|
||||
filters.add(filter);
|
||||
}
|
||||
|
@ -70,8 +70,8 @@ public abstract class AbstractListFilter implements PacketFilter {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(": (");
|
||||
for (Iterator<PacketFilter> it = filters.iterator(); it.hasNext();) {
|
||||
PacketFilter filter = it.next();
|
||||
for (Iterator<StanzaFilter> it = filters.iterator(); it.hasNext();) {
|
||||
StanzaFilter filter = it.next();
|
||||
sb.append(filter.toString());
|
||||
if (it.hasNext()) {
|
||||
sb.append(", ");
|
||||
|
|
|
@ -25,11 +25,11 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class AndFilter extends AbstractListFilter implements PacketFilter {
|
||||
public class AndFilter extends AbstractListFilter implements StanzaFilter {
|
||||
|
||||
/**
|
||||
* Creates an empty AND filter. Filters should be added using the
|
||||
* {@link #addFilter(PacketFilter)} method.
|
||||
* {@link #addFilter(StanzaFilter)} method.
|
||||
*/
|
||||
public AndFilter() {
|
||||
super();
|
||||
|
@ -40,12 +40,12 @@ public class AndFilter extends AbstractListFilter implements PacketFilter {
|
|||
*
|
||||
* @param filters the filters to add.
|
||||
*/
|
||||
public AndFilter(PacketFilter... filters) {
|
||||
public AndFilter(StanzaFilter... filters) {
|
||||
super(filters);
|
||||
}
|
||||
|
||||
public boolean accept(Stanza packet) {
|
||||
for (PacketFilter filter : filters) {
|
||||
for (StanzaFilter filter : filters) {
|
||||
if (!filter.accept(packet)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2014 Florian Schmaus
|
||||
* Copyright 2014-2015 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,39 +23,36 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
import org.jivesoftware.smack.util.Objects;
|
||||
|
||||
/**
|
||||
* Filters for packets of a particular type and allows a custom method to further filter the packets.
|
||||
* Filters for stanzas of a particular type and allows a custom method to further filter the packets.
|
||||
*
|
||||
* @author Florian Schmaus
|
||||
*/
|
||||
public abstract class FlexiblePacketTypeFilter<P extends Stanza> implements PacketFilter {
|
||||
public abstract class FlexibleStanzaTypeFilter<S extends Stanza> implements StanzaFilter {
|
||||
|
||||
protected final Class<P> packetType;
|
||||
protected final Class<S> stanzaType;
|
||||
|
||||
public FlexiblePacketTypeFilter(Class<P> packetType) {
|
||||
this.packetType = Objects.requireNonNull(packetType, "Type must not be null");
|
||||
public FlexibleStanzaTypeFilter(Class<S> packetType) {
|
||||
this.stanzaType = Objects.requireNonNull(packetType, "Type must not be null");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public FlexiblePacketTypeFilter() {
|
||||
packetType = (Class<P>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||
public FlexibleStanzaTypeFilter() {
|
||||
stanzaType = (Class<S>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean accept(Stanza packet) {
|
||||
if (packetType.isInstance(packet)) {
|
||||
return acceptSpecific((P) packet);
|
||||
public final boolean accept(Stanza packet) {
|
||||
if (stanzaType.isInstance(packet)) {
|
||||
return acceptSpecific((S) packet);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract boolean acceptSpecific(P packet);
|
||||
protected abstract boolean acceptSpecific(S packet);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" (" + packetType.toString() + ')');
|
||||
return sb.toString();
|
||||
return getClass().getSimpleName() + ": " + stanzaType.toString();
|
||||
}
|
||||
}
|
|
@ -30,7 +30,7 @@ import org.jxmpp.util.XmppStringUtils;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class FromMatchesFilter implements PacketFilter {
|
||||
public class FromMatchesFilter implements StanzaFilter {
|
||||
|
||||
private final String address;
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ import org.jxmpp.util.XmppStringUtils;
|
|||
* @author Lars Noschinski
|
||||
*
|
||||
*/
|
||||
public class IQReplyFilter implements PacketFilter {
|
||||
public class IQReplyFilter implements StanzaFilter {
|
||||
private static final Logger LOGGER = Logger.getLogger(IQReplyFilter.class.getName());
|
||||
|
||||
private final PacketFilter iqAndIdFilter;
|
||||
private final StanzaFilter iqAndIdFilter;
|
||||
private final OrFilter fromFilter;
|
||||
private final String to;
|
||||
private final String local;
|
||||
|
@ -98,8 +98,8 @@ public class IQReplyFilter implements PacketFilter {
|
|||
server = conn.getServiceName().toLowerCase(Locale.US);
|
||||
packetId = iqPacket.getStanzaId();
|
||||
|
||||
PacketFilter iqFilter = new OrFilter(IQTypeFilter.ERROR, IQTypeFilter.RESULT);
|
||||
PacketFilter idFilter = new StanzaIdFilter(iqPacket);
|
||||
StanzaFilter iqFilter = new OrFilter(IQTypeFilter.ERROR, IQTypeFilter.RESULT);
|
||||
StanzaFilter idFilter = new StanzaIdFilter(iqPacket);
|
||||
iqAndIdFilter = new AndFilter(iqFilter, idFilter);
|
||||
fromFilter = new OrFilter();
|
||||
fromFilter.addFilter(FromMatchesFilter.createFull(to));
|
||||
|
|
|
@ -27,13 +27,13 @@ import org.jivesoftware.smack.util.Objects;
|
|||
* @author Alexander Wenckus
|
||||
*
|
||||
*/
|
||||
public class IQTypeFilter extends FlexiblePacketTypeFilter<IQ> {
|
||||
public class IQTypeFilter extends FlexibleStanzaTypeFilter<IQ> {
|
||||
|
||||
public static final PacketFilter GET = new IQTypeFilter(Type.get);
|
||||
public static final PacketFilter SET = new IQTypeFilter(Type.set);
|
||||
public static final PacketFilter RESULT = new IQTypeFilter(Type.result);
|
||||
public static final PacketFilter ERROR = new IQTypeFilter(Type.error);
|
||||
public static final PacketFilter GET_OR_SET = new OrFilter(GET, SET);
|
||||
public static final StanzaFilter GET = new IQTypeFilter(Type.get);
|
||||
public static final StanzaFilter SET = new IQTypeFilter(Type.set);
|
||||
public static final StanzaFilter RESULT = new IQTypeFilter(Type.result);
|
||||
public static final StanzaFilter ERROR = new IQTypeFilter(Type.error);
|
||||
public static final StanzaFilter GET_OR_SET = new OrFilter(GET, SET);
|
||||
|
||||
private final IQ.Type type;
|
||||
|
||||
|
|
|
@ -27,15 +27,15 @@ import org.jivesoftware.smack.packet.Message.Type;
|
|||
* @see org.jivesoftware.smack.packet.Message.Type
|
||||
* @author Ward Harold
|
||||
*/
|
||||
public class MessageTypeFilter extends FlexiblePacketTypeFilter<Message> {
|
||||
public class MessageTypeFilter extends FlexibleStanzaTypeFilter<Message> {
|
||||
|
||||
public static final PacketFilter NORMAL = new MessageTypeFilter(Type.normal);
|
||||
public static final PacketFilter CHAT = new MessageTypeFilter(Type.chat);
|
||||
public static final PacketFilter GROUPCHAT = new MessageTypeFilter(Type.groupchat);
|
||||
public static final PacketFilter HEADLINE = new MessageTypeFilter(Type.headline);
|
||||
public static final PacketFilter ERROR = new MessageTypeFilter(Type.error);
|
||||
public static final PacketFilter NORMAL_OR_CHAT = new OrFilter(NORMAL, CHAT);
|
||||
public static final PacketFilter NORMAL_OR_CHAT_OR_HEADLINE = new OrFilter(NORMAL_OR_CHAT,
|
||||
public static final StanzaFilter NORMAL = new MessageTypeFilter(Type.normal);
|
||||
public static final StanzaFilter CHAT = new MessageTypeFilter(Type.chat);
|
||||
public static final StanzaFilter GROUPCHAT = new MessageTypeFilter(Type.groupchat);
|
||||
public static final StanzaFilter HEADLINE = new MessageTypeFilter(Type.headline);
|
||||
public static final StanzaFilter ERROR = new MessageTypeFilter(Type.error);
|
||||
public static final StanzaFilter NORMAL_OR_CHAT = new OrFilter(NORMAL, CHAT);
|
||||
public static final StanzaFilter NORMAL_OR_CHAT_OR_HEADLINE = new OrFilter(NORMAL_OR_CHAT,
|
||||
HEADLINE);
|
||||
|
||||
private final Message.Type type;
|
||||
|
|
|
@ -22,9 +22,9 @@ import org.jivesoftware.smack.packet.Message;
|
|||
/**
|
||||
* Filters message stanzas which have at least one body
|
||||
*/
|
||||
public class MessageWithBodiesFilter extends FlexiblePacketTypeFilter<Message> {
|
||||
public class MessageWithBodiesFilter extends FlexibleStanzaTypeFilter<Message> {
|
||||
|
||||
public static final PacketFilter INSTANCE = new MessageWithBodiesFilter();
|
||||
public static final StanzaFilter INSTANCE = new MessageWithBodiesFilter();
|
||||
|
||||
private MessageWithBodiesFilter() {
|
||||
super(Message.class);
|
||||
|
|
|
@ -22,9 +22,9 @@ import org.jivesoftware.smack.packet.Message;
|
|||
/**
|
||||
* Filters message stanzas which have at least one body
|
||||
*/
|
||||
public class MessageWithSubjectFilter extends FlexiblePacketTypeFilter<Message> {
|
||||
public class MessageWithSubjectFilter extends FlexibleStanzaTypeFilter<Message> {
|
||||
|
||||
public static final PacketFilter INSTANCE = new MessageWithSubjectFilter();
|
||||
public static final StanzaFilter INSTANCE = new MessageWithSubjectFilter();
|
||||
|
||||
private MessageWithSubjectFilter() {
|
||||
super(Message.class);
|
||||
|
|
|
@ -26,16 +26,16 @@ import org.jivesoftware.smack.util.Objects;
|
|||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class NotFilter implements PacketFilter {
|
||||
public class NotFilter implements StanzaFilter {
|
||||
|
||||
private final PacketFilter filter;
|
||||
private final StanzaFilter filter;
|
||||
|
||||
/**
|
||||
* Creates a NOT filter using the specified filter.
|
||||
*
|
||||
* @param filter the filter.
|
||||
*/
|
||||
public NotFilter(PacketFilter filter) {
|
||||
public NotFilter(StanzaFilter filter) {
|
||||
this.filter = Objects.requireNonNull(filter, "Parameter must not be null.");
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,11 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class OrFilter extends AbstractListFilter implements PacketFilter {
|
||||
public class OrFilter extends AbstractListFilter implements StanzaFilter {
|
||||
|
||||
/**
|
||||
* Creates an empty OR filter. Filters should be added using the
|
||||
* {@link #addFilter(PacketFilter)} method.
|
||||
* {@link #addFilter(StanzaFilter)} method.
|
||||
*/
|
||||
public OrFilter() {
|
||||
super();
|
||||
|
@ -40,13 +40,13 @@ public class OrFilter extends AbstractListFilter implements PacketFilter {
|
|||
*
|
||||
* @param filters the filters to add.
|
||||
*/
|
||||
public OrFilter(PacketFilter... filters) {
|
||||
public OrFilter(StanzaFilter... filters) {
|
||||
super(filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(Stanza packet) {
|
||||
for (PacketFilter filter : filters) {
|
||||
for (StanzaFilter filter : filters) {
|
||||
if (filter.accept(packet)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -18,15 +18,17 @@
|
|||
package org.jivesoftware.smack.filter;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Filters for packets with a particular type of packet extension.
|
||||
*
|
||||
* @author Matt Tucker
|
||||
* @deprecated use {@link StanzaExtensionFilter} instead.
|
||||
*/
|
||||
public class PacketExtensionFilter implements PacketFilter {
|
||||
@Deprecated
|
||||
public class PacketExtensionFilter implements StanzaFilter {
|
||||
|
||||
private final String elementName;
|
||||
private final String namespace;
|
||||
|
@ -61,7 +63,7 @@ public class PacketExtensionFilter implements PacketFilter {
|
|||
*
|
||||
* @param packetExtension
|
||||
*/
|
||||
public PacketExtensionFilter(PacketExtension packetExtension) {
|
||||
public PacketExtensionFilter(ExtensionElement packetExtension) {
|
||||
this(packetExtension.getElementName(), packetExtension.getNamespace());
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
package org.jivesoftware.smack.filter;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
/**
|
||||
* Defines a way to filter packets for particular attributes. Packet filters are used when
|
||||
* constructing packet listeners or collectors -- the filter defines what packets match the criteria
|
||||
|
@ -45,14 +43,9 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
* @see org.jivesoftware.smack.PacketCollector
|
||||
* @see org.jivesoftware.smack.PacketListener
|
||||
* @author Matt Tucker
|
||||
* @deprecated use {@link StanzaFilter}
|
||||
*/
|
||||
public interface PacketFilter {
|
||||
@Deprecated
|
||||
public interface PacketFilter extends StanzaFilter {
|
||||
|
||||
/**
|
||||
* Tests whether or not the specified packet should pass the filter.
|
||||
*
|
||||
* @param packet the packet to test.
|
||||
* @return true if and only if <tt>packet</tt> passes the filter.
|
||||
*/
|
||||
public boolean accept(Stanza packet);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.util.StringUtils;
|
|||
* @deprecated use {@link StanzaIdFilter} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public class PacketIDFilter implements PacketFilter {
|
||||
public class PacketIDFilter implements StanzaFilter {
|
||||
|
||||
private final String packetID;
|
||||
|
||||
|
|
|
@ -31,8 +31,10 @@ import org.jivesoftware.smack.packet.Presence;
|
|||
* </ul>
|
||||
*
|
||||
* @author Matt Tucker
|
||||
* @deprecated use {@link StanzaTypeFilter} instead.
|
||||
*/
|
||||
public class PacketTypeFilter implements PacketFilter {
|
||||
@Deprecated
|
||||
public class PacketTypeFilter implements StanzaFilter {
|
||||
|
||||
public static final PacketTypeFilter PRESENCE = new PacketTypeFilter(Presence.class);
|
||||
public static final PacketTypeFilter MESSAGE = new PacketTypeFilter(Message.class);
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.jivesoftware.smack.util.Objects;
|
|||
* A filter for Presence types. Returns true only if the stanza is an Presence packet and it matches the type provided in the
|
||||
* constructor.
|
||||
*/
|
||||
public class PresenceTypeFilter extends FlexiblePacketTypeFilter<Presence> {
|
||||
public class PresenceTypeFilter extends FlexibleStanzaTypeFilter<Presence> {
|
||||
|
||||
public static final PresenceTypeFilter AVAILABLE = new PresenceTypeFilter(Type.available);
|
||||
public static final PresenceTypeFilter UNAVAILABLE = new PresenceTypeFilter(Type.unavailable);
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack.filter;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Filters for stanzas with a particular type of stanza extension.
|
||||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class StanzaExtensionFilter implements StanzaFilter {
|
||||
|
||||
private final String elementName;
|
||||
private final String namespace;
|
||||
|
||||
/**
|
||||
* Creates a new stanza extension filter. Stanzas will pass the filter if
|
||||
* they have a stanza extension that matches the specified element name
|
||||
* and namespace.
|
||||
*
|
||||
* @param elementName the XML element name of the stanza extension.
|
||||
* @param namespace the XML namespace of the stanza extension.
|
||||
*/
|
||||
public StanzaExtensionFilter(String elementName, String namespace) {
|
||||
StringUtils.requireNotNullOrEmpty(namespace, "namespace must not be null or empty");
|
||||
|
||||
this.elementName = elementName;
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new stanza extension filter. Stanzas will pass the filter if they have a stanza
|
||||
* extension that matches the specified namespace.
|
||||
*
|
||||
* @param namespace the XML namespace of the stanza extension.
|
||||
*/
|
||||
public StanzaExtensionFilter(String namespace) {
|
||||
this(null, namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new stanza extension filter for the given stanza extension.
|
||||
*
|
||||
* @param packetExtension
|
||||
*/
|
||||
public StanzaExtensionFilter(ExtensionElement packetExtension) {
|
||||
this(packetExtension.getElementName(), packetExtension.getNamespace());
|
||||
}
|
||||
|
||||
public boolean accept(Stanza packet) {
|
||||
return packet.hasExtension(elementName, namespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + ": element=" + elementName + " namespace=" + namespace;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack.filter;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
/**
|
||||
* Defines a way to filter stanzas for particular attributes. Stanza filters are used when
|
||||
* constructing stanza listeners or collectors -- the filter defines what stanzas match the criteria
|
||||
* of the collector or listener for further stanza processing.
|
||||
* <p>
|
||||
* Several simple filters are pre-defined. These filters can be logically combined for more complex
|
||||
* stanza filtering by using the {@link org.jivesoftware.smack.filter.AndFilter AndFilter} and
|
||||
* {@link org.jivesoftware.smack.filter.OrFilter OrFilter} filters. It's also possible to define
|
||||
* your own filters by implementing this interface. The code example below creates a trivial filter
|
||||
* for stanzas with a specific ID (real code should use {@link StanzaIdFilter} instead).
|
||||
*
|
||||
* <pre>
|
||||
* // Use an anonymous inner class to define a stanza filter that returns
|
||||
* // all stanzas that have a stanza ID of "RS145".
|
||||
* StanzaFilter myFilter = new StanzaFilter() {
|
||||
* public boolean accept(Stanza stanza) {
|
||||
* return "RS145".equals(stanza.getStanzaId());
|
||||
* }
|
||||
* };
|
||||
* // Create a new stanza collector using the filter we created.
|
||||
* PacketCollector myCollector = connection.createPacketCollector(myFilter);
|
||||
* </pre>
|
||||
*
|
||||
* @see org.jivesoftware.smack.PacketCollector
|
||||
* @see org.jivesoftware.smack.PacketListener
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public interface StanzaFilter {
|
||||
|
||||
/**
|
||||
* Tests whether or not the specified stanza should pass the filter.
|
||||
*
|
||||
* @param stanza the packet to test.
|
||||
* @return true if and only if <tt>stanza</tt> passes the filter.
|
||||
*/
|
||||
public boolean accept(Stanza stanza);
|
||||
}
|
|
@ -25,7 +25,7 @@ import org.jivesoftware.smack.util.StringUtils;
|
|||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class StanzaIdFilter implements PacketFilter {
|
||||
public class StanzaIdFilter implements StanzaFilter {
|
||||
|
||||
private final String stanzaId;
|
||||
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack.filter;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
/**
|
||||
* Filters for Stanzas of a particular type. The type is given as a Class object, so
|
||||
* example types would:
|
||||
* <ul>
|
||||
* <li><tt>Message.class</tt>
|
||||
* <li><tt>IQ.class</tt>
|
||||
* <li><tt>Presence.class</tt>
|
||||
* </ul>
|
||||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public final class StanzaTypeFilter implements StanzaFilter {
|
||||
|
||||
public static final StanzaTypeFilter PRESENCE = new StanzaTypeFilter(Presence.class);
|
||||
public static final StanzaTypeFilter MESSAGE = new StanzaTypeFilter(Message.class);
|
||||
public static final StanzaTypeFilter IQ = new StanzaTypeFilter(IQ.class);
|
||||
|
||||
private final Class<? extends Stanza> packetType;
|
||||
|
||||
/**
|
||||
* Creates a new packet type filter that will filter for packets that are the
|
||||
* same type as <tt>packetType</tt>.
|
||||
*
|
||||
* @param packetType the Class type.
|
||||
*/
|
||||
public StanzaTypeFilter(Class<? extends Stanza> packetType) {
|
||||
this.packetType = packetType;
|
||||
}
|
||||
|
||||
public boolean accept(Stanza packet) {
|
||||
return packetType.isInstance(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName() + ": " + packetType.getName();
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ import org.jivesoftware.smack.util.StringUtils;
|
|||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class ThreadFilter extends FlexiblePacketTypeFilter<Message> implements PacketFilter {
|
||||
public class ThreadFilter extends FlexibleStanzaTypeFilter<Message> implements StanzaFilter {
|
||||
|
||||
private final String thread;
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Locale;
|
|||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
||||
public class ToFilter implements PacketFilter {
|
||||
public class ToFilter implements StanzaFilter {
|
||||
|
||||
private final String to;
|
||||
|
||||
|
|
|
@ -28,18 +28,18 @@ public class AbstractError {
|
|||
|
||||
private final String textNamespace;
|
||||
protected final Map<String, String> descriptiveTexts;
|
||||
private final List<PacketExtension> extensions;
|
||||
private final List<ExtensionElement> extensions;
|
||||
|
||||
|
||||
protected AbstractError(Map<String, String> descriptiveTexts) {
|
||||
this(descriptiveTexts, null);
|
||||
}
|
||||
|
||||
protected AbstractError(Map<String, String> descriptiveTexts, List<PacketExtension> extensions) {
|
||||
protected AbstractError(Map<String, String> descriptiveTexts, List<ExtensionElement> extensions) {
|
||||
this(descriptiveTexts, null, extensions);
|
||||
}
|
||||
|
||||
protected AbstractError(Map<String, String> descriptiveTexts, String textNamespace, List<PacketExtension> extensions) {
|
||||
protected AbstractError(Map<String, String> descriptiveTexts, String textNamespace, List<ExtensionElement> extensions) {
|
||||
if (descriptiveTexts != null) {
|
||||
this.descriptiveTexts = descriptiveTexts;
|
||||
} else {
|
||||
|
@ -91,7 +91,7 @@ public class AbstractError {
|
|||
* @param namespace the XML element namespace of the packet extension.
|
||||
* @return the extension, or <tt>null</tt> if it doesn't exist.
|
||||
*/
|
||||
public <PE extends PacketExtension> PE getExtension(String elementName, String namespace) {
|
||||
public <PE extends ExtensionElement> PE getExtension(String elementName, String namespace) {
|
||||
return PacketUtil.extensionElementFrom(extensions, elementName, namespace);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class AbstractError {
|
|||
xml.escape(text);
|
||||
xml.closeElement("text");
|
||||
}
|
||||
for (PacketExtension packetExtension : extensions) {
|
||||
for (ExtensionElement packetExtension : extensions) {
|
||||
xml.append(packetExtension.toXML());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class Bind extends IQ {
|
|||
return xml;
|
||||
}
|
||||
|
||||
public static class Feature implements PacketExtension {
|
||||
public static class Feature implements ExtensionElement {
|
||||
|
||||
public static final Feature INSTANCE = new Feature();
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Map;
|
|||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
/**
|
||||
* Default implementation of the PacketExtension interface. Unless a PacketExtensionProvider
|
||||
* Default implementation of the ExtensionElement interface. Unless a ExtensionElementProvider
|
||||
* is registered with {@link org.jivesoftware.smack.provider.ProviderManager ProviderManager},
|
||||
* instances of this class will be returned when getting packet extensions.<p>
|
||||
*
|
||||
|
@ -42,11 +42,11 @@ import org.jivesoftware.smack.util.XmlStringBuilder;
|
|||
* In this case, getValue("color") would return "blue", and getValue("food") would
|
||||
* return "pizza". This parsing mechanism mechanism is very simplistic and will not work
|
||||
* as desired in all cases (for example, if some of the elements have attributes. In those
|
||||
* cases, a custom PacketExtensionProvider should be used.
|
||||
* cases, a custom ExtensionElementProvider should be used.
|
||||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public class DefaultPacketExtension implements PacketExtension {
|
||||
public class DefaultExtensionElement implements ExtensionElement {
|
||||
|
||||
private String elementName;
|
||||
private String namespace;
|
||||
|
@ -58,7 +58,7 @@ public class DefaultPacketExtension implements PacketExtension {
|
|||
* @param elementName the name of the element of the XML sub-document.
|
||||
* @param namespace the namespace of the element.
|
||||
*/
|
||||
public DefaultPacketExtension(String elementName, String namespace) {
|
||||
public DefaultExtensionElement(String elementName, String namespace) {
|
||||
this.elementName = elementName;
|
||||
this.namespace = namespace;
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
package org.jivesoftware.smack.packet;
|
||||
|
||||
/**
|
||||
* Interface to represent a XML element. This is similar to {@link PacketExtension}, but does not
|
||||
* Interface to represent a XML element. This is similar to {@link ExtensionElement}, but does not
|
||||
* carry a namespace and is usually included as child element of an packet extension.
|
||||
*/
|
||||
public interface Element {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2003-2007 Jive Software.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
/**
|
||||
* Interface to represent extension elements.
|
||||
* <p>
|
||||
* An extension element is an XML subdocument
|
||||
* with a root element name and namespace. Extension elements are used to provide
|
||||
* extended functionality beyond what is in the base XMPP specification. Examples of
|
||||
* extensions elements include message events, message properties, and extra presence data.
|
||||
* IQ stanzas have limited support for extension elements.
|
||||
* <p>
|
||||
* This class is used primarily for extended content in XMPP Stanzas, to act as so called "extension elements". For more
|
||||
* information see <a href="https://tools.ietf.org/html/rfc6120#section-8.4">RFC 6120 § 8.4 Extended Content</a>.
|
||||
* </p>
|
||||
*
|
||||
* @see DefaultExtensionElement
|
||||
* @see org.jivesoftware.smack.provider.ExtensionElementProvider
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public interface ExtensionElement extends NamedElement {
|
||||
|
||||
/**
|
||||
* Returns the root element XML namespace.
|
||||
*
|
||||
* @return the namespace.
|
||||
*/
|
||||
public String getNamespace();
|
||||
|
||||
}
|
|
@ -23,6 +23,6 @@ package org.jivesoftware.smack.packet;
|
|||
*
|
||||
* @author Florian Schmaus
|
||||
*/
|
||||
public abstract class FullStreamElement implements PlainStreamElement, PacketExtension {
|
||||
public abstract class FullStreamElement implements PlainStreamElement, ExtensionElement {
|
||||
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ public abstract class IQ extends Stanza {
|
|||
this(iq.getChildElementName(), iq.getChildElementNamespace());
|
||||
}
|
||||
|
||||
public IQChildElementXmlStringBuilder(PacketExtension pe) {
|
||||
public IQChildElementXmlStringBuilder(ExtensionElement pe) {
|
||||
this(pe.getElementName(), pe.getNamespace());
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public class Mechanisms implements PacketExtension {
|
||||
public class Mechanisms implements ExtensionElement {
|
||||
|
||||
public static final String ELEMENT = "mechanisms";
|
||||
public static final String NAMESPACE = "urn:ietf:params:xml:ns:xmpp-sasl";
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.jivesoftware.smack.packet;
|
||||
|
||||
/**
|
||||
* Interface to represent a XML element. This is similar to {@link PacketExtension}, but does not
|
||||
* Interface to represent a XML element. This is similar to {@link ExtensionElement}, but does not
|
||||
* carry a namespace and is usually included as child element of an packet extension.
|
||||
*/
|
||||
public interface NamedElement extends Element {
|
||||
|
|
|
@ -132,7 +132,7 @@ public interface Packet extends TopLevelStreamElement {
|
|||
*
|
||||
* @return the packet extensions.
|
||||
*/
|
||||
public List<PacketExtension> getExtensions();
|
||||
public List<ExtensionElement> getExtensions();
|
||||
|
||||
/**
|
||||
* Return a set of all extensions with the given element name <emph>and</emph> namespace.
|
||||
|
@ -145,7 +145,7 @@ public interface Packet extends TopLevelStreamElement {
|
|||
* @return a set of all matching extensions.
|
||||
* @since 4.1
|
||||
*/
|
||||
public Set<PacketExtension> getExtensions(String elementName, String namespace);
|
||||
public Set<ExtensionElement> getExtensions(String elementName, String namespace);
|
||||
|
||||
/**
|
||||
* Returns the first extension of this packet that has the given namespace.
|
||||
|
@ -156,7 +156,7 @@ public interface Packet extends TopLevelStreamElement {
|
|||
* @param namespace the namespace of the extension that is desired.
|
||||
* @return the packet extension with the given namespace.
|
||||
*/
|
||||
public PacketExtension getExtension(String namespace);
|
||||
public ExtensionElement getExtension(String namespace);
|
||||
|
||||
/**
|
||||
* Returns the first packet extension that matches the specified element name and
|
||||
|
@ -173,20 +173,20 @@ public interface Packet extends TopLevelStreamElement {
|
|||
* @param namespace the XML element namespace of the packet extension.
|
||||
* @return the extension, or <tt>null</tt> if it doesn't exist.
|
||||
*/
|
||||
public <PE extends PacketExtension> PE getExtension(String elementName, String namespace);
|
||||
public <PE extends ExtensionElement> PE getExtension(String elementName, String namespace);
|
||||
/**
|
||||
* Adds a packet extension to the packet. Does nothing if extension is null.
|
||||
*
|
||||
* @param extension a packet extension.
|
||||
*/
|
||||
public void addExtension(PacketExtension extension);
|
||||
public void addExtension(ExtensionElement extension);
|
||||
|
||||
/**
|
||||
* Adds a collection of packet extensions to the packet. Does nothing if extensions is null.
|
||||
*
|
||||
* @param extensions a collection of packet extensions
|
||||
*/
|
||||
public void addExtensions(Collection<PacketExtension> extensions);
|
||||
public void addExtensions(Collection<ExtensionElement> extensions);
|
||||
|
||||
/**
|
||||
* Check if a packet extension with the given element and namespace exists.
|
||||
|
@ -215,7 +215,7 @@ public interface Packet extends TopLevelStreamElement {
|
|||
* @param namespace
|
||||
* @return the removed packet extension or null.
|
||||
*/
|
||||
public PacketExtension removeExtension(String elementName, String namespace);
|
||||
public ExtensionElement removeExtension(String elementName, String namespace);
|
||||
|
||||
/**
|
||||
* Removes a packet extension from the packet.
|
||||
|
@ -223,7 +223,7 @@ public interface Packet extends TopLevelStreamElement {
|
|||
* @param extension the packet extension to remove.
|
||||
* @return the removed packet extension or null.
|
||||
*/
|
||||
public PacketExtension removeExtension(PacketExtension extension);
|
||||
public ExtensionElement removeExtension(ExtensionElement extension);
|
||||
|
||||
@Override
|
||||
// NOTE When Smack is using Java 8, then this method should be moved in Element as "Default Method".
|
||||
|
|
|
@ -18,27 +18,24 @@
|
|||
package org.jivesoftware.smack.packet;
|
||||
|
||||
/**
|
||||
* Interface to represent packet extensions. A packet extension is an XML subdocument
|
||||
* with a root element name and namespace. Packet extensions are used to provide
|
||||
* Interface to represent extension elements.
|
||||
* <p>
|
||||
* An extension element is an XML subdocument
|
||||
* with a root element name and namespace. Extension elements are used to provide
|
||||
* extended functionality beyond what is in the base XMPP specification. Examples of
|
||||
* packet extensions include message events, message properties, and extra presence data.
|
||||
* IQ packets cannot contain packet extensions.
|
||||
* extensions elements include message events, message properties, and extra presence data.
|
||||
* IQ stanzas have limited support for extension elements.
|
||||
* <p>
|
||||
* This class is used primarily for extended content in XMPP Stanzas, to act as so called "extension elements". For more
|
||||
* information see <a href="https://tools.ietf.org/html/rfc6120#section-8.4">RFC 6120 § 8.4 Extended Content</a>.
|
||||
* </p>
|
||||
*
|
||||
* @see DefaultPacketExtension
|
||||
* @see org.jivesoftware.smack.provider.PacketExtensionProvider
|
||||
* @see DefaultExtensionElement
|
||||
* @see org.jivesoftware.smack.provider.ExtensionElementProvider
|
||||
* @author Matt Tucker
|
||||
* @deprecated use {@link ExtensionElement} instead.
|
||||
*/
|
||||
public interface PacketExtension extends NamedElement {
|
||||
|
||||
/**
|
||||
* Returns the root element XML namespace.
|
||||
*
|
||||
* @return the namespace.
|
||||
*/
|
||||
public String getNamespace();
|
||||
@Deprecated
|
||||
public interface PacketExtension extends ExtensionElement {
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class Session extends SimpleIQ {
|
|||
setType(IQ.Type.set);
|
||||
}
|
||||
|
||||
public static class Feature implements PacketExtension {
|
||||
public static class Feature implements ExtensionElement {
|
||||
|
||||
public static final String OPTIONAL_ELEMENT = "optional";
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
protected static final String DEFAULT_LANGUAGE =
|
||||
java.util.Locale.getDefault().getLanguage().toLowerCase(Locale.US);
|
||||
|
||||
private final MultiMap<String, PacketExtension> packetExtensions = new MultiMap<>();
|
||||
private final MultiMap<String, ExtensionElement> packetExtensions = new MultiMap<>();
|
||||
|
||||
private String id = null;
|
||||
private String to = null;
|
||||
|
@ -88,7 +88,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
error = p.error;
|
||||
|
||||
// Copy extensions
|
||||
for (PacketExtension pe : p.getExtensions()) {
|
||||
for (ExtensionElement pe : p.getExtensions()) {
|
||||
addExtension(pe);
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
*
|
||||
* @return a list of all extension elements of this stanza.
|
||||
*/
|
||||
public List<PacketExtension> getExtensions() {
|
||||
public List<ExtensionElement> getExtensions() {
|
||||
synchronized (packetExtensions) {
|
||||
// No need to create a new list, values() will already create a new one for us
|
||||
return packetExtensions.values();
|
||||
|
@ -252,7 +252,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
* @return a set of all matching extensions.
|
||||
* @since 4.1
|
||||
*/
|
||||
public Set<PacketExtension> getExtensions(String elementName, String namespace) {
|
||||
public Set<ExtensionElement> getExtensions(String elementName, String namespace) {
|
||||
requireNotNullOrEmpty(elementName, "elementName must not be null or empty");
|
||||
requireNotNullOrEmpty(namespace, "namespace must not be null or empty");
|
||||
String key = XmppStringUtils.generateKey(elementName, namespace);
|
||||
|
@ -268,32 +268,32 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
* @param namespace the namespace of the extension that is desired.
|
||||
* @return the packet extension with the given namespace.
|
||||
*/
|
||||
public PacketExtension getExtension(String namespace) {
|
||||
public ExtensionElement getExtension(String namespace) {
|
||||
return PacketUtil.extensionElementFrom(getExtensions(), null, namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first packet extension that matches the specified element name and
|
||||
* Returns the first extension that matches the specified element name and
|
||||
* namespace, or <tt>null</tt> if it doesn't exist. If the provided elementName is null,
|
||||
* only the namespace is matched. Packet extensions are
|
||||
* only the namespace is matched. Extensions are
|
||||
* are arbitrary XML sub-documents in standard XMPP packets. By default, a
|
||||
* DefaultPacketExtension instance will be returned for each extension. However,
|
||||
* PacketExtensionProvider instances can be registered with the
|
||||
* {@link DefaultExtensionElement} instance will be returned for each extension. However,
|
||||
* ExtensionElementProvider instances can be registered with the
|
||||
* {@link org.jivesoftware.smack.provider.ProviderManager ProviderManager}
|
||||
* class to handle custom parsing. In that case, the type of the Object
|
||||
* will be determined by the provider.
|
||||
*
|
||||
* @param elementName the XML element name of the packet extension. (May be null)
|
||||
* @param namespace the XML element namespace of the packet extension.
|
||||
* @param elementName the XML element name of the extension. (May be null)
|
||||
* @param namespace the XML element namespace of the extension.
|
||||
* @return the extension, or <tt>null</tt> if it doesn't exist.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <PE extends PacketExtension> PE getExtension(String elementName, String namespace) {
|
||||
public <PE extends ExtensionElement> PE getExtension(String elementName, String namespace) {
|
||||
if (namespace == null) {
|
||||
return null;
|
||||
}
|
||||
String key = XmppStringUtils.generateKey(elementName, namespace);
|
||||
PacketExtension packetExtension;
|
||||
ExtensionElement packetExtension;
|
||||
synchronized (packetExtensions) {
|
||||
packetExtension = packetExtensions.getFirst(key);
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
*
|
||||
* @param extension a packet extension.
|
||||
*/
|
||||
public void addExtension(PacketExtension extension) {
|
||||
public void addExtension(ExtensionElement extension) {
|
||||
if (extension == null) return;
|
||||
String key = XmppStringUtils.generateKey(extension.getElementName(), extension.getNamespace());
|
||||
synchronized (packetExtensions) {
|
||||
|
@ -321,9 +321,9 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
*
|
||||
* @param extensions a collection of packet extensions
|
||||
*/
|
||||
public void addExtensions(Collection<PacketExtension> extensions) {
|
||||
public void addExtensions(Collection<ExtensionElement> extensions) {
|
||||
if (extensions == null) return;
|
||||
for (PacketExtension packetExtension : extensions) {
|
||||
for (ExtensionElement packetExtension : extensions) {
|
||||
addExtension(packetExtension);
|
||||
}
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
*/
|
||||
public boolean hasExtension(String namespace) {
|
||||
synchronized (packetExtensions) {
|
||||
for (PacketExtension packetExtension : packetExtensions.values()) {
|
||||
for (ExtensionElement packetExtension : packetExtensions.values()) {
|
||||
if (packetExtension.getNamespace().equals(namespace)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
* @param namespace
|
||||
* @return the removed packet extension or null.
|
||||
*/
|
||||
public PacketExtension removeExtension(String elementName, String namespace) {
|
||||
public ExtensionElement removeExtension(String elementName, String namespace) {
|
||||
String key = XmppStringUtils.generateKey(elementName, namespace);
|
||||
synchronized (packetExtensions) {
|
||||
return packetExtensions.remove(key);
|
||||
|
@ -385,7 +385,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
* @param extension the packet extension to remove.
|
||||
* @return the removed packet extension or null.
|
||||
*/
|
||||
public PacketExtension removeExtension(PacketExtension extension) {
|
||||
public ExtensionElement removeExtension(ExtensionElement extension) {
|
||||
return removeExtension(extension.getElementName(), extension.getNamespace());
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,7 @@ public abstract class Stanza implements TopLevelStreamElement, Packet {
|
|||
protected final XmlStringBuilder getExtensionsXML() {
|
||||
XmlStringBuilder xml = new XmlStringBuilder();
|
||||
// Add in all standard extension sub-packets.
|
||||
for (PacketExtension extension : getExtensions()) {
|
||||
for (ExtensionElement extension : getExtensions()) {
|
||||
xml.append(extension.toXML());
|
||||
}
|
||||
return xml;
|
||||
|
|
|
@ -104,7 +104,7 @@ public class StreamError extends AbstractError implements PlainStreamElement {
|
|||
private final Condition condition;
|
||||
private final String conditionText;
|
||||
|
||||
public StreamError(Condition condition, String conditionText, Map<String, String> descriptiveTexts, List<PacketExtension> extensions) {
|
||||
public StreamError(Condition condition, String conditionText, Map<String, String> descriptiveTexts, List<ExtensionElement> extensions) {
|
||||
super(descriptiveTexts, extensions);
|
||||
// Some implementations may send the condition as non-empty element containing the empty string, that is
|
||||
// <condition xmlns='foo'></condition>, in this case the parser may calls this constructor with the empty string
|
||||
|
|
|
@ -99,7 +99,7 @@ public class XMPPError extends AbstractError {
|
|||
this(condition, null, null, null, null, null);
|
||||
}
|
||||
|
||||
public XMPPError(Condition condition, PacketExtension applicationSpecificCondition) {
|
||||
public XMPPError(Condition condition, ExtensionElement applicationSpecificCondition) {
|
||||
this(condition, null, null, null, null, Arrays.asList(applicationSpecificCondition));
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class XMPPError extends AbstractError {
|
|||
* @param extensions list of packet extensions
|
||||
*/
|
||||
public XMPPError(Condition condition, String conditionText, String errorGenerator, Type type, Map<String, String> descriptiveTexts,
|
||||
List<PacketExtension> extensions) {
|
||||
List<ExtensionElement> extensions) {
|
||||
super(descriptiveTexts, NAMESPACE, extensions);
|
||||
this.condition = condition;
|
||||
// Some implementations may send the condition as non-empty element containing the empty string, that is
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -61,7 +61,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
* <tt>ItemsProvider</tt> extends {@link EmbeddedExtensionProvider}
|
||||
* <tt>ItemProvider</tt> extends {@link EmbeddedExtensionProvider}
|
||||
* and
|
||||
* AtomProvider extends {@link PacketExtensionProvider}
|
||||
* AtomProvider extends {@link ExtensionElementProvider}
|
||||
*
|
||||
* These classes are then registered in the meta-inf/smack.providers file
|
||||
* as follows.
|
||||
|
@ -81,7 +81,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public abstract class EmbeddedExtensionProvider<PE extends PacketExtension> extends PacketExtensionProvider<PE> {
|
||||
public abstract class EmbeddedExtensionProvider<PE extends ExtensionElement> extends ExtensionElementProvider<PE> {
|
||||
|
||||
@Override
|
||||
public final PE parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
|
||||
|
@ -95,13 +95,13 @@ public abstract class EmbeddedExtensionProvider<PE extends PacketExtension> exte
|
|||
attMap.put(parser.getAttributeName(i), parser.getAttributeValue(i));
|
||||
}
|
||||
|
||||
List<PacketExtension> extensions = new ArrayList<>();
|
||||
List<ExtensionElement> extensions = new ArrayList<>();
|
||||
int event;
|
||||
do {
|
||||
event = parser.next();
|
||||
|
||||
if (event == XmlPullParser.START_TAG)
|
||||
PacketParserUtils.addPacketExtension(extensions, parser);
|
||||
PacketParserUtils.addExtensionElement(extensions, parser);
|
||||
}
|
||||
while (!(event == XmlPullParser.END_TAG && parser.getDepth() == initialDepth));
|
||||
|
||||
|
@ -109,5 +109,5 @@ public abstract class EmbeddedExtensionProvider<PE extends PacketExtension> exte
|
|||
}
|
||||
|
||||
protected abstract PE createReturnExtension(String currentElement, String currentNamespace,
|
||||
Map<String, String> attributeMap, List<? extends PacketExtension> content);
|
||||
Map<String, String> attributeMap, List<? extends ExtensionElement> content);
|
||||
}
|
||||
|
|
|
@ -18,15 +18,15 @@
|
|||
package org.jivesoftware.smack.provider;
|
||||
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
* An abstract class for parsing custom packets extensions. Each PacketExtensionProvider must
|
||||
* An abstract class for parsing custom extensions elements. Each ExtensionElementProvider must
|
||||
* be registered with the ProviderManager class for it to be used. Every implementation
|
||||
* of this abstract class <b>must</b> have a public, no-argument constructor.
|
||||
*
|
||||
* @author Matt Tucker
|
||||
*/
|
||||
public abstract class PacketExtensionProvider<PE extends PacketExtension> extends Provider<PE> {
|
||||
public abstract class ExtensionElementProvider<EE extends ExtensionElement> extends Provider<EE> {
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
* Defines the information required to register a packet extension Provider with the {@link ProviderManager} when using the
|
||||
|
@ -28,13 +28,13 @@ import org.jivesoftware.smack.packet.PacketExtension;
|
|||
public final class ExtensionProviderInfo extends AbstractProviderInfo {
|
||||
|
||||
/**
|
||||
* Defines an extension provider which implements the <code>PacketExtensionProvider</code> interface.
|
||||
* Defines an extension provider which implements the <code>ExtensionElementProvider</code> interface.
|
||||
*
|
||||
* @param elementName Element that provider parses.
|
||||
* @param namespace Namespace that provider parses.
|
||||
* @param extProvider The provider implementation.
|
||||
*/
|
||||
public ExtensionProviderInfo(String elementName, String namespace, PacketExtensionProvider<PacketExtension> extProvider) {
|
||||
public ExtensionProviderInfo(String elementName, String namespace, ExtensionElementProvider<ExtensionElement> extProvider) {
|
||||
super(elementName, namespace, extProvider);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -51,7 +51,7 @@ public class IntrospectionProvider{
|
|||
}
|
||||
}
|
||||
|
||||
public static abstract class PacketExtensionIntrospectionProvider<PE extends PacketExtension> extends PacketExtensionProvider<PE> {
|
||||
public static abstract class PacketExtensionIntrospectionProvider<PE extends ExtensionElement> extends ExtensionElementProvider<PE> {
|
||||
private final Class<PE> elementClass;
|
||||
|
||||
protected PacketExtensionIntrospectionProvider(Class<PE> elementClass) {
|
||||
|
|
|
@ -25,12 +25,12 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
* Loads the {@link IQProvider} and {@link PacketExtensionProvider} information from a standard provider file in preparation
|
||||
* Loads the {@link IQProvider} and {@link ExtensionElementProvider} information from a standard provider file in preparation
|
||||
* for loading into the {@link ProviderManager}.
|
||||
*
|
||||
* @author Robin Collier
|
||||
|
@ -95,8 +95,8 @@ public class ProviderFileLoader implements ProviderLoader {
|
|||
// a PacketExtension, add the class object itself and
|
||||
// then we'll use reflection later to create instances
|
||||
// of the class.
|
||||
if (PacketExtensionProvider.class.isAssignableFrom(provider)) {
|
||||
extProviders.add(new ExtensionProviderInfo(elementName, namespace, (PacketExtensionProvider<PacketExtension>) provider.newInstance()));
|
||||
if (ExtensionElementProvider.class.isAssignableFrom(provider)) {
|
||||
extProviders.add(new ExtensionProviderInfo(elementName, namespace, (ExtensionElementProvider<ExtensionElement>) provider.newInstance()));
|
||||
}
|
||||
else {
|
||||
exceptions.add(new IllegalArgumentException(className
|
||||
|
@ -106,7 +106,7 @@ public class ProviderFileLoader implements ProviderLoader {
|
|||
case "streamFeatureProvider":
|
||||
sfProviders.add(new StreamFeatureProviderInfo(elementName,
|
||||
namespace,
|
||||
(PacketExtensionProvider<PacketExtension>) provider.newInstance()));
|
||||
(ExtensionElementProvider<ExtensionElement>) provider.newInstance()));
|
||||
break;
|
||||
default:
|
||||
LOGGER.warning("Unknown provider type: " + typeName);
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
|
||||
|
@ -109,9 +109,9 @@ import org.jxmpp.util.XmppStringUtils;
|
|||
*/
|
||||
public final class ProviderManager {
|
||||
|
||||
private static final Map<String, PacketExtensionProvider<PacketExtension>> extensionProviders = new ConcurrentHashMap<String, PacketExtensionProvider<PacketExtension>>();
|
||||
private static final Map<String, ExtensionElementProvider<ExtensionElement>> extensionProviders = new ConcurrentHashMap<String, ExtensionElementProvider<ExtensionElement>>();
|
||||
private static final Map<String, IQProvider<IQ>> iqProviders = new ConcurrentHashMap<String, IQProvider<IQ>>();
|
||||
private static final Map<String, PacketExtensionProvider<PacketExtension>> streamFeatureProviders = new ConcurrentHashMap<String, PacketExtensionProvider<PacketExtension>>();
|
||||
private static final Map<String, ExtensionElementProvider<ExtensionElement>> streamFeatureProviders = new ConcurrentHashMap<String, ExtensionElementProvider<ExtensionElement>>();
|
||||
|
||||
static {
|
||||
// Ensure that Smack is initialized by calling getVersion, so that user
|
||||
|
@ -138,7 +138,7 @@ public final class ProviderManager {
|
|||
if (loader.getStreamFeatureProviderInfo() != null) {
|
||||
for (StreamFeatureProviderInfo info : loader.getStreamFeatureProviderInfo()) {
|
||||
addStreamFeatureProvider(info.getElementName(), info.getNamespace(),
|
||||
(PacketExtensionProvider<PacketExtension>) info.getProvider());
|
||||
(ExtensionElementProvider<ExtensionElement>) info.getProvider());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ public final class ProviderManager {
|
|||
* @param namespace namespace associated with extension provider.
|
||||
* @return the extenion provider.
|
||||
*/
|
||||
public static PacketExtensionProvider<PacketExtension> getExtensionProvider(String elementName, String namespace) {
|
||||
public static ExtensionElementProvider<ExtensionElement> getExtensionProvider(String elementName, String namespace) {
|
||||
String key = getKey(elementName, namespace);
|
||||
return extensionProviders.get(key);
|
||||
}
|
||||
|
@ -259,8 +259,8 @@ public final class ProviderManager {
|
|||
validate(elementName, namespace);
|
||||
// First remove existing providers
|
||||
String key = removeExtensionProvider(elementName, namespace);
|
||||
if (provider instanceof PacketExtensionProvider) {
|
||||
extensionProviders.put(key, (PacketExtensionProvider<PacketExtension>) provider);
|
||||
if (provider instanceof ExtensionElementProvider) {
|
||||
extensionProviders.put(key, (ExtensionElementProvider<ExtensionElement>) provider);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Provider must be a PacketExtensionProvider");
|
||||
}
|
||||
|
@ -288,18 +288,18 @@ public final class ProviderManager {
|
|||
*
|
||||
* @return all PacketExtensionProvider instances.
|
||||
*/
|
||||
public static List<PacketExtensionProvider<PacketExtension>> getExtensionProviders() {
|
||||
List<PacketExtensionProvider<PacketExtension>> providers = new ArrayList<>(extensionProviders.size());
|
||||
public static List<ExtensionElementProvider<ExtensionElement>> getExtensionProviders() {
|
||||
List<ExtensionElementProvider<ExtensionElement>> providers = new ArrayList<>(extensionProviders.size());
|
||||
providers.addAll(extensionProviders.values());
|
||||
return providers;
|
||||
}
|
||||
|
||||
public static PacketExtensionProvider<PacketExtension> getStreamFeatureProvider(String elementName, String namespace) {
|
||||
public static ExtensionElementProvider<ExtensionElement> getStreamFeatureProvider(String elementName, String namespace) {
|
||||
String key = getKey(elementName, namespace);
|
||||
return streamFeatureProviders.get(key);
|
||||
}
|
||||
|
||||
public static void addStreamFeatureProvider(String elementName, String namespace, PacketExtensionProvider<PacketExtension> provider) {
|
||||
public static void addStreamFeatureProvider(String elementName, String namespace, ExtensionElementProvider<ExtensionElement> provider) {
|
||||
validate(elementName, namespace);
|
||||
String key = getKey(elementName, namespace);
|
||||
streamFeatureProviders.put(key, provider);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smack.provider;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -31,7 +31,7 @@ public final class StreamFeatureProviderInfo extends AbstractProviderInfo {
|
|||
* @param extProvider The provider implementation.
|
||||
*/
|
||||
public StreamFeatureProviderInfo(String elementName, String namespace,
|
||||
PacketExtensionProvider<PacketExtension> extProvider) {
|
||||
ExtensionElementProvider<ExtensionElement> extProvider) {
|
||||
super(elementName, namespace, extProvider);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,13 +30,13 @@ import java.util.logging.Logger;
|
|||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.compress.packet.Compress;
|
||||
import org.jivesoftware.smack.packet.DefaultPacketExtension;
|
||||
import org.jivesoftware.smack.packet.DefaultExtensionElement;
|
||||
import org.jivesoftware.smack.packet.EmptyResultIQ;
|
||||
import org.jivesoftware.smack.packet.ErrorIQ;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Session;
|
||||
import org.jivesoftware.smack.packet.StartTls;
|
||||
|
@ -44,7 +44,7 @@ import org.jivesoftware.smack.packet.StreamError;
|
|||
import org.jivesoftware.smack.packet.UnparsedIQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
import org.jivesoftware.smack.sasl.packet.SaslStreamElements.SASLFailure;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -284,7 +284,7 @@ public class PacketParserUtils {
|
|||
message.setError(parseError(parser));
|
||||
break;
|
||||
default:
|
||||
PacketParserUtils.addPacketExtension(message, parser, elementName, namespace);
|
||||
PacketParserUtils.addExtensionElement(message, parser, elementName, namespace);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -574,7 +574,7 @@ public class PacketParserUtils {
|
|||
// Be extra robust: Skip PacketExtensions that cause Exceptions, instead of
|
||||
// failing completely here. See SMACK-390 for more information.
|
||||
try {
|
||||
PacketParserUtils.addPacketExtension(presence, parser, elementName, namespace);
|
||||
PacketParserUtils.addExtensionElement(presence, parser, elementName, namespace);
|
||||
} catch (Exception e) {
|
||||
LOGGER.log(Level.WARNING, "Failed to parse extension packet in Presence packet.", e);
|
||||
}
|
||||
|
@ -797,7 +797,7 @@ public class PacketParserUtils {
|
|||
public static StreamError parseStreamError(XmlPullParser parser) throws IOException, XmlPullParserException,
|
||||
SmackException {
|
||||
final int initialDepth = parser.getDepth();
|
||||
List<PacketExtension> extensions = new ArrayList<PacketExtension>();
|
||||
List<ExtensionElement> extensions = new ArrayList<ExtensionElement>();
|
||||
Map<String, String> descriptiveTexts = null;
|
||||
StreamError.Condition condition = null;
|
||||
String conditionText = null;
|
||||
|
@ -824,7 +824,7 @@ public class PacketParserUtils {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
PacketParserUtils.addPacketExtension(extensions, parser, name, namespace);
|
||||
PacketParserUtils.addExtensionElement(extensions, parser, name, namespace);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -853,7 +853,7 @@ public class PacketParserUtils {
|
|||
Map<String, String> descriptiveTexts = null;
|
||||
XMPPError.Condition condition = null;
|
||||
String conditionText = null;
|
||||
List<PacketExtension> extensions = new ArrayList<PacketExtension>();
|
||||
List<ExtensionElement> extensions = new ArrayList<ExtensionElement>();
|
||||
|
||||
// Parse the error header
|
||||
XMPPError.Type errorType = XMPPError.Type.fromString(parser.getAttributeValue("", "type"));
|
||||
|
@ -880,7 +880,7 @@ public class PacketParserUtils {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
PacketParserUtils.addPacketExtension(extensions, parser, name, namespace);
|
||||
PacketParserUtils.addExtensionElement(extensions, parser, name, namespace);
|
||||
}
|
||||
break;
|
||||
case XmlPullParser.END_TAG:
|
||||
|
@ -893,26 +893,36 @@ public class PacketParserUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* Parses a packet extension sub-packet.
|
||||
* @deprecated use {@link #parseExtensionElement(String, String, XmlPullParser)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static ExtensionElement parsePacketExtension(String elementName, String namespace,
|
||||
XmlPullParser parser) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
return parseExtensionElement(elementName, namespace, parser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an extension element.
|
||||
*
|
||||
* @param elementName the XML element name of the packet extension.
|
||||
* @param elementName the XML element name of the extension element.
|
||||
* @param namespace the XML namespace of the packet extension.
|
||||
* @param parser the XML parser, positioned at the starting element of the extension.
|
||||
* @return a PacketExtension.
|
||||
* @return an extension element.
|
||||
*/
|
||||
public static PacketExtension parsePacketExtension(String elementName, String namespace,
|
||||
public static ExtensionElement parseExtensionElement(String elementName, String namespace,
|
||||
XmlPullParser parser) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
// See if a provider is registered to handle the extension.
|
||||
PacketExtensionProvider<PacketExtension> provider = ProviderManager.getExtensionProvider(elementName, namespace);
|
||||
ExtensionElementProvider<ExtensionElement> provider = ProviderManager.getExtensionProvider(elementName, namespace);
|
||||
if (provider != null) {
|
||||
return provider.parse(parser);
|
||||
}
|
||||
|
||||
final int initialDepth = parser.getDepth();
|
||||
// No providers registered, so use a default extension.
|
||||
DefaultPacketExtension extension = new DefaultPacketExtension(elementName, namespace);
|
||||
DefaultExtensionElement extension = new DefaultExtensionElement(elementName, namespace);
|
||||
outerloop: while (true) {
|
||||
int eventType = parser.next();
|
||||
switch (eventType) {
|
||||
|
@ -1005,27 +1015,53 @@ public class PacketParserUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addPacketExtension(Stanza packet, XmlPullParser parser) throws XmlPullParserException,
|
||||
IOException, SmackException {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
addPacketExtension(packet, parser, parser.getName(), parser.getNamespace());
|
||||
addExtensionElement(packet, parser);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addPacketExtension(Stanza packet, XmlPullParser parser, String elementName, String namespace)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
PacketExtension packetExtension = parsePacketExtension(elementName, namespace, parser);
|
||||
addExtensionElement(packet, parser, elementName, namespace);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addPacketExtension(Collection<ExtensionElement> collection, XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
addExtensionElement(collection, parser, parser.getName(), parser.getNamespace());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void addPacketExtension(Collection<ExtensionElement> collection, XmlPullParser parser,
|
||||
String elementName, String namespace) throws XmlPullParserException, IOException, SmackException {
|
||||
addExtensionElement(collection, parser, elementName, namespace);
|
||||
}
|
||||
|
||||
|
||||
public static void addExtensionElement(Stanza packet, XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
ParserUtils.assertAtStartTag(parser);
|
||||
addExtensionElement(packet, parser, parser.getName(), parser.getNamespace());
|
||||
}
|
||||
|
||||
public static void addExtensionElement(Stanza packet, XmlPullParser parser, String elementName,
|
||||
String namespace) throws XmlPullParserException, IOException, SmackException {
|
||||
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser);
|
||||
packet.addExtension(packetExtension);
|
||||
}
|
||||
|
||||
public static void addPacketExtension(Collection<PacketExtension> collection, XmlPullParser parser)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
addPacketExtension(collection, parser, parser.getName(), parser.getNamespace());
|
||||
public static void addExtensionElement(Collection<ExtensionElement> collection,
|
||||
XmlPullParser parser) throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
addExtensionElement(collection, parser, parser.getName(), parser.getNamespace());
|
||||
}
|
||||
|
||||
public static void addPacketExtension(Collection<PacketExtension> collection, XmlPullParser parser,
|
||||
String elementName, String namespace) throws XmlPullParserException, IOException, SmackException {
|
||||
PacketExtension packetExtension = parsePacketExtension(elementName, namespace, parser);
|
||||
public static void addExtensionElement(Collection<ExtensionElement> collection,
|
||||
XmlPullParser parser, String elementName, String namespace)
|
||||
throws XmlPullParserException, IOException, SmackException {
|
||||
ExtensionElement packetExtension = parseExtensionElement(elementName, namespace, parser);
|
||||
collection.add(packetExtension);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smack.util;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
public class PacketUtil {
|
||||
|
||||
|
@ -32,8 +32,8 @@ public class PacketUtil {
|
|||
* @deprecated use {@link #extensionElementFrom(Collection, String, String)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static <PE extends PacketExtension> PE packetExtensionfromCollection(
|
||||
Collection<PacketExtension> collection, String element,
|
||||
public static <PE extends ExtensionElement> PE packetExtensionfromCollection(
|
||||
Collection<ExtensionElement> collection, String element,
|
||||
String namespace) {
|
||||
return extensionElementFrom(collection, element, namespace);
|
||||
}
|
||||
|
@ -47,9 +47,9 @@ public class PacketUtil {
|
|||
* @return the extension element
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <PE extends PacketExtension> PE extensionElementFrom(Collection<PacketExtension> collection,
|
||||
public static <PE extends ExtensionElement> PE extensionElementFrom(Collection<ExtensionElement> collection,
|
||||
String element, String namespace) {
|
||||
for (PacketExtension packetExtension : collection) {
|
||||
for (ExtensionElement packetExtension : collection) {
|
||||
if ((element == null || packetExtension.getElementName().equals(
|
||||
element))
|
||||
&& packetExtension.getNamespace().equals(namespace)) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Collection;
|
|||
|
||||
import org.jivesoftware.smack.packet.Element;
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
public class XmlStringBuilder implements Appendable, CharSequence {
|
||||
public static final String RIGHT_ANGLE_BRACKET = Character.toString('>');
|
||||
|
@ -31,7 +31,7 @@ public class XmlStringBuilder implements Appendable, CharSequence {
|
|||
sb = new LazyStringBuilder();
|
||||
}
|
||||
|
||||
public XmlStringBuilder(PacketExtension pe) {
|
||||
public XmlStringBuilder(ExtensionElement pe) {
|
||||
this();
|
||||
prelude(pe);
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ public class XmlStringBuilder implements Appendable, CharSequence {
|
|||
return this;
|
||||
}
|
||||
|
||||
public XmlStringBuilder prelude(PacketExtension pe) {
|
||||
public XmlStringBuilder prelude(ExtensionElement pe) {
|
||||
return prelude(pe.getElementName(), pe.getNamespace());
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smack;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -175,7 +175,7 @@ public class PacketCollectorTest
|
|||
assertNull(collector.pollResult());
|
||||
}
|
||||
|
||||
class OKEverything implements PacketFilter
|
||||
class OKEverything implements StanzaFilter
|
||||
{
|
||||
@Override
|
||||
public boolean accept(Stanza packet)
|
||||
|
@ -187,9 +187,9 @@ public class PacketCollectorTest
|
|||
|
||||
class TestPacketCollector extends PacketCollector
|
||||
{
|
||||
protected TestPacketCollector(XMPPConnection conection, PacketFilter packetFilter, int size)
|
||||
protected TestPacketCollector(XMPPConnection conection, StanzaFilter packetFilter, int size)
|
||||
{
|
||||
super(conection, PacketCollector.newConfiguration().setPacketFilter(packetFilter).setSize(size));
|
||||
super(conection, PacketCollector.newConfiguration().setStanzaFilter(packetFilter).setSize(size));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public class StreamErrorTest {
|
|||
assertNotNull(error);
|
||||
assertEquals(Condition.conflict, error.getCondition());
|
||||
assertEquals("Replaced by new connection", error.getDescriptiveText());
|
||||
PacketExtension appSpecificElement = error.getExtension("appSpecificElement", "myns");
|
||||
ExtensionElement appSpecificElement = error.getExtension("appSpecificElement", "myns");
|
||||
assertNotNull(appSpecificElement);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ import static org.junit.Assert.assertThat;
|
|||
import static org.jivesoftware.smack.test.util.CharsequenceEquals.equalsCharSequence;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.provider.ProviderManager;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
|
@ -72,12 +72,12 @@ public class ParsingExceptionTest {
|
|||
assertThat(MESSAGE_EXCEPTION_ELEMENT + EXTENSION2 + "</message>", equalsCharSequence(content));
|
||||
}
|
||||
|
||||
static class ThrowException extends PacketExtensionProvider<PacketExtension> {
|
||||
static class ThrowException extends ExtensionElementProvider<ExtensionElement> {
|
||||
public static final String ELEMENT = "exception";
|
||||
public static final String NAMESPACE = "http://smack.jivesoftware.org/exception";
|
||||
|
||||
@Override
|
||||
public PacketExtension parse(XmlPullParser parser, int initialDepth) throws SmackException {
|
||||
public ExtensionElement parse(XmlPullParser parser, int initialDepth) throws SmackException {
|
||||
throw new SmackException("Test Exception");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.carbons.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
|
||||
|
@ -32,7 +32,7 @@ import org.jivesoftware.smackx.forward.packet.Forwarded;
|
|||
*
|
||||
* @author Georg Lukas
|
||||
*/
|
||||
public class CarbonExtension implements PacketExtension {
|
||||
public class CarbonExtension implements ExtensionElement {
|
||||
public static final String NAMESPACE = Carbon.NAMESPACE;
|
||||
|
||||
private final Direction dir;
|
||||
|
@ -131,7 +131,7 @@ public class CarbonExtension implements PacketExtension {
|
|||
* Packet extension indicating that a message may not be carbon-copied. Adding this
|
||||
* extension to any message will disallow that message from being copied.
|
||||
*/
|
||||
public static class Private implements PacketExtension {
|
||||
public static class Private implements ExtensionElement {
|
||||
public static final Private INSTANCE = new Private();
|
||||
public static final String ELEMENT = "private";
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.carbons.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.carbons.packet.CarbonExtension;
|
||||
import org.jivesoftware.smackx.carbons.packet.CarbonExtension.Direction;
|
||||
import org.jivesoftware.smackx.forward.packet.Forwarded;
|
||||
|
@ -28,13 +28,13 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
/**
|
||||
* This class implements the {@link PacketExtensionProvider} to parse
|
||||
* This class implements the {@link ExtensionElementProvider} to parse
|
||||
* carbon copied messages from a packet. It will return a {@link CarbonExtension} packet extension.
|
||||
*
|
||||
* @author Georg Lukas
|
||||
*
|
||||
*/
|
||||
public class CarbonManagerProvider extends PacketExtensionProvider<CarbonExtension> {
|
||||
public class CarbonManagerProvider extends ExtensionElementProvider<CarbonExtension> {
|
||||
|
||||
private static final ForwardedProvider FORWARDED_PROVIDER = new ForwardedProvider();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.csi.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.FullStreamElement;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -73,7 +73,7 @@ public class ClientStateIndication {
|
|||
}
|
||||
}
|
||||
|
||||
public static class Feature implements PacketExtension {
|
||||
public static class Feature implements ExtensionElement {
|
||||
public static final Feature INSTANCE = new Feature();
|
||||
public static final String ELEMENT = "csi";
|
||||
|
||||
|
|
|
@ -19,12 +19,12 @@ package org.jivesoftware.smackx.csi.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.csi.packet.ClientStateIndication;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class ClientStateIndicationFeatureProvider extends PacketExtensionProvider<ClientStateIndication.Feature> {
|
||||
public class ClientStateIndicationFeatureProvider extends ExtensionElementProvider<ClientStateIndication.Feature> {
|
||||
|
||||
@Override
|
||||
public ClientStateIndication.Feature parse(XmlPullParser parser, int initialDepth)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.hoxt.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.hoxt.HOXTManager;
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ import org.jivesoftware.smackx.hoxt.HOXTManager;
|
|||
* @author Andriy Tsykholyas
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0332.html">XEP-0332: HTTP over XMPP transport</a>
|
||||
*/
|
||||
public class Base64BinaryChunk implements PacketExtension {
|
||||
public class Base64BinaryChunk implements ExtensionElement {
|
||||
|
||||
public static final String ELEMENT_CHUNK = "chunk";
|
||||
public static final String ATTRIBUTE_STREAM_ID = "streamId";
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smackx.hoxt.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.hoxt.packet.Base64BinaryChunk;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -29,7 +29,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
* @author Andriy Tsykholyas
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0332.html">XEP-0332: HTTP over XMPP transport</a>
|
||||
*/
|
||||
public class Base64BinaryChunkProvider extends PacketExtensionProvider<Base64BinaryChunk> {
|
||||
public class Base64BinaryChunkProvider extends ExtensionElementProvider<Base64BinaryChunk> {
|
||||
|
||||
@Override
|
||||
public Base64BinaryChunk parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
|
|
|
@ -16,10 +16,10 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.json.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
public abstract class AbstractJsonPacketExtension implements PacketExtension {
|
||||
public abstract class AbstractJsonPacketExtension implements ExtensionElement {
|
||||
|
||||
private final String json;
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@ package org.jivesoftware.smackx.json.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.json.packet.AbstractJsonPacketExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public abstract class AbstractJsonExtensionProvider extends PacketExtensionProvider<AbstractJsonPacketExtension> {
|
||||
public abstract class AbstractJsonExtensionProvider extends ExtensionElementProvider<AbstractJsonPacketExtension> {
|
||||
|
||||
@Override
|
||||
public AbstractJsonPacketExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException,
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.hoxt.packet.Base64BinaryChunk;
|
||||
import org.junit.Test;
|
||||
|
@ -39,7 +39,7 @@ public class Base64BinaryChunkProviderTest {
|
|||
Base64BinaryChunkProvider provider = new Base64BinaryChunkProvider();
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(string);
|
||||
|
||||
PacketExtension extension = provider.parse(parser);
|
||||
ExtensionElement extension = provider.parse(parser);
|
||||
assertTrue(extension instanceof Base64BinaryChunk);
|
||||
|
||||
Base64BinaryChunk chunk = (Base64BinaryChunk) extension;
|
||||
|
@ -57,7 +57,7 @@ public class Base64BinaryChunkProviderTest {
|
|||
Base64BinaryChunkProvider provider = new Base64BinaryChunkProvider();
|
||||
XmlPullParser parser = PacketParserUtils.getParserFor(string);
|
||||
|
||||
PacketExtension extension = provider.parse(parser);
|
||||
ExtensionElement extension = provider.parse(parser);
|
||||
assertTrue(extension instanceof Base64BinaryChunk);
|
||||
|
||||
Base64BinaryChunk chunk = (Base64BinaryChunk) extension;
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.jivesoftware.smack.*;
|
|||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.test.SmackTestCase;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -67,7 +67,7 @@ public class GroupChatInvitationTest extends SmackTestCase {
|
|||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// Register listener for groupchat invitations.
|
||||
PacketFilter filter = new PacketExtensionFilter("x", "jabber:x:conference");
|
||||
PacketFilter filter = new StanzaExtensionFilter("x", "jabber:x:conference");
|
||||
collector = getConnection(1).createPacketCollector(filter);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import org.jivesoftware.smack.SmackConfiguration;
|
|||
import org.jivesoftware.smack.TCPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.filter.IQTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
@ -90,7 +90,7 @@ public class EntityCapsTest extends SmackTestCase {
|
|||
discoInfoSend = true;
|
||||
}
|
||||
|
||||
}, new AndFilter(new PacketTypeFilter(DiscoverInfo.class), new IQTypeFilter(IQ.Type.get)));
|
||||
}, new AndFilter(new StanzaTypeFilter(DiscoverInfo.class), new IQTypeFilter(IQ.Type.get)));
|
||||
|
||||
// add a bogus feature so that con1 ver won't match con0's
|
||||
sdm1.addFeature(DISCOVER_TEST_FEATURE);
|
||||
|
|
|
@ -83,7 +83,7 @@ public class MessageEventTest extends SmackTestCase {
|
|||
|
||||
// Create a Listener that listens for Messages with the extension "jabber:x:roster"
|
||||
// This listener will listen on the conn2 and answer an ACK if everything is ok
|
||||
PacketFilter packetFilter = new PacketExtensionFilter("x", "jabber:x:event");
|
||||
PacketFilter packetFilter = new StanzaExtensionFilter("x", "jabber:x:event");
|
||||
PacketListener packetListener = new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
Message message = (Message) packet;
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Iterator;
|
|||
import org.jivesoftware.smack.Chat;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.ThreadFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -143,7 +143,7 @@ public class XHTMLExtensionTest extends SmackTestCase {
|
|||
//"http://jabber.org/protocol/xhtml-im"
|
||||
// This listener will listen on the conn2 and answer an ACK if everything is ok
|
||||
PacketFilter packetFilter =
|
||||
new PacketExtensionFilter("html", "http://jabber.org/protocol/xhtml-im");
|
||||
new StanzaExtensionFilter("html", "http://jabber.org/protocol/xhtml-im");
|
||||
PacketListener packetListener = new PacketListener() {
|
||||
@Override
|
||||
public void processPacket(Packet packet) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.jivesoftware.smackx.address.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -29,7 +29,7 @@ import java.util.List;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MultipleAddresses implements PacketExtension {
|
||||
public class MultipleAddresses implements ExtensionElement {
|
||||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/address";
|
||||
public static final String ELEMENT = "addresses";
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.address.provider;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.address.packet.MultipleAddresses;
|
||||
import org.jivesoftware.smackx.address.packet.MultipleAddresses.Type;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -30,7 +30,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
*
|
||||
* @author Gaston Dombiak
|
||||
*/
|
||||
public class MultipleAddressesProvider extends PacketExtensionProvider<MultipleAddresses> {
|
||||
public class MultipleAddressesProvider extends ExtensionElementProvider<MultipleAddresses> {
|
||||
|
||||
@Override
|
||||
public MultipleAddresses parse(XmlPullParser parser,
|
||||
|
|
|
@ -20,12 +20,12 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.amp.AMPDeliverCondition;
|
||||
import org.jivesoftware.smackx.amp.AMPExpireAtCondition;
|
||||
import org.jivesoftware.smackx.amp.AMPMatchResourceCondition;
|
||||
|
||||
public class AMPExtension implements PacketExtension {
|
||||
public class AMPExtension implements ExtensionElement {
|
||||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/amp";
|
||||
public static final String ELEMENT = "amp";
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.amp.provider;
|
|||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.amp.AMPDeliverCondition;
|
||||
import org.jivesoftware.smackx.amp.AMPExpireAtCondition;
|
||||
import org.jivesoftware.smackx.amp.AMPMatchResourceCondition;
|
||||
|
@ -28,7 +28,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
||||
public class AMPExtensionProvider extends PacketExtensionProvider<AMPExtension> {
|
||||
public class AMPExtensionProvider extends ExtensionElementProvider<AMPExtension> {
|
||||
private static final Logger LOGGER = Logger.getLogger(AMPExtensionProvider.class.getName());
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.attention.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* @see <a
|
||||
* href="http://xmpp.org/extensions/xep-0224.html">XEP-0224: Attention</a>
|
||||
*/
|
||||
public class AttentionExtension implements PacketExtension {
|
||||
public class AttentionExtension implements ExtensionElement {
|
||||
|
||||
/**
|
||||
* The XML element name of an 'attention' extension.
|
||||
|
@ -73,14 +73,14 @@ public class AttentionExtension implements PacketExtension {
|
|||
}
|
||||
|
||||
/**
|
||||
* A {@link PacketExtensionProvider} for the {@link AttentionExtension}. As
|
||||
* A {@link ExtensionElementProvider} for the {@link AttentionExtension}. As
|
||||
* Attention elements have no state/information other than the element name
|
||||
* and namespace, this implementation simply returns new instances of
|
||||
* {@link AttentionExtension}.
|
||||
*
|
||||
* @author Guus der Kinderen, guus.der.kinderen@gmail.com
|
||||
s */
|
||||
public static class Provider extends PacketExtensionProvider<AttentionExtension> {
|
||||
public static class Provider extends ExtensionElementProvider<AttentionExtension> {
|
||||
|
||||
@Override
|
||||
public AttentionExtension parse(XmlPullParser parser, int initialDepth) {
|
||||
|
|
|
@ -19,8 +19,8 @@ package org.jivesoftware.smackx.bytestreams.ibb;
|
|||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
|
||||
|
||||
|
@ -44,8 +44,8 @@ class DataListener implements PacketListener {
|
|||
private final InBandBytestreamManager manager;
|
||||
|
||||
/* packet filter for all In-Band Bytestream data packets */
|
||||
private final PacketFilter dataFilter = new AndFilter(
|
||||
new PacketTypeFilter(Data.class));
|
||||
private final StanzaFilter dataFilter = new AndFilter(
|
||||
new StanzaTypeFilter(Data.class));
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -70,7 +70,7 @@ class DataListener implements PacketListener {
|
|||
*
|
||||
* @return the packet filter for In-Band Bytestream data packets
|
||||
*/
|
||||
protected PacketFilter getFilter() {
|
||||
protected StanzaFilter getFilter() {
|
||||
return this.dataFilter;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
|
@ -279,7 +279,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
*
|
||||
* @return the data packet filter
|
||||
*/
|
||||
protected abstract PacketFilter getDataPacketFilter();
|
||||
protected abstract StanzaFilter getDataPacketFilter();
|
||||
|
||||
public synchronized int read() throws IOException {
|
||||
checkClosed();
|
||||
|
@ -489,12 +489,12 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
};
|
||||
}
|
||||
|
||||
protected PacketFilter getDataPacketFilter() {
|
||||
protected StanzaFilter getDataPacketFilter() {
|
||||
/*
|
||||
* filter all IQ stanzas having type 'SET' (represented by Data class), containing a
|
||||
* data packet extension, matching session ID and recipient
|
||||
*/
|
||||
return new AndFilter(new PacketTypeFilter(Data.class), new IBBDataPacketFilter());
|
||||
return new AndFilter(new StanzaTypeFilter(Data.class), new IBBDataPacketFilter());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -536,12 +536,12 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected PacketFilter getDataPacketFilter() {
|
||||
protected StanzaFilter getDataPacketFilter() {
|
||||
/*
|
||||
* filter all message stanzas containing a data packet extension, matching session ID
|
||||
* and recipient
|
||||
*/
|
||||
return new AndFilter(new PacketTypeFilter(Message.class), new IBBDataPacketFilter());
|
||||
return new AndFilter(new StanzaTypeFilter(Message.class), new IBBDataPacketFilter());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
* containing an In-Band Bytestream data packet extension whose session ID matches this sessions
|
||||
* ID.
|
||||
*/
|
||||
private class IBBDataPacketFilter implements PacketFilter {
|
||||
private class IBBDataPacketFilter implements StanzaFilter {
|
||||
|
||||
public boolean accept(Stanza packet) {
|
||||
// sender equals remote peer
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.bytestreams.ibb.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.IQ.IQChildElementXmlStringBuilder;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
|
@ -27,7 +27,7 @@ import org.jivesoftware.smack.util.stringencoder.Base64;
|
|||
*
|
||||
* @author Henning Staib
|
||||
*/
|
||||
public class DataPacketExtension implements PacketExtension {
|
||||
public class DataPacketExtension implements ExtensionElement {
|
||||
|
||||
/**
|
||||
* The element name of the data packet extension.
|
||||
|
|
|
@ -46,7 +46,7 @@ public class DataPacketProvider {
|
|||
}
|
||||
}
|
||||
|
||||
public static class PacketExtensionProvider extends org.jivesoftware.smack.provider.PacketExtensionProvider<DataPacketExtension> {
|
||||
public static class PacketExtensionProvider extends org.jivesoftware.smack.provider.ExtensionElementProvider<DataPacketExtension> {
|
||||
|
||||
@Override
|
||||
public DataPacketExtension parse(XmlPullParser parser,
|
||||
|
|
|
@ -27,13 +27,13 @@ import org.jivesoftware.smack.XMPPConnectionRegistry;
|
|||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaTypeFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.util.stringencoder.Base64;
|
||||
import org.jivesoftware.smackx.caps.cache.EntityCapsPersistentCache;
|
||||
|
@ -90,11 +90,11 @@ public class EntityCapsManager extends Manager {
|
|||
|
||||
private static Map<XMPPConnection, EntityCapsManager> instances = new WeakHashMap<>();
|
||||
|
||||
private static final PacketFilter PRESENCES_WITH_CAPS = new AndFilter(new PacketTypeFilter(Presence.class), new PacketExtensionFilter(
|
||||
private static final StanzaFilter PRESENCES_WITH_CAPS = new AndFilter(new StanzaTypeFilter(Presence.class), new StanzaExtensionFilter(
|
||||
ELEMENT, NAMESPACE));
|
||||
private static final PacketFilter PRESENCES_WITHOUT_CAPS = new AndFilter(new PacketTypeFilter(Presence.class), new NotFilter(new PacketExtensionFilter(
|
||||
private static final StanzaFilter PRESENCES_WITHOUT_CAPS = new AndFilter(new StanzaTypeFilter(Presence.class), new NotFilter(new StanzaExtensionFilter(
|
||||
ELEMENT, NAMESPACE)));
|
||||
private static final PacketFilter PRESENCES = PacketTypeFilter.PRESENCE;
|
||||
private static final StanzaFilter PRESENCES = StanzaTypeFilter.PRESENCE;
|
||||
|
||||
/**
|
||||
* Map of "node + '#' + hash" to DiscoverInfo data
|
||||
|
@ -482,7 +482,7 @@ public class EntityCapsManager extends Manager {
|
|||
final List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities());
|
||||
sdm.setNodeInformationProvider(entityNode + '#' + currentCapsVersion, new AbstractNodeInformationProvider() {
|
||||
List<String> features = sdm.getFeatures();
|
||||
List<PacketExtension> packetExtensions = sdm.getExtendedInfoAsList();
|
||||
List<ExtensionElement> packetExtensions = sdm.getExtendedInfoAsList();
|
||||
@Override
|
||||
public List<String> getNodeFeatures() {
|
||||
return features;
|
||||
|
@ -492,7 +492,7 @@ public class EntityCapsManager extends Manager {
|
|||
return identities;
|
||||
}
|
||||
@Override
|
||||
public List<PacketExtension> getNodePacketExtensions() {
|
||||
public List<ExtensionElement> getNodePacketExtensions() {
|
||||
return packetExtensions;
|
||||
}
|
||||
});
|
||||
|
@ -553,7 +553,7 @@ public class EntityCapsManager extends Manager {
|
|||
*/
|
||||
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
|
||||
List<FormField> foundFormTypes = new LinkedList<FormField>();
|
||||
for (PacketExtension pe : info.getExtensions()) {
|
||||
for (ExtensionElement pe : info.getExtensions()) {
|
||||
if (pe.getNamespace().equals(DataForm.NAMESPACE)) {
|
||||
DataForm df = (DataForm) pe;
|
||||
for (FormField f : df.getFields()) {
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
package org.jivesoftware.smackx.caps.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
|
||||
/**
|
||||
* A XEP-0115 Entity Capabilities extension.
|
||||
*/
|
||||
public class CapsExtension implements PacketExtension {
|
||||
public class CapsExtension implements ExtensionElement {
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/caps";
|
||||
public static final String ELEMENT = "c";
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@ package org.jivesoftware.smackx.caps.provider;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smackx.caps.EntityCapsManager;
|
||||
import org.jivesoftware.smackx.caps.packet.CapsExtension;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
public class CapsExtensionProvider extends PacketExtensionProvider<CapsExtension> {
|
||||
public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtension> {
|
||||
|
||||
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
|
|
|
@ -29,10 +29,10 @@ import org.jivesoftware.smack.chat.ChatManager;
|
|||
import org.jivesoftware.smack.chat.ChatManagerListener;
|
||||
import org.jivesoftware.smack.chat.ChatMessageListener;
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class ChatStateManager extends Manager {
|
|||
private static final Map<XMPPConnection, ChatStateManager> INSTANCES =
|
||||
new WeakHashMap<XMPPConnection, ChatStateManager>();
|
||||
|
||||
private static final PacketFilter filter = new NotFilter(new PacketExtensionFilter(NAMESPACE));
|
||||
private static final StanzaFilter filter = new NotFilter(new StanzaExtensionFilter(NAMESPACE));
|
||||
|
||||
/**
|
||||
* Returns the ChatStateManager related to the XMPPConnection and it will create one if it does
|
||||
|
@ -96,7 +96,7 @@ public class ChatStateManager extends Manager {
|
|||
|
||||
/**
|
||||
* Sets the current state of the provided chat. This method will send an empty bodied Message
|
||||
* packet with the state attached as a {@link org.jivesoftware.smack.packet.PacketExtension}, if
|
||||
* packet with the state attached as a {@link org.jivesoftware.smack.packet.ExtensionElement}, if
|
||||
* and only if the new chat state is different than the last state.
|
||||
*
|
||||
* @param newState the new state of the chat
|
||||
|
@ -170,7 +170,7 @@ public class ChatStateManager extends Manager {
|
|||
}
|
||||
|
||||
public void processMessage(Chat chat, Message message) {
|
||||
PacketExtension extension = message.getExtension(NAMESPACE);
|
||||
ExtensionElement extension = message.getExtension(NAMESPACE);
|
||||
if (extension == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
package org.jivesoftware.smackx.chatstates.packet;
|
||||
|
||||
import org.jivesoftware.smackx.chatstates.ChatState;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
|
@ -30,7 +30,7 @@ import org.xmlpull.v1.XmlPullParser;
|
|||
* @author Alexander Wenckus
|
||||
* @see org.jivesoftware.smackx.chatstates.ChatState
|
||||
*/
|
||||
public class ChatStateExtension implements PacketExtension {
|
||||
public class ChatStateExtension implements ExtensionElement {
|
||||
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/chatstates";
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class ChatStateExtension implements PacketExtension {
|
|||
return xml;
|
||||
}
|
||||
|
||||
public static class Provider extends PacketExtensionProvider<ChatStateExtension> {
|
||||
public static class Provider extends ExtensionElementProvider<ChatStateExtension> {
|
||||
|
||||
@Override
|
||||
public ChatStateExtension parse(XmlPullParser parser, int initialDepth) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.jivesoftware.smackx.commands.packet;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.commands.AdHocCommand;
|
||||
import org.jivesoftware.smackx.commands.AdHocCommand.Action;
|
||||
import org.jivesoftware.smackx.commands.AdHocCommand.SpecificErrorCondition;
|
||||
|
@ -237,7 +237,7 @@ public class AdHocCommandData extends IQ {
|
|||
return sessionID;
|
||||
}
|
||||
|
||||
public static class SpecificError implements PacketExtension {
|
||||
public static class SpecificError implements ExtensionElement {
|
||||
|
||||
public static final String namespace = "http://jabber.org/protocol/commands";
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.io.IOException;
|
|||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.provider.PacketExtensionProvider;
|
||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smackx.commands.AdHocCommand;
|
||||
import org.jivesoftware.smackx.commands.AdHocCommand.Action;
|
||||
|
@ -119,42 +119,42 @@ public class AdHocCommandDataProvider extends IQProvider<AdHocCommandData> {
|
|||
return adHocCommandData;
|
||||
}
|
||||
|
||||
public static class BadActionError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class BadActionError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badAction);
|
||||
}
|
||||
}
|
||||
|
||||
public static class MalformedActionError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class MalformedActionError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.malformedAction);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BadLocaleError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class BadLocaleError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badLocale);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BadPayloadError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class BadPayloadError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badPayload);
|
||||
}
|
||||
}
|
||||
|
||||
public static class BadSessionIDError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class BadSessionIDError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.badSessionid);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SessionExpiredError extends PacketExtensionProvider<AdHocCommandData.SpecificError> {
|
||||
public static class SessionExpiredError extends ExtensionElementProvider<AdHocCommandData.SpecificError> {
|
||||
@Override
|
||||
public AdHocCommandData.SpecificError parse(XmlPullParser parser, int initialDepth) {
|
||||
return new AdHocCommandData.SpecificError(AdHocCommand.SpecificErrorCondition.sessionExpired);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.delay;
|
|||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smackx.delay.packet.DelayInformation;
|
||||
|
||||
/**
|
||||
|
@ -95,7 +95,7 @@ public class DelayInformationManager {
|
|||
* @return true if the stanza got delayed.
|
||||
*/
|
||||
public static boolean isDelayedStanza(Stanza packet) {
|
||||
PacketExtension packetExtension = getDelayInformation(packet);
|
||||
ExtensionElement packetExtension = getDelayInformation(packet);
|
||||
return packetExtension != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,21 +17,21 @@
|
|||
package org.jivesoftware.smackx.delay.filter;
|
||||
|
||||
import org.jivesoftware.smack.filter.NotFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.filter.StanzaFilter;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.delay.DelayInformationManager;
|
||||
|
||||
/**
|
||||
* Filters stanza with delay information, ie. stanzas that got delayed for some reason
|
||||
*/
|
||||
public class DelayedStanzaFilter implements PacketFilter {
|
||||
public class DelayedStanzaFilter implements StanzaFilter {
|
||||
|
||||
public static final PacketFilter INSTANCE = new DelayedStanzaFilter();
|
||||
public static final StanzaFilter INSTANCE = new DelayedStanzaFilter();
|
||||
|
||||
/**
|
||||
* Filters stanzas that got not delayed, ie. have no delayed information
|
||||
*/
|
||||
public static final PacketFilter NOT_DELAYED_STANZA = new NotFilter(INSTANCE);
|
||||
public static final StanzaFilter NOT_DELAYED_STANZA = new NotFilter(INSTANCE);
|
||||
|
||||
private DelayedStanzaFilter() {
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue