Commit Graph

57 Commits

Author SHA1 Message Date
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 b7824f008d Introduce and use XmlStringBuilder.text()
Smack currently does unnecessary escaping of XML text, where it
escapes e.g. '"' to '"'. 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 3f9ca68134 Delete TypedCloneable 2020-06-14 17:38:51 +02:00
Florian Schmaus f1319d1c8b Move getters from Message to MessageView 2020-06-12 09:17:54 +02:00
Florian Schmaus 07da9ffb48 Do not have Stanza.getExtension(String, String) return a generic type
Returning a generic would allow for

List<ExtensionElement> list = stanza.getExtension("foo", "bar");

to compile (Note the we are calling getExtension(), not
getExtension*s*()).

Users are encouraged to use the type safe getExtension(Class<? extends
ExtensionElement) variant instead.

Fixes SMACK-825.
2020-04-05 22:10:05 +02:00
Florian Schmaus 14c351397d Implement message stanza <thread/> and <subject/> as ExtensionElement
Fixes SMACK-852.
2020-04-05 18:58:13 +02:00
Florian Schmaus e2d206e741 Introduce XMPPConnection.add(Message|Presence)Interceptor
add deprecate addStanzaInterceptor().
2019-10-25 21:41:55 +02:00
Florian Schmaus 5db6191110 Introduce StanzaBuilder
As first step to immutable Stanza types.
2019-10-25 21:41:55 +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 1a3067c89b Enable werror for javadoc and fix javadoc issues 2019-08-30 12:08:30 +02:00
Florian Schmaus 91ec6cc955 Javadoc changes for Java 11 compatibility 2019-07-19 23:05:46 +02:00
Florian Schmaus fa0c16d75c Introduce EqualsUtil and HashCode.(Builder|Cache) 2019-06-12 14:51:17 +02:00
Florian Schmaus fee3ed81ca Introduce XmlEnvironment 2019-02-05 13:18:03 +01:00
Florian Schmaus a3fcbdbf5a Make Stanza.appendErrorIfExists() aware of the enclosing XML namespace
Originally discovered by Paul Schaub:

Fixes an inconvenience, where an IQ with the implicit namespace
`jabber:client` would append the namespace to an error child element
like this:

