Commit Graph

53 Commits

Author SHA1 Message Date
Florian Schmaus c682091a47 Fix SASL EXTERNAL with client cert provided JID
isAnonymous() is now a bit weakened since it also considers
allowNullorEmptyUsername.

SaslExternalMechanism of smack-sasl-provided now also doesn't throw an
UnsupportedOperationException.

Follow up on 7e4e3699a1
2015-01-13 13:31:30 +01:00
Florian Schmaus 7e4e3699a1 Add allowEmptyOrNullUsername()
to ConnectionConfiguration.Builder().

And prepare SASL EXTERNAL for empty or null usernames.

Also clarify some parts regarding the user field.

Fixes SMACK-627
2015-01-10 11:26:15 +01:00
Florian Schmaus 6a43bab4f5 Remove protected getConnectionListeners()
Also remove reconnectionFailed() from XMPPBOSHConnection, only
ReconnectionManager should call it.

Add and fix javadoc of ConnectionListener.
2015-01-10 11:26:10 +01:00
Florian Schmaus 8c8ac546a9 Align thread names 2015-01-10 00:57:10 +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 e380872a41 Add 'resumed' bool ConnectionListener's authenticated()
It's important to know if the stream was resumed. authenticated() is the
ideal callback for Managers to reset their state (e.g. cached values of
the connection state). But if the stream was resumed, the cached values
don't have to be reset.
2015-01-07 21:11:09 +01:00
Florian Schmaus 3dd1365a5a Improve Privacy List code
notably add a cache for the active and default privacy list to avoid
IQ get/response round-trips.

Also add a few methods to PrivacyListManager to get the privacy list
names. The already existing methods always returned the whole list
together with the name, which caused two round-trips.

Simplified some code.

Properly escape Privacy XML.
2015-01-07 20:54:23 +01:00
Florian Schmaus 67c0a7089b Move notifyReconnection in AbstractXMPPConnection 2015-01-07 20:11:01 +01:00
Florian Schmaus 717090d272 Rework incoming packet listeners and Roster
Differentiate between asynchronous and synchronous ones. Asynchronous
are the ones where the invocation order may not be the same as the order
in which the stanzas arrived.

Since it's no longer guaranteed that when a unit test calls

processPacket(stanza)

the stanza will be completely processed when the call returns, it was
necessary to extend the unit tests (mostly Roster and ChatManager) with
a packet listener that waits for his invocation. Since we now also use
LinkedHashMaps as Map for the packet listeners (SMACK-531, SMACK-424),
adding a packet listeners as last also means that it will be called as
last. We exploit this behavior change now in the unit tests.

Rename 'recvListeners' to 'syncRecvListeners' in AbstractXMPPConnection.

Rename 'rosterInitialized' to 'loaded' in Roster.

Add Roster.isLoaded().

Reset 'loaded' to false in
Roster.setOfflinePresencesAndResetLoaded() (was setOfflinePresences()).

Fixes SMACK-583, SMACK-532, SMACK-424
2015-01-07 14:35:23 +01:00
Florian Schmaus f029b576a5 Add XMPPConnection.addAsyncPacketListener(PacketListener, PacketFilter)
and use this method in packet listeners that previously used Async.go().
2014-12-30 20:45:17 +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 5d5e3c05c5 Assert that processPacket is not called with null 2014-12-28 18:05:04 +01:00
Florian Schmaus 08c1f2c850 Add AbstractXMPPConnection.parseAndProcessStanza()
and remove BOSHPacketReader.

Reduces the duplicate code in smack-tcp and smack-bosh. Also moves
ParsingExceptionCallback into AbstractXMPPConnection.
2014-12-28 17:43:39 +01:00
Florian Schmaus 54706e3918 Move lastStanzaReceived in processPacket
of AbstractXMPPConnection.

In worst case we loose a timestamp because handleUnparsablePacket threw
an Exception.
2014-12-28 00:47:31 +01:00
Florian Schmaus efb9a5f517 Improve logging of finalize() methods 2014-12-19 12:55:31 +01:00
Florian Schmaus 18ac83cf8c Move SmackExecutorThreadFactory out of
AbstractXMPPConnection. And use it in PingManager.
2014-12-19 12:53:16 +01:00
Florian Schmaus 4b77d00e91 Re-add the login(String, String, String) method 2014-12-18 14:07:54 +01:00
Florian Schmaus d081055312 Use cached executor in AbstractXMPPConnection 2014-12-18 10:15:38 +01:00
Florian Schmaus a87227c531 Rename ConnectionConfigurationBuilder to Builder 2014-12-18 10:15:35 +01:00
Florian Schmaus 05870e6a22 s/Unkown/Unknown/g 2014-12-09 13:23:01 +01:00
Florian Schmaus 0db76f4eb1 Throw a NotConnectedException on disconnect()
if not connected. For consistent behavior, so that it is always
thrown. Previously it may be thrown or not.
2014-11-15 09:46:39 +01:00
Florian Schmaus def8fea05f Add reply timeout to NoResponseException message 2014-11-15 09:46:38 +01:00
Florian Schmaus c81cd34561 Apply builder pattern to ConnectionConfiguration
Introducing a clean split between the constant connection configuration
parameters, which are now all in ConnectionConfiguration and the dynamic
connection state (e.g. hostAddresses) which are now in
AbstractXMPPConnection.

Also removed all arguments of login() since the username, password,
resource and callback handler need now to be configured via
ConnectionConfiguration.

Also remove documentation/extensions/messageevents.md, as it's already
in documentation/legacy
2014-11-15 09:46:31 +01:00
Florian Schmaus a9c798f3bb Remove empty statements 2014-11-09 18:31:07 +01:00
Florian Schmaus 5647cac39c Move is(Connected|Authenticated) and getUser()
into AbstractXMPPConnection.

