Commit Graph

77 Commits

Author SHA1 Message Date
Florian Schmaus 5bb4727c57 Use Jid (and subclasses) from jxmpp-jid
Fixes SMACK-634
2015-02-17 16:07:16 +01:00
Florian Schmaus 0ee2d9ed1e Remove deprecated Packet class 2015-02-14 16:21:26 +01:00
Florian Schmaus 57c1b57b7c s/ a XMPP/ an XMPP/ 2015-02-12 12:13:19 +01:00
Florian Schmaus e0a2441c62 Add Stanza.hasStanzaIdSet() 2015-02-09 07:35:07 +01:00
Florian Schmaus 1190edad0f Add 'Packet' interface
to aid transition to the new 'Stanza' class ('Packet' was renamed to
'Stanza' a few commits before this).
2015-02-06 09:34:58 +01:00
Florian Schmaus a5beb7bd79 Add Stanza.getExtensions(String,String) 2015-02-06 09:34:58 +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 9fc26f1d83 Use MultiMap for Stanza extension elements 2015-02-05 11:04:38 +01:00
Florian Schmaus 5c16fdb017 Make Presence.getMode() return available if null 2015-02-03 19:32:08 +01:00
Florian Schmaus 4013c68584 Use Objects.requireNonNull() in Presence
Also make Objects.requireNonNull() throw NullPointerException to match
the original API behavior.
2015-02-03 19:32:04 +01:00
Florian Schmaus 37081b2810 Send more information with the stream open tag 2015-01-28 09:31:28 +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 86ea027301 Add StringUtils.requireNotNullOrEmpty and Objects.requireNonNull
and use this in a few places.
2015-01-26 20:47:09 +01:00
Florian Schmaus d5b8647d9d Create smack-im subproject for XMPP-IM
Move Roster and Chat(Manager) code into their own packages within the
new smack-im subproject.

Apply Manager pattern to Roster.

Fixes SMACK-637.
2015-01-26 07:54:05 +01:00
Florian Schmaus e722018808 Improve IQ.Type javadoc 2015-01-21 23:48:46 +01:00
Florian Schmaus dc6af6dd99 Add IQ.isRequestIQ()
and check IQ argument in IQReplyFilter.
2015-01-21 23:39:03 +01:00
Florian Schmaus 2f739662e5 Make IQ.setType(Type) throw IllegalArgumentException
when argument is 'null'.
2015-01-21 13:20:34 +01:00
Florian Schmaus 0f028fdf50 Make IQ.type private
to prevent subclasses form setting type to null.
2015-01-21 13:17:23 +01:00
Florian Schmaus 6a542824bc Add XMPPError.toString() 2015-01-21 10:02:34 +01:00
Florian Schmaus 293f90c6c6 Add StanzaIdUtil 2015-01-19 18:51:53 +01:00
Florian Schmaus 8c9b3d5c62 Improve RosterPacket.ItemType javadoc 2015-01-19 16:12:16 +01:00
Florian Schmaus 4a5732d679 Fix Packet's javadoc
ID_NOT_AVAILABLE was removed in
8b16c49a31
2015-01-19 14:04:05 +01:00
Florian Schmaus 8409dddffd Add PacketUtil.extensionElementFrom()
and deprecate extensionElementfromCollection()
2015-01-19 08:41:21 +01:00
Florian Schmaus d5fb5e1d01 Add all possible attributes to StreamOpen 2015-01-16 20:55:43 +01:00
lucastucchi 9b9a08bb4b Fix typo in StreamError: s/host_unkown/host_unknown/ 2015-01-16 20:55:42 +01:00
Florian Schmaus 313e537394 Fix 'condtions' typo in StreamError 2015-01-16 20:55:42 +01:00
Florian Schmaus 1d83db898e Parse xml-not-well-formed as not-well-formed
for backwards compatibility.

SMACK-400
2015-01-12 13:43:35 +01:00
Florian Schmaus 47ced860ec Fix typo: s/Conditoin/Condition/ 2015-01-12 13:43:25 +01:00
Florian Schmaus b0cecee710 Rename IQ.ELEMENT to IQ.IQ_ELEMENT
to avoid confusion between the IQ element 'iq' and the IQs child
element. ELEMENT defined in an IQ sublcass should contain the *child*
element.

