1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

Work on file transfer listeners

This commit is contained in:
vanitasvitae 2017-07-27 15:58:11 +02:00
parent 980c324f27
commit 5ce12974c8
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
12 changed files with 109 additions and 45 deletions

View file

@ -21,14 +21,12 @@ import org.jivesoftware.smackx.jft.listener.IncomingFileRequestListener;
import org.jivesoftware.smackx.jft.provider.JingleFileTransferProvider;
import org.jivesoftware.smackx.jingle.JingleDescriptionManager;
import org.jivesoftware.smackx.jingle.JingleManager;
import org.jivesoftware.smackx.jingle.util.Role;
import org.jivesoftware.smackx.jingle.callbacks.ContentAddCallback;
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
import org.jivesoftware.smackx.jingle.element.JingleElement;
import org.jivesoftware.smackx.jingle.JingleTransportManager;
import org.jivesoftware.smackx.jingle.components.JingleContent;
import org.jivesoftware.smackx.jingle.components.JingleSession;
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
import org.jivesoftware.smackx.jingle.JingleTransportManager;
import org.jivesoftware.smackx.jingle.util.Role;
import org.jxmpp.jid.FullJid;
@ -126,7 +124,14 @@ public final class JingleFileTransferManager extends Manager implements JingleDe
}
@Override
public JingleElement notifyContentListeners(JingleContent content, ContentAddCallback callback) {
public void notifySessionInitiate(JingleSession session) {
JingleContent content = session.getSoleContentOrThrow();
AbstractJingleFileTransfer transfer = (AbstractJingleFileTransfer) content.getDescription();
if (transfer.isOffer()) {
notifyIncomingFileOfferListeners((JingleIncomingFileOffer) transfer);
} else {
notifyIncomingFileRequestListeners((JingleIncomingFileRequest) transfer);
}
}
}

View file

@ -0,0 +1,27 @@
package org.jivesoftware.smackx.jft.callback;
import java.io.File;
import org.jivesoftware.smackx.jft.controller.IncomingFileOfferController;
import org.jivesoftware.smackx.jingle.callbacks.JingleCallback;
/**
* Created by vanitas on 27.07.17.
*/
public interface IncomingFileOfferCallback extends JingleCallback<IncomingFileOfferCallback.Destination> {
@Override
IncomingFileOfferController accept(Destination destination);
class Destination extends JingleCallback.Parameters {
private final File destination;
public Destination(File destination) {
this.destination = destination;
}
public File getDestination() {
return destination;
}
}
}

View file

@ -1,9 +1,10 @@
package org.jivesoftware.smackx.jft.controller;
import org.jivesoftware.smackx.jingle.controller.JingleDescriptionController;
import org.jivesoftware.smackx.jingle.JingleDescriptionController;
/**
* Created by vanitas on 27.07.17.
*/
public interface IncomingFileOfferController extends JingleDescriptionController {
}

View file

@ -1,6 +1,6 @@
package org.jivesoftware.smackx.jft.controller;
import org.jivesoftware.smackx.jingle.controller.JingleDescriptionController;
import org.jivesoftware.smackx.jingle.JingleDescriptionController;
/**
* Created by vanitas on 27.07.17.

View file

@ -11,4 +11,7 @@ public abstract class AbstractJingleFileTransfer extends JingleDescription<Jingl
public static final String NAMESPACE_V5 = "urn:xmpp:jingle:apps:file-transfer:5";
public static final String NAMESPACE = NAMESPACE_V5;
public abstract boolean isOffer();
public abstract boolean isRequest();
}