```
<iq (xmlns='jabber:client) <!-- in parenthesis since the NS is implicit --> ... >
    <error xmlns='jabber:client' <!-- this NS is too much --> ... />
</iq>
``
2018-08-01 13:16:20 +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 93c2b2be26 Do not return a Message "default" language if there is none 2018-05-09 17:13:08 +02:00
Florian Schmaus b4b75a3cca Make <subject/> (XML) language optional 2018-05-09 16:48:53 +02:00
Florian Schmaus 4b8f7ca6b6 Make <body/> (XML) language optional 2018-05-09 16:47:28 +02:00
Florian Schmaus 5ab2903c32 Change Element.toXml() to toXml(String enclosingNamespace) 2018-04-27 10:05:25 +02:00
Florian Schmaus 2b11074950 Merge branch '4.2' 2017-06-17 15:55:38 +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 7a5f9e6a03 Merge branch '4.2' 2017-05-25 11:25:36 +02:00
Florian Schmaus ce1cddc722 More checkstyle whitespace related checks 2017-05-24 14:42:38 +02:00
Florian Schmaus 52a52e12d2 Make Body and Subject implement ExtensionElement 2017-03-07 08:53:31 +01:00
Florian Schmaus 4c646436a5 Bump "Error Prone" to 2.0.15
and fix a few things :)
2017-02-11 16:16:41 +01:00
Florian Schmaus f633313c4a Add Message.setBody(CharSequence) 2017-01-02 00:47:25 +01:00
Florian Schmaus 5a2326a856 Add convinient constructors for Message and Presence 2016-10-31 12:24:03 +01:00
Florian Schmaus 4d7e4b2ab1 Add Message(String, String) constructor
to make simply Smack examples work, e.g.

Message message = new Message("user@example.org", "Hi, how are you?");
2016-07-24 21:21:21 +02:00
Florian Schmaus 86e11e69e8 Add Message.toString() providing a short description 2016-05-25 22:58:34 +02:00
Florian Schmaus b4694ec152 Add FinalClass checkstyle check
And mark affected classes final.
2015-04-06 10:45:12 +02:00
Florian Schmaus dc373f641c Make Smack Java8's javac and javadoc ready 2015-04-04 17:16:27 +02:00
Florian Schmaus 0fde39fa45 's;^\s+$;;' on all source files
And add checkstyle test for lines containing only whitespace characters.
2015-03-17 11:33:02 +01:00
Florian Schmaus 369878b6d9 Merge branch '4.1'
Conflicts:
	version.gradle
2015-03-11 20:51:08 +01:00
Florian Schmaus e85c1881d7 Add TypedCloneable 2015-03-10 22:50:48 +01:00
Florian Schmaus 701aa7d9c4 Merge branch '4.1'
Conflicts:
	smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
	smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java
	smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java
	smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java
	smack-core/src/main/java/org/jivesoftware/smack/debugger/SmackDebugger.java
	smack-core/src/main/java/org/jivesoftware/smack/packet/Packet.java
	smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java
	smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/VCardManager.java
	smack-extensions/src/test/java/org/jivesoftware/smackx/receipts/DeliveryReceiptTest.java
	smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java
	smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java
	smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java
	smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java
	smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java
	smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java
	version.gradle
2015-03-04 22:42:36 +01:00
Florian Schmaus e9dd3e2fa6 Add copy constructor to Message and Presence
and also implement Cloneable and add clone() methods.
2015-02-23 22:15:59 +01:00
Florian Schmaus 5bb4727c57 Use Jid (and subclasses) from jxmpp-jid
Fixes SMACK-634
2015-02-17 16:07:16 +01:00
Florian Schmaus 4698805a34 Rename 'Packet' class to 'Stanza'
Smack still uses the term 'Packet' in some places. This is just the
first step towards using correct XMPP terms in Smack.
2015-02-06 09:34:51 +01:00
Florian Schmaus ed4d815fba Make Message.setType(Type) not throw if type is null
RFC 6121 § 5.2.2:
"""
If an application receives a message with no 'type' attribute or the
application does not understand the value of the 'type' attribute
provided, it MUST consider the message to be of type "normal" (i.e.,
"normal" is the default).
"""
2015-01-26 20:47:14 +01:00
Florian Schmaus ba2df2a995 Add Message(String,String) 2014-12-01 14:40:58 +01:00
Florian Schmaus 252d5172e9 Return more specific types (e.g. Collection → List)
be generic as possible in what you accept, but more specific in what you
return.

Also tweak MultiuserChatManager methods a bit.
2014-11-29 13:41:49 +01:00
Florian Schmaus 9e797c1b17 Enable PacketExtensions for IQs
This is actually only part one, i.e. with this commit if the user adds a
PacketExtension to an IQ it will be included in IQ.toXml(). Which was
previously only the case if the IQ subclass explicitly included packet
extensions.

The second part of the change is to change the IQ provider, so that
packet extensions are automatically parsed.

Cases where PacketExtensions are used for Message and IQ are slightly
changed. The IQ sublcass now only has a field with this
PacketExtension (see for example
bytestreams.ibb.packet.DataPacketExtension).

Also changed hoxt API: Removed unnecessary indirection and made the
API more Smack idiomatic.
2014-11-10 11:43:18 +01:00
Florian Schmaus d60b63a89a Remove hashCode/equals from Message and Packet
Those where never correctly implemented and are not really used. If you
want to compare Packets, compare their toXML() result.

N.B. that we keep hashCode/equals for Message.(Subject|Body) because
those are correct and are in-use ('bodies' and 'subjects' are Sets in
Message).
2014-10-28 15:11:48 +01:00
Florian Schmaus 416f42deb7 Make fields in Packet and Message final 2014-10-28 15:11:48 +01:00
Florian Schmaus 10cca256c6 Remove unnecessary code in Message 2014-10-24 11:45:22 +02:00
Florian Schmaus ce8ccf3647 Make Message and Presence class final
In order to prevent users from trying to subclass those two, trying to
add their custom attributes (or attribute values) in the element of
those two, instead of using extension elements aka. PacketExtension.

See

- http://stackoverflow.com/q/26516386/
- http://stackoverflow.com/q/26507753/
- http://stackoverflow.com/q/26542601/
2014-10-24 11:14:41 +02:00
Florian Schmaus c024931de8 Remove XmlLangStanza
since all stanza types could have 'xml:lang' defined as top-level
stream element attribute.
2014-09-12 11:26:09 +02:00
Florian Schmaus fc51f3df48 Add support for XEP-0198: Stream Management
- De-duplicate code by moving it into AbstractXMPPConnection
- Introduce TopLevelStreamElement as superclass for all XMPP stream elements.
- Add SynchronizationPoint, ParserUtils
- Add ParserUtils

Fixes SMACK-333 and SMACK-521
2014-09-11 09:49:16 +02:00
Florian Schmaus 90c0064394 Add XmlLangStanza, to share the language field
between Message and Presence.
2014-09-03 18:11:32 +02:00