Add element to StreamInitation and fix FileTransferManager which still
used a packet listener instead of an IQ request handler to handle
incoming stream initiation requests.
2015-01-11 21:54:46 +01:00
Florian Schmaus bb8dcc9874 Add IQ request handler API
This also moves the logic to send error IQ replies from "when there is
no IQ provider registerd" to "when there is no IQ request handler
registered". Which has for example the advantage that IQ parsing no
longer asks for a connection instance.
2015-01-08 23:15:24 +01:00
Florian Schmaus e5c6c9bdf8 Remove unused private field in Session 2015-01-07 14:35:23 +01:00
Florian Schmaus c5d0fb3c7b Add support for *optional* session establishment
Don't perform XMPP session binding if the server announced the feature
as optional.

Fixes SMACK-622
2014-12-30 14:34:04 +01:00
Florian Schmaus 55a967da93 Add Packet.toString() 2014-12-27 21:12:59 +01:00
Jae Jang d5c7a2cad3 Switch right bracket to left bracket on condition start tag.
StreamError toXML should output <..><cond>..</cond>,
not <..>>cond>..</cond>.
2014-12-10 23:15:14 +01:00
Florian Schmaus 7640414e8d Set conditionText to null if it's the empty string
This fixes e.g. IllegalArgumentException "'conflict' can not contain a
condition text", when receiving elements like

<stream:error>
  <conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams'></conflict>
  <text xml:lang='' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>
    Replaced by new connection
  </text>
</sream:error>

(ejabberd does this)
2014-12-10 12:36:35 +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 9286a1decb Rework XMPP Error class design
Introduce AbstractError, change 'Conditions' to enums. Because of
AbstractError, it was necessary that PlainStreamElement and
TopLevelStreamElement becomes an interface. Thus the implementation of
TopLevelStreamElement.toString() had to be removed.

This adds

- policy-violation
- unexpected-request

to XMPPError.Condition, and removes the

- payment-required
- remote-server-error
- unexpected-condition
- request-timeout

Conditions

The file transfer code does now no longer throw XMPPErrorExceptions, but
SmackExceptions.

Fixes SMACK-608. Makes it possible to resolves SMACK-386.
2014-11-25 13:19:32 +01:00
Florian Schmaus 646a4a6f90 Add support for SASL failure 'text' elements
- Also move toString() into TopLevelStreamElement.
- Fix SASLFailure toXML xmlnsAttribute(NAMESPACE)
- Improve SASLFailure parsing
- And introduce XmlUnitUtils
2014-11-19 09:57:39 +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 77a4867450 Change Packet.getExtensionsXML()
Remove the synchronized, as getExtensions() is properly synchronized and will
return a copy.

Return XmlStringBuilder instead of CharSequence to take advantage of
fast XmlStringBuilder.append(XmlStringBuilder).

Mark the method as final, as it should not be overwritten.
2014-11-05 20:25:51 +01:00
Florian Schmaus 10643cce7c Use LinkedHashMap for PacketExtensions in Packet
to keep the order in which the elements are added.

Some XEPs define a Schema using 'xs:sequence' (see for example XEP-60 §
17.1), so the order the PacketExtensions are added should be the same
they are transformed to a XML String.
2014-11-05 17:58:32 +01:00
Florian Schmaus c1aef37081 Undeprecate Packet.getExtension(String)
as there a valid uses for it, see for example ChatStateManager:173.
2014-10-31 17:12:24 +01:00
Florian Schmaus 0e4196ae4b Added javadoc about extended content to PacketExtension 2014-10-30 13:21:36 +01:00
Florian Schmaus b73bb27463 Improve Packet javadoc 2014-10-29 14:05:38 +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 f94f7590a6 Store packet extensions in a HashMap
allowing O(1) lookups for PacketExtensions

The one EntityCapsManagerTest becomes obsolete with this change, as
duplicate extension elements (RFC 6120 § 8.4) are now no longer possible
after the stanza has been parsed (they still may be received on the
wire, but only the last duplicate will be added).
2014-10-28 15:11:43 +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