1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 09:09:38 +02:00

Introduce XmlEnvironment

This commit is contained in:
Florian Schmaus 2019-02-04 13:27:41 +01:00
parent dc780ffd6c
commit fee3ed81ca
229 changed files with 715 additions and 526 deletions

View file

@ -186,7 +186,7 @@ public abstract class OmemoBundleElement implements ExtensionElement {
}
@Override
public XmlStringBuilder toXML(String enclosingNamespace) {
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
XmlStringBuilder sb = new XmlStringBuilder(this, enclosingNamespace).rightAngleBracket();
sb.halfOpenElement(SIGNED_PRE_KEY_PUB).attribute(SIGNED_PRE_KEY_ID, signedPreKeyId).rightAngleBracket()
@ -227,11 +227,11 @@ public abstract class OmemoBundleElement implements ExtensionElement {
}
OmemoBundleElement otherOmemoBundleElement = (OmemoBundleElement) other;
return toXML(null).equals(otherOmemoBundleElement.toXML(null));
return toXML().toString().equals(otherOmemoBundleElement.toXML().toString());
}
@Override
public int hashCode() {
return this.toXML(null).hashCode();
return toXML().toString().hashCode();
}
}

View file

@ -64,7 +64,7 @@ public abstract class OmemoDeviceListElement implements ExtensionElement {
}
@Override
public final XmlStringBuilder toXML(String enclosingNamespace) {
public final XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
XmlStringBuilder sb = new XmlStringBuilder(this).rightAngleBracket();
for (Integer id : deviceIds) {

View file

@ -73,7 +73,7 @@ public abstract class OmemoElement implements ExtensionElement {
}
@Override
public XmlStringBuilder toXML(String enclosingNamespace) {
public XmlStringBuilder toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
XmlStringBuilder sb = new XmlStringBuilder(this, enclosingNamespace).rightAngleBracket();
sb.element(header);

View file

@ -66,7 +66,7 @@ public abstract class OmemoHeaderElement implements NamedElement {
}
@Override
public CharSequence toXML(String enclosingNamespace) {
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
XmlStringBuilder sb = new XmlStringBuilder(this);
sb.attribute(ATTR_SID, getSid()).rightAngleBracket();

View file

@ -68,7 +68,7 @@ public class OmemoKeyElement implements NamedElement {
}
@Override
public CharSequence toXML(String enclosingNamespace) {
public CharSequence toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
XmlStringBuilder sb = new XmlStringBuilder(this);
if (isPreKey()) {

View file

@ -76,7 +76,7 @@ public class OmemoBundleVAxolotlElementTest extends SmackTestSuite {
"</preKeyPublic>" +
"</prekeys>" +
"</bundle>";
String actual = bundle.toXML(null).toString();
String actual = bundle.toXML().toString();
assertEquals("Bundles XML must match.", expected, actual);
byte[] signedPreKey = "SignedPreKey".getBytes(StringUtils.UTF8);

View file

@ -42,7 +42,7 @@ public class OmemoDeviceListVAxolotlElementTest extends SmackTestSuite {
ids.add(9876);
OmemoDeviceListElement_VAxolotl element = new OmemoDeviceListElement_VAxolotl(ids);
String xml = element.toXML(null).toString();
String xml = element.toXML().toString();
XmlPullParser parser = TestUtils.getParser(xml);
OmemoDeviceListElement_VAxolotl parsed = new OmemoDeviceListVAxolotlProvider().parse(parser);

View file

@ -66,12 +66,12 @@ public class OmemoVAxolotlElementTest extends SmackTestSuite {
"</payload>" +
"</encrypted>";
String actual = element.toXML(null).toString();
String actual = element.toXML().toString();
assertEquals("Serialized xml of OmemoElement must match.", expected, actual);
OmemoElement_VAxolotl parsed = new OmemoVAxolotlProvider().parse(TestUtils.getParser(actual));
assertEquals("Parsed OmemoElement must equal the original.",
element.toXML(null).toString(),
parsed.toXML(null).toString());
element.toXML().toString(),
parsed.toXML().toString());
}
}