mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 20:12:07 +01:00
Renamed Connection to XMPPConnection
This commit is contained in:
parent
f3e007bad5
commit
489816c61f
145 changed files with 639 additions and 641 deletions
|
@ -14,7 +14,7 @@ Key Advantages :
|
||||||
- Extremely simple to use, yet powerful API. Sending a text message to a user can be accomplished in only a few lines of code:
|
- Extremely simple to use, yet powerful API. Sending a text message to a user can be accomplished in only a few lines of code:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Connection connection = new XMPPConnection("jabber.org");
|
XMPPConnection connection = new TCPConnection("jabber.org");
|
||||||
connection.connect();
|
connection.connect();
|
||||||
connection.login("mtucker", "password");
|
connection.login("mtucker", "password");
|
||||||
Chat chat = connection.getChatManager()
|
Chat chat = connection.getChatManager()
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
import org.jivesoftware.smack.PacketCollector;
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
|
@ -51,10 +51,10 @@ import org.igniterealtime.jbosh.ComposableBody;
|
||||||
* Creates a connection to a XMPP server via HTTP binding.
|
* Creates a connection to a XMPP server via HTTP binding.
|
||||||
* This is specified in the XEP-0206: XMPP Over BOSH.
|
* This is specified in the XEP-0206: XMPP Over BOSH.
|
||||||
*
|
*
|
||||||
* @see Connection
|
* @see XMPPConnection
|
||||||
* @author Guenther Niess
|
* @author Guenther Niess
|
||||||
*/
|
*/
|
||||||
public class BOSHConnection extends Connection {
|
public class BOSHConnection extends XMPPConnection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The XMPP Over Bosh namespace.
|
* The XMPP Over Bosh namespace.
|
||||||
|
|
|
@ -167,7 +167,7 @@ public class MessageTest extends SmackTestCase {
|
||||||
// Send the first message
|
// Send the first message
|
||||||
getConnection(0).sendPacket(msg);
|
getConnection(0).sendPacket(msg);
|
||||||
// Check that the connection that sent the message is still connected
|
// Check that the connection that sent the message is still connected
|
||||||
assertTrue("Connection was closed", getConnection(0).isConnected());
|
assertTrue("XMPPConnection was closed", getConnection(0).isConnected());
|
||||||
// Check that the message was received
|
// Check that the message was received
|
||||||
Message rcv = (Message) collector.nextResult(1000);
|
Message rcv = (Message) collector.nextResult(1000);
|
||||||
assertNotNull("No Message was received", rcv);
|
assertNotNull("No Message was received", rcv);
|
||||||
|
@ -175,7 +175,7 @@ public class MessageTest extends SmackTestCase {
|
||||||
// Send the second message
|
// Send the second message
|
||||||
getConnection(0).sendPacket(msg);
|
getConnection(0).sendPacket(msg);
|
||||||
// Check that the connection that sent the message is still connected
|
// Check that the connection that sent the message is still connected
|
||||||
assertTrue("Connection was closed", getConnection(0).isConnected());
|
assertTrue("XMPPConnection was closed", getConnection(0).isConnected());
|
||||||
// Check that the second message was received
|
// Check that the second message was received
|
||||||
rcv = (Message) collector.nextResult(1000);
|
rcv = (Message) collector.nextResult(1000);
|
||||||
assertNotNull("No Message was received", rcv);
|
assertNotNull("No Message was received", rcv);
|
||||||
|
|
|
@ -35,8 +35,8 @@ public class PresenceTest extends SmackTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connection(0) will send messages to the bareJID of Connection(1) where the user of
|
* XMPPConnection(0) will send messages to the bareJID of XMPPConnection(1) where the user of
|
||||||
* Connection(1) has logged from two different places with different presence priorities.
|
* XMPPConnection(1) has logged from two different places with different presence priorities.
|
||||||
*/
|
*/
|
||||||
public void testMessageToHighestPriority() {
|
public void testMessageToHighestPriority() {
|
||||||
TCPConnection conn = null;
|
TCPConnection conn = null;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.jivesoftware.smack.util;
|
package org.jivesoftware.smack.util;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.Roster;
|
import org.jivesoftware.smack.Roster;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ public class ConnectionUtils {
|
||||||
|
|
||||||
private ConnectionUtils() {}
|
private ConnectionUtils() {}
|
||||||
|
|
||||||
public static void becomeFriends(Connection con0, Connection con1) throws XMPPException {
|
public static void becomeFriends(XMPPConnection con0, XMPPConnection con1) throws XMPPException {
|
||||||
Roster r0 = con0.getRoster();
|
Roster r0 = con0.getRoster();
|
||||||
Roster r1 = con1.getRoster();
|
Roster r1 = con1.getRoster();
|
||||||
r0.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
|
r0.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
|
||||||
|
@ -17,9 +17,9 @@ public class ConnectionUtils {
|
||||||
r1.createEntry(con0.getUser(), "u1", null);
|
r1.createEntry(con0.getUser(), "u1", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void letsAllBeFriends(Connection[] connections) throws XMPPException {
|
public static void letsAllBeFriends(XMPPConnection[] connections) throws XMPPException {
|
||||||
for (Connection c1 : connections) {
|
for (XMPPConnection c1 : connections) {
|
||||||
for (Connection c2 : connections) {
|
for (XMPPConnection c2 : connections) {
|
||||||
if (c1 == c2)
|
if (c1 == c2)
|
||||||
continue;
|
continue;
|
||||||
becomeFriends(c1, c2);
|
becomeFriends(c1, c2);
|
||||||
|
|
|
@ -31,13 +31,13 @@ import org.jivesoftware.smack.util.StringUtils;
|
||||||
/**
|
/**
|
||||||
* Allows creation and management of accounts on an XMPP server.
|
* Allows creation and management of accounts on an XMPP server.
|
||||||
*
|
*
|
||||||
* @see Connection#getAccountManager()
|
* @see XMPPConnection#getAccountManager()
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
public class AccountManager {
|
public class AccountManager {
|
||||||
private static final Logger LOGGER = Logger.getLogger(AccountManager.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(AccountManager.class.getName());
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
private Registration info = null;
|
private Registration info = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ public class AccountManager {
|
||||||
*
|
*
|
||||||
* @param connection a connection to a XMPP server.
|
* @param connection a connection to a XMPP server.
|
||||||
*/
|
*/
|
||||||
public AccountManager(Connection connection) {
|
public AccountManager(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class Chat {
|
||||||
/**
|
/**
|
||||||
* Delivers a message directly to this chat, which will add the message
|
* Delivers a message directly to this chat, which will add the message
|
||||||
* to the collector and deliver it to all listeners registered with the
|
* to the collector and deliver it to all listeners registered with the
|
||||||
* Chat. This is used by the Connection class to deliver messages
|
* Chat. This is used by the XMPPConnection class to deliver messages
|
||||||
* without a thread ID.
|
* without a thread ID.
|
||||||
*
|
*
|
||||||
* @param message the message.
|
* @param message the message.
|
||||||
|
|
|
@ -108,9 +108,9 @@ public class ChatManager {
|
||||||
private Map<PacketInterceptor, PacketFilter> interceptors
|
private Map<PacketInterceptor, PacketFilter> interceptors
|
||||||
= new WeakHashMap<PacketInterceptor, PacketFilter>();
|
= new WeakHashMap<PacketInterceptor, PacketFilter>();
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
ChatManager(Connection connection) {
|
ChatManager(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
|
||||||
PacketFilter filter = new PacketFilter() {
|
PacketFilter filter = new PacketFilter() {
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ConnectionConfiguration implements Cloneable {
|
||||||
*/
|
*/
|
||||||
private CallbackHandler callbackHandler;
|
private CallbackHandler callbackHandler;
|
||||||
|
|
||||||
private boolean debuggerEnabled = Connection.DEBUG_ENABLED;
|
private boolean debuggerEnabled = XMPPConnection.DEBUG_ENABLED;
|
||||||
|
|
||||||
// Flag that indicates if a reconnection should be attempted when abruptly disconnected
|
// Flag that indicates if a reconnection should be attempted when abruptly disconnected
|
||||||
private boolean reconnectionAllowed = true;
|
private boolean reconnectionAllowed = true;
|
||||||
|
@ -368,7 +368,7 @@ public class ConnectionConfiguration implements Cloneable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the new connection about to be establish is going to be debugged. By
|
* Returns true if the new connection about to be establish is going to be debugged. By
|
||||||
* default the value of {@link Connection#DEBUG_ENABLED} is used.
|
* default the value of {@link XMPPConnection#DEBUG_ENABLED} is used.
|
||||||
*
|
*
|
||||||
* @return true if the new connection about to be establish is going to be debugged.
|
* @return true if the new connection about to be establish is going to be debugged.
|
||||||
*/
|
*/
|
||||||
|
@ -378,7 +378,7 @@ public class ConnectionConfiguration implements Cloneable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets if the new connection about to be establish is going to be debugged. By
|
* Sets if the new connection about to be establish is going to be debugged. By
|
||||||
* default the value of {@link Connection#DEBUG_ENABLED} is used.
|
* default the value of {@link XMPPConnection#DEBUG_ENABLED} is used.
|
||||||
*
|
*
|
||||||
* @param debuggerEnabled if the new connection about to be establish is going to be debugged.
|
* @param debuggerEnabled if the new connection about to be establish is going to be debugged.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
package org.jivesoftware.smack;
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementors of this interface will be notified when a new {@link Connection}
|
* Implementors of this interface will be notified when a new {@link XMPPConnection}
|
||||||
* has been created. The newly created connection will not be actually connected to
|
* has been created. The newly created connection will not be actually connected to
|
||||||
* the server. Use {@link Connection#addConnectionCreationListener(ConnectionCreationListener)}
|
* the server. Use {@link XMPPConnection#addConnectionCreationListener(ConnectionCreationListener)}
|
||||||
* to add new listeners.
|
* to add new listeners.
|
||||||
*
|
*
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
|
@ -33,6 +33,6 @@ public interface ConnectionCreationListener {
|
||||||
*
|
*
|
||||||
* @param connection the newly created connection.
|
* @param connection the newly created connection.
|
||||||
*/
|
*/
|
||||||
public void connectionCreated(Connection connection);
|
public void connectionCreated(XMPPConnection connection);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,10 +19,10 @@ package org.jivesoftware.smack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface that allows for implementing classes to listen for connection closing
|
* Interface that allows for implementing classes to listen for connection closing
|
||||||
* and reconnection events. Listeners are registered with Connection objects.
|
* and reconnection events. Listeners are registered with XMPPConnection objects.
|
||||||
*
|
*
|
||||||
* @see Connection#addConnectionListener
|
* @see XMPPConnection#addConnectionListener
|
||||||
* @see Connection#removeConnectionListener
|
* @see XMPPConnection#removeConnectionListener
|
||||||
*
|
*
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -20,13 +20,13 @@ import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
public abstract class Manager {
|
public abstract class Manager {
|
||||||
|
|
||||||
final WeakReference<Connection> weakConnection;
|
final WeakReference<XMPPConnection> weakConnection;
|
||||||
|
|
||||||
public Manager(Connection connection) {
|
public Manager(XMPPConnection connection) {
|
||||||
weakConnection = new WeakReference<Connection>(connection);
|
weakConnection = new WeakReference<XMPPConnection>(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Connection connection() {
|
protected final XMPPConnection connection() {
|
||||||
return weakConnection.get();
|
return weakConnection.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,14 +35,14 @@ import org.jivesoftware.smack.packet.XMPPError;
|
||||||
* older packets are automatically dropped. The default number is retrieved by
|
* older packets are automatically dropped. The default number is retrieved by
|
||||||
* {@link SmackConfiguration#getPacketCollectorSize()}.
|
* {@link SmackConfiguration#getPacketCollectorSize()}.
|
||||||
*
|
*
|
||||||
* @see Connection#createPacketCollector(PacketFilter)
|
* @see XMPPConnection#createPacketCollector(PacketFilter)
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
public class PacketCollector {
|
public class PacketCollector {
|
||||||
|
|
||||||
private PacketFilter packetFilter;
|
private PacketFilter packetFilter;
|
||||||
private ArrayBlockingQueue<Packet> resultQueue;
|
private ArrayBlockingQueue<Packet> resultQueue;
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
private boolean cancelled = false;
|
private boolean cancelled = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +52,7 @@ public class PacketCollector {
|
||||||
* @param connection the connection the collector is tied to.
|
* @param connection the connection the collector is tied to.
|
||||||
* @param packetFilter determines which packets will be returned by this collector.
|
* @param packetFilter determines which packets will be returned by this collector.
|
||||||
*/
|
*/
|
||||||
protected PacketCollector(Connection connection, PacketFilter packetFilter) {
|
protected PacketCollector(XMPPConnection connection, PacketFilter packetFilter) {
|
||||||
this(connection, packetFilter, SmackConfiguration.getPacketCollectorSize());
|
this(connection, packetFilter, SmackConfiguration.getPacketCollectorSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class PacketCollector {
|
||||||
* @param packetFilter determines which packets will be returned by this collector.
|
* @param packetFilter determines which packets will be returned by this collector.
|
||||||
* @param maxSize the maximum number of packets that will be stored in the collector.
|
* @param maxSize the maximum number of packets that will be stored in the collector.
|
||||||
*/
|
*/
|
||||||
protected PacketCollector(Connection connection, PacketFilter packetFilter, int maxSize) {
|
protected PacketCollector(XMPPConnection connection, PacketFilter packetFilter, int maxSize) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.packetFilter = packetFilter;
|
this.packetFilter = packetFilter;
|
||||||
this.resultQueue = new ArrayBlockingQueue<Packet>(maxSize);
|
this.resultQueue = new ArrayBlockingQueue<Packet>(maxSize);
|
||||||
|
|
|
@ -21,14 +21,14 @@ import org.jivesoftware.smack.packet.Packet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a mechanism to intercept and modify packets that are going to be
|
* Provides a mechanism to intercept and modify packets that are going to be
|
||||||
* sent to the server. PacketInterceptors are added to the {@link Connection}
|
* sent to the server. PacketInterceptors are added to the {@link XMPPConnection}
|
||||||
* together with a {@link org.jivesoftware.smack.filter.PacketFilter} so that only
|
* together with a {@link org.jivesoftware.smack.filter.PacketFilter} so that only
|
||||||
* certain packets are intercepted and processed by the interceptor.<p>
|
* certain packets are intercepted and processed by the interceptor.<p>
|
||||||
*
|
*
|
||||||
* This allows event-style programming -- every time a new packet is found,
|
* This allows event-style programming -- every time a new packet is found,
|
||||||
* the {@link #interceptPacket(Packet)} method will be called.
|
* the {@link #interceptPacket(Packet)} method will be called.
|
||||||
*
|
*
|
||||||
* @see Connection#addPacketInterceptor(PacketInterceptor, org.jivesoftware.smack.filter.PacketFilter)
|
* @see XMPPConnection#addPacketInterceptor(PacketInterceptor, org.jivesoftware.smack.filter.PacketFilter)
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
*/
|
*/
|
||||||
public interface PacketInterceptor {
|
public interface PacketInterceptor {
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.packet.Packet;
|
||||||
* opposite approach to the functionality provided by a {@link PacketCollector}
|
* opposite approach to the functionality provided by a {@link PacketCollector}
|
||||||
* which lets you block while waiting for results.
|
* which lets you block while waiting for results.
|
||||||
*
|
*
|
||||||
* @see Connection#addPacketListener(PacketListener, org.jivesoftware.smack.filter.PacketFilter)
|
* @see XMPPConnection#addPacketListener(PacketListener, org.jivesoftware.smack.filter.PacketFilter)
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
public interface PacketListener {
|
public interface PacketListener {
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class ReconnectionManager implements ConnectionListener {
|
||||||
private static final Logger LOGGER = Logger.getLogger(ReconnectionManager.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(ReconnectionManager.class.getName());
|
||||||
|
|
||||||
// Holds the connection to the server
|
// Holds the connection to the server
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
private Thread reconnectionThread;
|
private Thread reconnectionThread;
|
||||||
private int randomBase = new Random().nextInt(11) + 5; // between 5 and 15 seconds
|
private int randomBase = new Random().nextInt(11) + 5; // between 5 and 15 seconds
|
||||||
|
|
||||||
|
@ -48,14 +48,14 @@ public class ReconnectionManager implements ConnectionListener {
|
||||||
// Create a new PrivacyListManager on every established connection. In the init()
|
// Create a new PrivacyListManager on every established connection. In the init()
|
||||||
// method of PrivacyListManager, we'll add a listener that will delete the
|
// method of PrivacyListManager, we'll add a listener that will delete the
|
||||||
// instance when the connection is closed.
|
// instance when the connection is closed.
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
connection.addConnectionListener(new ReconnectionManager(connection));
|
connection.addConnectionListener(new ReconnectionManager(connection));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private ReconnectionManager(Connection connection) {
|
private ReconnectionManager(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ public class ReconnectionManager implements ConnectionListener {
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
// The process will try to reconnect until the connection is established or
|
// The process will try to reconnect until the connection is established or
|
||||||
// the user cancel the reconnection process {@link Connection#disconnect()}
|
// the user cancel the reconnection process {@link XMPPConnection#disconnect()}
|
||||||
while (ReconnectionManager.this.isReconnectionAllowed()) {
|
while (ReconnectionManager.this.isReconnectionAllowed()) {
|
||||||
// Find how much time we should wait until the next reconnection
|
// Find how much time we should wait until the next reconnection
|
||||||
int remainingSeconds = timeDelay();
|
int remainingSeconds = timeDelay();
|
||||||
|
@ -173,7 +173,7 @@ public class ReconnectionManager implements ConnectionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires listeners when The Connection will retry a reconnection. Expressed in seconds.
|
* Fires listeners when The XMPPConnection will retry a reconnection. Expressed in seconds.
|
||||||
*
|
*
|
||||||
* @param seconds the number of seconds that a reconnection will be attempted in.
|
* @param seconds the number of seconds that a reconnection will be attempted in.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -52,7 +52,7 @@ import org.jivesoftware.smack.util.StringUtils;
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
* @see Connection#getRoster()
|
* @see XMPPConnection#getRoster()
|
||||||
*/
|
*/
|
||||||
public class Roster {
|
public class Roster {
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class Roster {
|
||||||
*/
|
*/
|
||||||
private static SubscriptionMode defaultSubscriptionMode = SubscriptionMode.accept_all;
|
private static SubscriptionMode defaultSubscriptionMode = SubscriptionMode.accept_all;
|
||||||
|
|
||||||
private final Connection connection;
|
private final XMPPConnection connection;
|
||||||
private final RosterStore rosterStore;
|
private final RosterStore rosterStore;
|
||||||
private final Map<String, RosterGroup> groups;
|
private final Map<String, RosterGroup> groups;
|
||||||
private final Map<String,RosterEntry> entries;
|
private final Map<String,RosterEntry> entries;
|
||||||
|
@ -105,7 +105,7 @@ public class Roster {
|
||||||
*
|
*
|
||||||
* @param connection an XMPP connection.
|
* @param connection an XMPP connection.
|
||||||
*/
|
*/
|
||||||
Roster(final Connection connection) {
|
Roster(final XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
rosterStore = connection.getConfiguration().getRosterStore();
|
rosterStore = connection.getConfiguration().getRosterStore();
|
||||||
groups = new ConcurrentHashMap<String, RosterGroup>();
|
groups = new ConcurrentHashMap<String, RosterGroup>();
|
||||||
|
@ -138,9 +138,9 @@ public class Roster {
|
||||||
|
|
||||||
// if not connected add listener after successful login
|
// if not connected add listener after successful login
|
||||||
if(!this.connection.isConnected()) {
|
if(!this.connection.isConnected()) {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
|
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
if(connection.equals(Roster.this.connection)) {
|
if(connection.equals(Roster.this.connection)) {
|
||||||
Roster.this.connection.addConnectionListener(connectionListener);
|
Roster.this.connection.addConnectionListener(connectionListener);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class RosterEntry {
|
||||||
private RosterPacket.ItemType type;
|
private RosterPacket.ItemType type;
|
||||||
private RosterPacket.ItemStatus status;
|
private RosterPacket.ItemStatus status;
|
||||||
final private Roster roster;
|
final private Roster roster;
|
||||||
final private Connection connection;
|
final private XMPPConnection connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new roster entry.
|
* Creates a new roster entry.
|
||||||
|
@ -47,7 +47,7 @@ public class RosterEntry {
|
||||||
* @param connection a connection to the XMPP server.
|
* @param connection a connection to the XMPP server.
|
||||||
*/
|
*/
|
||||||
RosterEntry(String user, String name, RosterPacket.ItemType type,
|
RosterEntry(String user, String name, RosterPacket.ItemType type,
|
||||||
RosterPacket.ItemStatus status, Roster roster, Connection connection) {
|
RosterPacket.ItemStatus status, Roster roster, XMPPConnection connection) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.jivesoftware.smack.util.StringUtils;
|
||||||
public class RosterGroup {
|
public class RosterGroup {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
private final Set<RosterEntry> entries;
|
private final Set<RosterEntry> entries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,7 +45,7 @@ public class RosterGroup {
|
||||||
* @param name the name of the group.
|
* @param name the name of the group.
|
||||||
* @param connection the connection the group belongs to.
|
* @param connection the connection the group belongs to.
|
||||||
*/
|
*/
|
||||||
RosterGroup(String name, Connection connection) {
|
RosterGroup(String name, XMPPConnection connection) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
entries = new LinkedHashSet<RosterEntry>();
|
entries = new LinkedHashSet<RosterEntry>();
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class SASLAuthentication {
|
||||||
private static Map<String, Class<? extends SASLMechanism>> implementedMechanisms = new HashMap<String, Class<? extends SASLMechanism>>();
|
private static Map<String, Class<? extends SASLMechanism>> implementedMechanisms = new HashMap<String, Class<? extends SASLMechanism>>();
|
||||||
private static List<String> mechanismsPreferences = new ArrayList<String>();
|
private static List<String> mechanismsPreferences = new ArrayList<String>();
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
private Collection<String> serverMechanisms = new ArrayList<String>();
|
private Collection<String> serverMechanisms = new ArrayList<String>();
|
||||||
private SASLMechanism currentMechanism = null;
|
private SASLMechanism currentMechanism = null;
|
||||||
/**
|
/**
|
||||||
|
@ -170,7 +170,7 @@ public class SASLAuthentication {
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
SASLAuthentication(Connection connection) {
|
SASLAuthentication(XMPPConnection connection) {
|
||||||
super();
|
super();
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.init();
|
this.init();
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jivesoftware.smack;
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
@ -47,7 +46,7 @@ import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.Presence;
|
import org.jivesoftware.smack.packet.Presence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The abstract Connection class provides an interface for connections to a
|
* The abstract XMPPConnection class provides an interface for connections to a
|
||||||
* XMPP server and implements shared methods which are used by the
|
* XMPP server and implements shared methods which are used by the
|
||||||
* different types of connections (e.g. TCPConnection or BoshConnection).
|
* different types of connections (e.g. TCPConnection or BoshConnection).
|
||||||
*
|
*
|
||||||
|
@ -55,7 +54,7 @@ import org.jivesoftware.smack.packet.Presence;
|
||||||
* look like the following:
|
* look like the following:
|
||||||
* <pre>
|
* <pre>
|
||||||
* // Create a connection to the igniterealtime.org XMPP server.
|
* // Create a connection to the igniterealtime.org XMPP server.
|
||||||
* Connection con = new TCPConnection("igniterealtime.org");
|
* XMPPConnection con = new TCPConnection("igniterealtime.org");
|
||||||
* // Connect to the server
|
* // Connect to the server
|
||||||
* con.connect();
|
* con.connect();
|
||||||
* // Most servers require you to login before performing other tasks.
|
* // Most servers require you to login before performing other tasks.
|
||||||
|
@ -77,16 +76,15 @@ import org.jivesoftware.smack.packet.Presence;
|
||||||
* may be connected, disconnected and then connected again. Listeners of the Connection
|
* may be connected, disconnected and then connected again. Listeners of the Connection
|
||||||
* will be retained accross connections.<p>
|
* will be retained accross connections.<p>
|
||||||
* <p/>
|
* <p/>
|
||||||
* If a connected Connection gets disconnected abruptly then it will try to reconnect
|
* If a connected XMPPConnection gets disconnected abruptly then it will try to reconnect
|
||||||
* again. To stop the reconnection process, use {@link #disconnect()}. Once stopped
|
* again. To stop the reconnection process, use {@link #disconnect()}. Once stopped
|
||||||
* you can use {@link #connect()} to manually connect to the server.
|
* you can use {@link #connect()} to manually connect to the server.
|
||||||
*
|
*
|
||||||
* @see TCPConnection
|
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
* @author Guenther Niess
|
* @author Guenther Niess
|
||||||
*/
|
*/
|
||||||
public abstract class Connection {
|
public abstract class XMPPConnection {
|
||||||
private static final Logger LOGGER = Logger.getLogger(Connection.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(XMPPConnection.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counter to uniquely identify connections that are created.
|
* Counter to uniquely identify connections that are created.
|
||||||
|
@ -230,11 +228,11 @@ public abstract class Connection {
|
||||||
private final ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(2);
|
private final ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Connection to a XMPP server.
|
* Create a new XMPPConnection to a XMPP server.
|
||||||
*
|
*
|
||||||
* @param configuration The configuration which is used to establish the connection.
|
* @param configuration The configuration which is used to establish the connection.
|
||||||
*/
|
*/
|
||||||
protected Connection(ConnectionConfiguration configuration) {
|
protected XMPPConnection(ConnectionConfiguration configuration) {
|
||||||
config = configuration;
|
config = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,7 +480,7 @@ public abstract class Connection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the connection by setting presence to unavailable then closing the connection to
|
* Closes the connection by setting presence to unavailable then closing the connection to
|
||||||
* the XMPP server. The Connection can still be used for connecting to the server
|
* the XMPP server. The XMPPConnection can still be used for connecting to the server
|
||||||
* again.<p>
|
* again.<p>
|
||||||
* <p/>
|
* <p/>
|
||||||
* This method cleans up all resources used by the connection. Therefore, the roster,
|
* This method cleans up all resources used by the connection. Therefore, the roster,
|
||||||
|
@ -497,7 +495,7 @@ public abstract class Connection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the connection. A custom unavailable presence is sent to the server, followed
|
* Closes the connection. A custom unavailable presence is sent to the server, followed
|
||||||
* by closing the stream. The Connection can still be used for connecting to the server
|
* by closing the stream. The XMPPConnection can still be used for connecting to the server
|
||||||
* again. A custom unavilable presence is useful for communicating offline presence
|
* again. A custom unavilable presence is useful for communicating offline presence
|
||||||
* information such as "On vacation". Typically, just the status text of the presence
|
* information such as "On vacation". Typically, just the status text of the presence
|
||||||
* packet is set with online information, but most XMPP servers will deliver the full
|
* packet is set with online information, but most XMPP servers will deliver the full
|
||||||
|
@ -822,7 +820,7 @@ public abstract class Connection {
|
||||||
// option
|
// option
|
||||||
try {
|
try {
|
||||||
Constructor<?> constructor = debuggerClass
|
Constructor<?> constructor = debuggerClass
|
||||||
.getConstructor(Connection.class, Writer.class, Reader.class);
|
.getConstructor(XMPPConnection.class, Writer.class, Reader.class);
|
||||||
debugger = (SmackDebugger) constructor.newInstance(this, writer, reader);
|
debugger = (SmackDebugger) constructor.newInstance(this, writer, reader);
|
||||||
reader = debugger.getReader();
|
reader = debugger.getReader();
|
||||||
writer = debugger.getWriter();
|
writer = debugger.getWriter();
|
||||||
|
@ -842,7 +840,7 @@ public abstract class Connection {
|
||||||
/**
|
/**
|
||||||
* Set the servers Entity Caps node
|
* Set the servers Entity Caps node
|
||||||
*
|
*
|
||||||
* Connection holds this information in order to avoid a dependency to
|
* XMPPConnection holds this information in order to avoid a dependency to
|
||||||
* smackx where EntityCapsManager lives from smack.
|
* smackx where EntityCapsManager lives from smack.
|
||||||
*
|
*
|
||||||
* @param node
|
* @param node
|
||||||
|
@ -854,7 +852,7 @@ public abstract class Connection {
|
||||||
/**
|
/**
|
||||||
* Retrieve the servers Entity Caps node
|
* Retrieve the servers Entity Caps node
|
||||||
*
|
*
|
||||||
* Connection holds this information in order to avoid a dependency to
|
* XMPPConnection holds this information in order to avoid a dependency to
|
||||||
* smackx where EntityCapsManager lives from smack.
|
* smackx where EntityCapsManager lives from smack.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
|
@ -18,7 +18,7 @@ package org.jivesoftware.smack.debugger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.util.*;
|
import org.jivesoftware.smack.util.*;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public class ConsoleDebugger implements SmackDebugger {
|
||||||
public static boolean printInterpreted = false;
|
public static boolean printInterpreted = false;
|
||||||
private SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss aaa");
|
private SimpleDateFormat dateFormatter = new SimpleDateFormat("hh:mm:ss aaa");
|
||||||
|
|
||||||
private Connection connection = null;
|
private XMPPConnection connection = null;
|
||||||
|
|
||||||
private PacketListener listener = null;
|
private PacketListener listener = null;
|
||||||
private ConnectionListener connListener = null;
|
private ConnectionListener connListener = null;
|
||||||
|
@ -53,7 +53,7 @@ public class ConsoleDebugger implements SmackDebugger {
|
||||||
private ReaderListener readerListener;
|
private ReaderListener readerListener;
|
||||||
private WriterListener writerListener;
|
private WriterListener writerListener;
|
||||||
|
|
||||||
public ConsoleDebugger(Connection connection, Writer writer, Reader reader) {
|
public ConsoleDebugger(XMPPConnection connection, Writer writer, Reader reader) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
this.reader = reader;
|
this.reader = reader;
|
||||||
|
@ -111,7 +111,7 @@ public class ConsoleDebugger implements SmackDebugger {
|
||||||
connListener = new ConnectionListener() {
|
connListener = new ConnectionListener() {
|
||||||
public void connectionClosed() {
|
public void connectionClosed() {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
dateFormatter.format(new Date()) + " Connection closed (" +
|
dateFormatter.format(new Date()) + " XMPPConnection closed (" +
|
||||||
connection.hashCode() +
|
connection.hashCode() +
|
||||||
")");
|
")");
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class ConsoleDebugger implements SmackDebugger {
|
||||||
public void connectionClosedOnError(Exception e) {
|
public void connectionClosedOnError(Exception e) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
dateFormatter.format(new Date()) +
|
dateFormatter.format(new Date()) +
|
||||||
" Connection closed due to an exception (" +
|
" XMPPConnection closed due to an exception (" +
|
||||||
connection.hashCode() +
|
connection.hashCode() +
|
||||||
")");
|
")");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -134,13 +134,13 @@ public class ConsoleDebugger implements SmackDebugger {
|
||||||
}
|
}
|
||||||
public void reconnectionSuccessful() {
|
public void reconnectionSuccessful() {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
dateFormatter.format(new Date()) + " Connection reconnected (" +
|
dateFormatter.format(new Date()) + " XMPPConnection reconnected (" +
|
||||||
connection.hashCode() +
|
connection.hashCode() +
|
||||||
")");
|
")");
|
||||||
}
|
}
|
||||||
public void reconnectingIn(int seconds) {
|
public void reconnectingIn(int seconds) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
dateFormatter.format(new Date()) + " Connection (" +
|
dateFormatter.format(new Date()) + " XMPPConnection (" +
|
||||||
connection.hashCode() +
|
connection.hashCode() +
|
||||||
") will reconnect in " + seconds);
|
") will reconnect in " + seconds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class LiteDebugger implements SmackDebugger {
|
||||||
private static final String NEWLINE = "\n";
|
private static final String NEWLINE = "\n";
|
||||||
|
|
||||||
private JFrame frame = null;
|
private JFrame frame = null;
|
||||||
private Connection connection = null;
|
private XMPPConnection connection = null;
|
||||||
|
|
||||||
private PacketListener listener = null;
|
private PacketListener listener = null;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class LiteDebugger implements SmackDebugger {
|
||||||
private ReaderListener readerListener;
|
private ReaderListener readerListener;
|
||||||
private WriterListener writerListener;
|
private WriterListener writerListener;
|
||||||
|
|
||||||
public LiteDebugger(Connection connection, Writer writer, Reader reader) {
|
public LiteDebugger(XMPPConnection connection, Writer writer, Reader reader) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
this.reader = reader;
|
this.reader = reader;
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.jivesoftware.smack.*;
|
||||||
* displays XML traffic.<p>
|
* displays XML traffic.<p>
|
||||||
*
|
*
|
||||||
* Every implementation of this interface <b>must</b> have a public constructor with the following
|
* Every implementation of this interface <b>must</b> have a public constructor with the following
|
||||||
* arguments: Connection, Writer, Reader.
|
* arguments: XMPPConnection, Writer, Reader.
|
||||||
*
|
*
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smack.filter;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
@ -78,7 +78,7 @@ public class IQReplyFilter implements PacketFilter {
|
||||||
*
|
*
|
||||||
* @param iqPacket An IQ request. Filter for replies to this packet.
|
* @param iqPacket An IQ request. Filter for replies to this packet.
|
||||||
*/
|
*/
|
||||||
public IQReplyFilter(IQ iqPacket, Connection conn) {
|
public IQReplyFilter(IQ iqPacket, XMPPConnection conn) {
|
||||||
to = iqPacket.getTo();
|
to = iqPacket.getTo();
|
||||||
if (conn.getUser() == null) {
|
if (conn.getUser() == null) {
|
||||||
// We have not yet been assigned a username, this can happen if the connection is
|
// We have not yet been assigned a username, this can happen if the connection is
|
||||||
|
|
|
@ -279,7 +279,7 @@ public class Socks5ProxySocketFactory
|
||||||
o X'02' connection not allowed by ruleset
|
o X'02' connection not allowed by ruleset
|
||||||
o X'03' Network unreachable
|
o X'03' Network unreachable
|
||||||
o X'04' Host unreachable
|
o X'04' Host unreachable
|
||||||
o X'05' Connection refused
|
o X'05' XMPPConnection refused
|
||||||
o X'06' TTL expired
|
o X'06' TTL expired
|
||||||
o X'07' Command not supported
|
o X'07' Command not supported
|
||||||
o X'08' Address type not supported
|
o X'08' Address type not supported
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.packet.Bind;
|
import org.jivesoftware.smack.packet.Bind;
|
||||||
import org.jivesoftware.smack.packet.DefaultPacketExtension;
|
import org.jivesoftware.smack.packet.DefaultPacketExtension;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
@ -281,7 +281,7 @@ public class PacketParserUtils {
|
||||||
* @return an IQ object.
|
* @return an IQ object.
|
||||||
* @throws Exception if an exception occurs while parsing the packet.
|
* @throws Exception if an exception occurs while parsing the packet.
|
||||||
*/
|
*/
|
||||||
public static IQ parseIQ(XmlPullParser parser, Connection connection) throws Exception {
|
public static IQ parseIQ(XmlPullParser parser, XMPPConnection connection) throws Exception {
|
||||||
IQ iqPacket = null;
|
IQ iqPacket = null;
|
||||||
|
|
||||||
String id = parser.getAttributeValue("", "id");
|
String id = parser.getAttributeValue("", "id");
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionConfiguration;
|
import org.jivesoftware.smack.ConnectionConfiguration;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
|
@ -34,7 +34,7 @@ import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.packet.Presence;
|
import org.jivesoftware.smack.packet.Presence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dummy implementation of {@link Connection}, intended to be used during
|
* A dummy implementation of {@link XMPPConnection}, intended to be used during
|
||||||
* unit tests.
|
* unit tests.
|
||||||
*
|
*
|
||||||
* Instances store any packets that are delivered to be send using the
|
* Instances store any packets that are delivered to be send using the
|
||||||
|
@ -49,7 +49,7 @@ import org.jivesoftware.smack.packet.Presence;
|
||||||
* @see Connection
|
* @see Connection
|
||||||
* @author Guenther Niess
|
* @author Guenther Niess
|
||||||
*/
|
*/
|
||||||
public class DummyConnection extends Connection {
|
public class DummyConnection extends XMPPConnection {
|
||||||
|
|
||||||
private boolean authenticated = false;
|
private boolean authenticated = false;
|
||||||
private boolean anonymous = false;
|
private boolean anonymous = false;
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class PacketCollectorTest
|
||||||
|
|
||||||
class TestPacketCollector extends PacketCollector
|
class TestPacketCollector extends PacketCollector
|
||||||
{
|
{
|
||||||
protected TestPacketCollector(Connection conection, PacketFilter packetFilter, int size)
|
protected TestPacketCollector(XMPPConnection conection, PacketFilter packetFilter, int size)
|
||||||
{
|
{
|
||||||
super(conection, packetFilter, size);
|
super(conection, packetFilter, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class RosterTest {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
// Uncomment this to enable debug output
|
// Uncomment this to enable debug output
|
||||||
//Connection.DEBUG_ENABLED = true;
|
//XMPPConnection.DEBUG_ENABLED = true;
|
||||||
|
|
||||||
connection = new DummyConnection();
|
connection = new DummyConnection();
|
||||||
connection.connect();
|
connection.connect();
|
||||||
|
@ -702,7 +702,7 @@ public class RosterTest {
|
||||||
|
|
||||||
public synchronized void entriesAdded(Collection<String> addresses) {
|
public synchronized void entriesAdded(Collection<String> addresses) {
|
||||||
addressesAdded.addAll(addresses);
|
addressesAdded.addAll(addresses);
|
||||||
if (Connection.DEBUG_ENABLED) {
|
if (XMPPConnection.DEBUG_ENABLED) {
|
||||||
for (String address : addresses) {
|
for (String address : addresses) {
|
||||||
System.out.println("Roster entry for " + address + " added.");
|
System.out.println("Roster entry for " + address + " added.");
|
||||||
}
|
}
|
||||||
|
@ -711,7 +711,7 @@ public class RosterTest {
|
||||||
|
|
||||||
public synchronized void entriesDeleted(Collection<String> addresses) {
|
public synchronized void entriesDeleted(Collection<String> addresses) {
|
||||||
addressesDeleted.addAll(addresses);
|
addressesDeleted.addAll(addresses);
|
||||||
if (Connection.DEBUG_ENABLED) {
|
if (XMPPConnection.DEBUG_ENABLED) {
|
||||||
for (String address : addresses) {
|
for (String address : addresses) {
|
||||||
System.out.println("Roster entry for " + address + " deleted.");
|
System.out.println("Roster entry for " + address + " deleted.");
|
||||||
}
|
}
|
||||||
|
@ -720,7 +720,7 @@ public class RosterTest {
|
||||||
|
|
||||||
public synchronized void entriesUpdated(Collection<String> addresses) {
|
public synchronized void entriesUpdated(Collection<String> addresses) {
|
||||||
addressesUpdated.addAll(addresses);
|
addressesUpdated.addAll(addresses);
|
||||||
if (Connection.DEBUG_ENABLED) {
|
if (XMPPConnection.DEBUG_ENABLED) {
|
||||||
for (String address : addresses) {
|
for (String address : addresses) {
|
||||||
System.out.println("Roster entry for " + address + " updated.");
|
System.out.println("Roster entry for " + address + " updated.");
|
||||||
}
|
}
|
||||||
|
@ -728,7 +728,7 @@ public class RosterTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void presenceChanged(Presence presence) {
|
public void presenceChanged(Presence presence) {
|
||||||
if (Connection.DEBUG_ENABLED) {
|
if (XMPPConnection.DEBUG_ENABLED) {
|
||||||
System.out.println("Roster presence changed: " + presence.toXML());
|
System.out.println("Roster presence changed: " + presence.toXML());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class RosterVersioningTest {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
// Uncomment this to enable debug output
|
// Uncomment this to enable debug output
|
||||||
//Connection.DEBUG_ENABLED = true;
|
//XMPPConnection.DEBUG_ENABLED = true;
|
||||||
|
|
||||||
DefaultRosterStore store = DefaultRosterStore.init(tmpFolder.newFolder("store"));
|
DefaultRosterStore store = DefaultRosterStore.init(tmpFolder.newFolder("store"));
|
||||||
populateStore(store);
|
populateStore(store);
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.debugger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.debugger.SmackDebugger;
|
import org.jivesoftware.smack.debugger.SmackDebugger;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
|
@ -113,7 +113,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
private JFormattedTextField userField = null;
|
private JFormattedTextField userField = null;
|
||||||
private JFormattedTextField statusField = null;
|
private JFormattedTextField statusField = null;
|
||||||
|
|
||||||
private Connection connection = null;
|
private XMPPConnection connection = null;
|
||||||
|
|
||||||
private PacketListener packetReaderListener = null;
|
private PacketListener packetReaderListener = null;
|
||||||
private PacketListener packetWriterListener = null;
|
private PacketListener packetWriterListener = null;
|
||||||
|
@ -141,7 +141,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
|
|
||||||
JTabbedPane tabbedPane;
|
JTabbedPane tabbedPane;
|
||||||
|
|
||||||
public EnhancedDebugger(Connection connection, Writer writer, Reader reader) {
|
public EnhancedDebugger(XMPPConnection connection, Writer writer, Reader reader) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.writer = writer;
|
this.writer = writer;
|
||||||
this.reader = reader;
|
this.reader = reader;
|
||||||
|
@ -570,7 +570,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
// Add the Host information
|
// Add the Host information
|
||||||
JPanel connPanel = new JPanel();
|
JPanel connPanel = new JPanel();
|
||||||
connPanel.setLayout(new GridBagLayout());
|
connPanel.setLayout(new GridBagLayout());
|
||||||
connPanel.setBorder(BorderFactory.createTitledBorder("Connection information"));
|
connPanel.setBorder(BorderFactory.createTitledBorder("XMPPConnection information"));
|
||||||
|
|
||||||
JLabel label = new JLabel("Host: ");
|
JLabel label = new JLabel("Host: ");
|
||||||
label.setMinimumSize(new java.awt.Dimension(150, 14));
|
label.setMinimumSize(new java.awt.Dimension(150, 14));
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class EnhancedDebuggerWindow {
|
||||||
if (frame == null) {
|
if (frame == null) {
|
||||||
createDebug();
|
createDebug();
|
||||||
}
|
}
|
||||||
debugger.tabbedPane.setName("Connection_" + tabbedPane.getComponentCount());
|
debugger.tabbedPane.setName("XMPPConnection_" + tabbedPane.getComponentCount());
|
||||||
tabbedPane.add(debugger.tabbedPane, tabbedPane.getComponentCount() - 1);
|
tabbedPane.add(debugger.tabbedPane, tabbedPane.getComponentCount() - 1);
|
||||||
tabbedPane.setIconAt(tabbedPane.indexOfComponent(debugger.tabbedPane), connectionCreatedIcon);
|
tabbedPane.setIconAt(tabbedPane.indexOfComponent(debugger.tabbedPane), connectionCreatedIcon);
|
||||||
frame.setTitle(
|
frame.setTitle(
|
||||||
|
@ -168,7 +168,7 @@ public class EnhancedDebuggerWindow {
|
||||||
int index = getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane);
|
int index = getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane);
|
||||||
getInstance().tabbedPane.setToolTipTextAt(
|
getInstance().tabbedPane.setToolTipTextAt(
|
||||||
index,
|
index,
|
||||||
"Connection closed due to the exception: " + e.getMessage());
|
"XMPPConnection closed due to the exception: " + e.getMessage());
|
||||||
getInstance().tabbedPane.setIconAt(
|
getInstance().tabbedPane.setIconAt(
|
||||||
index,
|
index,
|
||||||
connectionClosedOnErrorIcon);
|
connectionClosedOnErrorIcon);
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Smack: Connection Management - Jive Software</title>
|
<title>Smack: XMPPConnection Management - Jive Software</title>
|
||||||
<link rel="stylesheet" type="text/css" href="style.css"/>
|
<link rel="stylesheet" type="text/css" href="style.css"/>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="header">
|
<div class="header">
|
||||||
Smack: Connection Management
|
Smack: XMPPConnection Management
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="nav">
|
<div class="nav">
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The <tt>org.jivesoftware.smack.Connection</tt> class manages your connection to an XMPP
|
The <tt>org.jivesoftware.smack.XMPPConnection</tt> class manages your connection to an XMPP
|
||||||
server. The default implementation is the <tt>org.jivesoftware.smack.XMPPConnection</tt>
|
server. The default implementation is the <tt>org.jivesoftware.smack.XMPPConnection</tt>
|
||||||
class. Two constructors are mainly used. The first, <tt>XMPPConnection(String)</tt> takes
|
class. Two constructors are mainly used. The first, <tt>XMPPConnection(String)</tt> takes
|
||||||
the server name you'd like to connect to as an argument. All default connection settings will
|
the server name you'd like to connect to as an argument. All default connection settings will
|
||||||
|
@ -80,7 +80,7 @@ manager will try to immediately reconnect to the server and increase the delay b
|
||||||
successive reconnections keep failing.</i>
|
successive reconnections keep failing.</i>
|
||||||
<br>
|
<br>
|
||||||
In case you want to force a reconnection while the reconnetion manager is waiting for the next
|
In case you want to force a reconnection while the reconnetion manager is waiting for the next
|
||||||
reconnection, you can just use <i>Connection#connect()</i> and a new attempt will be made.
|
reconnection, you can just use <i>XMPPConnection#connect()</i> and a new attempt will be made.
|
||||||
If the manual attempt also failed then the reconnection manager will still continue the
|
If the manual attempt also failed then the reconnection manager will still continue the
|
||||||
reconnection job.
|
reconnection job.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -26,7 +26,7 @@ Debugging mode can be enabled in two different ways:
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
<li>Add the following line of code <b>before</b> creating new connections:<p>
|
<li>Add the following line of code <b>before</b> creating new connections:<p>
|
||||||
<tt>Connection.DEBUG_ENABLED = true;</tt><p>
|
<tt>XMPPConnection.DEBUG_ENABLED = true;</tt><p>
|
||||||
|
|
||||||
<li>Set the Java system property <tt>smack.debugEnabled</tt> to true. The
|
<li>Set the Java system property <tt>smack.debugEnabled</tt> to true. The
|
||||||
system property can be set on the command line such as:<p>
|
system property can be set on the command line such as:<p>
|
||||||
|
@ -39,7 +39,7 @@ add the following line to your application before opening new connections:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<tt>Connection.DEBUG_ENABLED = false;</tt>
|
<tt>XMPPConnection.DEBUG_ENABLED = false;</tt>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
@ -73,7 +73,7 @@ When debugging mode is enabled, a debug window will appear containing tabs for e
|
||||||
The window will contain the following information:
|
The window will contain the following information:
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Connection tabs -- each tab shows debugging information related to the connection.
|
<li>XMPPConnection tabs -- each tab shows debugging information related to the connection.
|
||||||
<li>Smack info tab -- shows information about Smack (e.g. Smack version, installed components, etc.).
|
<li>Smack info tab -- shows information about Smack (e.g. Smack version, installed components, etc.).
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,9 @@ discovery request with the information that you previously configured.</p>
|
||||||
<b>Usage</b><p>
|
<b>Usage</b><p>
|
||||||
|
|
||||||
In order to configure the supported features by your client you should first obtain the
|
In order to configure the supported features by your client you should first obtain the
|
||||||
ServiceDiscoveryManager associated with your Connection. To get your ServiceDiscoveryManager
|
ServiceDiscoveryManager associated with your XMPPConnection. To get your ServiceDiscoveryManager
|
||||||
send <b>getInstanceFor(connection)</b> to the class <i><b>ServiceDiscoveryManager</b></i> where
|
send <b>getInstanceFor(connection)</b> to the class <i><b>ServiceDiscoveryManager</b></i> where
|
||||||
connection is your Connection.<br></p>
|
connection is your XMPPConnection.<br></p>
|
||||||
|
|
||||||
<p>Once you have your ServiceDiscoveryManager you will be able to manage the supported features. To
|
<p>Once you have your ServiceDiscoveryManager you will be able to manage the supported features. To
|
||||||
register a new feature send <b>addFeature(feature)</b> to your <i><b>ServiceDiscoveryManager</b></i>
|
register a new feature send <b>addFeature(feature)</b> to your <i><b>ServiceDiscoveryManager</b></i>
|
||||||
|
@ -48,7 +48,7 @@ String that represents the feature to remove.</p>
|
||||||
|
|
||||||
In this example we can see how to add and remove supported features: <br>
|
In this example we can see how to add and remove supported features: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Register that a new feature is supported by this XMPP entity</font>
|
<font color="#3f7f5f">// Register that a new feature is supported by this XMPP entity</font>
|
||||||
|
@ -74,7 +74,7 @@ to configure the information providers associated to the items/nodes within the
|
||||||
In order to configure the associated nodes within the Smack client you will need to create a
|
In order to configure the associated nodes within the Smack client you will need to create a
|
||||||
NodeInformationProvider and register it with the <i><b>ServiceDiscoveryManager</b></i>. To get
|
NodeInformationProvider and register it with the <i><b>ServiceDiscoveryManager</b></i>. To get
|
||||||
your ServiceDiscoveryManager send <b>getInstanceFor(connection)</b> to the class <i><b>ServiceDiscoveryManager</b></i>
|
your ServiceDiscoveryManager send <b>getInstanceFor(connection)</b> to the class <i><b>ServiceDiscoveryManager</b></i>
|
||||||
where connection is your Connection.<br></p>
|
where connection is your XMPPConnection.<br></p>
|
||||||
|
|
||||||
<p>Once you have your ServiceDiscoveryManager you will be able to register information providers
|
<p>Once you have your ServiceDiscoveryManager you will be able to register information providers
|
||||||
for the XMPP entity's nodes. To register a new node information provider send <b>setNodeInformationProvider(String node, NodeInformationProvider listener)</b>
|
for the XMPP entity's nodes. To register a new node information provider send <b>setNodeInformationProvider(String node, NodeInformationProvider listener)</b>
|
||||||
|
@ -126,7 +126,7 @@ the discovered items.</p>
|
||||||
|
|
||||||
In this example we can see how to discover the items associated with an online catalog service: <br>
|
In this example we can see how to discover the items associated with an online catalog service: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the items of a given XMPP entity</font>
|
<font color="#3f7f5f">// Get the items of a given XMPP entity</font>
|
||||||
|
@ -171,7 +171,7 @@ the discovered information.</p>
|
||||||
|
|
||||||
In this example we can see how to discover the information of a conference room: <br>
|
In this example we can see how to discover the information of a conference room: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the information of a given XMPP entity</font>
|
<font color="#3f7f5f">// Get the information of a given XMPP entity</font>
|
||||||
|
@ -216,7 +216,7 @@ to publish.</p>
|
||||||
|
|
||||||
In this example we can see how to publish new items: <br>
|
In this example we can see how to publish new items: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my Connection</font>
|
<pre> <font color="#3f7f5f">// Obtain the ServiceDiscoveryManager associated with my XMPPConnection</font>
|
||||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Create a DiscoverItems with the items to publish</font>
|
<font color="#3f7f5f">// Create a DiscoverItems with the items to publish</font>
|
||||||
|
|
|
@ -34,7 +34,7 @@ to enable the user to easily send a file.
|
||||||
<b>Usage</b><p>
|
<b>Usage</b><p>
|
||||||
|
|
||||||
In order to send a file you must first construct an instance of the <b><i>FileTransferManager</i></b>
|
In order to send a file you must first construct an instance of the <b><i>FileTransferManager</i></b>
|
||||||
class. This class has one constructor with one parameter which is your Connection.
|
class. This class has one constructor with one parameter which is your XMPPConnection.
|
||||||
In order to instantiate the manager you should call <i>new FileTransferManager(connection)</i>
|
In order to instantiate the manager you should call <i>new FileTransferManager(connection)</i>
|
||||||
|
|
||||||
<p>Once you have your <b><i>FileTransferManager</i></b> you will need to create an outgoing
|
<p>Once you have your <b><i>FileTransferManager</i></b> you will need to create an outgoing
|
||||||
|
@ -86,7 +86,7 @@ manager.</p>
|
||||||
<b>Usage</b><p>
|
<b>Usage</b><p>
|
||||||
|
|
||||||
In order to recieve a file you must first construct an instance of the <b><i>FileTransferManager</i></b>
|
In order to recieve a file you must first construct an instance of the <b><i>FileTransferManager</i></b>
|
||||||
class. This class has one constructor with one parameter which is your Connection.
|
class. This class has one constructor with one parameter which is your XMPPConnection.
|
||||||
In order to instantiate the manager you should call <i>new FileTransferManager(connection)</i>
|
In order to instantiate the manager you should call <i>new FileTransferManager(connection)</i>
|
||||||
|
|
||||||
<p>Once you have your <b><i>FileTransferManager</i></b> you will need to register a listener
|
<p>Once you have your <b><i>FileTransferManager</i></b> you will need to register a listener
|
||||||
|
|
|
@ -75,14 +75,14 @@ You can receive notification requests for the following events: delivered, displ
|
||||||
The general idea is to create a new <i>DefaultMessageEventRequestListener</i> that will listen to the event notifications
|
The general idea is to create a new <i>DefaultMessageEventRequestListener</i> that will listen to the event notifications
|
||||||
requests and react with custom logic. Then you will have to add the listener to the
|
requests and react with custom logic. Then you will have to add the listener to the
|
||||||
<i>MessageEventManager</i> that works on
|
<i>MessageEventManager</i> that works on
|
||||||
the desired <i>Connection</i>.
|
the desired <i>XMPPConnection</i>.
|
||||||
<p>Note that <i>DefaultMessageEventRequestListener</i> is a default implementation of the
|
<p>Note that <i>DefaultMessageEventRequestListener</i> is a default implementation of the
|
||||||
<i>MessageEventRequestListener</i> interface.
|
<i>MessageEventRequestListener</i> interface.
|
||||||
The class <i>DefaultMessageEventRequestListener</i> automatically sends a delivered notification to the sender of the message
|
The class <i>DefaultMessageEventRequestListener</i> automatically sends a delivered notification to the sender of the message
|
||||||
if the sender has requested to be notified when the message is delivered. If you decide to create a new class that
|
if the sender has requested to be notified when the message is delivered. If you decide to create a new class that
|
||||||
implements the <i>MessageEventRequestListener</i> interface, please remember to send the delivered notification.</p>
|
implements the <i>MessageEventRequestListener</i> interface, please remember to send the delivered notification.</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>To create a new <i>MessageEventManager</i> use the <i><b>MessageEventManager(Connection)</b></i> constructor.
|
<li>To create a new <i>MessageEventManager</i> use the <i><b>MessageEventManager(XMPPConnection)</b></i> constructor.
|
||||||
</li>
|
</li>
|
||||||
<li>To create an event notification requests listener create a subclass of <i><b>DefaultMessageEventRequestListener</b></i> or
|
<li>To create an event notification requests listener create a subclass of <i><b>DefaultMessageEventRequestListener</b></i> or
|
||||||
create a class that implements the <i><b>MessageEventRequestListener</b></i> interface.
|
create a class that implements the <i><b>MessageEventRequestListener</b></i> interface.
|
||||||
|
@ -178,9 +178,9 @@ will probably want to react to some or all of these events.</p>
|
||||||
|
|
||||||
The general idea is to create a new <i>MessageEventNotificationListener</i> that will listen to the event notifications
|
The general idea is to create a new <i>MessageEventNotificationListener</i> that will listen to the event notifications
|
||||||
and react with custom logic. Then you will have to add the listener to the <i>MessageEventManager</i> that works on
|
and react with custom logic. Then you will have to add the listener to the <i>MessageEventManager</i> that works on
|
||||||
the desired <i>Connection</i>.
|
the desired <i>XMPPConnection</i>.
|
||||||
<ul>
|
<ul>
|
||||||
<li>To create a new <i>MessageEventManager</i> use the <i><b>MessageEventManager(Connection)</b></i> constructor.
|
<li>To create a new <i>MessageEventManager</i> use the <i><b>MessageEventManager(XMPPConnection)</b></i> constructor.
|
||||||
</li>
|
</li>
|
||||||
<li>To create an event notifications listener create a class that implements the <i><b>MessageEventNotificationListener</b></i>
|
<li>To create an event notifications listener create a class that implements the <i><b>MessageEventNotificationListener</b></i>
|
||||||
interface.
|
interface.
|
||||||
|
|
|
@ -51,7 +51,7 @@ the form and finally send it back to the server.</p>
|
||||||
|
|
||||||
In this example we can see how to create an instant room: <br>
|
In this example we can see how to create an instant room: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a Connection for a room</font>
|
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a XMPPConnection for a room</font>
|
||||||
MultiUserChat muc = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
MultiUserChat muc = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Create the room</font>
|
<font color="#3f7f5f">// Create the room</font>
|
||||||
|
@ -65,7 +65,7 @@ In this example we can see how to create an instant room: <br>
|
||||||
|
|
||||||
In this example we can see how to create a reserved room. The form is completed with default values: <br>
|
In this example we can see how to create a reserved room. The form is completed with default values: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a Connection for a room</font>
|
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a XMPPConnection for a room</font>
|
||||||
MultiUserChat muc = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
MultiUserChat muc = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Create the room</font>
|
<font color="#3f7f5f">// Create the room</font>
|
||||||
|
@ -121,7 +121,7 @@ for a response from the server.</p>
|
||||||
|
|
||||||
In this example we can see how to join a room with a given nickname: <br>
|
In this example we can see how to join a room with a given nickname: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a Connection for a room</font>
|
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a XMPPConnection for a room</font>
|
||||||
MultiUserChat muc2 = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
MultiUserChat muc2 = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
||||||
|
|
||||||
<font color="#3f7f5f">// User2 joins the new room</font>
|
<font color="#3f7f5f">// User2 joins the new room</font>
|
||||||
|
@ -132,7 +132,7 @@ In this example we can see how to join a room with a given nickname: <br>
|
||||||
|
|
||||||
In this example we can see how to join a room with a given nickname and password: <br>
|
In this example we can see how to join a room with a given nickname and password: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a Connection for a room</font>
|
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a XMPPConnection for a room</font>
|
||||||
MultiUserChat muc2 = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
MultiUserChat muc2 = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
||||||
|
|
||||||
<font color="#3f7f5f">// User2 joins the new room using a password</font>
|
<font color="#3f7f5f">// User2 joins the new room using a password</font>
|
||||||
|
@ -144,7 +144,7 @@ In this example we can see how to join a room with a given nickname and password
|
||||||
In this example we can see how to join a room with a given nickname specifying the amount of history
|
In this example we can see how to join a room with a given nickname specifying the amount of history
|
||||||
to receive: <br>
|
to receive: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a Connection for a room</font>
|
<pre> <font color="#3f7f5f">// Create a MultiUserChat using a XMPPConnection for a room</font>
|
||||||
MultiUserChat muc2 = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
MultiUserChat muc2 = new MultiUserChat(conn1, <font color="#0000FF">"myroom@conference.jabber.org"</font>);
|
||||||
|
|
||||||
<font color="#3f7f5f">// User2 joins the new room using a password and specifying</font>
|
<font color="#3f7f5f">// User2 joins the new room using a password and specifying</font>
|
||||||
|
@ -205,7 +205,7 @@ In this example we can see how to listen for room invitations and decline invita
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre> <font color="#3f7f5f">// User3 listens for MUC invitations</font>
|
<pre> <font color="#3f7f5f">// User3 listens for MUC invitations</font>
|
||||||
MultiUserChat.addInvitationListener(conn3, new InvitationListener() {
|
MultiUserChat.addInvitationListener(conn3, new InvitationListener() {
|
||||||
public void invitationReceived(Connection conn, String room, String inviter, String reason, String password) {
|
public void invitationReceived(XMPPConnection conn, String room, String inviter, String reason, String password) {
|
||||||
<font color="#3f7f5f">// Reject the invitation</font>
|
<font color="#3f7f5f">// Reject the invitation</font>
|
||||||
MultiUserChat.decline(conn, room, inviter, <font color="#0000FF">"I'm busy right now"</font>);
|
MultiUserChat.decline(conn, room, inviter, <font color="#0000FF">"I'm busy right now"</font>);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ A user may want to discover if one of the user's contacts supports the Multi-Use
|
||||||
<b>Usage</b><p>
|
<b>Usage</b><p>
|
||||||
|
|
||||||
In order to discover if one of the user's contacts supports MUC just send
|
In order to discover if one of the user's contacts supports MUC just send
|
||||||
<b>isServiceEnabled(Connection connection, String user)</b> to the <i><b>MultiUserChat</b></i>
|
<b>isServiceEnabled(XMPPConnection connection, String user)</b> to the <i><b>MultiUserChat</b></i>
|
||||||
class where user is a fully qualified XMPP ID, e.g. jdoe@example.com. You will receive
|
class where user is a fully qualified XMPP ID, e.g. jdoe@example.com. You will receive
|
||||||
a boolean indicating whether the user supports MUC or not.</p>
|
a boolean indicating whether the user supports MUC or not.</p>
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ A user may also want to query a contact regarding which rooms the contact is in.
|
||||||
<b>Usage</b><p>
|
<b>Usage</b><p>
|
||||||
|
|
||||||
In order to get the rooms where a user is in just send
|
In order to get the rooms where a user is in just send
|
||||||
<b>getJoinedRooms(Connection connection, String user)</b> to the <i><b>MultiUserChat</b></i>
|
<b>getJoinedRooms(XMPPConnection connection, String user)</b> to the <i><b>MultiUserChat</b></i>
|
||||||
class where user is a fully qualified XMPP ID, e.g. jdoe@example.com. You will get an Iterator
|
class where user is a fully qualified XMPP ID, e.g. jdoe@example.com. You will get an Iterator
|
||||||
of Strings as an answer where each String represents a room name.</p>
|
of Strings as an answer where each String represents a room name.</p>
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ will provide information only for public rooms.</p>
|
||||||
|
|
||||||
<b>Usage</b><p>
|
<b>Usage</b><p>
|
||||||
|
|
||||||
In order to discover information about a room just send <b>getRoomInfo(Connection connection, String room)</b>
|
In order to discover information about a room just send <b>getRoomInfo(XMPPConnection connection, String room)</b>
|
||||||
to the <i><b>MultiUserChat</b></i> class where room is the XMPP ID of the room, e.g.
|
to the <i><b>MultiUserChat</b></i> class where room is the XMPP ID of the room, e.g.
|
||||||
roomName@conference.myserver. You will get a RoomInfo object that contains the discovered room
|
roomName@conference.myserver. You will get a RoomInfo object that contains the discovered room
|
||||||
information.</p>
|
information.</p>
|
||||||
|
|
|
@ -47,7 +47,7 @@ a fully configured node.</p><p>
|
||||||
Create an instant node: <br>
|
Create an instant node: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Create the node</font>
|
<font color="#3f7f5f">// Create the node</font>
|
||||||
|
@ -58,7 +58,7 @@ Create an instant node: <br>
|
||||||
Create a node with default configuration and then configure it: <br>
|
Create a node with default configuration and then configure it: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Create the node</font>
|
<font color="#3f7f5f">// Create the node</font>
|
||||||
|
@ -77,7 +77,7 @@ Create a node with default configuration and then configure it: <br>
|
||||||
Create and configure a node: <br>
|
Create and configure a node: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Create the node</font>
|
<font color="#3f7f5f">// Create the node</font>
|
||||||
|
@ -117,7 +117,7 @@ will be dependent on its configuration.
|
||||||
In this example we publish an item to a node that does not take payload: <br>
|
In this example we publish an item to a node that does not take payload: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the node</font>
|
<font color="#3f7f5f">// Get the node</font>
|
||||||
|
@ -133,7 +133,7 @@ In this example we publish an item to a node that does not take payload: <br>
|
||||||
In this example we publish an item to a node that does take payload: <br>
|
In this example we publish an item to a node that does take payload: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the node</font>
|
<font color="#3f7f5f">// Get the node</font>
|
||||||
|
@ -174,7 +174,7 @@ In this example we can see how to create a listener and register it and then sub
|
||||||
messages. <br>
|
messages. <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the node</font>
|
<font color="#3f7f5f">// Get the node</font>
|
||||||
|
@ -212,7 +212,7 @@ In this example we can see how to create a listener, register it and then subscr
|
||||||
item deletion messages. <br>
|
item deletion messages. <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the node</font>
|
<font color="#3f7f5f">// Get the node</font>
|
||||||
|
@ -250,7 +250,7 @@ In this example we can see how to create a listener, register it and then subscr
|
||||||
node configuration messages. <br>
|
node configuration messages. <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the node</font>
|
<font color="#3f7f5f">// Get the node</font>
|
||||||
|
@ -315,7 +315,7 @@ of a <i><b>LeafNode</b></i> and call one of the retrieve methods.
|
||||||
In this example we can see how to retrieve the existing items from a node: <br>
|
In this example we can see how to retrieve the existing items from a node: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the node</font>
|
<font color="#3f7f5f">// Get the node</font>
|
||||||
|
@ -329,7 +329,7 @@ In this example we can see how to retrieve the existing items from a node: <br>
|
||||||
In this example we can see how to retrieve the last N existing items: <br>
|
In this example we can see how to retrieve the last N existing items: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the node</font>
|
<font color="#3f7f5f">// Get the node</font>
|
||||||
|
@ -343,7 +343,7 @@ In this example we can see how to retrieve the specified existing items: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
|
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the node</font>
|
<font color="#3f7f5f">// Get the node</font>
|
||||||
|
@ -375,7 +375,7 @@ or <i><b>Node</b></i> classes depending on what type of information is required.
|
||||||
In this example we can see how to get pubsub capabilities: <br>
|
In this example we can see how to get pubsub capabilities: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the pubsub features that are supported</font>
|
<font color="#3f7f5f">// Get the pubsub features that are supported</font>
|
||||||
|
@ -386,7 +386,7 @@ In this example we can see how to get pubsub capabilities: <br>
|
||||||
In this example we can see how to get pubsub subscriptions for all nodes: <br>
|
In this example we can see how to get pubsub subscriptions for all nodes: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get all the subscriptions in the pubsub service</font>
|
<font color="#3f7f5f">// Get all the subscriptions in the pubsub service</font>
|
||||||
|
@ -397,7 +397,7 @@ In this example we can see how to get pubsub subscriptions for all nodes: <br>
|
||||||
In this example we can see how to get all affiliations for the users bare JID on the pubsub service: <br>
|
In this example we can see how to get all affiliations for the users bare JID on the pubsub service: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
|
|
||||||
<font color="#3f7f5f">// Get the affiliations for the users bare JID</font>
|
<font color="#3f7f5f">// Get the affiliations for the users bare JID</font>
|
||||||
|
@ -408,7 +408,7 @@ In this example we can see how to get all affiliations for the users bare JID on
|
||||||
In this example we can see how to get information about the node: <br>
|
In this example we can see how to get information about the node: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
Node node = mgr.getNode(<font color="#0000FF">"testNode"</font>);
|
Node node = mgr.getNode(<font color="#0000FF">"testNode"</font>);
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ In this example we can see how to get information about the node: <br>
|
||||||
In this example we can see how to discover the node items: <br>
|
In this example we can see how to discover the node items: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
Node node = mgr.getNode(<font color="#0000FF">"testNode"</font>);
|
Node node = mgr.getNode(<font color="#0000FF">"testNode"</font>);
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ In this example we can see how to discover the node items: <br>
|
||||||
In this example we can see how to get node subscriptions: <br>
|
In this example we can see how to get node subscriptions: <br>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
<pre>
|
<pre>
|
||||||
<font color="#3f7f5f">// Create a pubsub manager using an existing Connection</font>
|
<font color="#3f7f5f">// Create a pubsub manager using an existing XMPPConnection</font>
|
||||||
PubSubManager mgr = new PubSubManager(con);
|
PubSubManager mgr = new PubSubManager(con);
|
||||||
Node node = mgr.getNode(<font color="#0000FF">"testNode"</font>);
|
Node node = mgr.getNode(<font color="#0000FF">"testNode"</font>);
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ received.</p>
|
||||||
<li>Create a class that implements the <i><b>RosterExchangeListener</b></i> interface.</li>
|
<li>Create a class that implements the <i><b>RosterExchangeListener</b></i> interface.</li>
|
||||||
<li>Implement the method <b>entriesReceived(String, Iterator)</b> that will be called when new entries
|
<li>Implement the method <b>entriesReceived(String, Iterator)</b> that will be called when new entries
|
||||||
are received with custom logic.</li>
|
are received with custom logic.</li>
|
||||||
<li>Add the listener to the <i>RosterExchangeManager</i> that works on the desired <i>Connection</i>.</li>
|
<li>Add the listener to the <i>RosterExchangeManager</i> that works on the desired <i>XMPPConnection</i>.</li>
|
||||||
</ol></p>
|
</ol></p>
|
||||||
|
|
||||||
<b>Example</b><p>
|
<b>Example</b><p>
|
||||||
|
|
|
@ -97,7 +97,7 @@ the message as you do with any other message.</p>
|
||||||
An XHTML message is like any regular message, therefore to send the message you can follow
|
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
|
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 <b>#send(Message)</b> of <i><b>Chat</b></i> or you can use
|
of a chat just use the message <b>#send(Message)</b> of <i><b>Chat</b></i> or you can use
|
||||||
the message <b>#send(Packet)</b> of <i><b>Connection</b></i>.</p>
|
the message <b>#send(Packet)</b> of <i><b>XMPPConnection</b></i>.</p>
|
||||||
|
|
||||||
<b>Example</b><p>
|
<b>Example</b><p>
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ section explains how to explicitly discover for XHTML support.</p>
|
||||||
|
|
||||||
<b>Usage</b><p>
|
<b>Usage</b><p>
|
||||||
|
|
||||||
In order to discover if a remote user supports XHTML messages send <b>#isServiceEnabled(Connection
|
In order to discover if a remote user supports XHTML messages send <b>#isServiceEnabled(XMPPConnection
|
||||||
connection, String userID)</b> to the class <i><b>XHTMLManager</b></i> where connection is the connection
|
connection, String userID)</b> to the class <i><b>XHTMLManager</b></i> where connection is the connection
|
||||||
to use to perform the service discovery and userID is the user to check (A fully qualified xmpp ID,
|
to use to perform the service discovery and userID is the user to check (A fully qualified xmpp ID,
|
||||||
e.g. jdoe@example.com). This message will return true if the specified user handles XHTML messages.</p>
|
e.g. jdoe@example.com). This message will return true if the specified user handles XHTML messages.</p>
|
||||||
|
|
|
@ -94,10 +94,10 @@ conn2.connect();
|
||||||
<p>Note that maximum security will be used when connecting to the server by default (and when possible),
|
<p>Note that maximum security will be used when connecting to the server by default (and when possible),
|
||||||
including use of TLS encryption. The ConnectionConfiguration class provides advanced control
|
including use of TLS encryption. The ConnectionConfiguration class provides advanced control
|
||||||
over the connection created, such as the ability to disable or require encryption. See
|
over the connection created, such as the ability to disable or require encryption. See
|
||||||
<a href="connections.html">Connection Management</a> for full details.</p>
|
<a href="connections.html">XMPPConnection Management</a> for full details.</p>
|
||||||
|
|
||||||
<p>Once you've created a connection, you should login using a username and password
|
<p>Once you've created a connection, you should login using a username and password
|
||||||
with the <tt>Connection.login(String username, String password)</tt> method.
|
with the <tt>XMPPConnection.login(String username, String password)</tt> method.
|
||||||
Once you've logged in, you can being chatting with other users by creating
|
Once you've logged in, you can being chatting with other users by creating
|
||||||
new <tt>Chat</tt> or <tt>GroupChat</tt> objects.
|
new <tt>Chat</tt> or <tt>GroupChat</tt> objects.
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ The roster lets you keep track of the availability (presence) of other users. Us
|
||||||
can be organized into groups such as "Friends" and "Co-workers", and then you
|
can be organized into groups such as "Friends" and "Co-workers", and then you
|
||||||
discover whether each user is online or offline.<p>
|
discover whether each user is online or offline.<p>
|
||||||
|
|
||||||
Retrieve the roster using the <tt>Connection.getRoster()</tt> method. The roster
|
Retrieve the roster using the <tt>XMPPConnection.getRoster()</tt> method. The roster
|
||||||
class allows you to find all the roster entries, the groups they belong to, and the
|
class allows you to find all the roster entries, the groups they belong to, and the
|
||||||
current presence status of each entry.
|
current presence status of each entry.
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ and "out fishing":<p>
|
||||||
<font color="gray"><i>// Create a new presence. Pass in false to indicate we're unavailable.</i></font>
|
<font color="gray"><i>// Create a new presence. Pass in false to indicate we're unavailable.</i></font>
|
||||||
Presence presence = new Presence(Presence.Type.unavailable);
|
Presence presence = new Presence(Presence.Type.unavailable);
|
||||||
presence.setStatus(<font color="green">"Gone fishing"</font>);
|
presence.setStatus(<font color="green">"Gone fishing"</font>);
|
||||||
<font color="gray"><i>// Send the packet (assume we have a Connection instance called "con").</i></font>
|
<font color="gray"><i>// Send the packet (assume we have a XMPPConnection instance called "con").</i></font>
|
||||||
con.sendPacket(presence);
|
con.sendPacket(presence);
|
||||||
</pre></div>
|
</pre></div>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -29,7 +29,7 @@ A chat creates a new thread of messages (using a thread ID) between two users. T
|
||||||
following code snippet demonstrates how to create a new Chat with a user and then send
|
following code snippet demonstrates how to create a new Chat with a user and then send
|
||||||
them a text message:<p>
|
them a text message:<p>
|
||||||
|
|
||||||
<div class="code"><pre><font color="gray"><i>// Assume we've created a Connection name "connection".</i></font>
|
<div class="code"><pre><font color="gray"><i>// Assume we've created a XMPPConnection name "connection".</i></font>
|
||||||
ChatManager chatmanager = connection.getChatManager();
|
ChatManager chatmanager = connection.getChatManager();
|
||||||
Chat newChat = chatmanager.createChat(<font
|
Chat newChat = chatmanager.createChat(<font
|
||||||
color="green">"jsmith@jivesoftware.com"</font>, new MessageListener() {
|
color="green">"jsmith@jivesoftware.com"</font>, new MessageListener() {
|
||||||
|
@ -98,7 +98,7 @@ will create a new one that does match. To get this new chat, you have to regist
|
||||||
notified when it happens. You can register a message listener to receive all future messages as
|
notified when it happens. You can register a message listener to receive all future messages as
|
||||||
part of this handler.<p>
|
part of this handler.<p>
|
||||||
|
|
||||||
<div class="code"><pre><font color="gray"><i>// Assume we've created a Connection name "connection".</i></font>
|
<div class="code"><pre><font color="gray"><i>// Assume we've created a XMPPConnection name "connection".</i></font>
|
||||||
ChatManager chatmanager = connection.getChatManager().addChatListener(
|
ChatManager chatmanager = connection.getChatManager().addChatListener(
|
||||||
new ChatManagerListener() {
|
new ChatManagerListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -27,7 +27,7 @@ A packet listener is used for event style programming, while a packet collector
|
||||||
result queue of packets that you can do polling and blocking operations on. So, a packet
|
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,
|
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
|
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 <tt>Connection</tt> instance.<p>
|
arrive. Packet collectors and listeners can be created using an <tt>XMPPConnection</tt> instance.<p>
|
||||||
|
|
||||||
The <tt>org.jivesoftware.smack.filter.PacketFilter</tt> interface determines which
|
The <tt>org.jivesoftware.smack.filter.PacketFilter</tt> interface determines which
|
||||||
specific packets will be delivered to a <tt>PacketCollector</tt> or <tt>PacketListener</tt>.
|
specific packets will be delivered to a <tt>PacketCollector</tt> or <tt>PacketListener</tt>.
|
||||||
|
@ -42,7 +42,7 @@ listener:<p>
|
||||||
<font color="gray"><i>// user. We use an AndFilter to combine two other filters.</i></font>
|
<font color="gray"><i>// user. We use an AndFilter to combine two other filters.</i></font>
|
||||||
PacketFilter filter = new AndFilter(new PacketTypeFilter(<b>Message.class</b>),
|
PacketFilter filter = new AndFilter(new PacketTypeFilter(<b>Message.class</b>),
|
||||||
new FromContainsFilter(<font color="green">"mary@jivesoftware.com"</font>));
|
new FromContainsFilter(<font color="green">"mary@jivesoftware.com"</font>));
|
||||||
<font color="gray"><i>// Assume we've created a Connection name "connection".</i></font>
|
<font color="gray"><i>// Assume we've created a XMPPConnection name "connection".</i></font>
|
||||||
|
|
||||||
<font color="gray"><i>// First, register a packet collector using the filter we created.</i></font>
|
<font color="gray"><i>// First, register a packet collector using the filter we created.</i></font>
|
||||||
PacketCollector myCollector = connection.createPacketCollector(filter);
|
PacketCollector myCollector = connection.createPacketCollector(filter);
|
||||||
|
|
|
@ -21,7 +21,7 @@ A roster also allows you to organize users into groups such as "Friends" and
|
||||||
"Co-workers". Other IM systems refer to the roster as the buddy list, contact list,
|
"Co-workers". Other IM systems refer to the roster as the buddy list, contact list,
|
||||||
etc.<p>
|
etc.<p>
|
||||||
|
|
||||||
A <tt>Roster</tt> instance is obtained using the <tt>Connection.getRoster()</tt>
|
A <tt>Roster</tt> instance is obtained using the <tt>XMPPConnection.getRoster()</tt>
|
||||||
method.
|
method.
|
||||||
|
|
||||||
<p class="subheader">Roster Entries</p>
|
<p class="subheader">Roster Entries</p>
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
|
@ -44,12 +44,12 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
*/
|
*/
|
||||||
public class CarbonManager extends Manager {
|
public class CarbonManager extends Manager {
|
||||||
|
|
||||||
private static Map<Connection, CarbonManager> instances =
|
private static Map<XMPPConnection, CarbonManager> instances =
|
||||||
Collections.synchronizedMap(new WeakHashMap<Connection, CarbonManager>());
|
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, CarbonManager>());
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
getInstanceFor(connection);
|
getInstanceFor(connection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -57,7 +57,7 @@ public class CarbonManager extends Manager {
|
||||||
|
|
||||||
private volatile boolean enabled_state = false;
|
private volatile boolean enabled_state = false;
|
||||||
|
|
||||||
private CarbonManager(Connection connection) {
|
private CarbonManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
sdm.addFeature(CarbonExtension.NAMESPACE);
|
sdm.addFeature(CarbonExtension.NAMESPACE);
|
||||||
|
@ -71,7 +71,7 @@ public class CarbonManager extends Manager {
|
||||||
*
|
*
|
||||||
* @return a CarbonManager instance
|
* @return a CarbonManager instance
|
||||||
*/
|
*/
|
||||||
public static synchronized CarbonManager getInstanceFor(Connection connection) {
|
public static synchronized CarbonManager getInstanceFor(XMPPConnection connection) {
|
||||||
CarbonManager carbonManager = instances.get(connection);
|
CarbonManager carbonManager = instances.get(connection);
|
||||||
|
|
||||||
if (carbonManager == null) {
|
if (carbonManager == null) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class CompressionTest extends SmackTestCase {
|
||||||
// Login with the test account
|
// Login with the test account
|
||||||
connection.login("user0", "user0");
|
connection.login("user0", "user0");
|
||||||
|
|
||||||
assertTrue("Connection is not using stream compression", connection.isUsingCompression());
|
assertTrue("XMPPConnection is not using stream compression", connection.isUsingCompression());
|
||||||
|
|
||||||
// Request the version of the server
|
// Request the version of the server
|
||||||
Version version = new Version();
|
Version version = new Version();
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
||||||
MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc);
|
MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc);
|
||||||
|
|
||||||
Packet message1 = collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
Packet message1 = collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection 1 never received the message", message1);
|
assertNotNull("XMPPConnection 1 never received the message", message1);
|
||||||
MultipleRecipientInfo info1 = MultipleRecipientManager.getMultipleRecipientInfo(message1);
|
MultipleRecipientInfo info1 = MultipleRecipientManager.getMultipleRecipientInfo(message1);
|
||||||
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info1);
|
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info1);
|
||||||
assertFalse("Message 1 should be 'replyable'", info1.shouldNotReply());
|
assertFalse("Message 1 should be 'replyable'", info1.shouldNotReply());
|
||||||
|
@ -74,7 +74,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
||||||
assertEquals("Incorrect CC address", getBareJID(2), address1);
|
assertEquals("Incorrect CC address", getBareJID(2), address1);
|
||||||
|
|
||||||
Packet message2 = collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
Packet message2 = collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection 2 never received the message", message2);
|
assertNotNull("XMPPConnection 2 never received the message", message2);
|
||||||
MultipleRecipientInfo info2 = MultipleRecipientManager.getMultipleRecipientInfo(message2);
|
MultipleRecipientInfo info2 = MultipleRecipientManager.getMultipleRecipientInfo(message2);
|
||||||
assertNotNull("Message 2 does not contain MultipleRecipientInfo", info2);
|
assertNotNull("Message 2 does not contain MultipleRecipientInfo", info2);
|
||||||
assertFalse("Message 2 should be 'replyable'", info2.shouldNotReply());
|
assertFalse("Message 2 should be 'replyable'", info2.shouldNotReply());
|
||||||
|
@ -88,7 +88,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
||||||
assertEquals("Incorrect CC address", getBareJID(2), address2);
|
assertEquals("Incorrect CC address", getBareJID(2), address2);
|
||||||
|
|
||||||
Packet message3 = collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
Packet message3 = collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection 3 never received the message", message3);
|
assertNotNull("XMPPConnection 3 never received the message", message3);
|
||||||
MultipleRecipientInfo info3 = MultipleRecipientManager.getMultipleRecipientInfo(message3);
|
MultipleRecipientInfo info3 = MultipleRecipientManager.getMultipleRecipientInfo(message3);
|
||||||
assertNotNull("Message 3 does not contain MultipleRecipientInfo", info3);
|
assertNotNull("Message 3 does not contain MultipleRecipientInfo", info3);
|
||||||
assertFalse("Message 3 should be 'replyable'", info3.shouldNotReply());
|
assertFalse("Message 3 should be 'replyable'", info3.shouldNotReply());
|
||||||
|
@ -130,7 +130,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
||||||
// Get the message and ensure it's ok
|
// Get the message and ensure it's ok
|
||||||
Message message1 =
|
Message message1 =
|
||||||
(Message) collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
(Message) collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection 1 never received the message", message1);
|
assertNotNull("XMPPConnection 1 never received the message", message1);
|
||||||
MultipleRecipientInfo info = MultipleRecipientManager.getMultipleRecipientInfo(message1);
|
MultipleRecipientInfo info = MultipleRecipientManager.getMultipleRecipientInfo(message1);
|
||||||
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info);
|
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info);
|
||||||
assertFalse("Message 1 should be 'replyable'", info.shouldNotReply());
|
assertFalse("Message 1 should be 'replyable'", info.shouldNotReply());
|
||||||
|
@ -144,7 +144,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
||||||
|
|
||||||
// Get the reply and ensure it's ok
|
// Get the reply and ensure it's ok
|
||||||
reply1 = (Message) collector0.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
reply1 = (Message) collector0.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection 0 never received the reply", reply1);
|
assertNotNull("XMPPConnection 0 never received the reply", reply1);
|
||||||
info = MultipleRecipientManager.getMultipleRecipientInfo(reply1);
|
info = MultipleRecipientManager.getMultipleRecipientInfo(reply1);
|
||||||
assertNotNull("Replied message does not contain MultipleRecipientInfo", info);
|
assertNotNull("Replied message does not contain MultipleRecipientInfo", info);
|
||||||
assertFalse("Replied message should be 'replyable'", info.shouldNotReply());
|
assertFalse("Replied message should be 'replyable'", info.shouldNotReply());
|
||||||
|
@ -159,7 +159,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
||||||
|
|
||||||
// Get the reply and ensure it's ok
|
// Get the reply and ensure it's ok
|
||||||
reply2 = (Message) collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
reply2 = (Message) collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection 1 never received the reply", reply2);
|
assertNotNull("XMPPConnection 1 never received the reply", reply2);
|
||||||
info = MultipleRecipientManager.getMultipleRecipientInfo(reply2);
|
info = MultipleRecipientManager.getMultipleRecipientInfo(reply2);
|
||||||
assertNotNull("Replied message does not contain MultipleRecipientInfo", info);
|
assertNotNull("Replied message does not contain MultipleRecipientInfo", info);
|
||||||
assertFalse("Replied message should be 'replyable'", info.shouldNotReply());
|
assertFalse("Replied message should be 'replyable'", info.shouldNotReply());
|
||||||
|
@ -168,19 +168,19 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
||||||
|
|
||||||
// Check that connection2 recevied 3 messages
|
// Check that connection2 recevied 3 messages
|
||||||
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection2 didn't receive the 1 message", message1);
|
assertNotNull("XMPPConnection2 didn't receive the 1 message", message1);
|
||||||
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection2 didn't receive the 2 message", message1);
|
assertNotNull("XMPPConnection2 didn't receive the 2 message", message1);
|
||||||
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection2 didn't receive the 3 message", message1);
|
assertNotNull("XMPPConnection2 didn't receive the 3 message", message1);
|
||||||
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNull("Connection2 received 4 messages", message1);
|
assertNull("XMPPConnection2 received 4 messages", message1);
|
||||||
|
|
||||||
// Check that connection3 recevied only 1 message (was BCC in the first message)
|
// Check that connection3 recevied only 1 message (was BCC in the first message)
|
||||||
message1 = (Message) collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
message1 = (Message) collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection3 didn't receive the 1 message", message1);
|
assertNotNull("XMPPConnection3 didn't receive the 1 message", message1);
|
||||||
message1 = (Message) collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
message1 = (Message) collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNull("Connection2 received 2 messages", message1);
|
assertNull("XMPPConnection2 received 2 messages", message1);
|
||||||
|
|
||||||
collector0.cancel();
|
collector0.cancel();
|
||||||
collector1.cancel();
|
collector1.cancel();
|
||||||
|
@ -210,7 +210,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
||||||
// Get the message and ensure it's ok
|
// Get the message and ensure it's ok
|
||||||
Message message1 =
|
Message message1 =
|
||||||
(Message) collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
(Message) collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection 1 never received the message", message1);
|
assertNotNull("XMPPConnection 1 never received the message", message1);
|
||||||
MultipleRecipientInfo info = MultipleRecipientManager.getMultipleRecipientInfo(message1);
|
MultipleRecipientInfo info = MultipleRecipientManager.getMultipleRecipientInfo(message1);
|
||||||
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info);
|
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info);
|
||||||
assertTrue("Message 1 should be not 'replyable'", info.shouldNotReply());
|
assertTrue("Message 1 should be not 'replyable'", info.shouldNotReply());
|
||||||
|
@ -230,15 +230,15 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
||||||
|
|
||||||
// Check that connection2 recevied 1 messages
|
// Check that connection2 recevied 1 messages
|
||||||
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection2 didn't receive the 1 message", message1);
|
assertNotNull("XMPPConnection2 didn't receive the 1 message", message1);
|
||||||
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
message1 = (Message) collector2.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNull("Connection2 received 2 messages", message1);
|
assertNull("XMPPConnection2 received 2 messages", message1);
|
||||||
|
|
||||||
// Check that connection3 recevied only 1 message (was BCC in the first message)
|
// Check that connection3 recevied only 1 message (was BCC in the first message)
|
||||||
message1 = (Message) collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
message1 = (Message) collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNotNull("Connection3 didn't receive the 1 message", message1);
|
assertNotNull("XMPPConnection3 didn't receive the 1 message", message1);
|
||||||
message1 = (Message) collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
message1 = (Message) collector3.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||||
assertNull("Connection2 received 2 messages", message1);
|
assertNull("XMPPConnection2 received 2 messages", message1);
|
||||||
|
|
||||||
collector1.cancel();
|
collector1.cancel();
|
||||||
collector2.cancel();
|
collector2.cancel();
|
||||||
|
|
|
@ -18,7 +18,7 @@ import java.io.OutputStream;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.SynchronousQueue;
|
import java.util.concurrent.SynchronousQueue;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.PacketCollector;
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||||
|
@ -53,9 +53,9 @@ public class InBandBytestreamTest extends SmackTestCase {
|
||||||
* @throws XMPPException should not happen
|
* @throws XMPPException should not happen
|
||||||
*/
|
*/
|
||||||
public void testRespondWithErrorOnInBandBytestreamRequest() throws XMPPException {
|
public void testRespondWithErrorOnInBandBytestreamRequest() throws XMPPException {
|
||||||
Connection targetConnection = getConnection(0);
|
XMPPConnection targetConnection = getConnection(0);
|
||||||
|
|
||||||
Connection initiatorConnection = getConnection(1);
|
XMPPConnection initiatorConnection = getConnection(1);
|
||||||
|
|
||||||
Open open = new Open("sessionID", 1024);
|
Open open = new Open("sessionID", 1024);
|
||||||
open.setFrom(initiatorConnection.getUser());
|
open.setFrom(initiatorConnection.getUser());
|
||||||
|
@ -78,8 +78,8 @@ public class InBandBytestreamTest extends SmackTestCase {
|
||||||
*/
|
*/
|
||||||
public void testInBandBytestreamWithIQStanzas() throws Exception {
|
public void testInBandBytestreamWithIQStanzas() throws Exception {
|
||||||
|
|
||||||
Connection initiatorConnection = getConnection(0);
|
XMPPConnection initiatorConnection = getConnection(0);
|
||||||
Connection targetConnection = getConnection(1);
|
XMPPConnection targetConnection = getConnection(1);
|
||||||
|
|
||||||
// test data
|
// test data
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
|
@ -132,8 +132,8 @@ public class InBandBytestreamTest extends SmackTestCase {
|
||||||
*/
|
*/
|
||||||
public void testInBandBytestreamWithMessageStanzas() throws Exception {
|
public void testInBandBytestreamWithMessageStanzas() throws Exception {
|
||||||
|
|
||||||
Connection initiatorConnection = getConnection(0);
|
XMPPConnection initiatorConnection = getConnection(0);
|
||||||
Connection targetConnection = getConnection(1);
|
XMPPConnection targetConnection = getConnection(1);
|
||||||
|
|
||||||
// test data
|
// test data
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
|
@ -188,9 +188,9 @@ public class InBandBytestreamTest extends SmackTestCase {
|
||||||
*/
|
*/
|
||||||
public void testBiDirectionalInBandBytestream() throws Exception {
|
public void testBiDirectionalInBandBytestream() throws Exception {
|
||||||
|
|
||||||
Connection initiatorConnection = getConnection(0);
|
XMPPConnection initiatorConnection = getConnection(0);
|
||||||
|
|
||||||
Connection targetConnection = getConnection(1);
|
XMPPConnection targetConnection = getConnection(1);
|
||||||
|
|
||||||
// test data
|
// test data
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.concurrent.SynchronousQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.PacketCollector;
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
import org.jivesoftware.smack.SmackConfiguration;
|
import org.jivesoftware.smack.SmackConfiguration;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
@ -60,7 +60,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
||||||
* @throws XMPPException should not happen
|
* @throws XMPPException should not happen
|
||||||
*/
|
*/
|
||||||
public void testInitializationSocks5FeaturesAndListenerOnStartup() throws XMPPException {
|
public void testInitializationSocks5FeaturesAndListenerOnStartup() throws XMPPException {
|
||||||
Connection connection = getConnection(0);
|
XMPPConnection connection = getConnection(0);
|
||||||
|
|
||||||
assertTrue(ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(
|
assertTrue(ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(
|
||||||
Socks5BytestreamManager.NAMESPACE));
|
Socks5BytestreamManager.NAMESPACE));
|
||||||
|
@ -74,9 +74,9 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
||||||
* @throws XMPPException should not happen
|
* @throws XMPPException should not happen
|
||||||
*/
|
*/
|
||||||
public void testRespondWithErrorOnSocks5BytestreamRequest() throws XMPPException {
|
public void testRespondWithErrorOnSocks5BytestreamRequest() throws XMPPException {
|
||||||
Connection targetConnection = getConnection(0);
|
XMPPConnection targetConnection = getConnection(0);
|
||||||
|
|
||||||
Connection initiatorConnection = getConnection(1);
|
XMPPConnection initiatorConnection = getConnection(1);
|
||||||
|
|
||||||
Bytestream bytestreamInitiation = Socks5PacketUtils.createBytestreamInitiation(
|
Bytestream bytestreamInitiation = Socks5PacketUtils.createBytestreamInitiation(
|
||||||
initiatorConnection.getUser(), targetConnection.getUser(), "session_id");
|
initiatorConnection.getUser(), targetConnection.getUser(), "session_id");
|
||||||
|
@ -107,8 +107,8 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
||||||
|
|
||||||
assertTrue(socks5Proxy.isRunning());
|
assertTrue(socks5Proxy.isRunning());
|
||||||
|
|
||||||
Connection initiatorConnection = getConnection(0);
|
XMPPConnection initiatorConnection = getConnection(0);
|
||||||
Connection targetConnection = getConnection(1);
|
XMPPConnection targetConnection = getConnection(1);
|
||||||
|
|
||||||
// test data
|
// test data
|
||||||
final byte[] data = new byte[] { 1, 2, 3 };
|
final byte[] data = new byte[] { 1, 2, 3 };
|
||||||
|
@ -174,8 +174,8 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
||||||
|
|
||||||
assertFalse(Socks5Proxy.getSocks5Proxy().isRunning());
|
assertFalse(Socks5Proxy.getSocks5Proxy().isRunning());
|
||||||
|
|
||||||
Connection initiatorConnection = getConnection(0);
|
XMPPConnection initiatorConnection = getConnection(0);
|
||||||
Connection targetConnection = getConnection(1);
|
XMPPConnection targetConnection = getConnection(1);
|
||||||
|
|
||||||
// test data
|
// test data
|
||||||
final byte[] data = new byte[] { 1, 2, 3 };
|
final byte[] data = new byte[] { 1, 2, 3 };
|
||||||
|
@ -243,7 +243,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
||||||
*/
|
*/
|
||||||
public void testBiDirectionalSocks5BytestreamWithRemoteSocks5Proxy() throws Exception {
|
public void testBiDirectionalSocks5BytestreamWithRemoteSocks5Proxy() throws Exception {
|
||||||
|
|
||||||
Connection initiatorConnection = getConnection(0);
|
XMPPConnection initiatorConnection = getConnection(0);
|
||||||
|
|
||||||
// disable local socks5 proxy
|
// disable local socks5 proxy
|
||||||
SmackConfiguration.setLocalSocks5ProxyEnabled(false);
|
SmackConfiguration.setLocalSocks5ProxyEnabled(false);
|
||||||
|
@ -251,7 +251,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
||||||
|
|
||||||
assertFalse(Socks5Proxy.getSocks5Proxy().isRunning());
|
assertFalse(Socks5Proxy.getSocks5Proxy().isRunning());
|
||||||
|
|
||||||
Connection targetConnection = getConnection(1);
|
XMPPConnection targetConnection = getConnection(1);
|
||||||
|
|
||||||
// test data
|
// test data
|
||||||
final byte[] data = new byte[] { 1, 2, 3 };
|
final byte[] data = new byte[] { 1, 2, 3 };
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.TimeZone;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Chat;
|
import org.jivesoftware.smack.Chat;
|
||||||
import org.jivesoftware.smack.ChatManagerListener;
|
import org.jivesoftware.smack.ChatManagerListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionConfiguration;
|
import org.jivesoftware.smack.ConnectionConfiguration;
|
||||||
import org.jivesoftware.smack.PacketCollector;
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
import org.jivesoftware.smack.SmackConfiguration;
|
import org.jivesoftware.smack.SmackConfiguration;
|
||||||
|
@ -263,7 +263,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
// User3 is listening to MUC invitations
|
// User3 is listening to MUC invitations
|
||||||
MultiUserChat.addInvitationListener(getConnection(2), new InvitationListener() {
|
MultiUserChat.addInvitationListener(getConnection(2), new InvitationListener() {
|
||||||
public void invitationReceived(
|
public void invitationReceived(
|
||||||
Connection conn,
|
XMPPConnection conn,
|
||||||
String room,
|
String room,
|
||||||
String inviter,
|
String inviter,
|
||||||
String reason,
|
String reason,
|
||||||
|
@ -313,7 +313,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
||||||
// User3 is listening to MUC invitations
|
// User3 is listening to MUC invitations
|
||||||
MultiUserChat.addInvitationListener(getConnection(2), new InvitationListener() {
|
MultiUserChat.addInvitationListener(getConnection(2), new InvitationListener() {
|
||||||
public void invitationReceived(
|
public void invitationReceived(
|
||||||
Connection conn,
|
XMPPConnection conn,
|
||||||
String room,
|
String room,
|
||||||
String inviter,
|
String inviter,
|
||||||
String reason,
|
String reason,
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class MultipleRecipientInfo {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the received packet should not be replied. Use
|
* Returns true if the received packet should not be replied. Use
|
||||||
* {@link MultipleRecipientManager#reply(org.jivesoftware.smack.Connection, org.jivesoftware.smack.packet.Message, org.jivesoftware.smack.packet.Message)}
|
* {@link MultipleRecipientManager#reply(org.jivesoftware.smack.XMPPConnection, org.jivesoftware.smack.packet.Message, org.jivesoftware.smack.packet.Message)}
|
||||||
* to send replies.
|
* to send replies.
|
||||||
*
|
*
|
||||||
* @return true if the received packet should not be replied.
|
* @return true if the received packet should not be replied.
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.address;
|
package org.jivesoftware.smackx.address;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
|
@ -68,7 +68,7 @@ public class MultipleRecipientManager {
|
||||||
* @throws XMPPException if server does not support JEP-33: Extended Stanza Addressing and
|
* @throws XMPPException if server does not support JEP-33: Extended Stanza Addressing and
|
||||||
* some JEP-33 specific features were requested.
|
* some JEP-33 specific features were requested.
|
||||||
*/
|
*/
|
||||||
public static void send(Connection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc)
|
public static void send(XMPPConnection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc)
|
||||||
throws XMPPException {
|
throws XMPPException {
|
||||||
send(connection, packet, to, cc, bcc, null, null, false);
|
send(connection, packet, to, cc, bcc, null, null, false);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class MultipleRecipientManager {
|
||||||
* @throws XMPPException if server does not support JEP-33: Extended Stanza Addressing and
|
* @throws XMPPException if server does not support JEP-33: Extended Stanza Addressing and
|
||||||
* some JEP-33 specific features were requested.
|
* some JEP-33 specific features were requested.
|
||||||
*/
|
*/
|
||||||
public static void send(Connection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc,
|
public static void send(XMPPConnection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc,
|
||||||
String replyTo, String replyRoom, boolean noReply) throws XMPPException {
|
String replyTo, String replyRoom, boolean noReply) throws XMPPException {
|
||||||
String serviceAddress = getMultipleRecipienServiceAddress(connection);
|
String serviceAddress = getMultipleRecipienServiceAddress(connection);
|
||||||
if (serviceAddress != null) {
|
if (serviceAddress != null) {
|
||||||
|
@ -128,7 +128,7 @@ public class MultipleRecipientManager {
|
||||||
* @throws XMPPException if the original message was not sent to multiple recipients, or the
|
* @throws XMPPException if the original message was not sent to multiple recipients, or the
|
||||||
* original message cannot be replied or reply should be sent to a room.
|
* original message cannot be replied or reply should be sent to a room.
|
||||||
*/
|
*/
|
||||||
public static void reply(Connection connection, Message original, Message reply)
|
public static void reply(XMPPConnection connection, Message original, Message reply)
|
||||||
throws XMPPException {
|
throws XMPPException {
|
||||||
MultipleRecipientInfo info = getMultipleRecipientInfo(original);
|
MultipleRecipientInfo info = getMultipleRecipientInfo(original);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
|
@ -202,7 +202,7 @@ public class MultipleRecipientManager {
|
||||||
return extension == null ? null : new MultipleRecipientInfo(extension);
|
return extension == null ? null : new MultipleRecipientInfo(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendToIndividualRecipients(Connection connection, Packet packet,
|
private static void sendToIndividualRecipients(XMPPConnection connection, Packet packet,
|
||||||
List<String> to, List<String> cc, List<String> bcc) {
|
List<String> to, List<String> cc, List<String> bcc) {
|
||||||
if (to != null) {
|
if (to != null) {
|
||||||
for (Iterator<String> it = to.iterator(); it.hasNext();) {
|
for (Iterator<String> it = to.iterator(); it.hasNext();) {
|
||||||
|
@ -227,7 +227,7 @@ public class MultipleRecipientManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendThroughService(Connection connection, Packet packet, List<String> to,
|
private static void sendThroughService(XMPPConnection connection, Packet packet, List<String> to,
|
||||||
List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply,
|
List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply,
|
||||||
String serviceAddress) {
|
String serviceAddress) {
|
||||||
// Create multiple recipient extension
|
// Create multiple recipient extension
|
||||||
|
@ -281,7 +281,7 @@ public class MultipleRecipientManager {
|
||||||
* queried.
|
* queried.
|
||||||
* @return the address of the multiple recipients service or <tt>null</tt> if none was found.
|
* @return the address of the multiple recipients service or <tt>null</tt> if none was found.
|
||||||
*/
|
*/
|
||||||
private static String getMultipleRecipienServiceAddress(Connection connection) {
|
private static String getMultipleRecipienServiceAddress(XMPPConnection connection) {
|
||||||
String serviceName = connection.getServiceName();
|
String serviceName = connection.getServiceName();
|
||||||
String serviceAddress = (String) services.get(serviceName);
|
String serviceAddress = (String) services.get(serviceName);
|
||||||
if (serviceAddress == null) {
|
if (serviceAddress == null) {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.amp;
|
package org.jivesoftware.smackx.amp;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
|
||||||
public class AMPDeliverCondition implements AMPExtension.Condition {
|
public class AMPDeliverCondition implements AMPExtension.Condition {
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public class AMPDeliverCondition implements AMPExtension.Condition {
|
||||||
* @param connection Smack connection instance
|
* @param connection Smack connection instance
|
||||||
* @return true if deliver condition is supported.
|
* @return true if deliver condition is supported.
|
||||||
*/
|
*/
|
||||||
public static boolean isSupported(Connection connection) {
|
public static boolean isSupported(XMPPConnection connection) {
|
||||||
return AMPManager.isConditionSupported(connection, NAME);
|
return AMPManager.isConditionSupported(connection, NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.amp;
|
package org.jivesoftware.smackx.amp;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.util.XmppDateTime;
|
import org.jivesoftware.smack.util.XmppDateTime;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -31,7 +31,7 @@ public class AMPExpireAtCondition implements AMPExtension.Condition {
|
||||||
* @param connection Smack connection instance
|
* @param connection Smack connection instance
|
||||||
* @return true if expire-at condition is supported.
|
* @return true if expire-at condition is supported.
|
||||||
*/
|
*/
|
||||||
public static boolean isSupported(Connection connection) {
|
public static boolean isSupported(XMPPConnection connection) {
|
||||||
return AMPManager.isConditionSupported(connection, NAME);
|
return AMPManager.isConditionSupported(connection, NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.amp;
|
package org.jivesoftware.smackx.amp;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
|
@ -38,8 +38,8 @@ public class AMPManager {
|
||||||
// Enable the AMP support on every established connection
|
// Enable the AMP support on every established connection
|
||||||
// The ServiceDiscoveryManager class should have been already initialized
|
// The ServiceDiscoveryManager class should have been already initialized
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
AMPManager.setServiceEnabled(connection, true);
|
AMPManager.setServiceEnabled(connection, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -54,7 +54,7 @@ public class AMPManager {
|
||||||
* @param connection the connection where the service will be enabled or disabled
|
* @param connection the connection where the service will be enabled or disabled
|
||||||
* @param enabled indicates if the service will be enabled or disabled
|
* @param enabled indicates if the service will be enabled or disabled
|
||||||
*/
|
*/
|
||||||
public synchronized static void setServiceEnabled(Connection connection, boolean enabled) {
|
public synchronized static void setServiceEnabled(XMPPConnection connection, boolean enabled) {
|
||||||
if (isServiceEnabled(connection) == enabled)
|
if (isServiceEnabled(connection) == enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ public class AMPManager {
|
||||||
* @param connection the connection to look for AMP support
|
* @param connection the connection to look for AMP support
|
||||||
* @return a boolean indicating if the AMP support is enabled for the given connection
|
* @return a boolean indicating if the AMP support is enabled for the given connection
|
||||||
*/
|
*/
|
||||||
public static boolean isServiceEnabled(Connection connection) {
|
public static boolean isServiceEnabled(XMPPConnection connection) {
|
||||||
connection.getServiceName();
|
connection.getServiceName();
|
||||||
return ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(AMPExtension.NAMESPACE);
|
return ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(AMPExtension.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ public class AMPManager {
|
||||||
* @param action action to check
|
* @param action action to check
|
||||||
* @return true if this action is supported.
|
* @return true if this action is supported.
|
||||||
*/
|
*/
|
||||||
public static boolean isActionSupported(Connection connection, AMPExtension.Action action) {
|
public static boolean isActionSupported(XMPPConnection connection, AMPExtension.Action action) {
|
||||||
String featureName = AMPExtension.NAMESPACE + "?action=" + action.toString();
|
String featureName = AMPExtension.NAMESPACE + "?action=" + action.toString();
|
||||||
return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE);
|
return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
@ -97,12 +97,12 @@ public class AMPManager {
|
||||||
* @see AMPExpireAtCondition
|
* @see AMPExpireAtCondition
|
||||||
* @see AMPMatchResourceCondition
|
* @see AMPMatchResourceCondition
|
||||||
*/
|
*/
|
||||||
public static boolean isConditionSupported(Connection connection, String conditionName) {
|
public static boolean isConditionSupported(XMPPConnection connection, String conditionName) {
|
||||||
String featureName = AMPExtension.NAMESPACE + "?condition=" + conditionName;
|
String featureName = AMPExtension.NAMESPACE + "?condition=" + conditionName;
|
||||||
return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE);
|
return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isFeatureSupportedByServer(Connection connection, String featureName, String node) {
|
private static boolean isFeatureSupportedByServer(XMPPConnection connection, String featureName, String node) {
|
||||||
try {
|
try {
|
||||||
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
DiscoverInfo info = discoveryManager.discoverInfo(connection.getServiceName(), node);
|
DiscoverInfo info = discoveryManager.discoverInfo(connection.getServiceName(), node);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.amp;
|
package org.jivesoftware.smackx.amp;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
|
||||||
public class AMPMatchResourceCondition implements AMPExtension.Condition {
|
public class AMPMatchResourceCondition implements AMPExtension.Condition {
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public class AMPMatchResourceCondition implements AMPExtension.Condition {
|
||||||
* @param connection Smack connection instance
|
* @param connection Smack connection instance
|
||||||
* @return true if match-resource condition is supported.
|
* @return true if match-resource condition is supported.
|
||||||
*/
|
*/
|
||||||
public static boolean isSupported(Connection connection) {
|
public static boolean isSupported(XMPPConnection connection) {
|
||||||
return AMPManager.isConditionSupported(connection, NAME);
|
return AMPManager.isConditionSupported(connection, NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.bookmarks;
|
package org.jivesoftware.smackx.bookmarks;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smackx.iqprivate.PrivateDataManager;
|
import org.jivesoftware.smackx.iqprivate.PrivateDataManager;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import java.util.*;
|
||||||
* @author Alexander Wenckus
|
* @author Alexander Wenckus
|
||||||
*/
|
*/
|
||||||
public class BookmarkManager {
|
public class BookmarkManager {
|
||||||
private static final Map<Connection, BookmarkManager> bookmarkManagerMap = new HashMap<Connection, BookmarkManager>();
|
private static final Map<XMPPConnection, BookmarkManager> bookmarkManagerMap = new HashMap<XMPPConnection, BookmarkManager>();
|
||||||
static {
|
static {
|
||||||
PrivateDataManager.addPrivateDataProvider("storage", "storage:bookmarks",
|
PrivateDataManager.addPrivateDataProvider("storage", "storage:bookmarks",
|
||||||
new Bookmarks.Provider());
|
new Bookmarks.Provider());
|
||||||
|
@ -48,7 +48,7 @@ public class BookmarkManager {
|
||||||
* exist it is created.
|
* exist it is created.
|
||||||
* @throws XMPPException Thrown if the connection is null or has not yet been authenticated.
|
* @throws XMPPException Thrown if the connection is null or has not yet been authenticated.
|
||||||
*/
|
*/
|
||||||
public synchronized static BookmarkManager getBookmarkManager(Connection connection)
|
public synchronized static BookmarkManager getBookmarkManager(XMPPConnection connection)
|
||||||
throws XMPPException
|
throws XMPPException
|
||||||
{
|
{
|
||||||
BookmarkManager manager = (BookmarkManager) bookmarkManagerMap.get(connection);
|
BookmarkManager manager = (BookmarkManager) bookmarkManagerMap.get(connection);
|
||||||
|
@ -70,7 +70,7 @@ public class BookmarkManager {
|
||||||
* @param connection the connection for persisting and retrieving bookmarks.
|
* @param connection the connection for persisting and retrieving bookmarks.
|
||||||
* @throws XMPPException thrown when the connection is null or has not been authenticated.
|
* @throws XMPPException thrown when the connection is null or has not been authenticated.
|
||||||
*/
|
*/
|
||||||
private BookmarkManager(Connection connection) throws XMPPException {
|
private BookmarkManager(XMPPConnection connection) throws XMPPException {
|
||||||
if(connection == null || !connection.isAuthenticated()) {
|
if(connection == null || !connection.isAuthenticated()) {
|
||||||
throw new XMPPException("Invalid connection.");
|
throw new XMPPException("Invalid connection.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.util.List;
|
||||||
* See the following code sample for saving Bookmarks:
|
* See the following code sample for saving Bookmarks:
|
||||||
* <p/>
|
* <p/>
|
||||||
* <pre>
|
* <pre>
|
||||||
* Connection con = new TCPConnection("jabber.org");
|
* XMPPConnection con = new TCPConnection("jabber.org");
|
||||||
* con.login("john", "doe");
|
* con.login("john", "doe");
|
||||||
* Bookmarks bookmarks = new Bookmarks();
|
* Bookmarks bookmarks = new Bookmarks();
|
||||||
* <p/>
|
* <p/>
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Random;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
@ -96,8 +96,8 @@ public class InBandBytestreamManager implements BytestreamManager {
|
||||||
* connection
|
* connection
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(final Connection connection) {
|
public void connectionCreated(final XMPPConnection connection) {
|
||||||
// create the manager for this connection
|
// create the manager for this connection
|
||||||
InBandBytestreamManager.getByteStreamManager(connection);
|
InBandBytestreamManager.getByteStreamManager(connection);
|
||||||
|
|
||||||
|
@ -143,10 +143,10 @@ public class InBandBytestreamManager implements BytestreamManager {
|
||||||
private final static Random randomGenerator = new Random();
|
private final static Random randomGenerator = new Random();
|
||||||
|
|
||||||
/* stores one InBandBytestreamManager for each XMPP connection */
|
/* stores one InBandBytestreamManager for each XMPP connection */
|
||||||
private final static Map<Connection, InBandBytestreamManager> managers = new HashMap<Connection, InBandBytestreamManager>();
|
private final static Map<XMPPConnection, InBandBytestreamManager> managers = new HashMap<XMPPConnection, InBandBytestreamManager>();
|
||||||
|
|
||||||
/* XMPP connection */
|
/* XMPP connection */
|
||||||
private final Connection connection;
|
private final XMPPConnection connection;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* assigns a user to a listener that is informed if an In-Band Bytestream request for this user
|
* assigns a user to a listener that is informed if an In-Band Bytestream request for this user
|
||||||
|
@ -189,12 +189,12 @@ public class InBandBytestreamManager implements BytestreamManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the InBandBytestreamManager to handle In-Band Bytestreams for a given
|
* Returns the InBandBytestreamManager to handle In-Band Bytestreams for a given
|
||||||
* {@link Connection}.
|
* {@link XMPPConnection}.
|
||||||
*
|
*
|
||||||
* @param connection the XMPP connection
|
* @param connection the XMPP connection
|
||||||
* @return the InBandBytestreamManager for the given XMPP connection
|
* @return the InBandBytestreamManager for the given XMPP connection
|
||||||
*/
|
*/
|
||||||
public static synchronized InBandBytestreamManager getByteStreamManager(Connection connection) {
|
public static synchronized InBandBytestreamManager getByteStreamManager(XMPPConnection connection) {
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
return null;
|
return null;
|
||||||
InBandBytestreamManager manager = managers.get(connection);
|
InBandBytestreamManager manager = managers.get(connection);
|
||||||
|
@ -210,7 +210,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
||||||
*
|
*
|
||||||
* @param connection the XMPP connection
|
* @param connection the XMPP connection
|
||||||
*/
|
*/
|
||||||
private InBandBytestreamManager(Connection connection) {
|
private InBandBytestreamManager(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
|
||||||
// register bytestream open packet listener
|
// register bytestream open packet listener
|
||||||
|
@ -489,7 +489,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
||||||
*
|
*
|
||||||
* @return the XMPP connection
|
* @return the XMPP connection
|
||||||
*/
|
*/
|
||||||
protected Connection getConnection() {
|
protected XMPPConnection getConnection() {
|
||||||
return this.connection;
|
return this.connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.bytestreams.ibb;
|
package org.jivesoftware.smackx.bytestreams.ibb;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
||||||
|
@ -70,7 +70,7 @@ public class InBandBytestreamRequest implements BytestreamRequest {
|
||||||
* @throws XMPPException if stream is invalid.
|
* @throws XMPPException if stream is invalid.
|
||||||
*/
|
*/
|
||||||
public InBandBytestreamSession accept() throws XMPPException {
|
public InBandBytestreamSession accept() throws XMPPException {
|
||||||
Connection connection = this.manager.getConnection();
|
XMPPConnection connection = this.manager.getConnection();
|
||||||
|
|
||||||
// create In-Band Bytestream session and store it
|
// create In-Band Bytestream session and store it
|
||||||
InBandBytestreamSession ibbSession = new InBandBytestreamSession(connection,
|
InBandBytestreamSession ibbSession = new InBandBytestreamSession(connection,
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.filter.AndFilter;
|
import org.jivesoftware.smack.filter.AndFilter;
|
||||||
|
@ -58,7 +58,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||||
public class InBandBytestreamSession implements BytestreamSession {
|
public class InBandBytestreamSession implements BytestreamSession {
|
||||||
|
|
||||||
/* XMPP connection */
|
/* XMPP connection */
|
||||||
private final Connection connection;
|
private final XMPPConnection connection;
|
||||||
|
|
||||||
/* the In-Band Bytestream open request for this session */
|
/* the In-Band Bytestream open request for this session */
|
||||||
private final Open byteStreamRequest;
|
private final Open byteStreamRequest;
|
||||||
|
@ -89,7 +89,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
||||||
* @param byteStreamRequest the In-Band Bytestream open request for this session
|
* @param byteStreamRequest the In-Band Bytestream open request for this session
|
||||||
* @param remoteJID JID of the remote peer
|
* @param remoteJID JID of the remote peer
|
||||||
*/
|
*/
|
||||||
protected InBandBytestreamSession(Connection connection, Open byteStreamRequest,
|
protected InBandBytestreamSession(XMPPConnection connection, Open byteStreamRequest,
|
||||||
String remoteJID) {
|
String remoteJID) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.byteStreamRequest = byteStreamRequest;
|
this.byteStreamRequest = byteStreamRequest;
|
||||||
|
|
|
@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
@ -89,9 +89,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
* connection
|
* connection
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
|
|
||||||
public void connectionCreated(final Connection connection) {
|
public void connectionCreated(final XMPPConnection connection) {
|
||||||
// create the manager for this connection
|
// create the manager for this connection
|
||||||
Socks5BytestreamManager.getBytestreamManager(connection);
|
Socks5BytestreamManager.getBytestreamManager(connection);
|
||||||
|
|
||||||
|
@ -132,10 +132,10 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
private final static Random randomGenerator = new Random();
|
private final static Random randomGenerator = new Random();
|
||||||
|
|
||||||
/* stores one Socks5BytestreamManager for each XMPP connection */
|
/* stores one Socks5BytestreamManager for each XMPP connection */
|
||||||
private final static Map<Connection, Socks5BytestreamManager> managers = new HashMap<Connection, Socks5BytestreamManager>();
|
private final static Map<XMPPConnection, Socks5BytestreamManager> managers = new HashMap<XMPPConnection, Socks5BytestreamManager>();
|
||||||
|
|
||||||
/* XMPP connection */
|
/* XMPP connection */
|
||||||
private final Connection connection;
|
private final XMPPConnection connection;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* assigns a user to a listener that is informed if a bytestream request for this user is
|
* assigns a user to a listener that is informed if a bytestream request for this user is
|
||||||
|
@ -175,7 +175,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Socks5BytestreamManager to handle SOCKS5 Bytestreams for a given
|
* Returns the Socks5BytestreamManager to handle SOCKS5 Bytestreams for a given
|
||||||
* {@link Connection}.
|
* {@link XMPPConnection}.
|
||||||
* <p>
|
* <p>
|
||||||
* If no manager exists a new is created and initialized.
|
* If no manager exists a new is created and initialized.
|
||||||
*
|
*
|
||||||
|
@ -183,7 +183,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
* <code>null</code>
|
* <code>null</code>
|
||||||
* @return the Socks5BytestreamManager for the given XMPP connection
|
* @return the Socks5BytestreamManager for the given XMPP connection
|
||||||
*/
|
*/
|
||||||
public static synchronized Socks5BytestreamManager getBytestreamManager(Connection connection) {
|
public static synchronized Socks5BytestreamManager getBytestreamManager(XMPPConnection connection) {
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
*
|
*
|
||||||
* @param connection the XMPP connection
|
* @param connection the XMPP connection
|
||||||
*/
|
*/
|
||||||
private Socks5BytestreamManager(Connection connection) {
|
private Socks5BytestreamManager(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.initiationListener = new InitiationListener(this);
|
this.initiationListener = new InitiationListener(this);
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
* service discovery, disabling the listener for SOCKS5 Bytestream initiation requests and
|
* service discovery, disabling the listener for SOCKS5 Bytestream initiation requests and
|
||||||
* resetting its internal state, which includes removing this instance from the managers map.
|
* resetting its internal state, which includes removing this instance from the managers map.
|
||||||
* <p>
|
* <p>
|
||||||
* To re-enable the SOCKS5 Bytestream feature invoke {@link #getBytestreamManager(Connection)}.
|
* To re-enable the SOCKS5 Bytestream feature invoke {@link #getBytestreamManager(XMPPConnection)}.
|
||||||
* Using the file transfer API will automatically re-enable the SOCKS5 Bytestream feature.
|
* Using the file transfer API will automatically re-enable the SOCKS5 Bytestream feature.
|
||||||
*/
|
*/
|
||||||
public synchronized void disableService() {
|
public synchronized void disableService() {
|
||||||
|
@ -745,7 +745,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
||||||
*
|
*
|
||||||
* @return the XMPP connection
|
* @return the XMPP connection
|
||||||
*/
|
*/
|
||||||
protected Connection getConnection() {
|
protected XMPPConnection getConnection() {
|
||||||
return this.connection;
|
return this.connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.concurrent.TimeoutException;
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||||
|
@ -37,7 +37,7 @@ import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
|
||||||
class Socks5ClientForInitiator extends Socks5Client {
|
class Socks5ClientForInitiator extends Socks5Client {
|
||||||
|
|
||||||
/* the XMPP connection used to communicate with the SOCKS5 proxy */
|
/* the XMPP connection used to communicate with the SOCKS5 proxy */
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
/* the session ID used to activate SOCKS5 stream */
|
/* the session ID used to activate SOCKS5 stream */
|
||||||
private String sessionID;
|
private String sessionID;
|
||||||
|
@ -54,7 +54,7 @@ class Socks5ClientForInitiator extends Socks5Client {
|
||||||
* @param sessionID the session ID of the SOCKS5 Bytestream
|
* @param sessionID the session ID of the SOCKS5 Bytestream
|
||||||
* @param target the target JID of the SOCKS5 Bytestream
|
* @param target the target JID of the SOCKS5 Bytestream
|
||||||
*/
|
*/
|
||||||
public Socks5ClientForInitiator(StreamHost streamHost, String digest, Connection connection,
|
public Socks5ClientForInitiator(StreamHost streamHost, String digest, XMPPConnection connection,
|
||||||
String sessionID, String target) {
|
String sessionID, String target) {
|
||||||
super(streamHost, digest);
|
super(streamHost, digest);
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
|
|
@ -452,7 +452,7 @@ public class Socks5Proxy {
|
||||||
out.write(connectionRequest);
|
out.write(connectionRequest);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
|
||||||
throw new XMPPException("Connection is not allowed");
|
throw new XMPPException("XMPPConnection is not allowed");
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionRequest[1] = (byte) 0x00; // set return status to 0 (success)
|
connectionRequest[1] = (byte) 0x00; // set return status to 0 (success)
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.caps;
|
package org.jivesoftware.smackx.caps;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
|
@ -79,8 +79,8 @@ public class EntityCapsManager extends Manager {
|
||||||
|
|
||||||
private static boolean autoEnableEntityCaps = true;
|
private static boolean autoEnableEntityCaps = true;
|
||||||
|
|
||||||
private static Map<Connection, EntityCapsManager> instances = Collections
|
private static Map<XMPPConnection, EntityCapsManager> instances = Collections
|
||||||
.synchronizedMap(new WeakHashMap<Connection, EntityCapsManager>());
|
.synchronizedMap(new WeakHashMap<XMPPConnection, EntityCapsManager>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of (node + '#" + hash algorithm) to DiscoverInfo data
|
* Map of (node + '#" + hash algorithm) to DiscoverInfo data
|
||||||
|
@ -96,8 +96,8 @@ public class EntityCapsManager extends Manager {
|
||||||
protected static Map<String, NodeVerHash> jidCaps = new Cache<String, NodeVerHash>(10000, -1);
|
protected static Map<String, NodeVerHash> jidCaps = new Cache<String, NodeVerHash>(10000, -1);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
getInstanceFor(connection);
|
getInstanceFor(connection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -219,7 +219,7 @@ public class EntityCapsManager extends Manager {
|
||||||
((Cache) caps).setMaxCacheSize(maxCacheSize);
|
((Cache) caps).setMaxCacheSize(maxCacheSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EntityCapsManager(Connection connection) {
|
private EntityCapsManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
this.sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
this.sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
instances.put(connection, this);
|
instances.put(connection, this);
|
||||||
|
@ -317,7 +317,7 @@ public class EntityCapsManager extends Manager {
|
||||||
sdm.setEntityCapsManager(this);
|
sdm.setEntityCapsManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized EntityCapsManager getInstanceFor(Connection connection) {
|
public static synchronized EntityCapsManager getInstanceFor(XMPPConnection connection) {
|
||||||
if (SUPPORTED_HASHES.size() <= 0)
|
if (SUPPORTED_HASHES.size() <= 0)
|
||||||
throw new IllegalStateException("No supported hashes for EntityCapsManager");
|
throw new IllegalStateException("No supported hashes for EntityCapsManager");
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ public class EntityCapsManager extends Manager {
|
||||||
* the local users extended info
|
* the local users extended info
|
||||||
*/
|
*/
|
||||||
public void updateLocalEntityCaps() {
|
public void updateLocalEntityCaps() {
|
||||||
Connection connection = connection();
|
XMPPConnection connection = connection();
|
||||||
|
|
||||||
DiscoverInfo discoverInfo = new DiscoverInfo();
|
DiscoverInfo discoverInfo = new DiscoverInfo();
|
||||||
discoverInfo.setType(IQ.Type.RESULT);
|
discoverInfo.setType(IQ.Type.RESULT);
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Chat;
|
import org.jivesoftware.smack.Chat;
|
||||||
import org.jivesoftware.smack.ChatManagerListener;
|
import org.jivesoftware.smack.ChatManagerListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.MessageListener;
|
import org.jivesoftware.smack.MessageListener;
|
||||||
import org.jivesoftware.smack.PacketInterceptor;
|
import org.jivesoftware.smack.PacketInterceptor;
|
||||||
|
@ -38,11 +38,11 @@ import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles chat state for all chats on a particular Connection. This class manages both the
|
* Handles chat state for all chats on a particular XMPPConnection. This class manages both the
|
||||||
* packet extensions and the disco response neccesary for compliance with
|
* packet extensions and the disco response neccesary for compliance with
|
||||||
* <a href="http://www.xmpp.org/extensions/xep-0085.html">XEP-0085</a>.
|
* <a href="http://www.xmpp.org/extensions/xep-0085.html">XEP-0085</a>.
|
||||||
*
|
*
|
||||||
* NOTE: {@link org.jivesoftware.smackx.chatstates.ChatStateManager#getInstance(org.jivesoftware.smack.Connection)}
|
* NOTE: {@link org.jivesoftware.smackx.chatstates.ChatStateManager#getInstance(org.jivesoftware.smack.XMPPConnection)}
|
||||||
* needs to be called in order for the listeners to be registered appropriately with the connection.
|
* needs to be called in order for the listeners to be registered appropriately with the connection.
|
||||||
* If this does not occur you will not receive the update notifications.
|
* If this does not occur you will not receive the update notifications.
|
||||||
*
|
*
|
||||||
|
@ -53,19 +53,19 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
public class ChatStateManager extends Manager {
|
public class ChatStateManager extends Manager {
|
||||||
public static final String NAMESPACE = "http://jabber.org/protocol/chatstates";
|
public static final String NAMESPACE = "http://jabber.org/protocol/chatstates";
|
||||||
|
|
||||||
private static final Map<Connection, ChatStateManager> INSTANCES =
|
private static final Map<XMPPConnection, ChatStateManager> INSTANCES =
|
||||||
new WeakHashMap<Connection, ChatStateManager>();
|
new WeakHashMap<XMPPConnection, ChatStateManager>();
|
||||||
|
|
||||||
private static final PacketFilter filter = new NotFilter(new PacketExtensionFilter(NAMESPACE));
|
private static final PacketFilter filter = new NotFilter(new PacketExtensionFilter(NAMESPACE));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ChatStateManager related to the Connection and it will create one if it does
|
* Returns the ChatStateManager related to the XMPPConnection and it will create one if it does
|
||||||
* not yet exist.
|
* not yet exist.
|
||||||
*
|
*
|
||||||
* @param connection the connection to return the ChatStateManager
|
* @param connection the connection to return the ChatStateManager
|
||||||
* @return the ChatStateManager related the the connection.
|
* @return the ChatStateManager related the the connection.
|
||||||
*/
|
*/
|
||||||
public static synchronized ChatStateManager getInstance(final Connection connection) {
|
public static synchronized ChatStateManager getInstance(final XMPPConnection connection) {
|
||||||
ChatStateManager manager = INSTANCES.get(connection);
|
ChatStateManager manager = INSTANCES.get(connection);
|
||||||
if (manager == null) {
|
if (manager == null) {
|
||||||
manager = new ChatStateManager(connection);
|
manager = new ChatStateManager(connection);
|
||||||
|
@ -83,7 +83,7 @@ public class ChatStateManager extends Manager {
|
||||||
private final Map<Chat, ChatState> chatStates =
|
private final Map<Chat, ChatState> chatStates =
|
||||||
new ReferenceMap<Chat, ChatState>(ReferenceMap.WEAK, ReferenceMap.HARD);
|
new ReferenceMap<Chat, ChatState>(ReferenceMap.WEAK, ReferenceMap.HARD);
|
||||||
|
|
||||||
private ChatStateManager(Connection connection) {
|
private ChatStateManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
connection.getChatManager().addOutgoingMessageInterceptor(outgoingInterceptor, filter);
|
connection.getChatManager().addOutgoingMessageInterceptor(outgoingInterceptor, filter);
|
||||||
connection.getChatManager().addChatListener(incomingInterceptor);
|
connection.getChatManager().addChatListener(incomingInterceptor);
|
||||||
|
|
|
@ -47,8 +47,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
* An AdHocCommandManager is responsible for keeping the list of available
|
* An AdHocCommandManager is responsible for keeping the list of available
|
||||||
* commands offered by a service and for processing commands requests.
|
* commands offered by a service and for processing commands requests.
|
||||||
*
|
*
|
||||||
* Pass in a Connection instance to
|
* Pass in a XMPPConnection instance to
|
||||||
* {@link #getAddHocCommandsManager(org.jivesoftware.smack.Connection)} in order to
|
* {@link #getAddHocCommandsManager(org.jivesoftware.smack.XMPPConnection)} in order to
|
||||||
* get an instance of this class.
|
* get an instance of this class.
|
||||||
*
|
*
|
||||||
* @author Gabriel Guardincerri
|
* @author Gabriel Guardincerri
|
||||||
|
@ -62,11 +62,11 @@ public class AdHocCommandManager extends Manager {
|
||||||
private static final int SESSION_TIMEOUT = 2 * 60;
|
private static final int SESSION_TIMEOUT = 2 * 60;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map a Connection with it AdHocCommandManager. This map have a key-value
|
* Map a XMPPConnection with it AdHocCommandManager. This map have a key-value
|
||||||
* pair for every active connection.
|
* pair for every active connection.
|
||||||
*/
|
*/
|
||||||
private static Map<Connection, AdHocCommandManager> instances =
|
private static Map<XMPPConnection, AdHocCommandManager> instances =
|
||||||
Collections.synchronizedMap(new WeakHashMap<Connection, AdHocCommandManager>());
|
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, AdHocCommandManager>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the listener for all the connection creations. When a new
|
* Register the listener for all the connection creations. When a new
|
||||||
|
@ -74,8 +74,8 @@ public class AdHocCommandManager extends Manager {
|
||||||
* related to that connection.
|
* related to that connection.
|
||||||
*/
|
*/
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
getAddHocCommandsManager(connection);
|
getAddHocCommandsManager(connection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -88,7 +88,7 @@ public class AdHocCommandManager extends Manager {
|
||||||
* @param connection the XMPP connection.
|
* @param connection the XMPP connection.
|
||||||
* @return the AdHocCommandManager associated with the connection.
|
* @return the AdHocCommandManager associated with the connection.
|
||||||
*/
|
*/
|
||||||
public static synchronized AdHocCommandManager getAddHocCommandsManager(Connection connection) {
|
public static synchronized AdHocCommandManager getAddHocCommandsManager(XMPPConnection connection) {
|
||||||
AdHocCommandManager ahcm = instances.get(connection);
|
AdHocCommandManager ahcm = instances.get(connection);
|
||||||
if (ahcm == null) ahcm = new AdHocCommandManager(connection);
|
if (ahcm == null) ahcm = new AdHocCommandManager(connection);
|
||||||
return ahcm;
|
return ahcm;
|
||||||
|
@ -116,7 +116,7 @@ public class AdHocCommandManager extends Manager {
|
||||||
*/
|
*/
|
||||||
private Thread sessionsSweeper;
|
private Thread sessionsSweeper;
|
||||||
|
|
||||||
private AdHocCommandManager(Connection connection) {
|
private AdHocCommandManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
this.serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
this.serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
package org.jivesoftware.smackx.commands;
|
package org.jivesoftware.smackx.commands;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackConfiguration;
|
import org.jivesoftware.smack.SmackConfiguration;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
|
import org.jivesoftware.smackx.commands.packet.AdHocCommandData;
|
||||||
|
@ -43,7 +43,7 @@ public class RemoteCommand extends AdHocCommand {
|
||||||
/**
|
/**
|
||||||
* The connection that is used to execute this command
|
* The connection that is used to execute this command
|
||||||
*/
|
*/
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The full JID of the command host
|
* The full JID of the command host
|
||||||
|
@ -71,7 +71,7 @@ public class RemoteCommand extends AdHocCommand {
|
||||||
* @param node the identifier of the command.
|
* @param node the identifier of the command.
|
||||||
* @param jid the JID of the host.
|
* @param jid the JID of the host.
|
||||||
*/
|
*/
|
||||||
protected RemoteCommand(Connection connection, String node, String jid) {
|
protected RemoteCommand(XMPPConnection connection, String node, String jid) {
|
||||||
super();
|
super();
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.jid = jid;
|
this.jid = jid;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.disco;
|
package org.jivesoftware.smackx.disco;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
|
@ -69,8 +69,8 @@ public class ServiceDiscoveryManager extends Manager {
|
||||||
|
|
||||||
private EntityCapsManager capsManager;
|
private EntityCapsManager capsManager;
|
||||||
|
|
||||||
private static Map<Connection, ServiceDiscoveryManager> instances =
|
private static Map<XMPPConnection, ServiceDiscoveryManager> instances =
|
||||||
Collections.synchronizedMap(new WeakHashMap<Connection, ServiceDiscoveryManager>());
|
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, ServiceDiscoveryManager>());
|
||||||
|
|
||||||
private final Set<String> features = new HashSet<String>();
|
private final Set<String> features = new HashSet<String>();
|
||||||
private DataForm extendedInfo = null;
|
private DataForm extendedInfo = null;
|
||||||
|
@ -79,8 +79,8 @@ public class ServiceDiscoveryManager extends Manager {
|
||||||
|
|
||||||
// Create a new ServiceDiscoveryManager on every established connection
|
// Create a new ServiceDiscoveryManager on every established connection
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
getInstanceFor(connection);
|
getInstanceFor(connection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -97,13 +97,13 @@ public class ServiceDiscoveryManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new ServiceDiscoveryManager for a given Connection. This means that the
|
* Creates a new ServiceDiscoveryManager for a given XMPPConnection. This means that the
|
||||||
* service manager will respond to any service discovery request that the connection may
|
* service manager will respond to any service discovery request that the connection may
|
||||||
* receive.
|
* receive.
|
||||||
*
|
*
|
||||||
* @param connection the connection to which a ServiceDiscoveryManager is going to be created.
|
* @param connection the connection to which a ServiceDiscoveryManager is going to be created.
|
||||||
*/
|
*/
|
||||||
private ServiceDiscoveryManager(Connection connection) {
|
private ServiceDiscoveryManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
// Register the new instance and associate it with the connection
|
// Register the new instance and associate it with the connection
|
||||||
instances.put(connection, this);
|
instances.put(connection, this);
|
||||||
|
@ -115,7 +115,7 @@ public class ServiceDiscoveryManager extends Manager {
|
||||||
PacketFilter packetFilter = new PacketTypeFilter(DiscoverItems.class);
|
PacketFilter packetFilter = new PacketTypeFilter(DiscoverItems.class);
|
||||||
PacketListener packetListener = new PacketListener() {
|
PacketListener packetListener = new PacketListener() {
|
||||||
public void processPacket(Packet packet) {
|
public void processPacket(Packet packet) {
|
||||||
Connection connection = connection();
|
XMPPConnection connection = connection();
|
||||||
if (connection == null) return;
|
if (connection == null) return;
|
||||||
DiscoverItems discoverItems = (DiscoverItems) packet;
|
DiscoverItems discoverItems = (DiscoverItems) packet;
|
||||||
// Send back the items defined in the client if the request is of type GET
|
// Send back the items defined in the client if the request is of type GET
|
||||||
|
@ -152,7 +152,7 @@ public class ServiceDiscoveryManager extends Manager {
|
||||||
packetFilter = new PacketTypeFilter(DiscoverInfo.class);
|
packetFilter = new PacketTypeFilter(DiscoverInfo.class);
|
||||||
packetListener = new PacketListener() {
|
packetListener = new PacketListener() {
|
||||||
public void processPacket(Packet packet) {
|
public void processPacket(Packet packet) {
|
||||||
Connection connection = connection();
|
XMPPConnection connection = connection();
|
||||||
if (connection == null) return;
|
if (connection == null) return;
|
||||||
DiscoverInfo discoverInfo = (DiscoverInfo) packet;
|
DiscoverInfo discoverInfo = (DiscoverInfo) packet;
|
||||||
// Answer the client's supported features if the request is of the GET type
|
// Answer the client's supported features if the request is of the GET type
|
||||||
|
@ -281,12 +281,12 @@ public class ServiceDiscoveryManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ServiceDiscoveryManager instance associated with a given Connection.
|
* Returns the ServiceDiscoveryManager instance associated with a given XMPPConnection.
|
||||||
*
|
*
|
||||||
* @param connection the connection used to look for the proper ServiceDiscoveryManager.
|
* @param connection the connection used to look for the proper ServiceDiscoveryManager.
|
||||||
* @return the ServiceDiscoveryManager associated with a given Connection.
|
* @return the ServiceDiscoveryManager associated with a given XMPPConnection.
|
||||||
*/
|
*/
|
||||||
public static synchronized ServiceDiscoveryManager getInstanceFor(Connection connection) {
|
public static synchronized ServiceDiscoveryManager getInstanceFor(XMPPConnection connection) {
|
||||||
ServiceDiscoveryManager sdm = instances.get(connection);
|
ServiceDiscoveryManager sdm = instances.get(connection);
|
||||||
if (sdm == null) {
|
if (sdm == null) {
|
||||||
sdm = new ServiceDiscoveryManager(connection);
|
sdm = new ServiceDiscoveryManager(connection);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package org.jivesoftware.smackx.filetransfer;
|
package org.jivesoftware.smackx.filetransfer;
|
||||||
|
|
||||||
import org.jivesoftware.smack.PacketCollector;
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.filter.OrFilter;
|
import org.jivesoftware.smack.filter.OrFilter;
|
||||||
import org.jivesoftware.smack.filter.PacketFilter;
|
import org.jivesoftware.smack.filter.PacketFilter;
|
||||||
|
@ -40,11 +40,11 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
||||||
|
|
||||||
private StreamNegotiator primaryNegotiator;
|
private StreamNegotiator primaryNegotiator;
|
||||||
private StreamNegotiator secondaryNegotiator;
|
private StreamNegotiator secondaryNegotiator;
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
private PacketFilter primaryFilter;
|
private PacketFilter primaryFilter;
|
||||||
private PacketFilter secondaryFilter;
|
private PacketFilter secondaryFilter;
|
||||||
|
|
||||||
public FaultTolerantNegotiator(Connection connection, StreamNegotiator primary,
|
public FaultTolerantNegotiator(XMPPConnection connection, StreamNegotiator primary,
|
||||||
StreamNegotiator secondary) {
|
StreamNegotiator secondary) {
|
||||||
this.primaryNegotiator = primary;
|
this.primaryNegotiator = primary;
|
||||||
this.secondaryNegotiator = secondary;
|
this.secondaryNegotiator = secondary;
|
||||||
|
@ -64,7 +64,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
||||||
"stream method.");
|
"stream method.");
|
||||||
}
|
}
|
||||||
|
|
||||||
final Packet initiateIncomingStream(Connection connection, StreamInitiation initiation) {
|
final Packet initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) {
|
||||||
throw new UnsupportedOperationException("Initiation handled by createIncomingStream " +
|
throw new UnsupportedOperationException("Initiation handled by createIncomingStream " +
|
||||||
"method");
|
"method");
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package org.jivesoftware.smackx.filetransfer;
|
package org.jivesoftware.smackx.filetransfer;
|
||||||
|
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.filter.AndFilter;
|
import org.jivesoftware.smack.filter.AndFilter;
|
||||||
import org.jivesoftware.smack.filter.IQTypeFilter;
|
import org.jivesoftware.smack.filter.IQTypeFilter;
|
||||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||||
|
@ -48,15 +48,15 @@ public class FileTransferManager {
|
||||||
|
|
||||||
private List<FileTransferListener> listeners;
|
private List<FileTransferListener> listeners;
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a file transfer manager to initiate and receive file transfers.
|
* Creates a file transfer manager to initiate and receive file transfers.
|
||||||
*
|
*
|
||||||
* @param connection
|
* @param connection
|
||||||
* The Connection that the file transfers will use.
|
* The XMPPConnection that the file transfers will use.
|
||||||
*/
|
*/
|
||||||
public FileTransferManager(Connection connection) {
|
public FileTransferManager(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.fileTransferNegotiator = FileTransferNegotiator
|
this.fileTransferNegotiator = FileTransferNegotiator
|
||||||
.getInstanceFor(connection);
|
.getInstanceFor(connection);
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
import org.jivesoftware.smack.PacketCollector;
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
@ -58,8 +58,8 @@ public class FileTransferNegotiator {
|
||||||
"http://jabber.org/protocol/si/profile/file-transfer",
|
"http://jabber.org/protocol/si/profile/file-transfer",
|
||||||
"http://jabber.org/protocol/si"};
|
"http://jabber.org/protocol/si"};
|
||||||
|
|
||||||
private static final Map<Connection, FileTransferNegotiator> transferObject =
|
private static final Map<XMPPConnection, FileTransferNegotiator> transferObject =
|
||||||
new ConcurrentHashMap<Connection, FileTransferNegotiator>();
|
new ConcurrentHashMap<XMPPConnection, FileTransferNegotiator>();
|
||||||
|
|
||||||
private static final String STREAM_INIT_PREFIX = "jsi_";
|
private static final String STREAM_INIT_PREFIX = "jsi_";
|
||||||
|
|
||||||
|
@ -83,9 +83,9 @@ public class FileTransferNegotiator {
|
||||||
* @return The IMFileTransferManager
|
* @return The IMFileTransferManager
|
||||||
*/
|
*/
|
||||||
public static FileTransferNegotiator getInstanceFor(
|
public static FileTransferNegotiator getInstanceFor(
|
||||||
final Connection connection) {
|
final XMPPConnection connection) {
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
throw new IllegalArgumentException("Connection cannot be null");
|
throw new IllegalArgumentException("XMPPConnection cannot be null");
|
||||||
}
|
}
|
||||||
if (!connection.isConnected()) {
|
if (!connection.isConnected()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -110,7 +110,7 @@ public class FileTransferNegotiator {
|
||||||
* @param connection The connection on which to enable or disable the services.
|
* @param connection The connection on which to enable or disable the services.
|
||||||
* @param isEnabled True to enable, false to disable.
|
* @param isEnabled True to enable, false to disable.
|
||||||
*/
|
*/
|
||||||
public static void setServiceEnabled(final Connection connection,
|
public static void setServiceEnabled(final XMPPConnection connection,
|
||||||
final boolean isEnabled) {
|
final boolean isEnabled) {
|
||||||
ServiceDiscoveryManager manager = ServiceDiscoveryManager
|
ServiceDiscoveryManager manager = ServiceDiscoveryManager
|
||||||
.getInstanceFor(connection);
|
.getInstanceFor(connection);
|
||||||
|
@ -141,7 +141,7 @@ public class FileTransferNegotiator {
|
||||||
* @param connection The connection to check
|
* @param connection The connection to check
|
||||||
* @return True if all related services are enabled, false if they are not.
|
* @return True if all related services are enabled, false if they are not.
|
||||||
*/
|
*/
|
||||||
public static boolean isServiceEnabled(final Connection connection) {
|
public static boolean isServiceEnabled(final XMPPConnection connection) {
|
||||||
ServiceDiscoveryManager manager = ServiceDiscoveryManager
|
ServiceDiscoveryManager manager = ServiceDiscoveryManager
|
||||||
.getInstanceFor(connection);
|
.getInstanceFor(connection);
|
||||||
|
|
||||||
|
@ -200,13 +200,13 @@ public class FileTransferNegotiator {
|
||||||
|
|
||||||
// non-static
|
// non-static
|
||||||
|
|
||||||
private final Connection connection;
|
private final XMPPConnection connection;
|
||||||
|
|
||||||
private final StreamNegotiator byteStreamTransferManager;
|
private final StreamNegotiator byteStreamTransferManager;
|
||||||
|
|
||||||
private final StreamNegotiator inbandTransferManager;
|
private final StreamNegotiator inbandTransferManager;
|
||||||
|
|
||||||
private FileTransferNegotiator(final Connection connection) {
|
private FileTransferNegotiator(final XMPPConnection connection) {
|
||||||
configureConnection(connection);
|
configureConnection(connection);
|
||||||
|
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
@ -214,7 +214,7 @@ public class FileTransferNegotiator {
|
||||||
inbandTransferManager = new IBBTransferNegotiator(connection);
|
inbandTransferManager = new IBBTransferNegotiator(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureConnection(final Connection connection) {
|
private void configureConnection(final XMPPConnection connection) {
|
||||||
connection.addConnectionListener(new ConnectionListener() {
|
connection.addConnectionListener(new ConnectionListener() {
|
||||||
public void connectionClosed() {
|
public void connectionClosed() {
|
||||||
cleanup(connection);
|
cleanup(connection);
|
||||||
|
@ -238,7 +238,7 @@ public class FileTransferNegotiator {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cleanup(final Connection connection) {
|
private void cleanup(final XMPPConnection connection) {
|
||||||
if (transferObject.remove(connection) != null) {
|
if (transferObject.remove(connection) != null) {
|
||||||
inbandTransferManager.cleanup();
|
inbandTransferManager.cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.filetransfer;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.filter.AndFilter;
|
import org.jivesoftware.smack.filter.AndFilter;
|
||||||
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
||||||
|
@ -45,7 +45,7 @@ import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||||
*/
|
*/
|
||||||
public class IBBTransferNegotiator extends StreamNegotiator {
|
public class IBBTransferNegotiator extends StreamNegotiator {
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
private InBandBytestreamManager manager;
|
private InBandBytestreamManager manager;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
||||||
*
|
*
|
||||||
* @param connection The connection which this negotiator works on.
|
* @param connection The connection which this negotiator works on.
|
||||||
*/
|
*/
|
||||||
protected IBBTransferNegotiator(Connection connection) {
|
protected IBBTransferNegotiator(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.manager = InBandBytestreamManager.getByteStreamManager(connection);
|
this.manager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PushbackInputStream;
|
import java.io.PushbackInputStream;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.filter.AndFilter;
|
import org.jivesoftware.smack.filter.AndFilter;
|
||||||
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
||||||
|
@ -44,11 +44,11 @@ import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||||
*/
|
*/
|
||||||
public class Socks5TransferNegotiator extends StreamNegotiator {
|
public class Socks5TransferNegotiator extends StreamNegotiator {
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
private Socks5BytestreamManager manager;
|
private Socks5BytestreamManager manager;
|
||||||
|
|
||||||
Socks5TransferNegotiator(Connection connection) {
|
Socks5TransferNegotiator(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.manager = Socks5BytestreamManager.getBytestreamManager(this.connection);
|
this.manager = Socks5BytestreamManager.getBytestreamManager(this.connection);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
package org.jivesoftware.smackx.filetransfer;
|
package org.jivesoftware.smackx.filetransfer;
|
||||||
|
|
||||||
import org.jivesoftware.smack.PacketCollector;
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.filter.PacketFilter;
|
import org.jivesoftware.smack.filter.PacketFilter;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
|
@ -77,7 +77,7 @@ public abstract class StreamNegotiator {
|
||||||
return iq;
|
return iq;
|
||||||
}
|
}
|
||||||
|
|
||||||
Packet initiateIncomingStream(Connection connection, StreamInitiation initiation) throws XMPPException {
|
Packet initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) throws XMPPException {
|
||||||
StreamInitiation response = createInitiationAccept(initiation,
|
StreamInitiation response = createInitiationAccept(initiation,
|
||||||
getNamespaces());
|
getNamespaces());
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.iqlast;
|
package org.jivesoftware.smackx.iqlast;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
@ -54,7 +54,7 @@ import org.jivesoftware.smackx.iqlast.packet.LastActivity;
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* Connection con = new TCPConnection("jabber.org");
|
* XMPPConnection con = new TCPConnection("jabber.org");
|
||||||
* con.login("john", "doe");
|
* con.login("john", "doe");
|
||||||
* LastActivity activity = LastActivity.getLastActivity(con, "xray@jabber.org/Smack");
|
* LastActivity activity = LastActivity.getLastActivity(con, "xray@jabber.org/Smack");
|
||||||
* </pre>
|
* </pre>
|
||||||
|
@ -83,12 +83,12 @@ public class LastActivityManager {
|
||||||
|
|
||||||
private long lastMessageSent;
|
private long lastMessageSent;
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
// Enable the LastActivity support on every established connection
|
// Enable the LastActivity support on every established connection
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
new LastActivityManager(connection);
|
new LastActivityManager(connection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -98,9 +98,9 @@ public class LastActivityManager {
|
||||||
* Creates a last activity manager to response last activity requests.
|
* Creates a last activity manager to response last activity requests.
|
||||||
*
|
*
|
||||||
* @param connection
|
* @param connection
|
||||||
* The Connection that the last activity requests will use.
|
* The XMPPConnection that the last activity requests will use.
|
||||||
*/
|
*/
|
||||||
private LastActivityManager(Connection connection) {
|
private LastActivityManager(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
|
||||||
// Listen to all the sent messages to reset the idle time on each one
|
// Listen to all the sent messages to reset the idle time on each one
|
||||||
|
@ -185,14 +185,14 @@ public class LastActivityManager {
|
||||||
* 'host') the last activity is the uptime.
|
* 'host') the last activity is the uptime.
|
||||||
*
|
*
|
||||||
* @param con
|
* @param con
|
||||||
* the current Connection.
|
* the current XMPPConnection.
|
||||||
* @param jid
|
* @param jid
|
||||||
* the JID of the user.
|
* the JID of the user.
|
||||||
* @return the LastActivity packet of the jid.
|
* @return the LastActivity packet of the jid.
|
||||||
* @throws XMPPException
|
* @throws XMPPException
|
||||||
* thrown if a server error has occured.
|
* thrown if a server error has occured.
|
||||||
*/
|
*/
|
||||||
public static LastActivity getLastActivity(Connection con, String jid) throws XMPPException {
|
public static LastActivity getLastActivity(XMPPConnection con, String jid) throws XMPPException {
|
||||||
LastActivity activity = new LastActivity();
|
LastActivity activity = new LastActivity();
|
||||||
activity.setTo(jid);
|
activity.setTo(jid);
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ public class LastActivityManager {
|
||||||
* @param jid a JID to be tested for Last Activity support
|
* @param jid a JID to be tested for Last Activity support
|
||||||
* @return true if Last Activity is supported, otherwise false
|
* @return true if Last Activity is supported, otherwise false
|
||||||
*/
|
*/
|
||||||
public static boolean isLastActivitySupported(Connection connection, String jid) {
|
public static boolean isLastActivitySupported(XMPPConnection connection, String jid) {
|
||||||
try {
|
try {
|
||||||
DiscoverInfo result =
|
DiscoverInfo result =
|
||||||
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
|
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.iqlast.packet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.provider.IQProvider;
|
import org.jivesoftware.smack.provider.IQProvider;
|
||||||
|
@ -128,14 +128,14 @@ public class LastActivity extends IQ {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the last activity of a particular jid.
|
* Retrieve the last activity of a particular jid.
|
||||||
* @param con the current Connection.
|
* @param con the current XMPPConnection.
|
||||||
* @param jid the JID of the user.
|
* @param jid the JID of the user.
|
||||||
* @return the LastActivity packet of the jid.
|
* @return the LastActivity packet of the jid.
|
||||||
* @throws XMPPException thrown if a server error has occured.
|
* @throws XMPPException thrown if a server error has occured.
|
||||||
* @deprecated This method only retreives the lapsed time since the last logout of a particular jid.
|
* @deprecated This method only retreives the lapsed time since the last logout of a particular jid.
|
||||||
* Replaced by {@link org.jivesoftware.smackx.iqlast.LastActivityManager#getLastActivity(Connection, String) getLastActivity}
|
* Replaced by {@link org.jivesoftware.smackx.iqlast.LastActivityManager#getLastActivity(XMPPConnection, String) getLastActivity}
|
||||||
*/
|
*/
|
||||||
public static LastActivity getLastActivity(Connection con, String jid) throws XMPPException {
|
public static LastActivity getLastActivity(XMPPConnection con, String jid) throws XMPPException {
|
||||||
LastActivity activity = new LastActivity();
|
LastActivity activity = new LastActivity();
|
||||||
jid = StringUtils.parseBareAddress(jid);
|
jid = StringUtils.parseBareAddress(jid);
|
||||||
activity.setTo(jid);
|
activity.setTo(jid);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.iqprivate;
|
package org.jivesoftware.smackx.iqprivate;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.provider.IQProvider;
|
import org.jivesoftware.smack.provider.IQProvider;
|
||||||
|
@ -112,7 +112,7 @@ public class PrivateDataManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user to get and set private data for. In most cases, this value should
|
* The user to get and set private data for. In most cases, this value should
|
||||||
|
@ -129,7 +129,7 @@ public class PrivateDataManager {
|
||||||
* @param connection an XMPP connection which must have already undergone a
|
* @param connection an XMPP connection which must have already undergone a
|
||||||
* successful login.
|
* successful login.
|
||||||
*/
|
*/
|
||||||
public PrivateDataManager(Connection connection) {
|
public PrivateDataManager(XMPPConnection connection) {
|
||||||
if (!connection.isAuthenticated()) {
|
if (!connection.isAuthenticated()) {
|
||||||
throw new IllegalStateException("Must be logged in to XMPP server.");
|
throw new IllegalStateException("Must be logged in to XMPP server.");
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ public class PrivateDataManager {
|
||||||
* successful login.
|
* successful login.
|
||||||
* @param user the XMPP address of the user to get and set private data for.
|
* @param user the XMPP address of the user to get and set private data for.
|
||||||
*/
|
*/
|
||||||
public PrivateDataManager(Connection connection, String user) {
|
public PrivateDataManager(XMPPConnection connection, String user) {
|
||||||
if (!connection.isAuthenticated()) {
|
if (!connection.isAuthenticated()) {
|
||||||
throw new IllegalStateException("Must be logged in to XMPP server.");
|
throw new IllegalStateException("Must be logged in to XMPP server.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.filter.AndFilter;
|
import org.jivesoftware.smack.filter.AndFilter;
|
||||||
|
@ -49,12 +49,12 @@ import org.jivesoftware.smackx.iqversion.packet.Version;
|
||||||
* @author Georg Lukas
|
* @author Georg Lukas
|
||||||
*/
|
*/
|
||||||
public class VersionManager extends Manager {
|
public class VersionManager extends Manager {
|
||||||
private static final Map<Connection, VersionManager> instances =
|
private static final Map<XMPPConnection, VersionManager> instances =
|
||||||
Collections.synchronizedMap(new WeakHashMap<Connection, VersionManager>());
|
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, VersionManager>());
|
||||||
|
|
||||||
private Version own_version;
|
private Version own_version;
|
||||||
|
|
||||||
private VersionManager(final Connection connection) {
|
private VersionManager(final XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
instances.put(connection, this);
|
instances.put(connection, this);
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class VersionManager extends Manager {
|
||||||
, new AndFilter(new PacketTypeFilter(Version.class), new IQTypeFilter(Type.GET)));
|
, new AndFilter(new PacketTypeFilter(Version.class), new IQTypeFilter(Type.GET)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized VersionManager getInstanceFor(Connection connection) {
|
public static synchronized VersionManager getInstanceFor(XMPPConnection connection) {
|
||||||
VersionManager versionManager = instances.get(connection);
|
VersionManager versionManager = instances.get(connection);
|
||||||
|
|
||||||
if (versionManager == null) {
|
if (versionManager == null) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.jivesoftware.smack.packet.Packet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A variant of the {@link org.jivesoftware.smack.PacketCollector} class
|
* A variant of the {@link org.jivesoftware.smack.PacketCollector} class
|
||||||
* that does not force attachment to a <code>Connection</code>
|
* that does not force attachment to a <code>XMPPConnection</code>
|
||||||
* on creation and no filter is required. Used to collect message
|
* on creation and no filter is required. Used to collect message
|
||||||
* packets targeted to a group chat room.
|
* packets targeted to a group chat room.
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,9 +22,9 @@ import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||||
* Hosted rooms by a chat service may be discovered if they are configured to appear in the room
|
* Hosted rooms by a chat service may be discovered if they are configured to appear in the room
|
||||||
* directory . The information that may be discovered is the XMPP address of the room and the room
|
* directory . The information that may be discovered is the XMPP address of the room and the room
|
||||||
* name. The address of the room may be used for obtaining more detailed information
|
* name. The address of the room may be used for obtaining more detailed information
|
||||||
* {@link org.jivesoftware.smackx.muc.MultiUserChat#getRoomInfo(org.jivesoftware.smack.Connection, String)}
|
* {@link org.jivesoftware.smackx.muc.MultiUserChat#getRoomInfo(org.jivesoftware.smack.XMPPConnection, String)}
|
||||||
* or could be used for joining the room
|
* or could be used for joining the room
|
||||||
* {@link org.jivesoftware.smackx.muc.MultiUserChat#MultiUserChat(org.jivesoftware.smack.Connection, String)}
|
* {@link org.jivesoftware.smackx.muc.MultiUserChat#MultiUserChat(org.jivesoftware.smack.XMPPConnection, String)}
|
||||||
* and {@link org.jivesoftware.smackx.muc.MultiUserChat#join(String)}.
|
* and {@link org.jivesoftware.smackx.muc.MultiUserChat#join(String)}.
|
||||||
*
|
*
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
package org.jivesoftware.smackx.muc;
|
package org.jivesoftware.smackx.muc;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,14 +33,14 @@ public interface InvitationListener {
|
||||||
* If the room is password-protected, the invitee will receive a password to use to join
|
* If the room is password-protected, the invitee will receive a password to use to join
|
||||||
* the room. If the room is members-only, the the invitee may be added to the member list.
|
* the room. If the room is members-only, the the invitee may be added to the member list.
|
||||||
*
|
*
|
||||||
* @param conn the Connection that received the invitation.
|
* @param conn the XMPPConnection that received the invitation.
|
||||||
* @param room the room that invitation refers to.
|
* @param room the room that invitation refers to.
|
||||||
* @param inviter the inviter that sent the invitation. (e.g. crone1@shakespeare.lit).
|
* @param inviter the inviter that sent the invitation. (e.g. crone1@shakespeare.lit).
|
||||||
* @param reason the reason why the inviter sent the invitation.
|
* @param reason the reason why the inviter sent the invitation.
|
||||||
* @param password the password to use when joining the room.
|
* @param password the password to use when joining the room.
|
||||||
* @param message the message used by the inviter to send the invitation.
|
* @param message the message used by the inviter to send the invitation.
|
||||||
*/
|
*/
|
||||||
public abstract void invitationReceived(Connection conn, String room, String inviter, String reason,
|
public abstract void invitationReceived(XMPPConnection conn, String room, String inviter, String reason,
|
||||||
String password, Message message);
|
String password, Message message);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.jivesoftware.smack.PacketCollector;
|
||||||
import org.jivesoftware.smack.PacketInterceptor;
|
import org.jivesoftware.smack.PacketInterceptor;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.SmackConfiguration;
|
import org.jivesoftware.smack.SmackConfiguration;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.filter.AndFilter;
|
import org.jivesoftware.smack.filter.AndFilter;
|
||||||
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
||||||
|
@ -80,10 +80,10 @@ public class MultiUserChat {
|
||||||
private final static String discoNamespace = "http://jabber.org/protocol/muc";
|
private final static String discoNamespace = "http://jabber.org/protocol/muc";
|
||||||
private final static String discoNode = "http://jabber.org/protocol/muc#rooms";
|
private final static String discoNode = "http://jabber.org/protocol/muc#rooms";
|
||||||
|
|
||||||
private static Map<Connection, List<String>> joinedRooms =
|
private static Map<XMPPConnection, List<String>> joinedRooms =
|
||||||
new WeakHashMap<Connection, List<String>>();
|
new WeakHashMap<XMPPConnection, List<String>>();
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
private String room;
|
private String room;
|
||||||
private String subject;
|
private String subject;
|
||||||
private String nickname = null;
|
private String nickname = null;
|
||||||
|
@ -107,8 +107,8 @@ public class MultiUserChat {
|
||||||
private List<PacketListener> connectionListeners = new ArrayList<PacketListener>();
|
private List<PacketListener> connectionListeners = new ArrayList<PacketListener>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(final Connection connection) {
|
public void connectionCreated(final XMPPConnection connection) {
|
||||||
// Set on every established connection that this client supports the Multi-User
|
// Set on every established connection that this client supports the Multi-User
|
||||||
// Chat protocol. This information will be used when another client tries to
|
// Chat protocol. This information will be used when another client tries to
|
||||||
// discover whether this client supports MUC or not.
|
// discover whether this client supports MUC or not.
|
||||||
|
@ -116,12 +116,12 @@ public class MultiUserChat {
|
||||||
|
|
||||||
// Set the NodeInformationProvider that will provide information about the
|
// Set the NodeInformationProvider that will provide information about the
|
||||||
// joined rooms whenever a disco request is received
|
// joined rooms whenever a disco request is received
|
||||||
final WeakReference<Connection> weakRefConnection = new WeakReference<Connection>(connection);
|
final WeakReference<XMPPConnection> weakRefConnection = new WeakReference<XMPPConnection>(connection);
|
||||||
ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider(
|
ServiceDiscoveryManager.getInstanceFor(connection).setNodeInformationProvider(
|
||||||
discoNode,
|
discoNode,
|
||||||
new NodeInformationProvider() {
|
new NodeInformationProvider() {
|
||||||
public List<DiscoverItems.Item> getNodeItems() {
|
public List<DiscoverItems.Item> getNodeItems() {
|
||||||
Connection connection = weakRefConnection.get();
|
XMPPConnection connection = weakRefConnection.get();
|
||||||
if (connection == null) return new LinkedList<DiscoverItems.Item>();
|
if (connection == null) return new LinkedList<DiscoverItems.Item>();
|
||||||
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
|
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
|
||||||
Iterator<String> rooms=MultiUserChat.getJoinedRooms(connection);
|
Iterator<String> rooms=MultiUserChat.getJoinedRooms(connection);
|
||||||
|
@ -163,7 +163,7 @@ public class MultiUserChat {
|
||||||
* "service" is the hostname at which the multi-user chat
|
* "service" is the hostname at which the multi-user chat
|
||||||
* service is running. Make sure to provide a valid JID.
|
* service is running. Make sure to provide a valid JID.
|
||||||
*/
|
*/
|
||||||
public MultiUserChat(Connection connection, String room) {
|
public MultiUserChat(XMPPConnection connection, String room) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.room = room.toLowerCase();
|
this.room = room.toLowerCase();
|
||||||
init();
|
init();
|
||||||
|
@ -176,7 +176,7 @@ public class MultiUserChat {
|
||||||
* @param user the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.
|
* @param user the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.
|
||||||
* @return a boolean indicating whether the specified user supports the MUC protocol.
|
* @return a boolean indicating whether the specified user supports the MUC protocol.
|
||||||
*/
|
*/
|
||||||
public static boolean isServiceEnabled(Connection connection, String user) {
|
public static boolean isServiceEnabled(XMPPConnection connection, String user) {
|
||||||
try {
|
try {
|
||||||
DiscoverInfo result =
|
DiscoverInfo result =
|
||||||
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(user);
|
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(user);
|
||||||
|
@ -196,7 +196,7 @@ public class MultiUserChat {
|
||||||
* @param connection the connection used to join the rooms.
|
* @param connection the connection used to join the rooms.
|
||||||
* @return an Iterator on the rooms where the user has joined using a given connection.
|
* @return an Iterator on the rooms where the user has joined using a given connection.
|
||||||
*/
|
*/
|
||||||
private static Iterator<String> getJoinedRooms(Connection connection) {
|
private static Iterator<String> getJoinedRooms(XMPPConnection connection) {
|
||||||
List<String> rooms = joinedRooms.get(connection);
|
List<String> rooms = joinedRooms.get(connection);
|
||||||
if (rooms != null) {
|
if (rooms != null) {
|
||||||
return rooms.iterator();
|
return rooms.iterator();
|
||||||
|
@ -213,7 +213,7 @@ public class MultiUserChat {
|
||||||
* @param user the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.
|
* @param user the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com.
|
||||||
* @return an Iterator on the rooms where the requested user has joined.
|
* @return an Iterator on the rooms where the requested user has joined.
|
||||||
*/
|
*/
|
||||||
public static Iterator<String> getJoinedRooms(Connection connection, String user) {
|
public static Iterator<String> getJoinedRooms(XMPPConnection connection, String user) {
|
||||||
try {
|
try {
|
||||||
ArrayList<String> answer = new ArrayList<String>();
|
ArrayList<String> answer = new ArrayList<String>();
|
||||||
// Send the disco packet to the user
|
// Send the disco packet to the user
|
||||||
|
@ -242,7 +242,7 @@ public class MultiUserChat {
|
||||||
* @return the discovered information of a given room without actually having to join the room.
|
* @return the discovered information of a given room without actually having to join the room.
|
||||||
* @throws XMPPException if an error occured while trying to discover information of a room.
|
* @throws XMPPException if an error occured while trying to discover information of a room.
|
||||||
*/
|
*/
|
||||||
public static RoomInfo getRoomInfo(Connection connection, String room)
|
public static RoomInfo getRoomInfo(XMPPConnection connection, String room)
|
||||||
throws XMPPException {
|
throws XMPPException {
|
||||||
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room);
|
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room);
|
||||||
return new RoomInfo(info);
|
return new RoomInfo(info);
|
||||||
|
@ -255,7 +255,7 @@ public class MultiUserChat {
|
||||||
* @return a collection with the XMPP addresses of the Multi-User Chat services.
|
* @return a collection with the XMPP addresses of the Multi-User Chat services.
|
||||||
* @throws XMPPException if an error occured while trying to discover MUC services.
|
* @throws XMPPException if an error occured while trying to discover MUC services.
|
||||||
*/
|
*/
|
||||||
public static Collection<String> getServiceNames(Connection connection) throws XMPPException {
|
public static Collection<String> getServiceNames(XMPPConnection connection) throws XMPPException {
|
||||||
final List<String> answer = new ArrayList<String>();
|
final List<String> answer = new ArrayList<String>();
|
||||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
|
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
|
||||||
|
@ -285,7 +285,7 @@ public class MultiUserChat {
|
||||||
* @return a collection of HostedRooms.
|
* @return a collection of HostedRooms.
|
||||||
* @throws XMPPException if an error occured while trying to discover the information.
|
* @throws XMPPException if an error occured while trying to discover the information.
|
||||||
*/
|
*/
|
||||||
public static Collection<HostedRoom> getHostedRooms(Connection connection, String serviceName)
|
public static Collection<HostedRoom> getHostedRooms(XMPPConnection connection, String serviceName)
|
||||||
throws XMPPException {
|
throws XMPPException {
|
||||||
List<HostedRoom> answer = new ArrayList<HostedRoom>();
|
List<HostedRoom> answer = new ArrayList<HostedRoom>();
|
||||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
|
@ -689,7 +689,7 @@ public class MultiUserChat {
|
||||||
* @param inviter the inviter of the declined invitation.
|
* @param inviter the inviter of the declined invitation.
|
||||||
* @param reason the reason why the invitee is declining the invitation.
|
* @param reason the reason why the invitee is declining the invitation.
|
||||||
*/
|
*/
|
||||||
public static void decline(Connection conn, String room, String inviter, String reason) {
|
public static void decline(XMPPConnection conn, String room, String inviter, String reason) {
|
||||||
Message message = new Message(room);
|
Message message = new Message(room);
|
||||||
|
|
||||||
// Create the MUCUser packet that will include the rejection
|
// Create the MUCUser packet that will include the rejection
|
||||||
|
@ -711,7 +711,7 @@ public class MultiUserChat {
|
||||||
* @param conn the connection where the listener will be applied.
|
* @param conn the connection where the listener will be applied.
|
||||||
* @param listener an invitation listener.
|
* @param listener an invitation listener.
|
||||||
*/
|
*/
|
||||||
public static void addInvitationListener(Connection conn, InvitationListener listener) {
|
public static void addInvitationListener(XMPPConnection conn, InvitationListener listener) {
|
||||||
InvitationsMonitor.getInvitationsMonitor(conn).addInvitationListener(listener);
|
InvitationsMonitor.getInvitationsMonitor(conn).addInvitationListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ public class MultiUserChat {
|
||||||
* @param conn the connection where the listener was applied.
|
* @param conn the connection where the listener was applied.
|
||||||
* @param listener an invitation listener.
|
* @param listener an invitation listener.
|
||||||
*/
|
*/
|
||||||
public static void removeInvitationListener(Connection conn, InvitationListener listener) {
|
public static void removeInvitationListener(XMPPConnection conn, InvitationListener listener) {
|
||||||
InvitationsMonitor.getInvitationsMonitor(conn).removeInvitationListener(listener);
|
InvitationsMonitor.getInvitationsMonitor(conn).removeInvitationListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1661,7 +1661,7 @@ public class MultiUserChat {
|
||||||
* group chat. Only "group chat" messages addressed to this group chat will
|
* group chat. Only "group chat" messages addressed to this group chat will
|
||||||
* be delivered to the listener. If you wish to listen for other packets
|
* be delivered to the listener. If you wish to listen for other packets
|
||||||
* that may be associated with this group chat, you should register a
|
* that may be associated with this group chat, you should register a
|
||||||
* PacketListener directly with the Connection with the appropriate
|
* PacketListener directly with the XMPPConnection with the appropriate
|
||||||
* PacketListener.
|
* PacketListener.
|
||||||
*
|
*
|
||||||
* @param listener a packet listener.
|
* @param listener a packet listener.
|
||||||
|
@ -2310,17 +2310,17 @@ public class MultiUserChat {
|
||||||
// We use a WeakHashMap so that the GC can collect the monitor when the
|
// We use a WeakHashMap so that the GC can collect the monitor when the
|
||||||
// connection is no longer referenced by any object.
|
// connection is no longer referenced by any object.
|
||||||
// Note that when the InvitationsMonitor is used, i.e. when there are InvitationListeners, it will add a
|
// Note that when the InvitationsMonitor is used, i.e. when there are InvitationListeners, it will add a
|
||||||
// PacketListener to the Connection and therefore a strong reference from the Connection to the
|
// PacketListener to the XMPPConnection and therefore a strong reference from the XMPPConnection to the
|
||||||
// InvitationsMonior will exists, preventing it from beeing gc'ed. After the last InvitationListener is gone,
|
// InvitationsMonior will exists, preventing it from beeing gc'ed. After the last InvitationListener is gone,
|
||||||
// the PacketListener will get removed (cancel()) allowing the garbage collection of the InvitationsMonitor
|
// the PacketListener will get removed (cancel()) allowing the garbage collection of the InvitationsMonitor
|
||||||
// instance.
|
// instance.
|
||||||
private final static Map<Connection, WeakReference<InvitationsMonitor>> monitors =
|
private final static Map<XMPPConnection, WeakReference<InvitationsMonitor>> monitors =
|
||||||
new WeakHashMap<Connection, WeakReference<InvitationsMonitor>>();
|
new WeakHashMap<XMPPConnection, WeakReference<InvitationsMonitor>>();
|
||||||
|
|
||||||
// We don't use a synchronized List here because it would break the semantic of (add|remove)InvitationListener
|
// We don't use a synchronized List here because it would break the semantic of (add|remove)InvitationListener
|
||||||
private final List<InvitationListener> invitationsListeners =
|
private final List<InvitationListener> invitationsListeners =
|
||||||
new ArrayList<InvitationListener>();
|
new ArrayList<InvitationListener>();
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
private PacketFilter invitationFilter;
|
private PacketFilter invitationFilter;
|
||||||
private PacketListener invitationPacketListener;
|
private PacketListener invitationPacketListener;
|
||||||
|
|
||||||
|
@ -2330,7 +2330,7 @@ public class MultiUserChat {
|
||||||
* @param conn the connection to monitor for room invitations.
|
* @param conn the connection to monitor for room invitations.
|
||||||
* @return a new or existing InvitationsMonitor for a given connection.
|
* @return a new or existing InvitationsMonitor for a given connection.
|
||||||
*/
|
*/
|
||||||
public static InvitationsMonitor getInvitationsMonitor(Connection conn) {
|
public static InvitationsMonitor getInvitationsMonitor(XMPPConnection conn) {
|
||||||
synchronized (monitors) {
|
synchronized (monitors) {
|
||||||
if (!monitors.containsKey(conn) || monitors.get(conn).get() == null) {
|
if (!monitors.containsKey(conn) || monitors.get(conn).get() == null) {
|
||||||
// We need to use a WeakReference because the monitor references the
|
// We need to use a WeakReference because the monitor references the
|
||||||
|
@ -2351,7 +2351,7 @@ public class MultiUserChat {
|
||||||
*
|
*
|
||||||
* @param connection the connection to monitor for possible room invitations
|
* @param connection the connection to monitor for possible room invitations
|
||||||
*/
|
*/
|
||||||
private InvitationsMonitor(Connection connection) {
|
private InvitationsMonitor(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.muc;
|
||||||
|
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.filter.PacketFilter;
|
import org.jivesoftware.smack.filter.PacketFilter;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
import org.jivesoftware.smack.util.StringUtils;
|
import org.jivesoftware.smack.util.StringUtils;
|
||||||
|
@ -31,9 +31,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A <code>RoomListenerMultiplexor</code> multiplexes incoming packets on
|
* A <code>RoomListenerMultiplexor</code> multiplexes incoming packets on
|
||||||
* a <code>Connection</code> using a single listener/filter pair.
|
* a <code>XMPPConnection</code> using a single listener/filter pair.
|
||||||
* A single <code>RoomListenerMultiplexor</code> is created for each
|
* A single <code>RoomListenerMultiplexor</code> is created for each
|
||||||
* {@link org.jivesoftware.smack.Connection} that has joined MUC rooms
|
* {@link org.jivesoftware.smack.XMPPConnection} that has joined MUC rooms
|
||||||
* within its session.
|
* within its session.
|
||||||
*
|
*
|
||||||
* @author Larry Kirschner
|
* @author Larry Kirschner
|
||||||
|
@ -42,10 +42,10 @@ class RoomListenerMultiplexor implements ConnectionListener {
|
||||||
|
|
||||||
// We use a WeakHashMap so that the GC can collect the monitor when the
|
// We use a WeakHashMap so that the GC can collect the monitor when the
|
||||||
// connection is no longer referenced by any object.
|
// connection is no longer referenced by any object.
|
||||||
private static final Map<Connection, WeakReference<RoomListenerMultiplexor>> monitors =
|
private static final Map<XMPPConnection, WeakReference<RoomListenerMultiplexor>> monitors =
|
||||||
new WeakHashMap<Connection, WeakReference<RoomListenerMultiplexor>>();
|
new WeakHashMap<XMPPConnection, WeakReference<RoomListenerMultiplexor>>();
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
private RoomMultiplexFilter filter;
|
private RoomMultiplexFilter filter;
|
||||||
private RoomMultiplexListener listener;
|
private RoomMultiplexListener listener;
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class RoomListenerMultiplexor implements ConnectionListener {
|
||||||
* @param conn the connection to monitor for room invitations.
|
* @param conn the connection to monitor for room invitations.
|
||||||
* @return a new or existing RoomListenerMultiplexor for a given connection.
|
* @return a new or existing RoomListenerMultiplexor for a given connection.
|
||||||
*/
|
*/
|
||||||
public static RoomListenerMultiplexor getRoomMultiplexor(Connection conn) {
|
public static RoomListenerMultiplexor getRoomMultiplexor(XMPPConnection conn) {
|
||||||
synchronized (monitors) {
|
synchronized (monitors) {
|
||||||
if (!monitors.containsKey(conn) || monitors.get(conn).get() == null) {
|
if (!monitors.containsKey(conn) || monitors.get(conn).get() == null) {
|
||||||
RoomListenerMultiplexor rm = new RoomListenerMultiplexor(conn, new RoomMultiplexFilter(),
|
RoomListenerMultiplexor rm = new RoomListenerMultiplexor(conn, new RoomMultiplexFilter(),
|
||||||
|
@ -75,12 +75,12 @@ class RoomListenerMultiplexor implements ConnectionListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All access should be through
|
* All access should be through
|
||||||
* the static method {@link #getRoomMultiplexor(Connection)}.
|
* the static method {@link #getRoomMultiplexor(XMPPConnection)}.
|
||||||
*/
|
*/
|
||||||
private RoomListenerMultiplexor(Connection connection, RoomMultiplexFilter filter,
|
private RoomListenerMultiplexor(XMPPConnection connection, RoomMultiplexFilter filter,
|
||||||
RoomMultiplexListener listener) {
|
RoomMultiplexListener listener) {
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
throw new IllegalArgumentException("Connection is null");
|
throw new IllegalArgumentException("XMPPConnection is null");
|
||||||
}
|
}
|
||||||
if (filter == null) {
|
if (filter == null) {
|
||||||
throw new IllegalArgumentException("Filter is null");
|
throw new IllegalArgumentException("Filter is null");
|
||||||
|
@ -143,11 +143,11 @@ class RoomListenerMultiplexor implements ConnectionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The single <code>Connection</code>-level <code>PacketFilter</code> used by a {@link RoomListenerMultiplexor}
|
* The single <code>XMPPConnection</code>-level <code>PacketFilter</code> used by a {@link RoomListenerMultiplexor}
|
||||||
* for all muc chat rooms on an <code>Connection</code>.
|
* for all muc chat rooms on an <code>XMPPConnection</code>.
|
||||||
* Each time a muc chat room is added to/removed from an
|
* Each time a muc chat room is added to/removed from an
|
||||||
* <code>Connection</code> the address for that chat room
|
* <code>XMPPConnection</code> the address for that chat room
|
||||||
* is added to/removed from that <code>Connection</code>'s
|
* is added to/removed from that <code>XMPPConnection</code>'s
|
||||||
* <code>RoomMultiplexFilter</code>.
|
* <code>RoomMultiplexFilter</code>.
|
||||||
*/
|
*/
|
||||||
private static class RoomMultiplexFilter implements PacketFilter {
|
private static class RoomMultiplexFilter implements PacketFilter {
|
||||||
|
@ -178,12 +178,12 @@ class RoomListenerMultiplexor implements ConnectionListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The single <code>Connection</code>-level <code>PacketListener</code>
|
* The single <code>XMPPConnection</code>-level <code>PacketListener</code>
|
||||||
* used by a {@link RoomListenerMultiplexor}
|
* used by a {@link RoomListenerMultiplexor}
|
||||||
* for all muc chat rooms on an <code>Connection</code>.
|
* for all muc chat rooms on an <code>XMPPConnection</code>.
|
||||||
* Each time a muc chat room is added to/removed from an
|
* Each time a muc chat room is added to/removed from an
|
||||||
* <code>Connection</code> the address and listener for that chat room
|
* <code>XMPPConnection</code> the address and listener for that chat room
|
||||||
* are added to/removed from that <code>Connection</code>'s
|
* are added to/removed from that <code>XMPPConnection</code>'s
|
||||||
* <code>RoomMultiplexListener</code>.
|
* <code>RoomMultiplexListener</code>.
|
||||||
*
|
*
|
||||||
* @author Larry Kirschner
|
* @author Larry Kirschner
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.offline;
|
||||||
|
|
||||||
import org.jivesoftware.smack.PacketCollector;
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
import org.jivesoftware.smack.SmackConfiguration;
|
import org.jivesoftware.smack.SmackConfiguration;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.filter.AndFilter;
|
import org.jivesoftware.smack.filter.AndFilter;
|
||||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||||
|
@ -58,11 +58,11 @@ public class OfflineMessageManager {
|
||||||
|
|
||||||
private final static String namespace = "http://jabber.org/protocol/offline";
|
private final static String namespace = "http://jabber.org/protocol/offline";
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
private PacketFilter packetFilter;
|
private PacketFilter packetFilter;
|
||||||
|
|
||||||
public OfflineMessageManager(Connection connection) {
|
public OfflineMessageManager(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
packetFilter =
|
packetFilter =
|
||||||
new AndFilter(new PacketExtensionFilter("offline", namespace),
|
new AndFilter(new PacketExtensionFilter("offline", namespace),
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||||
import org.jivesoftware.smack.filter.PacketFilter;
|
import org.jivesoftware.smack.filter.PacketFilter;
|
||||||
import org.jivesoftware.smack.packet.Message;
|
import org.jivesoftware.smack.packet.Message;
|
||||||
|
@ -62,7 +62,7 @@ public class PEPManager {
|
||||||
|
|
||||||
private List<PEPListener> pepListeners = new ArrayList<PEPListener>();
|
private List<PEPListener> pepListeners = new ArrayList<PEPListener>();
|
||||||
|
|
||||||
private Connection connection;
|
private XMPPConnection connection;
|
||||||
|
|
||||||
private PacketFilter packetFilter = new PacketExtensionFilter("event", "http://jabber.org/protocol/pubsub#event");
|
private PacketFilter packetFilter = new PacketExtensionFilter("event", "http://jabber.org/protocol/pubsub#event");
|
||||||
private PacketListener packetListener;
|
private PacketListener packetListener;
|
||||||
|
@ -70,9 +70,9 @@ public class PEPManager {
|
||||||
/**
|
/**
|
||||||
* Creates a new PEP exchange manager.
|
* Creates a new PEP exchange manager.
|
||||||
*
|
*
|
||||||
* @param connection a Connection which is used to send and receive messages.
|
* @param connection a XMPPConnection which is used to send and receive messages.
|
||||||
*/
|
*/
|
||||||
public PEPManager(Connection connection) {
|
public PEPManager(XMPPConnection connection) {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.ConnectionListener;
|
import org.jivesoftware.smack.ConnectionListener;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
|
@ -56,29 +56,29 @@ public class PingManager extends Manager {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(PingManager.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(PingManager.class.getName());
|
||||||
|
|
||||||
private static final Map<Connection, PingManager> INSTANCES = Collections
|
private static final Map<XMPPConnection, PingManager> INSTANCES = Collections
|
||||||
.synchronizedMap(new WeakHashMap<Connection, PingManager>());
|
.synchronizedMap(new WeakHashMap<XMPPConnection, PingManager>());
|
||||||
|
|
||||||
private static final PacketFilter PING_PACKET_FILTER = new AndFilter(
|
private static final PacketFilter PING_PACKET_FILTER = new AndFilter(
|
||||||
new PacketTypeFilter(Ping.class), new IQTypeFilter(Type.GET));
|
new PacketTypeFilter(Ping.class), new IQTypeFilter(Type.GET));
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
getInstanceFor(connection);
|
getInstanceFor(connection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves a {@link PingManager} for the specified {@link Connection}, creating one if it doesn't already
|
* Retrieves a {@link PingManager} for the specified {@link XMPPConnection}, creating one if it doesn't already
|
||||||
* exist.
|
* exist.
|
||||||
*
|
*
|
||||||
* @param connection
|
* @param connection
|
||||||
* The connection the manager is attached to.
|
* The connection the manager is attached to.
|
||||||
* @return The new or existing manager.
|
* @return The new or existing manager.
|
||||||
*/
|
*/
|
||||||
public synchronized static PingManager getInstanceFor(Connection connection) {
|
public synchronized static PingManager getInstanceFor(XMPPConnection connection) {
|
||||||
PingManager pingManager = INSTANCES.get(connection);
|
PingManager pingManager = INSTANCES.get(connection);
|
||||||
if (pingManager == null) {
|
if (pingManager == null) {
|
||||||
pingManager = new PingManager(connection);
|
pingManager = new PingManager(connection);
|
||||||
|
@ -117,7 +117,7 @@ public class PingManager extends Manager {
|
||||||
*/
|
*/
|
||||||
private long lastSuccessfulManualPing = -1;
|
private long lastSuccessfulManualPing = -1;
|
||||||
|
|
||||||
private PingManager(Connection connection) {
|
private PingManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
sdm.addFeature(PingManager.NAMESPACE);
|
sdm.addFeature(PingManager.NAMESPACE);
|
||||||
|
@ -308,7 +308,7 @@ public class PingManager extends Manager {
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
LOGGER.fine("ServerPingTask run()");
|
LOGGER.fine("ServerPingTask run()");
|
||||||
Connection connection = connection();
|
XMPPConnection connection = connection();
|
||||||
if (connection == null) {
|
if (connection == null) {
|
||||||
// connection has been collected by GC
|
// connection has been collected by GC
|
||||||
// which means we can stop the thread by breaking the loop
|
// which means we can stop the thread by breaking the loop
|
||||||
|
@ -344,7 +344,7 @@ public class PingManager extends Manager {
|
||||||
maybeSchedulePingServerTask();
|
maybeSchedulePingServerTask();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warning("ServerPingTask: Connection was not authenticated");
|
LOGGER.warning("ServerPingTask: XMPPConnection was not authenticated");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
|
@ -50,8 +50,8 @@ import org.jivesoftware.smackx.privacy.packet.PrivacyItem;
|
||||||
public class PrivacyListManager extends Manager {
|
public class PrivacyListManager extends Manager {
|
||||||
|
|
||||||
// Keep the list of instances of this class.
|
// Keep the list of instances of this class.
|
||||||
private static Map<Connection, PrivacyListManager> instances = Collections
|
private static Map<XMPPConnection, PrivacyListManager> instances = Collections
|
||||||
.synchronizedMap(new WeakHashMap<Connection, PrivacyListManager>());
|
.synchronizedMap(new WeakHashMap<XMPPConnection, PrivacyListManager>());
|
||||||
|
|
||||||
private final List<PrivacyListListener> listeners = new ArrayList<PrivacyListListener>();
|
private final List<PrivacyListListener> listeners = new ArrayList<PrivacyListListener>();
|
||||||
PacketFilter packetFilter = new AndFilter(new IQTypeFilter(IQ.Type.SET),
|
PacketFilter packetFilter = new AndFilter(new IQTypeFilter(IQ.Type.SET),
|
||||||
|
@ -61,8 +61,8 @@ public class PrivacyListManager extends Manager {
|
||||||
// Create a new PrivacyListManager on every established connection. In the init()
|
// Create a new PrivacyListManager on every established connection. In the init()
|
||||||
// method of PrivacyListManager, we'll add a listener that will delete the
|
// method of PrivacyListManager, we'll add a listener that will delete the
|
||||||
// instance when the connection is closed.
|
// instance when the connection is closed.
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
getInstanceFor(connection);
|
getInstanceFor(connection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -74,7 +74,7 @@ public class PrivacyListManager extends Manager {
|
||||||
*
|
*
|
||||||
* @param connection the XMPP connection.
|
* @param connection the XMPP connection.
|
||||||
*/
|
*/
|
||||||
private PrivacyListManager(final Connection connection) {
|
private PrivacyListManager(final XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
// Register the new instance and associate it with the connection
|
// Register the new instance and associate it with the connection
|
||||||
instances.put(connection, this);
|
instances.put(connection, this);
|
||||||
|
@ -129,12 +129,12 @@ public class PrivacyListManager extends Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the PrivacyListManager instance associated with a given Connection.
|
* Returns the PrivacyListManager instance associated with a given XMPPConnection.
|
||||||
*
|
*
|
||||||
* @param connection the connection used to look for the proper PrivacyListManager.
|
* @param connection the connection used to look for the proper PrivacyListManager.
|
||||||
* @return the PrivacyListManager associated with a given Connection.
|
* @return the PrivacyListManager associated with a given XMPPConnection.
|
||||||
*/
|
*/
|
||||||
public static synchronized PrivacyListManager getInstanceFor(Connection connection) {
|
public static synchronized PrivacyListManager getInstanceFor(XMPPConnection connection) {
|
||||||
PrivacyListManager plm = instances.get(connection);
|
PrivacyListManager plm = instances.get(connection);
|
||||||
if (plm == null) plm = new PrivacyListManager(connection);
|
if (plm == null) plm = new PrivacyListManager(connection);
|
||||||
return plm;
|
return plm;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.pubsub;
|
package org.jivesoftware.smackx.pubsub;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.packet.PacketExtension;
|
import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,7 @@ import org.jivesoftware.smack.packet.PacketExtension;
|
||||||
*
|
*
|
||||||
* Affiliations are retrieved from the {@link PubSubManager#getAffiliations()} method, which
|
* Affiliations are retrieved from the {@link PubSubManager#getAffiliations()} method, which
|
||||||
* gets affiliations for the calling user, based on the identity that is associated with
|
* gets affiliations for the calling user, based on the identity that is associated with
|
||||||
* the {@link Connection}.
|
* the {@link XMPPConnection}.
|
||||||
*
|
*
|
||||||
* @author Robin Collier
|
* @author Robin Collier
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.pubsub;
|
package org.jivesoftware.smackx.pubsub;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
|
|
||||||
public class CollectionNode extends Node
|
public class CollectionNode extends Node
|
||||||
{
|
{
|
||||||
CollectionNode(Connection connection, String nodeId)
|
CollectionNode(XMPPConnection connection, String nodeId)
|
||||||
{
|
{
|
||||||
super(connection, nodeId);
|
super(connection, nodeId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ.Type;
|
import org.jivesoftware.smack.packet.IQ.Type;
|
||||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||||
|
@ -36,7 +36,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||||
*/
|
*/
|
||||||
public class LeafNode extends Node
|
public class LeafNode extends Node
|
||||||
{
|
{
|
||||||
LeafNode(Connection connection, String nodeName)
|
LeafNode(XMPPConnection connection, String nodeName)
|
||||||
{
|
{
|
||||||
super(connection, nodeName);
|
super(connection, nodeName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.filter.OrFilter;
|
import org.jivesoftware.smack.filter.OrFilter;
|
||||||
import org.jivesoftware.smack.filter.PacketFilter;
|
import org.jivesoftware.smack.filter.PacketFilter;
|
||||||
|
@ -45,7 +45,7 @@ import org.jivesoftware.smackx.xdata.Form;
|
||||||
|
|
||||||
abstract public class Node
|
abstract public class Node
|
||||||
{
|
{
|
||||||
protected Connection con;
|
protected XMPPConnection con;
|
||||||
protected String id;
|
protected String id;
|
||||||
protected String to;
|
protected String to;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ abstract public class Node
|
||||||
* @param connection The connection the node is associated with
|
* @param connection The connection the node is associated with
|
||||||
* @param nodeName The node id
|
* @param nodeName The node id
|
||||||
*/
|
*/
|
||||||
Node(Connection connection, String nodeName)
|
Node(XMPPConnection connection, String nodeName)
|
||||||
{
|
{
|
||||||
con = connection;
|
con = connection;
|
||||||
id = nodeName;
|
id = nodeName;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ.Type;
|
import org.jivesoftware.smack.packet.IQ.Type;
|
||||||
import org.jivesoftware.smack.packet.Packet;
|
import org.jivesoftware.smack.packet.Packet;
|
||||||
|
@ -45,7 +45,7 @@ import org.jivesoftware.smackx.xdata.FormField;
|
||||||
*/
|
*/
|
||||||
final public class PubSubManager
|
final public class PubSubManager
|
||||||
{
|
{
|
||||||
private Connection con;
|
private XMPPConnection con;
|
||||||
private String to;
|
private String to;
|
||||||
private Map<String, Node> nodeMap = new ConcurrentHashMap<String, Node>();
|
private Map<String, Node> nodeMap = new ConcurrentHashMap<String, Node>();
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ final public class PubSubManager
|
||||||
*
|
*
|
||||||
* @param connection The XMPP connection
|
* @param connection The XMPP connection
|
||||||
*/
|
*/
|
||||||
public PubSubManager(Connection connection)
|
public PubSubManager(XMPPConnection connection)
|
||||||
{
|
{
|
||||||
con = connection;
|
con = connection;
|
||||||
to = "pubsub." + connection.getServiceName();
|
to = "pubsub." + connection.getServiceName();
|
||||||
|
@ -68,7 +68,7 @@ final public class PubSubManager
|
||||||
* @param connection The XMPP connection
|
* @param connection The XMPP connection
|
||||||
* @param toAddress The pubsub specific to address (required for some servers)
|
* @param toAddress The pubsub specific to address (required for some servers)
|
||||||
*/
|
*/
|
||||||
public PubSubManager(Connection connection, String toAddress)
|
public PubSubManager(XMPPConnection connection, String toAddress)
|
||||||
{
|
{
|
||||||
con = connection;
|
con = connection;
|
||||||
to = toAddress;
|
to = toAddress;
|
||||||
|
@ -305,25 +305,25 @@ final public class PubSubManager
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Packet sendPubsubPacket(Connection con, String to, Type type, PacketExtension ext)
|
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PacketExtension ext)
|
||||||
throws XMPPException
|
throws XMPPException
|
||||||
{
|
{
|
||||||
return sendPubsubPacket(con, to, type, ext, null);
|
return sendPubsubPacket(con, to, type, ext, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Packet sendPubsubPacket(Connection con, String to, Type type, PacketExtension ext, PubSubNamespace ns)
|
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PacketExtension ext, PubSubNamespace ns)
|
||||||
throws XMPPException
|
throws XMPPException
|
||||||
{
|
{
|
||||||
return con.createPacketCollectorAndSend(createPubsubPacket(to, type, ext, ns)).nextResultOrThrow();
|
return con.createPacketCollectorAndSend(createPubsubPacket(to, type, ext, ns)).nextResultOrThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Packet sendPubsubPacket(Connection con, String to, Type type, PubSub packet)
|
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PubSub packet)
|
||||||
throws XMPPException
|
throws XMPPException
|
||||||
{
|
{
|
||||||
return sendPubsubPacket(con, to, type, packet, null);
|
return sendPubsubPacket(con, to, type, packet, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Packet sendPubsubPacket(Connection con, String to, Type type, PubSub packet, PubSubNamespace ns)
|
static Packet sendPubsubPacket(XMPPConnection con, String to, Type type, PubSub packet, PubSubNamespace ns)
|
||||||
throws XMPPException
|
throws XMPPException
|
||||||
{
|
{
|
||||||
return con.createPacketCollectorAndSend(packet).nextResultOrThrow();
|
return con.createPacketCollectorAndSend(packet).nextResultOrThrow();
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
|
@ -41,12 +41,12 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
*/
|
*/
|
||||||
public class DeliveryReceiptManager extends Manager implements PacketListener {
|
public class DeliveryReceiptManager extends Manager implements PacketListener {
|
||||||
|
|
||||||
private static Map<Connection, DeliveryReceiptManager> instances =
|
private static Map<XMPPConnection, DeliveryReceiptManager> instances =
|
||||||
Collections.synchronizedMap(new WeakHashMap<Connection, DeliveryReceiptManager>());
|
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, DeliveryReceiptManager>());
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
getInstanceFor(connection);
|
getInstanceFor(connection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -56,7 +56,7 @@ public class DeliveryReceiptManager extends Manager implements PacketListener {
|
||||||
private Set<ReceiptReceivedListener> receiptReceivedListeners = Collections
|
private Set<ReceiptReceivedListener> receiptReceivedListeners = Collections
|
||||||
.synchronizedSet(new HashSet<ReceiptReceivedListener>());
|
.synchronizedSet(new HashSet<ReceiptReceivedListener>());
|
||||||
|
|
||||||
private DeliveryReceiptManager(Connection connection) {
|
private DeliveryReceiptManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
sdm.addFeature(DeliveryReceipt.NAMESPACE);
|
sdm.addFeature(DeliveryReceipt.NAMESPACE);
|
||||||
|
@ -73,7 +73,7 @@ public class DeliveryReceiptManager extends Manager implements PacketListener {
|
||||||
*
|
*
|
||||||
* @return the DeliveryReceiptManager instance for the given connection
|
* @return the DeliveryReceiptManager instance for the given connection
|
||||||
*/
|
*/
|
||||||
public static synchronized DeliveryReceiptManager getInstanceFor(Connection connection) {
|
public static synchronized DeliveryReceiptManager getInstanceFor(XMPPConnection connection) {
|
||||||
DeliveryReceiptManager receiptManager = instances.get(connection);
|
DeliveryReceiptManager receiptManager = instances.get(connection);
|
||||||
|
|
||||||
if (receiptManager == null) {
|
if (receiptManager == null) {
|
||||||
|
@ -117,7 +117,7 @@ public class DeliveryReceiptManager extends Manager implements PacketListener {
|
||||||
DeliveryReceiptRequest drr = (DeliveryReceiptRequest)packet.getExtension(
|
DeliveryReceiptRequest drr = (DeliveryReceiptRequest)packet.getExtension(
|
||||||
DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE);
|
DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE);
|
||||||
if (drr != null) {
|
if (drr != null) {
|
||||||
Connection connection = connection();
|
XMPPConnection connection = connection();
|
||||||
Message ack = new Message(packet.getFrom(), Message.Type.normal);
|
Message ack = new Message(packet.getFrom(), Message.Type.normal);
|
||||||
ack.addExtension(new DeliveryReceipt(packet.getPacketID()));
|
ack.addExtension(new DeliveryReceipt(packet.getPacketID()));
|
||||||
connection.sendPacket(ack);
|
connection.sendPacket(ack);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.search;
|
package org.jivesoftware.smackx.search;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.provider.IQProvider;
|
import org.jivesoftware.smack.provider.IQProvider;
|
||||||
|
@ -55,13 +55,13 @@ public class UserSearch extends IQ {
|
||||||
/**
|
/**
|
||||||
* Returns the form for all search fields supported by the search service.
|
* Returns the form for all search fields supported by the search service.
|
||||||
*
|
*
|
||||||
* @param con the current Connection.
|
* @param con the current XMPPConnection.
|
||||||
* @param searchService the search service to use. (ex. search.jivesoftware.com)
|
* @param searchService the search service to use. (ex. search.jivesoftware.com)
|
||||||
* @return the search form received by the server.
|
* @return the search form received by the server.
|
||||||
* @throws org.jivesoftware.smack.XMPPException
|
* @throws org.jivesoftware.smack.XMPPException
|
||||||
* thrown if a server error has occurred.
|
* thrown if a server error has occurred.
|
||||||
*/
|
*/
|
||||||
public Form getSearchForm(Connection con, String searchService) throws XMPPException {
|
public Form getSearchForm(XMPPConnection con, String searchService) throws XMPPException {
|
||||||
UserSearch search = new UserSearch();
|
UserSearch search = new UserSearch();
|
||||||
search.setType(IQ.Type.GET);
|
search.setType(IQ.Type.GET);
|
||||||
search.setTo(searchService);
|
search.setTo(searchService);
|
||||||
|
@ -73,14 +73,14 @@ public class UserSearch extends IQ {
|
||||||
/**
|
/**
|
||||||
* Sends the filled out answer form to be sent and queried by the search service.
|
* Sends the filled out answer form to be sent and queried by the search service.
|
||||||
*
|
*
|
||||||
* @param con the current Connection.
|
* @param con the current XMPPConnection.
|
||||||
* @param searchForm the <code>Form</code> to send for querying.
|
* @param searchForm the <code>Form</code> to send for querying.
|
||||||
* @param searchService the search service to use. (ex. search.jivesoftware.com)
|
* @param searchService the search service to use. (ex. search.jivesoftware.com)
|
||||||
* @return ReportedData the data found from the query.
|
* @return ReportedData the data found from the query.
|
||||||
* @throws org.jivesoftware.smack.XMPPException
|
* @throws org.jivesoftware.smack.XMPPException
|
||||||
* thrown if a server error has occurred.
|
* thrown if a server error has occurred.
|
||||||
*/
|
*/
|
||||||
public ReportedData sendSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
|
public ReportedData sendSearchForm(XMPPConnection con, Form searchForm, String searchService) throws XMPPException {
|
||||||
UserSearch search = new UserSearch();
|
UserSearch search = new UserSearch();
|
||||||
search.setType(IQ.Type.SET);
|
search.setType(IQ.Type.SET);
|
||||||
search.setTo(searchService);
|
search.setTo(searchService);
|
||||||
|
@ -93,14 +93,14 @@ public class UserSearch extends IQ {
|
||||||
/**
|
/**
|
||||||
* Sends the filled out answer form to be sent and queried by the search service.
|
* Sends the filled out answer form to be sent and queried by the search service.
|
||||||
*
|
*
|
||||||
* @param con the current Connection.
|
* @param con the current XMPPConnection.
|
||||||
* @param searchForm the <code>Form</code> to send for querying.
|
* @param searchForm the <code>Form</code> to send for querying.
|
||||||
* @param searchService the search service to use. (ex. search.jivesoftware.com)
|
* @param searchService the search service to use. (ex. search.jivesoftware.com)
|
||||||
* @return ReportedData the data found from the query.
|
* @return ReportedData the data found from the query.
|
||||||
* @throws org.jivesoftware.smack.XMPPException
|
* @throws org.jivesoftware.smack.XMPPException
|
||||||
* thrown if a server error has occurred.
|
* thrown if a server error has occurred.
|
||||||
*/
|
*/
|
||||||
public ReportedData sendSimpleSearchForm(Connection con, Form searchForm, String searchService) throws XMPPException {
|
public ReportedData sendSimpleSearchForm(XMPPConnection con, Form searchForm, String searchService) throws XMPPException {
|
||||||
SimpleUserSearch search = new SimpleUserSearch();
|
SimpleUserSearch search = new SimpleUserSearch();
|
||||||
search.setForm(searchForm);
|
search.setForm(searchForm);
|
||||||
search.setType(IQ.Type.SET);
|
search.setType(IQ.Type.SET);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.search;
|
package org.jivesoftware.smackx.search;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||||
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
||||||
|
@ -34,7 +34,7 @@ import java.util.List;
|
||||||
* searching (DataForms or No DataForms), but allows the user to simply use the DataForm model for both
|
* searching (DataForms or No DataForms), but allows the user to simply use the DataForm model for both
|
||||||
* types of support.
|
* types of support.
|
||||||
* <pre>
|
* <pre>
|
||||||
* Connection con = new TCPConnection("jabber.org");
|
* XMPPConnection con = new TCPConnection("jabber.org");
|
||||||
* con.login("john", "doe");
|
* con.login("john", "doe");
|
||||||
* UserSearchManager search = new UserSearchManager(con, "users.jabber.org");
|
* UserSearchManager search = new UserSearchManager(con, "users.jabber.org");
|
||||||
* Form searchForm = search.getSearchForm();
|
* Form searchForm = search.getSearchForm();
|
||||||
|
@ -48,15 +48,15 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class UserSearchManager {
|
public class UserSearchManager {
|
||||||
|
|
||||||
private Connection con;
|
private XMPPConnection con;
|
||||||
private UserSearch userSearch;
|
private UserSearch userSearch;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new UserSearchManager.
|
* Creates a new UserSearchManager.
|
||||||
*
|
*
|
||||||
* @param con the Connection to use.
|
* @param con the XMPPConnection to use.
|
||||||
*/
|
*/
|
||||||
public UserSearchManager(Connection con) {
|
public UserSearchManager(XMPPConnection con) {
|
||||||
this.con = con;
|
this.con = con;
|
||||||
userSearch = new UserSearch();
|
userSearch = new UserSearch();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.sharedgroups;
|
package org.jivesoftware.smackx.sharedgroups;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smackx.sharedgroups.packet.SharedGroupsInfo;
|
import org.jivesoftware.smackx.sharedgroups.packet.SharedGroupsInfo;
|
||||||
|
@ -40,7 +40,7 @@ public class SharedGroupManager {
|
||||||
* @param connection connection to use to get the user's shared groups.
|
* @param connection connection to use to get the user's shared groups.
|
||||||
* @return collection with the shared groups' name of the logged user.
|
* @return collection with the shared groups' name of the logged user.
|
||||||
*/
|
*/
|
||||||
public static List<String> getSharedGroups(Connection connection) throws XMPPException {
|
public static List<String> getSharedGroups(XMPPConnection connection) throws XMPPException {
|
||||||
// Discover the shared groups of the logged user
|
// Discover the shared groups of the logged user
|
||||||
SharedGroupsInfo info = new SharedGroupsInfo();
|
SharedGroupsInfo info = new SharedGroupsInfo();
|
||||||
info.setType(IQ.Type.GET);
|
info.setType(IQ.Type.GET);
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.time;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
import org.jivesoftware.smack.Manager;
|
import org.jivesoftware.smack.Manager;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
|
@ -35,7 +35,7 @@ import org.jivesoftware.smackx.time.packet.Time;
|
||||||
|
|
||||||
public class EntityTimeManager extends Manager {
|
public class EntityTimeManager extends Manager {
|
||||||
|
|
||||||
private static final Map<Connection, EntityTimeManager> INSTANCES = new WeakHashMap<Connection, EntityTimeManager>();
|
private static final Map<XMPPConnection, EntityTimeManager> INSTANCES = new WeakHashMap<XMPPConnection, EntityTimeManager>();
|
||||||
|
|
||||||
private static final PacketFilter TIME_PACKET_FILTER = new AndFilter(new PacketTypeFilter(
|
private static final PacketFilter TIME_PACKET_FILTER = new AndFilter(new PacketTypeFilter(
|
||||||
Time.class), new IQTypeFilter(Type.GET));
|
Time.class), new IQTypeFilter(Type.GET));
|
||||||
|
@ -43,8 +43,8 @@ public class EntityTimeManager extends Manager {
|
||||||
private static boolean autoEnable = true;
|
private static boolean autoEnable = true;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||||
public void connectionCreated(Connection connection) {
|
public void connectionCreated(XMPPConnection connection) {
|
||||||
getInstanceFor(connection);
|
getInstanceFor(connection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -54,7 +54,7 @@ public class EntityTimeManager extends Manager {
|
||||||
EntityTimeManager.autoEnable = autoEnable;
|
EntityTimeManager.autoEnable = autoEnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized static EntityTimeManager getInstanceFor(Connection connection) {
|
public synchronized static EntityTimeManager getInstanceFor(XMPPConnection connection) {
|
||||||
EntityTimeManager entityTimeManager = INSTANCES.get(connection);
|
EntityTimeManager entityTimeManager = INSTANCES.get(connection);
|
||||||
if (entityTimeManager == null) {
|
if (entityTimeManager == null) {
|
||||||
entityTimeManager = new EntityTimeManager(connection);
|
entityTimeManager = new EntityTimeManager(connection);
|
||||||
|
@ -64,7 +64,7 @@ public class EntityTimeManager extends Manager {
|
||||||
|
|
||||||
private boolean enabled = false;
|
private boolean enabled = false;
|
||||||
|
|
||||||
private EntityTimeManager(Connection connection) {
|
private EntityTimeManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
INSTANCES.put(connection, this);
|
INSTANCES.put(connection, this);
|
||||||
if (autoEnable)
|
if (autoEnable)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue