mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Merge master 4.2.1
This commit is contained in:
commit
9ff0333032
42 changed files with 357 additions and 256 deletions
|
@ -32,9 +32,9 @@ public class SlotRequest extends IQ {
|
|||
public static final String ELEMENT = "request";
|
||||
public static final String NAMESPACE = HttpFileUploadManager.NAMESPACE;
|
||||
|
||||
private final String filename;
|
||||
private final long size;
|
||||
private final String contentType;
|
||||
protected final String filename;
|
||||
protected final long size;
|
||||
protected final String contentType;
|
||||
|
||||
public SlotRequest(DomainBareJid uploadServiceAddress, String filename, long size) {
|
||||
this(uploadServiceAddress, filename, size, null);
|
||||
|
@ -82,10 +82,10 @@ public class SlotRequest extends IQ {
|
|||
|
||||
@Override
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
xml.element("filename", filename);
|
||||
xml.element("size", String.valueOf(size));
|
||||
xml.optElement("content-type", contentType);
|
||||
xml.attribute("filename", filename);
|
||||
xml.attribute("size", String.valueOf(size));
|
||||
xml.optAttribute("content-type", contentType);
|
||||
xml.setEmptyElement();
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,4 +40,13 @@ public class SlotRequest_V0_2 extends SlotRequest {
|
|||
public SlotRequest_V0_2(DomainBareJid uploadServiceAddress, String filename, long size, String contentType) {
|
||||
super(uploadServiceAddress, filename, size, contentType, NAMESPACE);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder xml) {
|
||||
xml.rightAngleBracket();
|
||||
xml.element("filename", filename);
|
||||
xml.element("size", String.valueOf(size));
|
||||
xml.optElement("content-type", contentType);
|
||||
return xml;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,6 @@ import org.jivesoftware.smackx.ciphers.Aes256GcmNoPadding;
|
|||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.jet.component.JetSecurity;
|
||||
import org.jivesoftware.smackx.jet.provider.JetSecurityProvider;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.JingleFileTransferManager;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleOutgoingFileOffer;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.OutgoingFileOfferController;
|
||||
import org.jivesoftware.smackx.jingle.JingleDescriptionManager;
|
||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
||||
|
@ -39,6 +36,9 @@ import org.jivesoftware.smackx.jingle.component.JingleContent;
|
|||
import org.jivesoftware.smackx.jingle.component.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
import org.jivesoftware.smackx.jingle.util.Role;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.JingleFileTransferManager;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleOutgoingFileOffer;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.OutgoingFileOfferController;
|
||||
|
||||
import org.jxmpp.jid.FullJid;
|
||||
|
||||
|
|
|
@ -30,6 +30,14 @@ import org.jivesoftware.smack.SmackException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
||||
import org.jivesoftware.smackx.jingle.JingleDescriptionManager;
|
||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
||||
import org.jivesoftware.smackx.jingle.component.JingleContent;
|
||||
import org.jivesoftware.smackx.jingle.component.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.component.JingleTransport;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
import org.jivesoftware.smackx.jingle.util.Role;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.adapter.JingleFileTransferAdapter;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransfer;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransferFile;
|
||||
|
@ -42,14 +50,6 @@ import org.jivesoftware.smackx.jingle_filetransfer.controller.OutgoingFileReques
|
|||
import org.jivesoftware.smackx.jingle_filetransfer.listener.IncomingFileOfferListener;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.listener.IncomingFileRequestListener;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.provider.JingleFileTransferProvider;
|
||||
import org.jivesoftware.smackx.jingle.JingleDescriptionManager;
|
||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||
import org.jivesoftware.smackx.jingle.JingleTransportManager;
|
||||
import org.jivesoftware.smackx.jingle.component.JingleContent;
|
||||
import org.jivesoftware.smackx.jingle.component.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.component.JingleTransport;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
import org.jivesoftware.smackx.jingle.util.Role;
|
||||
|
||||
import org.jxmpp.jid.FullJid;
|
||||
|
||||
|
|
|
@ -21,14 +21,14 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.packet.NamedElement;
|
||||
import org.jivesoftware.smackx.jingle.adapter.JingleDescriptionAdapter;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransfer;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleIncomingFileOffer;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleIncomingFileRequest;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferElement;
|
||||
import org.jivesoftware.smackx.jingle.adapter.JingleDescriptionAdapter;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
|
||||
/**
|
||||
* Created by vanitas on 28.07.17.
|
||||
|
|
|
@ -20,10 +20,10 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.component.JingleDescription;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.JingleFileTransferController;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.listener.ProgressListener;
|
||||
import org.jivesoftware.smackx.jingle.component.JingleDescription;
|
||||
|
||||
/**
|
||||
* Created by vanitas on 22.07.17.
|
||||
|
|
|
@ -29,11 +29,11 @@ import org.jivesoftware.smack.SmackException;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.IncomingFileOfferController;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
|
||||
import org.jivesoftware.smackx.jingle.component.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionInfoElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.IncomingFileOfferController;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
|
||||
|
||||
/**
|
||||
* Behind the scenes logic of an incoming Jingle file offer.
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
package org.jivesoftware.smackx.jingle_filetransfer.component;
|
||||
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionInfoElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.IncomingFileRequestController;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionInfoElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||
|
||||
/**
|
||||
* Created by vanitas on 27.07.17.
|
||||
|
|
|
@ -25,9 +25,9 @@ import java.util.logging.Level;
|
|||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.OutgoingFileOfferController;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionInfoElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.OutgoingFileOfferController;
|
||||
|
||||
/**
|
||||
* Created by vanitas on 26.07.17.
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
package org.jivesoftware.smackx.jingle_filetransfer.component;
|
||||
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.OutgoingFileRequestController;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionInfoElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.controller.OutgoingFileRequestController;
|
||||
|
||||
/**
|
||||
* Created by vanitas on 27.07.17.
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle_filetransfer.controller;
|
||||
|
||||
import org.jivesoftware.smackx.jingle.JingleDescriptionController;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransferFile;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.listener.ProgressListener;
|
||||
import org.jivesoftware.smackx.jingle.JingleDescriptionController;
|
||||
|
||||
/**
|
||||
* User interface for Jingle file transfers.
|
||||
|
|
|
@ -19,8 +19,8 @@ package org.jivesoftware.smackx.jingle_filetransfer.element;
|
|||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.Objects;
|
||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransfer;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransfer;
|
||||
|
||||
/**
|
||||
* Checksum element.
|
||||
|
|
|
@ -19,9 +19,9 @@ package org.jivesoftware.smackx.jingle_filetransfer.element;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransfer;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransfer;
|
||||
|
||||
/**
|
||||
* File element.
|
||||
|
|
|
@ -23,10 +23,10 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
|||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.ChecksumElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ import java.util.ArrayList;
|
|||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||
import org.jivesoftware.smackx.hashes.provider.HashElementProvider;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
||||
import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.component.JingleFileTransfer;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
||||
import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ import org.jivesoftware.smackx.rsm.packet.RSMSet;
|
|||
import org.jivesoftware.smackx.xdata.FormField;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.jxmpp.jid.BareJid;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.EntityFullJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
@ -103,9 +104,12 @@ public final class MamManager extends Manager {
|
|||
|
||||
private final Jid archiveAddress;
|
||||
|
||||
private final ServiceDiscoveryManager serviceDiscoveryManager;
|
||||
|
||||
private MamManager(XMPPConnection connection, Jid archiveAddress) {
|
||||
super(connection);
|
||||
this.archiveAddress = archiveAddress;
|
||||
serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -586,6 +590,23 @@ public final class MamManager extends Manager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if MAM is supported for the XMPP connection managed by this MamManager.
|
||||
*
|
||||
* @return true if MAM is supported for the XMPP connection, <code>false</code>otherwhise.
|
||||
*
|
||||
* @throws NoResponseException
|
||||
* @throws XMPPErrorException
|
||||
* @throws NotConnectedException
|
||||
* @throws InterruptedException
|
||||
* @since 4.2.1
|
||||
* @see <a href="https://xmpp.org/extensions/xep-0313.html#support">XEP-0313 § 7. Determining support</a>
|
||||
*/
|
||||
public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
BareJid myBareJid = connection().getUser().asBareJid();
|
||||
return serviceDiscoveryManager.supportsFeature(myBareJid, MamElements.NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if Message Archive Management is supported by the server.
|
||||
*
|
||||
|
@ -594,7 +615,10 @@ public final class MamManager extends Manager {
|
|||
* @throws XMPPErrorException
|
||||
* @throws NoResponseException
|
||||
* @throws InterruptedException
|
||||
* @depreacted use {@link #isSupported()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
// TODO Remove in Smack 4.3
|
||||
public boolean isSupportedByServer()
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
return ServiceDiscoveryManager.getInstanceFor(connection()).serverSupportsFeature(MamElements.NAMESPACE);
|
||||
|
|
|
@ -16,49 +16,52 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.httpfileupload;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jivesoftware.smackx.httpfileupload.element.SlotRequest;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class SlotRequestCreateTest {
|
||||
|
||||
String testRequest
|
||||
= "<request xmlns='urn:xmpp:http:upload:0'>"
|
||||
+ "<filename>my_juliet.png</filename>"
|
||||
+ "<size>23456</size>"
|
||||
+ "<content-type>image/jpeg</content-type>"
|
||||
+ "</request>";
|
||||
= "<request xmlns='urn:xmpp:http:upload:0'"
|
||||
+ " filename='my_juliet.png'"
|
||||
+ " size='23456'"
|
||||
+ " content-type='image/jpeg'"
|
||||
+ "/>";
|
||||
|
||||
String testRequestWithoutContentType
|
||||
= "<request xmlns='urn:xmpp:http:upload:0'>"
|
||||
+ "<filename>my_romeo.png</filename>"
|
||||
+ "<size>52523</size>"
|
||||
+ "</request>";
|
||||
= "<request xmlns='urn:xmpp:http:upload:0'"
|
||||
+ " filename='my_romeo.png'"
|
||||
+ " size='52523'"
|
||||
+ "/>";
|
||||
|
||||
@Test
|
||||
public void checkSlotRequestCreation() throws XmppStringprepException {
|
||||
public void checkSlotRequestCreation() throws SAXException, IOException {
|
||||
SlotRequest slotRequest = new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_juliet.png", 23456, "image/jpeg");
|
||||
|
||||
Assert.assertEquals("my_juliet.png", slotRequest.getFilename());
|
||||
Assert.assertEquals(23456, slotRequest.getSize());
|
||||
Assert.assertEquals("image/jpeg", slotRequest.getContentType());
|
||||
|
||||
Assert.assertEquals(testRequest, slotRequest.getChildElementXML().toString());
|
||||
assertXMLEqual(testRequest, slotRequest.getChildElementXML().toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkSlotRequestCreationWithoutContentType() throws XmppStringprepException {
|
||||
public void checkSlotRequestCreationWithoutContentType() throws SAXException, IOException {
|
||||
SlotRequest slotRequest = new SlotRequest(JidTestUtil.DOMAIN_BARE_JID_1, "my_romeo.png", 52523);
|
||||
|
||||
Assert.assertEquals("my_romeo.png", slotRequest.getFilename());
|
||||
Assert.assertEquals(52523, slotRequest.getSize());
|
||||
Assert.assertEquals(null, slotRequest.getContentType());
|
||||
|
||||
Assert.assertEquals(testRequestWithoutContentType, slotRequest.getChildElementXML().toString());
|
||||
assertXMLEqual(testRequestWithoutContentType, slotRequest.getChildElementXML().toString());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
|
|
|
@ -22,11 +22,11 @@ import org.jivesoftware.smack.test.util.SmackTestSuite;
|
|||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smackx.hashes.HashManager;
|
||||
import org.jivesoftware.smackx.hashes.element.HashElement;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.ChecksumElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
||||
import org.jivesoftware.smackx.jingle_filetransfer.provider.ChecksumProvider;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue