mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Bump "Error Prone" to 2.0.15
and fix a few things :)
This commit is contained in:
parent
ef0af66b21
commit
4c646436a5
246 changed files with 1122 additions and 124 deletions
|
@ -53,6 +53,7 @@ import org.jxmpp.jid.Jid;
|
|||
*
|
||||
* @see <a href="https://xmpp.org/extensions/xep-0296.html">XEP-0296: Best Practices for Resource Locking</a>
|
||||
*/
|
||||
@SuppressWarnings("FunctionalInterfaceClash")
|
||||
public final class ChatManager extends Manager {
|
||||
|
||||
private static final Map<XMPPConnection, ChatManager> INSTANCES = new WeakHashMap<>();
|
||||
|
@ -188,22 +189,84 @@ public final class ChatManager extends Manager {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean addListener(IncomingChatMessageListener listener) {
|
||||
/**
|
||||
* Add a new listener for incoming chat messages.
|
||||
*
|
||||
* @param listener the listener to add.
|
||||
* @return <code>true</code> if the listener was not already added.
|
||||
*/
|
||||
public boolean addIncomingListener(IncomingChatMessageListener listener) {
|
||||
return incomingListeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new listener for incoming chat messages.
|
||||
*
|
||||
* @param listener the listener to add.
|
||||
* @return <code>true</code> if the listener was not already added.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("FunctionalInterfaceClash")
|
||||
public boolean addListener(IncomingChatMessageListener listener) {
|
||||
return addIncomingListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an incoming chat message listener.
|
||||
*
|
||||
* @param listener the listener to remove.
|
||||
* @return <code>true</code> if the listener was active and got removed.
|
||||
*/
|
||||
@SuppressWarnings("FunctionalInterfaceClash")
|
||||
public boolean removeListener(IncomingChatMessageListener listener) {
|
||||
return incomingListeners.remove(listener);
|
||||
}
|
||||
|
||||
public boolean addListener(OutgoingChatMessageListener listener) {
|
||||
/**
|
||||
* Add a new listener for outgoing chat messages.
|
||||
*
|
||||
* @param listener the listener to add.
|
||||
* @return <code>true</code> if the listener was not already added.
|
||||
*/
|
||||
public boolean addOutgoingListener(OutgoingChatMessageListener listener) {
|
||||
return outgoingListeners.add(listener);
|
||||
}
|
||||
|
||||
public boolean removeOutoingLIstener(OutgoingChatMessageListener listener) {
|
||||
/**
|
||||
* Add a new listener for incoming chat messages.
|
||||
*
|
||||
* @param listener the listener to add.
|
||||
* @return <code>true</code> if the listener was not already added.
|
||||
* @deprecated use {@link #addOutgoingListener(OutgoingChatMessageListener)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("FunctionalInterfaceClash")
|
||||
public boolean addListener(OutgoingChatMessageListener listener) {
|
||||
return addOutgoingListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an outgoing chat message listener.
|
||||
*
|
||||
* @param listener the listener to remove.
|
||||
* @return <code>true</code> if the listener was active and got removed.
|
||||
*/
|
||||
public boolean removeListener(OutgoingChatMessageListener listener) {
|
||||
return outgoingListeners.remove(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an outgoing chat message listener.
|
||||
*
|
||||
* @param listener the listener to remove.
|
||||
* @return <code>true</code> if the listener was active and got removed.
|
||||
* @deprecated use {@link #removeListener(OutgoingChatMessageListener)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean removeOutoingLIstener(OutgoingChatMessageListener listener) {
|
||||
return removeListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a new or retrieve the existing chat with <code>jid</code>.
|
||||
*
|
||||
|
|
|
@ -40,6 +40,7 @@ public class AMPManager {
|
|||
// The ServiceDiscoveryManager class should have been already initialized
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
AMPManager.setServiceEnabled(connection, true);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ public class AttentionExtension implements ExtensionElement {
|
|||
*
|
||||
* @see org.jivesoftware.smack.packet.PacketExtension#getElementName()
|
||||
*/
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT_NAME;
|
||||
}
|
||||
|
@ -56,6 +57,7 @@ public class AttentionExtension implements ExtensionElement {
|
|||
*
|
||||
* @see org.jivesoftware.smack.packet.PacketExtension#getNamespace()
|
||||
*/
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
@ -65,6 +67,7 @@ public class AttentionExtension implements ExtensionElement {
|
|||
*
|
||||
* @see org.jivesoftware.smack.packet.PacketExtension#toXML()
|
||||
*/
|
||||
@Override
|
||||
public String toXML() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append('<').append(getElementName()).append(" xmlns=\"").append(
|
||||
|
|
|
@ -131,6 +131,7 @@ public class BookmarkedConference implements SharedBookmark {
|
|||
this.isShared = isShared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShared() {
|
||||
return isShared;
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ public class BookmarkedURL implements SharedBookmark {
|
|||
this.isShared = shared;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShared() {
|
||||
return isShared;
|
||||
}
|
||||
|
|
|
@ -151,6 +151,7 @@ public class Bookmarks implements PrivateData {
|
|||
*
|
||||
* @return the element name.
|
||||
*/
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
@ -160,6 +161,7 @@ public class Bookmarks implements PrivateData {
|
|||
*
|
||||
* @return the namespace.
|
||||
*/
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
@ -218,6 +220,7 @@ public class Bookmarks implements PrivateData {
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
Bookmarks storage = new Bookmarks();
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ public abstract class InBandBytestreamListener implements BytestreamListener {
|
|||
|
||||
|
||||
|
||||
@Override
|
||||
public void incomingBytestreamRequest(BytestreamRequest request) {
|
||||
incomingBytestreamRequest((InBandBytestreamRequest) request);
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ public final class InBandBytestreamManager implements BytestreamManager {
|
|||
*/
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(final XMPPConnection connection) {
|
||||
// create the manager for this connection
|
||||
InBandBytestreamManager.getByteStreamManager(connection);
|
||||
|
@ -236,6 +237,7 @@ public final class InBandBytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @param listener the listener to register
|
||||
*/
|
||||
@Override
|
||||
public void addIncomingBytestreamListener(BytestreamListener listener) {
|
||||
this.allRequestListeners.add(listener);
|
||||
}
|
||||
|
@ -246,6 +248,7 @@ public final class InBandBytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @param listener the listener to remove
|
||||
*/
|
||||
@Override
|
||||
public void removeIncomingBytestreamListener(BytestreamListener listener) {
|
||||
this.allRequestListeners.remove(listener);
|
||||
}
|
||||
|
@ -268,6 +271,7 @@ public final class InBandBytestreamManager implements BytestreamManager {
|
|||
* @param listener the listener to register
|
||||
* @param initiatorJID the JID of the user that wants to establish an In-Band Bytestream
|
||||
*/
|
||||
@Override
|
||||
public void addIncomingBytestreamListener(BytestreamListener listener, Jid initiatorJID) {
|
||||
this.userListeners.put(initiatorJID, listener);
|
||||
}
|
||||
|
@ -277,6 +281,9 @@ public final class InBandBytestreamManager implements BytestreamManager {
|
|||
*
|
||||
* @param initiatorJID the JID of the user the listener should be removed
|
||||
*/
|
||||
@Override
|
||||
// TODO: Change argument to Jid in Smack 4.3.
|
||||
@SuppressWarnings("CollectionIncompatibleType")
|
||||
public void removeIncomingBytestreamListener(String initiatorJID) {
|
||||
this.userListeners.remove(initiatorJID);
|
||||
}
|
||||
|
@ -402,6 +409,7 @@ public final class InBandBytestreamManager implements BytestreamManager {
|
|||
* @throws SmackException if there was no response from the server.
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Override
|
||||
public InBandBytestreamSession establishSession(Jid targetJID) throws XMPPException, SmackException, InterruptedException {
|
||||
String sessionID = getNextSessionID();
|
||||
return establishSession(targetJID, sessionID);
|
||||
|
@ -420,6 +428,7 @@ public final class InBandBytestreamManager implements BytestreamManager {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Override
|
||||
public InBandBytestreamSession establishSession(Jid targetJID, String sessionID)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
Open byteStreamRequest = new Open(sessionID, this.defaultBlockSize, this.stanza);
|
||||
|
|
|
@ -50,6 +50,7 @@ public class InBandBytestreamRequest implements BytestreamRequest {
|
|||
*
|
||||
* @return the sender of the In-Band Bytestream open request
|
||||
*/
|
||||
@Override
|
||||
public Jid getFrom() {
|
||||
return this.byteStreamRequest.getFrom();
|
||||
}
|
||||
|
@ -59,6 +60,7 @@ public class InBandBytestreamRequest implements BytestreamRequest {
|
|||
*
|
||||
* @return the session ID of the In-Band Bytestream open request
|
||||
*/
|
||||
@Override
|
||||
public String getSessionID() {
|
||||
return this.byteStreamRequest.getSessionID();
|
||||
}
|
||||
|
@ -71,6 +73,7 @@ public class InBandBytestreamRequest implements BytestreamRequest {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Override
|
||||
public InBandBytestreamSession accept() throws NotConnectedException, InterruptedException {
|
||||
XMPPConnection connection = this.manager.getConnection();
|
||||
|
||||
|
@ -92,6 +95,7 @@ public class InBandBytestreamRequest implements BytestreamRequest {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Override
|
||||
public void reject() throws NotConnectedException, InterruptedException {
|
||||
this.manager.replyRejectPacket(this.byteStreamRequest);
|
||||
}
|
||||
|
|
|
@ -109,18 +109,22 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
return this.inputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() {
|
||||
return this.outputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReadTimeout() {
|
||||
return this.inputStream.readTimeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadTimeout(int timeout) {
|
||||
if (timeout < 0) {
|
||||
throw new IllegalArgumentException("Timeout must be >= 0");
|
||||
|
@ -151,6 +155,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
this.closeBothStreamsEnabled = closeBothStreamsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
closeByLocal(true); // close input stream
|
||||
closeByLocal(false); // close output stream
|
||||
|
@ -224,7 +229,9 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
this.inputStream.cleanup();
|
||||
|
||||
// remove session from manager
|
||||
InBandBytestreamManager.getByteStreamManager(this.connection).getSessions().remove(this);
|
||||
// Thanks Google Error Prone for finding the bug where remove() was called with 'this' as argument. Changed
|
||||
// now to remove(byteStreamRequest.getSessionID).
|
||||
InBandBytestreamManager.getByteStreamManager(this.connection).getSessions().remove(byteStreamRequest.getSessionID());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -283,6 +290,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
*/
|
||||
protected abstract StanzaFilter getDataPacketFilter();
|
||||
|
||||
@Override
|
||||
public synchronized int read() throws IOException {
|
||||
checkClosed();
|
||||
|
||||
|
@ -298,6 +306,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
return buffer[bufferPointer++] & 0xff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int read(byte[] b, int off, int len) throws IOException {
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
|
@ -331,6 +340,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
return len;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized int read(byte[] b) throws IOException {
|
||||
return read(b, 0, b.length);
|
||||
}
|
||||
|
@ -405,10 +415,12 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean markSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (closeInvoked) {
|
||||
return;
|
||||
|
@ -444,11 +456,13 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
*/
|
||||
private class IQIBBInputStream extends IBBInputStream {
|
||||
|
||||
@Override
|
||||
protected StanzaListener getDataPacketListener() {
|
||||
return new StanzaListener() {
|
||||
|
||||
private long lastSequence = -1;
|
||||
|
||||
@Override
|
||||
public void processStanza(Stanza packet) throws NotConnectedException, InterruptedException {
|
||||
// get data packet extension
|
||||
DataPacketExtension data = ((Data) packet).getDataPacketExtension();
|
||||
|
@ -491,6 +505,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StanzaFilter getDataPacketFilter() {
|
||||
/*
|
||||
* filter all IQ stanzas having type 'SET' (represented by Data class), containing a
|
||||
|
@ -507,9 +522,11 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
*/
|
||||
private class MessageIBBInputStream extends IBBInputStream {
|
||||
|
||||
@Override
|
||||
protected StanzaListener getDataPacketListener() {
|
||||
return new StanzaListener() {
|
||||
|
||||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
// get data packet extension
|
||||
DataPacketExtension data = (DataPacketExtension) packet.getExtension(
|
||||
|
@ -555,6 +572,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
*/
|
||||
private class IBBDataPacketFilter implements StanzaFilter {
|
||||
|
||||
@Override
|
||||
public boolean accept(Stanza packet) {
|
||||
// sender equals remote peer
|
||||
if (!packet.getFrom().equals(remoteJID)) {
|
||||
|
@ -619,6 +637,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
*/
|
||||
protected abstract void writeToXML(DataPacketExtension data) throws IOException, NotConnectedException, InterruptedException;
|
||||
|
||||
@Override
|
||||
public synchronized void write(int b) throws IOException {
|
||||
if (this.isClosed) {
|
||||
throw new IOException("Stream is closed");
|
||||
|
@ -632,6 +651,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
buffer[bufferPointer++] = (byte) b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void write(byte[] b, int off, int len) throws IOException {
|
||||
if (b == null) {
|
||||
throw new NullPointerException();
|
||||
|
@ -662,6 +682,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void write(byte[] b) throws IOException {
|
||||
write(b, 0, b.length);
|
||||
}
|
||||
|
@ -698,6 +719,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
bufferPointer += len - available;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void flush() throws IOException {
|
||||
if (this.isClosed) {
|
||||
throw new IOException("Stream is closed");
|
||||
|
@ -735,6 +757,7 @@ public class InBandBytestreamSession implements BytestreamSession {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (isClosed) {
|
||||
return;
|
||||
|
|
|
@ -66,6 +66,7 @@ class InitiationListener extends AbstractIqRequestHandler {
|
|||
public IQ handleIQRequest(final IQ packet) {
|
||||
initiationListenerExecutor.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
processRequest(packet);
|
||||
|
|
|
@ -126,10 +126,12 @@ public class DataPacketExtension implements ExtensionElement {
|
|||
return this.decodedData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ final class InitiationListener extends AbstractIqRequestHandler {
|
|||
public IQ handleIQRequest(final IQ packet) {
|
||||
initiationListenerExecutor.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
processRequest(packet);
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
|
|||
*/
|
||||
public abstract class Socks5BytestreamListener implements BytestreamListener {
|
||||
|
||||
@Override
|
||||
public void incomingBytestreamRequest(BytestreamRequest request) {
|
||||
incomingBytestreamRequest((Socks5BytestreamRequest) request);
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
|
||||
@Override
|
||||
public void connectionCreated(final XMPPConnection connection) {
|
||||
// create the manager for this connection
|
||||
Socks5BytestreamManager.getBytestreamManager(connection);
|
||||
|
@ -198,6 +199,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
*
|
||||
* @param listener the listener to register
|
||||
*/
|
||||
@Override
|
||||
public void addIncomingBytestreamListener(BytestreamListener listener) {
|
||||
this.allRequestListeners.add(listener);
|
||||
}
|
||||
|
@ -208,6 +210,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
*
|
||||
* @param listener the listener to remove
|
||||
*/
|
||||
@Override
|
||||
public void removeIncomingBytestreamListener(BytestreamListener listener) {
|
||||
this.allRequestListeners.remove(listener);
|
||||
}
|
||||
|
@ -230,6 +233,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
* @param listener the listener to register
|
||||
* @param initiatorJID the JID of the user that wants to establish a SOCKS5 Bytestream
|
||||
*/
|
||||
@Override
|
||||
public void addIncomingBytestreamListener(BytestreamListener listener, Jid initiatorJID) {
|
||||
this.userListeners.put(initiatorJID, listener);
|
||||
}
|
||||
|
@ -239,6 +243,9 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
*
|
||||
* @param initiatorJID the JID of the user the listener should be removed
|
||||
*/
|
||||
// TODO: Change parameter to Jid in Smack 4.3.
|
||||
@Override
|
||||
@SuppressWarnings("CollectionIncompatibleType")
|
||||
public void removeIncomingBytestreamListener(String initiatorJID) {
|
||||
this.userListeners.remove(initiatorJID);
|
||||
}
|
||||
|
@ -386,6 +393,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
* @throws InterruptedException if the current thread was interrupted while waiting
|
||||
* @throws SmackException if there was no response from the server.
|
||||
*/
|
||||
@Override
|
||||
public Socks5BytestreamSession establishSession(Jid targetJID) throws XMPPException,
|
||||
IOException, InterruptedException, SmackException {
|
||||
String sessionID = getNextSessionID();
|
||||
|
@ -405,6 +413,7 @@ public final class Socks5BytestreamManager extends Manager implements Bytestream
|
|||
* @throws SmackException if the target does not support SOCKS5.
|
||||
* @throws XMPPException
|
||||
*/
|
||||
@Override
|
||||
public Socks5BytestreamSession establishSession(Jid targetJID, String sessionID)
|
||||
throws IOException, InterruptedException, NoResponseException, SmackException, XMPPException{
|
||||
XMPPConnection connection = connection();
|
||||
|
|
|
@ -170,6 +170,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
*
|
||||
* @return the sender of the SOCKS5 Bytestream initialization request.
|
||||
*/
|
||||
@Override
|
||||
public Jid getFrom() {
|
||||
return this.bytestreamRequest.getFrom();
|
||||
}
|
||||
|
@ -179,6 +180,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
*
|
||||
* @return the session ID of the SOCKS5 Bytestream initialization request.
|
||||
*/
|
||||
@Override
|
||||
public String getSessionID() {
|
||||
return this.bytestreamRequest.getSessionID();
|
||||
}
|
||||
|
@ -195,6 +197,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
* @throws XMPPErrorException
|
||||
* @throws SmackException
|
||||
*/
|
||||
@Override
|
||||
public Socks5BytestreamSession accept() throws InterruptedException, XMPPErrorException, SmackException {
|
||||
Collection<StreamHost> streamHosts = this.bytestreamRequest.getStreamHosts();
|
||||
|
||||
|
@ -264,6 +267,7 @@ public class Socks5BytestreamRequest implements BytestreamRequest {
|
|||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Override
|
||||
public void reject() throws NotConnectedException, InterruptedException {
|
||||
this.manager.replyRejectPacket(this.bytestreamRequest);
|
||||
}
|
||||
|
|
|
@ -64,14 +64,17 @@ public class Socks5BytestreamSession implements BytestreamSession {
|
|||
return !this.isDirect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return this.socket.getInputStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream getOutputStream() throws IOException {
|
||||
return this.socket.getOutputStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReadTimeout() throws IOException {
|
||||
try {
|
||||
return this.socket.getSoTimeout();
|
||||
|
@ -81,6 +84,7 @@ public class Socks5BytestreamSession implements BytestreamSession {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadTimeout(int timeout) throws IOException {
|
||||
try {
|
||||
this.socket.setSoTimeout(timeout);
|
||||
|
@ -90,6 +94,7 @@ public class Socks5BytestreamSession implements BytestreamSession {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
this.socket.close();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.bytestreams.socks5;
|
|||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
|
@ -34,6 +35,7 @@ import java.util.logging.Logger;
|
|||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
|
||||
|
||||
/**
|
||||
|
@ -82,6 +84,7 @@ class Socks5Client {
|
|||
// wrap connecting in future for timeout
|
||||
FutureTask<Socket> futureTask = new FutureTask<Socket>(new Callable<Socket>() {
|
||||
|
||||
@Override
|
||||
public Socket call() throws IOException, SmackException {
|
||||
|
||||
// initialize socket
|
||||
|
@ -199,7 +202,13 @@ class Socks5Client {
|
|||
* @return SOCKS5 connection request message
|
||||
*/
|
||||
private byte[] createSocks5ConnectRequest() {
|
||||
byte[] addr = this.digest.getBytes();
|
||||
byte[] addr;
|
||||
try {
|
||||
addr = digest.getBytes(StringUtils.UTF8);
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
|
||||
byte[] data = new byte[7 + addr.length];
|
||||
data[0] = (byte) 0x05; // version (SOCKS5)
|
||||
|
|
|
@ -69,6 +69,7 @@ class Socks5ClientForInitiator extends Socks5Client {
|
|||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Socket getSocket(int timeout) throws IOException, InterruptedException,
|
||||
TimeoutException, XMPPException, SmackException {
|
||||
Socket socket = null;
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
/**
|
||||
* The Socks5Proxy class represents a local SOCKS5 proxy server. It can be enabled/disabled by
|
||||
|
@ -381,6 +382,7 @@ public final class Socks5Proxy {
|
|||
*/
|
||||
private class Socks5ServerProcess implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
Socket socket = null;
|
||||
|
@ -470,7 +472,7 @@ public final class Socks5Proxy {
|
|||
byte[] connectionRequest = Socks5Utils.receiveSocks5Message(in);
|
||||
|
||||
// extract digest
|
||||
String responseDigest = new String(connectionRequest, 5, connectionRequest[4]);
|
||||
String responseDigest = new String(connectionRequest, 5, connectionRequest[4], StringUtils.UTF8);
|
||||
|
||||
// return error if digest is not allowed
|
||||
if (!Socks5Proxy.this.allowedConnections.contains(responseDigest)) {
|
||||
|
|
|
@ -317,6 +317,7 @@ public class Bytestream extends IQ {
|
|||
return port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENTNAME;
|
||||
}
|
||||
|
@ -366,6 +367,7 @@ public class Bytestream extends IQ {
|
|||
return JID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENTNAME;
|
||||
}
|
||||
|
@ -408,6 +410,7 @@ public class Bytestream extends IQ {
|
|||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENTNAME;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ import java.util.WeakHashMap;
|
|||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
|
@ -113,6 +114,7 @@ public final class EntityCapsManager extends Manager {
|
|||
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
|
@ -346,6 +348,7 @@ public final class EntityCapsManager extends Manager {
|
|||
// XEP-0115 specifies that a client SHOULD include entity capabilities
|
||||
// with every presence notification it sends.
|
||||
StanzaListener packetInterceptor = new StanzaListener() {
|
||||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
if (!entityCapsEnabled) {
|
||||
// Be sure to not send stanzas with the caps extension if it's not enabled
|
||||
|
@ -403,7 +406,11 @@ public final class EntityCapsManager extends Manager {
|
|||
* @param user
|
||||
* the user (Full JID)
|
||||
*/
|
||||
// TODO: Change parameter type to Jid in Smack 4.3.
|
||||
@SuppressWarnings("CollectionIncompatibleType")
|
||||
public static void removeUserCapsNode(String user) {
|
||||
// While JID_TO_NODEVER_CHACHE has the generic types <Jid, NodeVerHash>, it is ok to call remove with String
|
||||
// arguments, since the same Jid and String representations would be equal and have the same hash code.
|
||||
JID_TO_NODEVER_CACHE.remove(user);
|
||||
}
|
||||
|
||||
|
@ -658,6 +665,7 @@ public final class EntityCapsManager extends Manager {
|
|||
// XEP-0128 data forms, sort the forms by the FORM_TYPE (i.e.,
|
||||
// by the XML character data of the <value/> element).
|
||||
SortedSet<FormField> fs = new TreeSet<FormField>(new Comparator<FormField>() {
|
||||
@Override
|
||||
public int compare(FormField f1, FormField f2) {
|
||||
return f1.getVariable().compareTo(f2.getVariable());
|
||||
}
|
||||
|
@ -701,9 +709,16 @@ public final class EntityCapsManager extends Manager {
|
|||
// encoded using Base64 as specified in Section 4 of RFC 4648
|
||||
// (note: the Base64 output MUST NOT include whitespace and MUST set
|
||||
// padding bits to zero).
|
||||
byte[] bytes;
|
||||
try {
|
||||
bytes = sb.toString().getBytes(StringUtils.UTF8);
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
byte[] digest;
|
||||
synchronized(md) {
|
||||
digest = md.digest(sb.toString().getBytes());
|
||||
digest = md.digest(bytes);
|
||||
}
|
||||
String version = Base64.encodeToString(digest);
|
||||
return new CapsVersionAndHash(version, hash);
|
||||
|
|
|
@ -35,10 +35,12 @@ public class CapsExtension implements ExtensionElement {
|
|||
this.hash = hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
|
||||
public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtension> {
|
||||
|
||||
@Override
|
||||
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
String hash = null;
|
||||
|
|
|
@ -119,6 +119,7 @@ public final class ChatStateManager extends Manager {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
@ -129,6 +130,7 @@ public final class ChatStateManager extends Manager {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return connection().hashCode();
|
||||
}
|
||||
|
@ -164,12 +166,14 @@ public final class ChatStateManager extends Manager {
|
|||
}
|
||||
}
|
||||
|
||||
private class IncomingMessageInterceptor implements ChatManagerListener, ChatMessageListener {
|
||||
private static class IncomingMessageInterceptor implements ChatManagerListener, ChatMessageListener {
|
||||
|
||||
@Override
|
||||
public void chatCreated(final org.jivesoftware.smack.chat.Chat chat, boolean createdLocally) {
|
||||
chat.addMessageListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processMessage(org.jivesoftware.smack.chat.Chat chat, Message message) {
|
||||
ExtensionElement extension = message.getExtension(NAMESPACE);
|
||||
if (extension == null) {
|
||||
|
|
|
@ -457,12 +457,13 @@ public abstract class AdHocCommand {
|
|||
*/
|
||||
sessionExpired("session-expired");
|
||||
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
SpecificErrorCondition(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.commands;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -83,6 +84,7 @@ public final class AdHocCommandManager extends Manager {
|
|||
*/
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getAddHocCommandsManager(connection);
|
||||
}
|
||||
|
@ -200,8 +202,16 @@ public final class AdHocCommandManager extends Manager {
|
|||
*/
|
||||
public void registerCommand(String node, String name, final Class<? extends LocalCommand> clazz) {
|
||||
registerCommand(node, name, new LocalCommandFactory() {
|
||||
@Override
|
||||
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException {
|
||||
return clazz.newInstance();
|
||||
try {
|
||||
return clazz.getConstructor().newInstance();
|
||||
}
|
||||
catch (IllegalArgumentException | InvocationTargetException | NoSuchMethodException
|
||||
| SecurityException e) {
|
||||
// TODO: Throw those method in Smack 4.3.
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -393,6 +403,7 @@ public final class AdHocCommandManager extends Manager {
|
|||
// See if the session reaping thread is started. If not, start it.
|
||||
if (sessionsSweeper == null) {
|
||||
sessionsSweeper = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
for (String sessionId : executingCommands.keySet()) {
|
||||
|
|
|
@ -248,9 +248,11 @@ public class AdHocCommandData extends IQ {
|
|||
this.condition = condition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return condition.toString();
|
||||
}
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
@ -259,6 +261,7 @@ public class AdHocCommandData extends IQ {
|
|||
return condition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append('<').append(getElementName());
|
||||
|
|
|
@ -88,10 +88,12 @@ public class DelayInformation implements ExtensionElement {
|
|||
return reason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
|
|
@ -25,18 +25,22 @@ import java.util.List;
|
|||
|
||||
public abstract class AbstractNodeInformationProvider implements NodeInformationProvider {
|
||||
|
||||
@Override
|
||||
public List<DiscoverItems.Item> getNodeItems() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNodeFeatures() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DiscoverInfo.Identity> getNodeIdentities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtensionElement> getNodePacketExtensions() {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ public final class ServiceDiscoveryManager extends Manager {
|
|||
// Create a new ServiceDiscoveryManager on every established connection
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
|
|
|
@ -394,6 +394,7 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
|
|||
* <a href="http://xmpp.org/extensions/xep-0115.html#ver-proc">XEP-0015 5.4 Processing Method (Step 3.3)</a>.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
@ -437,6 +438,7 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
|
|||
* @return a negative integer, zero, or a positive integer as this object is less than,
|
||||
* equal to, or greater than the specified object.
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(DiscoverInfo.Identity other) {
|
||||
String otherLang = other.lang == null ? "" : other.lang;
|
||||
String thisLang = lang == null ? "" : lang;
|
||||
|
@ -512,6 +514,7 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
|
|||
return xml;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
|
|
@ -55,11 +55,13 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
secondaryNegotiator.newStreamInitiation(from, streamID);
|
||||
}
|
||||
|
||||
@Override
|
||||
InputStream negotiateIncomingStream(Stanza streamInitiation) {
|
||||
throw new UnsupportedOperationException("Negotiation only handled by create incoming " +
|
||||
"stream method.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream createIncomingStream(final StreamInitiation initiation) throws SmackException, XMPPErrorException, InterruptedException {
|
||||
// This could be either an xep47 ibb 'open' iq or an xep65 streamhost iq
|
||||
IQ initationSet = initiateIncomingStream(connection, initiation);
|
||||
|
@ -79,6 +81,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target)
|
||||
throws SmackException, XMPPException, InterruptedException {
|
||||
OutputStream stream;
|
||||
|
@ -92,6 +95,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
return stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getNamespaces() {
|
||||
String[] primary = primaryNegotiator.getNamespaces();
|
||||
String[] secondary = secondaryNegotiator.getNamespaces();
|
||||
|
|
|
@ -292,12 +292,13 @@ public abstract class FileTransfer {
|
|||
*/
|
||||
cancelled("Cancelled");
|
||||
|
||||
private String status;
|
||||
private final String status;
|
||||
|
||||
private Status(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return status;
|
||||
}
|
||||
|
@ -358,6 +359,7 @@ public abstract class FileTransfer {
|
|||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return msg;
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
|||
this.manager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutputStream createOutgoingStream(String streamID, Jid initiator,
|
||||
Jid target) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
InBandBytestreamSession session = this.manager.establishSession(target, streamID);
|
||||
|
@ -65,6 +66,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
|||
return session.getOutputStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream createIncomingStream(StreamInitiation initiation)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
/*
|
||||
|
@ -87,10 +89,12 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
|||
this.manager.ignoreBytestreamRequestOnce(streamID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getNamespaces() {
|
||||
return new String[] { DataPacketExtension.NAMESPACE };
|
||||
}
|
||||
|
||||
@Override
|
||||
InputStream negotiateIncomingStream(Stanza streamInitiation) throws NotConnectedException, InterruptedException {
|
||||
// build In-Band Bytestream request
|
||||
InBandBytestreamRequest request = new ByteStreamRequest(this.manager,
|
||||
|
|
|
@ -126,6 +126,7 @@ public class IncomingFileTransfer extends FileTransfer {
|
|||
}
|
||||
|
||||
Thread transferThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
inputStream = negotiateStream();
|
||||
|
@ -184,6 +185,7 @@ public class IncomingFileTransfer extends FileTransfer {
|
|||
FutureTask<InputStream> streamNegotiatorTask = new FutureTask<InputStream>(
|
||||
new Callable<InputStream>() {
|
||||
|
||||
@Override
|
||||
public InputStream call() throws Exception {
|
||||
return streamNegotiator
|
||||
.createIncomingStream(recieveRequest.getStreamInitiation());
|
||||
|
@ -220,6 +222,7 @@ public class IncomingFileTransfer extends FileTransfer {
|
|||
return inputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
setStatus(Status.cancelled);
|
||||
}
|
||||
|
|
|
@ -174,6 +174,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
setFileInfo(fileName, fileSize);
|
||||
this.callback = progress;
|
||||
transferThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
OutgoingFileTransfer.this.outputStream = negotiateStream(
|
||||
|
@ -192,7 +193,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
}
|
||||
|
||||
private void checkTransferThread() {
|
||||
if (transferThread != null && transferThread.isAlive() || isDone()) {
|
||||
if ((transferThread != null && transferThread.isAlive()) || isDone()) {
|
||||
throw new IllegalStateException(
|
||||
"File transfer in progress or has already completed.");
|
||||
}
|
||||
|
@ -225,6 +226,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
}
|
||||
|
||||
transferThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
outputStream = negotiateStream(file.getName(), file
|
||||
|
@ -298,6 +300,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
|
||||
setFileInfo(fileName, fileSize);
|
||||
transferThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//Create packet filter
|
||||
try {
|
||||
|
@ -398,6 +401,7 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
return outputStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
setStatus(Status.cancelled);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ public final class GeoLocationManager extends Manager {
|
|||
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ public final class LastActivityManager extends Manager {
|
|||
// Enable the LastActivity support on every established connection
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
LastActivityManager.getInstanceFor(connection);
|
||||
}
|
||||
|
@ -135,6 +136,7 @@ public final class LastActivityManager extends Manager {
|
|||
|
||||
// Listen to all the sent messages to reset the idle time on each one
|
||||
connection.addPacketSendingListener(new StanzaListener() {
|
||||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
Presence presence = (Presence) packet;
|
||||
Presence.Mode mode = presence.getMode();
|
||||
|
|
|
@ -66,6 +66,7 @@ public class DefaultPrivateData implements PrivateData {
|
|||
*
|
||||
* @return the XML element name of the stanza(/packet) extension.
|
||||
*/
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return elementName;
|
||||
}
|
||||
|
@ -75,10 +76,12 @@ public class DefaultPrivateData implements PrivateData {
|
|||
*
|
||||
* @return the XML namespace of the stanza(/packet) extension.
|
||||
*/
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append('<').append(elementName).append(" xmlns=\"").append(namespace).append("\">");
|
||||
|
|
|
@ -71,6 +71,7 @@ public final class VersionManager extends Manager {
|
|||
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
VersionManager.getInstanceFor(connection);
|
||||
}
|
||||
|
|
|
@ -32,48 +32,63 @@ import org.jxmpp.jid.parts.Resourcepart;
|
|||
*/
|
||||
public class DefaultParticipantStatusListener implements ParticipantStatusListener {
|
||||
|
||||
@Override
|
||||
public void joined(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void left(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kicked(EntityFullJid participant, Jid actor, String reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void voiceGranted(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void voiceRevoked(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void banned(EntityFullJid participant, Jid actor, String reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void membershipGranted(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void membershipRevoked(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moderatorGranted(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moderatorRevoked(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ownershipGranted(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ownershipRevoked(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adminGranted(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adminRevoked(EntityFullJid participant) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nicknameChanged(EntityFullJid participant, Resourcepart newNickname) {
|
||||
}
|
||||
|
||||
|
|
|
@ -30,42 +30,55 @@ import org.jxmpp.jid.Jid;
|
|||
*/
|
||||
public class DefaultUserStatusListener implements UserStatusListener {
|
||||
|
||||
@Override
|
||||
public void kicked(Jid actor, String reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void voiceGranted() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void voiceRevoked() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void banned(Jid actor, String reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void membershipGranted() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void membershipRevoked() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moderatorGranted() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moderatorRevoked() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ownershipGranted() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ownershipRevoked() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adminGranted() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adminRevoked() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomDestroyed(MultiUserChat alternateMUC, String reason) {
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,7 @@ public class MultiUserChat {
|
|||
|
||||
// Create a listener for subject updates.
|
||||
subjectListener = new StanzaListener() {
|
||||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
Message msg = (Message) packet;
|
||||
EntityFullJid from = msg.getFrom().asEntityFullJidIfPossible();
|
||||
|
@ -181,6 +182,7 @@ public class MultiUserChat {
|
|||
|
||||
// Create a listener for all presence updates.
|
||||
presenceListener = new StanzaListener() {
|
||||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
Presence presence = (Presence) packet;
|
||||
final EntityFullJid from = presence.getFrom().asEntityFullJidIfPossible();
|
||||
|
@ -251,6 +253,7 @@ public class MultiUserChat {
|
|||
// Listens for all messages that include a MUCUser extension and fire the invitation
|
||||
// rejection listeners if the message includes an invitation rejection.
|
||||
declinesListener = new StanzaListener() {
|
||||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
Message message = (Message) packet;
|
||||
// Get the MUC User extension
|
||||
|
|
|
@ -82,6 +82,7 @@ public final class MultiUserChatManager extends Manager {
|
|||
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
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
|
||||
|
@ -149,6 +150,7 @@ public final class MultiUserChatManager extends Manager {
|
|||
// Listens for all messages that include a MUCUser extension and fire the invitation
|
||||
// listeners if the message includes an invitation.
|
||||
StanzaListener invitationPacketListener = new StanzaListener() {
|
||||
@Override
|
||||
public void processStanza(Stanza packet) {
|
||||
final Message message = (Message) packet;
|
||||
// Get the MUCUser extension
|
||||
|
|
|
@ -110,6 +110,7 @@ public class Occupant {
|
|||
return nick;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof Occupant)) {
|
||||
return false;
|
||||
|
@ -118,6 +119,7 @@ public class Occupant {
|
|||
return jid.equals(occupant.jid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
result = affiliation.hashCode();
|
||||
|
|
|
@ -92,10 +92,12 @@ public class GroupChatInvitation implements ExtensionElement {
|
|||
return roomAddress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
|
|
@ -72,10 +72,12 @@ public class MUCInitialPresence implements ExtensionElement {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
@ -282,6 +284,7 @@ public class MUCInitialPresence implements ExtensionElement {
|
|||
this.since = since;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML() {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.optIntAttribute("maxchars", getMaxChars());
|
||||
|
|
|
@ -158,6 +158,7 @@ public class MUCItem implements NamedElement {
|
|||
return role;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML() {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
xml.optAttribute("affiliation", getAffiliation());
|
||||
|
|
|
@ -50,10 +50,12 @@ public class MUCUser implements ExtensionElement {
|
|||
private String password;
|
||||
private Destroy destroy;
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ public class Nick implements ExtensionElement {
|
|||
*
|
||||
* @see org.jivesoftware.smack.packet.PacketExtension#getElementName()
|
||||
*/
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT_NAME;
|
||||
}
|
||||
|
@ -74,6 +75,7 @@ public class Nick implements ExtensionElement {
|
|||
*
|
||||
* @see org.jivesoftware.smack.packet.PacketExtension#getNamespace()
|
||||
*/
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
@ -83,6 +85,7 @@ public class Nick implements ExtensionElement {
|
|||
*
|
||||
* @see org.jivesoftware.smack.packet.PacketExtension#toXML()
|
||||
*/
|
||||
@Override
|
||||
public String toXML() {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
|
||||
|
|
|
@ -152,6 +152,7 @@ public class OfflineMessageManager {
|
|||
}
|
||||
// Filter offline messages that were requested by this request
|
||||
StanzaFilter messageFilter = new AndFilter(PACKET_FILTER, new StanzaFilter() {
|
||||
@Override
|
||||
public boolean accept(Stanza packet) {
|
||||
OfflineMessageInfo info = (OfflineMessageInfo) packet.getExtension("offline",
|
||||
namespace);
|
||||
|
|
|
@ -42,6 +42,7 @@ public class OfflineMessageInfo implements ExtensionElement {
|
|||
*
|
||||
* @return the XML element name of the stanza(/packet) extension.
|
||||
*/
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return "offline";
|
||||
}
|
||||
|
@ -52,6 +53,7 @@ public class OfflineMessageInfo implements ExtensionElement {
|
|||
*
|
||||
* @return the XML namespace of the stanza(/packet) extension.
|
||||
*/
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return "http://jabber.org/protocol/offline";
|
||||
}
|
||||
|
@ -78,6 +80,7 @@ public class OfflineMessageInfo implements ExtensionElement {
|
|||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append('<').append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
||||
|
|
|
@ -91,6 +91,7 @@ public final class PEPManager extends Manager {
|
|||
private PEPManager(XMPPConnection connection) {
|
||||
super(connection);
|
||||
StanzaListener packetListener = new StanzaListener() {
|
||||
@Override
|
||||
public void processStanza(Stanza stanza) {
|
||||
Message message = (Message) stanza;
|
||||
EventElement event = EventElement.from(stanza);
|
||||
|
|
|
@ -67,6 +67,7 @@ public final class PingManager extends Manager {
|
|||
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
|
@ -402,6 +403,7 @@ public final class PingManager extends Manager {
|
|||
}
|
||||
|
||||
private final Runnable pingServerRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LOGGER.fine("ServerPingTask run()");
|
||||
pingServerIfNecessary();
|
||||
|
|
|
@ -78,6 +78,7 @@ public final class PrivacyListManager extends Manager {
|
|||
static {
|
||||
// Create a new PrivacyListManager on every established connection.
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ public class Affiliation implements ExtensionElement
|
|||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return namespace.getXmlns();
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketE
|
|||
return form;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtensionElement> getExtensions()
|
||||
{
|
||||
if (getConfiguration() == null)
|
||||
|
|
|
@ -610,6 +610,7 @@ public class ConfigureForm extends Form
|
|||
*
|
||||
* @return The node title
|
||||
*/
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return getFieldValue(ConfigureNodeFields.title);
|
||||
|
@ -620,6 +621,7 @@ public class ConfigureForm extends Form
|
|||
*
|
||||
* @param title The node title
|
||||
*/
|
||||
@Override
|
||||
public void setTitle(String title)
|
||||
{
|
||||
addField(ConfigureNodeFields.title, FormField.Type.text_single);
|
||||
|
|
|
@ -58,6 +58,7 @@ public class EventElement implements EmbeddedPacketExtension
|
|||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExtensionElement> getExtensions()
|
||||
{
|
||||
return Arrays.asList(new ExtensionElement[]{getEvent()});
|
||||
|
@ -68,11 +69,13 @@ public class EventElement implements EmbeddedPacketExtension
|
|||
return ext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName()
|
||||
{
|
||||
return "event";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace()
|
||||
{
|
||||
return PubSubNamespace.EVENT.getXmlns();
|
||||
|
|
|
@ -48,8 +48,8 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
|
|||
/** A retract element, which has an optional <b>notify</b> attribute when publishing deletions. */
|
||||
retract(PubSubElementType.RETRACT, "notify");
|
||||
|
||||
private PubSubElementType elem;
|
||||
private String att;
|
||||
private final PubSubElementType elem;
|
||||
private final String att;
|
||||
|
||||
private ItemsElementType(PubSubElementType nodeElement, String attribute)
|
||||
{
|
||||
|
@ -130,6 +130,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
|
|||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ExtensionElement> getExtensions()
|
||||
{
|
||||
|
|
|
@ -604,6 +604,7 @@ abstract public class Node
|
|||
listener = eventListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public void processStanza(Stanza packet)
|
||||
{
|
||||
|
@ -631,6 +632,7 @@ abstract public class Node
|
|||
listener = eventListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processStanza(Stanza packet)
|
||||
{
|
||||
// CHECKSTYLE:OFF
|
||||
|
@ -667,7 +669,7 @@ abstract public class Node
|
|||
*
|
||||
* @author Robin Collier
|
||||
*/
|
||||
public class NodeConfigTranslator implements StanzaListener
|
||||
public static class NodeConfigTranslator implements StanzaListener
|
||||
{
|
||||
private NodeConfigListener listener;
|
||||
|
||||
|
@ -676,12 +678,11 @@ abstract public class Node
|
|||
listener = eventListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processStanza(Stanza packet)
|
||||
{
|
||||
// CHECKSTYLE:OFF
|
||||
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
|
||||
ConfigurationEvent config = (ConfigurationEvent)event.getEvent();
|
||||
// CHECKSTYLE:ON
|
||||
|
||||
listener.handleNodeConfiguration(config);
|
||||
}
|
||||
|
@ -712,6 +713,7 @@ abstract public class Node
|
|||
&& "item".equals(secondLevelElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptSpecific(Message message) {
|
||||
EventElement event = EventElement.from(message);
|
||||
|
||||
|
|
|
@ -65,16 +65,19 @@ public class NodeExtension implements ExtensionElement
|
|||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName()
|
||||
{
|
||||
return element.getElementName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace()
|
||||
{
|
||||
return element.getNamespace().getXmlns();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence toXML()
|
||||
{
|
||||
return '<' + getElementName() + (node == null ? "" : " node='" + node + '\'') + "/>";
|
||||
|
|
|
@ -51,8 +51,8 @@ public enum PubSubElementType
|
|||
SUBSCRIPTIONS("subscriptions", PubSubNamespace.BASIC),
|
||||
UNSUBSCRIBE("unsubscribe", PubSubNamespace.BASIC);
|
||||
|
||||
private String eName;
|
||||
private PubSubNamespace nSpace;
|
||||
private final String eName;
|
||||
private final PubSubNamespace nSpace;
|
||||
|
||||
private PubSubElementType(String elemName, PubSubNamespace ns)
|
||||
{
|
||||
|
|
|
@ -45,16 +45,19 @@ public class RetractItem implements ExtensionElement
|
|||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName()
|
||||
{
|
||||
return "retract";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace()
|
||||
{
|
||||
return PubSubNamespace.EVENT.getXmlns();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML()
|
||||
{
|
||||
return "<retract id='" + id + "'/>";
|
||||
|
|
|
@ -45,11 +45,13 @@ public class SimplePayload implements ExtensionElement
|
|||
ns = namespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName()
|
||||
{
|
||||
return elemName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace()
|
||||
{
|
||||
return ns;
|
||||
|
|
|
@ -133,6 +133,7 @@ public class Subscription extends NodeExtension
|
|||
return configRequired;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder("<subscription");
|
||||
|
|
|
@ -83,6 +83,7 @@ public final class DeliveryReceiptManager extends Manager {
|
|||
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
|
|
|
@ -36,16 +36,19 @@ public class DeliveryReceiptRequest implements ExtensionElement
|
|||
{
|
||||
public static final String ELEMENT = "request";
|
||||
|
||||
@Override
|
||||
public String getElementName()
|
||||
{
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace()
|
||||
{
|
||||
return DeliveryReceipt.NAMESPACE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML()
|
||||
{
|
||||
return "<request xmlns='" + DeliveryReceipt.NAMESPACE + "'/>";
|
||||
|
|
|
@ -44,10 +44,12 @@ public class Header implements ExtensionElement {
|
|||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return HeadersExtension.NAMESPACE;
|
||||
}
|
||||
|
|
|
@ -48,10 +48,12 @@ public class HeadersExtension implements ExtensionElement {
|
|||
return headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
|
|
@ -317,14 +317,17 @@ public class StreamInitiation extends IQ {
|
|||
return isRanged;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return "file";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return "http://jabber.org/protocol/si/profile/file-transfer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
|
||||
|
@ -370,7 +373,7 @@ public class StreamInitiation extends IQ {
|
|||
* @author Alexander Wenckus
|
||||
*
|
||||
*/
|
||||
public class Feature implements ExtensionElement {
|
||||
public static class Feature implements ExtensionElement {
|
||||
|
||||
private final DataForm data;
|
||||
|
||||
|
@ -392,14 +395,17 @@ public class StreamInitiation extends IQ {
|
|||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return "http://jabber.org/protocol/feature-neg";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return "feature";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf
|
||||
|
|
|
@ -43,6 +43,7 @@ public final class EntityTimeManager extends Manager {
|
|||
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
getInstanceFor(connection);
|
||||
}
|
||||
|
|
|
@ -728,6 +728,7 @@ public class VCard extends IQ {
|
|||
|
||||
// Used in tests:
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
@ -776,6 +777,7 @@ public class VCard extends IQ {
|
|||
return workPhones.equals(vCard.workPhones);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
result = homePhones.hashCode();
|
||||
|
|
|
@ -364,6 +364,7 @@ public class FormField implements NamedElement {
|
|||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML() {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this);
|
||||
// Add attributes
|
||||
|
@ -455,6 +456,7 @@ public class FormField implements NamedElement {
|
|||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML() {
|
||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||
// Add attribute
|
||||
|
|
|
@ -171,10 +171,12 @@ public class DataForm implements ExtensionElement {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ public class DataLayout implements ExtensionElement {
|
|||
this.var = var;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML() {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this);
|
||||
buf.attribute("var", getVar());
|
||||
|
@ -181,6 +182,7 @@ public class DataLayout implements ExtensionElement {
|
|||
return this.sectionLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML() {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this);
|
||||
buf.optAttribute("label", getLabel());
|
||||
|
@ -211,6 +213,7 @@ public class DataLayout implements ExtensionElement {
|
|||
|
||||
public static final String ELEMENT = "reportedref";
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML() {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this);
|
||||
buf.closeEmptyElement();
|
||||
|
@ -236,6 +239,7 @@ public class DataLayout implements ExtensionElement {
|
|||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML() {
|
||||
XmlStringBuilder buf = new XmlStringBuilder();
|
||||
buf.element(ELEMENT, getText());
|
||||
|
|
|
@ -144,6 +144,7 @@ public abstract class ValidateElement implements ExtensionElement {
|
|||
buf.emptyElement(METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConsistency(FormField formField) {
|
||||
checkListRangeConsistency(formField);
|
||||
if (formField.getType() != null) {
|
||||
|
@ -186,6 +187,7 @@ public abstract class ValidateElement implements ExtensionElement {
|
|||
buf.emptyElement(METHOD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConsistency(FormField formField) {
|
||||
checkListRangeConsistency(formField);
|
||||
if (formField.getType() != null) {
|
||||
|
@ -253,6 +255,7 @@ public abstract class ValidateElement implements ExtensionElement {
|
|||
return max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConsistency(FormField formField) {
|
||||
checkNonMultiConsistency(formField, METHOD);
|
||||
if (getDatatype().equals(ValidateElement.DATATYPE_XS_STRING)) {
|
||||
|
@ -302,6 +305,7 @@ public abstract class ValidateElement implements ExtensionElement {
|
|||
buf.element("regex", getRegex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkConsistency(FormField formField) {
|
||||
checkNonMultiConsistency(formField, METHOD);
|
||||
}
|
||||
|
@ -340,6 +344,7 @@ public abstract class ValidateElement implements ExtensionElement {
|
|||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlStringBuilder toXML() {
|
||||
XmlStringBuilder buf = new XmlStringBuilder(this);
|
||||
buf.optLongAttribute("min", getMin());
|
||||
|
|
|
@ -40,6 +40,7 @@ import java.util.List;
|
|||
public class XHTMLManager {
|
||||
static {
|
||||
XMPPConnectionRegistry.addConnectionCreationListener(new ConnectionCreationListener() {
|
||||
@Override
|
||||
public void connectionCreated(XMPPConnection connection) {
|
||||
// Enable the XHTML support on every established connection
|
||||
XHTMLManager.setServiceEnabled(connection, true);
|
||||
|
|
|
@ -400,6 +400,7 @@ public class XHTMLText {
|
|||
*
|
||||
* @return the text of the XHTMLText
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return text.toString();
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public class XHTMLExtension implements ExtensionElement {
|
|||
*
|
||||
* @return the XML element name of the stanza(/packet) extension.
|
||||
*/
|
||||
@Override
|
||||
public String getElementName() {
|
||||
return ELEMENT;
|
||||
}
|
||||
|
@ -58,6 +59,7 @@ public class XHTMLExtension implements ExtensionElement {
|
|||
*
|
||||
* @return the XML namespace of the stanza(/packet) extension.
|
||||
*/
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return NAMESPACE;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smackx.bob;
|
|||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.bob.element.BoBIQ;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -50,7 +51,7 @@ public class BoBIQTest extends SmackTestSuite {
|
|||
BoBIQ bobIQ = PacketParserUtils.parseStanza(sampleBoBIQResponse);
|
||||
|
||||
BoBHash bobHash = new BoBHash("8f35fef110ffc5df08d579a50083ff9308fb6242", "sha1");
|
||||
BoBData bobData = new BoBData("image/png", "sarasade2354j2".getBytes(), 86400);
|
||||
BoBData bobData = new BoBData("image/png", "sarasade2354j2".getBytes(StringUtils.UTF8), 86400);
|
||||
|
||||
BoBIQ createdBoBIQ = new BoBIQ(bobHash, bobData);
|
||||
createdBoBIQ.setStanzaId("sarasa");
|
||||
|
|
|
@ -164,6 +164,7 @@ public class InBandBytestreamManagerTest extends InitExtensions {
|
|||
|
||||
protocol.addResponse(null, new Verification<Open, IQ>() {
|
||||
|
||||
@Override
|
||||
public void verify(Open request, IQ response) {
|
||||
assertEquals(StanzaType.MESSAGE, request.getStanza());
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ public class InBandBytestreamSessionMessageTest extends InitExtensions {
|
|||
|
||||
long lastSeq = 0;
|
||||
|
||||
@Override
|
||||
public void verify(Message request, IQ response) {
|
||||
DataPacketExtension dpe = (DataPacketExtension) request.getExtension(
|
||||
DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE);
|
||||
|
|
|
@ -103,6 +103,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
|
|||
|
||||
long lastSeq = 0;
|
||||
|
||||
@Override
|
||||
public void verify(Data request, IQ response) {
|
||||
assertEquals(lastSeq++, request.getDataPacketExtension().getSeq());
|
||||
}
|
||||
|
@ -267,6 +268,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
|
|||
// compares the data of each packet with the control data
|
||||
Verification<Data, IQ> dataVerification = new Verification<Data, IQ>() {
|
||||
|
||||
@Override
|
||||
public void verify(Data request, IQ response) {
|
||||
byte[] decodedData = request.getDataPacketExtension().getDecodedData();
|
||||
int seq = (int) request.getDataPacketExtension().getSeq();
|
||||
|
@ -372,6 +374,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
|
|||
// verify reply to invalid data packet is an error
|
||||
protocol.addResponse(null, Verification.requestTypeERROR, new Verification<IQ, IQ>() {
|
||||
|
||||
@Override
|
||||
public void verify(IQ request, IQ response) {
|
||||
assertEquals(XMPPError.Condition.unexpected_request,
|
||||
request.getError().getCondition());
|
||||
|
@ -410,6 +413,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
|
|||
// verify reply to invalid data packet is an error
|
||||
protocol.addResponse(null, Verification.requestTypeERROR, new Verification<IQ, IQ>() {
|
||||
|
||||
@Override
|
||||
public void verify(IQ request, IQ response) {
|
||||
assertEquals(XMPPError.Condition.bad_request,
|
||||
request.getError().getCondition());
|
||||
|
@ -639,6 +643,7 @@ public class InBandBytestreamSessionTest extends InitExtensions {
|
|||
|
||||
Thread closer = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(200);
|
||||
|
|
|
@ -20,8 +20,10 @@ import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.InitExtensions;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -68,13 +70,13 @@ public class DataPacketExtensionTest extends InitExtensions {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnNullIfDataIsInvalid() {
|
||||
public void shouldReturnNullIfDataIsInvalid() throws UnsupportedEncodingException {
|
||||
// pad character is not at end of data
|
||||
DataPacketExtension data = new DataPacketExtension("sessionID", 0, "BBBB=CCC");
|
||||
assertNull(data.getDecodedData());
|
||||
|
||||
// invalid Base64 character
|
||||
data = new DataPacketExtension("sessionID", 0, new String(new byte[] { 123 }));
|
||||
data = new DataPacketExtension("sessionID", 0, new String(new byte[] { 123 }, StringUtils.UTF8));
|
||||
assertNull(data.getDecodedData());
|
||||
}
|
||||
|
||||
|
|
|
@ -604,6 +604,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
// return used stream host info as response to the bytestream initiation
|
||||
protocol.addResponse(streamHostUsedPacket, new Verification<Bytestream, Bytestream>() {
|
||||
|
||||
@Override
|
||||
public void verify(Bytestream request, Bytestream response) {
|
||||
// verify SOCKS5 Bytestream request
|
||||
assertEquals(response.getSessionID(), request.getSessionID());
|
||||
|
@ -698,6 +699,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
// return used stream host info as response to the bytestream initiation
|
||||
protocol.addResponse(streamHostUsedPacket, new Verification<Bytestream, Bytestream>() {
|
||||
|
||||
@Override
|
||||
public void verify(Bytestream request, Bytestream response) {
|
||||
assertEquals(response.getSessionID(), request.getSessionID());
|
||||
assertEquals(1, request.getStreamHosts().size());
|
||||
|
@ -714,6 +716,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
// return proxy activation response if proxy should be activated
|
||||
protocol.addResponse(activationResponse, new Verification<Bytestream, IQ>() {
|
||||
|
||||
@Override
|
||||
public void verify(Bytestream request, IQ response) {
|
||||
assertEquals(targetJID, request.getToActivate().getTarget());
|
||||
}
|
||||
|
@ -796,6 +799,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
// return used stream host info as response to the bytestream initiation
|
||||
protocol.addResponse(streamHostUsedPacket, new Verification<Bytestream, Bytestream>() {
|
||||
|
||||
@Override
|
||||
public void verify(Bytestream request, Bytestream response) {
|
||||
assertEquals(response.getSessionID(), request.getSessionID());
|
||||
StreamHost streamHost1 = request.getStreamHosts().get(0);
|
||||
|
@ -862,6 +866,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
Verification<Bytestream, Bytestream> streamHostUsedVerification1 = new Verification<Bytestream, Bytestream>() {
|
||||
|
||||
@Override
|
||||
public void verify(Bytestream request, Bytestream response) {
|
||||
assertEquals(response.getSessionID(), request.getSessionID());
|
||||
assertEquals(2, request.getStreamHosts().size());
|
||||
|
@ -898,6 +903,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
Verification<Bytestream, Bytestream> streamHostUsedVerification2 = new Verification<Bytestream, Bytestream>() {
|
||||
|
||||
@Override
|
||||
public void verify(Bytestream request, Bytestream response) {
|
||||
assertEquals(response.getSessionID(), request.getSessionID());
|
||||
assertEquals(2, request.getStreamHosts().size());
|
||||
|
@ -946,6 +952,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
|
||||
Verification<Bytestream, Bytestream> streamHostUsedVerification = new Verification<Bytestream, Bytestream>() {
|
||||
|
||||
@Override
|
||||
public void verify(Bytestream request, Bytestream response) {
|
||||
assertEquals(response.getSessionID(), request.getSessionID());
|
||||
assertEquals(2, request.getStreamHosts().size());
|
||||
|
@ -1079,6 +1086,7 @@ public class Socks5ByteStreamManagerTest {
|
|||
// return proxy activation response if proxy should be activated
|
||||
protocol.addResponse(activationResponse, new Verification<Bytestream, IQ>() {
|
||||
|
||||
@Override
|
||||
public void verify(Bytestream request, IQ response) {
|
||||
assertEquals(targetJID, request.getToActivate().getTarget());
|
||||
}
|
||||
|
|
|
@ -254,6 +254,7 @@ public class Socks5ClientForInitiatorTest {
|
|||
protocol.addResponse(activationResponse, Verification.correspondingSenderReceiver,
|
||||
Verification.requestTypeSET, new Verification<Bytestream, IQ>() {
|
||||
|
||||
@Override
|
||||
public void verify(Bytestream request, IQ response) {
|
||||
// verify that the correct stream should be activated
|
||||
assertNotNull(request.getToActivate());
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.net.Socket;
|
|||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.util.NetworkUtil;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream.StreamHost;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
|
@ -236,7 +237,7 @@ public class Socks5ClientTest {
|
|||
// reply with full SOCKS5 message with an error code (01 = general SOCKS server
|
||||
// failure)
|
||||
out.write(new byte[] { (byte) 0x05, (byte) 0x01, (byte) 0x00, (byte) 0x03 });
|
||||
byte[] address = digest.getBytes();
|
||||
byte[] address = digest.getBytes(StringUtils.UTF8);
|
||||
out.write(address.length);
|
||||
out.write(address);
|
||||
out.write(new byte[] { (byte) 0x00, (byte) 0x00 });
|
||||
|
@ -295,7 +296,7 @@ public class Socks5ClientTest {
|
|||
out.write(new byte[] { (byte) 0x05, (byte) 0x00 });
|
||||
out.flush();
|
||||
|
||||
byte[] address = digest.getBytes();
|
||||
byte[] address = digest.getBytes(StringUtils.UTF8);
|
||||
|
||||
assertEquals((byte) 0x05, (byte) in.read()); // version
|
||||
assertEquals((byte) 0x01, (byte) in.read()); // connect request
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.net.UnknownHostException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -272,7 +273,7 @@ public class Socks5ProxyTest {
|
|||
proxy.start();
|
||||
|
||||
assertTrue(proxy.isRunning());
|
||||
String digest = new String(new byte[] { (byte) 0xAA });
|
||||
String digest = new String(new byte[] { (byte) 0xAA }, StringUtils.UTF8);
|
||||
|
||||
// add digest to allow connection
|
||||
proxy.addTransfer(digest);
|
||||
|
|
|
@ -30,6 +30,7 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Simple SOCKS5 proxy for testing purposes. It is almost the same as the Socks5Proxy class but the
|
||||
|
@ -206,6 +207,7 @@ public final class Socks5TestProxy {
|
|||
*/
|
||||
class Socks5ServerProcess implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
Socket socket = null;
|
||||
|
@ -295,7 +297,7 @@ public final class Socks5TestProxy {
|
|||
byte[] connectionRequest = Socks5Utils.receiveSocks5Message(in);
|
||||
|
||||
// extract digest
|
||||
String responseDigest = new String(connectionRequest, 5, connectionRequest[4]);
|
||||
String responseDigest = new String(connectionRequest, 5, connectionRequest[4], StringUtils.UTF8);
|
||||
|
||||
connectionRequest[1] = (byte) 0x00; // set return status to 0 (success)
|
||||
out.write(connectionRequest);
|
||||
|
|
|
@ -88,7 +88,7 @@ public class DataValidationTest {
|
|||
assertEquals("min-val", rdv.getMin());
|
||||
assertEquals("max-val", rdv.getMax());
|
||||
assertNotNull(rdv.getListRange());
|
||||
assertEquals(new Long(111), rdv.getListRange().getMin());
|
||||
assertEquals(Long.valueOf(111), rdv.getListRange().getMin());
|
||||
assertEquals(999, rdv.getListRange().getMax().intValue());
|
||||
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ public class ConnectionUtils {
|
|||
|
||||
// mock send method
|
||||
Answer<Object> addIncoming = new Answer<Object>() {
|
||||
@Override
|
||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
||||
protocol.getRequests().add((Stanza) invocation.getArguments()[0]);
|
||||
return null;
|
||||
|
@ -101,6 +102,7 @@ public class ConnectionUtils {
|
|||
|
||||
// mock receive methods
|
||||
Answer<Stanza> answer = new Answer<Stanza>() {
|
||||
@Override
|
||||
public Stanza answer(InvocationOnMock invocation) throws Throwable {
|
||||
return protocol.getResponses().poll();
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
*/
|
||||
public static Verification<Stanza, Stanza> correspondingSenderReceiver = new Verification<Stanza, Stanza>() {
|
||||
|
||||
@Override
|
||||
public void verify(Stanza request, Stanza response) {
|
||||
assertEquals(response.getFrom(), request.getTo());
|
||||
}
|
||||
|
@ -50,6 +51,7 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
*/
|
||||
public static Verification<IQ, Stanza> requestTypeGET = new Verification<IQ, Stanza>() {
|
||||
|
||||
@Override
|
||||
public void verify(IQ request, Stanza response) {
|
||||
assertEquals(IQ.Type.get, request.getType());
|
||||
}
|
||||
|
@ -61,6 +63,7 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
*/
|
||||
public static Verification<IQ, Stanza> requestTypeSET = new Verification<IQ, Stanza>() {
|
||||
|
||||
@Override
|
||||
public void verify(IQ request, Stanza response) {
|
||||
assertEquals(IQ.Type.set, request.getType());
|
||||
}
|
||||
|
@ -72,6 +75,7 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
*/
|
||||
public static Verification<IQ, Stanza> requestTypeRESULT = new Verification<IQ, Stanza>() {
|
||||
|
||||
@Override
|
||||
public void verify(IQ request, Stanza response) {
|
||||
assertEquals(IQ.Type.result, request.getType());
|
||||
}
|
||||
|
@ -83,6 +87,7 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
*/
|
||||
public static Verification<IQ, Stanza> requestTypeERROR = new Verification<IQ, Stanza>() {
|
||||
|
||||
@Override
|
||||
public void verify(IQ request, Stanza response) {
|
||||
assertEquals(IQ.Type.error, request.getType());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue