1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-30 02:02:06 +01:00

Rolling back some JID escaping work related to SMACK-170.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@5384 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2006-09-15 22:42:06 +00:00 committed by gato
parent 6be93f4a4e
commit e65ecdc913
8 changed files with 186 additions and 233 deletions

View file

@ -40,10 +40,10 @@ import java.lang.reflect.Method;
import java.net.Socket; import java.net.Socket;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArraySet;
/** /**
* Creates a connection to a XMPP server. A simple use of this API might * Creates a connection to a XMPP server. A simple use of this API might
@ -89,8 +89,8 @@ public class XMPPConnection {
*/ */
public static boolean DEBUG_ENABLED = false; public static boolean DEBUG_ENABLED = false;
private final static List<ConnectionEstablishedListener> connectionEstablishedListeners = private final static Set<ConnectionEstablishedListener> connectionEstablishedListeners =
new CopyOnWriteArrayList<ConnectionEstablishedListener>(); new CopyOnWriteArraySet<ConnectionEstablishedListener>();
static { static {
// Use try block since we may not have permission to get a system // Use try block since we may not have permission to get a system
@ -167,7 +167,7 @@ public class XMPPConnection {
* Holds the initial configuration used while creating the connection. * Holds the initial configuration used while creating the connection.
*/ */
private ConnectionConfiguration configuration; private ConnectionConfiguration configuration;
/** /**
* Creates a new connection to the specified XMPP server. A DNS SRV lookup will be * Creates a new connection to the specified XMPP server. A DNS SRV lookup will be
* performed to try to determine the IP address and port corresponding to the * performed to try to determine the IP address and port corresponding to the
@ -396,7 +396,6 @@ public class XMPPConnection {
} }
// Do partial version of nameprep on the username. // Do partial version of nameprep on the username.
username = username.toLowerCase().trim(); username = username.toLowerCase().trim();
username = StringUtils.escapeNode(username);
String response; String response;
if (configuration.isSASLAuthenticationEnabled() && if (configuration.isSASLAuthenticationEnabled() &&
@ -437,14 +436,14 @@ public class XMPPConnection {
if (sendPresence) { if (sendPresence) {
packetWriter.sendPacket(new Presence(Presence.Type.available)); packetWriter.sendPacket(new Presence(Presence.Type.available));
} }
// Indicate that we're now authenticated. // Indicate that we're now authenticated.
authenticated = true; authenticated = true;
anonymous = false; anonymous = false;
// Stores the autentication for future reconnection // Stores the autentication for future reconnection
this.getConfiguration().setUsernameAndPassword(username, password); this.getConfiguration().setUsernameAndPassword(username, password);
// If debugging is enabled, change the the debug window title to include the // If debugging is enabled, change the the debug window title to include the
// name we are now logged-in as. // name we are now logged-in as.
// If DEBUG_ENABLED was set to true AFTER the connection was created the debugger // If DEBUG_ENABLED was set to true AFTER the connection was created the debugger
@ -654,30 +653,30 @@ public class XMPPConnection {
catch (Exception e) { catch (Exception e) {
// Ignore. // Ignore.
} }
this.setWasAuthenticated(authenticated); this.setWasAuthenticated(authenticated);
authenticated = false; authenticated = false;
connected = false; connected = false;
saslAuthentication.init(); saslAuthentication.init();
} }
/** /**
* Closes the connection by setting presence to unavailable then closing the stream to * Closes the connection by setting presence to unavailable then closing the stream to
* the XMPP server. The XMPPConnection can still be used for connecting to the server * the XMPP server. The XMPPConnection can still be used for connecting to the server
* again. * again.
* *
* The difference between disconnect and shutdown is that disconnect makes a complete reset * The difference between disconnect and shutdown is that disconnect makes a complete reset
* of the connection state whereas shutdown only cleans the connection and keeps alive * of the connection state whereas shutdown only cleans the connection and keeps alive
* packet reader listeners, previous login and roster presences. * packet reader listeners, previous login and roster presences.
*/ */
public void disconnect() { public void disconnect() {
this.shutdown(); this.shutdown();
this.roster = null; this.roster = null;
this.wasAuthenticated = false; this.wasAuthenticated = false;
packetWriter = null; packetWriter = null;
packetReader = null; packetReader = null;
} }
@ -819,9 +818,7 @@ public class XMPPConnection {
* @param connectionEstablishedListener a listener interested on connection established events. * @param connectionEstablishedListener a listener interested on connection established events.
*/ */
public static void addConnectionEstablishedListener(ConnectionEstablishedListener connectionEstablishedListener) { public static void addConnectionEstablishedListener(ConnectionEstablishedListener connectionEstablishedListener) {
if (!connectionEstablishedListeners.contains(connectionEstablishedListener)) { connectionEstablishedListeners.add(connectionEstablishedListener);
connectionEstablishedListeners.add(connectionEstablishedListener);
}
} }
/** /**
@ -878,7 +875,7 @@ public class XMPPConnection {
// Do nothing // Do nothing
} }
} }
/** /**
* Initializes the connection by creating a packet reader and writer and opening a * Initializes the connection by creating a packet reader and writer and opening a
* XMPP stream to the server. * XMPP stream to the server.
@ -1317,14 +1314,14 @@ public class XMPPConnection {
this.notify(); this.notify();
} }
} }
/** /**
* Establishes a connection to the XMPP server and performs an automatic login * Establishes a connection to the XMPP server and performs an automatic login
* only if the previous connection state was logged (authenticated). It basically * only if the previous connection state was logged (authenticated). It basically
* creates and maintains a socket connection to the server.<p> * creates and maintains a socket connection to the server.<p>
* *
* Listeners will be preserved from a previous connection if the reconnection * Listeners will be preserved from a previous connection if the reconnection
* occurs after an abrupt termination. * occurs after an abrupt termination.
* *
* @throws XMPPException if an error occurs while trying to establish the connection. * @throws XMPPException if an error occurs while trying to establish the connection.
* Two possible errors can occur which will be wrapped by an XMPPException -- * Two possible errors can occur which will be wrapped by an XMPPException --
* UnknownHostException (XMPP error code 504), and IOException (XMPP error code * UnknownHostException (XMPP error code 504), and IOException (XMPP error code
@ -1350,10 +1347,10 @@ public class XMPPConnection {
} }
} }
} }
/** /**
* Sets whether the connection has already logged in the server. * Sets whether the connection has already logged in the server.
* *
* @param wasAuthenticated true if the connection has already been authenticated. * @param wasAuthenticated true if the connection has already been authenticated.
*/ */
private void setWasAuthenticated(boolean wasAuthenticated) { private void setWasAuthenticated(boolean wasAuthenticated) {

View file

@ -43,7 +43,7 @@ public abstract class Packet {
/** /**
* Constant used as packetID to indicate that a packet has no id. To indicate that a packet * Constant used as packetID to indicate that a packet has no id. To indicate that a packet
* has no id set this constant as the packet's id. When the packet is asked for its id the * has no id set this constant as the packet's id. When the packet is asked for its id the
* answer will be <tt>null</tt>. * answer will be <tt>null</tt>.
*/ */
public static final String ID_NOT_AVAILABLE = "ID_NOT_AVAILABLE"; public static final String ID_NOT_AVAILABLE = "ID_NOT_AVAILABLE";
@ -86,7 +86,7 @@ public abstract class Packet {
if (ID_NOT_AVAILABLE.equals(packetID)) { if (ID_NOT_AVAILABLE.equals(packetID)) {
return null; return null;
} }
if (packetID == null) { if (packetID == null) {
packetID = nextID(); packetID = nextID();
} }
@ -94,7 +94,7 @@ public abstract class Packet {
} }
/** /**
* Sets the unique ID of the packet. To indicate that a packet has no id * Sets the unique ID of the packet. To indicate that a packet has no id
* pass the constant ID_NOT_AVAILABLE as the packet's id value. * pass the constant ID_NOT_AVAILABLE as the packet's id value.
* *
* @param packetID the unique ID for the packet. * @param packetID the unique ID for the packet.
@ -122,8 +122,7 @@ public abstract class Packet {
* @param to who the packet is being sent to. * @param to who the packet is being sent to.
*/ */
public void setTo(String to) { public void setTo(String to) {
// Use escaped version of the JID in case the user included invalid characters. this.to = to;
this.to = StringUtils.escapeJID(to);
} }
/** /**
@ -146,8 +145,7 @@ public abstract class Packet {
* @param from who the packet is being sent to. * @param from who the packet is being sent to.
*/ */
public void setFrom(String from) { public void setFrom(String from) {
// Use escaped version of the JID in case the user included invalid characters. this.from = from;
this.from = StringUtils.escapeJID(from);
} }
/** /**

View file

@ -198,7 +198,7 @@ public class RosterPacket extends IQ {
public String toXML() { public String toXML() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("<item jid=\"").append(StringUtils.escapeJID(user)).append("\""); buf.append("<item jid=\"").append(user).append("\"");
if (name != null) { if (name != null) {
buf.append(" name=\"").append(StringUtils.escapeForXML(name)).append("\""); buf.append(" name=\"").append(StringUtils.escapeForXML(name)).append("\"");
} }

View file

@ -47,7 +47,7 @@ public class StringUtils {
if (XMPPAddress == null) { if (XMPPAddress == null) {
return null; return null;
} }
int atIndex = XMPPAddress.lastIndexOf("@"); int atIndex = XMPPAddress.indexOf("@");
if (atIndex <= 0) { if (atIndex <= 0) {
return ""; return "";
} }
@ -68,7 +68,7 @@ public class StringUtils {
if (XMPPAddress == null) { if (XMPPAddress == null) {
return null; return null;
} }
int atIndex = XMPPAddress.lastIndexOf("@"); int atIndex = XMPPAddress.indexOf("@");
// If the String ends with '@', return the empty string. // If the String ends with '@', return the empty string.
if (atIndex + 1 > XMPPAddress.length()) { if (atIndex + 1 > XMPPAddress.length()) {
return ""; return "";
@ -127,8 +127,6 @@ public class StringUtils {
} }
} }
/** /**
* Escapes the node portion of a JID according to "JID Escaping" (JEP-0106). * Escapes the node portion of a JID according to "JID Escaping" (JEP-0106).
* Escaping replaces characters prohibited by node-prep with escape sequences, * Escaping replaces characters prohibited by node-prep with escape sequences,
@ -168,9 +166,15 @@ public class StringUtils {
for (int i=0, n=node.length(); i<n; i++) { for (int i=0, n=node.length(); i<n; i++) {
char c = node.charAt(i); char c = node.charAt(i);
switch (c) { switch (c) {
case '"': buf.append("\\22"); break;
case '&': buf.append("\\26"); break;
case '\'': buf.append("\\27"); break;
case '/': buf.append("\\2f"); break;
case ':': buf.append("\\3a"); break;
case '<': buf.append("\\3c"); break;
case '>': buf.append("\\3e"); break;
case '@': buf.append("\\40"); break; case '@': buf.append("\\40"); break;
case '\\': buf.append("\\5c"); break;
default: { default: {
if (Character.isWhitespace(c)) { if (Character.isWhitespace(c)) {
buf.append("\\20"); buf.append("\\20");
@ -184,43 +188,6 @@ public class StringUtils {
return buf.toString(); return buf.toString();
} }
/**
* Escapes a complete JID by examing the Node itself and escaping
* when neccessary.
* @param jid the users JID
* @return the escaped JID.
*/
public static String escapeJID(String jid){
if(jid == null){
return null;
}
final StringBuilder builder = new StringBuilder();
String node = parseName(jid);
String restOfJID = jid.substring(node.length());
builder.append(escapeNode(node));
builder.append(restOfJID);
return builder.toString();
}
/**
* Unescapes a complete JID by examing the node itself and unescaping when necessary.
* @param jid the users jid.
* @return the unescaped JID.
*/
public static String unescapeJID(String jid){
if(jid == null){
return null;
}
final StringBuilder builder = new StringBuilder();
String node = parseName(jid);
String restOfJID = jid.substring(node.length());
builder.append(unescapeNode(node));
builder.append(restOfJID);
return builder.toString();
}
/** /**
* Un-escapes the node portion of a JID according to "JID Escaping" (JEP-0106).<p> * Un-escapes the node portion of a JID according to "JID Escaping" (JEP-0106).<p>
* Escaping replaces characters prohibited by node-prep with escape sequences, * Escaping replaces characters prohibited by node-prep with escape sequences,

View file

@ -20,8 +20,6 @@
package org.jivesoftware.smackx; package org.jivesoftware.smackx;
import org.jivesoftware.smack.util.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
@ -31,7 +29,7 @@ import java.util.List;
* Represents a field of a form. The field could be used to represent a question to complete, * Represents a field of a form. The field could be used to represent a question to complete,
* a completed question or a data returned from a search. The exact interpretation of the field * a completed question or a data returned from a search. The exact interpretation of the field
* depends on the context where the field is used. * depends on the context where the field is used.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public class FormField { public class FormField {
@ -55,31 +53,31 @@ public class FormField {
private final List<String> values = new ArrayList<String>(); private final List<String> values = new ArrayList<String>();
/** /**
* Creates a new FormField with the variable name that uniquely identifies the field * Creates a new FormField with the variable name that uniquely identifies the field
* in the context of the form. * in the context of the form.
* *
* @param variable the variable name of the question. * @param variable the variable name of the question.
*/ */
public FormField(String variable) { public FormField(String variable) {
this.variable = variable; this.variable = variable;
} }
/** /**
* Creates a new FormField of type FIXED. The fields of type FIXED do not define a variable * Creates a new FormField of type FIXED. The fields of type FIXED do not define a variable
* name. * name.
* *
*/ */
public FormField() { public FormField() {
this.type = FormField.TYPE_FIXED; this.type = FormField.TYPE_FIXED;
} }
/** /**
* Returns a description that provides extra clarification about the question. This information * Returns a description that provides extra clarification about the question. This information
* could be presented to the user either in tool-tip, help button, or as a section of text * could be presented to the user either in tool-tip, help button, or as a section of text
* before the question.<p> * before the question.<p>
* *
* If the question is of type FIXED then the description should remain empty. * If the question is of type FIXED then the description should remain empty.
* *
* @return description that provides extra clarification about the question. * @return description that provides extra clarification about the question.
*/ */
public String getDescription() { public String getDescription() {
@ -87,9 +85,9 @@ public class FormField {
} }
/** /**
* Returns the label of the question which should give enough information to the user to * Returns the label of the question which should give enough information to the user to
* fill out the form. * fill out the form.
* *
* @return label of the question. * @return label of the question.
*/ */
public String getLabel() { public String getLabel() {
@ -98,9 +96,9 @@ public class FormField {
/** /**
* Returns an Iterator for the available options that the user has in order to answer * Returns an Iterator for the available options that the user has in order to answer
* the question. * the question.
* *
* @return Iterator for the available options. * @return Iterator for the available options.
*/ */
public Iterator<Option> getOptions() { public Iterator<Option> getOptions() {
synchronized (options) { synchronized (options) {
@ -110,7 +108,7 @@ public class FormField {
/** /**
* Returns true if the question must be answered in order to complete the questionnaire. * Returns true if the question must be answered in order to complete the questionnaire.
* *
* @return true if the question must be answered in order to complete the questionnaire. * @return true if the question must be answered in order to complete the questionnaire.
*/ */
public boolean isRequired() { public boolean isRequired() {
@ -119,23 +117,23 @@ public class FormField {
/** /**
* Returns an indicative of the format for the data to answer. Valid formats are: * Returns an indicative of the format for the data to answer. Valid formats are:
* *
* <ul> * <ul>
* <li>text-single -> single line or word of text * <li>text-single -> single line or word of text
* <li>text-private -> instead of showing the user what they typed, you show ***** to * <li>text-private -> instead of showing the user what they typed, you show ***** to
* protect it * protect it
* <li>text-multi -> multiple lines of text entry * <li>text-multi -> multiple lines of text entry
* <li>list-single -> given a list of choices, pick one * <li>list-single -> given a list of choices, pick one
* <li>list-multi -> given a list of choices, pick one or more * <li>list-multi -> given a list of choices, pick one or more
* <li>boolean -> 0 or 1, true or false, yes or no. Default value is 0 * <li>boolean -> 0 or 1, true or false, yes or no. Default value is 0
* <li>fixed -> fixed for putting in text to show sections, or just advertise your web * <li>fixed -> fixed for putting in text to show sections, or just advertise your web
* site in the middle of the form * site in the middle of the form
* <li>hidden -> is not given to the user at all, but returned with the questionnaire * <li>hidden -> is not given to the user at all, but returned with the questionnaire
* <li>jid-single -> Jabber ID - choosing a JID from your roster, and entering one based * <li>jid-single -> Jabber ID - choosing a JID from your roster, and entering one based
* on the rules for a JID. * on the rules for a JID.
* <li>jid-multi -> multiple entries for JIDs * <li>jid-multi -> multiple entries for JIDs
* </ul> * </ul>
* *
* @return format for the data to answer. * @return format for the data to answer.
*/ */
public String getType() { public String getType() {
@ -144,10 +142,10 @@ public class FormField {
/** /**
* Returns an Iterator for the default values of the question if the question is part * Returns an Iterator for the default values of the question if the question is part
* of a form to fill out. Otherwise, returns an Iterator for the answered values of * of a form to fill out. Otherwise, returns an Iterator for the answered values of
* the question. * the question.
* *
* @return an Iterator for the default values or answered values of the question. * @return an Iterator for the default values or answered values of the question.
*/ */
public Iterator<String> getValues() { public Iterator<String> getValues() {
synchronized (values) { synchronized (values) {
@ -157,7 +155,7 @@ public class FormField {
/** /**
* Returns the variable name that the question is filling out. * Returns the variable name that the question is filling out.
* *
* @return the variable name of the question. * @return the variable name of the question.
*/ */
public String getVariable() { public String getVariable() {
@ -166,11 +164,11 @@ public class FormField {
/** /**
* Sets a description that provides extra clarification about the question. This information * Sets a description that provides extra clarification about the question. This information
* could be presented to the user either in tool-tip, help button, or as a section of text * could be presented to the user either in tool-tip, help button, or as a section of text
* before the question.<p> * before the question.<p>
* *
* If the question is of type FIXED then the description should remain empty. * If the question is of type FIXED then the description should remain empty.
* *
* @param description provides extra clarification about the question. * @param description provides extra clarification about the question.
*/ */
public void setDescription(String description) { public void setDescription(String description) {
@ -178,9 +176,9 @@ public class FormField {
} }
/** /**
* Sets the label of the question which should give enough information to the user to * Sets the label of the question which should give enough information to the user to
* fill out the form. * fill out the form.
* *
* @param label the label of the question. * @param label the label of the question.
*/ */
public void setLabel(String label) { public void setLabel(String label) {
@ -189,7 +187,7 @@ public class FormField {
/** /**
* Sets if the question must be answered in order to complete the questionnaire. * Sets if the question must be answered in order to complete the questionnaire.
* *
* @param required if the question must be answered in order to complete the questionnaire. * @param required if the question must be answered in order to complete the questionnaire.
*/ */
public void setRequired(boolean required) { public void setRequired(boolean required) {
@ -198,23 +196,23 @@ public class FormField {
/** /**
* Sets an indicative of the format for the data to answer. Valid formats are: * Sets an indicative of the format for the data to answer. Valid formats are:
* *
* <ul> * <ul>
* <li>text-single -> single line or word of text * <li>text-single -> single line or word of text
* <li>text-private -> instead of showing the user what they typed, you show ***** to * <li>text-private -> instead of showing the user what they typed, you show ***** to
* protect it * protect it
* <li>text-multi -> multiple lines of text entry * <li>text-multi -> multiple lines of text entry
* <li>list-single -> given a list of choices, pick one * <li>list-single -> given a list of choices, pick one
* <li>list-multi -> given a list of choices, pick one or more * <li>list-multi -> given a list of choices, pick one or more
* <li>boolean -> 0 or 1, true or false, yes or no. Default value is 0 * <li>boolean -> 0 or 1, true or false, yes or no. Default value is 0
* <li>fixed -> fixed for putting in text to show sections, or just advertise your web * <li>fixed -> fixed for putting in text to show sections, or just advertise your web
* site in the middle of the form * site in the middle of the form
* <li>hidden -> is not given to the user at all, but returned with the questionnaire * <li>hidden -> is not given to the user at all, but returned with the questionnaire
* <li>jid-single -> Jabber ID - choosing a JID from your roster, and entering one based * <li>jid-single -> Jabber ID - choosing a JID from your roster, and entering one based
* on the rules for a JID. * on the rules for a JID.
* <li>jid-multi -> multiple entries for JIDs * <li>jid-multi -> multiple entries for JIDs
* </ul> * </ul>
* *
* @param type an indicative of the format for the data to answer. * @param type an indicative of the format for the data to answer.
*/ */
public void setType(String type) { public void setType(String type) {
@ -222,9 +220,9 @@ public class FormField {
} }
/** /**
* Adds a default value to the question if the question is part of a form to fill out. * Adds a default value to the question if the question is part of a form to fill out.
* Otherwise, adds an answered value to the question. * Otherwise, adds an answered value to the question.
* *
* @param value a default value or an answered value of the question. * @param value a default value or an answered value of the question.
*/ */
public void addValue(String value) { public void addValue(String value) {
@ -234,9 +232,9 @@ public class FormField {
} }
/** /**
* Adds a default values to the question if the question is part of a form to fill out. * Adds a default values to the question if the question is part of a form to fill out.
* Otherwise, adds an answered values to the question. * Otherwise, adds an answered values to the question.
* *
* @param newValues default values or an answered values of the question. * @param newValues default values or an answered values of the question.
*/ */
public void addValues(List<String> newValues) { public void addValues(List<String> newValues) {
@ -254,11 +252,11 @@ public class FormField {
values.removeAll(new ArrayList<String>(values)); values.removeAll(new ArrayList<String>(values));
} }
} }
/** /**
* Adss an available options to the question that the user has in order to answer * Adss an available options to the question that the user has in order to answer
* the question. * the question.
* *
* @param option a new available option for the question. * @param option a new available option for the question.
*/ */
public void addOption(Option option) { public void addOption(Option option) {
@ -290,7 +288,7 @@ public class FormField {
} }
// Loop through all the values and append them to the string buffer // Loop through all the values and append them to the string buffer
for (Iterator<String> i = getValues(); i.hasNext();) { for (Iterator<String> i = getValues(); i.hasNext();) {
buf.append("<value>").append(StringUtils.escapeForXML(i.next())).append("</value>"); buf.append("<value>").append(i.next()).append("</value>");
} }
// Loop through all the values and append them to the string buffer // Loop through all the values and append them to the string buffer
for (Iterator i = getOptions(); i.hasNext();) { for (Iterator i = getOptions(); i.hasNext();) {

View file

@ -20,15 +20,13 @@
package org.jivesoftware.smackx; package org.jivesoftware.smackx;
import org.jivesoftware.smack.util.StringUtils;
import java.util.*; import java.util.*;
/** /**
* Represents a roster item, which consists of a JID and , their name and * Represents a roster item, which consists of a JID and , their name and
* the groups the roster item belongs to. This roster item does not belong * the groups the roster item belongs to. This roster item does not belong
* to the local roster. Therefore, it does not persist in the server.<p> * to the local roster. Therefore, it does not persist in the server.<p>
* *
* The idea of a RemoteRosterEntry is to be used as part of a roster exchange. * The idea of a RemoteRosterEntry is to be used as part of a roster exchange.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
@ -37,7 +35,7 @@ public class RemoteRosterEntry {
private String user; private String user;
private String name; private String name;
private List groupNames = new ArrayList(); private final List<String> groupNames = new ArrayList<String>();
/** /**
* Creates a new remote roster entry. * Creates a new remote roster entry.
@ -51,7 +49,7 @@ public class RemoteRosterEntry {
this.user = user; this.user = user;
this.name = name; this.name = name;
if (groups != null) { if (groups != null) {
groupNames = new ArrayList(Arrays.asList(groups)); groupNames.addAll(Arrays.asList(groups));
} }
} }
@ -93,23 +91,19 @@ public class RemoteRosterEntry {
*/ */
public String[] getGroupArrayNames() { public String[] getGroupArrayNames() {
synchronized (groupNames) { synchronized (groupNames) {
return (String[]) return Collections.unmodifiableList(groupNames).toArray(new String[groupNames.size()]);
(Collections
.unmodifiableList(groupNames)
.toArray(new String[groupNames.size()]));
} }
} }
public String toXML() { public String toXML() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("<item jid=\"").append(StringUtils.escapeJID(user)).append("\""); buf.append("<item jid=\"").append(user).append("\"");
if (name != null) { if (name != null) {
buf.append(" name=\"").append(name).append("\""); buf.append(" name=\"").append(name).append("\"");
} }
buf.append(">"); buf.append(">");
synchronized (groupNames) { synchronized (groupNames) {
for (int i = 0; i < groupNames.size(); i++) { for (String groupName : groupNames) {
String groupName = (String) groupNames.get(i);
buf.append("<group>").append(groupName).append("</group>"); buf.append("<group>").append(groupName).append("</group>");
} }
} }

View file

@ -21,12 +21,11 @@
package org.jivesoftware.smackx.packet; package org.jivesoftware.smackx.packet;
import org.jivesoftware.smack.packet.PacketExtension; import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.util.StringUtils;
/** /**
* Represents extended presence information about roles, affiliations, full JIDs, * Represents extended presence information about roles, affiliations, full JIDs,
* or status codes scoped by the 'http://jabber.org/protocol/muc#user' namespace. * or status codes scoped by the 'http://jabber.org/protocol/muc#user' namespace.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public class MUCUser implements PacketExtension { public class MUCUser implements PacketExtension {
@ -76,7 +75,7 @@ public class MUCUser implements PacketExtension {
* Returns the invitation for another user to a room. The sender of the invitation * Returns the invitation for another user to a room. The sender of the invitation
* must be an occupant of the room. The invitation will be sent to the room which in turn * must be an occupant of the room. The invitation will be sent to the room which in turn
* will forward the invitation to the invitee. * will forward the invitation to the invitee.
* *
* @return an invitation for another user to a room. * @return an invitation for another user to a room.
*/ */
public Invite getInvite() { public Invite getInvite() {
@ -84,9 +83,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Returns the rejection to an invitation from another user to a room. The rejection will be * Returns the rejection to an invitation from another user to a room. The rejection will be
* sent to the room which in turn will forward the refusal to the inviter. * sent to the room which in turn will forward the refusal to the inviter.
* *
* @return a rejection to an invitation from another user to a room. * @return a rejection to an invitation from another user to a room.
*/ */
public Decline getDecline() { public Decline getDecline() {
@ -95,7 +94,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the item child that holds information about roles, affiliation, jids and nicks. * Returns the item child that holds information about roles, affiliation, jids and nicks.
* *
* @return an item child that holds information about roles, affiliation, jids and nicks. * @return an item child that holds information about roles, affiliation, jids and nicks.
*/ */
public Item getItem() { public Item getItem() {
@ -103,9 +102,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Returns the password to use to enter Password-Protected Room. A Password-Protected Room is * Returns the password to use to enter Password-Protected Room. A Password-Protected Room is
* a room that a user cannot enter without first providing the correct password. * a room that a user cannot enter without first providing the correct password.
* *
* @return the password to use to enter Password-Protected Room. * @return the password to use to enter Password-Protected Room.
*/ */
public String getPassword() { public String getPassword() {
@ -114,7 +113,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the status which holds a code that assists in presenting notification messages. * Returns the status which holds a code that assists in presenting notification messages.
* *
* @return the status which holds a code that assists in presenting notification messages. * @return the status which holds a code that assists in presenting notification messages.
*/ */
public Status getStatus() { public Status getStatus() {
@ -123,9 +122,9 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the notification that the room has been destroyed. After a room has been destroyed, * Returns the notification that the room has been destroyed. After a room has been destroyed,
* the room occupants will receive a Presence packet of type 'unavailable' with the reason for * the room occupants will receive a Presence packet of type 'unavailable' with the reason for
* the room destruction if provided by the room owner. * the room destruction if provided by the room owner.
* *
* @return a notification that the room has been destroyed. * @return a notification that the room has been destroyed.
*/ */
public Destroy getDestroy() { public Destroy getDestroy() {
@ -136,7 +135,7 @@ public class MUCUser implements PacketExtension {
* Sets the invitation for another user to a room. The sender of the invitation * Sets the invitation for another user to a room. The sender of the invitation
* must be an occupant of the room. The invitation will be sent to the room which in turn * must be an occupant of the room. The invitation will be sent to the room which in turn
* will forward the invitation to the invitee. * will forward the invitation to the invitee.
* *
* @param invite the invitation for another user to a room. * @param invite the invitation for another user to a room.
*/ */
public void setInvite(Invite invite) { public void setInvite(Invite invite) {
@ -144,9 +143,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Sets the rejection to an invitation from another user to a room. The rejection will be * Sets the rejection to an invitation from another user to a room. The rejection will be
* sent to the room which in turn will forward the refusal to the inviter. * sent to the room which in turn will forward the refusal to the inviter.
* *
* @param decline the rejection to an invitation from another user to a room. * @param decline the rejection to an invitation from another user to a room.
*/ */
public void setDecline(Decline decline) { public void setDecline(Decline decline) {
@ -155,7 +154,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the item child that holds information about roles, affiliation, jids and nicks. * Sets the item child that holds information about roles, affiliation, jids and nicks.
* *
* @param item the item child that holds information about roles, affiliation, jids and nicks. * @param item the item child that holds information about roles, affiliation, jids and nicks.
*/ */
public void setItem(Item item) { public void setItem(Item item) {
@ -163,9 +162,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Sets the password to use to enter Password-Protected Room. A Password-Protected Room is * Sets the password to use to enter Password-Protected Room. A Password-Protected Room is
* a room that a user cannot enter without first providing the correct password. * a room that a user cannot enter without first providing the correct password.
* *
* @param string the password to use to enter Password-Protected Room. * @param string the password to use to enter Password-Protected Room.
*/ */
public void setPassword(String string) { public void setPassword(String string) {
@ -174,8 +173,8 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the status which holds a code that assists in presenting notification messages. * Sets the status which holds a code that assists in presenting notification messages.
* *
* @param status the status which holds a code that assists in presenting notification * @param status the status which holds a code that assists in presenting notification
* messages. * messages.
*/ */
public void setStatus(Status status) { public void setStatus(Status status) {
@ -184,9 +183,9 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the notification that the room has been destroyed. After a room has been destroyed, * Sets the notification that the room has been destroyed. After a room has been destroyed,
* the room occupants will receive a Presence packet of type 'unavailable' with the reason for * the room occupants will receive a Presence packet of type 'unavailable' with the reason for
* the room destruction if provided by the room owner. * the room destruction if provided by the room owner.
* *
* @param destroy the notification that the room has been destroyed. * @param destroy the notification that the room has been destroyed.
*/ */
public void setDestroy(Destroy destroy) { public void setDestroy(Destroy destroy) {
@ -196,7 +195,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Represents an invitation for another user to a room. The sender of the invitation * Represents an invitation for another user to a room. The sender of the invitation
* must be an occupant of the room. The invitation will be sent to the room which in turn * must be an occupant of the room. The invitation will be sent to the room which in turn
* will forward the invitation to the invitee. * will forward the invitation to the invitee.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
@ -206,9 +205,9 @@ public class MUCUser implements PacketExtension {
private String to; private String to;
/** /**
* Returns the bare JID of the inviter or, optionally, the room JID. (e.g. * Returns the bare JID of the inviter or, optionally, the room JID. (e.g.
* 'crone1@shakespeare.lit/desktop'). * 'crone1@shakespeare.lit/desktop').
* *
* @return the room's occupant that sent the invitation. * @return the room's occupant that sent the invitation.
*/ */
public String getFrom() { public String getFrom() {
@ -217,7 +216,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the message explaining the invitation. * Returns the message explaining the invitation.
* *
* @return the message explaining the invitation. * @return the message explaining the invitation.
*/ */
public String getReason() { public String getReason() {
@ -226,7 +225,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the bare JID of the invitee. (e.g. 'hecate@shakespeare.lit') * Returns the bare JID of the invitee. (e.g. 'hecate@shakespeare.lit')
* *
* @return the bare JID of the invitee. * @return the bare JID of the invitee.
*/ */
public String getTo() { public String getTo() {
@ -234,9 +233,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Sets the bare JID of the inviter or, optionally, the room JID. (e.g. * Sets the bare JID of the inviter or, optionally, the room JID. (e.g.
* 'crone1@shakespeare.lit/desktop') * 'crone1@shakespeare.lit/desktop')
* *
* @param from the bare JID of the inviter or, optionally, the room JID. * @param from the bare JID of the inviter or, optionally, the room JID.
*/ */
public void setFrom(String from) { public void setFrom(String from) {
@ -245,7 +244,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the message explaining the invitation. * Sets the message explaining the invitation.
* *
* @param reason the message explaining the invitation. * @param reason the message explaining the invitation.
*/ */
public void setReason(String reason) { public void setReason(String reason) {
@ -254,7 +253,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the bare JID of the invitee. (e.g. 'hecate@shakespeare.lit') * Sets the bare JID of the invitee. (e.g. 'hecate@shakespeare.lit')
* *
* @param to the bare JID of the invitee. * @param to the bare JID of the invitee.
*/ */
public void setTo(String to) { public void setTo(String to) {
@ -277,11 +276,11 @@ public class MUCUser implements PacketExtension {
buf.append("</invite>"); buf.append("</invite>");
return buf.toString(); return buf.toString();
} }
}; }
/** /**
* Represents a rejection to an invitation from another user to a room. The rejection will be * Represents a rejection to an invitation from another user to a room. The rejection will be
* sent to the room which in turn will forward the refusal to the inviter. * sent to the room which in turn will forward the refusal to the inviter.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
@ -291,9 +290,9 @@ public class MUCUser implements PacketExtension {
private String to; private String to;
/** /**
* Returns the bare JID of the invitee that rejected the invitation. (e.g. * Returns the bare JID of the invitee that rejected the invitation. (e.g.
* 'crone1@shakespeare.lit/desktop'). * 'crone1@shakespeare.lit/desktop').
* *
* @return the bare JID of the invitee that rejected the invitation. * @return the bare JID of the invitee that rejected the invitation.
*/ */
public String getFrom() { public String getFrom() {
@ -302,7 +301,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the message explaining why the invitation was rejected. * Returns the message explaining why the invitation was rejected.
* *
* @return the message explaining the reason for the rejection. * @return the message explaining the reason for the rejection.
*/ */
public String getReason() { public String getReason() {
@ -311,7 +310,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the bare JID of the inviter. (e.g. 'hecate@shakespeare.lit') * Returns the bare JID of the inviter. (e.g. 'hecate@shakespeare.lit')
* *
* @return the bare JID of the inviter. * @return the bare JID of the inviter.
*/ */
public String getTo() { public String getTo() {
@ -319,9 +318,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Sets the bare JID of the invitee that rejected the invitation. (e.g. * Sets the bare JID of the invitee that rejected the invitation. (e.g.
* 'crone1@shakespeare.lit/desktop'). * 'crone1@shakespeare.lit/desktop').
* *
* @param from the bare JID of the invitee that rejected the invitation. * @param from the bare JID of the invitee that rejected the invitation.
*/ */
public void setFrom(String from) { public void setFrom(String from) {
@ -330,7 +329,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the message explaining why the invitation was rejected. * Sets the message explaining why the invitation was rejected.
* *
* @param reason the message explaining the reason for the rejection. * @param reason the message explaining the reason for the rejection.
*/ */
public void setReason(String reason) { public void setReason(String reason) {
@ -339,7 +338,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the bare JID of the inviter. (e.g. 'hecate@shakespeare.lit') * Sets the bare JID of the inviter. (e.g. 'hecate@shakespeare.lit')
* *
* @param to the bare JID of the inviter. * @param to the bare JID of the inviter.
*/ */
public void setTo(String to) { public void setTo(String to) {
@ -362,7 +361,7 @@ public class MUCUser implements PacketExtension {
buf.append("</decline>"); buf.append("</decline>");
return buf.toString(); return buf.toString();
} }
}; }
/** /**
* Item child that holds information about roles, affiliation, jids and nicks. * Item child that holds information about roles, affiliation, jids and nicks.
@ -378,8 +377,8 @@ public class MUCUser implements PacketExtension {
private String role; private String role;
/** /**
* Creates a new item child. * Creates a new item child.
* *
* @param affiliation the actor's affiliation to the room * @param affiliation the actor's affiliation to the room
* @param role the privilege level of an occupant within a room. * @param role the privilege level of an occupant within a room.
*/ */
@ -390,7 +389,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the actor (JID of an occupant in the room) that was kicked or banned. * Returns the actor (JID of an occupant in the room) that was kicked or banned.
* *
* @return the JID of an occupant in the room that was kicked or banned. * @return the JID of an occupant in the room that was kicked or banned.
*/ */
public String getActor() { public String getActor() {
@ -400,7 +399,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the reason for the item child. The reason is optional and could be used to * Returns the reason for the item child. The reason is optional and could be used to
* explain the reason why a user (occupant) was kicked or banned. * explain the reason why a user (occupant) was kicked or banned.
* *
* @return the reason for the item child. * @return the reason for the item child.
*/ */
public String getReason() { public String getReason() {
@ -408,11 +407,11 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Returns the occupant's affiliation to the room. The affiliation is a semi-permanent * Returns the occupant's affiliation to the room. The affiliation is a semi-permanent
* association or connection with a room. The possible affiliations are "owner", "admin", * association or connection with a room. The possible affiliations are "owner", "admin",
* "member", and "outcast" (naturally it is also possible to have no affiliation). An * "member", and "outcast" (naturally it is also possible to have no affiliation). An
* affiliation lasts across a user's visits to a room. * affiliation lasts across a user's visits to a room.
* *
* @return the actor's affiliation to the room * @return the actor's affiliation to the room
*/ */
public String getAffiliation() { public String getAffiliation() {
@ -420,9 +419,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Returns the <room@service/nick> by which an occupant is identified within the context * Returns the <room@service/nick> by which an occupant is identified within the context
* of a room. If the room is non-anonymous, the JID will be included in the item. * of a room. If the room is non-anonymous, the JID will be included in the item.
* *
* @return the room JID by which an occupant is identified within the room. * @return the room JID by which an occupant is identified within the room.
*/ */
public String getJid() { public String getJid() {
@ -430,9 +429,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Returns the new nickname of an occupant that is changing his/her nickname. The new * Returns the new nickname of an occupant that is changing his/her nickname. The new
* nickname is sent as part of the unavailable presence. * nickname is sent as part of the unavailable presence.
* *
* @return the new nickname of an occupant that is changing his/her nickname. * @return the new nickname of an occupant that is changing his/her nickname.
*/ */
public String getNick() { public String getNick() {
@ -440,11 +439,11 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Returns the temporary position or privilege level of an occupant within a room. The * Returns the temporary position or privilege level of an occupant within a room. The
* possible roles are "moderator", "participant", and "visitor" (it is also possible to * possible roles are "moderator", "participant", and "visitor" (it is also possible to
* have no defined role). A role lasts only for the duration of an occupant's visit to * have no defined role). A role lasts only for the duration of an occupant's visit to
* a room. * a room.
* *
* @return the privilege level of an occupant within a room. * @return the privilege level of an occupant within a room.
*/ */
public String getRole() { public String getRole() {
@ -453,7 +452,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the actor (JID of an occupant in the room) that was kicked or banned. * Sets the actor (JID of an occupant in the room) that was kicked or banned.
* *
* @param actor the actor (JID of an occupant in the room) that was kicked or banned. * @param actor the actor (JID of an occupant in the room) that was kicked or banned.
*/ */
public void setActor(String actor) { public void setActor(String actor) {
@ -463,7 +462,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the reason for the item child. The reason is optional and could be used to * Sets the reason for the item child. The reason is optional and could be used to
* explain the reason why a user (occupant) was kicked or banned. * explain the reason why a user (occupant) was kicked or banned.
* *
* @param reason the reason why a user (occupant) was kicked or banned. * @param reason the reason why a user (occupant) was kicked or banned.
*/ */
public void setReason(String reason) { public void setReason(String reason) {
@ -471,9 +470,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Sets the <room@service/nick> by which an occupant is identified within the context * Sets the <room@service/nick> by which an occupant is identified within the context
* of a room. If the room is non-anonymous, the JID will be included in the item. * of a room. If the room is non-anonymous, the JID will be included in the item.
* *
* @param jid the JID by which an occupant is identified within a room. * @param jid the JID by which an occupant is identified within a room.
*/ */
public void setJid(String jid) { public void setJid(String jid) {
@ -481,9 +480,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Sets the new nickname of an occupant that is changing his/her nickname. The new * Sets the new nickname of an occupant that is changing his/her nickname. The new
* nickname is sent as part of the unavailable presence. * nickname is sent as part of the unavailable presence.
* *
* @param nick the new nickname of an occupant that is changing his/her nickname. * @param nick the new nickname of an occupant that is changing his/her nickname.
*/ */
public void setNick(String nick) { public void setNick(String nick) {
@ -497,7 +496,7 @@ public class MUCUser implements PacketExtension {
buf.append(" affiliation=\"").append(getAffiliation()).append("\""); buf.append(" affiliation=\"").append(getAffiliation()).append("\"");
} }
if (getJid() != null) { if (getJid() != null) {
buf.append(" jid=\"").append(StringUtils.escapeJID(getJid())).append("\""); buf.append(" jid=\"").append(getJid()).append("\"");
} }
if (getNick() != null) { if (getNick() != null) {
buf.append(" nick=\"").append(getNick()).append("\""); buf.append(" nick=\"").append(getNick()).append("\"");
@ -514,16 +513,16 @@ public class MUCUser implements PacketExtension {
buf.append("<reason>").append(getReason()).append("</reason>"); buf.append("<reason>").append(getReason()).append("</reason>");
} }
if (getActor() != null) { if (getActor() != null) {
buf.append("<actor jid=\"").append(StringUtils.escapeJID(getActor())).append("\"/>"); buf.append("<actor jid=\"").append(getActor()).append("\"/>");
} }
buf.append("</item>"); buf.append("</item>");
} }
return buf.toString(); return buf.toString();
} }
}; }
/** /**
* Status code assists in presenting notification messages. The following link provides the * Status code assists in presenting notification messages. The following link provides the
* list of existing error codes (@link http://www.jabber.org/jeps/jep-0045.html#errorstatus). * list of existing error codes (@link http://www.jabber.org/jeps/jep-0045.html#errorstatus).
* *
* @author Gaston Dombiak * @author Gaston Dombiak
@ -532,8 +531,8 @@ public class MUCUser implements PacketExtension {
private String code; private String code;
/** /**
* Creates a new instance of Status with the specified code. * Creates a new instance of Status with the specified code.
* *
* @param code the code that uniquely identifies the reason of the error. * @param code the code that uniquely identifies the reason of the error.
*/ */
public Status(String code) { public Status(String code) {
@ -541,9 +540,9 @@ public class MUCUser implements PacketExtension {
} }
/** /**
* Returns the code that uniquely identifies the reason of the error. The code * Returns the code that uniquely identifies the reason of the error. The code
* assists in presenting notification messages. * assists in presenting notification messages.
* *
* @return the code that uniquely identifies the reason of the error. * @return the code that uniquely identifies the reason of the error.
*/ */
public String getCode() { public String getCode() {
@ -555,13 +554,13 @@ public class MUCUser implements PacketExtension {
buf.append("<status code=\"").append(getCode()).append("\"/>"); buf.append("<status code=\"").append(getCode()).append("\"/>");
return buf.toString(); return buf.toString();
} }
}; }
/** /**
* Represents a notification that the room has been destroyed. After a room has been destroyed, * Represents a notification that the room has been destroyed. After a room has been destroyed,
* the room occupants will receive a Presence packet of type 'unavailable' with the reason for * the room occupants will receive a Presence packet of type 'unavailable' with the reason for
* the room destruction if provided by the room owner. * the room destruction if provided by the room owner.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public static class Destroy { public static class Destroy {
@ -571,7 +570,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the JID of an alternate location since the current room is being destroyed. * Returns the JID of an alternate location since the current room is being destroyed.
* *
* @return the JID of an alternate location. * @return the JID of an alternate location.
*/ */
public String getJid() { public String getJid() {
@ -580,7 +579,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Returns the reason for the room destruction. * Returns the reason for the room destruction.
* *
* @return the reason for the room destruction. * @return the reason for the room destruction.
*/ */
public String getReason() { public String getReason() {
@ -589,7 +588,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the JID of an alternate location since the current room is being destroyed. * Sets the JID of an alternate location since the current room is being destroyed.
* *
* @param jid the JID of an alternate location. * @param jid the JID of an alternate location.
*/ */
public void setJid(String jid) { public void setJid(String jid) {
@ -598,7 +597,7 @@ public class MUCUser implements PacketExtension {
/** /**
* Sets the reason for the room destruction. * Sets the reason for the room destruction.
* *
* @param reason the reason for the room destruction. * @param reason the reason for the room destruction.
*/ */
public void setReason(String reason) { public void setReason(String reason) {
@ -609,7 +608,7 @@ public class MUCUser implements PacketExtension {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("<destroy"); buf.append("<destroy");
if (getJid() != null) { if (getJid() != null) {
buf.append(" jid=\"").append(StringUtils.escapeJID(getJid())).append("\""); buf.append(" jid=\"").append(getJid()).append("\"");
} }
if (getReason() == null) { if (getReason() == null) {
buf.append("/>"); buf.append("/>");

View file

@ -91,11 +91,11 @@ public class UserSearchManager {
final List<String> searchServices = new ArrayList<String>(); final List<String> searchServices = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
DiscoverItems items = discoManager.discoverItems(con.getServiceName()); DiscoverItems items = discoManager.discoverItems(con.getServiceName());
Iterator iter = items.getItems(); Iterator<DiscoverItems.Item> iter = items.getItems();
while (iter.hasNext()) { while (iter.hasNext()) {
DiscoverItems.Item item = (DiscoverItems.Item) iter.next(); DiscoverItems.Item item = iter.next();
try { try {
DiscoverInfo info = null; DiscoverInfo info;
try { try {
info = discoManager.discoverInfo(item.getEntityID()); info = discoManager.discoverInfo(item.getEntityID());
} }