1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-01 01:35:59 +01:00
Commit graph

89 commits

Author SHA1 Message Date
Florian Schmaus
57c1b57b7c s/ a XMPP/ an XMPP/ 2015-02-12 12:13:19 +01:00
Florian Schmaus
96e3d5c533 Add XMPPTCPConnection(CharSequence, String) constructor 2015-02-09 07:35:16 +01:00
Florian Schmaus
1630b44b8d Reset smSessionId on XMPPTCPConnection.disconnect() 2015-02-09 07:35:15 +01:00
Florian Schmaus
3b8f4c144e Add missing space in log statement within XMPPTCPConnection 2015-02-09 07:35:15 +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
5a56ff011b Add XMPPConnection.getStreamId()
and remove getConnectionID().

Also make streamId a field of AbstractXMPPConnection. Most XMPP
connection types have a streamId, it appears to be optional when BOSH
is used though.
2015-01-28 17:14:33 +01:00
Florian Schmaus
612ca1ad9d Use CharSequence instead of String for username
in XMPPTCPConnection's constructor.
2015-01-28 09:34:01 +01:00
Florian Schmaus
37081b2810 Send more information with the stream open tag 2015-01-28 09:31:28 +01:00
Florian Schmaus
780872f2ef Remove superflous throwAlreadyConnected…Exception
in XMPPTCPConnection. connectInternal() is only called by
AbstractXMPPConnection.connect() which does already invoke this method.
2015-01-26 07:54:12 +01:00
Florian Schmaus
4b10f36e9e Report failed DNS SRV lookup in ConnectionException
instead of just logging a warning if the XMPP domain has no DNS SRV
lookups, create the failedAddresses list now within DNSUtil and add the
information that the SRV lookup failed.
2015-01-26 07:54:12 +01:00
Florian Schmaus
30ec2bd072 Cleanup XMPPTCPConnection, mostly exception handling
In initConnection, only initReaderAndWriter() throws IOException.

connectUsingConfiguration doesn't need to take an argument.

PacketReader.init does not throw a SmackException.

Use Async.go() in PacketWriter, just like it's already done in PacketReader.
2015-01-26 07:54:12 +01:00
Florian Schmaus
d9c97fabfb Make connectUsingConfiguration more robust
If 'return' is not reached, then always throw a
ConnectionException.

Also make it clear that populateHostAddresses adds at least one address.
2015-01-26 07:54:11 +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
4c218c96f6 Move Stream Management code into o.j.smack.sm
from o.jsmack.tcp.sm, as XEP-198 Stream Management is not an "XMPP over
TCP" exclusive feature. It could also be use together with the Websocket
binding of XMPP, so we may have a smack-streammangement in the
future. This change prepares for that by moving the SM code out of the
XMPP TCP package namespace.
2015-01-18 11:07:47 +01:00
Florian Schmaus
6d7f3904d9 Throw NotConnectedException on login()
if connect() was not previously called. Previously calling login() with
arguments would not check for the preconditions.

The check to throw needs to be performed in AbstractXMPPConnection
before every 'abstract login(Non)Anonymously()' call. That's the two
lines that check the preconditions are duplicated.

Also fix NPE in
XMPPTCPConnection.throwNotConnectedExceptionIfAppropriate() when
packetWrite is null (i.e. if the connection was never connected before).
2015-01-17 17:53:36 +01:00
Florian Schmaus
75fd1683d1 Fix stanzaIdAcknowledgedListeners not being called
Replace isNotEmpty(id) with isNullOrEmpty(id)
2015-01-17 14:11:21 +01:00
Florian Schmaus
2ea469be10 Add javadoc to XMPPTCPConnectionConfiguration 2015-01-17 10:34:37 +01:00
Florian Schmaus
d099e7b16d Improve handling of InterruptedException
InterruptedExceptions should be treated as the users intention to
'cancel' the current thread's task. There is no such thing as a
spurious interrupt (not to be confused with "spurious wakeups").
2015-01-16 17:31:10 +01:00
Florian Schmaus
106512d8d4 Assure stanzaIdAcknowledgedListeners are removed
after at most 12 hours.

Also set a keep alive time for the removeCallbacksService to 30 seconds
and add AbstractXMPPConnection.schedule(Runnable, long, TimeUnit).
2015-01-15 21:36:23 +01:00
Florian Schmaus
6209d75536 Add XMPPTCPConnection.getMaxSmResumptionTime()
Note that the logic determining the max resumption time has changed,
Math.min() is now used instead of Math.max(). This should match the real
life situation, e.g. if the server announced a max resumption time of 10
minutes and the client one of 5, then it should be assumed that the
connection/stream state is dropped by the parties after 5 minutes.
2015-01-15 21:33:44 +01:00
Florian Schmaus
04d47b2dda Use Asyn.go() to create and start reader thread
in XMPPTCPConnection.
2015-01-15 18:36:35 +01:00
Florian Schmaus
ed84b4a8b3 Add javadoc to and fix typo in XMPPTCPConnection 2015-01-15 18:36:35 +01:00
Florian Schmaus
3582de0654 Fix initializing clientHandledStanzasCount
From XEP-198: Stream Management § 4. Acks:

"""
Note: There are two values of 'h' for any given stream: one maintained
by the client to keep track of stanzas it has handled from the server,
and one maintained by the server to keep track of stanzas it has handled
from the client. The client initializes its value to zero when it sends
<enable/> to the server, and the server initializes its value to zero
when it sends <enabled/> to the client (it is expected that the server
will respond immediately to <enable/> and set its counter to zero at
that time).
"""

Previously smack initialized both to 0 just before sending enabled. But
according to the note from XEP-198 the server's counter is initialized
by the server "when it sends <enabled/> to the client, so we need to set
clientHandledStanzasCount to 0 when we receive <enabled/>. Because the
server started counted right after he send <enabled/>.

Thanks to Kim "zash" Alvefur for pointing this out.
2015-01-15 18:36:08 +01:00
Florian Schmaus
3187436ba7 Throw exception if END_DOCUMENT is seen
instead of calling just instantShutdown(). Now we will catch this
exception, call notifyConnectionError which also calls
instantShutdown() but also notifies the connection listeners of the
event.

Smack should never all instantShutdown() without notifying the
connection listeners.
2015-01-14 17:07:35 +01:00
Florian Schmaus
2aaedcb2fd Improve stanza ack listener handling
- Don't abort if there is a NotConnectedExceptions, other listeners may
  want to be informed of the ack nevertheless.
- Simply return if the id is null or empty.
2015-01-13 13:31:45 +01:00
Florian Schmaus
24b940138f Improve XMPPTCPConnection.processHandledCount(long)
Add shortcut: If stanzaAcknowledgedListeners is not empty, then we don't
need to check the stanzaIdAcknowledgedListeners.

Also fixes a bug, instead of

if (id != null && stanzaAcknowledgedListeners.contains(id)) {

it must be

if (id != null && stanzaIdAcknowledgedListeners.containsKey(id)) {
2015-01-13 13:31:45 +01:00
Florian Schmaus
07539820c3 Make addStanzaAck…Listener() not throw
users may want to add listeners before the connection is connected. The
comment was also wrong, those listeners never got auto removed.
2015-01-13 13:31:45 +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
67c0a7089b Move notifyReconnection in AbstractXMPPConnection 2015-01-07 20:11:01 +01:00
Florian Schmaus
f6144c553c Try all Inet Addresses of the host when connecting
instead of the first resolved one.

Also some small refactorizations (e.g. getSocketFactory())
2015-01-07 14:35:23 +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
c770b12348 Add log statements around socket.connect() of XMPPTCPConnection 2015-01-07 14:35:22 +01:00
Florian Schmaus
a24c813ed1 Add XMPPTCPConnectionConfiguration.getConnectTimeout() 2015-01-07 14:35:22 +01:00
Christoph Fiehe
665e7914f2 Enable OSGi compliance via 'DynamicImport-Package: *'
on package layer instead of Declarative Service (DS) approach.
Restructuring and cleanup of initialization process to ensure that all
internal config files are found by the corresponding bundle
classloaders.

SMACK-343
2015-01-03 13:14:02 +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
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
d0341c1d94 Add XMPPTCPConnection.streamWasResumed() 2014-12-17 10:34:16 +01:00
Florian Schmaus
05870e6a22 s/Unkown/Unknown/g 2014-12-09 13:23:01 +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
59d3f55003 Set smWasEnableAtLeastOnce before sync point
to allow users to add stanza acknowledged listeners in
ConnectionListener.authenticated().
2014-11-17 23:59:00 +01:00
Florian Schmaus
504b550ef2 Report not connected/authenticated when resumeable
Since c81cd34561 we can report not
connected/authenticated when the client is disconnected but the stream
could be resumed. The previous behavior caused some confusion among
the users.
2014-11-16 18:53:31 +01:00
Florian Schmaus
301519a264 Fix END_DOCUMENT handling in XMPPTCPConnection
The 'break' statement in the END_DOCUMENT case should break the parsing
loop and not the switch/case within. Therefore we need to add a loop
label on break on that label.
2014-11-15 09:46:39 +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
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
6b21455b32 Asynchronous invoke Stanza Acknowledged Listeners 2014-10-29 10:18:08 +01:00
Florian Schmaus
ac41fda1e5 Add Stream Management javadoc
- rename idStanzaAcknowledged to stanzaIdAcknowledged
- introduce smWasEnabledAtLeastOnce and throw
  StreamManagementNotEnabledExceptions
- enable SM is SM resumption is enabled
2014-10-29 10:06:33 +01:00
Florian Schmaus
92bc3452da Handle spurious interrupts in XMPPTCPConnection
Also remove unnecessary done() check in nextStreamElement() and remove
wrong comment in !instantShutdown branch. There is no mechanism to
forcible close the socket.
2014-10-28 15:11:48 +01:00