Also remove wasAuthenticated field from XMPPBOSHConnection, it is
already in AbstractXMPPConnection.
2014-11-01 12:42:53 +01:00
Florian Schmaus 0408d075b7 Merge invokePacketCollectors() and notifiyReceivedListeners()
into invokePacketCollectorsAndNotifyRecvListeners()
2014-10-30 23:36:40 +01:00
Florian Schmaus ed66c838e1 Invoke PacketCollectors in ListenerNotification
Also make executorService a non-ScheduledExecutorService. This was an
artifact from times where executorService as used to schedule
Runnables. But now it's just used to queue the receive packets in
Runnables and call the packet collectors and listeners.
2014-10-29 19:38:45 +01:00
Florian Schmaus 9f56842ee4 Notify packet sending listeners in new thread
sendListeners are now invoked *after* the packet has been put on the
wire.

Also sending listener exceptions are not catched and not only
NotConnectedExceptions. And a exception does not cause a 'break' but a
'continue' now. Log level is WARNING now.
2014-10-25 16:35:58 +02:00
Florian Schmaus 5ad4e85ed5 Setup Roster before sending initial presence
Thanks to Phil Winder for reporting the issue.
2014-10-20 21:58:20 +02:00
Florian Schmaus 98a3c46e9a Add XMPPConnection.createPacketcollectorAndSend(PacketFilter, Packet)
Using

createPacketCollector(filter);
sendPacket(packet);

was error prone, i.e. the PacketCollector could leak if sendPacket()
would throw an exception and the user forgot to call
PacketCollector.cancel(). For cases where
createPacketCollectorAndSend(IQ) is not sufficient (because we don't
send IQs), createPacketCollectorAndSend(PacketFilter, Packet) is now
used, which does take care that the PacketCollector does not leak if
sendPacket() throws an Exception.
2014-10-13 10:45:00 +02:00
Florian Schmaus 63d52f6eaa Replace PacketInterceptor with PacketListener
both serve the same purpose: As callback for Packets. There is no need
to have both, so remace PacketInterceptor and let PacketListener take
its place. Some classes like ChatStateManager can now use
MessageListener as interceptor callback, which is more convenient.
2014-10-12 19:19:44 +02:00
Florian Schmaus 36da216b4a Reworked Interceptor and InterceptorWrapper
Allows interceptor to remove themselves in the interceptPacket() method.

Same change for Interceptors as was done in
15d59299a2 for (send|recv)Listeners.
2014-10-10 12:22:23 +02:00
Florian Schmaus c3528d082e Add invokePacketCollectors, remove duplicate code
Add javadoc about why we use CocurrentLinkedQueue for collectors.
2014-10-10 02:41:37 +02:00
Florian Schmaus 15d59299a2 Reworked (send|recv)Listeners, ListenerWrapper
instead of rely on ListenerWrapper checking the PacketFilter *and*
invoking the PacketListener we now use two for-each loops, where the
first filters the PacketListeners that should get invoked and use the
second for-each loop to actually invoke the PacketListener.

Before, the code was not thread safe if a PacketListener would remove
itself from the (send|recv)Listeners.

Also make packet(Listener|Filter) in ListenerWrapper final.
2014-10-10 00:44:51 +02:00
Florian Schmaus 03686fbaaf Use CopyOnWriteArraySet for connectionListener 2014-10-09 23:55:02 +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 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 28629e0e7f Fix wrong boolean condition in async API
inverse boolean condition, correct is: "if packetListener has been
removed, then we received no response" and add check for
exceptionCallback being null.
2014-08-21 12:02:32 +02:00
Florian Schmaus 64e49cb934 Add getLastStanzaReceived() to XMPPConnection
also remove faulty PongFilter from PingManager. It never matched any
stanzas, since a Pong is just a plain result IQ that is not qualified by
any XMPP Ping namespace.

Fixes SMACK-597
2014-08-20 10:35:17 +02:00
Vyacheslav Blinov 342ab65138 SmackDebugger initialization moved to dedicated factory.
You can set your custom debugger class as before, by using clear api
method ReflectionDebuggerFactory.setDebuggerClass, or you can set custom
debugger factory using SmackConfiguration.setDebuggerFactory if it's not
enough flexible for your needs
2014-08-18 12:03:54 +02:00
Florian Schmaus c84419a55e Create org.jivesoftware.smack.rosterstore package
and move RosterStore and DirectoryRosterStore into it.
2014-08-16 15:37:16 +02:00
Florian Schmaus aeda0e4660 Add an API to send and wait async for a response
SMACK-595

Also remove the unused AbstractXMPPConnection.getPacketListeners()
method.
2014-08-16 00:08:53 +02:00
Florian Schmaus 70f1c22bb2 Prevent PacketCollector leaking
in AbstractXMPPConnection.createPacketCollectorAndSend(IQ) in case there
is a NoResponseException.
2014-08-04 18:15:42 +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 fe258fe110 Fix XMPPTCPConnection to set 'host' and 'port'
Fixes SMACK-585
2014-07-23 08:29:35 +02:00
Florian Schmaus 1ed5c48bcc Merge branch '4.0'
Conflicts:
	smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java
2014-07-16 10:52:58 +02:00
Júlio Cesar Bueno Cotta 944ac37fc3 Remove getConfiguration() from XMPPConnection
interface definition.
2014-06-05 11:42:26 +02:00
Florian Schmaus 12b9e9d507 Add AndroidDebugger as possible debugger
Create AbstractXMPPConnection.DEBUGGERS with possible debugger classes.
2014-06-01 12:24:50 +02:00