Commit Graph

77 Commits

Author SHA1 Message Date
Florian Schmaus ad9867ebdf Merge branch '4.4' 2022-02-03 08:43:32 +01:00
Florian Schmaus 1dae0c0c32 [core] Use Enum.toString() in XmlStringBuilder.attribute(String, Enum<?>)
All other enum-using methods of XmlStringBuilder already use
Enum.toString(), as opposed to Enum.name(), this was the only left. I
do not remember why I did not to change this method too, probably
because of its plenty call sites.

But since this method already broke Jingle XML serializaton,
JingleAction was e.g., 'session_accept' when it should be
'session-accept', we change it now.

Fixes SMACK-921.
2022-01-22 11:08:35 +01:00
Florian Schmaus e842195b71 Merge branch '4.4' 2021-10-19 14:33:21 +02:00
Florian Schmaus b243a40e26 [core] Pass down the XML environment in IQChildElementXmlStringBuilder
This allows to avoid redundant XML namespaces within IQs, like for
example here:

<iq xmlns='jabber:client' id='EKP8I-1' type='set'>
    <jingle xmlns='urn:xmpp:jingle:1' action='content-accept' sid='MySession'>
        <content xmlns='urn:xmpp:jingle:1' creator='initiator' name='Hello world'>
        </content>
    </jingle>
</iq>

Fixes SMACK-917

Reported-by: Jonathan Lennox
2021-10-19 11:29:23 +02:00
Florian Schmaus 3d4e7938a7 Make ExtensionElement marker interface wrt. QNAME field
ExtensionElement is now a marker interface that requires all
implementation non-abstract classes to carry a static final QNAME
field (of type QName). This is verified by a new unit test.

Also FullyQualifiedElement is renamed to simply XmlElement. XmlElement
is used over ExtensionElement when implementing classes do not
statically know the qualified name of the XML elements they
represent. In general, XmlElement should be used sparingly, and every
XML element should be modeled by its own Java class (implementing
ExtensionElement).
2021-04-18 21:07:19 +02:00
Florian Schmaus 35a71f0131 Merge branch '4.4' 2021-01-06 13:51:38 +01:00
Florian Schmaus fcc372754e Fix NPE in BoBIQ by adding XmlStringBuilder.optIntAttribute(String, Integer)
The method was missing and hence BoBIQ used optIntAttribute(String,
int) instead, which resulted in an NPE if the Integer was null.

Fixes SMACK-895.
2021-01-06 13:45:13 +01:00
Florian Schmaus d8642847ea Smack 4.4.0
-----BEGIN PGP SIGNATURE-----
 
 iQGTBAABCgB9FiEEl3UFnzoh3OFr5PuuIjmn6PWFIFIFAl/Msl5fFIAAAAAALgAo
 aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDk3
 NzUwNTlGM0EyMURDRTE2QkU0RkJBRTIyMzlBN0U4RjU4NTIwNTIACgkQIjmn6PWF
 IFIq8gf9GZp0Cl9Gr+seA/C8nczE/cNRKfHnDR224klbjlGrnojb+bL2QgeKG6wN
 u/eL3+UMus8uw3+R8NKARawqt/r6mbk4bgdGEbzoByLO6iiPYTr7TuZmTOQyZa5L
 tMNkFIvfvMzDeDDqI4z4uTgT3s7YBg0d4BT7cL8T6RaZGHF57OxqhWnKxMuaiTXH
 HJzVTPrtAcYg17QZl5+mrhiWyynE5+4QGeluYHlh7vvsniwNOqrwO1vWHg2BX003
 DjaHK+6oLjKxVljCklXxE7Wsx0VcMrBfv2qZwW3Q4ZzZVcrAn8TC4HrUtR8DL176
 DpGlEhmmdr3xKKX0JQ9RmIod+xSabw==
 =4wGX
 -----END PGP SIGNATURE-----

Merge tag '4.4.0'

Smack 4.4.0
2020-12-06 12:16:44 +01:00
Florian Schmaus a4bb5bfda8 [ibb] Use UInt16 for 'seq' and fix its handling
Fixes a off-by-one error when incrementing 'seq'. Thanks to Kim
Alvefur <zash@zash.se> for spotting this.
2020-12-05 23:04:17 +01:00
Florian Schmaus b857f33ac3 Merge branch '4.4' 2020-09-20 14:12:37 +02:00
Florian Schmaus b7824f008d Introduce and use XmlStringBuilder.text()
Smack currently does unnecessary escaping of XML text, where it
escapes e.g. '"' to '&quot;'. This bloats the stanza size, especially
if JSON payloads are involved.

Fixes SMACK-892 (although there are probably still places where
XmlStringBuilder.escape() is used when XmlStringBuild.text() could
have been used).
2020-09-17 14:20:11 +02:00
Florian Schmaus 2a9671ca93 [core] Change type of XmlStringBuilder cosntructor to FullyQualifiedElement
There is no reason we should do this only for ExtensionElements, this
behavior is sane for every FulllyQualifiedElement.
2020-08-26 11:35:22 +02:00
Florian Schmaus 77e26fc575 Re-work data form API
Apply builder pattern to form fields and replace getVariable() with
getFieldName(). Refer to the field name as "field name" instead of
"variable" everyone, just as XEP-0004 does.

Improve the high-level form API: introduce FilledForm and FillableForm
which perform stronger validation and consistency checks.

Also add FormFieldRegistry to enable processing of 'submit' forms
where the form field types are omitted.

Smack also now does omit the form field type declaration on 'submit'
type forms, as it is allowed by XEP-0004.
2020-05-13 20:14:41 +02:00
Florian Schmaus f9fb4d7627 Remove deprecated XmlStringBuilder.rightAngelBracket()
This method was marked deprecated with bbf89c65b ("Fix typo in
XmlStringBuilder, it's not an Angel"). Now it is time to remove it.
2020-04-05 17:26:21 +02:00
Florian Schmaus eb4c2c5572 s/occured/occurred/ 2019-10-30 12:02:36 +01:00
Florian Schmaus eeb6c52f7e Move SASL logic into AbstractXMPPConnection
Besides the way the transport handles the stream after SASL
<success/>, the SASL logic is independend from the underlying
transport (BOSH, TCP, …). Hence move it up into
AbstractXMPPConnection.

This also has the benefit that we can make some more methods private
or package-private.

Also introduce XmlStringBuilder.optTextChild(), which causes some
associated changes.
2019-09-25 13:49:21 +02:00
Florian Schmaus bd4b91fc26 Introduce AbstractXMPPConnection.outgoingStreamXmlEnvironment 2019-09-23 16:12:48 +02:00
Florian Schmaus 002d060584 XmlStringBuilder: Map all XML serialization to appendXmlTo()
this is now the single place where serializatin happens.
2019-09-23 16:12:48 +02:00
Florian Schmaus 3318a44016 XmlStringBuilder: Declare actual return type instead of supertype 2019-09-18 09:01:04 +02:00
Florian Schmaus 8086a11c6c XmlStringBuilder: Use potential length for target StringBuilder 2019-09-18 08:55:51 +02:00
Florian Schmaus fb3a71a14d Fix ConcurrentModificationException in XmlStringBuilder.appendToXml()
We want to append to appendable, not sb, the LazyStringBuilder we are
currently iterating over,
2019-09-18 08:48:39 +02:00
Florian Schmaus 65576cf3c2 Rework XML Element hierarchy and XmlStringBuilder
- Reduce the amount of types that are subtypes of NamedElement. See
javadoc of NamedElement for rationale.
- Work more with XmlEnvironment in XmlStringBuilder.
- Some minor changes to XmlStringBuilder API.
2019-09-07 18:17:08 +02:00
Florian Schmaus dd4df0a5ef Improve how XmlStringBuilder handles enclosing XML environments
to avoid emitting unnecessary attributes like xmlns.

Also add a test for MediaElement that checks that <uri/> does not
carry a xmlns attribute.
2019-09-04 10:22:56 +02:00
Florian Schmaus 935465a11b Remove duplicate code in XmlStringBuilder 2019-09-04 10:22:55 +02:00
Florian Schmaus 85ef149c83 Make XmlStringBuilder.prelude() protected
as the user should never be required to call it.
2019-09-04 10:22:55 +02:00
Florian Schmaus 1a3067c89b Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
Florian Schmaus 12cbeede57 Use Enum.toString() in XmlStringBuilder.element(String, Enum)
as toString() is often overriden by Enums to yield the expected XMPP
wire protocol representation.
2019-08-03 22:15:44 +02:00
Florian Schmaus 4ca2c7cc69 Enable MissingJavadocPackage and UnnecessaryParentheses checkstyle checks 2019-07-24 09:18:39 +02:00
Florian Schmaus b3b242f397 Add TODO comment to XmlStringBuilder 2019-06-11 12:47:39 +02:00
Florian Schmaus 4d36e3b521 Introduce FormFieldChildElement and make FormField immutable 2019-06-11 12:47:39 +02:00
Florian Schmaus 505493d889 Add XmlStringBuilder.optAttribute(String, Number) 2019-05-07 10:18:55 +02:00
Florian Schmaus fee3ed81ca Introduce XmlEnvironment 2019-02-05 13:18:03 +01:00
Florian Schmaus e98d42790a SmackReactor/NIO, Java8/Android19, Pretty print XML, FSM connections
This commit adds
- SmackReactor / NIO
- a framework for finite state machine connections
- support for Java 8
- pretty printed XML debug output

It also
- reworks the integration test framework
- raises the minimum Android API level to 19
- introduces XmppNioTcpConnection

Furthermore fixes SMACK-801 (at least partly). Java 8 language
features are available, but not all runtime library methods. For that
we would need to raise the Android API level to 24 or higher.
2019-02-05 13:18:03 +01:00
Florian Schmaus 00ce194109 Use Enum.toString() instead of Enum.name() in XmlStringBuilder.optElement() 2018-10-19 11:12:57 +02:00
Florian Schmaus b60a772df1 Remove unnecessary getNamespace() call in XmlStringBuilder 2018-10-03 20:09:56 +02:00
Paul Schaub 74bebc13e6
requireNotNullOrEmpty -> requireNotNullNorEmpty 2018-07-17 15:10:39 +02:00
Florian Schmaus f290197f6a Merge branch '4.3' 2018-06-12 15:49:43 +02:00
Florian Schmaus 414d730962 Optimize XmlStringBuilder.element() for the empty element case
For example RSM (XEP-0059) gives <before/> a different semantic as
<before>UID</before>.
2018-06-07 17:15:16 +02:00
Paul Schaub 27c77fcb1c Add utility methods
ParserUtils: getShortAttribute
XmlStringBuilder: attribute(String, long), optAttribute(String, Long)
2018-05-20 11:27:52 +02:00
Florian Schmaus e8923b9d16 Enable trailing whitespace checkstyle check
for all source code regions, including javadoc.
2018-05-09 23:26:39 +02:00
Florian Schmaus a9e45475ab Treat <body/> just like all other extension elements in Message
This turned out to be a rather large change.
2018-05-09 17:13:09 +02:00
Florian Schmaus 5ab2903c32 Change Element.toXml() to toXml(String enclosingNamespace) 2018-04-27 10:05:25 +02:00
Paul Schaub cb18056613 Fix minor codestyle issues 2017-12-17 11:03:46 +01:00
Ingo Bauersachs 699145ee5f Get descriptive text from error without lang
A stanza with <error><text>Some text</text></error>, i.e. without a
xml:lang attribute, did not return the value 'Some text' in
getDescriptiveText().

Insert the empty string as key when the attribute is not present while
parsing the xml. When writing, omit the attribute if the key is the
empty string.
2017-09-27 00:21:40 +02:00
Florian Schmaus 5424c9635f Add XmlStringBuilder.optXmlLangAttribute(String) 2017-06-17 11:41:35 +02:00
Florian Schmaus 08e897113d Add CustomImportOrder checkstyle rule
And matching ImportOrder settings for Eclipse in
resources/eclipse/smack.importorder
2017-06-14 17:12:43 +02:00
Florian Schmaus ce1cddc722 More checkstyle whitespace related checks 2017-05-24 14:42:38 +02:00
Florian Schmaus b91978dcc4 Add (partial) support for IoT XEPs
That is XEP-0323, -0324, -0325, and -0347.

SMACK-727.
2016-07-21 08:51:11 +02:00
Florian Schmaus e6a9027cc6 Improve StringUtils.escapeForXml() 2016-01-18 22:04:20 +01:00
Florian Schmaus 227ef2c5ae Add StandardExtensionElement
replaces DefaultExtensionElement which is now deprecated.

Also changes Stanza (and MultiMap) API so that there can be duplicate extension
elements, as this change is required for StandardExtensionElement and by
the XMPP standard.
2015-10-19 08:21:42 +02:00