A start for the new Jingle API. Since Jingle is a single IQ with many
plugable extensions, there are some particularities we need to deal
with, e.g. jingle users have to register with JingleManager.
This is untested code. There may be drangons.
Previously publish() was "asynchronously" in that sense that the response
of the IQ as *not* awaited, and send() would wait for the
responses. It makes no sense to have that functionality this way.
Instead we now make publish() to the right thing, i.e., wait for an IQ
result, make send() a proxy for publish(), and mark send() deprecated.
In the future, there may be a publishAsync() method which returns a
Future instance.
by extending Manager.
Because FileTransferNegotiator will hold a strong reference to the
StreamNegotiators, which will eventually prevent XMPPConnection from
being GC'ed if no weak references in StreamNegotiator are used.
Thanks to Werner Glanzer for pointing this out.
To prevent
java.util.ConcurrentModificationException
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:788)
at java.util.HashMap$KeyIterator.next(HashMap.java:815)
at org.jivesoftware.smackx.ping.PingManager.pingMyServer(PingManager.java:252)
at org.kontalk.service.msgcenter.MessageCenterService$3.run(MessageCenterService.java:1114)
at java.lang.Thread.run(Thread.java:818)
Thanks to Daniele Ricci for reporting this.
instead of an EntityFullJid, because according to XEP-0045 § 7.8.1.:
"The <room@service> itself MUST then add a 'from' address to the
<invite/> element whose value is the bare JID, full JID, or occupant
JID of the inviter …"
The jids list doesn't have to be lazy initialized, because every IQ of
that type is guaranteed to contain at least one JID.
Also use ParserUtils.getJidAttribute().
for the last message. We now count the number of messages we want to
retrieve, and don't wait for another message if we have already
received all.
Thanks to King Jeong Hun for reporting this.
capturing all outoing presences of type 'available' would also capture
presences not used for presence broadcast, e.g., MUC presences.
This caused the EntityCaps integration test (localEntityCaps) to fail
if the MUC integration test was run before.
the manager must use a copy of the BlockListIQ's JID list, since it may
be the empty list which is not modifiable.
Also rename the getter methods from getJids() to getBlockedJids().
and not by '!error' as this there are presence stanzas containing the
muc#user namespace also send to the client, which results in a
ClassCastException in the StanzaListener.
Returning a boolean is not really expressive in such cases. For example,
if it returns 'false' then the callee has no information *what* went
wrong. Instead throw an SmackException with some more information.
A unauthorized user sents a update room subject message which is
rejected by the server. It responds with an error message which
is not picked up by the ChangeSubjectListener.
Mostly remove the helper utils. The server is required to present the
client with a consisent state of the block list and corresponding
modifications, so we should not end up with duplicate entires if we
don't check for them.
SMACK-731
Smack's previous entity caps implementation assumed that an entity lost
its entity caps feature as soon as a presence without caps from that
entity was received. But according to XEP-0115 § 8.4, this is a
perfectly normal optimization technique. We now reset the caps state
after an available presence becomes unavailable.
Also introduce PresenceEventListener, which is required for this
feature.
Also make Roster.preApprove() take a BareJid as argument.
Fixes SMACK-723.
Some servers respond to disco#info requests with
<iq id='npGtO-21' type='result' to='phone@xxx/MAXS' from='xxx'>
<query xmlns='http://jabber.org/protocol/disco#info'>
<identity type='pep' name='Prosody' category='pubsub'/>
<identity type='im' name='Prosody' category='server'/>
<feature var='urn:xmpp:blocking'/>
<feature var='urn:xmpp:carbons:2'/>
<feature var='urn:xmpp:carbons:1'/>
<feature var='vcard-temp'/>
<feature var='http://jabber.org/protocol/commands'/>
<feature var='urn:xmpp:mam:0'/>
<feature var='jabber:iq:private'/>
<feature var='http://jabber.org/protocol/pubsub#publish'/>
<feature var='http://jabber.org/protocol/disco#info'/>
<feature var='http://jabber.org/protocol/disco#items'/>
<feature var='urn:xmpp:ping'/>
<feature var='msgoffline'/>
<feature var='jabber:iq:roster'/>
<feature var='urn:xmpp:archive:auto'/>
<feature var='urn:xmpp:archive:manage'/>
<feature var='urn:xmpp:archive:pref'/>
<feature var='http://jabber.org/protocol/rsm'/>
<feature xmlns='urn:xmpp:archive'><optional><default/></optional></feature>
</query></iq>
Note the
<feature
xmlns='urn:xmpp:archive'><optional><default/></optional></feature>
which will cause the current parser implementation to parse it as
DiscoInfo Feature resulting in an Exception because some attributes are
missing.
This commit prevents this.
The previously used approach of
project(':smack-core').sourceSets.test.runtimeClasspath
caused the 'eclipse' target to produce duplicate classpath entries in
.classpath when run with Gradle >= 2.6. It also relied on Gradle
internals.
Instead we now use
project(path: ":smack-core", configuration: "testRuntime")
project(path: ":smack-core", configuration: "archives")
to be able to use test classes from other subprojects (usually
smack-core) in e.g. smack-extensions. The 'archives' configuration
includes the test jar.
See also https://discuss.gradle.org/t/11784
Thanks to Lari Hotari for helping with this issue.
So that we can wrap the original exception within the
SmackException. It's not possible to wrap it into the IOException
because of the used min Android API level.
Check if serverSocket is null before calling isClosed(), as otherwise
the resulting NPE will cause an endless loop.
Thanks to Michael Grafl for reporting.
Fixes SMACK-707.
instead of String, which will always return null if used with
ocupantsMap.get(String), because String.equals(Object) is only true if
Object is also instanceof String.
Thanks to Adnan Elezovic for reporting.
And replace all instances where String.Builder.append() is called with a
String of length one with append(char).
Also adds StringUtils.toStringBuilder(Collection, String).
and use weak references.
Disabling the Socks5Manager every time the connection is terminated, and
re-enabling it when it got connected again causes unwanted side
effects. Like adding a new feature to the ServiceDiscoveryManager causes
an update of the entity's capabilities, which then triggers a new outgoing
presence (announcing the new caps version).
SMACK-671
Also don't override eventually send presences on
updateLocalEntityCaps(), instead save the last sent Presence stanza and
re-send that stanza.
SMACK-669.
Must use interceptors instead of sending listeners, as those are
invoked *after* the stanza has been put on the wire. Also use the
correct filter, which excludes ack messages.
Fixes SMACK-656.
Also add MucConfigFormManager and improve the MUC API (SMACK-648). Bump
to jxmpp 0.5.0-alpha3.
Improve and extend PrivateDataManager and BookmarkManager.
XEP-0080 states that lon,lat,error,alt,accuracy,bearing and speed are
decimal values, and thus should either be present as decimal, or not present
at all (as they are optional elements).
Usage of String.valueOf(value) in code lead to creating a "null"
string in case number was not present, thus creating an element with
"null" content, which is not a valid decimal value.
Remove the TestSuite class. We now have
SmackTestSuite
^
|
InitExtensions
^
|
$UnitTest
where most basic setup is done in a static block within
SmackTestSuite (only stringencoder setup right now).
Also some minor fixes in unit tests.
Other Managers, e.g. EntityCapsManager, may be notified if e.g. a
feature is added or removed. While they are notified, the state of SDM
must be consistent, therefore synchronize SDM methods that modify the
state.
- Lines containing tab(s) after space
- Usage of printStackTrace
- Usage of println
- Add SupressionCommentFilter module
SuppressionCommentFilter can be enabled with
// CHECKSTYLE:OFF
and disabled with
// CHECKSTYLE:ON
instead of throwing XmlPullParserException, IOException and
SmackException.
Add a guard to AbstractXMPPConnection.processPacket() to always re-throw
RuntimeExceptions.
- Made jid of type BareJid
- Made it implement TypedCloneable
- Made it implement Serializable
- Made it immutable
Also update its parsing code. And add some convenience methods to
ParserUtils.
As not including "role='none'" when kicking a user will result in an
XMPPErrorException. Also there appears to be nothing in XEP-45 which
says "if role is not set, then it defaults to 'none'".
Data packets where not received by the InBandByteStream due to a missing
IQRequestHandler
Conflicts:
smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/DataListener.java
smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamManager.java
smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamSession.java
With bb8dcc9874 the concept if IQ request
handlers was introduced in Smack. This doesn't allow packet/stanza
collectors/listeners to filter for incoming IQ requests. Unfortunately
the file transfer code relied on this being able, so it broke with the
change.
There were two places where the file transfer code was listening for
incoming IQ requests:
- InitationListener(s)
- Negotiator(s)
With this change, we let the InitiationListener signal the existence of
an incoming initation request, send by an IQ of type 'set', using the
newly created EventManager utility.
The negotiator waits for those events to arrive and proceedes as it would
have done when the packet collector was used.
In case the users tries to save a VCard he previously retrieved via
loadVCard() this would previously fail, as the 'to' address is set to
the clients full JID.
b71039660b made FormField.setType(Type)
throw an illegal argument exception if type is fixed, but the
DataFormProvider was not changed, so it still would call
setType(Type.fixed).
Change DataFormProvider so that the non-argument constructer of
FormField is used when type == fixed.
Make 'order' an long
Parse fall-through case's child elements (message, iq, presence-in,
presence-out)
Remove
privacy.addExtension(new DefaultPacketExtension(parser.getName(), parser.getNamespace()));
at the beginning of PrivacyProvider. Was there since day one for an
unknown reason.
add a new AutoReceiptMode enum that specifies how delivery receipt
requests are handled. Default is to send receipts if the requstor is
subscribed to the user's presence.
Also make sure that messages contain an id if a receipt request is
added to it.
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).
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.
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
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.
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.
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.
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.
Also add XHTMLExtension.from(Message) and change XHTMLManager.addBody()
signature so that it expects a XHTMLText (Modifications to the original
patch by Florian Schmaus).
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
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
- HeadersExtension.getHeaders() now returns a List instead of a
Collection
- Use XmlStringBuilder in Header and HeadersExtension toXML()
- Add HeadersProviderTest
- Use Smack formatting
Also remove duplicate parsing code regarding SHIM from HOXT
implementation.
Data Forms Validation are a part of Data Fields and implemented as
extensions, added to a Datafield.
Data validation extensions are validated before adding to the message,
using the consistency rules as described in the XEP.
Fixes SMACK-621.
Minor modifications done by Florian Schmaus <flo@geekplace.eu>
- No need to use a synchronized map, as the getInstanceFor method is
synchronized
- Put the PingManager in the map where it's created and not in the
constructor
Those were broken since 9e797c1b17 as they
always used the basic PubSub namespace, i.e. without a fragment. Which
resulted in e.g. delete requests look like
<iq to="pubsub.ec-xmpp" id="2GAeW-75" type="set">
<pubsub xmlns="http://jabber.org/protocol/pubsub">
<delete node="2e92d38c-9e90-47f6-8e26-330d25ebe96b"/>
</pubsub>
</iq>
when the namespace should be in fact
http://jabber.org/protocol/pubsub#owner
Where e.g. entity reference expansion is disbled. Note that this affects
only the VCard provider, as it's the only provider in Smack that uses
SAX's DocumentBuilder.
Fixes SMACK-620
Mostly because of 738276e1aca093da16ea160462bdda7523a26a14 in jxmpp,
which fixes fractional seconds parsing.
Which made also the slight change in DelayInformationTest necessary.
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.
- to use CopyOnWriteArraySet for listeners
- do not wrap instance map in sync block (getInstanceFor() is already synchronized)
- use PacketTypeFilter instead of PacketExtensionFilter
- add removeListener(PrivacyListListener)
- rework getPrivacyLists
- don't set from attribute
- remove unused getUser()
Entity Capability versions are useless without the information which
hash algorithm was used to calculate those. Right now, only 'sha-1' is
used, but this may change in the feature. This commit makes the first
steps preparing for such a feature.
Also fixes a minor bug:
- CAPS_CACHE.put(currentCapsVersion, discoverInfo);
currentCapsVersion is not a valid key for the cache, as it does cache
"node + '#' + ver" to disco infos.
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.
XEP-141 Data Forms are never used as stand alone packet extension, there
is no need to register the provider with the ProviderManager.
This makes the parse method of DataFormProvider static.
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
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.
allowing O(1) lookups for PacketExtensions
The one EntityCapsManagerTest becomes obsolete with this change, as
duplicate extension elements (RFC 6120 § 8.4) are now no longer possible
after the stanza has been parsed (they still may be received on the
wire, but only the last duplicate will be added).
Thanks to Stefan Karlsson for helping with the implementation.
Also add SASLMechanism.checkIfSuccessfulOrThrow(), to increase the
security by verifying the mechanisms state at the end of SASL
authentication.
SASLMechanism now has a SASLPrep StringTransformer.
Refactor SHA1 functions out of StringUtils into SHA1 utility class.
Add MAC utility class.
Make DummyConnection getSentpacket() methods use generics to make unit
testing SCRAM-SHA1 easier.
Fixes SMACK-398
Make sure that the Packets are of type Message. To prevent:
E/AbstractXMPPConnection﹕ Exception in packet listener
java.lang.ClassCastException: org.jivesoftware.smack.packet.Presence cannot be cast to org.jivesoftware.smack.packet.Message
at org.jivesoftware.smackx.muc.MultiUserChatManager$2.processPacket(MultiUserChatM anager.java:124)
at org.jivesoftware.smack.AbstractXMPPConnection.notifiyReceivedListeners(Abstract XMPPConnection.java:854)
at org.jivesoftware.smack.AbstractXMPPConnection$ListenerNotification.run(Abstract XMPPConnection.java:876)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201 (ScheduledThreadPoolExecutor.java:153)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Schedu ledThreadPoolExecutor.java:267)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:856)
I've got reports from users that in some cases there can be multiple
identities. Not just one, and in this case, the node type may not be the
first identity. We now iterate over all identities until we either found
one of type "leaf" or "collection".
For example one user reports an ejabberd with PEP case, where the first
identity is of type "pep", the second of type "leaf" and a third one
with category "account" and type "registered".
Also extend DiscoverInfo API with hasIdentity(String, String) and
getIdentities(String, String).
in AdHocCommandData.
This check was added in 3a37b71e19, but a
session ID can be null, if it's the first invocation. This prevented
RemoteCommand.execute() from executing, since RemoteCommand's sessionID
member will be null at the first invocation.
apply the Manager pattern to 'muc'. This prevents the user creating
multiple MultiUserChat instances for the same MUC.
Move the static method from MultiUserChat to MultiUserChatManager.
Also add AbstractNodeInformationProvider.
Use CopyOnWriteArraySet for listeners, remove the old reflection based
listener invocation approach.
Remove unnecessary casts.
Return List instead of Collection where possible.
sendMessage(Message) now set's the MUC as 'to' and the message type to
groupchat.
remove PacketMultiplexListener, RoomListenerMultiplexor and
ConnectionDetachedPacketCollector(Test), which was a bunch of
(in same cases redundant) code that formed a complex construct that
presumably tried to make MultiUserChat instances easily garbage
collect-able.
Now, MultiUserChat should be eligible for gc if the userHashLeft() is
invoked before the reference to the instance is dropped, which should be
the case in the most scenarios. Otherwise the connection may references
the MultiUserChat instance over Packet(Listener|Interceptor)s preventing
the gc.
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.
Use PresenceListener as intercepting callback interface.
Remove the for-each loops in MultiUserChat by using the interception
facilities of the XMPPConnection.
Add ToFilter.
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.
instead of using a PacketListener, which means that the user has to
downcast the Packet to Message, we now use a Listener which callback
parameter is already Message/Presence.
It is necessary to introduce MessageListener and PresenceListener, which
are interfaces that have a callback for Message/Presence instead of
Packet. The 'old' MessageListener is renamed to ChatMessageListener.
Use Generics in ConnectionDetachedPacketCollector.
- Make MultipleAddress.Type a enum
- Change the signature of the methods to use Collection instead of List
- Use for-each loops instead of iterators
- Switch Provider to new provider pattern (using switch-case)
- Use XmlStringBuilder (extend the API by two new methods)
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.
also remove 'lang' attribute, since it belongs into IQ, see XEP-50 3.7:
"The requester SHOULD provide its locale information using the "xml:lang"
attribute on either the <iq/> (RECOMMENDED) or <command/> element."
- 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
let's use the standard idiom for Input- to OutputStream transfers. This
also avoids an initial no-op on the first write, when the count is '0'.
Also fixes a bug when the size of file/stream transferred is '0' (which
is perfectly fine and possible).
which is basically the body of the pingServerRunnable available as
public part of the API. The intention is to allow 3rd party
components (e.g. Android's AlarmManager) to trigger the code.