Commit Graph

49 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 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 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 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 f4aaf387d4 Use assertAtStartTag in parseStanza 2014-12-28 17:45:11 +01:00
Florian Schmaus c89d06861b Use switch-case in PacketParserUtils.parseContentDepthWithoutRoundtrip() 2014-12-10 12:28:22 +01:00
Florian Schmaus 77f0fdc156 Add (IQ|PacketExtension)IntrospectionProvider
This simplifies code as there is no longer a distinction between
"normal" providers and introspection providers in ProviderManager
necessary.

It's also easier to get an idea where introspection is used for parsing.
2014-12-10 11:09:52 +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 1de2fc2a81 Refactor Bind and Roster IQ parsing code into providers 2014-10-30 13:21:36 +01:00
Florian Schmaus e88583d287 Use switch/case in 'IQ parse(XmlPullParser)' 2014-10-30 13:21:36 +01:00
Florian Schmaus b5daee3032 Include the full content in UnparsedResultIQ
In order to prevent

<iq to='...' from='...' type='result' id='1'>
  <mynode xmlns='my:namespace' myattr='...'>
    <somenode\>
  </mynode>
</iq>

showing up as UnparsedResultIQ like this:

<iq to='...' from='...' type='result' id='1'>
  <somenode\>
</iq>
2014-10-30 13:21:36 +01:00
Florian Schmaus 3733a6aaa5 Cache the parser availability of the roundtrip feature
As otherwise there would be multiple log statements (which are of level
fine but nevertheless).

PacketParserUtils: XmlPullParser does not support XML_ROUNDTRIP org.xmlpull.v1.XmlPullParserException: unsupported feature: http://xmlpull.org/v1/doc/features.html#xml-roundtrip (position:START_DOCUMENT null@1:1)
PacketParserUtils: 	at org.kxml2.io.KXmlParser.setFeature(KXmlParser.java:2091)
PacketParserUtils: 	at org.jivesoftware.smack.util.PacketParserUtils.newXmppParser(PacketParserUtils.java:150)
PacketParserUtils: 	at org.jivesoftware.smack.util.PacketParserUtils.newXmppParser(PacketParserUtils.java:172)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection.openStream(XMPPTCPConnection.java:963)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter.access$2600(XMPPTCPConnection.java:1224)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketWriter$1.run(XMPPTCPConnection.java:1263)
PacketParserUtils: XmlPullParser does not support XML_ROUNDTRIP org.xmlpull.v1.XmlPullParserException: unsupported feature: http://xmlpull.org/v1/doc/features.html#xml-roundtrip (position:START_DOCUMENT null@1:1)
PacketParserUtils: 	at org.kxml2.io.KXmlParser.setFeature(KXmlParser.java:2091)
PacketParserUtils: 	at org.jivesoftware.smack.util.PacketParserUtils.newXmppParser(PacketParserUtils.java:150)
PacketParserUtils: 	at org.jivesoftware.smack.util.PacketParserUtils.newXmppParser(PacketParserUtils.java:172)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection.openStream(XMPPTCPConnection.java:963)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:970)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:989)
PacketParserUtils: XmlPullParser does not support XML_ROUNDTRIP org.xmlpull.v1.XmlPullParserException: unsupported feature: http://xmlpull.org/v1/doc/features.html#xml-roundtrip (position:START_DOCUMENT null@1:1)
PacketParserUtils: 	at org.kxml2.io.KXmlParser.setFeature(KXmlParser.java:2091)
PacketParserUtils: 	at org.jivesoftware.smack.util.PacketParserUtils.newXmppParser(PacketParserUtils.java:150)
PacketParserUtils: 	at org.jivesoftware.smack.util.PacketParserUtils.newXmppParser(PacketParserUtils.java:172)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection.openStream(XMPPTCPConnection.java:963)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:970)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:989)
PacketParserUtils: XmlPullParser does not support XML_ROUNDTRIP org.xmlpull.v1.XmlPullParserException: unsupported feature: http://xmlpull.org/v1/doc/features.html#xml-roundtrip (position:START_DOCUMENT null@1:1)
PacketParserUtils: 	at org.kxml2.io.KXmlParser.setFeature(KXmlParser.java:2091)
PacketParserUtils: 	at org.jivesoftware.smack.util.PacketParserUtils.newXmppParser(PacketParserUtils.java:150)
PacketParserUtils: 	at org.jivesoftware.smack.util.PacketParserUtils.newXmppParser(PacketParserUtils.java:172)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection.openStream(XMPPTCPConnection.java:963)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:970)
PacketParserUtils: 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:989)
2014-10-19 20:58:42 +02:00
Florian Schmaus ed58abbee7 Support XML_ROUNDTRIP where possible
The approach to avoid XmlPullParser's XML_ROUNDTRIP feature prevents
Smack from handling XML namespaces on e.g. PubSub payloads on platforms
where support for XML_ROUNDTRIP would be available.

