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

2757 commits

Author SHA1 Message Date
Florian Schmaus
0bcd3d9356 Synchronize connect() and login()
Those methods being not synchronized was never an issue, but they should
mutally exclusive and not be called multiple times concurrently.
2015-01-18 11:16:12 +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
Gligor Selimovic
79fe40bf97 Fixed Exception in packet listener Workgroup
Prevent java.util.ConcurrentModificationException by using a
CopyOnWriteArraySet.
2015-01-17 20:06:06 +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
25bcb6b891 Deprecate setLegacySessionDisabled(boolean) 2015-01-17 12:36:35 +01:00
Florian Schmaus
9ec7d628c8 TLSUtils.disableHostnameVerificationForTlsCertificates()
(yeah, I know)

Sometimes "a friend" has setup an XMPP service which uses a self-signed
cert. While we can get a decent amount of security by using techniques
like e.g. the MemorizingTrustManager, there's still a pitfall. If the
service's TLS certificates contains no or the wrong service/hostname
information, Smack will throw an CertificateException. Therefore provide
an API call to disable hostname verification.
2015-01-17 12:17:28 +01:00
Florian Schmaus
c36ffd18c2 Improve VCard API
move API out of VCard into VCardManager. Mark old methods as deprecated.
2015-01-17 11:45:02 +01:00
Florian Schmaus
2ea469be10 Add javadoc to XMPPTCPConnectionConfiguration 2015-01-17 10:34:37 +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
2e23a6f150 Allows PacketCollector's to cancel each other
This is useful for cases where a result set is requested, as it's the
case in XEP-13 and XEP-313.

Also adds
XMPPConnection.createPacketCollector(PacketCollector.Configuration).
2015-01-16 20:55:32 +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
14b03149db Add PacketCollector.throwIfCancelled()
to prevent wrong usage of the collector.
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
9950f4d5de Mark (add|remove)PacketListener deprecated
in AbstractXMPPConnection. It was previously only marked deprecated in
the XMPPConnection interface definition.
2015-01-14 17:32:52 +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
9cc58ec8a0 Smack 4.1.0-beta2-SNAPSHOT 2015-01-14 09:32:13 +01:00
Florian Schmaus
fd69a4c97f Smack 4.1.0-beta1 2015-01-14 09:21:35 +01:00
Florian Schmaus
fc14962445 Make disconnect() not throw NotConnectedException
while disconnect(Presence) still does to notify the user that the
unavailable presence was not send.
2015-01-13 23:20:37 +01:00
Florian Schmaus
eb6b8df7c5 Add MultiUserChat.requestVoice() 2015-01-13 13:31:45 +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
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
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
f1a1215f35 Make DataForm type an enum 2015-01-10 20:10:46 +01:00
Florian Schmaus
98c69f6895 Add ServiceDiscoveryManager.serverSupportsFeature() 2015-01-10 19:36:33 +01:00
Florian Schmaus
b71039660b Improve data form API
Add

DataForm.getField(String)
DataForm.getHiddenFormTypeField()
2015-01-10 18:05:05 +01:00
Florian Schmaus
64242ace72 Add PacketCollector.getCollectedCount() 2015-01-10 18:05:00 +01:00
Florian Schmaus
e4bc6c2f37 Add support for 'ofrom' type (XEP-33)
of Extended Stanza Addressing.

Fixes SMACK-626.
2015-01-10 11:33:59 +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
50c7d0bc2c Don't log whole exceptions in VCardProvider
when trying to harden the parser.
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
8f8e0c7138 Use Async.go() in ReconnectionManager 2015-01-10 01:12:37 +01:00
Florian Schmaus
8c8ac546a9 Align thread names 2015-01-10 00:57:10 +01:00
Florian Schmaus
8e74f7faed Improve 'forward' code
Move Forwarded into forward.packet and remove deprecated methods. Also
make fields final.

Improve ForwardedProvider:
- use INSTANCE of DelayInformationProvider
- use loop label
- don't throw exceptions in certain cases, instead log
2015-01-09 11:32:00 +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
fcb4844d10 Improve DeliveryReceiptManager
Use anonymous inner classes for packet listeners so that the
processPacket() method is not exposed as part of the Managers public
API.

And some small fixes.
2015-01-08 23:15:18 +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
82eb9b18dd Add and use AbstractConnectionClosedListener 2015-01-07 20:11:00 +01:00