mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
Fix errors
This commit is contained in:
parent
ff96a7c336
commit
d231024547
9 changed files with 59 additions and 135 deletions
|
@ -36,12 +36,12 @@ import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildEleme
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingJingleFileTransferCallback;
|
import org.jivesoftware.smackx.jingle_filetransfer.callback.IncomingJingleFileTransferCallback;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleContentDescriptionFileTransfer;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferContentDescription;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferPayloadElement;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.handler.FileOfferHandler;
|
import org.jivesoftware.smackx.jingle_filetransfer.handler.FileOfferHandler;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.handler.FileRequestHandler;
|
import org.jivesoftware.smackx.jingle_filetransfer.handler.FileRequestHandler;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.listener.IncomingJingleFileTransferListener;
|
import org.jivesoftware.smackx.jingle_filetransfer.listener.IncomingJingleFileTransferListener;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.provider.JingleContentDescriptionFileTransferProvider;
|
import org.jivesoftware.smackx.jingle_filetransfer.provider.JingleFileTransferContentDescriptionProvider;
|
||||||
import org.jivesoftware.smackx.jingle_ibb.JingleInBandByteStreamManager;
|
import org.jivesoftware.smackx.jingle_ibb.JingleInBandByteStreamManager;
|
||||||
import org.jivesoftware.smackx.jingle_ibb.element.JingleInBandByteStreamTransport;
|
import org.jivesoftware.smackx.jingle_ibb.element.JingleInBandByteStreamTransport;
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
|
@ -85,7 +85,7 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
NAMESPACE_V5, this);
|
NAMESPACE_V5, this);
|
||||||
|
|
||||||
JingleContentProviderManager.addJingleContentDescriptionProvider(
|
JingleContentProviderManager.addJingleContentDescriptionProvider(
|
||||||
NAMESPACE_V5, new JingleContentDescriptionFileTransferProvider());
|
NAMESPACE_V5, new JingleFileTransferContentDescriptionProvider());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +112,8 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
incomingJingleFileTransferListeners.remove(listener);
|
incomingJingleFileTransferListeners.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleFileTransferPayloadElement.Builder fileTransferPayloadBuilderFromFile(File file) {
|
public JingleFileTransferChildElement.Builder fileTransferPayloadBuilderFromFile(File file) {
|
||||||
JingleFileTransferPayloadElement.Builder payloadBuilder = JingleFileTransferPayloadElement.getBuilder();
|
JingleFileTransferChildElement.Builder payloadBuilder = JingleFileTransferChildElement.getBuilder();
|
||||||
payloadBuilder.setDate(new Date(file.lastModified()));
|
payloadBuilder.setDate(new Date(file.lastModified()));
|
||||||
payloadBuilder.setName(file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(File.pathSeparator) + 1));
|
payloadBuilder.setName(file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(File.pathSeparator) + 1));
|
||||||
payloadBuilder.setSize((int) file.length());
|
payloadBuilder.setSize((int) file.length());
|
||||||
|
@ -128,13 +128,13 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
final byte[] bytes = new byte[(int) file.length()];
|
final byte[] bytes = new byte[(int) file.length()];
|
||||||
HashElement hashElement = FileAndHashReader.readAndCalculateHash(file, bytes, HashManager.ALGORITHM.SHA_256);
|
HashElement hashElement = FileAndHashReader.readAndCalculateHash(file, bytes, HashManager.ALGORITHM.SHA_256);
|
||||||
Date lastModified = new Date(file.lastModified());
|
Date lastModified = new Date(file.lastModified());
|
||||||
JingleFileTransferPayloadElement payload = new JingleFileTransferPayloadElement(
|
JingleFileTransferChildElement payload = new JingleFileTransferChildElement(
|
||||||
lastModified, "A file", hashElement,
|
lastModified, "A file", hashElement,
|
||||||
"application/octet-stream", file.getName(), (int) file.length(), null);
|
"application/octet-stream", file.getName(), (int) file.length(), null);
|
||||||
ArrayList<JingleContentDescriptionChildElement> payloadTypes = new ArrayList<>();
|
ArrayList<JingleContentDescriptionChildElement> payloadTypes = new ArrayList<>();
|
||||||
payloadTypes.add(payload);
|
payloadTypes.add(payload);
|
||||||
|
|
||||||
JingleContentDescriptionFileTransfer descriptionFileTransfer = new JingleContentDescriptionFileTransfer(payloadTypes);
|
JingleFileTransferContentDescription descriptionFileTransfer = new JingleFileTransferContentDescription(payloadTypes);
|
||||||
final JingleInBandByteStreamTransport transport = new JingleInBandByteStreamTransport();
|
final JingleInBandByteStreamTransport transport = new JingleInBandByteStreamTransport();
|
||||||
JingleContent.Builder cb = JingleContent.getBuilder();
|
JingleContent.Builder cb = JingleContent.getBuilder();
|
||||||
cb.setDescription(descriptionFileTransfer)
|
cb.setDescription(descriptionFileTransfer)
|
||||||
|
@ -220,7 +220,7 @@ public final class JingleFileTransferManager extends Manager implements JingleHa
|
||||||
else {
|
else {
|
||||||
throw new AssertionError("Undefined (see XEP-0234 §4.1)");
|
throw new AssertionError("Undefined (see XEP-0234 §4.1)");
|
||||||
}
|
}
|
||||||
//break;
|
break;
|
||||||
case session_terminate:
|
case session_terminate:
|
||||||
// Remote wants to terminate our current session
|
// Remote wants to terminate our current session
|
||||||
case transport_accept:
|
case transport_accept:
|
||||||
|
|
|
@ -32,9 +32,9 @@ public class Checksum implements ExtensionElement {
|
||||||
|
|
||||||
private final JingleContent.Creator creator;
|
private final JingleContent.Creator creator;
|
||||||
private final String name;
|
private final String name;
|
||||||
private JingleFileTransferPayloadElement file;
|
private JingleFileTransferChildElement file;
|
||||||
|
|
||||||
public Checksum(JingleContent.Creator creator, String name, JingleFileTransferPayloadElement file) {
|
public Checksum(JingleContent.Creator creator, String name, JingleFileTransferChildElement file) {
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
Objects.requireNonNull(file.getHash(), "file MUST contain at least one hash element.");
|
Objects.requireNonNull(file.getHash(), "file MUST contain at least one hash element.");
|
||||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Date;
|
||||||
/**
|
/**
|
||||||
* Content of type File.
|
* Content of type File.
|
||||||
*/
|
*/
|
||||||
public class JingleFileTransferPayloadElement extends JingleContentDescriptionChildElement {
|
public class JingleFileTransferChildElement extends JingleContentDescriptionChildElement {
|
||||||
public static final String ELEMENT = "file";
|
public static final String ELEMENT = "file";
|
||||||
public static final String ELEM_DATE = "date";
|
public static final String ELEM_DATE = "date";
|
||||||
public static final String ELEM_DESC = "desc";
|
public static final String ELEM_DESC = "desc";
|
||||||
|
@ -42,7 +42,7 @@ public class JingleFileTransferPayloadElement extends JingleContentDescriptionCh
|
||||||
private final int size;
|
private final int size;
|
||||||
private final Range range;
|
private final Range range;
|
||||||
|
|
||||||
public JingleFileTransferPayloadElement(Date date, String desc, HashElement hash, String mediaType, String name, int size, Range range) {
|
public JingleFileTransferChildElement(Date date, String desc, HashElement hash, String mediaType, String name, int size, Range range) {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
this.hash = hash;
|
this.hash = hash;
|
||||||
|
@ -154,8 +154,8 @@ public class JingleFileTransferPayloadElement extends JingleContentDescriptionCh
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JingleFileTransferPayloadElement build() {
|
public JingleFileTransferChildElement build() {
|
||||||
return new JingleFileTransferPayloadElement(date, desc, hash, mediaType, name, size, range);
|
return new JingleFileTransferChildElement(date, desc, hash, mediaType, name, size, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setFile(File file) {
|
public Builder setFile(File file) {
|
|
@ -25,9 +25,9 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* Description.
|
* Description.
|
||||||
*/
|
*/
|
||||||
public class JingleContentDescriptionFileTransfer extends JingleContentDescription {
|
public class JingleFileTransferContentDescription extends JingleContentDescription {
|
||||||
|
|
||||||
public JingleContentDescriptionFileTransfer(List<JingleContentDescriptionChildElement> payloadTypes) {
|
public JingleFileTransferContentDescription(List<JingleContentDescriptionChildElement> payloadTypes) {
|
||||||
super(payloadTypes);
|
super(payloadTypes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2017 Paul Schaub
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.jivesoftware.smackx.jingle_filetransfer.provider;
|
|
||||||
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider;
|
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleContentDescriptionFileTransfer;
|
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferPayloadElement;
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import static org.xmlpull.v1.XmlPullParser.END_TAG;
|
|
||||||
import static org.xmlpull.v1.XmlPullParser.START_TAG;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provider for JingleContentDescriptionFileTransfer elements.
|
|
||||||
*/
|
|
||||||
public class JingleContentDescriptionFileTransferProvider
|
|
||||||
extends JingleContentDescriptionProvider<JingleContentDescriptionFileTransfer> {
|
|
||||||
@Override
|
|
||||||
public JingleContentDescriptionFileTransfer parse(XmlPullParser parser, int initialDepth) throws Exception {
|
|
||||||
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
|
|
||||||
while (true) {
|
|
||||||
int tag = parser.nextTag();
|
|
||||||
String name = parser.getName();
|
|
||||||
|
|
||||||
if (tag == START_TAG) {
|
|
||||||
switch (name) {
|
|
||||||
case JingleFileTransferPayloadElement.ELEMENT:
|
|
||||||
payloads.add(new JingleFileTransferPayloadProvider().parse(parser));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tag == END_TAG) {
|
|
||||||
if (name.equals(JingleContentDescriptionFileTransfer.ELEMENT)) {
|
|
||||||
return new JingleContentDescriptionFileTransfer(payloads);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -18,24 +18,30 @@ package org.jivesoftware.smackx.jingle_filetransfer.provider;
|
||||||
|
|
||||||
import org.jivesoftware.smackx.hash.element.HashElement;
|
import org.jivesoftware.smackx.hash.element.HashElement;
|
||||||
import org.jivesoftware.smackx.hash.provider.HashElementProvider;
|
import org.jivesoftware.smackx.hash.provider.HashElementProvider;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionPayloadProvider;
|
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferPayloadElement;
|
import org.jivesoftware.smackx.jingle.provider.JingleContentDescriptionProvider;
|
||||||
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferContentDescription;
|
||||||
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
||||||
import org.jxmpp.util.XmppDateTime;
|
import org.jxmpp.util.XmppDateTime;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static org.xmlpull.v1.XmlPullParser.END_TAG;
|
import static org.xmlpull.v1.XmlPullParser.END_TAG;
|
||||||
import static org.xmlpull.v1.XmlPullParser.START_TAG;
|
import static org.xmlpull.v1.XmlPullParser.START_TAG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provider for JingleFileTransferPayloadElements.
|
* Provider for JingleContentDescriptionFileTransfer elements.
|
||||||
*/
|
*/
|
||||||
public class JingleFileTransferPayloadProvider extends JingleContentDescriptionPayloadProvider<JingleFileTransferPayloadElement> {
|
public class JingleFileTransferContentDescriptionProvider
|
||||||
|
extends JingleContentDescriptionProvider<JingleFileTransferContentDescription> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JingleFileTransferPayloadElement parse(XmlPullParser parser, int initialDepth) throws Exception {
|
public JingleFileTransferContentDescription parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||||
|
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
|
||||||
boolean inRange = false;
|
boolean inRange = false;
|
||||||
JingleFileTransferPayloadElement.Builder builder = JingleFileTransferPayloadElement.getBuilder();
|
JingleFileTransferChildElement.Builder builder = JingleFileTransferChildElement.getBuilder();
|
||||||
HashElement inRangeHash = null;
|
HashElement inRangeHash = null;
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
@ -48,23 +54,23 @@ public class JingleFileTransferPayloadProvider extends JingleContentDescriptionP
|
||||||
|
|
||||||
if (tag == START_TAG) {
|
if (tag == START_TAG) {
|
||||||
switch (elem) {
|
switch (elem) {
|
||||||
case JingleFileTransferPayloadElement.ELEM_DATE:
|
case JingleFileTransferChildElement.ELEM_DATE:
|
||||||
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
|
builder.setDate(XmppDateTime.parseXEP0082Date(parser.nextText()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JingleFileTransferPayloadElement.ELEM_DESC:
|
case JingleFileTransferChildElement.ELEM_DESC:
|
||||||
builder.setDescription(parser.nextText());
|
builder.setDescription(parser.nextText());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JingleFileTransferPayloadElement.ELEM_MEDIA_TYPE:
|
case JingleFileTransferChildElement.ELEM_MEDIA_TYPE:
|
||||||
builder.setMediaType(parser.nextText());
|
builder.setMediaType(parser.nextText());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JingleFileTransferPayloadElement.ELEM_NAME:
|
case JingleFileTransferChildElement.ELEM_NAME:
|
||||||
builder.setName(parser.nextText());
|
builder.setName(parser.nextText());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JingleFileTransferPayloadElement.ELEM_SIZE:
|
case JingleFileTransferChildElement.ELEM_SIZE:
|
||||||
builder.setSize(Integer.parseInt(parser.nextText()));
|
builder.setSize(Integer.parseInt(parser.nextText()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -99,8 +105,13 @@ public class JingleFileTransferPayloadProvider extends JingleContentDescriptionP
|
||||||
inRangeHash = null;
|
inRangeHash = null;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JingleFileTransferPayloadElement.ELEMENT:
|
case JingleFileTransferChildElement.ELEMENT:
|
||||||
return builder.build();
|
payloads.add(builder.build());
|
||||||
|
builder = JingleFileTransferChildElement.getBuilder();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case JingleFileTransferContentDescription.ELEMENT:
|
||||||
|
return new JingleFileTransferContentDescription(payloads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,7 +29,7 @@ import static junit.framework.TestCase.assertNull;
|
||||||
/**
|
/**
|
||||||
* Test the JingleContentFile class.
|
* Test the JingleContentFile class.
|
||||||
*/
|
*/
|
||||||
public class JingleFileTransferPayloadElementTest extends SmackTestSuite {
|
public class JingleFileTransferChildElementTest extends SmackTestSuite {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void rangeTest() throws Exception {
|
public void rangeTest() throws Exception {
|
|
@ -21,10 +21,11 @@ import org.jivesoftware.smack.test.util.TestUtils;
|
||||||
import org.jivesoftware.smackx.hash.HashManager;
|
import org.jivesoftware.smackx.hash.HashManager;
|
||||||
import org.jivesoftware.smackx.hash.element.HashElement;
|
import org.jivesoftware.smackx.hash.element.HashElement;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferPayloadElement;
|
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionChildElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleContentDescriptionFileTransfer;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferContentDescription;
|
||||||
|
import org.jivesoftware.smackx.jingle_filetransfer.element.JingleFileTransferChildElement;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
import org.jivesoftware.smackx.jingle_filetransfer.element.Range;
|
||||||
import org.jivesoftware.smackx.jingle_filetransfer.provider.JingleContentDescriptionFileTransferProvider;
|
import org.jivesoftware.smackx.jingle_filetransfer.provider.JingleFileTransferContentDescriptionProvider;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.jxmpp.util.XmppDateTime;
|
import org.jxmpp.util.XmppDateTime;
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ import static org.junit.Assert.assertNotNull;
|
||||||
/**
|
/**
|
||||||
* Test the JingleContentDescriptionFileTransfer element and provider.
|
* Test the JingleContentDescriptionFileTransfer element and provider.
|
||||||
*/
|
*/
|
||||||
public class JingleContentDescriptionFileTransferTest extends SmackTestSuite {
|
public class JingleFileTransferContentDescriptionTest extends SmackTestSuite {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parserTest() throws Exception {
|
public void parserTest() throws Exception {
|
||||||
|
@ -65,19 +66,19 @@ public class JingleContentDescriptionFileTransferTest extends SmackTestSuite {
|
||||||
HashElement hashElement = new HashElement(algorithm, hashB64);
|
HashElement hashElement = new HashElement(algorithm, hashB64);
|
||||||
Range range = new Range();
|
Range range = new Range();
|
||||||
Date date = XmppDateTime.parseDate(dateString);
|
Date date = XmppDateTime.parseDate(dateString);
|
||||||
JingleFileTransferPayloadElement jingleFileTransferPayloadElement = new JingleFileTransferPayloadElement(date, descriptionString, hashElement, mediaTypeString, nameString, sizeInt, range);
|
JingleFileTransferChildElement jingleFileTransferChildElement = new JingleFileTransferChildElement(date, descriptionString, hashElement, mediaTypeString, nameString, sizeInt, range);
|
||||||
ArrayList<JingleContentDescriptionPayloadElement> payloads = new ArrayList<>();
|
ArrayList<JingleContentDescriptionChildElement> payloads = new ArrayList<>();
|
||||||
payloads.add(jingleFileTransferPayloadElement);
|
payloads.add(jingleFileTransferChildElement);
|
||||||
|
|
||||||
JingleContentDescriptionFileTransfer descriptionFileTransfer =
|
JingleFileTransferContentDescription descriptionFileTransfer =
|
||||||
new JingleContentDescriptionFileTransfer(payloads);
|
new JingleFileTransferContentDescription(payloads);
|
||||||
assertEquals(xml, descriptionFileTransfer.toXML().toString());
|
assertEquals(xml, descriptionFileTransfer.toXML().toString());
|
||||||
|
|
||||||
JingleContentDescription parsed = new JingleContentDescriptionFileTransferProvider()
|
JingleContentDescription parsed = new JingleFileTransferContentDescriptionProvider()
|
||||||
.parse(TestUtils.getParser(xml));
|
.parse(TestUtils.getParser(xml));
|
||||||
assertEquals(xml, parsed.toXML().toString());
|
assertEquals(xml, parsed.toXML().toString());
|
||||||
|
|
||||||
JingleFileTransferPayloadElement payload = (JingleFileTransferPayloadElement) parsed.getJinglePayloadTypes().get(0);
|
JingleFileTransferChildElement payload = (JingleFileTransferChildElement) parsed.getJinglePayloadTypes().get(0);
|
||||||
assertEquals(date, payload.getDate());
|
assertEquals(date, payload.getDate());
|
||||||
assertEquals(descriptionString, payload.getDescription());
|
assertEquals(descriptionString, payload.getDescription());
|
||||||
assertEquals(mediaTypeString, payload.getMediaType());
|
assertEquals(mediaTypeString, payload.getMediaType());
|
||||||
|
@ -86,7 +87,7 @@ public class JingleContentDescriptionFileTransferTest extends SmackTestSuite {
|
||||||
assertEquals(range, payload.getRange());
|
assertEquals(range, payload.getRange());
|
||||||
assertEquals(hashElement, payload.getHash());
|
assertEquals(hashElement, payload.getHash());
|
||||||
|
|
||||||
JingleContentDescriptionFileTransfer descriptionFileTransfer1 = new JingleContentDescriptionFileTransfer(null);
|
JingleFileTransferContentDescription descriptionFileTransfer1 = new JingleFileTransferContentDescription(null);
|
||||||
assertNotNull(descriptionFileTransfer1.getJinglePayloadTypes());
|
assertNotNull(descriptionFileTransfer1.getJinglePayloadTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,12 +107,12 @@ public class JingleContentDescriptionFileTransferTest extends SmackTestSuite {
|
||||||
"</range>" +
|
"</range>" +
|
||||||
"</file>" +
|
"</file>" +
|
||||||
"</description>";
|
"</description>";
|
||||||
JingleFileTransferPayloadElement payload = new JingleFileTransferPayloadElement(null, null, null, null, null, -1, range);
|
JingleFileTransferChildElement payload = new JingleFileTransferChildElement(null, null, null, null, null, -1, range);
|
||||||
ArrayList<JingleContentDescriptionPayloadElement> list = new ArrayList<>();
|
ArrayList<JingleContentDescriptionChildElement> list = new ArrayList<>();
|
||||||
list.add(payload);
|
list.add(payload);
|
||||||
JingleContentDescriptionFileTransfer fileTransfer = new JingleContentDescriptionFileTransfer(list);
|
JingleFileTransferContentDescription fileTransfer = new JingleFileTransferContentDescription(list);
|
||||||
assertEquals(xml, fileTransfer.toXML().toString());
|
assertEquals(xml, fileTransfer.toXML().toString());
|
||||||
JingleContentDescriptionFileTransfer parsed = new JingleContentDescriptionFileTransferProvider()
|
JingleFileTransferContentDescription parsed = new JingleFileTransferContentDescriptionProvider()
|
||||||
.parse(TestUtils.getParser(xml));
|
.parse(TestUtils.getParser(xml));
|
||||||
assertEquals(xml, parsed.toXML().toString());
|
assertEquals(xml, parsed.toXML().toString());
|
||||||
}
|
}
|
|
@ -1,31 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright 2017 Paul Schaub
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.jivesoftware.smackx.jingle.provider;
|
|
||||||
|
|
||||||
import org.jivesoftware.smack.provider.ExtensionElementProvider;
|
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescriptionPayloadElement;
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provider for JingleContentDescriptionPayloadElements.
|
|
||||||
*/
|
|
||||||
public abstract class JingleContentDescriptionPayloadProvider<D extends JingleContentDescriptionPayloadElement>
|
|
||||||
extends ExtensionElementProvider<D> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public abstract D parse(XmlPullParser parser, int initialDepth) throws Exception;
|
|
||||||
}
|
|
Loading…
Reference in a new issue