Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
90d6377
Fix empty SASL's <response/> element.
Feb 11, 2011
71a6517
DataForm in FileTransferNegotiator must contains field with TYPE_LIST…
Feb 28, 2011
0c06a1b
Set file size and name for outgoing file transfer from InputStream.
Mar 2, 2011
03237f7
Revert "initialize ServiceDiscovery on demand"
Mar 29, 2011
a480d98
fixing SMACK-329 http://issues.igniterealtime.org/browse/SMACK-329
Apr 14, 2011
f4d8f79
Do disco by component name
Apr 17, 2011
6a37d9e
Fix using compression
Apr 21, 2011
cb68c8e
Remove chat manager on disconnect
Apr 21, 2011
e3a7f3d
Fix NullPointerException in disconnect
Apr 21, 2011
131b812
Fix syntax error in last commit
Apr 21, 2011
084a181
Catch IllegalStateException in FileTransfer
Apr 21, 2011
44cf742
fix npe in xhtmlExtensionProvider
Apr 26, 2011
6c51b12
Pubsub's affiliations fixed.
Apr 27, 2011
870299d
Incorrect caps calculation fix ("http://jabber.org/protocol/caps" was…
Apr 27, 2011
4ff5973
Fix affiliation provider and packet extension to retrieve all affilia…
May 5, 2011
b73cf20
merge with 3.2.0
May 8, 2011
781031c
SMACK-338 this should use IBB as fallback protocol if available
May 23, 2011
64fdc34
Merge branch 'smack-aiv' into 3_2_0
May 24, 2011
a282398
Catch and log exceptions in Smack Listener Processor.
Jun 6, 2011
38cc176
Pubsub element can be inside the message stanza.
Jun 6, 2011
c2b1a2f
Fix NullPointerException in initConnection.
Jun 6, 2011
b430676
Creating a thread and never starting it will cause a memory leak.
Jun 6, 2011
44d445d
Unregister connections on connectionClosedOnError.
Jun 6, 2011
fd2d512
Use weak references to connections from managers.
Jun 6, 2011
f1e889a
Allow to add connection listener before connection was established.
Jun 6, 2011
31c700d
Don't register connection creation listener from roster.
Jun 6, 2011
6d812b4
Cache key store.
Jun 6, 2011
2310a20
Merge branch 'changes'
Jun 6, 2011
f579c5c
Subscription element can be inside http://jabber.org/protocol/pubsub#…
Jun 6, 2011
bceed8a
Some extra changes from smack 3.2.0.
Jun 6, 2011
e6f6936
Remove unused import.
Jun 7, 2011
ccdd408
Possibility to remove empty group.
Jun 30, 2011
10b3b22
Don't create roster if it is not loaded at login.
Jun 30, 2011
47dcb8d
Don't use semaphore while waiting for PacketReader to be started.
Jun 4, 2012
a7210a3
Path and password for trust store can be null.
Jun 4, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<!-- Smack Version -->
<property name="version.major" value="3" />
<property name="version.minor" value="1" />
<property name="version.minor" value="2" />
<property name="version.revision" value="0" />
<property name="version.extra" value="" />

Expand Down Expand Up @@ -98,8 +98,8 @@
destdir="${compile.dir}"
includeAntRuntime="no"
debug="on"
source="1.5"
target="1.5"
source="1.6"
target="1.6"
>
<src path="${basedir}/source" />
<classpath>
Expand All @@ -113,8 +113,8 @@
destdir="${compile.dir}/jingle/extension"
includeAntRuntime="no"
debug="on"
source="1.5"
target="1.5"
source="1.6"
target="1.6"
>
<src path="${basedir}/jingle/extension/source" />
<classpath>
Expand All @@ -141,8 +141,8 @@
destdir="${compile.test.dir}"
includeAntRuntime="no"
debug="on"
source="1.5"
target="1.5"
source="1.6"
target="1.6"
>
<src path="${test.dir}" />
<classpath>
Expand Down
24 changes: 24 additions & 0 deletions build/resources/META-INF/smack.providers
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@
<className>org.jivesoftware.smackx.pubsub.provider.PubSubProvider</className>
</iqProvider>

<extensionProvider>
<elementName>pubsub</elementName>
<namespace>http://jabber.org/protocol/pubsub</namespace>
<className>org.jivesoftware.smackx.pubsub.provider.PubSubElementProvider</className>
</extensionProvider>

<extensionProvider>
<elementName>create</elementName>
<namespace>http://jabber.org/protocol/pubsub</namespace>
Expand Down Expand Up @@ -534,12 +540,30 @@
<className>org.jivesoftware.smackx.pubsub.provider.SubscriptionProvider</className>
</extensionProvider>

<extensionProvider>
<elementName>subscription</elementName>
<namespace>http://jabber.org/protocol/pubsub#event</namespace>
<className>org.jivesoftware.smackx.pubsub.provider.SubscriptionProvider</className>
</extensionProvider>

<extensionProvider>
<elementName>affiliations</elementName>
<namespace>http://jabber.org/protocol/pubsub</namespace>
<className>org.jivesoftware.smackx.pubsub.provider.AffiliationsProvider</className>
</extensionProvider>

<extensionProvider>
<elementName>affiliations</elementName>
<namespace>http://jabber.org/protocol/pubsub#owner</namespace>
<className>org.jivesoftware.smackx.pubsub.provider.AffiliationsProvider</className>
</extensionProvider>

<extensionProvider>
<elementName>affiliation</elementName>
<namespace>http://jabber.org/protocol/pubsub#owner</namespace>
<className>org.jivesoftware.smackx.pubsub.provider.AffiliationProvider</className>
</extensionProvider>

<extensionProvider>
<elementName>affiliation</elementName>
<namespace>http://jabber.org/protocol/pubsub</namespace>
Expand Down
60 changes: 59 additions & 1 deletion build/resources/releasedocs/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,65 @@ <h1>Smack Changelog</h1>
</div>

<div id="pageBody">

<h2>3.2.0 -- <span style="font-weight: normal;">May 3, 2011</span></h2>
<h3>New Feature</h3>
<ul>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-272'>SMACK-272</a>] - Add support for pubsub (XEP-0060)</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-296'>SMACK-296</a>] - Add support for XEP-0224: Attention</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-319'>SMACK-319</a>] - Add common interfaces for SOCKS5 Bytestreams and In-Band Bytestreams</li>
</ul>

<h3>Improvement</h3>
<ul>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-137'>SMACK-137</a>] - File Transfer Settings</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-156'>SMACK-156</a>] - Add the ability to register for roster events before logging in</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-261'>SMACK-261</a>] - Minor Jingle cleanup to better support Jingle in Spark</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-277'>SMACK-277</a>] - Update XMLUnit to the latest version</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-282'>SMACK-282</a>] - Support SASL-related error conditions.</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-283'>SMACK-283</a>] - Investigate why Jingle is connecting to stun.xten.net</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-285'>SMACK-285</a>] - Add support for Nicks</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-289'>SMACK-289</a>] - There is no way of retrieving items from a pubsub node when the user has multiple subscriptions.</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-294'>SMACK-294</a>] - Handle empty roster groups and no goups in the same way</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-295'>SMACK-295</a>] - Fire reconnectionSuccessful event when session is established</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-297'>SMACK-297</a>] - add configuration for local Socks5 proxy</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-298'>SMACK-298</a>] - Respond to all incoming Socks5 bytestream requests</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-299'>SMACK-299</a>] - Improve accepting of Socks5 bytestream requests</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-300'>SMACK-300</a>] - improve local Socks5 proxy implemetation</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-301'>SMACK-301</a>] - support for bytestream packets to query Socks5 proxy for network address</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-302'>SMACK-302</a>] - Improve establishing of Socks5 bytestreams</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-303'>SMACK-303</a>] - integrate of the extracted Socks5 bytestream API in file transfer API</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-304'>SMACK-304</a>] - Extend the IQ API to create empty IQ results and IQ error response packets</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-307'>SMACK-307</a>] - Improve Message Parser Robustness and Message Body I18N</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-309'>SMACK-309</a>] - Fully implement XEP-0047 In-Band Bytestreams</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-310'>SMACK-310</a>] - Add Support for Localized Message Subjects</li>
</ul>

<h3>Bug</h3>
<ul>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-163'>SMACK-163</a>] - Fix NPE in RoomInfo when subject has not value</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-207'>SMACK-207</a>] - Parsing of messages may disconnect Smack/Spark</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-225'>SMACK-225</a>] - Improper handeling of DNS SRV records</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-232'>SMACK-232</a>] - Better handling of Roster error</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-243'>SMACK-243</a>] - Packet with wrong date format makes Smack to disconnect</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-264'>SMACK-264</a>] - fix for NPE in SASLMechanism.java</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-269'>SMACK-269</a>] - Smack 3.1.0 creates a new chat for every incoming message</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-271'>SMACK-271</a>] - Deadlock in XMPPConnection while login and parsing stream features</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-275'>SMACK-275</a>] - Patch: Fix for broken SASL DIGEST-MD5 implementation</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-280'>SMACK-280</a>] - The authentification should use the Connection#sendPacket method and work transparent with packets and packet listeners.</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-288'>SMACK-288</a>] - The parsing of the result for a LeafNode.getItems() call is incorrect. It creates a DefaultPacketExtension instead of an Item for every other item in the result.</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-290'>SMACK-290</a>] - Deadlock while getting Roster before it&#39;s initialized</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-291'>SMACK-291</a>] - RosterGroup modifications should depend on roster push</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-293'>SMACK-293</a>] - Support optional roster subscription attribute</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-305'>SMACK-305</a>] - RosterEntry#getGroups causing a roster reload</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-308'>SMACK-308</a>] - Multiple errors in pubsub GetItemsRequest</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-312'>SMACK-312</a>] - Only fire RosterListener#entriesUpdated for RosterEntries that changed</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-327'>SMACK-327</a>] - getFeatures() method on DiscoverInfo is improperly set to be package protected instead of public</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-328'>SMACK-328</a>] - Number format exception while parsing dates.</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-332'>SMACK-332</a>] - Smack 3.2.0b2 shows wrong version in Smack Dubugger Window</li>
<li>[<a href='http://issues.igniterealtime.org/browse/SMACK-334'>SMACK-334</a>] - Error in form for FileTransferNegotiator</li>
</ul>

<h2>3.1.0 -- <span style="font-weight: normal;">November 20, 2008</span></h2>

<h3>New Features</h3>
Expand Down Expand Up @@ -333,4 +391,4 @@ <h2>2.2.0 -- <span style="font-weight: normal;">March 9, 2006</span></h2>
</div>

</body>
</html>
</html>
34 changes: 34 additions & 0 deletions documentation/messaging.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,40 @@
}
</pre>
</div>

<p class="subheader">
Incoming Chat
</p>

When chats are prompted by another user, the setup is slightly different since
you are receiving a chat message first. Instead of explicitly creating a chat to send
messages, you need to register to handle newly created Chat instances when the ChatManager
creates them.
</br>
</br>
The ChatManager will already find a matching chat (by thread id) and if none exists, then it
will create a new one that does match. To get this new chat, you have to register to be
notified when it happens. You can register a message listener to receive all future messages as
part of this handler.<p>

<div class="code"><pre><font color="gray"><i>// Assume we've created a Connection name "connection".</i></font>
ChatManager chatmanager = connection.getChatManager().addChatListener(
new ChatManagerListener() {
@Override
public void chatCreated(Chat chat, boolean createdLocally)
{
if (!createdLocally)
chat.addMessageListener(new MyNewMessageListener());;
}
});
</pre>
</div>
In addition to thread based chat messages, there are some clients that
do not send a thread id as part of the chat. To handle this scenario,
Smack will attempt match the incoming messages to the best fit existing
chat, based on the JID. It will attempt to find a chat with the same full
JID, failing that, it will try the base JID. If no existing chat to the
user can found, then a new one is created.
<p>

<br clear="all"/><br><br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ public class STUNResolver extends TransportResolver {
// The filename where the STUN servers are stored.
public final static String STUNSERVERS_FILENAME = "META-INF/stun-config.xml";

// Fallback values when we don't have any STUN server to use...
private final static String FALLBACKHOSTNAME = "stun.xten.net";

private final static int FALLBACKHOSTPORT = 3478;

// Current STUN server we are using
protected STUNService currentServer;

Expand Down Expand Up @@ -189,10 +184,10 @@ public ArrayList loadSTUNServers(java.io.InputStream stunConfigStream) {

}
catch (XmlPullParserException e) {
e.printStackTrace();
LOGGER.error(e.getMessage(), e);
}
catch (IOException e) {
e.printStackTrace();
LOGGER.error(e.getMessage(), e);
}

currentServer = bestSTUNServer(serversList);
Expand Down Expand Up @@ -247,13 +242,7 @@ public ArrayList loadSTUNServers() {
}
}
catch (Exception e) {
e.printStackTrace();
}

// If the list of candidates is empty, add at least one default server
if (serversList.isEmpty()) {
currentServer = new STUNService(FALLBACKHOSTNAME, FALLBACKHOSTPORT);
serversList.add(currentServer);
LOGGER.error(e.getMessage(), e);
}

return serversList;
Expand Down Expand Up @@ -370,14 +359,14 @@ public void run() {
}
}
catch (Exception e) {
e.printStackTrace();
LOGGER.error(e.getMessage(), e);
}
}
}
}
}
catch (SocketException e) {
e.printStackTrace();
LOGGER.error(e.getMessage(), e);
}
finally {
setInitialized();
Expand Down Expand Up @@ -524,7 +513,7 @@ public boolean checkBinding() {
}
}
catch (Exception e) {
e.printStackTrace();
LOGGER.error(e.getMessage(), e);
}

return result;
Expand Down
29 changes: 15 additions & 14 deletions source/org/jivesoftware/smack/AccountManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ public Collection<String> getAccountAttributes() {
if (info == null) {
getRegistrationInfo();
}
List<String> attributes = info.getRequiredFields();
if (attributes.size()>0) {
HashSet<String> set = new HashSet<String>(attributes);
return Collections.unmodifiableSet(set);
Map<String, String> attributes = info.getAttributes();
if (attributes != null) {
return Collections.unmodifiableSet(attributes.keySet());
}
}
catch (XMPPException xe) {
Expand Down Expand Up @@ -226,12 +225,10 @@ public void createAccount(String username, String password, Map<String, String>
}
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(connection.getServiceName());
for(String s : attributes.keySet()){
reg.addAttribute(s, attributes.get(s));
}
reg.setUsername(username);
reg.setPassword(password);
reg.setTo(connection.getServiceName());
attributes.put("username",username);
attributes.put("password",password);
reg.setAttributes(attributes);
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
new PacketTypeFilter(IQ.class));
PacketCollector collector = connection.createPacketCollector(filter);
Expand Down Expand Up @@ -259,8 +256,10 @@ public void changePassword(String newPassword) throws XMPPException {
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(connection.getServiceName());
reg.setUsername(StringUtils.parseName(connection.getUser()));
reg.setPassword(newPassword);
Map<String, String> map = new HashMap<String, String>();
map.put("username",StringUtils.parseName(connection.getUser()));
map.put("password",newPassword);
reg.setAttributes(map);
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
new PacketTypeFilter(IQ.class));
PacketCollector collector = connection.createPacketCollector(filter);
Expand Down Expand Up @@ -291,8 +290,10 @@ public void deleteAccount() throws XMPPException {
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(connection.getServiceName());
// To delete an account, we set remove to true
reg.setRemove(true);
Map<String, String> attributes = new HashMap<String, String>();
// To delete an account, we add a single attribute, "remove", that is blank.
attributes.put("remove", "");
reg.setAttributes(attributes);
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
new PacketTypeFilter(IQ.class));
PacketCollector collector = connection.createPacketCollector(filter);
Expand Down
37 changes: 32 additions & 5 deletions source/org/jivesoftware/smack/ChatManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@

package org.jivesoftware.smack;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import java.util.concurrent.CopyOnWriteArraySet;

import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.FromContainsFilter;
import org.jivesoftware.smack.filter.PacketFilter;
Expand Down Expand Up @@ -65,14 +72,20 @@ private static synchronized String nextID() {
/**
* Maps thread ID to chat.
*/
private Map<String, Chat> threadChats = new ReferenceMap<String, Chat>(ReferenceMap.HARD,
ReferenceMap.WEAK);
private Map<String, Chat> threadChats = Collections.synchronizedMap(new ReferenceMap<String, Chat>(ReferenceMap.HARD,
ReferenceMap.WEAK));

/**
* Maps jids to chats
*/
private Map<String, Chat> jidChats = new ReferenceMap<String, Chat>(ReferenceMap.HARD,
ReferenceMap.WEAK);
private Map<String, Chat> jidChats = Collections.synchronizedMap(new ReferenceMap<String, Chat>(ReferenceMap.HARD,
ReferenceMap.WEAK));

/**
* Maps base jids to chats
*/
private Map<String, Chat> baseJidChats = Collections.synchronizedMap(new ReferenceMap<String, Chat>(ReferenceMap.HARD,
ReferenceMap.WEAK));

private Set<ChatManagerListener> chatManagerListeners
= new CopyOnWriteArraySet<ChatManagerListener>();
Expand Down Expand Up @@ -161,6 +174,7 @@ private Chat createChat(String userJID, String threadID, boolean createdLocally)
Chat chat = new Chat(this, userJID, threadID);
threadChats.put(threadID, chat);
jidChats.put(userJID, chat);
baseJidChats.put(StringUtils.parseBareAddress(userJID), chat);

for(ChatManagerListener listener : chatManagerListeners) {
listener.chatCreated(chat, createdLocally);
Expand All @@ -179,8 +193,21 @@ private Chat createChat(Message message) {
return createChat(userJID, threadID, false);
}

/**
* Try to get a matching chat for the given user JID. Try the full
* JID map first, the try to match on the base JID if no match is
* found.
*
* @param userJID
* @return
*/
private Chat getUserChat(String userJID) {
return jidChats.get(userJID);
Chat match = jidChats.get(userJID);

if (match == null) {
match = baseJidChats.get(StringUtils.parseBareAddress(userJID));
}
return match;
}

public Chat getThreadChat(String thread) {
Expand Down
Loading