思特奇智慧酒店云平台 v0.0.5版本的 MD5 值为:dedb172bb322639d79d7e0e26262fb5c
以下内容为反编译后的 FileTransferManager.java 源代码,内容仅作参考
package org.jivesoftware.smackx.filetransfer;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smackx.si.packet.StreamInitiation;
public final class FileTransferManager extends Manager {
public static final Map<XMPPConnection, FileTransferManager> INSTANCES = new WeakHashMap();
public final FileTransferNegotiator fileTransferNegotiator;
public final List<FileTransferListener> listeners;
public FileTransferManager(XMPPConnection xMPPConnection) {
super(xMPPConnection);
this.listeners = new CopyOnWriteArrayList();
this.fileTransferNegotiator = FileTransferNegotiator.getInstanceFor(xMPPConnection);
xMPPConnection.registerIQRequestHandler(new AbstractIqRequestHandler(StreamInitiation.ELEMENT, "http://jabber.org/protocol/si", IQ.Type.set, IQRequestHandler.Mode.async) {
@Override
public IQ handleIQRequest(IQ iq) {
FileTransferRequest fileTransferRequest = new FileTransferRequest(FileTransferManager.this, (StreamInitiation) iq);
for (FileTransferListener fileTransferListener : FileTransferManager.this.listeners) {
fileTransferListener.fileTransferRequest(fileTransferRequest);
}
return null;
}
});
}
public static synchronized FileTransferManager getInstanceFor(XMPPConnection xMPPConnection) {
FileTransferManager fileTransferManager;
synchronized (FileTransferManager.class) {
fileTransferManager = INSTANCES.get(xMPPConnection);
if (fileTransferManager == null) {
fileTransferManager = new FileTransferManager(xMPPConnection);
INSTANCES.put(xMPPConnection, fileTransferManager);
}
}
return fileTransferManager;
}
public void addFileTransferListener(FileTransferListener fileTransferListener) {
this.listeners.add(fileTransferListener);
}
public IncomingFileTransfer createIncomingFileTransfer(FileTransferRequest fileTransferRequest) {
if (fileTransferRequest != null) {
IncomingFileTransfer incomingFileTransfer = new IncomingFileTransfer(fileTransferRequest, this.fileTransferNegotiator);
incomingFileTransfer.setFileInfo(fileTransferRequest.getFileName(), fileTransferRequest.getFileSize());
return incomingFileTransfer;
}
throw new NullPointerException("ReceiveRequest cannot be null");
}
public OutgoingFileTransfer createOutgoingFileTransfer(uw3 uw3Var) {
if (uw3Var != null) {
return new OutgoingFileTransfer(connection().getUser(), uw3Var, FileTransferNegotiator.getNextStreamID(), this.fileTransferNegotiator);
}
throw new IllegalArgumentException("userID was null");
}
public void rejectIncomingFileTransfer(FileTransferRequest fileTransferRequest) throws SmackException.NotConnectedException, InterruptedException {
connection().sendStanza(IQ.createErrorResponse(fileTransferRequest.getStreamInitiation(), StanzaError.getBuilder(StanzaError.Condition.forbidden)));
}
public void removeFileTransferListener(FileTransferListener fileTransferListener) {
this.listeners.remove(fileTransferListener);
}
}