mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Smack 4.2.1
-----BEGIN PGP SIGNATURE----- iQGTBAABCgB9FiEEl3UFnzoh3OFr5PuuIjmn6PWFIFIFAlmR75tfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDk3 NzUwNTlGM0EyMURDRTE2QkU0RkJBRTIyMzlBN0U4RjU4NTIwNTIACgkQIjmn6PWF IFLeXggAjdgj7YVUe22NtamnROBj1c3PaWwgSY0gEjcyDPsOz5qeqNUdQLHbmt2j XQQpYZWKg1/1uoQHlsixaFKbGVctKRk72aNEodRfd1osta11WTOwZKEb8nI411Tt 7M0Fhf430WZY6nioZiZIorsmid57fftJ2EMPlmjEDp2FD0AVGAXkEhCneGaPtt9Q hbWbepIy9tApeIH+QgmFLBmPLnFCaSg+X6NUden3Z21bUz5vH8pmcbeUVfsNB7kW nkkDuNwKHPFLgjuhcq7D+KAKRwNU7n8WEuHseRzM7bMCEB+S/rZok5KPXe/tV4v+ YZKN2e+2yh4j5l4FT/fCzELfWcvrgA== =MV3G -----END PGP SIGNATURE----- Merge tag '4.2.1' Smack 4.2.1
This commit is contained in:
commit
43abd52d76
26 changed files with 332 additions and 228 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue