mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Renamed Connection to XMPPConnection
This commit is contained in:
parent
f3e007bad5
commit
489816c61f
145 changed files with 639 additions and 641 deletions
|
@ -51,7 +51,7 @@ public class CompressionTest extends SmackTestCase {
|
|||
// Login with the test account
|
||||
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
|
||||
Version version = new Version();
|
||||
|
|
|
@ -60,7 +60,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc);
|
||||
|
||||
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);
|
||||
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info1);
|
||||
assertFalse("Message 1 should be 'replyable'", info1.shouldNotReply());
|
||||
|
@ -74,7 +74,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
assertEquals("Incorrect CC address", getBareJID(2), address1);
|
||||
|
||||
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);
|
||||
assertNotNull("Message 2 does not contain MultipleRecipientInfo", info2);
|
||||
assertFalse("Message 2 should be 'replyable'", info2.shouldNotReply());
|
||||
|
@ -88,7 +88,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
assertEquals("Incorrect CC address", getBareJID(2), address2);
|
||||
|
||||
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);
|
||||
assertNotNull("Message 3 does not contain MultipleRecipientInfo", info3);
|
||||
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
|
||||
Message message1 =
|
||||
(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);
|
||||
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info);
|
||||
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
|
||||
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);
|
||||
assertNotNull("Replied message does not contain MultipleRecipientInfo", info);
|
||||
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
|
||||
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);
|
||||
assertNotNull("Replied message does not contain MultipleRecipientInfo", info);
|
||||
assertFalse("Replied message should be 'replyable'", info.shouldNotReply());
|
||||
|
@ -168,19 +168,19 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
|
||||
// Check that connection2 recevied 3 messages
|
||||
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());
|
||||
assertNotNull("Connection2 didn't receive the 2 message", message1);
|
||||
assertNotNull("XMPPConnection2 didn't receive the 2 message", message1);
|
||||
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());
|
||||
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)
|
||||
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());
|
||||
assertNull("Connection2 received 2 messages", message1);
|
||||
assertNull("XMPPConnection2 received 2 messages", message1);
|
||||
|
||||
collector0.cancel();
|
||||
collector1.cancel();
|
||||
|
@ -210,7 +210,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
// Get the message and ensure it's ok
|
||||
Message message1 =
|
||||
(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);
|
||||
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info);
|
||||
assertTrue("Message 1 should be not 'replyable'", info.shouldNotReply());
|
||||
|
@ -230,15 +230,15 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
|
||||
// Check that connection2 recevied 1 messages
|
||||
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());
|
||||
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)
|
||||
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());
|
||||
assertNull("Connection2 received 2 messages", message1);
|
||||
assertNull("XMPPConnection2 received 2 messages", message1);
|
||||
|
||||
collector1.cancel();
|
||||
collector2.cancel();
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.io.OutputStream;
|
|||
import java.util.Random;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
|
@ -53,9 +53,9 @@ public class InBandBytestreamTest extends SmackTestCase {
|
|||
* @throws XMPPException should not happen
|
||||
*/
|
||||
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.setFrom(initiatorConnection.getUser());
|
||||
|
@ -78,8 +78,8 @@ public class InBandBytestreamTest extends SmackTestCase {
|
|||
*/
|
||||
public void testInBandBytestreamWithIQStanzas() throws Exception {
|
||||
|
||||
Connection initiatorConnection = getConnection(0);
|
||||
Connection targetConnection = getConnection(1);
|
||||
XMPPConnection initiatorConnection = getConnection(0);
|
||||
XMPPConnection targetConnection = getConnection(1);
|
||||
|
||||
// test data
|
||||
Random rand = new Random();
|
||||
|
@ -132,8 +132,8 @@ public class InBandBytestreamTest extends SmackTestCase {
|
|||
*/
|
||||
public void testInBandBytestreamWithMessageStanzas() throws Exception {
|
||||
|
||||
Connection initiatorConnection = getConnection(0);
|
||||
Connection targetConnection = getConnection(1);
|
||||
XMPPConnection initiatorConnection = getConnection(0);
|
||||
XMPPConnection targetConnection = getConnection(1);
|
||||
|
||||
// test data
|
||||
Random rand = new Random();
|
||||
|
@ -188,9 +188,9 @@ public class InBandBytestreamTest extends SmackTestCase {
|
|||
*/
|
||||
public void testBiDirectionalInBandBytestream() throws Exception {
|
||||
|
||||
Connection initiatorConnection = getConnection(0);
|
||||
XMPPConnection initiatorConnection = getConnection(0);
|
||||
|
||||
Connection targetConnection = getConnection(1);
|
||||
XMPPConnection targetConnection = getConnection(1);
|
||||
|
||||
// test data
|
||||
Random rand = new Random();
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.concurrent.SynchronousQueue;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
@ -60,7 +60,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
|||
* @throws XMPPException should not happen
|
||||
*/
|
||||
public void testInitializationSocks5FeaturesAndListenerOnStartup() throws XMPPException {
|
||||
Connection connection = getConnection(0);
|
||||
XMPPConnection connection = getConnection(0);
|
||||
|
||||
assertTrue(ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(
|
||||
Socks5BytestreamManager.NAMESPACE));
|
||||
|
@ -74,9 +74,9 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
|||
* @throws XMPPException should not happen
|
||||
*/
|
||||
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(
|
||||
initiatorConnection.getUser(), targetConnection.getUser(), "session_id");
|
||||
|
@ -107,8 +107,8 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
|||
|
||||
assertTrue(socks5Proxy.isRunning());
|
||||
|
||||
Connection initiatorConnection = getConnection(0);
|
||||
Connection targetConnection = getConnection(1);
|
||||
XMPPConnection initiatorConnection = getConnection(0);
|
||||
XMPPConnection targetConnection = getConnection(1);
|
||||
|
||||
// test data
|
||||
final byte[] data = new byte[] { 1, 2, 3 };
|
||||
|
@ -174,8 +174,8 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
|||
|
||||
assertFalse(Socks5Proxy.getSocks5Proxy().isRunning());
|
||||
|
||||
Connection initiatorConnection = getConnection(0);
|
||||
Connection targetConnection = getConnection(1);
|
||||
XMPPConnection initiatorConnection = getConnection(0);
|
||||
XMPPConnection targetConnection = getConnection(1);
|
||||
|
||||
// test data
|
||||
final byte[] data = new byte[] { 1, 2, 3 };
|
||||
|
@ -243,7 +243,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
|||
*/
|
||||
public void testBiDirectionalSocks5BytestreamWithRemoteSocks5Proxy() throws Exception {
|
||||
|
||||
Connection initiatorConnection = getConnection(0);
|
||||
XMPPConnection initiatorConnection = getConnection(0);
|
||||
|
||||
// disable local socks5 proxy
|
||||
SmackConfiguration.setLocalSocks5ProxyEnabled(false);
|
||||
|
@ -251,7 +251,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
|
|||
|
||||
assertFalse(Socks5Proxy.getSocks5Proxy().isRunning());
|
||||
|
||||
Connection targetConnection = getConnection(1);
|
||||
XMPPConnection targetConnection = getConnection(1);
|
||||
|
||||
// test data
|
||||
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.ChatManagerListener;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionConfiguration;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
|
@ -263,7 +263,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
|||
// User3 is listening to MUC invitations
|
||||
MultiUserChat.addInvitationListener(getConnection(2), new InvitationListener() {
|
||||
public void invitationReceived(
|
||||
Connection conn,
|
||||
XMPPConnection conn,
|
||||
String room,
|
||||
String inviter,
|
||||
String reason,
|
||||
|
@ -313,7 +313,7 @@ public class MultiUserChatTest extends SmackTestCase {
|
|||
// User3 is listening to MUC invitations
|
||||
MultiUserChat.addInvitationListener(getConnection(2), new InvitationListener() {
|
||||
public void invitationReceived(
|
||||
Connection conn,
|
||||
XMPPConnection conn,
|
||||
String room,
|
||||
String inviter,
|
||||
String reason,
|
||||
|
|
|
@ -71,7 +71,7 @@ public class MultipleRecipientInfo {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return true if the received packet should not be replied.
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.address;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
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
|
||||
* 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 {
|
||||
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
|
||||
* 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 serviceAddress = getMultipleRecipienServiceAddress(connection);
|
||||
if (serviceAddress != null) {
|
||||
|
@ -128,7 +128,7 @@ public class MultipleRecipientManager {
|
|||
* @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.
|
||||
*/
|
||||
public static void reply(Connection connection, Message original, Message reply)
|
||||
public static void reply(XMPPConnection connection, Message original, Message reply)
|
||||
throws XMPPException {
|
||||
MultipleRecipientInfo info = getMultipleRecipientInfo(original);
|
||||
if (info == null) {
|
||||
|
@ -202,7 +202,7 @@ public class MultipleRecipientManager {
|
|||
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) {
|
||||
if (to != null) {
|
||||
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,
|
||||
String serviceAddress) {
|
||||
// Create multiple recipient extension
|
||||
|
@ -281,7 +281,7 @@ public class MultipleRecipientManager {
|
|||
* queried.
|
||||
* @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 serviceAddress = (String) services.get(serviceName);
|
||||
if (serviceAddress == null) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.amp;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
|
||||
public class AMPDeliverCondition implements AMPExtension.Condition {
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class AMPDeliverCondition implements AMPExtension.Condition {
|
|||
* @param connection Smack connection instance
|
||||
* @return true if deliver condition is supported.
|
||||
*/
|
||||
public static boolean isSupported(Connection connection) {
|
||||
public static boolean isSupported(XMPPConnection connection) {
|
||||
return AMPManager.isConditionSupported(connection, NAME);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.amp;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.util.XmppDateTime;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -31,7 +31,7 @@ public class AMPExpireAtCondition implements AMPExtension.Condition {
|
|||
* @param connection Smack connection instance
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.amp;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
|
@ -38,8 +38,8 @@ public class AMPManager {
|
|||
// Enable the AMP support on every established connection
|
||||
// The ServiceDiscoveryManager class should have been already initialized
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
AMPManager.setServiceEnabled(connection, true);
|
||||
}
|
||||
});
|
||||
|
@ -54,7 +54,7 @@ public class AMPManager {
|
|||
* @param connection the connection where 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)
|
||||
return;
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class AMPManager {
|
|||
* @param connection the connection to look for AMP support
|
||||
* @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();
|
||||
return ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(AMPExtension.NAMESPACE);
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class AMPManager {
|
|||
* @param action action to check
|
||||
* @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();
|
||||
return isFeatureSupportedByServer(connection, featureName, AMPExtension.NAMESPACE);
|
||||
}
|
||||
|
@ -97,12 +97,12 @@ public class AMPManager {
|
|||
* @see AMPExpireAtCondition
|
||||
* @see AMPMatchResourceCondition
|
||||
*/
|
||||
public static boolean isConditionSupported(Connection connection, String conditionName) {
|
||||
public static boolean isConditionSupported(XMPPConnection connection, String conditionName) {
|
||||
String featureName = AMPExtension.NAMESPACE + "?condition=" + conditionName;
|
||||
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 {
|
||||
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
DiscoverInfo info = discoveryManager.discoverInfo(connection.getServiceName(), node);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.amp;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
|
||||
public class AMPMatchResourceCondition implements AMPExtension.Condition {
|
||||
|
||||
|
@ -27,7 +27,7 @@ public class AMPMatchResourceCondition implements AMPExtension.Condition {
|
|||
* @param connection Smack connection instance
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.bookmarks;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.iqprivate.PrivateDataManager;
|
||||
|
||||
|
@ -34,7 +34,7 @@ import java.util.*;
|
|||
* @author Alexander Wenckus
|
||||
*/
|
||||
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 {
|
||||
PrivateDataManager.addPrivateDataProvider("storage", "storage:bookmarks",
|
||||
new Bookmarks.Provider());
|
||||
|
@ -48,7 +48,7 @@ public class BookmarkManager {
|
|||
* exist it is created.
|
||||
* @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
|
||||
{
|
||||
BookmarkManager manager = (BookmarkManager) bookmarkManagerMap.get(connection);
|
||||
|
@ -70,7 +70,7 @@ public class BookmarkManager {
|
|||
* @param connection the connection for persisting and retrieving bookmarks.
|
||||
* @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()) {
|
||||
throw new XMPPException("Invalid connection.");
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.List;
|
|||
* See the following code sample for saving Bookmarks:
|
||||
* <p/>
|
||||
* <pre>
|
||||
* Connection con = new TCPConnection("jabber.org");
|
||||
* XMPPConnection con = new TCPConnection("jabber.org");
|
||||
* con.login("john", "doe");
|
||||
* Bookmarks bookmarks = new Bookmarks();
|
||||
* <p/>
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Random;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -96,8 +96,8 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
* connection
|
||||
*/
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(final Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(final XMPPConnection connection) {
|
||||
// create the manager for this connection
|
||||
InBandBytestreamManager.getByteStreamManager(connection);
|
||||
|
||||
|
@ -143,10 +143,10 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
private final static Random randomGenerator = new Random();
|
||||
|
||||
/* 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 */
|
||||
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
|
||||
|
@ -189,12 +189,12 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
|
||||
/**
|
||||
* Returns the InBandBytestreamManager to handle In-Band Bytestreams for a given
|
||||
* {@link Connection}.
|
||||
* {@link XMPPConnection}.
|
||||
*
|
||||
* @param connection the 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)
|
||||
return null;
|
||||
InBandBytestreamManager manager = managers.get(connection);
|
||||
|
@ -210,7 +210,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @param connection the XMPP connection
|
||||
*/
|
||||
private InBandBytestreamManager(Connection connection) {
|
||||
private InBandBytestreamManager(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
|
||||
// register bytestream open packet listener
|
||||
|
@ -489,7 +489,7 @@ public class InBandBytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @return the XMPP connection
|
||||
*/
|
||||
protected Connection getConnection() {
|
||||
protected XMPPConnection getConnection() {
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
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.packet.IQ;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
||||
|
@ -70,7 +70,7 @@ public class InBandBytestreamRequest implements BytestreamRequest {
|
|||
* @throws XMPPException if stream is invalid.
|
||||
*/
|
||||
public InBandBytestreamSession accept() throws XMPPException {
|
||||
Connection connection = this.manager.getConnection();
|
||||
XMPPConnection connection = this.manager.getConnection();
|
||||
|
||||
// create In-Band Bytestream session and store it
|
||||
InBandBytestreamSession ibbSession = new InBandBytestreamSession(connection,
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.concurrent.BlockingQueue;
|
|||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
|
@ -58,7 +58,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
|||
public class InBandBytestreamSession implements BytestreamSession {
|
||||
|
||||
/* XMPP connection */
|
||||
private final Connection connection;
|
||||
private final XMPPConnection connection;
|
||||
|
||||
/* the In-Band Bytestream open request for this session */
|
||||
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 remoteJID JID of the remote peer
|
||||
*/
|
||||
protected InBandBytestreamSession(Connection connection, Open byteStreamRequest,
|
||||
protected InBandBytestreamSession(XMPPConnection connection, Open byteStreamRequest,
|
||||
String remoteJID) {
|
||||
this.connection = connection;
|
||||
this.byteStreamRequest = byteStreamRequest;
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jivesoftware.smack.AbstractConnectionListener;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -89,9 +89,9 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
* connection
|
||||
*/
|
||||
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
|
||||
Socks5BytestreamManager.getBytestreamManager(connection);
|
||||
|
||||
|
@ -132,10 +132,10 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
private final static Random randomGenerator = new Random();
|
||||
|
||||
/* 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 */
|
||||
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
|
||||
|
@ -175,7 +175,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
|
||||
/**
|
||||
* Returns the Socks5BytestreamManager to handle SOCKS5 Bytestreams for a given
|
||||
* {@link Connection}.
|
||||
* {@link XMPPConnection}.
|
||||
* <p>
|
||||
* If no manager exists a new is created and initialized.
|
||||
*
|
||||
|
@ -183,7 +183,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
* <code>null</code>
|
||||
* @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) {
|
||||
return null;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @param connection the XMPP connection
|
||||
*/
|
||||
private Socks5BytestreamManager(Connection connection) {
|
||||
private Socks5BytestreamManager(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
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
|
||||
* resetting its internal state, which includes removing this instance from the managers map.
|
||||
* <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.
|
||||
*/
|
||||
public synchronized void disableService() {
|
||||
|
@ -745,7 +745,7 @@ public final class Socks5BytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @return the XMPP connection
|
||||
*/
|
||||
protected Connection getConnection() {
|
||||
protected XMPPConnection getConnection() {
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.io.IOException;
|
|||
import java.net.Socket;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
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 {
|
||||
|
||||
/* the XMPP connection used to communicate with the SOCKS5 proxy */
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
/* the session ID used to activate SOCKS5 stream */
|
||||
private String sessionID;
|
||||
|
@ -54,7 +54,7 @@ class Socks5ClientForInitiator extends Socks5Client {
|
|||
* @param sessionID the session ID 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) {
|
||||
super(streamHost, digest);
|
||||
this.connection = connection;
|
||||
|
|
|
@ -452,7 +452,7 @@ public class Socks5Proxy {
|
|||
out.write(connectionRequest);
|
||||
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)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.caps;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
|
@ -79,8 +79,8 @@ public class EntityCapsManager extends Manager {
|
|||
|
||||
private static boolean autoEnableEntityCaps = true;
|
||||
|
||||
private static Map<Connection, EntityCapsManager> instances = Collections
|
||||
.synchronizedMap(new WeakHashMap<Connection, EntityCapsManager>());
|
||||
private static Map<XMPPConnection, EntityCapsManager> instances = Collections
|
||||
.synchronizedMap(new WeakHashMap<XMPPConnection, EntityCapsManager>());
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
});
|
||||
|
@ -219,7 +219,7 @@ public class EntityCapsManager extends Manager {
|
|||
((Cache) caps).setMaxCacheSize(maxCacheSize);
|
||||
}
|
||||
|
||||
private EntityCapsManager(Connection connection) {
|
||||
private EntityCapsManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
this.sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
instances.put(connection, this);
|
||||
|
@ -317,7 +317,7 @@ public class EntityCapsManager extends Manager {
|
|||
sdm.setEntityCapsManager(this);
|
||||
}
|
||||
|
||||
public static synchronized EntityCapsManager getInstanceFor(Connection connection) {
|
||||
public static synchronized EntityCapsManager getInstanceFor(XMPPConnection connection) {
|
||||
if (SUPPORTED_HASHES.size() <= 0)
|
||||
throw new IllegalStateException("No supported hashes for EntityCapsManager");
|
||||
|
||||
|
@ -413,7 +413,7 @@ public class EntityCapsManager extends Manager {
|
|||
* the local users extended info
|
||||
*/
|
||||
public void updateLocalEntityCaps() {
|
||||
Connection connection = connection();
|
||||
XMPPConnection connection = connection();
|
||||
|
||||
DiscoverInfo discoverInfo = new DiscoverInfo();
|
||||
discoverInfo.setType(IQ.Type.RESULT);
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.WeakHashMap;
|
|||
|
||||
import org.jivesoftware.smack.Chat;
|
||||
import org.jivesoftware.smack.ChatManagerListener;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.MessageListener;
|
||||
import org.jivesoftware.smack.PacketInterceptor;
|
||||
|
@ -38,11 +38,11 @@ import org.jivesoftware.smackx.chatstates.packet.ChatStateExtension;
|
|||
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
|
||||
* <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.
|
||||
* 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 static final String NAMESPACE = "http://jabber.org/protocol/chatstates";
|
||||
|
||||
private static final Map<Connection, ChatStateManager> INSTANCES =
|
||||
new WeakHashMap<Connection, ChatStateManager>();
|
||||
private static final Map<XMPPConnection, ChatStateManager> INSTANCES =
|
||||
new WeakHashMap<XMPPConnection, ChatStateManager>();
|
||||
|
||||
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.
|
||||
*
|
||||
* @param connection the connection to return the ChatStateManager
|
||||
* @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);
|
||||
if (manager == null) {
|
||||
manager = new ChatStateManager(connection);
|
||||
|
@ -83,7 +83,7 @@ public class ChatStateManager extends Manager {
|
|||
private final Map<Chat, ChatState> chatStates =
|
||||
new ReferenceMap<Chat, ChatState>(ReferenceMap.WEAK, ReferenceMap.HARD);
|
||||
|
||||
private ChatStateManager(Connection connection) {
|
||||
private ChatStateManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
connection.getChatManager().addOutgoingMessageInterceptor(outgoingInterceptor, filter);
|
||||
connection.getChatManager().addChatListener(incomingInterceptor);
|
||||
|
|
|
@ -47,8 +47,8 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
* An AdHocCommandManager is responsible for keeping the list of available
|
||||
* commands offered by a service and for processing commands requests.
|
||||
*
|
||||
* Pass in a Connection instance to
|
||||
* {@link #getAddHocCommandsManager(org.jivesoftware.smack.Connection)} in order to
|
||||
* Pass in a XMPPConnection instance to
|
||||
* {@link #getAddHocCommandsManager(org.jivesoftware.smack.XMPPConnection)} in order to
|
||||
* get an instance of this class.
|
||||
*
|
||||
* @author Gabriel Guardincerri
|
||||
|
@ -62,11 +62,11 @@ public class AdHocCommandManager extends Manager {
|
|||
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.
|
||||
*/
|
||||
private static Map<Connection, AdHocCommandManager> instances =
|
||||
Collections.synchronizedMap(new WeakHashMap<Connection, AdHocCommandManager>());
|
||||
private static Map<XMPPConnection, AdHocCommandManager> instances =
|
||||
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, AdHocCommandManager>());
|
||||
|
||||
/**
|
||||
* Register the listener for all the connection creations. When a new
|
||||
|
@ -74,8 +74,8 @@ public class AdHocCommandManager extends Manager {
|
|||
* related to that connection.
|
||||
*/
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getAddHocCommandsManager(connection);
|
||||
}
|
||||
});
|
||||
|
@ -88,7 +88,7 @@ public class AdHocCommandManager extends Manager {
|
|||
* @param connection the XMPP 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);
|
||||
if (ahcm == null) ahcm = new AdHocCommandManager(connection);
|
||||
return ahcm;
|
||||
|
@ -116,7 +116,7 @@ public class AdHocCommandManager extends Manager {
|
|||
*/
|
||||
private Thread sessionsSweeper;
|
||||
|
||||
private AdHocCommandManager(Connection connection) {
|
||||
private AdHocCommandManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
this.serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.jivesoftware.smackx.commands;
|
||||
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
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
|
||||
*/
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* The full JID of the command host
|
||||
|
@ -71,7 +71,7 @@ public class RemoteCommand extends AdHocCommand {
|
|||
* @param node the identifier of the command.
|
||||
* @param jid the JID of the host.
|
||||
*/
|
||||
protected RemoteCommand(Connection connection, String node, String jid) {
|
||||
protected RemoteCommand(XMPPConnection connection, String node, String jid) {
|
||||
super();
|
||||
this.connection = connection;
|
||||
this.jid = jid;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.disco;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
|
@ -69,8 +69,8 @@ public class ServiceDiscoveryManager extends Manager {
|
|||
|
||||
private EntityCapsManager capsManager;
|
||||
|
||||
private static Map<Connection, ServiceDiscoveryManager> instances =
|
||||
Collections.synchronizedMap(new WeakHashMap<Connection, ServiceDiscoveryManager>());
|
||||
private static Map<XMPPConnection, ServiceDiscoveryManager> instances =
|
||||
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, ServiceDiscoveryManager>());
|
||||
|
||||
private final Set<String> features = new HashSet<String>();
|
||||
private DataForm extendedInfo = null;
|
||||
|
@ -79,8 +79,8 @@ public class ServiceDiscoveryManager extends Manager {
|
|||
|
||||
// Create a new ServiceDiscoveryManager on every established connection
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection 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
|
||||
* receive.
|
||||
*
|
||||
* @param connection the connection to which a ServiceDiscoveryManager is going to be created.
|
||||
*/
|
||||
private ServiceDiscoveryManager(Connection connection) {
|
||||
private ServiceDiscoveryManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
// Register the new instance and associate it with the connection
|
||||
instances.put(connection, this);
|
||||
|
@ -115,7 +115,7 @@ public class ServiceDiscoveryManager extends Manager {
|
|||
PacketFilter packetFilter = new PacketTypeFilter(DiscoverItems.class);
|
||||
PacketListener packetListener = new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
Connection connection = connection();
|
||||
XMPPConnection connection = connection();
|
||||
if (connection == null) return;
|
||||
DiscoverItems discoverItems = (DiscoverItems) packet;
|
||||
// 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);
|
||||
packetListener = new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
Connection connection = connection();
|
||||
XMPPConnection connection = connection();
|
||||
if (connection == null) return;
|
||||
DiscoverInfo discoverInfo = (DiscoverInfo) packet;
|
||||
// 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.
|
||||
* @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);
|
||||
if (sdm == null) {
|
||||
sdm = new ServiceDiscoveryManager(connection);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.filetransfer;
|
||||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.OrFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
|
@ -40,11 +40,11 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
|
||||
private StreamNegotiator primaryNegotiator;
|
||||
private StreamNegotiator secondaryNegotiator;
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
private PacketFilter primaryFilter;
|
||||
private PacketFilter secondaryFilter;
|
||||
|
||||
public FaultTolerantNegotiator(Connection connection, StreamNegotiator primary,
|
||||
public FaultTolerantNegotiator(XMPPConnection connection, StreamNegotiator primary,
|
||||
StreamNegotiator secondary) {
|
||||
this.primaryNegotiator = primary;
|
||||
this.secondaryNegotiator = secondary;
|
||||
|
@ -64,7 +64,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
"stream method.");
|
||||
}
|
||||
|
||||
final Packet initiateIncomingStream(Connection connection, StreamInitiation initiation) {
|
||||
final Packet initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) {
|
||||
throw new UnsupportedOperationException("Initiation handled by createIncomingStream " +
|
||||
"method");
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.filetransfer;
|
||||
|
||||
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.IQTypeFilter;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
|
@ -48,15 +48,15 @@ public class FileTransferManager {
|
|||
|
||||
private List<FileTransferListener> listeners;
|
||||
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* Creates a file transfer manager to initiate and receive file transfers.
|
||||
*
|
||||
* @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.fileTransferNegotiator = FileTransferNegotiator
|
||||
.getInstanceFor(connection);
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
|||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
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"};
|
||||
|
||||
private static final Map<Connection, FileTransferNegotiator> transferObject =
|
||||
new ConcurrentHashMap<Connection, FileTransferNegotiator>();
|
||||
private static final Map<XMPPConnection, FileTransferNegotiator> transferObject =
|
||||
new ConcurrentHashMap<XMPPConnection, FileTransferNegotiator>();
|
||||
|
||||
private static final String STREAM_INIT_PREFIX = "jsi_";
|
||||
|
||||
|
@ -83,9 +83,9 @@ public class FileTransferNegotiator {
|
|||
* @return The IMFileTransferManager
|
||||
*/
|
||||
public static FileTransferNegotiator getInstanceFor(
|
||||
final Connection connection) {
|
||||
final XMPPConnection connection) {
|
||||
if (connection == null) {
|
||||
throw new IllegalArgumentException("Connection cannot be null");
|
||||
throw new IllegalArgumentException("XMPPConnection cannot be null");
|
||||
}
|
||||
if (!connection.isConnected()) {
|
||||
return null;
|
||||
|
@ -110,7 +110,7 @@ public class FileTransferNegotiator {
|
|||
* @param connection The connection on which to enable or disable the services.
|
||||
* @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) {
|
||||
ServiceDiscoveryManager manager = ServiceDiscoveryManager
|
||||
.getInstanceFor(connection);
|
||||
|
@ -141,7 +141,7 @@ public class FileTransferNegotiator {
|
|||
* @param connection The connection to check
|
||||
* @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
|
||||
.getInstanceFor(connection);
|
||||
|
||||
|
@ -200,13 +200,13 @@ public class FileTransferNegotiator {
|
|||
|
||||
// non-static
|
||||
|
||||
private final Connection connection;
|
||||
private final XMPPConnection connection;
|
||||
|
||||
private final StreamNegotiator byteStreamTransferManager;
|
||||
|
||||
private final StreamNegotiator inbandTransferManager;
|
||||
|
||||
private FileTransferNegotiator(final Connection connection) {
|
||||
private FileTransferNegotiator(final XMPPConnection connection) {
|
||||
configureConnection(connection);
|
||||
|
||||
this.connection = connection;
|
||||
|
@ -214,7 +214,7 @@ public class FileTransferNegotiator {
|
|||
inbandTransferManager = new IBBTransferNegotiator(connection);
|
||||
}
|
||||
|
||||
private void configureConnection(final Connection connection) {
|
||||
private void configureConnection(final XMPPConnection connection) {
|
||||
connection.addConnectionListener(new ConnectionListener() {
|
||||
public void connectionClosed() {
|
||||
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) {
|
||||
inbandTransferManager.cleanup();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.filetransfer;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
||||
|
@ -45,7 +45,7 @@ import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
|||
*/
|
||||
public class IBBTransferNegotiator extends StreamNegotiator {
|
||||
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
private InBandBytestreamManager manager;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
|||
*
|
||||
* @param connection The connection which this negotiator works on.
|
||||
*/
|
||||
protected IBBTransferNegotiator(Connection connection) {
|
||||
protected IBBTransferNegotiator(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
this.manager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.io.PushbackInputStream;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.FromMatchesFilter;
|
||||
|
@ -44,11 +44,11 @@ import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
|||
*/
|
||||
public class Socks5TransferNegotiator extends StreamNegotiator {
|
||||
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
private Socks5BytestreamManager manager;
|
||||
|
||||
Socks5TransferNegotiator(Connection connection) {
|
||||
Socks5TransferNegotiator(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
this.manager = Socks5BytestreamManager.getBytestreamManager(this.connection);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.filetransfer;
|
||||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -77,7 +77,7 @@ public abstract class StreamNegotiator {
|
|||
return iq;
|
||||
}
|
||||
|
||||
Packet initiateIncomingStream(Connection connection, StreamInitiation initiation) throws XMPPException {
|
||||
Packet initiateIncomingStream(XMPPConnection connection, StreamInitiation initiation) throws XMPPException {
|
||||
StreamInitiation response = createInitiationAccept(initiation,
|
||||
getNamespaces());
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.iqlast;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
|
@ -54,7 +54,7 @@ import org.jivesoftware.smackx.iqlast.packet.LastActivity;
|
|||
* <p>
|
||||
*
|
||||
* <pre>
|
||||
* Connection con = new TCPConnection("jabber.org");
|
||||
* XMPPConnection con = new TCPConnection("jabber.org");
|
||||
* con.login("john", "doe");
|
||||
* LastActivity activity = LastActivity.getLastActivity(con, "xray@jabber.org/Smack");
|
||||
* </pre>
|
||||
|
@ -83,12 +83,12 @@ public class LastActivityManager {
|
|||
|
||||
private long lastMessageSent;
|
||||
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
// Enable the LastActivity support on every established connection
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
new LastActivityManager(connection);
|
||||
}
|
||||
});
|
||||
|
@ -98,9 +98,9 @@ public class LastActivityManager {
|
|||
* Creates a last activity manager to response last activity requests.
|
||||
*
|
||||
* @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;
|
||||
|
||||
// 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.
|
||||
*
|
||||
* @param con
|
||||
* the current Connection.
|
||||
* the current XMPPConnection.
|
||||
* @param jid
|
||||
* the JID of the user.
|
||||
* @return the LastActivity packet of the jid.
|
||||
* @throws XMPPException
|
||||
* 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();
|
||||
activity.setTo(jid);
|
||||
|
||||
|
@ -207,7 +207,7 @@ public class LastActivityManager {
|
|||
* @param jid a JID to be tested for Last Activity support
|
||||
* @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 {
|
||||
DiscoverInfo result =
|
||||
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.iqlast.packet;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
|
@ -128,14 +128,14 @@ public class LastActivity extends IQ {
|
|||
|
||||
/**
|
||||
* 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.
|
||||
* @return the LastActivity packet of the jid.
|
||||
* @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.
|
||||
* 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();
|
||||
jid = StringUtils.parseBareAddress(jid);
|
||||
activity.setTo(jid);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.iqprivate;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
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
|
||||
|
@ -129,7 +129,7 @@ public class PrivateDataManager {
|
|||
* @param connection an XMPP connection which must have already undergone a
|
||||
* successful login.
|
||||
*/
|
||||
public PrivateDataManager(Connection connection) {
|
||||
public PrivateDataManager(XMPPConnection connection) {
|
||||
if (!connection.isAuthenticated()) {
|
||||
throw new IllegalStateException("Must be logged in to XMPP server.");
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public class PrivateDataManager {
|
|||
* successful login.
|
||||
* @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()) {
|
||||
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.WeakHashMap;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
|
@ -49,12 +49,12 @@ import org.jivesoftware.smackx.iqversion.packet.Version;
|
|||
* @author Georg Lukas
|
||||
*/
|
||||
public class VersionManager extends Manager {
|
||||
private static final Map<Connection, VersionManager> instances =
|
||||
Collections.synchronizedMap(new WeakHashMap<Connection, VersionManager>());
|
||||
private static final Map<XMPPConnection, VersionManager> instances =
|
||||
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, VersionManager>());
|
||||
|
||||
private Version own_version;
|
||||
|
||||
private VersionManager(final Connection connection) {
|
||||
private VersionManager(final XMPPConnection connection) {
|
||||
super(connection);
|
||||
instances.put(connection, this);
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class VersionManager extends Manager {
|
|||
, 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);
|
||||
|
||||
if (versionManager == null) {
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
* 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
|
||||
* {@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
|
||||
* {@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)}.
|
||||
*
|
||||
* @author Gaston Dombiak
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.muc;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
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
|
||||
* 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 inviter the inviter that sent the invitation. (e.g. crone1@shakespeare.lit).
|
||||
* @param reason the reason why the inviter sent the invitation.
|
||||
* @param password the password to use when joining the room.
|
||||
* @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);
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.jivesoftware.smack.PacketCollector;
|
|||
import org.jivesoftware.smack.PacketInterceptor;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
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 discoNode = "http://jabber.org/protocol/muc#rooms";
|
||||
|
||||
private static Map<Connection, List<String>> joinedRooms =
|
||||
new WeakHashMap<Connection, List<String>>();
|
||||
private static Map<XMPPConnection, List<String>> joinedRooms =
|
||||
new WeakHashMap<XMPPConnection, List<String>>();
|
||||
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
private String room;
|
||||
private String subject;
|
||||
private String nickname = null;
|
||||
|
@ -107,8 +107,8 @@ public class MultiUserChat {
|
|||
private List<PacketListener> connectionListeners = new ArrayList<PacketListener>();
|
||||
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(final Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(final XMPPConnection connection) {
|
||||
// Set on every established connection that this client supports the Multi-User
|
||||
// Chat protocol. This information will be used when another client tries to
|
||||
// discover whether this client supports MUC or not.
|
||||
|
@ -116,12 +116,12 @@ public class MultiUserChat {
|
|||
|
||||
// Set the NodeInformationProvider that will provide information about the
|
||||
// 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(
|
||||
discoNode,
|
||||
new NodeInformationProvider() {
|
||||
public List<DiscoverItems.Item> getNodeItems() {
|
||||
Connection connection = weakRefConnection.get();
|
||||
XMPPConnection connection = weakRefConnection.get();
|
||||
if (connection == null) return new LinkedList<DiscoverItems.Item>();
|
||||
List<DiscoverItems.Item> answer = new ArrayList<DiscoverItems.Item>();
|
||||
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 running. Make sure to provide a valid JID.
|
||||
*/
|
||||
public MultiUserChat(Connection connection, String room) {
|
||||
public MultiUserChat(XMPPConnection connection, String room) {
|
||||
this.connection = connection;
|
||||
this.room = room.toLowerCase();
|
||||
init();
|
||||
|
@ -176,7 +176,7 @@ public class MultiUserChat {
|
|||
* @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.
|
||||
*/
|
||||
public static boolean isServiceEnabled(Connection connection, String user) {
|
||||
public static boolean isServiceEnabled(XMPPConnection connection, String user) {
|
||||
try {
|
||||
DiscoverInfo result =
|
||||
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(user);
|
||||
|
@ -196,7 +196,7 @@ public class MultiUserChat {
|
|||
* @param connection the connection used to join the rooms.
|
||||
* @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);
|
||||
if (rooms != null) {
|
||||
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.
|
||||
* @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 {
|
||||
ArrayList<String> answer = new ArrayList<String>();
|
||||
// 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.
|
||||
* @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 {
|
||||
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(room);
|
||||
return new RoomInfo(info);
|
||||
|
@ -255,7 +255,7 @@ public class MultiUserChat {
|
|||
* @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.
|
||||
*/
|
||||
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>();
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
|
||||
|
@ -285,7 +285,7 @@ public class MultiUserChat {
|
|||
* @return a collection of HostedRooms.
|
||||
* @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 {
|
||||
List<HostedRoom> answer = new ArrayList<HostedRoom>();
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
@ -689,7 +689,7 @@ public class MultiUserChat {
|
|||
* @param inviter the inviter of the declined 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);
|
||||
|
||||
// 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 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);
|
||||
}
|
||||
|
||||
|
@ -722,7 +722,7 @@ public class MultiUserChat {
|
|||
* @param conn the connection where the listener was applied.
|
||||
* @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);
|
||||
}
|
||||
|
||||
|
@ -1661,7 +1661,7 @@ public class MultiUserChat {
|
|||
* 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
|
||||
* 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.
|
||||
*
|
||||
* @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
|
||||
// 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
|
||||
// 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,
|
||||
// the PacketListener will get removed (cancel()) allowing the garbage collection of the InvitationsMonitor
|
||||
// instance.
|
||||
private final static Map<Connection, WeakReference<InvitationsMonitor>> monitors =
|
||||
new WeakHashMap<Connection, WeakReference<InvitationsMonitor>>();
|
||||
private final static Map<XMPPConnection, WeakReference<InvitationsMonitor>> monitors =
|
||||
new WeakHashMap<XMPPConnection, WeakReference<InvitationsMonitor>>();
|
||||
|
||||
// We don't use a synchronized List here because it would break the semantic of (add|remove)InvitationListener
|
||||
private final List<InvitationListener> invitationsListeners =
|
||||
new ArrayList<InvitationListener>();
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
private PacketFilter invitationFilter;
|
||||
private PacketListener invitationPacketListener;
|
||||
|
||||
|
@ -2330,7 +2330,7 @@ public class MultiUserChat {
|
|||
* @param conn the connection to monitor for room invitations.
|
||||
* @return a new or existing InvitationsMonitor for a given connection.
|
||||
*/
|
||||
public static InvitationsMonitor getInvitationsMonitor(Connection conn) {
|
||||
public static InvitationsMonitor getInvitationsMonitor(XMPPConnection conn) {
|
||||
synchronized (monitors) {
|
||||
if (!monitors.containsKey(conn) || monitors.get(conn).get() == null) {
|
||||
// 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
|
||||
*/
|
||||
private InvitationsMonitor(Connection connection) {
|
||||
private InvitationsMonitor(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.muc;
|
|||
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
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.packet.Packet;
|
||||
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>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
|
||||
* {@link org.jivesoftware.smack.Connection} that has joined MUC rooms
|
||||
* {@link org.jivesoftware.smack.XMPPConnection} that has joined MUC rooms
|
||||
* within its session.
|
||||
*
|
||||
* @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
|
||||
// connection is no longer referenced by any object.
|
||||
private static final Map<Connection, WeakReference<RoomListenerMultiplexor>> monitors =
|
||||
new WeakHashMap<Connection, WeakReference<RoomListenerMultiplexor>>();
|
||||
private static final Map<XMPPConnection, WeakReference<RoomListenerMultiplexor>> monitors =
|
||||
new WeakHashMap<XMPPConnection, WeakReference<RoomListenerMultiplexor>>();
|
||||
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
private RoomMultiplexFilter filter;
|
||||
private RoomMultiplexListener listener;
|
||||
|
||||
|
@ -55,7 +55,7 @@ class RoomListenerMultiplexor implements ConnectionListener {
|
|||
* @param conn the connection to monitor for room invitations.
|
||||
* @return a new or existing RoomListenerMultiplexor for a given connection.
|
||||
*/
|
||||
public static RoomListenerMultiplexor getRoomMultiplexor(Connection conn) {
|
||||
public static RoomListenerMultiplexor getRoomMultiplexor(XMPPConnection conn) {
|
||||
synchronized (monitors) {
|
||||
if (!monitors.containsKey(conn) || monitors.get(conn).get() == null) {
|
||||
RoomListenerMultiplexor rm = new RoomListenerMultiplexor(conn, new RoomMultiplexFilter(),
|
||||
|
@ -75,12 +75,12 @@ class RoomListenerMultiplexor implements ConnectionListener {
|
|||
|
||||
/**
|
||||
* 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) {
|
||||
if (connection == null) {
|
||||
throw new IllegalArgumentException("Connection is null");
|
||||
throw new IllegalArgumentException("XMPPConnection is null");
|
||||
}
|
||||
if (filter == 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}
|
||||
* for all muc chat rooms on an <code>Connection</code>.
|
||||
* The single <code>XMPPConnection</code>-level <code>PacketFilter</code> used by a {@link RoomListenerMultiplexor}
|
||||
* for all muc chat rooms on an <code>XMPPConnection</code>.
|
||||
* Each time a muc chat room is added to/removed from an
|
||||
* <code>Connection</code> the address for that chat room
|
||||
* is added to/removed from that <code>Connection</code>'s
|
||||
* <code>XMPPConnection</code> the address for that chat room
|
||||
* is added to/removed from that <code>XMPPConnection</code>'s
|
||||
* <code>RoomMultiplexFilter</code>.
|
||||
*/
|
||||
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}
|
||||
* 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
|
||||
* <code>Connection</code> the address and listener for that chat room
|
||||
* are added to/removed from that <code>Connection</code>'s
|
||||
* <code>XMPPConnection</code> the address and listener for that chat room
|
||||
* are added to/removed from that <code>XMPPConnection</code>'s
|
||||
* <code>RoomMultiplexListener</code>.
|
||||
*
|
||||
* @author Larry Kirschner
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.offline;
|
|||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.AndFilter;
|
||||
import org.jivesoftware.smack.filter.PacketExtensionFilter;
|
||||
|
@ -58,11 +58,11 @@ public class OfflineMessageManager {
|
|||
|
||||
private final static String namespace = "http://jabber.org/protocol/offline";
|
||||
|
||||
private Connection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
private PacketFilter packetFilter;
|
||||
|
||||
public OfflineMessageManager(Connection connection) {
|
||||
public OfflineMessageManager(XMPPConnection connection) {
|
||||
this.connection = connection;
|
||||
packetFilter =
|
||||
new AndFilter(new PacketExtensionFilter("offline", namespace),
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
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.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -62,7 +62,7 @@ public class PEPManager {
|
|||
|
||||
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 PacketListener packetListener;
|
||||
|
@ -70,9 +70,9 @@ public class PEPManager {
|
|||
/**
|
||||
* 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;
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.concurrent.ScheduledFuture;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.ConnectionListener;
|
||||
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 Map<Connection, PingManager> INSTANCES = Collections
|
||||
.synchronizedMap(new WeakHashMap<Connection, PingManager>());
|
||||
private static final Map<XMPPConnection, PingManager> INSTANCES = Collections
|
||||
.synchronizedMap(new WeakHashMap<XMPPConnection, PingManager>());
|
||||
|
||||
private static final PacketFilter PING_PACKET_FILTER = new AndFilter(
|
||||
new PacketTypeFilter(Ping.class), new IQTypeFilter(Type.GET));
|
||||
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection 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.
|
||||
*
|
||||
* @param connection
|
||||
* The connection the manager is attached to.
|
||||
* @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);
|
||||
if (pingManager == null) {
|
||||
pingManager = new PingManager(connection);
|
||||
|
@ -117,7 +117,7 @@ public class PingManager extends Manager {
|
|||
*/
|
||||
private long lastSuccessfulManualPing = -1;
|
||||
|
||||
private PingManager(Connection connection) {
|
||||
private PingManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
sdm.addFeature(PingManager.NAMESPACE);
|
||||
|
@ -308,7 +308,7 @@ public class PingManager extends Manager {
|
|||
|
||||
public void run() {
|
||||
LOGGER.fine("ServerPingTask run()");
|
||||
Connection connection = connection();
|
||||
XMPPConnection connection = connection();
|
||||
if (connection == null) {
|
||||
// connection has been collected by GC
|
||||
// which means we can stop the thread by breaking the loop
|
||||
|
@ -344,7 +344,7 @@ public class PingManager extends Manager {
|
|||
maybeSchedulePingServerTask();
|
||||
}
|
||||
} 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.WeakHashMap;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
|
@ -50,8 +50,8 @@ import org.jivesoftware.smackx.privacy.packet.PrivacyItem;
|
|||
public class PrivacyListManager extends Manager {
|
||||
|
||||
// Keep the list of instances of this class.
|
||||
private static Map<Connection, PrivacyListManager> instances = Collections
|
||||
.synchronizedMap(new WeakHashMap<Connection, PrivacyListManager>());
|
||||
private static Map<XMPPConnection, PrivacyListManager> instances = Collections
|
||||
.synchronizedMap(new WeakHashMap<XMPPConnection, PrivacyListManager>());
|
||||
|
||||
private final List<PrivacyListListener> listeners = new ArrayList<PrivacyListListener>();
|
||||
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()
|
||||
// method of PrivacyListManager, we'll add a listener that will delete the
|
||||
// instance when the connection is closed.
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
});
|
||||
|
@ -74,7 +74,7 @@ public class PrivacyListManager extends Manager {
|
|||
*
|
||||
* @param connection the XMPP connection.
|
||||
*/
|
||||
private PrivacyListManager(final Connection connection) {
|
||||
private PrivacyListManager(final XMPPConnection connection) {
|
||||
super(connection);
|
||||
// Register the new instance and associate it with the connection
|
||||
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.
|
||||
* @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);
|
||||
if (plm == null) plm = new PrivacyListManager(connection);
|
||||
return plm;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
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
|
||||
* gets affiliations for the calling user, based on the identity that is associated with
|
||||
* the {@link Connection}.
|
||||
* the {@link XMPPConnection}.
|
||||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
|
||||
public class CollectionNode extends Node
|
||||
{
|
||||
CollectionNode(Connection connection, String nodeId)
|
||||
CollectionNode(XMPPConnection connection, String nodeId)
|
||||
{
|
||||
super(connection, nodeId);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smackx.disco.packet.DiscoverItems;
|
||||
|
@ -36,7 +36,7 @@ import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
|||
*/
|
||||
public class LeafNode extends Node
|
||||
{
|
||||
LeafNode(Connection connection, String nodeName)
|
||||
LeafNode(XMPPConnection connection, String nodeName)
|
||||
{
|
||||
super(connection, nodeName);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.List;
|
|||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.OrFilter;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
|
@ -45,7 +45,7 @@ import org.jivesoftware.smackx.xdata.Form;
|
|||
|
||||
abstract public class Node
|
||||
{
|
||||
protected Connection con;
|
||||
protected XMPPConnection con;
|
||||
protected String id;
|
||||
protected String to;
|
||||
|
||||
|
@ -60,7 +60,7 @@ abstract public class Node
|
|||
* @param connection The connection the node is associated with
|
||||
* @param nodeName The node id
|
||||
*/
|
||||
Node(Connection connection, String nodeName)
|
||||
Node(XMPPConnection connection, String nodeName)
|
||||
{
|
||||
con = connection;
|
||||
id = nodeName;
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
@ -45,7 +45,7 @@ import org.jivesoftware.smackx.xdata.FormField;
|
|||
*/
|
||||
final public class PubSubManager
|
||||
{
|
||||
private Connection con;
|
||||
private XMPPConnection con;
|
||||
private String to;
|
||||
private Map<String, Node> nodeMap = new ConcurrentHashMap<String, Node>();
|
||||
|
||||
|
@ -55,7 +55,7 @@ final public class PubSubManager
|
|||
*
|
||||
* @param connection The XMPP connection
|
||||
*/
|
||||
public PubSubManager(Connection connection)
|
||||
public PubSubManager(XMPPConnection connection)
|
||||
{
|
||||
con = connection;
|
||||
to = "pubsub." + connection.getServiceName();
|
||||
|
@ -68,7 +68,7 @@ final public class PubSubManager
|
|||
* @param connection The XMPP connection
|
||||
* @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;
|
||||
to = toAddress;
|
||||
|
@ -305,25 +305,25 @@ final public class PubSubManager
|
|||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
return con.createPacketCollectorAndSend(packet).nextResultOrThrow();
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
|
@ -41,12 +41,12 @@ import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
|||
*/
|
||||
public class DeliveryReceiptManager extends Manager implements PacketListener {
|
||||
|
||||
private static Map<Connection, DeliveryReceiptManager> instances =
|
||||
Collections.synchronizedMap(new WeakHashMap<Connection, DeliveryReceiptManager>());
|
||||
private static Map<XMPPConnection, DeliveryReceiptManager> instances =
|
||||
Collections.synchronizedMap(new WeakHashMap<XMPPConnection, DeliveryReceiptManager>());
|
||||
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
});
|
||||
|
@ -56,7 +56,7 @@ public class DeliveryReceiptManager extends Manager implements PacketListener {
|
|||
private Set<ReceiptReceivedListener> receiptReceivedListeners = Collections
|
||||
.synchronizedSet(new HashSet<ReceiptReceivedListener>());
|
||||
|
||||
private DeliveryReceiptManager(Connection connection) {
|
||||
private DeliveryReceiptManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
sdm.addFeature(DeliveryReceipt.NAMESPACE);
|
||||
|
@ -73,7 +73,7 @@ public class DeliveryReceiptManager extends Manager implements PacketListener {
|
|||
*
|
||||
* @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);
|
||||
|
||||
if (receiptManager == null) {
|
||||
|
@ -117,7 +117,7 @@ public class DeliveryReceiptManager extends Manager implements PacketListener {
|
|||
DeliveryReceiptRequest drr = (DeliveryReceiptRequest)packet.getExtension(
|
||||
DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE);
|
||||
if (drr != null) {
|
||||
Connection connection = connection();
|
||||
XMPPConnection connection = connection();
|
||||
Message ack = new Message(packet.getFrom(), Message.Type.normal);
|
||||
ack.addExtension(new DeliveryReceipt(packet.getPacketID()));
|
||||
connection.sendPacket(ack);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.search;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
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.
|
||||
*
|
||||
* @param con the current Connection.
|
||||
* @param con the current XMPPConnection.
|
||||
* @param searchService the search service to use. (ex. search.jivesoftware.com)
|
||||
* @return the search form received by the server.
|
||||
* @throws org.jivesoftware.smack.XMPPException
|
||||
* 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();
|
||||
search.setType(IQ.Type.GET);
|
||||
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.
|
||||
*
|
||||
* @param con the current Connection.
|
||||
* @param con the current XMPPConnection.
|
||||
* @param searchForm the <code>Form</code> to send for querying.
|
||||
* @param searchService the search service to use. (ex. search.jivesoftware.com)
|
||||
* @return ReportedData the data found from the query.
|
||||
* @throws org.jivesoftware.smack.XMPPException
|
||||
* 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();
|
||||
search.setType(IQ.Type.SET);
|
||||
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.
|
||||
*
|
||||
* @param con the current Connection.
|
||||
* @param con the current XMPPConnection.
|
||||
* @param searchForm the <code>Form</code> to send for querying.
|
||||
* @param searchService the search service to use. (ex. search.jivesoftware.com)
|
||||
* @return ReportedData the data found from the query.
|
||||
* @throws org.jivesoftware.smack.XMPPException
|
||||
* 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();
|
||||
search.setForm(searchForm);
|
||||
search.setType(IQ.Type.SET);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.search;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
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
|
||||
* types of support.
|
||||
* <pre>
|
||||
* Connection con = new TCPConnection("jabber.org");
|
||||
* XMPPConnection con = new TCPConnection("jabber.org");
|
||||
* con.login("john", "doe");
|
||||
* UserSearchManager search = new UserSearchManager(con, "users.jabber.org");
|
||||
* Form searchForm = search.getSearchForm();
|
||||
|
@ -48,15 +48,15 @@ import java.util.List;
|
|||
*/
|
||||
public class UserSearchManager {
|
||||
|
||||
private Connection con;
|
||||
private XMPPConnection con;
|
||||
private UserSearch userSearch;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
userSearch = new UserSearch();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.sharedgroups;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
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.
|
||||
* @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
|
||||
SharedGroupsInfo info = new SharedGroupsInfo();
|
||||
info.setType(IQ.Type.GET);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.time;
|
|||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
|
@ -35,7 +35,7 @@ import org.jivesoftware.smackx.time.packet.Time;
|
|||
|
||||
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(
|
||||
Time.class), new IQTypeFilter(Type.GET));
|
||||
|
@ -43,8 +43,8 @@ public class EntityTimeManager extends Manager {
|
|||
private static boolean autoEnable = true;
|
||||
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
});
|
||||
|
@ -54,7 +54,7 @@ public class EntityTimeManager extends Manager {
|
|||
EntityTimeManager.autoEnable = autoEnable;
|
||||
}
|
||||
|
||||
public synchronized static EntityTimeManager getInstanceFor(Connection connection) {
|
||||
public synchronized static EntityTimeManager getInstanceFor(XMPPConnection connection) {
|
||||
EntityTimeManager entityTimeManager = INSTANCES.get(connection);
|
||||
if (entityTimeManager == null) {
|
||||
entityTimeManager = new EntityTimeManager(connection);
|
||||
|
@ -64,7 +64,7 @@ public class EntityTimeManager extends Manager {
|
|||
|
||||
private boolean enabled = false;
|
||||
|
||||
private EntityTimeManager(Connection connection) {
|
||||
private EntityTimeManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
INSTANCES.put(connection, this);
|
||||
if (autoEnable)
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.Map.Entry;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
@ -508,15 +508,15 @@ public class VCard extends IQ {
|
|||
}
|
||||
|
||||
/**
|
||||
* Save this vCard for the user connected by 'connection'. Connection should be authenticated
|
||||
* Save this vCard for the user connected by 'connection'. XMPPConnection should be authenticated
|
||||
* and not anonymous.<p>
|
||||
* <p/>
|
||||
* NOTE: the method is asynchronous and does not wait for the returned value.
|
||||
*
|
||||
* @param connection the Connection to use.
|
||||
* @param connection the XMPPConnection to use.
|
||||
* @throws XMPPException thrown if there was an issue setting the VCard in the server.
|
||||
*/
|
||||
public void save(Connection connection) throws XMPPException {
|
||||
public void save(XMPPConnection connection) throws XMPPException {
|
||||
checkAuthenticated(connection, true);
|
||||
|
||||
setType(IQ.Type.SET);
|
||||
|
@ -525,10 +525,10 @@ public class VCard extends IQ {
|
|||
}
|
||||
|
||||
/**
|
||||
* Load VCard information for a connected user. Connection should be authenticated
|
||||
* Load VCard information for a connected user. XMPPConnection should be authenticated
|
||||
* and not anonymous.
|
||||
*/
|
||||
public void load(Connection connection) throws XMPPException {
|
||||
public void load(XMPPConnection connection) throws XMPPException {
|
||||
checkAuthenticated(connection, true);
|
||||
|
||||
setFrom(connection.getUser());
|
||||
|
@ -536,16 +536,16 @@ public class VCard extends IQ {
|
|||
}
|
||||
|
||||
/**
|
||||
* Load VCard information for a given user. Connection should be authenticated and not anonymous.
|
||||
* Load VCard information for a given user. XMPPConnection should be authenticated and not anonymous.
|
||||
*/
|
||||
public void load(Connection connection, String user) throws XMPPException {
|
||||
public void load(XMPPConnection connection, String user) throws XMPPException {
|
||||
checkAuthenticated(connection, false);
|
||||
|
||||
setTo(user);
|
||||
doLoad(connection, user);
|
||||
}
|
||||
|
||||
private void doLoad(Connection connection, String user) throws XMPPException {
|
||||
private void doLoad(XMPPConnection connection, String user) throws XMPPException {
|
||||
setType(Type.GET);
|
||||
VCard result = (VCard) connection.createPacketCollectorAndSend(this).nextResultOrThrow();
|
||||
copyFieldsFrom(result);
|
||||
|
@ -573,15 +573,15 @@ public class VCard extends IQ {
|
|||
}
|
||||
}
|
||||
|
||||
private void checkAuthenticated(Connection connection, boolean checkForAnonymous) {
|
||||
private void checkAuthenticated(XMPPConnection connection, boolean checkForAnonymous) {
|
||||
if (connection == null) {
|
||||
throw new IllegalArgumentException("No connection was provided");
|
||||
}
|
||||
if (!connection.isAuthenticated()) {
|
||||
throw new IllegalArgumentException("Connection is not authenticated");
|
||||
throw new IllegalArgumentException("XMPPConnection is not authenticated");
|
||||
}
|
||||
if (checkForAnonymous && connection.isAnonymous()) {
|
||||
throw new IllegalArgumentException("Connection cannot be anonymous");
|
||||
throw new IllegalArgumentException("XMPPConnection cannot be anonymous");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
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.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
|
@ -45,7 +45,7 @@ public class MessageEventManager {
|
|||
private List<MessageEventNotificationListener> messageEventNotificationListeners = new ArrayList<MessageEventNotificationListener>();
|
||||
private List<MessageEventRequestListener> messageEventRequestListeners = new ArrayList<MessageEventRequestListener>();
|
||||
|
||||
private Connection con;
|
||||
private XMPPConnection con;
|
||||
|
||||
private PacketFilter packetFilter = new PacketExtensionFilter("x", "jabber:x:event");
|
||||
private PacketListener packetListener;
|
||||
|
@ -53,9 +53,9 @@ public class MessageEventManager {
|
|||
/**
|
||||
* Creates a new message event manager.
|
||||
*
|
||||
* @param con a Connection to a XMPP server.
|
||||
* @param con a XMPPConnection to a XMPP server.
|
||||
*/
|
||||
public MessageEventManager(Connection con) {
|
||||
public MessageEventManager(XMPPConnection con) {
|
||||
this.con = con;
|
||||
init();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.jivesoftware.smackx.xhtmlim;
|
||||
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
|
@ -45,8 +45,8 @@ public class XHTMLManager {
|
|||
// Enable the XHTML support on every established connection
|
||||
// The ServiceDiscoveryManager class should have been already initialized
|
||||
static {
|
||||
Connection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(Connection connection) {
|
||||
XMPPConnection.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
XHTMLManager.setServiceEnabled(connection, true);
|
||||
}
|
||||
});
|
||||
|
@ -103,7 +103,7 @@ public class XHTMLManager {
|
|||
* @param connection the connection where 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)
|
||||
return;
|
||||
|
||||
|
@ -121,7 +121,7 @@ public class XHTMLManager {
|
|||
* @param connection the connection to look for XHTML support
|
||||
* @return a boolean indicating if the XHTML support is enabled for the given connection
|
||||
*/
|
||||
public static boolean isServiceEnabled(Connection connection) {
|
||||
public static boolean isServiceEnabled(XMPPConnection connection) {
|
||||
return ServiceDiscoveryManager.getInstanceFor(connection).includesFeature(namespace);
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ public class XHTMLManager {
|
|||
* @param userID the user to check. A fully qualified xmpp ID, e.g. jdoe@example.com
|
||||
* @return a boolean indicating whether the specified user handles XHTML messages
|
||||
*/
|
||||
public static boolean isServiceEnabled(Connection connection, String userID) {
|
||||
public static boolean isServiceEnabled(XMPPConnection connection, String userID) {
|
||||
try {
|
||||
DiscoverInfo result =
|
||||
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(userID);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.bytestreams.ibb;
|
|||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.CloseListener;
|
||||
|
@ -49,7 +49,7 @@ public class CloseListenerTest {
|
|||
public void shouldReplyErrorIfSessionIsUnknown() throws Exception {
|
||||
|
||||
// mock connection
|
||||
Connection connection = mock(Connection.class);
|
||||
XMPPConnection connection = mock(XMPPConnection.class);
|
||||
|
||||
// initialize InBandBytestreamManager to get the CloseListener
|
||||
InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.bytestreams.ibb;
|
|||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.DataListener;
|
||||
|
@ -50,7 +50,7 @@ public class DataListenerTest {
|
|||
public void shouldReplyErrorIfSessionIsUnknown() throws Exception {
|
||||
|
||||
// mock connection
|
||||
Connection connection = mock(Connection.class);
|
||||
XMPPConnection connection = mock(XMPPConnection.class);
|
||||
|
||||
// initialize InBandBytestreamManager to get the DataListener
|
||||
InBandBytestreamManager byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.bytestreams.ibb;
|
|||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
|
@ -50,7 +50,7 @@ public class InBandBytestreamManagerTest {
|
|||
Protocol protocol;
|
||||
|
||||
// mocked XMPP connection
|
||||
Connection connection;
|
||||
XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
@ -70,15 +70,15 @@ public class InBandBytestreamManagerTest {
|
|||
|
||||
/**
|
||||
* Test that
|
||||
* {@link InBandBytestreamManager#getByteStreamManager(Connection)} returns
|
||||
* {@link InBandBytestreamManager#getByteStreamManager(XMPPConnection)} returns
|
||||
* one bytestream manager for every connection
|
||||
*/
|
||||
@Test
|
||||
public void shouldHaveOneManagerForEveryConnection() {
|
||||
|
||||
// mock two connections
|
||||
Connection connection1 = mock(Connection.class);
|
||||
Connection connection2 = mock(Connection.class);
|
||||
XMPPConnection connection1 = mock(XMPPConnection.class);
|
||||
XMPPConnection connection2 = mock(XMPPConnection.class);
|
||||
|
||||
// get bytestream manager for the first connection twice
|
||||
InBandBytestreamManager conn1ByteStreamManager1 = InBandBytestreamManager.getByteStreamManager(connection1);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.bytestreams.ibb;
|
|||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
|
||||
|
@ -41,7 +41,7 @@ public class InBandBytestreamRequestTest {
|
|||
String targetJID = "target@xmpp-server/Smack";
|
||||
String sessionID = "session_id";
|
||||
|
||||
Connection connection;
|
||||
XMPPConnection connection;
|
||||
InBandBytestreamManager byteStreamManager;
|
||||
Open initBytestream;
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class InBandBytestreamRequestTest {
|
|||
public void setup() {
|
||||
|
||||
// mock connection
|
||||
connection = mock(Connection.class);
|
||||
connection = mock(XMPPConnection.class);
|
||||
|
||||
// initialize InBandBytestreamManager to get the InitiationListener
|
||||
byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -62,7 +62,7 @@ public class InBandBytestreamSessionMessageTest {
|
|||
Protocol protocol;
|
||||
|
||||
// mocked XMPP connection
|
||||
Connection connection;
|
||||
XMPPConnection connection;
|
||||
|
||||
InBandBytestreamManager byteStreamManager;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.util.Random;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -63,7 +63,7 @@ public class InBandBytestreamSessionTest {
|
|||
Protocol protocol;
|
||||
|
||||
// mocked XMPP connection
|
||||
Connection connection;
|
||||
XMPPConnection connection;
|
||||
|
||||
InBandBytestreamManager byteStreamManager;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.bytestreams.ibb;
|
|||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
||||
|
@ -43,7 +43,7 @@ public class InitiationListenerTest {
|
|||
String targetJID = "target@xmpp-server/Smack";
|
||||
String sessionID = "session_id";
|
||||
|
||||
Connection connection;
|
||||
XMPPConnection connection;
|
||||
InBandBytestreamManager byteStreamManager;
|
||||
InitiationListener initiationListener;
|
||||
Open initBytestream;
|
||||
|
@ -55,7 +55,7 @@ public class InitiationListenerTest {
|
|||
public void setup() {
|
||||
|
||||
// mock connection
|
||||
connection = mock(Connection.class);
|
||||
connection = mock(XMPPConnection.class);
|
||||
|
||||
// initialize InBandBytestreamManager to get the InitiationListener
|
||||
byteStreamManager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.jivesoftware.smackx.bytestreams.socks5;
|
|||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
||||
|
@ -47,7 +47,7 @@ public class InitiationListenerTest {
|
|||
String proxyAddress = "127.0.0.1";
|
||||
String sessionID = "session_id";
|
||||
|
||||
Connection connection;
|
||||
XMPPConnection connection;
|
||||
Socks5BytestreamManager byteStreamManager;
|
||||
InitiationListener initiationListener;
|
||||
Bytestream initBytestream;
|
||||
|
@ -59,7 +59,7 @@ public class InitiationListenerTest {
|
|||
public void setup() {
|
||||
|
||||
// mock connection
|
||||
connection = mock(Connection.class);
|
||||
connection = mock(XMPPConnection.class);
|
||||
|
||||
// create service discovery manager for mocked connection
|
||||
ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.net.ConnectException;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
|
@ -66,7 +66,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
Protocol protocol;
|
||||
|
||||
// mocked XMPP connection
|
||||
Connection connection;
|
||||
XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
@ -84,15 +84,15 @@ public class Socks5ByteStreamManagerTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test that {@link Socks5BytestreamManager#getBytestreamManager(Connection)} returns one
|
||||
* Test that {@link Socks5BytestreamManager#getBytestreamManager(XMPPConnection)} returns one
|
||||
* bytestream manager for every connection
|
||||
*/
|
||||
@Test
|
||||
public void shouldHaveOneManagerForEveryConnection() {
|
||||
|
||||
// mock two connections
|
||||
Connection connection1 = mock(Connection.class);
|
||||
Connection connection2 = mock(Connection.class);
|
||||
XMPPConnection connection1 = mock(XMPPConnection.class);
|
||||
XMPPConnection connection2 = mock(XMPPConnection.class);
|
||||
|
||||
/*
|
||||
* create service discovery managers for the connections because the
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.io.OutputStream;
|
|||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
@ -55,7 +55,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
|
||||
Protocol protocol;
|
||||
|
||||
Connection connection;
|
||||
XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.io.InputStream;
|
|||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
|
@ -60,7 +60,7 @@ public class Socks5ClientForInitiatorTest {
|
|||
Protocol protocol;
|
||||
|
||||
// mocked XMPP connection
|
||||
Connection connection;
|
||||
XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
|
|
@ -31,7 +31,7 @@ public class FileTransferNegotiatorTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
// Uncomment this to enable debug output
|
||||
// Connection.DEBUG_ENABLED = true;
|
||||
// XMPPConnection.DEBUG_ENABLED = true;
|
||||
|
||||
connection = new DummyConnection();
|
||||
connection.connect();
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
//import java.util.concurrent.CountDownLatch;
|
||||
//import java.util.concurrent.TimeUnit;
|
||||
//
|
||||
//import org.jivesoftware.smack.Connection;
|
||||
//import org.jivesoftware.smack.XMPPConnection;
|
||||
//import org.jivesoftware.smack.DummyConnection;
|
||||
//import org.jivesoftware.smack.PacketInterceptor;
|
||||
//import org.jivesoftware.smack.PacketListener;
|
||||
|
@ -157,7 +157,7 @@
|
|||
// return con;
|
||||
// }
|
||||
//
|
||||
// private void addInterceptor(final Connection con, final CountDownLatch latch) {
|
||||
// private void addInterceptor(final XMPPConnection con, final CountDownLatch latch) {
|
||||
// con.addPacketInterceptor(new PacketInterceptor() {
|
||||
// @Override
|
||||
// public void interceptPacket(Packet packet) {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ItemValidationTest
|
|||
public void setUp() throws Exception
|
||||
{
|
||||
// Uncomment this to enable debug output
|
||||
// Connection.DEBUG_ENABLED = true;
|
||||
// XMPPConnection.DEBUG_ENABLED = true;
|
||||
|
||||
connection = new ThreadedDummyConnection();
|
||||
connection.connect();
|
||||
|
|
|
@ -20,7 +20,7 @@ import static org.mockito.Matchers.*;
|
|||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
@ -59,11 +59,11 @@ public class ConnectionUtils {
|
|||
* @return a mocked XMPP connection
|
||||
* @throws XMPPException
|
||||
*/
|
||||
public static Connection createMockedConnection(final Protocol protocol,
|
||||
public static XMPPConnection createMockedConnection(final Protocol protocol,
|
||||
String initiatorJID, String xmppServer) throws XMPPException {
|
||||
|
||||
// mock XMPP connection
|
||||
Connection connection = mock(Connection.class);
|
||||
XMPPConnection connection = mock(XMPPConnection.class);
|
||||
when(connection.getUser()).thenReturn(initiatorJID);
|
||||
when(connection.getServiceName()).thenReturn(xmppServer);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
* // create protocol
|
||||
* Protocol protocol = new Protocol();
|
||||
* // create mocked connection
|
||||
* Connection connection = ConnectionUtils.createMockedConnection(protocol, "user@xmpp-server", "xmpp-server");
|
||||
* XMPPConnection connection = ConnectionUtils.createMockedConnection(protocol, "user@xmpp-server", "xmpp-server");
|
||||
*
|
||||
* // add reply packet to protocol
|
||||
* Packet reply = new Packet();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue