Commit Graph

88 Commits

Author SHA1 Message Date
Florian Schmaus 0fde39fa45 's;^\s+$;;' on all source files
And add checkstyle test for lines containing only whitespace characters.
2015-03-17 11:33:02 +01:00
Florian Schmaus bc093b620d Make Provider.parse() just throw Exception
instead of throwing XmlPullParserException, IOException and
SmackException.

Add a guard to AbstractXMPPConnection.processPacket() to always re-throw
RuntimeExceptions.
2015-03-13 09:27:18 +01:00
Florian Schmaus 701aa7d9c4 Merge branch '4.1'
Conflicts:
	smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
	smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java
	smack-core/src/main/java/org/jivesoftware/smack/PacketListener.java
	smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java
	smack-core/src/main/java/org/jivesoftware/smack/debugger/SmackDebugger.java
	smack-core/src/main/java/org/jivesoftware/smack/packet/Packet.java
	smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java
	smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/address/provider/MultipleAddressesProvider.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FaultTolerantNegotiator.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/IBBTransferNegotiator.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/Socks5TransferNegotiator.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/StreamNegotiator.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PubSubManager.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/packet/PubSub.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/VCardManager.java
	smack-extensions/src/test/java/org/jivesoftware/smackx/receipts/DeliveryReceiptTest.java
	smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java
	smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSession.java
	smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleProvider.java
	smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/packet/UserID.java
	smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/provider/RosterExchangeProvider.java
	smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java
	version.gradle
2015-03-04 22:42:36 +01:00
Florian Schmaus ed4fa3390f Add XMPPConnection.sendStanza(Stanza)
and deprecate sendPacket().
2015-03-04 21:46:44 +01:00
Florian Schmaus 21c0be5e2a Fixed AbstractXMPPConnection.cachedExecutorService
the combination with concurrencyLevel and LinkedBlockingQueue never
worked as intented. The idea was that the cachedExecutorService would
spawn new threads until maximumPoolSize (=concurrencyLevel) is reached,
and then start queing the Runnables.

But this was not the case, since ThreadPoolExecutor does not take into
consideration if the worker threads is busy, i.e. executing a Runnable,
or idle, i.e. waiting for a Runnable.

This means that if a busy Worker would execute a Runnable, which would
block, because it's waiting for an event (e.g. an incoming IQ
request), then the handling of those incoming IQ request would be
queued by ThreadPoolExecutor, because no fewer threads then corePoolSize
are running and the task can be queued (since the LinkedBlockingQueue is
unbounded).
2015-03-02 15:50:13 +01:00
Florian Schmaus 75ec271c6c Rename PacketListener to StanzaListener
and add the PacketListener as deprecated interface.
2015-03-02 15:49:56 +01:00
Florian Schmaus d4a6d8e653 Rename PacketFilter (and implementing classes) and PacketExtension
to StanzaFilter and ExtensionElement.
2015-02-28 13:49:38 +01:00
Florian Schmaus 404b90054b Use Executors.newSingleThreadScheduledExecutor
and remove the calls to setMaximumPoolSize() and steKeepAliveTime()
since they are ineffective on Android.
2015-02-25 16:17:09 +01:00
Florian Schmaus fbf0ba13ce Merge Smack 4.1.0-rc2
Conflicts:
	smack-core/src/main/java/org/jivesoftware/smack/filter/FromMatchesFilter.java
	smack-extensions/src/main/java/org/jivesoftware/smackx/iqregister/AccountManager.java
	version.gradle
2015-02-21 18:07:45 +01:00
Florian Schmaus 7ebea7ce94 Add StanzaIdFilter, deprecate PacketIDFilter 2015-02-19 16:07:42 +01:00
Florian Schmaus 887c6114b7 Add filter information to NoResponseException
in order to aid debugging errors. This made it necessary to override
'toString()' for all filters in Smack.
2015-02-19 12:14:16 +01:00
Florian Schmaus 5bb4727c57 Use Jid (and subclasses) from jxmpp-jid
Fixes SMACK-634
2015-02-17 16:07:16 +01:00
Florian Schmaus bc61527bd2 Expose InterruptedException
SMACK-632
2015-02-14 14:57:33 +01:00
Florian Schmaus 57c1b57b7c s/ a XMPP/ an XMPP/ 2015-02-12 12:13:19 +01:00
Florian Schmaus a0cf121d7a Make cached executor service use linked blocking queue
Since e6045c6593 the cached executor
services maximum pool size is limited to concurrencyLevel (was
previously Integer.MAX_VALUE). In order to prevent
RejectExecutionException we need to use an queue which max size is
greater than 1 (i.e. nont an SynchronousQueue).

Connection closed with error java.util.concurrent.RejectedExecutionException: Task org.jivesoftware.smack.tcp.XMPPTCPConnection$2@41dce200 rejected from java.util.concurrent.ThreadPoolExecutor@41d59150[Running, pool size = 3, active threads = 3, queued tasks = 0, completed tasks = 4]
 	at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2011)
 	at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:793)
 	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1339)
 	at org.jivesoftware.smack.AbstractXMPPConnection.asyncGo(AbstractXMPPConnection.java:1583)
 	at org.jivesoftware.smack.tcp.XMPPTCPConnection.processHandledCount(XMPPTCPConnection.java:1655)
 	at org.jivesoftware.smack.tcp.XMPPTCPConnection.access$2300(XMPPTCPConnection.java:137)
 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1083)
 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$200(XMPPTCPConnection.java:896)
 	at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:911)
 	at java.lang.Thread.run(Thread.java:841)
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 86ea027301 Add StringUtils.requireNotNullOrEmpty and Objects.requireNonNull
and use this in a few places.
2015-01-26 20:47:09 +01:00
Florian Schmaus 1407f10f7f Make connect() return a self-reference 2015-01-26 07:54:13 +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 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 e6045c6593 Add AbstractXMPPConnection.setConcurrencyLevel(int)
Also limit the max pool size of the remove callbacks service and use the
same keep alive time for idle threads as the cached executor service
uses.

Note that it would be possible to merge those two. But this could lead
to tasks from the cached executor service blocking the removal of
callbacks, which we don't want.
2015-01-26 07:54:11 +01:00
Florian Schmaus cbb477ebeb Add AbstractXMPPConnection.setReplyToUnkownIq(boolean)
and some javadoc related to IQ request handlers.
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 440af7675a Rename SmackConfiguration.DEBUG_ENABLED to DEBUG 2015-01-19 08:26:42 +01:00
Florian Schmaus 672d131280 Fix AbstractXMPPConnection.login() javadoc
non-SASL auth is no longer supported by Smack.
2015-01-19 08:26:41 +01:00
Florian Schmaus cb67f1d5c3 Switch 'username' paramater to CharSequence
instead of String. So that jxmpp-jids Localpart class can also be used
as argument.
Note that the username is not always the localpart!
2015-01-19 08:26:38 +01:00
Florian Schmaus ed67ed8e11 SASL, username and password related javadoc improvements 2015-01-18 20:42:27 +01:00
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 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 25bcb6b891 Deprecate setLegacySessionDisabled(boolean) 2015-01-17 12:36:35 +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 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 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 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 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