mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-14 06:51:08 +01:00
Use Jid (and subclasses) from jxmpp-jid
Fixes SMACK-634
This commit is contained in:
parent
0ee2d9ed1e
commit
5bb4727c57
180 changed files with 1510 additions and 1032 deletions
|
|
@ -39,6 +39,7 @@ import org.jivesoftware.smack.filter.OrFilter;
|
|||
import org.jivesoftware.smack.filter.PacketFilter;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -61,7 +62,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
this.connection = connection;
|
||||
}
|
||||
|
||||
public PacketFilter getInitiationPacketFilter(String from, String streamID) {
|
||||
public PacketFilter getInitiationPacketFilter(Jid from, String streamID) {
|
||||
if (primaryFilter == null || secondaryFilter == null) {
|
||||
primaryFilter = primaryNegotiator.getInitiationPacketFilter(from, streamID);
|
||||
secondaryFilter = secondaryNegotiator.getInitiationPacketFilter(from, streamID);
|
||||
|
|
@ -143,7 +144,7 @@ public class FaultTolerantNegotiator extends StreamNegotiator {
|
|||
return primaryFilter.accept(streamInitiation) ? primaryNegotiator : secondaryNegotiator;
|
||||
}
|
||||
|
||||
public OutputStream createOutgoingStream(String streamID, String initiator, String target)
|
||||
public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target)
|
||||
throws SmackException, XMPPException, InterruptedException {
|
||||
OutputStream stream;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* Contains the generic file information and progress related to a particular
|
||||
* file transfer.
|
||||
|
|
@ -35,7 +37,7 @@ public abstract class FileTransfer {
|
|||
|
||||
private long fileSize;
|
||||
|
||||
private String peer;
|
||||
private Jid peer;
|
||||
|
||||
private Status status = Status.initial;
|
||||
|
||||
|
|
@ -56,7 +58,7 @@ public abstract class FileTransfer {
|
|||
*/
|
||||
private static final int BUFFER_SIZE = 8192;
|
||||
|
||||
protected FileTransfer(String peer, String streamID,
|
||||
protected FileTransfer(Jid peer, String streamID,
|
||||
FileTransferNegotiator negotiator) {
|
||||
this.peer = peer;
|
||||
this.streamID = streamID;
|
||||
|
|
@ -106,7 +108,7 @@ public abstract class FileTransfer {
|
|||
*
|
||||
* @return Returns the JID of the peer for this file transfer.
|
||||
*/
|
||||
public String getPeer() {
|
||||
public Jid getPeer() {
|
||||
return peer;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
import org.jxmpp.jid.FullJid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -33,7 +33,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
|
||||
/**
|
||||
* The file transfer manager class handles the sending and recieving of files.
|
||||
* To send a file invoke the {@link #createOutgoingFileTransfer(String)} method.
|
||||
* To send a file invoke the {@link #createOutgoingFileTransfer(FullJid)} method.
|
||||
* <p>
|
||||
* And to recieve a file add a file transfer listener to the manager. The
|
||||
* listener will notify you when there is a new file transfer request. To create
|
||||
|
|
@ -117,15 +117,12 @@ public class FileTransferManager extends Manager {
|
|||
* @return The send file object on which the negotiated transfer can be run.
|
||||
* @exception IllegalArgumentException if userID is null or not a full JID
|
||||
*/
|
||||
public OutgoingFileTransfer createOutgoingFileTransfer(String userID) {
|
||||
if (userID == null) {
|
||||
throw new IllegalArgumentException("userID was null");
|
||||
}
|
||||
public OutgoingFileTransfer createOutgoingFileTransfer(FullJid userID) {
|
||||
// We need to create outgoing file transfers with a full JID since this method will later
|
||||
// use XEP-0095 to negotiate the stream. This is done with IQ stanzas that need to be addressed to a full JID
|
||||
// in order to reach an client entity.
|
||||
else if (!XmppStringUtils.isFullJID(userID)) {
|
||||
throw new IllegalArgumentException("The provided user id was not a full JID (i.e. with resource part)");
|
||||
if (userID == null) {
|
||||
throw new IllegalArgumentException("userID was null");
|
||||
}
|
||||
|
||||
return new OutgoingFileTransfer(connection().getUser(), userID,
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import org.jivesoftware.smackx.filetransfer.FileTransferException.NoStreamMethod
|
|||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* Manages the negotiation of file transfers according to XEP-0096. If a file is
|
||||
|
|
@ -302,7 +303,7 @@ public class FileTransferNegotiator extends Manager {
|
|||
* @throws NoAcceptableTransferMechanisms
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
public StreamNegotiator negotiateOutgoingTransfer(final String userID,
|
||||
public StreamNegotiator negotiateOutgoingTransfer(final Jid userID,
|
||||
final String streamID, final String fileName, final long size,
|
||||
final String desc, int responseTimeout) throws XMPPErrorException, NotConnectedException, NoResponseException, NoAcceptableTransferMechanisms, InterruptedException {
|
||||
StreamInitiation si = new StreamInitiation();
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package org.jivesoftware.smackx.filetransfer;
|
|||
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* A request to send a file recieved from another user.
|
||||
|
|
@ -88,7 +89,7 @@ public class FileTransferRequest {
|
|||
* @return Returns the fully-qualified jabber ID of the user that requested
|
||||
* this file transfer.
|
||||
*/
|
||||
public String getRequestor() {
|
||||
public Jid getRequestor() {
|
||||
return streamInitiation.getFrom();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession;
|
|||
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
|
||||
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* The In-Band Bytestream file transfer method, or IBB for short, transfers the
|
||||
|
|
@ -62,8 +63,8 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
|||
this.manager = InBandBytestreamManager.getByteStreamManager(connection);
|
||||
}
|
||||
|
||||
public OutputStream createOutgoingStream(String streamID, String initiator,
|
||||
String target) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
public OutputStream createOutgoingStream(String streamID, Jid initiator,
|
||||
Jid target) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
InBandBytestreamSession session = this.manager.establishSession(target, streamID);
|
||||
session.setCloseBothStreamsEnabled(true);
|
||||
return session.getOutputStream();
|
||||
|
|
@ -81,7 +82,7 @@ public class IBBTransferNegotiator extends StreamNegotiator {
|
|||
return negotiateIncomingStream(streamInitiation);
|
||||
}
|
||||
|
||||
public PacketFilter getInitiationPacketFilter(String from, String streamID) {
|
||||
public PacketFilter getInitiationPacketFilter(Jid from, String streamID) {
|
||||
/*
|
||||
* this method is always called prior to #negotiateIncomingStream() so
|
||||
* the In-Band Bytestream initiation listener must ignore the next
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.jivesoftware.smack.SmackException.IllegalStateChangeException;
|
|||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* Handles the sending of a file to another user. File transfer's in jabber have
|
||||
|
|
@ -70,11 +71,11 @@ public class OutgoingFileTransfer extends FileTransfer {
|
|||
|
||||
private OutputStream outputStream;
|
||||
|
||||
private String initiator;
|
||||
private Jid initiator;
|
||||
|
||||
private Thread transferThread;
|
||||
|
||||
protected OutgoingFileTransfer(String initiator, String target,
|
||||
protected OutgoingFileTransfer(Jid initiator, Jid target,
|
||||
String streamID, FileTransferNegotiator transferNegotiator) {
|
||||
super(target, streamID, transferNegotiator);
|
||||
this.initiator = initiator;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest;
|
|||
import org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamSession;
|
||||
import org.jivesoftware.smackx.bytestreams.socks5.packet.Bytestream;
|
||||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
/**
|
||||
* Negotiates a SOCKS5 Bytestream to be used for file transfers. The implementation is based on the
|
||||
|
|
@ -57,7 +58,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OutputStream createOutgoingStream(String streamID, String initiator, String target) throws NoResponseException, SmackException, XMPPException
|
||||
public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target) throws NoResponseException, SmackException, XMPPException
|
||||
{
|
||||
try {
|
||||
return this.manager.establishSession(target, streamID).getOutputStream();
|
||||
|
|
@ -84,7 +85,7 @@ public class Socks5TransferNegotiator extends StreamNegotiator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PacketFilter getInitiationPacketFilter(final String from, String streamID) {
|
||||
public PacketFilter getInitiationPacketFilter(final Jid from, String streamID) {
|
||||
/*
|
||||
* this method is always called prior to #negotiateIncomingStream() so the SOCKS5
|
||||
* InitiationListener must ignore the next SOCKS5 Bytestream request with the given session
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.jivesoftware.smack.packet.Stanza;
|
|||
import org.jivesoftware.smackx.si.packet.StreamInitiation;
|
||||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
|
@ -94,7 +95,7 @@ public abstract class StreamNegotiator {
|
|||
* @return The <b><i>PacketFilter</b></i> that will return the packet relatable to the stream
|
||||
* initiation.
|
||||
*/
|
||||
public abstract PacketFilter getInitiationPacketFilter(String from, String streamID);
|
||||
public abstract PacketFilter getInitiationPacketFilter(Jid from, String streamID);
|
||||
|
||||
|
||||
abstract InputStream negotiateIncomingStream(Stanza streamInitiation) throws XMPPErrorException,
|
||||
|
|
@ -137,7 +138,7 @@ public abstract class StreamNegotiator {
|
|||
* @throws InterruptedException
|
||||
*/
|
||||
public abstract OutputStream createOutgoingStream(String streamID,
|
||||
String initiator, String target) throws XMPPErrorException, NoResponseException, SmackException, XMPPException, InterruptedException;
|
||||
Jid initiator, Jid target) throws XMPPErrorException, NoResponseException, SmackException, XMPPException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Returns the XMPP namespace reserved for this particular type of file
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue