27 lines
1.0 KiB
Java
27 lines
1.0 KiB
Java
package de.vanitasvitae.sync_client;
|
|
|
|
import java.io.File;
|
|
|
|
import org.jivesoftware.smack.SmackException;
|
|
import org.jivesoftware.smack.XMPPException;
|
|
import org.jivesoftware.smackx.jft.JingleFileTransferManager;
|
|
|
|
import org.jxmpp.stringprep.XmppStringprepException;
|
|
|
|
public class Slave extends Client {
|
|
|
|
public Slave(String username, String password, String dir) throws XmppStringprepException {
|
|
super(username, password, dir);
|
|
JingleFileTransferManager jingleFileTransferManager = JingleFileTransferManager.getInstanceFor(connection);
|
|
jingleFileTransferManager.addIncomingFileOfferListener(offer -> {
|
|
try {
|
|
File target = new File(root.toFile(), offer.getFile().getName());
|
|
target.getParentFile().mkdirs();
|
|
offer.accept(connection, target);
|
|
} catch (InterruptedException | XMPPException.XMPPErrorException | SmackException.NoResponseException | SmackException.NotConnectedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
});
|
|
}
|
|
}
|