mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 04:22:05 +01:00
Small tweaks.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@6183 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
b34d338b31
commit
1f3ab16aad
4 changed files with 35 additions and 26 deletions
|
@ -445,16 +445,24 @@ public class MultiUserChat {
|
|||
|
||||
// Wait for a presence packet back from the server.
|
||||
PacketFilter responseFilter =
|
||||
new AndFilter(
|
||||
new FromMatchesFilter(room + "/" + nickname),
|
||||
new PacketTypeFilter(Presence.class));
|
||||
PacketCollector response = connection.createPacketCollector(responseFilter);
|
||||
// Send join packet.
|
||||
connection.sendPacket(joinPresence);
|
||||
// Wait up to a certain number of seconds for a reply.
|
||||
Presence presence = (Presence) response.nextResult(timeout);
|
||||
// Stop queuing results
|
||||
response.cancel();
|
||||
new AndFilter(
|
||||
new FromMatchesFilter(room + "/" + nickname),
|
||||
new PacketTypeFilter(Presence.class));
|
||||
PacketCollector response = null;
|
||||
Presence presence;
|
||||
try {
|
||||
response = connection.createPacketCollector(responseFilter);
|
||||
// Send join packet.
|
||||
connection.sendPacket(joinPresence);
|
||||
// Wait up to a certain number of seconds for a reply.
|
||||
presence = (Presence) response.nextResult(timeout);
|
||||
}
|
||||
finally {
|
||||
// Stop queuing results
|
||||
if (response != null) {
|
||||
response.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
if (presence == null) {
|
||||
throw new XMPPException("No response from server.");
|
||||
|
@ -795,6 +803,9 @@ public class MultiUserChat {
|
|||
|
||||
/**
|
||||
* Fires invitation rejection listeners.
|
||||
*
|
||||
* @param invitee the user being invited.
|
||||
* @param reason the reason for the rejection
|
||||
*/
|
||||
private void fireInvitationRejectionListeners(String invitee, String reason) {
|
||||
InvitationRejectionListener[] listeners;
|
||||
|
|
|
@ -22,10 +22,10 @@ package org.jivesoftware.smackx.packet;
|
|||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* A DiscoverInfo IQ packet, which is used by XMPP clients to request and receive information
|
||||
|
@ -38,8 +38,8 @@ import java.util.List;
|
|||
*/
|
||||
public class DiscoverInfo extends IQ {
|
||||
|
||||
private final List<Feature> features = new ArrayList<Feature>();
|
||||
private final List<Identity> identities = new ArrayList<Identity>();
|
||||
private final List<Feature> features = new CopyOnWriteArrayList<Feature>();
|
||||
private final List<Identity> identities = new CopyOnWriteArrayList<Identity>();
|
||||
private String node;
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ public class DiscoverInfo extends IQ {
|
|||
* @param feature the discovered feature
|
||||
*/
|
||||
public void addFeature(String feature) {
|
||||
addFeature(new DiscoverInfo.Feature(feature));
|
||||
addFeature(new Feature(feature));
|
||||
}
|
||||
|
||||
private void addFeature(Feature feature) {
|
||||
|
@ -64,7 +64,7 @@ public class DiscoverInfo extends IQ {
|
|||
*/
|
||||
Iterator<Feature> getFeatures() {
|
||||
synchronized (features) {
|
||||
return Collections.unmodifiableList(new ArrayList<Feature>(features)).iterator();
|
||||
return Collections.unmodifiableList(features).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ public class DiscoverInfo extends IQ {
|
|||
*/
|
||||
public Iterator<Identity> getIdentities() {
|
||||
synchronized (identities) {
|
||||
return Collections.unmodifiableList(new ArrayList<Identity>(identities)).iterator();
|
||||
return Collections.unmodifiableList(identities).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@ package org.jivesoftware.smackx.packet;
|
|||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* A DiscoverItems IQ packet, which is used by XMPP clients to request and receive items
|
||||
|
@ -38,7 +38,7 @@ import java.util.List;
|
|||
*/
|
||||
public class DiscoverItems extends IQ {
|
||||
|
||||
private final List<DiscoverItems.Item> items = new ArrayList<DiscoverItems.Item>();
|
||||
private final List<Item> items = new CopyOnWriteArrayList<Item>();
|
||||
private String node;
|
||||
|
||||
/**
|
||||
|
@ -59,8 +59,7 @@ public class DiscoverItems extends IQ {
|
|||
*/
|
||||
public Iterator<DiscoverItems.Item> getItems() {
|
||||
synchronized (items) {
|
||||
return Collections.unmodifiableList(new ArrayList<DiscoverItems.Item>(items))
|
||||
.iterator();
|
||||
return Collections.unmodifiableList(items).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,8 +99,7 @@ public class DiscoverItems extends IQ {
|
|||
}
|
||||
buf.append(">");
|
||||
synchronized (items) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Item item = items.get(i);
|
||||
for (Item item : items) {
|
||||
buf.append(item.toXML());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class DiscoverItemsProvider implements IQProvider {
|
|||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||
DiscoverItems discoverItems = new DiscoverItems();
|
||||
boolean done = false;
|
||||
DiscoverItems.Item item = null;
|
||||
DiscoverItems.Item item;
|
||||
String jid = "";
|
||||
String name = "";
|
||||
String action = "";
|
||||
|
@ -44,7 +44,7 @@ public class DiscoverItemsProvider implements IQProvider {
|
|||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
if ("item".equals(parser.getName())) {
|
||||
// Initialize the variables from the parsed XML
|
||||
jid = parser.getAttributeValue("", "jid");
|
||||
name = parser.getAttributeValue("", "name");
|
||||
|
@ -52,7 +52,7 @@ public class DiscoverItemsProvider implements IQProvider {
|
|||
action = parser.getAttributeValue("", "action");
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
if ("item".equals(parser.getName())) {
|
||||
// Create a new Item and add it to DiscoverItems.
|
||||
item = new DiscoverItems.Item(jid);
|
||||
item.setName(name);
|
||||
|
@ -60,7 +60,7 @@ public class DiscoverItemsProvider implements IQProvider {
|
|||
item.setAction(action);
|
||||
discoverItems.addItem(item);
|
||||
}
|
||||
if (parser.getName().equals("query")) {
|
||||
if ("query".equals(parser.getName())) {
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue