Skip to content

Commit 0c4fd39

Browse files
committed
Rebase on master
1 parent a0a7f4e commit 0c4fd39

File tree

4 files changed

+36
-25
lines changed

4 files changed

+36
-25
lines changed

smack-experimental/src/main/java/org/jivesoftware/smackx/file_metadata/provider/FileMetadataElementProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
*/
1717
package org.jivesoftware.smackx.file_metadata.provider;
1818

19+
import java.io.IOException;
20+
import java.text.ParseException;
21+
1922
import org.jivesoftware.smack.packet.XmlEnvironment;
2023
import org.jivesoftware.smack.parsing.SmackParsingException;
2124
import org.jivesoftware.smack.provider.ExtensionElementProvider;
@@ -28,9 +31,6 @@
2831
import org.jivesoftware.smackx.thumbnails.element.ThumbnailElement;
2932
import org.jivesoftware.smackx.thumbnails.provider.ThumbnailElementProvider;
3033

31-
import java.io.IOException;
32-
import java.text.ParseException;
33-
3434
public class FileMetadataElementProvider extends ExtensionElementProvider<FileMetadataElement> {
3535

3636
@Override

smack-experimental/src/main/java/org/jivesoftware/smackx/stateless_file_sharing/element/SourcesElement.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,19 @@
2020
import java.util.Collections;
2121
import java.util.List;
2222

23-
import org.jivesoftware.smack.packet.ExtensionElement;
2423
import org.jivesoftware.smack.packet.NamedElement;
2524
import org.jivesoftware.smack.packet.XmlEnvironment;
2625
import org.jivesoftware.smack.util.XmlStringBuilder;
27-
import org.jivesoftware.smackx.url_address_information.element.UrlDataElement;
26+
import org.jivesoftware.smackx.urldata.element.UrlDataElement;
2827

2928
public class SourcesElement implements NamedElement {
3029

3130
public static final String ELEMENT = "sources";
3231

3332
private final List<UrlDataElement> urlDataElements = new ArrayList<>();
34-
private final List<ExtensionElement> otherSourceElements = new ArrayList<>();
33+
private final List<NamedElement> otherSourceElements = new ArrayList<>();
3534

36-
public SourcesElement(List<UrlDataElement> urlDataElements, List<ExtensionElement> otherSourceElements) {
35+
public SourcesElement(List<UrlDataElement> urlDataElements, List<NamedElement> otherSourceElements) {
3736
this.urlDataElements.addAll(urlDataElements);
3837
this.otherSourceElements.addAll(otherSourceElements);
3938
}
@@ -51,7 +50,7 @@ public List<UrlDataElement> getUrlDataElements() {
5150
return Collections.unmodifiableList(urlDataElements);
5251
}
5352

54-
public List<ExtensionElement> getOtherSourceElements() {
53+
public List<NamedElement> getOtherSourceElements() {
5554
return Collections.unmodifiableList(otherSourceElements);
5655
}
5756

smack-experimental/src/main/java/org/jivesoftware/smackx/stateless_file_sharing/provider/FileSharingElementProvider.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.util.ArrayList;
2121
import java.util.List;
2222

23-
import org.jivesoftware.smack.packet.ExtensionElement;
23+
import org.jivesoftware.smack.packet.NamedElement;
2424
import org.jivesoftware.smack.packet.XmlEnvironment;
2525
import org.jivesoftware.smack.parsing.SmackParsingException;
2626
import org.jivesoftware.smack.parsing.StandardExtensionElementProvider;
@@ -32,8 +32,9 @@
3232
import org.jivesoftware.smackx.file_metadata.provider.FileMetadataElementProvider;
3333
import org.jivesoftware.smackx.stateless_file_sharing.element.FileSharingElement;
3434
import org.jivesoftware.smackx.stateless_file_sharing.element.SourcesElement;
35-
import org.jivesoftware.smackx.url_address_information.element.UrlDataElement;
36-
import org.jivesoftware.smackx.url_address_information.provider.UrlDataElementProvider;
35+
import org.jivesoftware.smackx.urldata.element.UrlDataElement;
36+
import org.jivesoftware.smackx.urldata.provider.UrlDataElementProvider;
37+
3738

3839
public class FileSharingElementProvider extends ExtensionElementProvider<FileSharingElement> {
3940

@@ -45,24 +46,24 @@ public FileSharingElement parse(XmlPullParser parser, int initialDepth, XmlEnvir
4546
FileMetadataElement fileMetadataElement = null;
4647
SourcesElement sourcesElement = null;
4748
List<UrlDataElement> urlDataElements = new ArrayList<>();
48-
List<ExtensionElement> otherSourceElements = new ArrayList<>();
49+
List<NamedElement> otherSourceElements = new ArrayList<>();
4950
do {
5051
XmlPullParser.TagEvent event = parser.nextTag();
5152
String name = parser.getName();
5253

5354
if (event == XmlPullParser.TagEvent.START_ELEMENT) {
5455
if (name.equals(FileMetadataElement.ELEMENT)) {
55-
fileMetadataElement = FileMetadataElementProvider.TEST_INSTANCE.parse(parser, xmlEnvironment);
56+
fileMetadataElement = new FileMetadataElementProvider().parse(parser, xmlEnvironment);
5657
} else if (name.equals(SourcesElement.ELEMENT)) {
5758
int innerDepth = parser.getDepth();
5859
do {
5960
XmlPullParser.TagEvent innerEvent = parser.nextTag();
6061
String innerName = parser.getName();
6162
if (innerEvent.equals(XmlPullParser.TagEvent.START_ELEMENT)) {
6263
if (innerName.equals(UrlDataElement.ELEMENT)) {
63-
urlDataElements.add(UrlDataElementProvider.INSTANCE.parse(parser));
64+
urlDataElements.add(new UrlDataElementProvider().parse(parser));
6465
} else {
65-
ExtensionElementProvider<?> provider = ProviderManager.getExtensionProvider(innerName, parser.getNamespace());
66+
ExtensionElementProvider<? extends NamedElement> provider = ProviderManager.getExtensionProvider(innerName, parser.getNamespace());
6667
if (provider == null) {
6768
provider = new StandardExtensionElementProvider();
6869
}

smack-experimental/src/test/java/org/jivesoftware/smackx/stateless_file_sharing/FileSharingElementTest.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1+
/**
2+
*
3+
* Copyright 2020 Paul Schaub
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package org.jivesoftware.smackx.stateless_file_sharing;
218

319
import static org.jivesoftware.smack.test.util.XmlAssertUtil.assertXmlSimilar;
4-
import static org.junit.jupiter.api.Assertions.assertEquals;
520

621
import java.io.IOException;
722
import java.util.Collections;
@@ -17,7 +32,8 @@
1732
import org.jivesoftware.smackx.stateless_file_sharing.element.FileSharingElement;
1833
import org.jivesoftware.smackx.stateless_file_sharing.element.SourcesElement;
1934
import org.jivesoftware.smackx.stateless_file_sharing.provider.FileSharingElementProvider;
20-
import org.jivesoftware.smackx.url_address_information.element.UrlDataElement;
35+
import org.jivesoftware.smackx.thumbnails.element.ThumbnailElement;
36+
import org.jivesoftware.smackx.urldata.element.UrlDataElement;
2137

2238
import org.junit.jupiter.api.Test;
2339

@@ -34,13 +50,7 @@ public void simpleElementTest() throws XmlPullParserException, IOException, Smac
3450
.addHash(new HashElement(HashManager.ALGORITHM.SHA3_256, "2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU="))
3551
.addHash(new HashElement(HashManager.ALGORITHM.BLAKE2B256, "2AfMGH8O7UNPTvUVAM9aK13mpCY="))
3652
.addDescription("Photo from the summit.")
37-
.addOtherChildElement(
38-
StandardExtensionElement.builder("thumbnail", "urn:xmpp:thumbs:1")
39-
.addAttribute("uri", "cid:[email protected]")
40-
.addAttribute("media-type", "image/png")
41-
.addAttribute("width", "128")
42-
.addAttribute("height", "96")
43-
.build())
53+
.addThumbnail(new ThumbnailElement("cid:[email protected]", "image/png", 128, 96))
4454
.build(),
4555
new SourcesElement(Collections.singletonList(
4656
new UrlDataElement(
@@ -61,7 +71,8 @@ public void simpleElementTest() throws XmlPullParserException, IOException, Smac
6171
" <media-type>image/jpeg</media-type>\n" +
6272
" <name>summit.jpg</name>\n" +
6373
" <size>3032449</size>\n" +
64-
" <dimensions>4096x2160</dimensions>\n" +
74+
" <width>4096</width>\n" +
75+
" <height>2160</height>\n" +
6576
" <hash xmlns='urn:xmpp:hashes:2' algo='sha3-256'>2XarmwTlNxDAMkvymloX3S5+VbylNrJt/l5QyPa+YoU=</hash>\n" +
6677
" <hash xmlns='urn:xmpp:hashes:2' algo='id-blake2b256'>2AfMGH8O7UNPTvUVAM9aK13mpCY=</hash>\n" +
6778
" <desc>Photo from the summit.</desc>\n" +

0 commit comments

Comments
 (0)