CarrotChat v2.8.60.240131版本的 MD5 值为:2baf8b9f31830b86b5c5a85ae6b47e05

以下内容为反编译后的 IBBTransferNegotiator.java 源代码,内容仅作参考


package org.jivesoftware.smackx.filetransfer;

import java.io.InputStream;
import java.io.OutputStream;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamManager;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamRequest;
import org.jivesoftware.smackx.bytestreams.ibb.InBandBytestreamSession;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Open;
import org.jivesoftware.smackx.si.packet.StreamInitiation;
import org.jxmpp.jid.Jid;
public class IBBTransferNegotiator extends StreamNegotiator {
    private final InBandBytestreamManager manager;

    public static final class ByteStreamRequest extends InBandBytestreamRequest {
        private ByteStreamRequest(InBandBytestreamManager inBandBytestreamManager, Open open) {
            super(inBandBytestreamManager, open);
        }
    }

    public IBBTransferNegotiator(XMPPConnection xMPPConnection) {
        super(xMPPConnection);
        this.manager = InBandBytestreamManager.getByteStreamManager(xMPPConnection);
    }

    @Override
    public InputStream createIncomingStream(StreamInitiation streamInitiation) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
        this.manager.ignoreBytestreamRequestOnce(streamInitiation.getSessionID());
        return negotiateIncomingStream(initiateIncomingStream(connection(), streamInitiation));
    }

    @Override
    public OutputStream createOutgoingStream(String str, Jid jid, Jid jid2) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException {
        InBandBytestreamSession establishSession = this.manager.establishSession(jid2, str);
        establishSession.setCloseBothStreamsEnabled(true);
        return establishSession.getOutputStream();
    }

    @Override
    public String[] getNamespaces() {
        return new String[]{"http://jabber.org/protocol/ibb"};
    }

    @Override
    InputStream negotiateIncomingStream(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException {
        InBandBytestreamSession accept = new ByteStreamRequest(this.manager, (Open) stanza).accept();
        accept.setCloseBothStreamsEnabled(true);
        return accept.getInputStream();
    }

    @Override
    public void newStreamInitiation(Jid jid, String str) {
        this.manager.ignoreBytestreamRequestOnce(str);
    }
}