/** * Creates an OutgoingFileTransfer to send a file to another user. * * @param userID * The fully qualified jabber ID (i.e. full JID) with resource of the user to * send the file to. * @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(EntityFullJid 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. if (userID == null) { throw new IllegalArgumentException("userID was null"); } return new OutgoingFileTransfer(connection().getUser(), userID, FileTransferNegotiator.getNextStreamID(), fileTransferNegotiator); }
/** * Reject an incoming file transfer. * <p> * Specified in XEP-95 4.2 and 3.2 Example 8 * </p> * @param request * @throws NotConnectedException * @throws InterruptedException */ protected void rejectIncomingFileTransfer(FileTransferRequest request) throws NotConnectedException, InterruptedException { StreamInitiation initiation = request.getStreamInitiation(); // Reject as specified in XEP-95 4.2. Note that this is not to be confused with the Socks 5 // Bytestream rejection as specified in XEP-65 5.3.1 Example 13, which says that // 'not-acceptable' should be returned. This is done by Smack in // Socks5BytestreamManager.replyRejectPacket(IQ). IQ rejection = IQ.createErrorResponse(initiation, StanzaError.getBuilder( StanzaError.Condition.forbidden)); connection().sendStanza(rejection); } }