We now check for this XmlPullParser feature and use it if it's
available.
2014-10-15 22:50:48 +02:00
Florian Schmaus 452b2aca0f Add 'PacketParserUtils.addPacketextension()' 2014-10-08 16:01:19 +02:00
Florian Schmaus 6980c8e63d Rework Smack Provider design
this is the first stop towards fixing "SMACK-65: parsing should look for
depth", by providing the initial parsing depth to the provider. Some
methods (.e.g parseMessage) now use the depth as abort condition,
instead of a unclean String equals check.

parseIQ() and parseExtension() where both renamed to parse.

This also restricts the Exceptions thrown by the parse method, to just
XmlPullParserException, IOException and SmackException (not really a big
victory, but nevertheless a slight improvement).

StreamFeatureProvider is now gone, we simply use PacketExtensionProvider
for stream features.
2014-10-08 16:01:14 +02:00
Florian Schmaus 47dd63e6b2 Don't use instanceof in a parse(IQ|PacketExtension)
Instead of using instanceof *every time* we parse an IQ or
PacketExtension, we now check the type of the Provider only once when
adding it.
2014-09-26 10:45:25 +02:00
Florian Schmaus 9016120d71 Add support for (custom) data form extensions
Fixes SMACK-605
2014-09-12 13:43:04 +02:00
Florian Schmaus d57fecfcc9 Add ELEMENT and NAMESPACE to RosterPacket 2014-09-12 13:40:04 +02:00
Florian Schmaus 46a4402a69 Add StreamFeatureProvider
so that AccountManager and the CapsExtension can be moved to
smack-extensions, where they belong.
2014-09-11 23:58:07 +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 34bc13bec7 Merge branch '4.0'
Conflicts:
	build.gradle
	smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java
	smack-core/src/main/java/org/jivesoftware/smack/packet/XMPPError.java
	smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
	smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/provider/ItemProvider.java
2014-09-05 22:11:35 +02:00
Florian Schmaus b5b134f569 Process all XML namespaces in PubSub ItemProvider
Fixes SMACK-601
2014-08-29 14:59:54 +02:00
Florian Schmaus 5a5524623c Make presence parsing more robust
by allowing 'show' to be an empty element: '<show />'
2014-08-28 14:14:18 +02:00
Florian Schmaus bbf89c65bf Fix typo in XmlStringBuilder, it's not an Angel
s/rightAngelBracket/rightAngleBracket/
2014-08-20 21:25:14 +02:00
Florian Schmaus 47ffcd8b6d Merge branch '4.0' 2014-08-20 15:29:29 +02:00
Florian Schmaus 1e5f0eb749 Make parseElementText handle empty string elements
ie. elements which only content is the empty string, for example
<body></body>.

Fixes SMACK-598
2014-08-20 15:23:52 +02:00
Florian Schmaus 6ab2bf9fe0 Also log the exception in parsePresence()
when parsing packet extensions.
2014-08-19 22:14:47 +02:00
Florian Schmaus 7277eb553a Enable more 'checkstyle' checks
AvoidStarImport
IllegalImport
RedundantImport
UpperEll
ArrayTypeStyle
GenericWhitespace
EmptyStatement
PackageDelcaration
2014-08-15 23:17:45 +02:00
Florian Schmaus 6caf2cbdb5 Don't use IQReplyFilter for resource binding
as the local username is only available after binding (and legacy
session establishment). This makes Smack compatible again with XMPP
services that use the user's JID as from attribute in the result IQ
after the bind set IQ, e.g. Facebook:

SENT:
<iq id='sqvTK-1' type='set'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <resource>Smack</resource>
  </bind>
</iq>

RCV:
<iq from='user.name.1@chat.facebook.com' id='sqvTK-1' type='result'>
  <bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
    <jid>user.name.1@chat.facebook.com/Smack</jid>
  </bind>
</iq>

Fixes SMACK-590
2014-08-04 18:01:05 +02:00
Florian Schmaus 89dc3a0e85 Add smack-android and redesign SASL authentication
This commit marks an important milestone with the addition of the
smack-android subproject. Smack is now able to run native on Android
without requiring any modifications, which makes the aSmack build
environment obsolete.

It was necessary to redesign the code for SASL authentication to achieve
this. Smack now comes with smack-sasl-provided for SASL implementations
that do not rely on additional APIs like javax for platforms where those
APIs are not available like Android.
2014-08-01 10:34:47 +02:00
Florian Schmaus bdf9a75c4f Use XmlStringBuilder in RosterPacket and XMPPError 2014-07-07 12:30:36 +02:00
Florian Schmaus 8b16c49a31 Remove Packet.ID_NOT_AVAILABLE 2014-07-06 23:57:06 +02:00
Florian Schmaus f671b9e781 Use CharSequence instead of String in parseContent()
and parseContentDepth(). This also means that the type of some fields
changed from String to CharSequence.

Also add Matcher for CharSequences.
2014-07-06 21:10:40 +02:00
Florian Schmaus 54b18e3575 Make XHMTMLExtensionProvider use parseElement()
which makes the whole provider much simpler.

Also use CharSequence as Base for XHTML-IM bodies.
2014-07-05 15:04:35 +02:00
Florian Schmaus 94a16ba41e Merge branch '4.0'
Conflicts:
	build.gradle
	documentation/connections.html
	documentation/gettingstarted.html
	smack-core/src/main/java/org/jivesoftware/smack/SmackException.java
	smack-core/src/test/java/org/jivesoftware/smack/parsing/ParsingExceptionTest.java
	smack-core/src/test/java/org/jivesoftware/smack/test/util/TestUtils.java
	smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/caps/cache/SimpleDirectoryPersistentCache.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/ping/PingManager.java
	smack-tcp/src/main/java/org/jivesoftware/smack/tcp/PacketReader.java
2014-07-05 14:37:22 +02:00
Florian Schmaus d8d88d9abd Make XHTMLText use XmlStringBuidler
also define all element and attribute names as constants.
2014-07-05 14:19:31 +02:00
Florian Schmaus 56222d6ee2 Improve parseContent() and parseContentDepth()
The idea is that xml-roundtrip should *never* be expected from a
XmlPullParser. So what we need is a method that parses the content of an
element without relying on getText() returning text if on START_TAG or
END_TAG. This is already done by PubSubs ItemProvider.

Also add PacketParserUtils.parseElement() which will return the current
element as String and use this method in PubSub's ItemProvider.
2014-06-20 12:07:25 +02:00
Florian Schmaus b083449cc3 Throw more exceptions when parsing Presences
when parsing core elements of Presences.
2014-06-10 18:42:17 +02:00
Florian Schmaus 009057e2e2 Streamline String to Enum transformation
for the core stanza Enums.
2014-06-10 18:35:24 +02:00
Júlio Cesar Bueno Cotta 9be0c480e3 Change IQ.Type to enum 2014-06-06 21:10:13 -03:00
Florian Schmaus 3647a7fce5 Improve parsing. Add method for de-serializing Strings
Move some duplicate code from XMPP(TCP|BOSH)Connection to
PacketParserUtils. Remove TestUtils as the method now part of Smack's
public API in PacketParserUtils.
2014-05-28 08:18:44 +02:00
Florian Schmaus 98333e362d Add 'null' check to parseContentDepth
Does not fix the actual problem, but at least prevents resource
allocation until OOM.
2014-05-11 10:18:49 +02:00
Florian Schmaus e0b8577930 Make IQ attributes final in parseIQ() 2014-05-11 10:15:14 +02:00
Florian Schmaus 90ea9ba2fc Make ProviderManager static
also remove initialize() from ProviderFileLoader, by simply putting the
code into the constructor.
2014-05-11 09:27:41 +02:00
Florian Schmaus 82654cd15e Use StringBuilder in parseContentDepth()
instead of StringBuffer, which comes with unnecessary synchronization
overhead.
2014-05-10 10:53:03 +02:00
Florian Schmaus 91fd15ad86 Prefix subprojects with 'smack-'
instead of using the old baseName=smack appendix=project.name approach,
we are now going convention over configuration and renaming the
subprojects directories to the proper name.

Having a prefix is actually very helpful, because the resulting
libraries will be named like the subproject. And a core-4.0.0-rc1.jar is
not as explicit about what it actually *is* as a
smack-core-4.0.0-rc1.jar.

SMACK-265
2014-04-28 19:44:14 +02:00
Renamed from core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java (Browse further)