mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +01:00
SMACK-363 Applied code cleanup patches for many generics related issues.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13325 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
6dc64671e2
commit
e08c8afe44
109 changed files with 577 additions and 605 deletions
|
@ -10,8 +10,9 @@ import org.jivesoftware.smackx.packet.JingleError;
|
|||
* @author Alvaro Saurin <alvaro.saurin@gmail.com>
|
||||
*/
|
||||
public class JingleException extends XMPPException {
|
||||
|
||||
private final JingleError error;
|
||||
private static final long serialVersionUID = -1521230401958103382L;
|
||||
|
||||
private final JingleError error;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
|
|
|
@ -215,13 +215,13 @@ public class JingleManager implements JingleSessionListener {
|
|||
|
||||
connection.getRoster().addRosterListener(new RosterListener() {
|
||||
|
||||
public void entriesAdded(Collection addresses) {
|
||||
public void entriesAdded(Collection<String> addresses) {
|
||||
}
|
||||
|
||||
public void entriesUpdated(Collection addresses) {
|
||||
public void entriesUpdated(Collection<String> addresses) {
|
||||
}
|
||||
|
||||
public void entriesDeleted(Collection addresses) {
|
||||
public void entriesDeleted(Collection<String> addresses) {
|
||||
}
|
||||
|
||||
public void presenceChanged(Presence presence) {
|
||||
|
|
|
@ -96,7 +96,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
private static final SmackLogger LOGGER = SmackLogger.getLogger(JingleSession.class);
|
||||
|
||||
// static
|
||||
private static final HashMap sessions = new HashMap();
|
||||
private static final HashMap<Connection, JingleSession> sessions = new HashMap<Connection, JingleSession>();
|
||||
|
||||
private static final Random randomGenerator = new Random();
|
||||
|
||||
|
@ -116,14 +116,10 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
|
||||
protected List<JingleMediaManager> jingleMediaManagers = null;
|
||||
|
||||
private boolean closed = false;
|
||||
|
||||
private JingleSessionState sessionState;
|
||||
|
||||
private List<ContentNegotiator> contentNegotiators;
|
||||
|
||||
private JingleSessionRequest sessionRequest;
|
||||
|
||||
private Connection connection;
|
||||
|
||||
private String sessionInitPacketID;
|
||||
|
@ -181,7 +177,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
public JingleSession(Connection conn, JingleSessionRequest request, String initiator, String responder,
|
||||
List<JingleMediaManager> jingleMediaManagers) {
|
||||
this(conn, initiator, responder, generateSessionId(), jingleMediaManagers);
|
||||
sessionRequest = request;
|
||||
//sessionRequest = request; // unused
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -525,29 +521,6 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
// throw new IllegalStateException("Only session-initiate allowed in the UNKNOWN state.");
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* @param inJingle
|
||||
* @param inAction
|
||||
*/
|
||||
private void sendPendingStateAction(Jingle inJingle, JingleActionEnum inAction) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param inJingle
|
||||
* @param inAction
|
||||
*/
|
||||
private void sendActiveStateAction(Jingle inJingle, JingleActionEnum inAction) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param inJingle
|
||||
* @param inAction
|
||||
*/
|
||||
private void sendEndedStateAction(Jingle inJingle, JingleActionEnum inAction) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Acknowledge a IQ packet.
|
||||
|
@ -670,7 +643,7 @@ public class JingleSession extends JingleNegotiator implements MediaReceivedList
|
|||
JingleSession result = null;
|
||||
synchronized (sessions) {
|
||||
if (sessions.containsKey(con)) {
|
||||
result = (JingleSession) sessions.get(con);
|
||||
result = sessions.get(con);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class SmackLogger {
|
|||
* @param classToLog This is the class that wants to log. (This gives commons-logging a means to control log-level by class.)
|
||||
* @return An instance of a SmackLogger for the class that wants logging.
|
||||
*/
|
||||
public static SmackLogger getLogger(Class classToLog) {
|
||||
public static SmackLogger getLogger(Class<?> classToLog) {
|
||||
return new SmackLogger(classToLog);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class SmackLogger {
|
|||
* This is private to make it impossible to instantiate a new SmackLogger outside of the getLogger() static method.
|
||||
* @param classToLog This is the class that wants to log. (This gives commons-logging a means to control log-level by class.)
|
||||
*/
|
||||
public SmackLogger(Class classToLog) {
|
||||
public SmackLogger(Class<?> classToLog) {
|
||||
setupSmackLogger(classToLog);
|
||||
}
|
||||
|
||||
|
@ -63,9 +63,9 @@ public class SmackLogger {
|
|||
* @param classToLog
|
||||
* @return
|
||||
*/
|
||||
private void setupSmackLogger(Class classToLog) {
|
||||
private void setupSmackLogger(Class<?> classToLog) {
|
||||
try {
|
||||
Class logFactoryClass = SmackLogger.class.getClassLoader().loadClass("org.apache.commons.logging.LogFactory");
|
||||
Class<?> logFactoryClass = SmackLogger.class.getClassLoader().loadClass("org.apache.commons.logging.LogFactory");
|
||||
Method method = logFactoryClass.getMethod("getLog", Class.class);
|
||||
//Constructor<Log> constructor = Log.class.getConstructor(new Class[] { Object.class });
|
||||
commonsLogger = (Log) method.invoke(null, classToLog);
|
||||
|
|
|
@ -310,7 +310,7 @@ public class MediaNegotiator extends JingleNegotiator {
|
|||
private IQ receiveSessionAcceptAction(Jingle jingle, JingleDescription description) throws JingleException {
|
||||
IQ response = null;
|
||||
PayloadType.Audio agreedCommonAudioPt;
|
||||
List offeredPayloads = new ArrayList();
|
||||
List<PayloadType> offeredPayloads = new ArrayList<PayloadType>();
|
||||
|
||||
if (bestCommonAudioPt == null) {
|
||||
// Update the best common audio PT
|
||||
|
@ -358,7 +358,7 @@ public class MediaNegotiator extends JingleNegotiator {
|
|||
|
||||
// Payload types
|
||||
|
||||
private PayloadType calculateBestCommonAudioPt(List remoteAudioPts) {
|
||||
private PayloadType calculateBestCommonAudioPt(List<PayloadType> remoteAudioPts) {
|
||||
final ArrayList<PayloadType> commonAudioPtsHere = new ArrayList<PayloadType>();
|
||||
final ArrayList<PayloadType> commonAudioPtsThere = new ArrayList<PayloadType>();
|
||||
PayloadType result = null;
|
||||
|
|
|
@ -17,6 +17,8 @@ import com.sun.media.util.Registry;
|
|||
|
||||
public class JMFInit extends Frame implements Runnable {
|
||||
|
||||
private static final long serialVersionUID = 6476412003260641680L;
|
||||
|
||||
private static final SmackLogger LOGGER = SmackLogger.getLogger(JMFInit.class);
|
||||
|
||||
private String tempDir = "/tmp";
|
||||
|
@ -89,7 +91,7 @@ public class JMFInit extends Frame implements Runnable {
|
|||
private void detectCaptureDevices() {
|
||||
// check if JavaSound capture is available
|
||||
message("Looking for Audio capturer");
|
||||
Class dsauto;
|
||||
Class<?> dsauto;
|
||||
try {
|
||||
dsauto = Class.forName("DirectSoundAuto");
|
||||
dsauto.newInstance();
|
||||
|
@ -102,7 +104,7 @@ public class JMFInit extends Frame implements Runnable {
|
|||
//Do nothing
|
||||
}
|
||||
|
||||
Class jsauto;
|
||||
Class<?> jsauto;
|
||||
try {
|
||||
jsauto = Class.forName("JavaSoundAuto");
|
||||
jsauto.newInstance();
|
||||
|
@ -166,7 +168,7 @@ public class JMFInit extends Frame implements Runnable {
|
|||
}
|
||||
|
||||
private void detectDirectAudio() {
|
||||
Class cls;
|
||||
Class<?> cls;
|
||||
int plType = PlugInManager.RENDERER;
|
||||
String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
|
||||
try {
|
||||
|
@ -190,7 +192,7 @@ public class JMFInit extends Frame implements Runnable {
|
|||
PlugInManager.addPlugIn(dar, inputFormats, new Format[0],
|
||||
plType);
|
||||
// Move it to the top of the list
|
||||
Vector rendList = PlugInManager.getPlugInList(null, null,
|
||||
Vector<String> rendList = PlugInManager.getPlugInList(null, null,
|
||||
plType);
|
||||
int listSize = rendList.size();
|
||||
if (rendList.elementAt(listSize - 1).equals(dar)) {
|
||||
|
@ -212,7 +214,7 @@ public class JMFInit extends Frame implements Runnable {
|
|||
}
|
||||
|
||||
private void detectS8DirectAudio() {
|
||||
Class cls;
|
||||
Class<?> cls;
|
||||
int plType = PlugInManager.RENDERER;
|
||||
String dar = "com.sun.media.renderer.audio.DirectAudioRenderer";
|
||||
try {
|
||||
|
@ -227,7 +229,7 @@ public class JMFInit extends Frame implements Runnable {
|
|||
if (rend instanceof ExclusiveUse
|
||||
&& !((ExclusiveUse) rend).isExclusive()) {
|
||||
// sol8+, DAR supports mixing
|
||||
Vector rendList = PlugInManager.getPlugInList(null, null,
|
||||
Vector<String> rendList = PlugInManager.getPlugInList(null, null,
|
||||
plType);
|
||||
int listSize = rendList.size();
|
||||
boolean found = false;
|
||||
|
|
|
@ -43,7 +43,8 @@ import java.util.List;
|
|||
*/
|
||||
public class Demo extends JFrame {
|
||||
|
||||
private JingleTransportManager transportManager = null;
|
||||
private static final long serialVersionUID = -6584021277434403855L;
|
||||
private JingleTransportManager transportManager = null;
|
||||
private Connection xmppConnection = null;
|
||||
|
||||
private String server = null;
|
||||
|
@ -117,7 +118,9 @@ public class Demo extends JFrame {
|
|||
jPanel.add(jid);
|
||||
|
||||
jPanel.add(new JButton(new AbstractAction("Call") {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
private static final long serialVersionUID = 4308448034795312815L;
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (outgoing != null) return;
|
||||
try {
|
||||
outgoing = jm.createOutgoingJingleSession(jid.getText());
|
||||
|
@ -130,7 +133,9 @@ public class Demo extends JFrame {
|
|||
}));
|
||||
|
||||
jPanel.add(new JButton(new AbstractAction("Hangup") {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
private static final long serialVersionUID = -4508007389146723587L;
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (outgoing != null)
|
||||
try {
|
||||
outgoing.terminate();
|
||||
|
|
|
@ -17,7 +17,8 @@ import java.net.SocketException;
|
|||
*/
|
||||
public class ImageReceiver extends Canvas {
|
||||
|
||||
private boolean on = true;
|
||||
private static final long serialVersionUID = -7000112305305269025L;
|
||||
private boolean on = true;
|
||||
private DatagramSocket socket;
|
||||
private BufferedImage tiles[][];
|
||||
private static final int tileWidth = ImageTransmitter.tileWidth;
|
||||
|
|
|
@ -72,13 +72,13 @@ public class OctTreeQuantizer implements Quantizer {
|
|||
private int reduceColors;
|
||||
private int maximumColors;
|
||||
private int colors = 0;
|
||||
private Vector[] colorList;
|
||||
private Vector<OctTreeNode>[] colorList;
|
||||
|
||||
public OctTreeQuantizer() {
|
||||
setup(256);
|
||||
colorList = new Vector[MAX_LEVEL+1];
|
||||
for (int i = 0; i < MAX_LEVEL+1; i++)
|
||||
colorList[i] = new Vector();
|
||||
colorList[i] = new Vector<OctTreeNode>();
|
||||
root = new OctTreeNode();
|
||||
}
|
||||
|
||||
|
@ -200,10 +200,10 @@ public class OctTreeQuantizer implements Quantizer {
|
|||
|
||||
private void reduceTree(int numColors) {
|
||||
for (int level = MAX_LEVEL-1; level >= 0; level--) {
|
||||
Vector v = colorList[level];
|
||||
Vector<OctTreeNode> v = colorList[level];
|
||||
if (v != null && v.size() > 0) {
|
||||
for (int j = 0; j < v.size(); j++) {
|
||||
OctTreeNode node = (OctTreeNode)v.elementAt(j);
|
||||
OctTreeNode node = v.elementAt(j);
|
||||
if (node.children > 0) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
OctTreeNode child = node.leaf[i];
|
||||
|
|
|
@ -54,7 +54,7 @@ public class BasicResolver extends TransportResolver {
|
|||
|
||||
clearCandidates();
|
||||
|
||||
Enumeration ifaces = null;
|
||||
Enumeration<NetworkInterface> ifaces = null;
|
||||
|
||||
try {
|
||||
ifaces = NetworkInterface.getNetworkInterfaces();
|
||||
|
@ -64,11 +64,11 @@ public class BasicResolver extends TransportResolver {
|
|||
|
||||
while (ifaces.hasMoreElements()) {
|
||||
|
||||
NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
|
||||
Enumeration iaddresses = iface.getInetAddresses();
|
||||
NetworkInterface iface = ifaces.nextElement();
|
||||
Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
|
||||
|
||||
while (iaddresses.hasMoreElements()) {
|
||||
InetAddress iaddress = (InetAddress) iaddresses.nextElement();
|
||||
InetAddress iaddress = iaddresses.nextElement();
|
||||
if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress() && !iaddress.isSiteLocalAddress()) {
|
||||
TransportCandidate tr = new TransportCandidate.Fixed(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName(), getFreePort());
|
||||
tr.setLocalIp(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName());
|
||||
|
@ -87,11 +87,11 @@ public class BasicResolver extends TransportResolver {
|
|||
|
||||
while (ifaces.hasMoreElements()) {
|
||||
|
||||
NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
|
||||
Enumeration iaddresses = iface.getInetAddresses();
|
||||
NetworkInterface iface = ifaces.nextElement();
|
||||
Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
|
||||
|
||||
while (iaddresses.hasMoreElements()) {
|
||||
InetAddress iaddress = (InetAddress) iaddresses.nextElement();
|
||||
InetAddress iaddress = iaddresses.nextElement();
|
||||
if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress()) {
|
||||
TransportCandidate tr = new TransportCandidate.Fixed(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName(), getFreePort());
|
||||
tr.setLocalIp(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName());
|
||||
|
|
|
@ -114,7 +114,7 @@ public class BridgedResolver extends TransportResolver {
|
|||
}
|
||||
|
||||
public static String getLocalHost() {
|
||||
Enumeration ifaces = null;
|
||||
Enumeration<NetworkInterface> ifaces = null;
|
||||
|
||||
try {
|
||||
ifaces = NetworkInterface.getNetworkInterfaces();
|
||||
|
@ -125,11 +125,11 @@ public class BridgedResolver extends TransportResolver {
|
|||
|
||||
while (ifaces.hasMoreElements()) {
|
||||
|
||||
NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
|
||||
Enumeration iaddresses = iface.getInetAddresses();
|
||||
NetworkInterface iface = ifaces.nextElement();
|
||||
Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
|
||||
|
||||
while (iaddresses.hasMoreElements()) {
|
||||
InetAddress iaddress = (InetAddress) iaddresses.nextElement();
|
||||
InetAddress iaddress = iaddresses.nextElement();
|
||||
if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress() && !iaddress.isSiteLocalAddress() && !(iaddress instanceof Inet6Address)) {
|
||||
return iaddress.getHostAddress();
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ import org.jivesoftware.smackx.jingle.SmackLogger;
|
|||
*
|
||||
* @author Thiago Camargo
|
||||
*/
|
||||
public class ICECandidate extends TransportCandidate implements Comparable {
|
||||
public class ICECandidate extends TransportCandidate implements Comparable<ICECandidate> {
|
||||
|
||||
private static final SmackLogger LOGGER = SmackLogger.getLogger(ICECandidate.class);
|
||||
|
||||
|
@ -438,18 +438,14 @@ public class ICECandidate extends TransportCandidate implements Comparable {
|
|||
* object is less than, equal to, or greater than the specified
|
||||
* object
|
||||
*/
|
||||
public int compareTo(Object arg) {
|
||||
if (arg instanceof ICECandidate) {
|
||||
ICECandidate tc = (ICECandidate) arg;
|
||||
if (getPreference() < tc.getPreference()) {
|
||||
return -1;
|
||||
}
|
||||
else if (getPreference() > tc.getPreference()) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public int compareTo(ICECandidate arg) {
|
||||
if (getPreference() < arg.getPreference()) {
|
||||
return -1;
|
||||
} else if (getPreference() > arg.getPreference()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,6 @@ public class ICEResolver extends TransportResolver {
|
|||
i++;
|
||||
}
|
||||
} catch (SocketException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -225,7 +224,7 @@ public class ICEResolver extends TransportResolver {
|
|||
|
||||
if (publicIp != null && !publicIp.equals("")) {
|
||||
|
||||
Enumeration ifaces = null;
|
||||
Enumeration<NetworkInterface> ifaces = null;
|
||||
|
||||
try {
|
||||
ifaces = NetworkInterface.getNetworkInterfaces();
|
||||
|
@ -240,11 +239,11 @@ public class ICEResolver extends TransportResolver {
|
|||
|
||||
while (ifaces.hasMoreElements() && !false) {
|
||||
|
||||
NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
|
||||
Enumeration iaddresses = iface.getInetAddresses();
|
||||
NetworkInterface iface = ifaces.nextElement();
|
||||
Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
|
||||
|
||||
while (iaddresses.hasMoreElements()) {
|
||||
InetAddress iaddress = (InetAddress) iaddresses.nextElement();
|
||||
InetAddress iaddress = iaddresses.nextElement();
|
||||
if (iaddress.getHostAddress().indexOf(publicIp) > -1) {
|
||||
found = true;
|
||||
break;
|
||||
|
|
|
@ -442,9 +442,9 @@ public class RTPBridge extends IQ {
|
|||
// }
|
||||
|
||||
DiscoverInfo discoInfo = disco.discoverInfo(connection.getServiceName());
|
||||
Iterator iter = discoInfo.getIdentities();
|
||||
Iterator<DiscoverInfo.Identity> iter = discoInfo.getIdentities();
|
||||
while (iter.hasNext()) {
|
||||
DiscoverInfo.Identity identity = (DiscoverInfo.Identity) iter.next();
|
||||
DiscoverInfo.Identity identity = iter.next();
|
||||
if ((identity.getName() != null) && (identity.getName().startsWith("rtpbridge"))) {
|
||||
return true;
|
||||
}
|
||||
|
@ -528,7 +528,7 @@ public class RTPBridge extends IQ {
|
|||
|
||||
if (response.getIp() == null || response.getIp().equals("")) return null;
|
||||
|
||||
Enumeration ifaces = null;
|
||||
Enumeration<NetworkInterface> ifaces = null;
|
||||
try {
|
||||
ifaces = NetworkInterface.getNetworkInterfaces();
|
||||
}
|
||||
|
@ -537,11 +537,11 @@ public class RTPBridge extends IQ {
|
|||
}
|
||||
while (ifaces!=null&&ifaces.hasMoreElements()) {
|
||||
|
||||
NetworkInterface iface = (NetworkInterface) ifaces.nextElement();
|
||||
Enumeration iaddresses = iface.getInetAddresses();
|
||||
NetworkInterface iface = ifaces.nextElement();
|
||||
Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
|
||||
|
||||
while (iaddresses.hasMoreElements()) {
|
||||
InetAddress iaddress = (InetAddress) iaddresses.nextElement();
|
||||
InetAddress iaddress = iaddresses.nextElement();
|
||||
if (!iaddress.isLoopbackAddress())
|
||||
if (iaddress.getHostAddress().indexOf(response.getIp()) >= 0)
|
||||
return null;
|
||||
|
|
|
@ -230,9 +230,9 @@ public class STUN extends IQ {
|
|||
try {
|
||||
DiscoverItems items = disco.discoverItems(connection.getServiceName());
|
||||
|
||||
Iterator iter = items.getItems();
|
||||
Iterator<DiscoverItems.Item> iter = items.getItems();
|
||||
while (iter.hasNext()) {
|
||||
DiscoverItems.Item item = (DiscoverItems.Item) iter.next();
|
||||
DiscoverItems.Item item = iter.next();
|
||||
DiscoverInfo info = disco.discoverInfo(item.getEntityID());
|
||||
|
||||
Iterator<DiscoverInfo.Identity> iter2 = info.getIdentities();
|
||||
|
|
|
@ -134,8 +134,8 @@ public class STUNResolver extends TransportResolver {
|
|||
* @param stunConfigStream An InputStream with the configuration file.
|
||||
* @return A list of loaded servers
|
||||
*/
|
||||
public ArrayList loadSTUNServers(java.io.InputStream stunConfigStream) {
|
||||
ArrayList serversList = new ArrayList();
|
||||
public ArrayList<STUNService> loadSTUNServers(java.io.InputStream stunConfigStream) {
|
||||
ArrayList<STUNService> serversList = new ArrayList<STUNService>();
|
||||
String serverName;
|
||||
int serverPort;
|
||||
|
||||
|
@ -216,8 +216,8 @@ public class STUNResolver extends TransportResolver {
|
|||
*
|
||||
* @return a list of services
|
||||
*/
|
||||
public ArrayList loadSTUNServers() {
|
||||
ArrayList serversList = new ArrayList();
|
||||
public ArrayList<STUNService> loadSTUNServers() {
|
||||
ArrayList<STUNService> serversList = new ArrayList<STUNService>();
|
||||
|
||||
// Load the STUN configuration
|
||||
try {
|
||||
|
@ -228,11 +228,11 @@ public class STUNResolver extends TransportResolver {
|
|||
classLoaders[1] = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
for (int i = 0; i < classLoaders.length; i++) {
|
||||
Enumeration stunConfigEnum = classLoaders[i]
|
||||
Enumeration<URL> stunConfigEnum = classLoaders[i]
|
||||
.getResources(STUNSERVERS_FILENAME);
|
||||
|
||||
while (stunConfigEnum.hasMoreElements() && serversList.isEmpty()) {
|
||||
URL url = (URL) stunConfigEnum.nextElement();
|
||||
URL url = stunConfigEnum.nextElement();
|
||||
java.io.InputStream stunConfigStream = null;
|
||||
|
||||
stunConfigStream = url.openStream();
|
||||
|
@ -253,12 +253,12 @@ public class STUNResolver extends TransportResolver {
|
|||
*
|
||||
* @return the best STUN server that can be used.
|
||||
*/
|
||||
private STUNService bestSTUNServer(ArrayList listServers) {
|
||||
private STUNService bestSTUNServer(ArrayList<STUNService> listServers) {
|
||||
if (listServers.isEmpty()) {
|
||||
return null;
|
||||
} else {
|
||||
// TODO: this should use some more advanced criteria...
|
||||
return (STUNService) listServers.get(0);
|
||||
return listServers.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,19 +305,17 @@ public class STUNResolver extends TransportResolver {
|
|||
// Iterate through the list of interfaces, and ask
|
||||
// to the STUN server for our address.
|
||||
try {
|
||||
Enumeration ifaces = NetworkInterface.getNetworkInterfaces();
|
||||
Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
|
||||
String candAddress;
|
||||
int candPort;
|
||||
|
||||
while (ifaces.hasMoreElements()) {
|
||||
|
||||
NetworkInterface iface = (NetworkInterface) ifaces
|
||||
.nextElement();
|
||||
Enumeration iaddresses = iface.getInetAddresses();
|
||||
NetworkInterface iface = ifaces.nextElement();
|
||||
Enumeration<InetAddress> iaddresses = iface.getInetAddresses();
|
||||
|
||||
while (iaddresses.hasMoreElements()) {
|
||||
InetAddress iaddress = (InetAddress) iaddresses
|
||||
.nextElement();
|
||||
InetAddress iaddress = iaddresses.nextElement();
|
||||
if (!iaddress.isLoopbackAddress()
|
||||
&& !iaddress.isLinkLocalAddress()) {
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ import java.util.List;
|
|||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smackx.jingle.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.SmackLogger;
|
||||
import org.jivesoftware.smackx.jingle.nat.TransportResolverListener.Checker;
|
||||
|
||||
/**
|
||||
* Transport candidate.
|
||||
|
@ -103,7 +104,7 @@ public abstract class TransportCandidate {
|
|||
private Thread echoThread = null;
|
||||
|
||||
// Listeners for events
|
||||
private final List<TransportResolverListener.Checker> listeners = new ArrayList();
|
||||
private final List<TransportResolverListener.Checker> listeners = new ArrayList<Checker>();
|
||||
|
||||
public void addCandidateEcho(JingleSession session) throws SocketException, UnknownHostException {
|
||||
candidateEcho = new CandidateEcho(this, session);
|
||||
|
@ -387,9 +388,9 @@ public abstract class TransportCandidate {
|
|||
public void run() {
|
||||
boolean isUsable;
|
||||
|
||||
InetAddress candAddress;
|
||||
|
||||
try {
|
||||
candAddress = InetAddress.getByName(getIp());
|
||||
InetAddress candAddress = InetAddress.getByName(getIp());
|
||||
isUsable = true;//candAddress.isReachable(TransportResolver.CHECK_TIMEOUT);
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
@ -425,7 +426,7 @@ public abstract class TransportCandidate {
|
|||
*/
|
||||
public List<TransportResolverListener.Checker> getListenersList() {
|
||||
synchronized (listeners) {
|
||||
return new ArrayList(listeners);
|
||||
return new ArrayList<Checker>(listeners);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -449,9 +449,9 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
|||
*
|
||||
* @return The list of valid (ie, already checked) remote candidates.
|
||||
*/
|
||||
final ArrayList getValidRemoteCandidatesList() {
|
||||
final ArrayList<TransportCandidate> getValidRemoteCandidatesList() {
|
||||
synchronized (validRemoteCandidates) {
|
||||
return new ArrayList(validRemoteCandidates);
|
||||
return new ArrayList<TransportCandidate>(validRemoteCandidates);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
|||
* @return The iterator for the list of valid (ie, already checked) remote
|
||||
* candidates.
|
||||
*/
|
||||
public final Iterator getValidRemoteCandidates() {
|
||||
public final Iterator<TransportCandidate> getValidRemoteCandidates() {
|
||||
return Collections.unmodifiableList(getRemoteCandidates()).iterator();
|
||||
}
|
||||
|
||||
|
@ -471,11 +471,11 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
|||
*
|
||||
* @param rc the remote candidate to add.
|
||||
*/
|
||||
private void addRemoteCandidates(List rc) {
|
||||
private void addRemoteCandidates(List<TransportCandidate> rc) {
|
||||
if (rc != null) {
|
||||
if (rc.size() > 0) {
|
||||
for (Object aRc : rc) {
|
||||
addRemoteCandidate((TransportCandidate) aRc);
|
||||
for (TransportCandidate aRc : rc) {
|
||||
addRemoteCandidate(aRc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -829,7 +829,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
|||
*/
|
||||
public TransportCandidate getBestRemoteCandidate() {
|
||||
// Hopefully, we only have one validRemoteCandidate
|
||||
ArrayList cands = getValidRemoteCandidatesList();
|
||||
ArrayList<TransportCandidate> cands = getValidRemoteCandidatesList();
|
||||
if (!cands.isEmpty()) {
|
||||
LOGGER.debug("RAW CAND");
|
||||
return (TransportCandidate) cands.get(0);
|
||||
|
@ -883,14 +883,17 @@ public abstract class TransportNegotiator extends JingleNegotiator {
|
|||
public TransportCandidate getBestRemoteCandidate() {
|
||||
ICECandidate result = null;
|
||||
|
||||
ArrayList<ICECandidate> cands = getValidRemoteCandidatesList();
|
||||
ArrayList<TransportCandidate> cands = getValidRemoteCandidatesList();
|
||||
if (!cands.isEmpty()) {
|
||||
int highest = -1;
|
||||
ICECandidate chose = null;
|
||||
for (ICECandidate transportCandidate : cands) {
|
||||
if (transportCandidate.getPreference() > highest) {
|
||||
chose = transportCandidate;
|
||||
highest = transportCandidate.getPreference();
|
||||
for (TransportCandidate transportCandidate : cands) {
|
||||
if (transportCandidate instanceof ICECandidate) {
|
||||
ICECandidate icecandidate = (ICECandidate) transportCandidate;
|
||||
if (icecandidate.getPreference() > highest) {
|
||||
chose = icecandidate;
|
||||
highest = icecandidate.getPreference();
|
||||
}
|
||||
}
|
||||
}
|
||||
result = chose;
|
||||
|
|
|
@ -233,9 +233,9 @@ public abstract class TransportResolver {
|
|||
*
|
||||
* @return the list of listeners
|
||||
*/
|
||||
public ArrayList getListenersList() {
|
||||
public ArrayList<TransportResolverListener> getListenersList() {
|
||||
synchronized (listeners) {
|
||||
return new ArrayList(listeners);
|
||||
return new ArrayList<TransportResolverListener>(listeners);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,9 +245,9 @@ public abstract class TransportResolver {
|
|||
* @param cand The candidate added to the list of candidates.
|
||||
*/
|
||||
protected void triggerCandidateAdded(TransportCandidate cand) {
|
||||
Iterator iter = getListenersList().iterator();
|
||||
Iterator<TransportResolverListener> iter = getListenersList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
TransportResolverListener trl = (TransportResolverListener) iter.next();
|
||||
TransportResolverListener trl = iter.next();
|
||||
if (trl instanceof TransportResolverListener.Resolver) {
|
||||
TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl;
|
||||
LOGGER.debug("triggerCandidateAdded : " + cand.getLocalIp());
|
||||
|
@ -260,9 +260,9 @@ public abstract class TransportResolver {
|
|||
* Trigger a event notifying the initialization of the resolution process.
|
||||
*/
|
||||
private void triggerResolveInit() {
|
||||
Iterator iter = getListenersList().iterator();
|
||||
Iterator<TransportResolverListener> iter = getListenersList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
TransportResolverListener trl = (TransportResolverListener) iter.next();
|
||||
TransportResolverListener trl = iter.next();
|
||||
if (trl instanceof TransportResolverListener.Resolver) {
|
||||
TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl;
|
||||
li.init();
|
||||
|
@ -274,9 +274,9 @@ public abstract class TransportResolver {
|
|||
* Trigger a event notifying the obtention of all the candidates.
|
||||
*/
|
||||
private void triggerResolveEnd() {
|
||||
Iterator iter = getListenersList().iterator();
|
||||
Iterator<TransportResolverListener> iter = getListenersList().iterator();
|
||||
while (iter.hasNext()) {
|
||||
TransportResolverListener trl = (TransportResolverListener) iter.next();
|
||||
TransportResolverListener trl = iter.next();
|
||||
if (trl instanceof TransportResolverListener.Resolver) {
|
||||
TransportResolverListener.Resolver li = (TransportResolverListener.Resolver) trl;
|
||||
li.end();
|
||||
|
@ -315,9 +315,9 @@ public abstract class TransportResolver {
|
|||
*
|
||||
* @return an iterator
|
||||
*/
|
||||
public Iterator getCandidates() {
|
||||
public Iterator<TransportCandidate> getCandidates() {
|
||||
synchronized (candidates) {
|
||||
return Collections.unmodifiableList(new ArrayList(candidates)).iterator();
|
||||
return Collections.unmodifiableList(new ArrayList<TransportCandidate>(candidates)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,13 @@ public abstract class TransportResolver {
|
|||
public TransportCandidate getPreferredCandidate() {
|
||||
TransportCandidate result = null;
|
||||
|
||||
ArrayList cands = (ArrayList) getCandidatesList();
|
||||
ArrayList<ICECandidate> cands = new ArrayList<ICECandidate>();
|
||||
for (TransportCandidate tpcan : getCandidatesList()) {
|
||||
if (tpcan instanceof ICECandidate)
|
||||
cands.add((ICECandidate) tpcan);
|
||||
}
|
||||
|
||||
// (ArrayList<ICECandidate>) getCandidatesList();
|
||||
if (cands.size() > 0) {
|
||||
Collections.sort(cands);
|
||||
// Return the last candidate
|
||||
|
|
|
@ -218,7 +218,7 @@ public class Jingle extends IQ {
|
|||
*/
|
||||
public Iterator<JingleContent> getContents() {
|
||||
synchronized (contents) {
|
||||
return Collections.unmodifiableList(new ArrayList(contents)).iterator();
|
||||
return Collections.unmodifiableList(new ArrayList<JingleContent>(contents)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public abstract class JingleContentDescription implements PacketExtension {
|
|||
|
||||
// non-static
|
||||
|
||||
private final List payloads = new ArrayList();
|
||||
private final List<JinglePayloadType> payloads = new ArrayList<JinglePayloadType>();
|
||||
|
||||
/**
|
||||
* Creates a content description..
|
||||
|
@ -81,11 +81,11 @@ public abstract class JingleContentDescription implements PacketExtension {
|
|||
*
|
||||
* @param pts the payloads to add.
|
||||
*/
|
||||
public void addAudioPayloadTypes(final List pts) {
|
||||
public void addAudioPayloadTypes(final List<PayloadType.Audio> pts) {
|
||||
synchronized (payloads) {
|
||||
Iterator ptIter = pts.iterator();
|
||||
Iterator<PayloadType.Audio> ptIter = pts.iterator();
|
||||
while (ptIter.hasNext()) {
|
||||
PayloadType.Audio pt = (PayloadType.Audio) ptIter.next();
|
||||
PayloadType.Audio pt = ptIter.next();
|
||||
addJinglePayloadType(new JinglePayloadType.Audio(pt));
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ public abstract class JingleContentDescription implements PacketExtension {
|
|||
*
|
||||
* @return an Iterator for the audio payloads in the packet.
|
||||
*/
|
||||
public Iterator getJinglePayloadTypes() {
|
||||
public Iterator<JinglePayloadType> getJinglePayloadTypes() {
|
||||
return Collections.unmodifiableList(getJinglePayloadTypesList()).iterator();
|
||||
}
|
||||
|
||||
|
@ -105,9 +105,9 @@ public abstract class JingleContentDescription implements PacketExtension {
|
|||
*
|
||||
* @return a list for the audio payloads in the packet.
|
||||
*/
|
||||
public ArrayList getJinglePayloadTypesList() {
|
||||
public ArrayList<JinglePayloadType> getJinglePayloadTypesList() {
|
||||
synchronized (payloads) {
|
||||
return new ArrayList(payloads);
|
||||
return new ArrayList<JinglePayloadType>(payloads);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,15 +116,15 @@ public abstract class JingleContentDescription implements PacketExtension {
|
|||
*
|
||||
* @return a list of PayloadType.Audio
|
||||
*/
|
||||
public ArrayList getAudioPayloadTypesList() {
|
||||
ArrayList result = new ArrayList();
|
||||
Iterator jinglePtsIter = getJinglePayloadTypes();
|
||||
public ArrayList<PayloadType.Audio> getAudioPayloadTypesList() {
|
||||
ArrayList<PayloadType.Audio> result = new ArrayList<PayloadType.Audio>();
|
||||
Iterator<JinglePayloadType> jinglePtsIter = getJinglePayloadTypes();
|
||||
|
||||
while (jinglePtsIter.hasNext()) {
|
||||
JinglePayloadType jpt = (JinglePayloadType) jinglePtsIter.next();
|
||||
JinglePayloadType jpt = jinglePtsIter.next();
|
||||
if (jpt instanceof JinglePayloadType.Audio) {
|
||||
JinglePayloadType.Audio jpta = (JinglePayloadType.Audio) jpt;
|
||||
result.add(jpta.getPayloadType());
|
||||
result.add((PayloadType.Audio)jpta.getPayloadType());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,9 +155,9 @@ public abstract class JingleContentDescription implements PacketExtension {
|
|||
buf.append("<").append(getElementName());
|
||||
buf.append(" xmlns=\"").append(getNamespace()).append("\" >");
|
||||
|
||||
Iterator pt = payloads.listIterator();
|
||||
Iterator<JinglePayloadType> pt = payloads.listIterator();
|
||||
while (pt.hasNext()) {
|
||||
JinglePayloadType pte = (JinglePayloadType) pt.next();
|
||||
JinglePayloadType pte = pt.next();
|
||||
buf.append(pte.toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
|
|
|
@ -90,7 +90,7 @@ public abstract class JingleDescription implements PacketExtension {
|
|||
*/
|
||||
public void addAudioPayloadTypes(final List<PayloadType> pts) {
|
||||
synchronized (payloads) {
|
||||
Iterator ptIter = pts.iterator();
|
||||
Iterator<PayloadType> ptIter = pts.iterator();
|
||||
while (ptIter.hasNext()) {
|
||||
PayloadType.Audio pt = (PayloadType.Audio) ptIter.next();
|
||||
addPayloadType(new PayloadType.Audio(pt));
|
||||
|
|
|
@ -95,7 +95,7 @@ public class JingleTransport implements PacketExtension {
|
|||
*
|
||||
* @return an iterator
|
||||
*/
|
||||
public Iterator getCandidates() {
|
||||
public Iterator<JingleTransportCandidate> getCandidates() {
|
||||
return Collections.unmodifiableList(getCandidatesList()).iterator();
|
||||
}
|
||||
|
||||
|
@ -160,11 +160,10 @@ public class JingleTransport implements PacketExtension {
|
|||
synchronized (candidates) {
|
||||
if (getCandidatesCount() > 0) {
|
||||
buf.append(">");
|
||||
Iterator iter = getCandidates();
|
||||
Iterator<JingleTransportCandidate> iter = getCandidates();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
JingleTransportCandidate candidate = (JingleTransportCandidate) iter
|
||||
.next();
|
||||
JingleTransportCandidate candidate = iter.next();
|
||||
buf.append(candidate.toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
|
||||
import org.jivesoftware.smack.test.SmackTestCase;
|
||||
import org.jivesoftware.smackx.jingle.media.PayloadType;
|
||||
import org.jivesoftware.smackx.jingle.media.PayloadType.Audio;
|
||||
|
||||
public class PayloadTypeTest extends SmackTestCase {
|
||||
|
||||
|
@ -21,8 +22,8 @@ public class PayloadTypeTest extends SmackTestCase {
|
|||
* Test for the difference of payloads.
|
||||
*/
|
||||
public void testDifference() {
|
||||
ArrayList set1 = new ArrayList();
|
||||
ArrayList set2 = new ArrayList();
|
||||
ArrayList<Audio> set1 = new ArrayList<Audio>();
|
||||
ArrayList<Audio> set2 = new ArrayList<Audio>();
|
||||
|
||||
PayloadType.Audio common1 = new PayloadType.Audio(34, "supercodec-1", 2, 14000);
|
||||
PayloadType.Audio common2 = new PayloadType.Audio(56, "supercodec-2", 1, 44000);
|
||||
|
@ -38,7 +39,7 @@ public class PayloadTypeTest extends SmackTestCase {
|
|||
set2.add(common1);
|
||||
|
||||
// Get the difference
|
||||
ArrayList commonSet = new ArrayList();
|
||||
ArrayList<Audio> commonSet = new ArrayList<Audio>();
|
||||
commonSet.addAll(set1);
|
||||
commonSet.retainAll(set2);
|
||||
|
||||
|
@ -54,8 +55,8 @@ public class PayloadTypeTest extends SmackTestCase {
|
|||
* Test for the difference of payloads when we are handling the same sets.
|
||||
*/
|
||||
public void testDifferenceSameSet() {
|
||||
ArrayList set1 = new ArrayList();
|
||||
ArrayList set2 = new ArrayList();
|
||||
ArrayList<Audio> set1 = new ArrayList<Audio>();
|
||||
ArrayList<Audio> set2 = new ArrayList<Audio>();
|
||||
|
||||
PayloadType.Audio common1 = new PayloadType.Audio(34, "supercodec-1", 2, 14000);
|
||||
PayloadType.Audio common2 = new PayloadType.Audio(56, "supercodec-2", 1, 44000);
|
||||
|
@ -73,7 +74,7 @@ public class PayloadTypeTest extends SmackTestCase {
|
|||
set2.add(common4);
|
||||
|
||||
// Get the difference
|
||||
ArrayList commonSet = new ArrayList();
|
||||
ArrayList<Audio> commonSet = new ArrayList<Audio>();
|
||||
commonSet.addAll(set1);
|
||||
commonSet.retainAll(set2);
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jivesoftware.smackx.jingle.nat;
|
||||
|
||||
import de.javawi.jstun.test.demo.StunServer;
|
||||
import de.javawi.jstun.test.demo.ice.Candidate;
|
||||
import de.javawi.jstun.test.demo.ice.ICENegociator;
|
||||
import de.javawi.jstun.util.UtilityException;
|
||||
|
@ -13,6 +14,7 @@ import org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener;
|
|||
import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
|
||||
import org.jivesoftware.smackx.jingle.media.PayloadType;
|
||||
import org.jivesoftware.smackx.jingle.mediaimpl.test.TestMediaManager;
|
||||
import org.jivesoftware.smackx.jingle.nat.STUNResolver.STUNService;
|
||||
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
|
@ -182,7 +184,7 @@ public class STUNResolverTest extends SmackTestCase {
|
|||
public void testLoadSTUNServers() throws Exception {
|
||||
STUNResolver stunResolver = new STUNResolver() {
|
||||
};
|
||||
ArrayList stunServers = stunResolver.loadSTUNServers();
|
||||
ArrayList<STUNService> stunServers = stunResolver.loadSTUNServers();
|
||||
|
||||
assertTrue(stunServers.size() > 0);
|
||||
System.out.println(stunServers.size() + " servers loaded");
|
||||
|
@ -244,8 +246,8 @@ public class STUNResolverTest extends SmackTestCase {
|
|||
*
|
||||
* @return A testing list
|
||||
*/
|
||||
private ArrayList getTestPayloads1() {
|
||||
ArrayList result = new ArrayList();
|
||||
private ArrayList<PayloadType> getTestPayloads1() {
|
||||
ArrayList<PayloadType> result = new ArrayList<PayloadType>();
|
||||
|
||||
result.add(new PayloadType.Audio(34, "supercodec-1", 2, 14000));
|
||||
result.add(new PayloadType.Audio(56, "supercodec-2", 1, 44000));
|
||||
|
@ -255,8 +257,8 @@ public class STUNResolverTest extends SmackTestCase {
|
|||
return result;
|
||||
}
|
||||
|
||||
private ArrayList getTestPayloads2() {
|
||||
ArrayList result = new ArrayList();
|
||||
private ArrayList<PayloadType> getTestPayloads2() {
|
||||
ArrayList<PayloadType> result = new ArrayList<PayloadType>();
|
||||
|
||||
result.add(new PayloadType.Audio(27, "supercodec-3", 2, 28000));
|
||||
result.add(new PayloadType.Audio(56, "supercodec-2", 1, 44000));
|
||||
|
|
|
@ -2,9 +2,6 @@ package org.jivesoftware.smackx.jingle.nat;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import org.jivesoftware.smack.test.SmackTestCase;
|
||||
|
||||
|
@ -35,18 +32,18 @@ public class TransportCandidateTest extends SmackTestCase {
|
|||
public void testCompareTo() {
|
||||
int highestPref = 100;
|
||||
|
||||
TransportCandidate cand1 = new ICECandidate("192.168.2.1", 3, 2,
|
||||
ICECandidate cand1 = new ICECandidate("192.168.2.1", 3, 2,
|
||||
"password", 3468, "username", 1, ICECandidate.Type.prflx);
|
||||
TransportCandidate cand2 = new ICECandidate("192.168.5.1", 2, 10,
|
||||
ICECandidate cand2 = new ICECandidate("192.168.5.1", 2, 10,
|
||||
"password", 3469, "username", 15,ICECandidate.Type.prflx);
|
||||
TransportCandidate candH = new ICECandidate("192.168.2.1", 1, 2,
|
||||
ICECandidate candH = new ICECandidate("192.168.2.1", 1, 2,
|
||||
"password", 3468, "username", highestPref, ICECandidate.Type.prflx);
|
||||
TransportCandidate cand3 = new ICECandidate("192.168.2.10", 2, 10,
|
||||
ICECandidate cand3 = new ICECandidate("192.168.2.10", 2, 10,
|
||||
"password", 3469, "username", 2, ICECandidate.Type.prflx);
|
||||
TransportCandidate cand4 = new ICECandidate("192.168.4.1", 3, 2,
|
||||
ICECandidate cand4 = new ICECandidate("192.168.4.1", 3, 2,
|
||||
"password", 3468, "username", 78, ICECandidate.Type.prflx);
|
||||
|
||||
ArrayList candList = new ArrayList();
|
||||
ArrayList<ICECandidate> candList = new ArrayList<ICECandidate>();
|
||||
candList.add(cand1);
|
||||
candList.add(cand2);
|
||||
candList.add(candH);
|
||||
|
|
|
@ -63,7 +63,7 @@ import java.util.*;
|
|||
*/
|
||||
public class SASLAuthentication implements UserAuthentication {
|
||||
|
||||
private static Map<String, Class> implementedMechanisms = new HashMap<String, Class>();
|
||||
private static Map<String, Class<? extends SASLMechanism>> implementedMechanisms = new HashMap<String, Class<? extends SASLMechanism>>();
|
||||
private static List<String> mechanismsPreferences = new ArrayList<String>();
|
||||
|
||||
private Connection connection;
|
||||
|
@ -109,7 +109,7 @@ public class SASLAuthentication implements UserAuthentication {
|
|||
* @param name common name of the SASL mechanism. E.g.: PLAIN, DIGEST-MD5 or KERBEROS_V4.
|
||||
* @param mClass a SASLMechanism subclass.
|
||||
*/
|
||||
public static void registerSASLMechanism(String name, Class mClass) {
|
||||
public static void registerSASLMechanism(String name, Class<? extends SASLMechanism> mClass) {
|
||||
implementedMechanisms.put(name, mClass);
|
||||
}
|
||||
|
||||
|
@ -167,8 +167,8 @@ public class SASLAuthentication implements UserAuthentication {
|
|||
*
|
||||
* @return the registerd SASLMechanism classes sorted by the level of preference.
|
||||
*/
|
||||
public static List<Class> getRegisterSASLMechanisms() {
|
||||
List<Class> answer = new ArrayList<Class>();
|
||||
public static List<Class<? extends SASLMechanism>> getRegisterSASLMechanisms() {
|
||||
List<Class<? extends SASLMechanism>> answer = new ArrayList<Class<? extends SASLMechanism>>();
|
||||
for (String mechanismsPreference : mechanismsPreferences) {
|
||||
answer.add(implementedMechanisms.get(mechanismsPreference));
|
||||
}
|
||||
|
@ -228,9 +228,9 @@ public class SASLAuthentication implements UserAuthentication {
|
|||
// A SASL mechanism was found. Authenticate using the selected mechanism and then
|
||||
// proceed to bind a resource
|
||||
try {
|
||||
Class mechanismClass = implementedMechanisms.get(selectedMechanism);
|
||||
Constructor constructor = mechanismClass.getConstructor(SASLAuthentication.class);
|
||||
currentMechanism = (SASLMechanism) constructor.newInstance(this);
|
||||
Class<? extends SASLMechanism> mechanismClass = implementedMechanisms.get(selectedMechanism);
|
||||
Constructor<? extends SASLMechanism> constructor = mechanismClass.getConstructor(SASLAuthentication.class);
|
||||
currentMechanism = constructor.newInstance(this);
|
||||
// Trigger SASL authentication with the selected mechanism. We use
|
||||
// connection.getHost() since GSAPI requires the FQDN of the server, which
|
||||
// may not match the XMPP domain.
|
||||
|
@ -310,9 +310,9 @@ public class SASLAuthentication implements UserAuthentication {
|
|||
// A SASL mechanism was found. Authenticate using the selected mechanism and then
|
||||
// proceed to bind a resource
|
||||
try {
|
||||
Class mechanismClass = implementedMechanisms.get(selectedMechanism);
|
||||
Constructor constructor = mechanismClass.getConstructor(SASLAuthentication.class);
|
||||
currentMechanism = (SASLMechanism) constructor.newInstance(this);
|
||||
Class<? extends SASLMechanism> mechanismClass = implementedMechanisms.get(selectedMechanism);
|
||||
Constructor<? extends SASLMechanism> constructor = mechanismClass.getConstructor(SASLAuthentication.class);
|
||||
currentMechanism = constructor.newInstance(this);
|
||||
// Trigger SASL authentication with the selected mechanism. We use
|
||||
// connection.getHost() since GSAPI requires the FQDN of the server, which
|
||||
// may not match the XMPP domain.
|
||||
|
|
|
@ -69,9 +69,9 @@ public final class SmackConfiguration {
|
|||
// Get an array of class loaders to try loading the providers files from.
|
||||
ClassLoader[] classLoaders = getClassLoaders();
|
||||
for (ClassLoader classLoader : classLoaders) {
|
||||
Enumeration configEnum = classLoader.getResources("META-INF/smack-config.xml");
|
||||
Enumeration<URL> configEnum = classLoader.getResources("META-INF/smack-config.xml");
|
||||
while (configEnum.hasMoreElements()) {
|
||||
URL url = (URL) configEnum.nextElement();
|
||||
URL url = configEnum.nextElement();
|
||||
InputStream systemStream = null;
|
||||
try {
|
||||
systemStream = url.openStream();
|
||||
|
|
|
@ -743,7 +743,7 @@ public class XMPPConnection extends Connection {
|
|||
}
|
||||
else if(config.getKeystoreType().equals("PKCS11")) {
|
||||
try {
|
||||
Constructor c = Class.forName("sun.security.pkcs11.SunPKCS11").getConstructor(InputStream.class);
|
||||
Constructor<?> c = Class.forName("sun.security.pkcs11.SunPKCS11").getConstructor(InputStream.class);
|
||||
String pkcs11Config = "name = SmartCard\nlibrary = "+config.getPKCS11Library();
|
||||
ByteArrayInputStream config = new ByteArrayInputStream(pkcs11Config.getBytes());
|
||||
Provider p = (Provider)c.newInstance(config);
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.jivesoftware.smack.packet.Packet;
|
|||
*/
|
||||
public class PacketTypeFilter implements PacketFilter {
|
||||
|
||||
Class packetType;
|
||||
Class<? extends Packet> packetType;
|
||||
|
||||
/**
|
||||
* Creates a new packet type filter that will filter for packets that are the
|
||||
|
@ -43,7 +43,7 @@ public class PacketTypeFilter implements PacketFilter {
|
|||
*
|
||||
* @param packetType the Class type.
|
||||
*/
|
||||
public PacketTypeFilter(Class packetType) {
|
||||
public PacketTypeFilter(Class<? extends Packet> packetType) {
|
||||
// Ensure the packet type is a sub-class of Packet.
|
||||
if (!Packet.class.isAssignableFrom(packetType)) {
|
||||
throw new IllegalArgumentException("Packet type must be a sub-class of Packet.");
|
||||
|
|
|
@ -58,7 +58,7 @@ public class Privacy extends IQ {
|
|||
* @param listItem the {@link PrivacyItem} that rules the list.
|
||||
* @return the privacy List.
|
||||
*/
|
||||
public List setPrivacyList(String listName, List<PrivacyItem> listItem) {
|
||||
public List<PrivacyItem> setPrivacyList(String listName, List<PrivacyItem> listItem) {
|
||||
// Add new list to the itemLists
|
||||
this.getItemLists().put(listName, listItem);
|
||||
return listItem;
|
||||
|
|
|
@ -157,10 +157,10 @@ public class ProviderManager {
|
|||
// Get an array of class loaders to try loading the providers files from.
|
||||
ClassLoader[] classLoaders = getClassLoaders();
|
||||
for (ClassLoader classLoader : classLoaders) {
|
||||
Enumeration providerEnum = classLoader.getResources(
|
||||
Enumeration<URL> providerEnum = classLoader.getResources(
|
||||
"META-INF/smack.providers");
|
||||
while (providerEnum.hasMoreElements()) {
|
||||
URL url = (URL) providerEnum.nextElement();
|
||||
URL url = providerEnum.nextElement();
|
||||
InputStream providerStream = null;
|
||||
try {
|
||||
providerStream = url.openStream();
|
||||
|
@ -190,7 +190,7 @@ public class ProviderManager {
|
|||
// reflection later to create instances of the class.
|
||||
try {
|
||||
// Add the provider to the map.
|
||||
Class provider = Class.forName(className);
|
||||
Class<?> provider = Class.forName(className);
|
||||
if (IQProvider.class.isAssignableFrom(provider)) {
|
||||
iqProviders.put(key, provider.newInstance());
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ public class ProviderManager {
|
|||
// of the class.
|
||||
try {
|
||||
// Add the provider to the map.
|
||||
Class provider = Class.forName(className);
|
||||
Class<?> provider = Class.forName(className);
|
||||
if (PacketExtensionProvider.class.isAssignableFrom(
|
||||
provider)) {
|
||||
extensionProviders.put(key, provider.newInstance());
|
||||
|
@ -309,7 +309,7 @@ public class ProviderManager {
|
|||
Object provider)
|
||||
{
|
||||
if (!(provider instanceof IQProvider || (provider instanceof Class &&
|
||||
IQ.class.isAssignableFrom((Class)provider))))
|
||||
IQ.class.isAssignableFrom((Class<?>)provider))))
|
||||
{
|
||||
throw new IllegalArgumentException("Provider must be an IQProvider " +
|
||||
"or a Class instance.");
|
||||
|
|
|
@ -26,7 +26,6 @@ import java.io.IOException;
|
|||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import javax.security.sasl.Sasl;
|
||||
import javax.security.sasl.SaslClient;
|
||||
import javax.security.auth.callback.CallbackHandler;
|
||||
|
||||
/**
|
||||
|
@ -61,7 +60,7 @@ public class SASLGSSAPIMechanism extends SASLMechanism {
|
|||
*/
|
||||
public void authenticate(String username, String host, CallbackHandler cbh) throws IOException, XMPPException {
|
||||
String[] mechanisms = { getName() };
|
||||
Map props = new HashMap();
|
||||
Map<String,String> props = new HashMap<String,String>();
|
||||
props.put(Sasl.SERVER_AUTH,"TRUE");
|
||||
sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, cbh);
|
||||
authenticate();
|
||||
|
@ -80,7 +79,7 @@ public class SASLGSSAPIMechanism extends SASLMechanism {
|
|||
*/
|
||||
public void authenticate(String username, String host, String password) throws IOException, XMPPException {
|
||||
String[] mechanisms = { getName() };
|
||||
Map props = new HashMap();
|
||||
Map<String,String> props = new HashMap<String, String>();
|
||||
props.put(Sasl.SERVER_AUTH,"TRUE");
|
||||
sc = Sasl.createSaslClient(mechanisms, username, "xmpp", host, props, this);
|
||||
authenticate();
|
||||
|
|
|
@ -477,7 +477,7 @@ public class Cache<K, V> implements Map<K, V> {
|
|||
return false;
|
||||
}
|
||||
|
||||
final CacheObject cacheObject = (CacheObject) o;
|
||||
final CacheObject<?> cacheObject = (CacheObject<?>) o;
|
||||
|
||||
return object.equals(cacheObject.object);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.naming.directory.Attributes;
|
|||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.directory.InitialDirContext;
|
||||
|
||||
|
||||
/**
|
||||
* Utilty class to perform DNS lookups for XMPP services.
|
||||
*
|
||||
|
@ -39,13 +40,13 @@ public class DNSUtil {
|
|||
* Create a cache to hold the 100 most recently accessed DNS lookups for a period of
|
||||
* 10 minutes.
|
||||
*/
|
||||
private static Map cache = new Cache(100, 1000*60*10);
|
||||
private static Map<String, HostAddress> cache = new Cache<String, HostAddress>(100, 1000*60*10);
|
||||
|
||||
private static DirContext context;
|
||||
|
||||
static {
|
||||
try {
|
||||
Hashtable env = new Hashtable();
|
||||
Hashtable<String, String> env = new Hashtable<String, String>();
|
||||
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
|
||||
context = new InitialDirContext(env);
|
||||
}
|
||||
|
@ -97,9 +98,9 @@ public class DNSUtil {
|
|||
try {
|
||||
Attributes dnsLookup = context.getAttributes("_xmpp-client._tcp." + domain, new String[]{"SRV"});
|
||||
Attribute srvAttribute = dnsLookup.get("SRV");
|
||||
NamingEnumeration srvRecords = srvAttribute.getAll();
|
||||
NamingEnumeration<String> srvRecords = (NamingEnumeration<String>) srvAttribute.getAll();
|
||||
while(srvRecords.hasMore()) {
|
||||
String srvRecord = (String) srvRecords.next();
|
||||
String srvRecord = srvRecords.next();
|
||||
String [] srvRecordEntries = srvRecord.split(" ");
|
||||
int priority = Integer.parseInt(srvRecordEntries[srvRecordEntries.length - 4]);
|
||||
int port = Integer.parseInt(srvRecordEntries[srvRecordEntries.length-2]);
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.*;
|
|||
public class ObservableReader extends Reader {
|
||||
|
||||
Reader wrappedReader = null;
|
||||
List listeners = new ArrayList();
|
||||
List<ReaderListener> listeners = new ArrayList<ReaderListener>();
|
||||
|
||||
public ObservableReader(Reader wrappedReader) {
|
||||
this.wrappedReader = wrappedReader;
|
||||
|
|
|
@ -32,7 +32,7 @@ import java.util.*;
|
|||
public class ObservableWriter extends Writer {
|
||||
|
||||
Writer wrappedWriter = null;
|
||||
List listeners = new ArrayList();
|
||||
List<WriterListener> listeners = new ArrayList<WriterListener>();
|
||||
|
||||
public ObservableWriter(Writer wrappedWriter) {
|
||||
this.wrappedWriter = wrappedWriter;
|
||||
|
|
|
@ -307,7 +307,7 @@ public class PacketParserUtils {
|
|||
}
|
||||
else if (provider instanceof Class) {
|
||||
iqPacket = (IQ)PacketParserUtils.parseWithIntrospection(elementName,
|
||||
(Class)provider, parser);
|
||||
(Class<?>)provider, parser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -769,7 +769,7 @@ public class PacketParserUtils {
|
|||
}
|
||||
else if (provider instanceof Class) {
|
||||
return (PacketExtension)parseWithIntrospection(
|
||||
elementName, (Class)provider, parser);
|
||||
elementName, (Class<?>)provider, parser);
|
||||
}
|
||||
}
|
||||
// No providers registered, so use a default extension.
|
||||
|
@ -814,7 +814,7 @@ public class PacketParserUtils {
|
|||
}
|
||||
|
||||
public static Object parseWithIntrospection(String elementName,
|
||||
Class objectClass, XmlPullParser parser) throws Exception
|
||||
Class<?> objectClass, XmlPullParser parser) throws Exception
|
||||
{
|
||||
boolean done = false;
|
||||
Object object = objectClass.newInstance();
|
||||
|
@ -825,7 +825,7 @@ public class PacketParserUtils {
|
|||
String stringValue = parser.nextText();
|
||||
PropertyDescriptor descriptor = new PropertyDescriptor(name, objectClass);
|
||||
// Load the class type of the property.
|
||||
Class propertyType = descriptor.getPropertyType();
|
||||
Class<?> propertyType = descriptor.getPropertyType();
|
||||
// Get the value of the property by converting it from a
|
||||
// String to the correct object type.
|
||||
Object value = decode(propertyType, stringValue);
|
||||
|
@ -850,7 +850,7 @@ public class PacketParserUtils {
|
|||
* @return the String value decoded into the specified type.
|
||||
* @throws Exception If decoding failed due to an error.
|
||||
*/
|
||||
private static Object decode(Class type, String value) throws Exception {
|
||||
private static Object decode(Class<?> type, String value) throws Exception {
|
||||
if (type.getName().equals("java.lang.String")) {
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -389,8 +389,8 @@ public class Form {
|
|||
public String getInstructions() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// Join the list of instructions together separated by newlines
|
||||
for (Iterator it = dataForm.getInstructions(); it.hasNext();) {
|
||||
sb.append((String) it.next());
|
||||
for (Iterator<String> it = dataForm.getInstructions(); it.hasNext();) {
|
||||
sb.append(it.next());
|
||||
// If this is not the last instruction then append a newline
|
||||
if (it.hasNext()) {
|
||||
sb.append("\n");
|
||||
|
|
|
@ -292,8 +292,8 @@ public class FormField {
|
|||
buf.append("<value>").append(i.next()).append("</value>");
|
||||
}
|
||||
// Loop through all the values and append them to the string buffer
|
||||
for (Iterator i = getOptions(); i.hasNext();) {
|
||||
buf.append(((Option) i.next()).toXML());
|
||||
for (Iterator<Option> i = getOptions(); i.hasNext();) {
|
||||
buf.append((i.next()).toXML());
|
||||
}
|
||||
buf.append("</field>");
|
||||
return buf.toString();
|
||||
|
|
|
@ -206,18 +206,18 @@ public class MessageEventManager {
|
|||
(MessageEvent) message.getExtension("x", "jabber:x:event");
|
||||
if (messageEvent.isMessageEventRequest()) {
|
||||
// Fire event for requests of message events
|
||||
for (Iterator it = messageEvent.getEventTypes(); it.hasNext();)
|
||||
for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
|
||||
fireMessageEventRequestListeners(
|
||||
message.getFrom(),
|
||||
message.getPacketID(),
|
||||
((String) it.next()).concat("NotificationRequested"));
|
||||
it.next().concat("NotificationRequested"));
|
||||
} else
|
||||
// Fire event for notifications of message events
|
||||
for (Iterator it = messageEvent.getEventTypes(); it.hasNext();)
|
||||
for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
|
||||
fireMessageEventNotificationListeners(
|
||||
message.getFrom(),
|
||||
messageEvent.getPacketID(),
|
||||
((String) it.next()).concat("Notification"));
|
||||
it.next().concat("Notification"));
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public class MultipleRecipientInfo {
|
|||
*
|
||||
* @return list of primary recipients of the packet.
|
||||
*/
|
||||
public List getTOAddresses() {
|
||||
public List<MultipleAddresses.Address> getTOAddresses() {
|
||||
return extension.getAddressesOfType(MultipleAddresses.TO);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class MultipleRecipientInfo {
|
|||
*
|
||||
* @return list of secondary recipients of the packet.
|
||||
*/
|
||||
public List getCCAddresses() {
|
||||
public List<MultipleAddresses.Address> getCCAddresses() {
|
||||
return extension.getAddressesOfType(MultipleAddresses.CC);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class MultipleRecipientInfo {
|
|||
* no specific address was provided.
|
||||
*/
|
||||
public String getReplyRoom() {
|
||||
List replyRoom = extension.getAddressesOfType(MultipleAddresses.REPLY_ROOM);
|
||||
List<MultipleAddresses.Address> replyRoom = extension.getAddressesOfType(MultipleAddresses.REPLY_ROOM);
|
||||
return replyRoom.isEmpty() ? null : ((MultipleAddresses.Address) replyRoom.get(0)).getJid();
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class MultipleRecipientInfo {
|
|||
* no specific address was provided.
|
||||
*/
|
||||
public MultipleAddresses.Address getReplyAddress() {
|
||||
List replyTo = extension.getAddressesOfType(MultipleAddresses.REPLY_TO);
|
||||
List<MultipleAddresses.Address> replyTo = extension.getAddressesOfType(MultipleAddresses.REPLY_TO);
|
||||
return replyTo.isEmpty() ? null : (MultipleAddresses.Address) replyTo.get(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MultipleRecipientManager {
|
|||
* Create a cache to hold the 100 most recently accessed elements for a period of
|
||||
* 24 hours.
|
||||
*/
|
||||
private static Cache services = new Cache(100, 24 * 60 * 60 * 1000);
|
||||
private static Cache<String, String> services = new Cache<String, String>(100, 24 * 60 * 60 * 1000);
|
||||
|
||||
/**
|
||||
* Sends the specified packet to the list of specified recipients using the
|
||||
|
@ -67,7 +67,7 @@ public class MultipleRecipientManager {
|
|||
* @throws XMPPException if server does not support JEP-33: Extended Stanza Addressing and
|
||||
* some JEP-33 specific features were requested.
|
||||
*/
|
||||
public static void send(Connection connection, Packet packet, List to, List cc, List bcc)
|
||||
public static void send(Connection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc)
|
||||
throws XMPPException {
|
||||
send(connection, packet, to, cc, bcc, null, null, false);
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class MultipleRecipientManager {
|
|||
* @throws XMPPException if server does not support JEP-33: Extended Stanza Addressing and
|
||||
* some JEP-33 specific features were requested.
|
||||
*/
|
||||
public static void send(Connection connection, Packet packet, List to, List cc, List bcc,
|
||||
public static void send(Connection connection, Packet packet, List<String> to, List<String> cc, List<String> bcc,
|
||||
String replyTo, String replyRoom, boolean noReply) throws XMPPException {
|
||||
String serviceAddress = getMultipleRecipienServiceAddress(connection);
|
||||
if (serviceAddress != null) {
|
||||
|
@ -151,14 +151,14 @@ public class MultipleRecipientManager {
|
|||
}
|
||||
else {
|
||||
// Send reply to multiple recipients
|
||||
List to = new ArrayList();
|
||||
List cc = new ArrayList();
|
||||
for (Iterator it = info.getTOAddresses().iterator(); it.hasNext();) {
|
||||
String jid = ((MultipleAddresses.Address) it.next()).getJid();
|
||||
List<String> to = new ArrayList<String>();
|
||||
List<String> cc = new ArrayList<String>();
|
||||
for (Iterator<MultipleAddresses.Address> it = info.getTOAddresses().iterator(); it.hasNext();) {
|
||||
String jid = it.next().getJid();
|
||||
to.add(jid);
|
||||
}
|
||||
for (Iterator it = info.getCCAddresses().iterator(); it.hasNext();) {
|
||||
String jid = ((MultipleAddresses.Address) it.next()).getJid();
|
||||
for (Iterator<MultipleAddresses.Address> it = info.getCCAddresses().iterator(); it.hasNext();) {
|
||||
String jid = it.next().getJid();
|
||||
cc.add(jid);
|
||||
}
|
||||
// Add original sender as a 'to' address (if not already present)
|
||||
|
@ -202,50 +202,50 @@ public class MultipleRecipientManager {
|
|||
}
|
||||
|
||||
private static void sendToIndividualRecipients(Connection connection, Packet packet,
|
||||
List to, List cc, List bcc) {
|
||||
List<String> to, List<String> cc, List<String> bcc) {
|
||||
if (to != null) {
|
||||
for (Iterator it = to.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = to.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (cc != null) {
|
||||
for (Iterator it = cc.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = cc.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
if (bcc != null) {
|
||||
for (Iterator it = bcc.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = bcc.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
packet.setTo(jid);
|
||||
connection.sendPacket(new PacketCopy(packet.toXML()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendThroughService(Connection connection, Packet packet, List to,
|
||||
List cc, List bcc, String replyTo, String replyRoom, boolean noReply,
|
||||
private static void sendThroughService(Connection connection, Packet packet, List<String> to,
|
||||
List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply,
|
||||
String serviceAddress) {
|
||||
// Create multiple recipient extension
|
||||
MultipleAddresses multipleAddresses = new MultipleAddresses();
|
||||
if (to != null) {
|
||||
for (Iterator it = to.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = to.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
multipleAddresses.addAddress(MultipleAddresses.TO, jid, null, null, false, null);
|
||||
}
|
||||
}
|
||||
if (cc != null) {
|
||||
for (Iterator it = cc.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = cc.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
multipleAddresses.addAddress(MultipleAddresses.CC, jid, null, null, false, null);
|
||||
}
|
||||
}
|
||||
if (bcc != null) {
|
||||
for (Iterator it = bcc.iterator(); it.hasNext();) {
|
||||
String jid = (String) it.next();
|
||||
for (Iterator<String> it = bcc.iterator(); it.hasNext();) {
|
||||
String jid = it.next();
|
||||
multipleAddresses.addAddress(MultipleAddresses.BCC, jid, null, null, false, null);
|
||||
}
|
||||
}
|
||||
|
@ -300,8 +300,8 @@ public class MultipleRecipientManager {
|
|||
// Get the disco items and send the disco packet to each server item
|
||||
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection)
|
||||
.discoverItems(serviceName);
|
||||
for (Iterator it = items.getItems(); it.hasNext();) {
|
||||
DiscoverItems.Item item = (DiscoverItems.Item) it.next();
|
||||
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
|
||||
DiscoverItems.Item item = it.next();
|
||||
info = ServiceDiscoveryManager.getInstanceFor(connection)
|
||||
.discoverInfo(item.getEntityID(), item.getNode());
|
||||
if (info.containsFeature("http://jabber.org/protocol/address")) {
|
||||
|
|
|
@ -113,8 +113,8 @@ public class OfflineMessageManager {
|
|||
List<OfflineMessageHeader> answer = new ArrayList<OfflineMessageHeader>();
|
||||
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
|
||||
null, namespace);
|
||||
for (Iterator it = items.getItems(); it.hasNext();) {
|
||||
DiscoverItems.Item item = (DiscoverItems.Item) it.next();
|
||||
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
|
||||
DiscoverItems.Item item = it.next();
|
||||
answer.add(new OfflineMessageHeader(item));
|
||||
}
|
||||
return answer.iterator();
|
||||
|
|
|
@ -62,7 +62,7 @@ public class PrivateDataManager {
|
|||
/**
|
||||
* Map of provider instances.
|
||||
*/
|
||||
private static Map privateDataProviders = new Hashtable();
|
||||
private static Map<String, PrivateDataProvider> privateDataProviders = new Hashtable<String, PrivateDataProvider>();
|
||||
|
||||
/**
|
||||
* Returns the private data provider registered to the specified XML element name and namespace.
|
||||
|
|
|
@ -77,7 +77,7 @@ public class RemoteRosterEntry {
|
|||
*
|
||||
* @return an Iterator for the group names.
|
||||
*/
|
||||
public Iterator getGroupNames() {
|
||||
public Iterator<String> getGroupNames() {
|
||||
synchronized (groupNames) {
|
||||
return Collections.unmodifiableList(groupNames).iterator();
|
||||
}
|
||||
|
|
|
@ -37,6 +37,6 @@ public interface RosterExchangeListener {
|
|||
* @param remoteRosterEntries the entries sent by the user. The entries are instances of
|
||||
* RemoteRosterEntry.
|
||||
*/
|
||||
public void entriesReceived(String from, Iterator remoteRosterEntries);
|
||||
public void entriesReceived(String from, Iterator<RemoteRosterEntry> remoteRosterEntries);
|
||||
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ public class RosterExchangeManager {
|
|||
/**
|
||||
* Fires roster exchange listeners.
|
||||
*/
|
||||
private void fireRosterExchangeListeners(String from, Iterator remoteRosterEntries) {
|
||||
private void fireRosterExchangeListeners(String from, Iterator<RemoteRosterEntry> remoteRosterEntries) {
|
||||
RosterExchangeListener[] listeners = null;
|
||||
synchronized (rosterExchangeListeners) {
|
||||
listeners = new RosterExchangeListener[rosterExchangeListeners.size()];
|
||||
|
|
|
@ -27,7 +27,7 @@ public class SharedGroupManager {
|
|||
* @param connection connection to use to get the user's shared groups.
|
||||
* @return collection with the shared groups' name of the logged user.
|
||||
*/
|
||||
public static List getSharedGroups(Connection connection) throws XMPPException {
|
||||
public static List<String> getSharedGroups(Connection connection) throws XMPPException {
|
||||
// Discover the shared groups of the logged user
|
||||
SharedGroupsInfo info = new SharedGroupsInfo();
|
||||
info.setType(IQ.Type.GET);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class XHTMLManager {
|
|||
* @param message an XHTML message
|
||||
* @return an Iterator for the bodies in the message or null if none.
|
||||
*/
|
||||
public static Iterator getBodies(Message message) {
|
||||
public static Iterator<String> getBodies(Message message) {
|
||||
XHTMLExtension xhtmlExtension = (XHTMLExtension) message.getExtension("html", namespace);
|
||||
if (xhtmlExtension != null)
|
||||
return xhtmlExtension.getBodies();
|
||||
|
|
|
@ -138,10 +138,10 @@ public class AdHocCommandManager {
|
|||
* @param name the human readable name of the command.
|
||||
* @param clazz the class of the command, which must extend {@link LocalCommand}.
|
||||
*/
|
||||
public void registerCommand(String node, String name, final Class clazz) {
|
||||
public void registerCommand(String node, String name, final Class<? extends LocalCommand> clazz) {
|
||||
registerCommand(node, name, new LocalCommandFactory() {
|
||||
public LocalCommand getInstance() throws InstantiationException, IllegalAccessException {
|
||||
return (LocalCommand)clazz.newInstance();
|
||||
return clazz.newInstance();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -258,7 +258,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
|||
return false;
|
||||
}
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
public Class<?> getColumnClass(int columnIndex) {
|
||||
if (columnIndex == 2 || columnIndex == 3) {
|
||||
return Icon.class;
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ public class EnhancedDebuggerWindow {
|
|||
Vector<String> providers = new Vector<String>();
|
||||
for (Object provider : ProviderManager.getInstance().getIQProviders()) {
|
||||
if (provider.getClass() == Class.class) {
|
||||
providers.add(((Class) provider).getName());
|
||||
providers.add(((Class<?>) provider).getName());
|
||||
}
|
||||
else {
|
||||
providers.add(provider.getClass().getName());
|
||||
|
@ -245,7 +245,7 @@ public class EnhancedDebuggerWindow {
|
|||
providers = new Vector<String>();
|
||||
for (Object provider : ProviderManager.getInstance().getExtensionProviders()) {
|
||||
if (provider.getClass() == Class.class) {
|
||||
providers.add(((Class) provider).getName());
|
||||
providers.add(((Class<?>) provider).getName());
|
||||
}
|
||||
else {
|
||||
providers.add(provider.getClass().getName());
|
||||
|
|
|
@ -1703,8 +1703,8 @@ public class MultiUserChat {
|
|||
}
|
||||
// Get the list of affiliates from the server's answer
|
||||
List<Affiliate> affiliates = new ArrayList<Affiliate>();
|
||||
for (Iterator it = answer.getItems(); it.hasNext();) {
|
||||
affiliates.add(new Affiliate((MUCOwner.Item) it.next()));
|
||||
for (Iterator<MUCOwner.Item> it = answer.getItems(); it.hasNext();) {
|
||||
affiliates.add(new Affiliate(it.next()));
|
||||
}
|
||||
return affiliates;
|
||||
}
|
||||
|
@ -1744,8 +1744,8 @@ public class MultiUserChat {
|
|||
}
|
||||
// Get the list of affiliates from the server's answer
|
||||
List<Affiliate> affiliates = new ArrayList<Affiliate>();
|
||||
for (Iterator it = answer.getItems(); it.hasNext();) {
|
||||
affiliates.add(new Affiliate((MUCAdmin.Item) it.next()));
|
||||
for (Iterator<MUCAdmin.Item> it = answer.getItems(); it.hasNext();) {
|
||||
affiliates.add(new Affiliate(it.next()));
|
||||
}
|
||||
return affiliates;
|
||||
}
|
||||
|
@ -1806,8 +1806,8 @@ public class MultiUserChat {
|
|||
}
|
||||
// Get the list of participants from the server's answer
|
||||
List<Occupant> participants = new ArrayList<Occupant>();
|
||||
for (Iterator it = answer.getItems(); it.hasNext();) {
|
||||
participants.add(new Occupant((MUCAdmin.Item) it.next()));
|
||||
for (Iterator<MUCAdmin.Item> it = answer.getItems(); it.hasNext();) {
|
||||
participants.add(new Occupant(it.next()));
|
||||
}
|
||||
return participants;
|
||||
}
|
||||
|
@ -2035,7 +2035,7 @@ public class MultiUserChat {
|
|||
userStatusListeners.toArray(listeners);
|
||||
}
|
||||
// Get the classes of the method parameters
|
||||
Class[] paramClasses = new Class[params.length];
|
||||
Class<?>[] paramClasses = new Class[params.length];
|
||||
for (int i = 0; i < params.length; i++) {
|
||||
paramClasses[i] = params[i].getClass();
|
||||
}
|
||||
|
@ -2088,7 +2088,7 @@ public class MultiUserChat {
|
|||
}
|
||||
try {
|
||||
// Get the method to execute based on the requested methodName and parameter
|
||||
Class[] classes = new Class[params.size()];
|
||||
Class<?>[] classes = new Class[params.size()];
|
||||
for (int i=0;i<params.size(); i++) {
|
||||
classes[i] = String.class;
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ public class DataForm implements PacketExtension {
|
|||
if (getTitle() != null) {
|
||||
buf.append("<title>").append(getTitle()).append("</title>");
|
||||
}
|
||||
for (Iterator it=getInstructions(); it.hasNext();) {
|
||||
for (Iterator<String> it=getInstructions(); it.hasNext();) {
|
||||
buf.append("<instructions>").append(it.next()).append("</instructions>");
|
||||
}
|
||||
// Append the list of fields returned from a search
|
||||
|
@ -210,13 +210,13 @@ public class DataForm implements PacketExtension {
|
|||
buf.append(getReportedData().toXML());
|
||||
}
|
||||
// Loop through all the items returned from a search and append them to the string buffer
|
||||
for (Iterator i = getItems(); i.hasNext();) {
|
||||
Item item = (Item) i.next();
|
||||
for (Iterator<Item> i = getItems(); i.hasNext();) {
|
||||
Item item = i.next();
|
||||
buf.append(item.toXML());
|
||||
}
|
||||
// Loop through all the form fields and append them to the string buffer
|
||||
for (Iterator i = getFields(); i.hasNext();) {
|
||||
FormField field = (FormField) i.next();
|
||||
for (Iterator<FormField> i = getFields(); i.hasNext();) {
|
||||
FormField field = i.next();
|
||||
buf.append(field.toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
|
@ -250,8 +250,8 @@ public class DataForm implements PacketExtension {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<reported>");
|
||||
// Loop through all the form items and append them to the string buffer
|
||||
for (Iterator i = getFields(); i.hasNext();) {
|
||||
FormField field = (FormField) i.next();
|
||||
for (Iterator<FormField> i = getFields(); i.hasNext();) {
|
||||
FormField field = i.next();
|
||||
buf.append(field.toXML());
|
||||
}
|
||||
buf.append("</reported>");
|
||||
|
@ -285,8 +285,8 @@ public class DataForm implements PacketExtension {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<item>");
|
||||
// Loop through all the form items and append them to the string buffer
|
||||
for (Iterator i = getFields(); i.hasNext();) {
|
||||
FormField field = (FormField) i.next();
|
||||
for (Iterator<FormField> i = getFields(); i.hasNext();) {
|
||||
FormField field = i.next();
|
||||
buf.append(field.toXML());
|
||||
}
|
||||
buf.append("</item>");
|
||||
|
|
|
@ -51,7 +51,7 @@ public class DefaultPrivateData implements PrivateData {
|
|||
|
||||
private String elementName;
|
||||
private String namespace;
|
||||
private Map map;
|
||||
private Map<String, String> map;
|
||||
|
||||
/**
|
||||
* Creates a new generic private data object.
|
||||
|
@ -85,8 +85,8 @@ public class DefaultPrivateData implements PrivateData {
|
|||
public String toXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<").append(elementName).append(" xmlns=\"").append(namespace).append("\">");
|
||||
for (Iterator i=getNames(); i.hasNext(); ) {
|
||||
String name = (String)i.next();
|
||||
for (Iterator<String> i=getNames(); i.hasNext(); ) {
|
||||
String name = i.next();
|
||||
String value = getValue(name);
|
||||
buf.append("<").append(name).append(">");
|
||||
buf.append(value);
|
||||
|
@ -102,11 +102,11 @@ public class DefaultPrivateData implements PrivateData {
|
|||
*
|
||||
* @return an Iterator for the names.
|
||||
*/
|
||||
public synchronized Iterator getNames() {
|
||||
public synchronized Iterator<String> getNames() {
|
||||
if (map == null) {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
return Collections.<String>emptyList().iterator();
|
||||
}
|
||||
return Collections.unmodifiableMap(new HashMap(map)).keySet().iterator();
|
||||
return Collections.unmodifiableSet(map.keySet()).iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,7 +130,7 @@ public class DefaultPrivateData implements PrivateData {
|
|||
*/
|
||||
public synchronized void setValue(String name, String value) {
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
map = new HashMap<String,String>();
|
||||
}
|
||||
map.put(name, value);
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
*/
|
||||
|
||||
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 org.jivesoftware.smack.packet.IQ;
|
||||
|
||||
/**
|
||||
* IQ packet that serves for kicking users, granting and revoking voice, banning users,
|
||||
* modifying the ban list, granting and revoking membership and granting and revoking
|
||||
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
*/
|
||||
public class MUCAdmin extends IQ {
|
||||
|
||||
private List items = new ArrayList();
|
||||
private List<Item> items = new ArrayList<Item>();
|
||||
|
||||
/**
|
||||
* Returns an Iterator for item childs that holds information about roles, affiliation,
|
||||
|
@ -45,9 +45,9 @@ public class MUCAdmin extends IQ {
|
|||
* @return an Iterator for item childs that holds information about roles, affiliation,
|
||||
* jids and nicks.
|
||||
*/
|
||||
public Iterator getItems() {
|
||||
public Iterator<Item> getItems() {
|
||||
synchronized (items) {
|
||||
return Collections.unmodifiableList(new ArrayList(items)).iterator();
|
||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class MUCAdmin extends IQ {
|
|||
buf.append("<query xmlns=\"http://jabber.org/protocol/muc#admin\">");
|
||||
synchronized (items) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Item item = (Item) items.get(i);
|
||||
Item item = items.get(i);
|
||||
buf.append(item.toXML());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.util.List;
|
|||
*/
|
||||
public class MUCOwner extends IQ {
|
||||
|
||||
private List items = new ArrayList();
|
||||
private List<Item> items = new ArrayList<Item>();
|
||||
private Destroy destroy;
|
||||
|
||||
/**
|
||||
|
@ -45,9 +45,9 @@ public class MUCOwner extends IQ {
|
|||
* @return an Iterator for item childs that holds information about affiliation,
|
||||
* jids and nicks.
|
||||
*/
|
||||
public Iterator getItems() {
|
||||
public Iterator<Item> getItems() {
|
||||
synchronized (items) {
|
||||
return Collections.unmodifiableList(new ArrayList(items)).iterator();
|
||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ public class MessageEvent implements PacketExtension {
|
|||
*
|
||||
* @return an iterator over all the types of events of the MessageEvent.
|
||||
*/
|
||||
public Iterator getEventTypes() {
|
||||
ArrayList allEvents = new ArrayList();
|
||||
public Iterator<String> getEventTypes() {
|
||||
ArrayList<String> allEvents = new ArrayList<String>();
|
||||
if (isDelivered()) {
|
||||
allEvents.add(MessageEvent.DELIVERED);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class MultipleAddresses implements PacketExtension {
|
|||
public static final String TO = "to";
|
||||
|
||||
|
||||
private List addresses = new ArrayList();
|
||||
private List<Address> addresses = new ArrayList<Address>();
|
||||
|
||||
/**
|
||||
* Adds a new address to which the packet is going to be sent or was sent.
|
||||
|
@ -84,9 +84,9 @@ public class MultipleAddresses implements PacketExtension {
|
|||
* @param type Examples of address type are: TO, CC, BCC, etc.
|
||||
* @return the list of addresses that matches the specified type.
|
||||
*/
|
||||
public List getAddressesOfType(String type) {
|
||||
List answer = new ArrayList(addresses.size());
|
||||
for (Iterator it = addresses.iterator(); it.hasNext();) {
|
||||
public List<Address> getAddressesOfType(String type) {
|
||||
List<Address> answer = new ArrayList<Address>(addresses.size());
|
||||
for (Iterator<Address> it = addresses.iterator(); it.hasNext();) {
|
||||
Address address = (Address) it.next();
|
||||
if (address.getType().equals(type)) {
|
||||
answer.add(address);
|
||||
|
@ -109,7 +109,7 @@ public class MultipleAddresses implements PacketExtension {
|
|||
buf.append("<").append(getElementName());
|
||||
buf.append(" xmlns=\"").append(getNamespace()).append("\">");
|
||||
// Loop through all the addresses and append them to the string buffer
|
||||
for (Iterator i = addresses.iterator(); i.hasNext();) {
|
||||
for (Iterator<Address> i = addresses.iterator(); i.hasNext();) {
|
||||
Address address = (Address) i.next();
|
||||
buf.append(address.toXML());
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import java.util.List;
|
|||
*/
|
||||
public class OfflineMessageRequest extends IQ {
|
||||
|
||||
private List items = new ArrayList();
|
||||
private List<Item> items = new ArrayList<Item>();
|
||||
private boolean purge = false;
|
||||
private boolean fetch = false;
|
||||
|
||||
|
@ -48,9 +48,9 @@ public class OfflineMessageRequest extends IQ {
|
|||
* @return an Iterator for item childs that holds information about offline messages to
|
||||
* view or delete.
|
||||
*/
|
||||
public Iterator getItems() {
|
||||
public Iterator<Item> getItems() {
|
||||
synchronized (items) {
|
||||
return Collections.unmodifiableList(new ArrayList(items)).iterator();
|
||||
return Collections.unmodifiableList(new ArrayList<Item>(items)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ public class OfflineMessageRequest extends IQ {
|
|||
buf.append("<offline xmlns=\"http://jabber.org/protocol/offline\">");
|
||||
synchronized (items) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
Item item = (Item) items.get(i);
|
||||
Item item = items.get(i);
|
||||
buf.append(item.toXML());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ import java.util.List;
|
|||
*/
|
||||
public class RosterExchange implements PacketExtension {
|
||||
|
||||
private List remoteRosterEntries = new ArrayList();
|
||||
private List<RemoteRosterEntry> remoteRosterEntries = new ArrayList<RemoteRosterEntry>();
|
||||
|
||||
/**
|
||||
* Creates a new empty roster exchange package.
|
||||
|
@ -132,9 +132,9 @@ public class RosterExchange implements PacketExtension {
|
|||
*
|
||||
* @return an Iterator for the roster entries in the packet.
|
||||
*/
|
||||
public Iterator getRosterEntries() {
|
||||
public Iterator<RemoteRosterEntry> getRosterEntries() {
|
||||
synchronized (remoteRosterEntries) {
|
||||
List entries = Collections.unmodifiableList(new ArrayList(remoteRosterEntries));
|
||||
List<RemoteRosterEntry> entries = Collections.unmodifiableList(new ArrayList<RemoteRosterEntry>(remoteRosterEntries));
|
||||
return entries.iterator();
|
||||
}
|
||||
}
|
||||
|
@ -170,8 +170,8 @@ public class RosterExchange implements PacketExtension {
|
|||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
||||
"\">");
|
||||
// Loop through all roster entries and append them to the string buffer
|
||||
for (Iterator i = getRosterEntries(); i.hasNext();) {
|
||||
RemoteRosterEntry remoteRosterEntry = (RemoteRosterEntry) i.next();
|
||||
for (Iterator<RemoteRosterEntry> i = getRosterEntries(); i.hasNext();) {
|
||||
RemoteRosterEntry remoteRosterEntry = i.next();
|
||||
buf.append(remoteRosterEntry.toXML());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
|
|
|
@ -19,21 +19,21 @@ import java.util.List;
|
|||
*/
|
||||
public class SharedGroupsInfo extends IQ {
|
||||
|
||||
private List groups = new ArrayList();
|
||||
private List<String> groups = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Returns a collection with the shared group names returned from the server.
|
||||
*
|
||||
* @return collection with the shared group names returned from the server.
|
||||
*/
|
||||
public List getGroups() {
|
||||
public List<String> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public String getChildElementXML() {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append("<sharedgroup xmlns=\"http://www.jivesoftware.org/protocol/sharedgroup\">");
|
||||
for (Iterator it=groups.iterator(); it.hasNext();) {
|
||||
for (Iterator<String> it=groups.iterator(); it.hasNext();) {
|
||||
buf.append("<group>").append(it.next()).append("</group>");
|
||||
}
|
||||
buf.append("</sharedgroup>");
|
||||
|
|
|
@ -20,16 +20,6 @@
|
|||
|
||||
package org.jivesoftware.smackx.packet;
|
||||
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
@ -42,6 +32,17 @@ import java.security.NoSuchAlgorithmException;
|
|||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.PacketCollector;
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
/**
|
||||
* A VCard class for use with the
|
||||
|
@ -740,14 +741,14 @@ public class VCard extends IQ {
|
|||
}
|
||||
|
||||
private void appendPhones(Map<String, String> phones, final String code) {
|
||||
Iterator it = phones.entrySet().iterator();
|
||||
Iterator<Map.Entry<String, String>> it = phones.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
final Map.Entry entry = (Map.Entry) it.next();
|
||||
final Map.Entry<String,String> entry = it.next();
|
||||
appendTag("TEL", true, new ContentBuilder() {
|
||||
public void addTagContent() {
|
||||
appendEmptyTag(entry.getKey());
|
||||
appendEmptyTag(code);
|
||||
appendTag("NUMBER", StringUtils.escapeForXML((String) entry.getValue()));
|
||||
appendTag("NUMBER", StringUtils.escapeForXML(entry.getValue()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -759,10 +760,10 @@ public class VCard extends IQ {
|
|||
public void addTagContent() {
|
||||
appendEmptyTag(code);
|
||||
|
||||
Iterator it = addr.entrySet().iterator();
|
||||
Iterator<Map.Entry<String, String>> it = addr.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
final Map.Entry entry = (Map.Entry) it.next();
|
||||
appendTag((String) entry.getKey(), StringUtils.escapeForXML((String) entry.getValue()));
|
||||
final Entry<String, String> entry = it.next();
|
||||
appendTag(entry.getKey(), StringUtils.escapeForXML(entry.getValue()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -774,17 +775,17 @@ public class VCard extends IQ {
|
|||
}
|
||||
|
||||
private void appendGenericFields() {
|
||||
Iterator it = otherSimpleFields.entrySet().iterator();
|
||||
Iterator<Map.Entry<String, String>> it = otherSimpleFields.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
Map.Entry<String, String> entry = it.next();
|
||||
appendTag(entry.getKey().toString(),
|
||||
StringUtils.escapeForXML((String) entry.getValue()));
|
||||
StringUtils.escapeForXML(entry.getValue()));
|
||||
}
|
||||
|
||||
it = otherUnescapableFields.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
appendTag(entry.getKey().toString(), (String) entry.getValue());
|
||||
Map.Entry<String, String> entry = it.next();
|
||||
appendTag(entry.getKey().toString(),entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ import java.util.List;
|
|||
*/
|
||||
public class XHTMLExtension implements PacketExtension {
|
||||
|
||||
private List bodies = new ArrayList();
|
||||
private List<String> bodies = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Returns the XML element name of the extension sub-packet root element.
|
||||
|
@ -85,8 +85,8 @@ public class XHTMLExtension implements PacketExtension {
|
|||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
|
||||
"\">");
|
||||
// Loop through all the bodies and append them to the string buffer
|
||||
for (Iterator i = getBodies(); i.hasNext();) {
|
||||
buf.append((String) i.next());
|
||||
for (Iterator<String> i = getBodies(); i.hasNext();) {
|
||||
buf.append(i.next());
|
||||
}
|
||||
buf.append("</").append(getElementName()).append(">");
|
||||
return buf.toString();
|
||||
|
@ -97,9 +97,9 @@ public class XHTMLExtension implements PacketExtension {
|
|||
*
|
||||
* @return an Iterator for the bodies in the packet.
|
||||
*/
|
||||
public Iterator getBodies() {
|
||||
public Iterator<String> getBodies() {
|
||||
synchronized (bodies) {
|
||||
return Collections.unmodifiableList(new ArrayList(bodies)).iterator();
|
||||
return Collections.unmodifiableList(new ArrayList<String>(bodies)).iterator();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ public class DataFormProvider implements PacketExtensionProvider {
|
|||
|
||||
private DataForm.Item parseItem(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
List fields = new ArrayList();
|
||||
List<FormField> fields = new ArrayList<FormField>();
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
|
@ -123,7 +123,7 @@ public class DataFormProvider implements PacketExtensionProvider {
|
|||
|
||||
private DataForm.ReportedData parseReported(XmlPullParser parser) throws Exception {
|
||||
boolean done = false;
|
||||
List fields = new ArrayList();
|
||||
List<FormField> fields = new ArrayList<FormField>();
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
|
|
|
@ -57,13 +57,13 @@ public class RosterExchangeProvider implements PacketExtensionProvider {
|
|||
RemoteRosterEntry remoteRosterEntry = null;
|
||||
String jid = "";
|
||||
String name = "";
|
||||
ArrayList groupsName = new ArrayList();
|
||||
ArrayList<String> groupsName = new ArrayList<String>();
|
||||
while (!done) {
|
||||
int eventType = parser.next();
|
||||
if (eventType == XmlPullParser.START_TAG) {
|
||||
if (parser.getName().equals("item")) {
|
||||
// Reset this variable since they are optional for each item
|
||||
groupsName = new ArrayList();
|
||||
groupsName = new ArrayList<String>();
|
||||
// Initialize the variables from the parsed XML
|
||||
jid = parser.getAttributeValue("", "jid");
|
||||
name = parser.getAttributeValue("", "name");
|
||||
|
|
|
@ -184,8 +184,8 @@ public class VCardProvider implements IQProvider {
|
|||
Element addressNode = (Element) allAddresses.item(i);
|
||||
|
||||
String type = null;
|
||||
List code = new ArrayList();
|
||||
List value = new ArrayList();
|
||||
List<String> code = new ArrayList<String>();
|
||||
List<String> value = new ArrayList<String>();
|
||||
NodeList childNodes = addressNode.getChildNodes();
|
||||
for (int j = 0; j < childNodes.getLength(); j++) {
|
||||
Node node = childNodes.item(j);
|
||||
|
|
|
@ -37,7 +37,7 @@ abstract public class Node
|
|||
protected String id;
|
||||
protected String to;
|
||||
|
||||
protected ConcurrentHashMap<ItemEventListener, PacketListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener, PacketListener>();
|
||||
protected ConcurrentHashMap<ItemEventListener<Item>, PacketListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, PacketListener>();
|
||||
protected ConcurrentHashMap<ItemDeleteListener, PacketListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, PacketListener>();
|
||||
protected ConcurrentHashMap<NodeConfigListener, PacketListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, PacketListener>();
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import org.jivesoftware.smack.Connection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smackx.Form;
|
||||
import org.jivesoftware.smackx.FormField;
|
||||
import org.jivesoftware.smackx.ServiceDiscoveryManager;
|
||||
|
@ -149,7 +149,7 @@ final public class PubSubManager
|
|||
* @return the node
|
||||
* @throws XMPPException The node does not exist
|
||||
*/
|
||||
public Node getNode(String id)
|
||||
public <T extends Node> T getNode(String id)
|
||||
throws XMPPException
|
||||
{
|
||||
Node node = nodeMap.get(id);
|
||||
|
@ -169,7 +169,7 @@ final public class PubSubManager
|
|||
node.setTo(to);
|
||||
nodeMap.put(id, node);
|
||||
}
|
||||
return node;
|
||||
return (T) node;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -122,9 +122,9 @@ class SimpleUserSearch extends IQ {
|
|||
fields.add(field);
|
||||
|
||||
boolean exists = false;
|
||||
Iterator cols = data.getColumns();
|
||||
Iterator<ReportedData.Column> cols = data.getColumns();
|
||||
while (cols.hasNext()) {
|
||||
ReportedData.Column column = (ReportedData.Column) cols.next();
|
||||
ReportedData.Column column = cols.next();
|
||||
if (column.getVariable().equals(name)) {
|
||||
exists = true;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public class UserSearchManager {
|
|||
* @return a Collection of search services found on the server.
|
||||
* @throws XMPPException thrown if a server error has occurred.
|
||||
*/
|
||||
public Collection getSearchServices() throws XMPPException {
|
||||
public Collection<String> getSearchServices() throws XMPPException {
|
||||
final List<String> searchServices = new ArrayList<String>();
|
||||
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
|
||||
DiscoverItems items = discoManager.discoverItems(con.getServiceName());
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.util.MetaDataUtils;
|
||||
|
@ -40,16 +41,16 @@ public class MetaData implements PacketExtension {
|
|||
*/
|
||||
public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
|
||||
|
||||
private Map metaData;
|
||||
private Map<String, List<String>> metaData;
|
||||
|
||||
public MetaData(Map metaData) {
|
||||
public MetaData(Map<String, List<String>> metaData) {
|
||||
this.metaData = metaData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Map of metadata contained by this instance
|
||||
*/
|
||||
public Map getMetaData() {
|
||||
public Map<String, List<String>> getMetaData() {
|
||||
return metaData;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +37,7 @@ public class WorkgroupInvitation {
|
|||
protected String issuingWorkgroupName;
|
||||
protected String messageBody;
|
||||
protected String invitationSender;
|
||||
protected Map metaData;
|
||||
protected Map<String, List<String>> metaData;
|
||||
|
||||
/**
|
||||
* This calls the 5-argument constructor with a null MetaData argument value
|
||||
|
@ -65,7 +66,7 @@ public class WorkgroupInvitation {
|
|||
* @param metaData the metadata sent with the invitation
|
||||
*/
|
||||
public WorkgroupInvitation (String jid, String group, String workgroup, String sessID, String msgBody,
|
||||
String from, Map metaData) {
|
||||
String from, Map<String, List<String>> metaData) {
|
||||
super();
|
||||
|
||||
this.uniqueID = jid;
|
||||
|
@ -126,7 +127,7 @@ public class WorkgroupInvitation {
|
|||
* @return the meta data associated with the invitation, or null if this instance was
|
||||
* constructed with none
|
||||
*/
|
||||
public Map getMetaData () {
|
||||
public Map<String, List<String>> getMetaData () {
|
||||
return this.metaData;
|
||||
}
|
||||
|
||||
|
|
|
@ -318,8 +318,8 @@ public class AgentRoster {
|
|||
}
|
||||
// Fire an event.
|
||||
synchronized (entries) {
|
||||
for (Iterator i = entries.iterator(); i.hasNext();) {
|
||||
String entry = (String)i.next();
|
||||
for (Iterator<String> i = entries.iterator(); i.hasNext();) {
|
||||
String entry = i.next();
|
||||
if (entry.toLowerCase().equals(StringUtils.parseBareAddress(key).toLowerCase())) {
|
||||
fireEvent(EVENT_PRESENCE_CHANGED, packet);
|
||||
}
|
||||
|
@ -358,8 +358,8 @@ public class AgentRoster {
|
|||
public void processPacket(Packet packet) {
|
||||
if (packet instanceof AgentStatusRequest) {
|
||||
AgentStatusRequest statusRequest = (AgentStatusRequest)packet;
|
||||
for (Iterator i = statusRequest.getAgents().iterator(); i.hasNext();) {
|
||||
AgentStatusRequest.Item item = (AgentStatusRequest.Item)i.next();
|
||||
for (Iterator<AgentStatusRequest.Item> i = statusRequest.getAgents().iterator(); i.hasNext();) {
|
||||
AgentStatusRequest.Item item = i.next();
|
||||
String agentJID = item.getJID();
|
||||
if ("remove".equals(item.getType())) {
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.jivesoftware.smackx.workgroup.agent;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.MetaData;
|
||||
import org.jivesoftware.smackx.workgroup.QueueUser;
|
||||
import org.jivesoftware.smackx.workgroup.WorkgroupInvitation;
|
||||
import org.jivesoftware.smackx.workgroup.WorkgroupInvitationListener;
|
||||
import org.jivesoftware.smackx.workgroup.ext.history.AgentChatHistory;
|
||||
|
@ -60,7 +61,7 @@ public class AgentSession {
|
|||
private boolean online = false;
|
||||
private Presence.Mode presenceMode;
|
||||
private int maxChats;
|
||||
private final Map<String, String> metaData;
|
||||
private final Map<String, List<String>> metaData;
|
||||
|
||||
private Map<String, WorkgroupQueue> queues;
|
||||
|
||||
|
@ -96,7 +97,7 @@ public class AgentSession {
|
|||
|
||||
this.maxChats = -1;
|
||||
|
||||
this.metaData = new HashMap<String, String>();
|
||||
this.metaData = new HashMap<String, List<String>>();
|
||||
|
||||
this.queues = new HashMap<String, WorkgroupQueue>();
|
||||
|
||||
|
@ -199,10 +200,10 @@ public class AgentSession {
|
|||
*/
|
||||
public void setMetaData(String key, String val) throws XMPPException {
|
||||
synchronized (this.metaData) {
|
||||
String oldVal = (String)this.metaData.get(key);
|
||||
List<String> oldVals = metaData.get(key);
|
||||
|
||||
if ((oldVal == null) || (!oldVal.equals(val))) {
|
||||
metaData.put(key, val);
|
||||
if ((oldVals == null) || (!oldVals.get(0).equals(val))) {
|
||||
oldVals.set(0, val);
|
||||
|
||||
setStatus(presenceMode, maxChats);
|
||||
}
|
||||
|
@ -218,7 +219,7 @@ public class AgentSession {
|
|||
*/
|
||||
public void removeMetaData(String key) throws XMPPException {
|
||||
synchronized (this.metaData) {
|
||||
String oldVal = (String)metaData.remove(key);
|
||||
List<String> oldVal = metaData.remove(key);
|
||||
|
||||
if (oldVal != null) {
|
||||
setStatus(presenceMode, maxChats);
|
||||
|
@ -233,8 +234,8 @@ public class AgentSession {
|
|||
* @return the meta data value associated with the key or <tt>null</tt> if the meta-data
|
||||
* doesn't exist..
|
||||
*/
|
||||
public String getMetaData(String key) {
|
||||
return (String)metaData.get(key);
|
||||
public List<String> getMetaData(String key) {
|
||||
return metaData.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -642,7 +643,7 @@ public class AgentSession {
|
|||
}
|
||||
|
||||
private void fireInvitationEvent(String groupChatJID, String sessionID, String body,
|
||||
String from, Map metaData) {
|
||||
String from, Map<String, List<String>> metaData) {
|
||||
WorkgroupInvitation invitation = new WorkgroupInvitation(connection.getUser(), groupChatJID,
|
||||
workgroupJID, sessionID, body, from, metaData);
|
||||
|
||||
|
@ -654,7 +655,7 @@ public class AgentSession {
|
|||
}
|
||||
|
||||
private void fireQueueUsersEvent(WorkgroupQueue queue, WorkgroupQueue.Status status,
|
||||
int averageWaitTime, Date oldestEntry, Set users) {
|
||||
int averageWaitTime, Date oldestEntry, Set<QueueUser> users) {
|
||||
synchronized (queueUsersListeners) {
|
||||
for (QueueUsersListener listener : queueUsersListeners) {
|
||||
if (status != null) {
|
||||
|
@ -754,7 +755,7 @@ public class AgentSession {
|
|||
MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null;
|
||||
if (invite != null && workgroupJID.equals(invite.getFrom())) {
|
||||
String sessionID = null;
|
||||
Map metaData = null;
|
||||
Map<String, List<String>> metaData = null;
|
||||
|
||||
SessionID sessionIDExt = (SessionID)message.getExtension(SessionID.ELEMENT_NAME,
|
||||
SessionID.NAMESPACE);
|
||||
|
@ -980,7 +981,7 @@ public class AgentSession {
|
|||
* @return Map a map of all metadata associated with the sessionID.
|
||||
* @throws XMPPException if an error occurs while getting information from the server.
|
||||
*/
|
||||
public Map getChatMetadata(String sessionID) throws XMPPException {
|
||||
public Map<String, List<String>> getChatMetadata(String sessionID) throws XMPPException {
|
||||
ChatMetadata request = new ChatMetadata();
|
||||
request.setType(IQ.Type.GET);
|
||||
request.setTo(workgroupJID);
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.jivesoftware.smack.packet.IQ;
|
|||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +45,7 @@ public class Offer {
|
|||
private String userID;
|
||||
private String workgroupName;
|
||||
private Date expiresDate;
|
||||
private Map metaData;
|
||||
private Map<String, List<String>> metaData;
|
||||
private OfferContent content;
|
||||
|
||||
private boolean accepted = false;
|
||||
|
@ -66,7 +67,7 @@ public class Offer {
|
|||
*/
|
||||
Offer(Connection conn, AgentSession agentSession, String userID,
|
||||
String userJID, String workgroupName, Date expiresDate,
|
||||
String sessionID, Map metaData, OfferContent content)
|
||||
String sessionID, Map<String, List<String>> metaData, OfferContent content)
|
||||
{
|
||||
this.connection = conn;
|
||||
this.session = agentSession;
|
||||
|
@ -155,7 +156,7 @@ public class Offer {
|
|||
*
|
||||
* @return the offer meta-data.
|
||||
*/
|
||||
public Map getMetaData() {
|
||||
public Map<String, List<String>> getMetaData() {
|
||||
return this.metaData;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ package org.jivesoftware.smackx.workgroup.agent;
|
|||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.QueueUser;
|
||||
|
||||
public interface QueueUsersListener {
|
||||
|
||||
/**
|
||||
|
@ -54,5 +56,5 @@ public interface QueueUsersListener {
|
|||
* @param queue the workgroup queue.
|
||||
* @param users the list of users waiting in the queue.
|
||||
*/
|
||||
public void usersUpdated(WorkgroupQueue queue, Set users);
|
||||
public void usersUpdated(WorkgroupQueue queue, Set<QueueUser> users);
|
||||
}
|
|
@ -21,6 +21,8 @@ package org.jivesoftware.smackx.workgroup.agent;
|
|||
|
||||
import java.util.*;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.QueueUser;
|
||||
|
||||
/**
|
||||
* A queue in a workgroup, which is a pool of agents that are routed a specific type of
|
||||
* chat request.
|
||||
|
@ -32,7 +34,7 @@ public class WorkgroupQueue {
|
|||
|
||||
private int averageWaitTime = -1;
|
||||
private Date oldestEntry = null;
|
||||
private Set users = Collections.EMPTY_SET;
|
||||
private Set<QueueUser> users = Collections.emptySet();
|
||||
|
||||
private int maxChats = 0;
|
||||
private int currentChats = 0;
|
||||
|
@ -87,14 +89,14 @@ public class WorkgroupQueue {
|
|||
*
|
||||
* @return an Iterator for the users waiting in the queue.
|
||||
*/
|
||||
public Iterator getUsers() {
|
||||
public Iterator<QueueUser> getUsers() {
|
||||
if (users == null) {
|
||||
return Collections.EMPTY_SET.iterator();
|
||||
return new HashSet<QueueUser>().iterator();
|
||||
}
|
||||
return Collections.unmodifiableSet(users).iterator();
|
||||
}
|
||||
|
||||
void setUsers(Set users) {
|
||||
void setUsers(Set<QueueUser> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class AgentChatHistory extends IQ {
|
|||
private int maxSessions;
|
||||
private long startDate;
|
||||
|
||||
private List agentChatSessions = new ArrayList();
|
||||
private List<AgentChatSession> agentChatSessions = new ArrayList<AgentChatSession>();
|
||||
|
||||
public AgentChatHistory(String agentJID, int maxSessions, Date startDate) {
|
||||
this.agentJID = agentJID;
|
||||
|
@ -58,7 +58,7 @@ public class AgentChatHistory extends IQ {
|
|||
agentChatSessions.add(chatSession);
|
||||
}
|
||||
|
||||
public Collection getAgentChatSessions() {
|
||||
public Collection<AgentChatSession> getAgentChatSessions() {
|
||||
return agentChatSessions;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.jivesoftware.smack.provider.IQProvider;
|
|||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatMetadata extends IQ {
|
||||
|
@ -51,13 +52,13 @@ public class ChatMetadata extends IQ {
|
|||
}
|
||||
|
||||
|
||||
private Map map = new HashMap();
|
||||
private Map<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
|
||||
public void setMetadata(Map metadata){
|
||||
public void setMetadata(Map<String, List<String>> metadata){
|
||||
this.map = metadata;
|
||||
}
|
||||
|
||||
public Map getMetadata(){
|
||||
public Map<String, List<String>> getMetadata(){
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -94,7 +95,7 @@ public class ChatMetadata extends IQ {
|
|||
chatM.setSessionID(parser.nextText());
|
||||
}
|
||||
else if (parser.getName().equals("metadata")) {
|
||||
Map map = MetaDataUtils.parseMetaData(parser);
|
||||
Map<String, List<String>> map = MetaDataUtils.parseMetaData(parser);
|
||||
chatM.setMetadata(map);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jivesoftware.smackx.workgroup.packet;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smackx.workgroup.MetaData;
|
||||
|
@ -41,7 +42,7 @@ public class MetaDataProvider implements PacketExtensionProvider {
|
|||
*/
|
||||
public PacketExtension parseExtension (XmlPullParser parser)
|
||||
throws Exception {
|
||||
Map metaData = MetaDataUtils.parseMetaData(parser);
|
||||
Map<String, List<String>> metaData = MetaDataUtils.parseMetaData(parser);
|
||||
|
||||
return new MetaData(metaData);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.jivesoftware.smack.util.PacketParserUtils;
|
|||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +50,7 @@ public class OfferRequestProvider implements IQProvider {
|
|||
int timeout = -1;
|
||||
OfferContent content = null;
|
||||
boolean done = false;
|
||||
Map metaData = new HashMap();
|
||||
Map<String, List<String>> metaData = new HashMap<String, List<String>>();
|
||||
|
||||
if (eventType != XmlPullParser.START_TAG) {
|
||||
// throw exception
|
||||
|
@ -111,11 +112,11 @@ public class OfferRequestProvider implements IQProvider {
|
|||
private int timeout;
|
||||
private String userID;
|
||||
private String userJID;
|
||||
private Map metaData;
|
||||
private Map<String, List<String>> metaData;
|
||||
private String sessionID;
|
||||
private OfferContent content;
|
||||
|
||||
public OfferRequestPacket(String userJID, String userID, int timeout, Map metaData,
|
||||
public OfferRequestPacket(String userJID, String userID, int timeout, Map<String, List<String>> metaData,
|
||||
String sessionID, OfferContent content)
|
||||
{
|
||||
this.userJID = userJID;
|
||||
|
@ -174,7 +175,7 @@ public class OfferRequestProvider implements IQProvider {
|
|||
*
|
||||
* @return meta-data associated with the offer.
|
||||
*/
|
||||
public Map getMetaData() {
|
||||
public Map<String, List<String>> getMetaData() {
|
||||
return this.metaData;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,12 +45,12 @@ public class ChatSettings extends IQ {
|
|||
*/
|
||||
public static final int BOT_SETTINGS = 2;
|
||||
|
||||
private List settings;
|
||||
private List<ChatSetting> settings;
|
||||
private String key;
|
||||
private int type = -1;
|
||||
|
||||
public ChatSettings() {
|
||||
settings = new ArrayList();
|
||||
settings = new ArrayList<ChatSetting>();
|
||||
}
|
||||
|
||||
public ChatSettings(String key) {
|
||||
|
@ -69,16 +69,16 @@ public class ChatSettings extends IQ {
|
|||
settings.add(setting);
|
||||
}
|
||||
|
||||
public Collection getSettings() {
|
||||
public Collection<ChatSetting> getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public ChatSetting getChatSetting(String key) {
|
||||
Collection col = getSettings();
|
||||
Collection<ChatSetting> col = getSettings();
|
||||
if (col != null) {
|
||||
Iterator iter = col.iterator();
|
||||
Iterator<ChatSetting> iter = col.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ChatSetting chatSetting = (ChatSetting)iter.next();
|
||||
ChatSetting chatSetting = iter.next();
|
||||
if (chatSetting.getKey().equals(key)) {
|
||||
return chatSetting;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Map;
|
|||
|
||||
public class GenericSettings extends IQ {
|
||||
|
||||
private Map map = new HashMap();
|
||||
private Map<String, String> map = new HashMap<String, String>();
|
||||
|
||||
private String query;
|
||||
|
||||
|
@ -41,11 +41,11 @@ public class GenericSettings extends IQ {
|
|||
this.query = query;
|
||||
}
|
||||
|
||||
public Map getMap() {
|
||||
public Map<String, String> getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setMap(Map map) {
|
||||
public void setMap(Map<String, String> map) {
|
||||
this.map = map;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,9 +58,8 @@ public class Workgroup {
|
|||
private String workgroupJID;
|
||||
private Connection connection;
|
||||
private boolean inQueue;
|
||||
private List invitationListeners;
|
||||
private List queueListeners;
|
||||
private List siteInviteListeners;
|
||||
private List<WorkgroupInvitationListener> invitationListeners;
|
||||
private List<QueueListener> queueListeners;
|
||||
|
||||
private int queuePosition = -1;
|
||||
private int queueRemainingTime = -1;
|
||||
|
@ -84,9 +83,8 @@ public class Workgroup {
|
|||
this.workgroupJID = workgroupJID;
|
||||
this.connection = connection;
|
||||
inQueue = false;
|
||||
invitationListeners = new ArrayList();
|
||||
queueListeners = new ArrayList();
|
||||
siteInviteListeners = new ArrayList();
|
||||
invitationListeners = new ArrayList<WorkgroupInvitationListener>();
|
||||
queueListeners = new ArrayList<QueueListener>();
|
||||
|
||||
// Register as a queue listener for internal usage by this instance.
|
||||
addQueueListener(new QueueListener() {
|
||||
|
@ -378,7 +376,7 @@ public class Workgroup {
|
|||
* that a connection failure occured or that the server explicitly rejected the
|
||||
* request to join the queue.
|
||||
*/
|
||||
public void joinQueue(Map metadata, String userID) throws XMPPException {
|
||||
public void joinQueue(Map<String,Object> metadata, String userID) throws XMPPException {
|
||||
// If already in the queue ignore the join request.
|
||||
if (inQueue) {
|
||||
throw new IllegalStateException("Already in queue " + workgroupJID);
|
||||
|
@ -386,10 +384,10 @@ public class Workgroup {
|
|||
|
||||
// Build dataform from metadata
|
||||
Form form = new Form(Form.TYPE_SUBMIT);
|
||||
Iterator iter = metadata.keySet().iterator();
|
||||
Iterator<String> iter = metadata.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
String name = (String)iter.next();
|
||||
String value = (String)metadata.get(name).toString();
|
||||
String name = iter.next();
|
||||
String value = metadata.get(name).toString();
|
||||
|
||||
String escapedName = StringUtils.escapeForXML(name);
|
||||
String escapedValue = StringUtils.escapeForXML(value);
|
||||
|
@ -489,8 +487,8 @@ public class Workgroup {
|
|||
|
||||
private void fireInvitationEvent(WorkgroupInvitation invitation) {
|
||||
synchronized (invitationListeners) {
|
||||
for (Iterator i = invitationListeners.iterator(); i.hasNext();) {
|
||||
WorkgroupInvitationListener listener = (WorkgroupInvitationListener)i.next();
|
||||
for (Iterator<WorkgroupInvitationListener> i = invitationListeners.iterator(); i.hasNext();) {
|
||||
WorkgroupInvitationListener listener = i.next();
|
||||
listener.invitationReceived(invitation);
|
||||
}
|
||||
}
|
||||
|
@ -498,8 +496,8 @@ public class Workgroup {
|
|||
|
||||
private void fireQueueJoinedEvent() {
|
||||
synchronized (queueListeners) {
|
||||
for (Iterator i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = (QueueListener)i.next();
|
||||
for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = i.next();
|
||||
listener.joinedQueue();
|
||||
}
|
||||
}
|
||||
|
@ -507,8 +505,8 @@ public class Workgroup {
|
|||
|
||||
private void fireQueueDepartedEvent() {
|
||||
synchronized (queueListeners) {
|
||||
for (Iterator i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = (QueueListener)i.next();
|
||||
for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = i.next();
|
||||
listener.departedQueue();
|
||||
}
|
||||
}
|
||||
|
@ -516,8 +514,8 @@ public class Workgroup {
|
|||
|
||||
private void fireQueuePositionEvent(int currentPosition) {
|
||||
synchronized (queueListeners) {
|
||||
for (Iterator i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = (QueueListener)i.next();
|
||||
for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = i.next();
|
||||
listener.queuePositionUpdated(currentPosition);
|
||||
}
|
||||
}
|
||||
|
@ -525,8 +523,8 @@ public class Workgroup {
|
|||
|
||||
private void fireQueueTimeEvent(int secondsRemaining) {
|
||||
synchronized (queueListeners) {
|
||||
for (Iterator i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = (QueueListener)i.next();
|
||||
for (Iterator<QueueListener> i = queueListeners.iterator(); i.hasNext();) {
|
||||
QueueListener listener = i.next();
|
||||
listener.queueWaitTimeUpdated(secondsRemaining);
|
||||
}
|
||||
}
|
||||
|
@ -560,7 +558,7 @@ public class Workgroup {
|
|||
MUCUser.Invite invite = mucUser != null ? mucUser.getInvite() : null;
|
||||
if (invite != null && workgroupJID.equals(invite.getFrom())) {
|
||||
String sessionID = null;
|
||||
Map metaData = null;
|
||||
Map<String, List<String>> metaData = null;
|
||||
|
||||
pe = msg.getExtension(SessionID.ELEMENT_NAME,
|
||||
SessionID.NAMESPACE);
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
package org.jivesoftware.smackx.workgroup.util;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.ListIterator;
|
||||
|
||||
/**
|
||||
* This class is a very flexible event dispatcher which implements Runnable so that it can
|
||||
|
@ -34,7 +35,7 @@ import java.util.*;
|
|||
public class ListenerEventDispatcher
|
||||
implements Runnable {
|
||||
|
||||
protected transient ArrayList triplets;
|
||||
protected transient ArrayList<TripletContainer> triplets;
|
||||
|
||||
protected transient boolean hasFinishedDispatching;
|
||||
protected transient boolean isRunning;
|
||||
|
@ -42,7 +43,7 @@ public class ListenerEventDispatcher
|
|||
public ListenerEventDispatcher () {
|
||||
super();
|
||||
|
||||
this.triplets = new ArrayList();
|
||||
this.triplets = new ArrayList<TripletContainer>();
|
||||
|
||||
this.hasFinishedDispatching = false;
|
||||
this.isRunning = false;
|
||||
|
@ -81,13 +82,13 @@ public class ListenerEventDispatcher
|
|||
}
|
||||
|
||||
public void run() {
|
||||
ListIterator li = null;
|
||||
ListIterator<TripletContainer> li = null;
|
||||
|
||||
this.isRunning = true;
|
||||
|
||||
li = this.triplets.listIterator();
|
||||
while (li.hasNext()) {
|
||||
TripletContainer tc = (TripletContainer)li.next();
|
||||
TripletContainer tc = li.next();
|
||||
|
||||
try {
|
||||
tc.getListenerMethod().invoke(tc.getListenerInstance(), tc.getMethodArguments());
|
||||
|
|
|
@ -40,14 +40,14 @@ public class MetaDataUtils {
|
|||
* @throws XmlPullParserException if an error occurs while parsing the XML.
|
||||
* @throws IOException if an error occurs while parsing the XML.
|
||||
*/
|
||||
public static Map parseMetaData(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
public static Map<String, List<String>> parseMetaData(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
int eventType = parser.getEventType();
|
||||
|
||||
// If correctly positioned on an opening meta-data tag, parse meta-data.
|
||||
if ((eventType == XmlPullParser.START_TAG)
|
||||
&& parser.getName().equals(MetaData.ELEMENT_NAME)
|
||||
&& parser.getNamespace().equals(MetaData.NAMESPACE)) {
|
||||
Map metaData = new Hashtable();
|
||||
Map<String, List<String>> metaData = new Hashtable<String, List<String>>();
|
||||
|
||||
eventType = parser.nextTag();
|
||||
|
||||
|
@ -58,11 +58,11 @@ public class MetaDataUtils {
|
|||
String value = parser.nextText();
|
||||
|
||||
if (metaData.containsKey(name)) {
|
||||
List values = (List)metaData.get(name);
|
||||
List<String> values = metaData.get(name);
|
||||
values.add(value);
|
||||
}
|
||||
else {
|
||||
List values = new ArrayList();
|
||||
List<String> values = new ArrayList<String>();
|
||||
values.add(value);
|
||||
metaData.put(name, values);
|
||||
}
|
||||
|
@ -73,34 +73,26 @@ public class MetaDataUtils {
|
|||
return metaData;
|
||||
}
|
||||
|
||||
return Collections.EMPTY_MAP;
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes a Map of String name/value pairs into the meta-data XML format.
|
||||
*
|
||||
* @param metaData the Map of meta-data.
|
||||
* @param metaData the Map of meta-data as Map<String,List<String>>
|
||||
* @return the meta-data values in XML form.
|
||||
*/
|
||||
public static String serializeMetaData(Map metaData) {
|
||||
public static String serializeMetaData(Map<String, List<String>> metaData) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (metaData != null && metaData.size() > 0) {
|
||||
buf.append("<metadata xmlns=\"http://jivesoftware.com/protocol/workgroup\">");
|
||||
for (Iterator i = metaData.keySet().iterator(); i.hasNext();) {
|
||||
Object key = i.next();
|
||||
Object value = metaData.get(key);
|
||||
if (value instanceof List) {
|
||||
List values = (List)metaData.get(key);
|
||||
for (Iterator it = values.iterator(); it.hasNext();) {
|
||||
String v = (String)it.next();
|
||||
buf.append("<value name=\"").append(key).append("\">");
|
||||
buf.append(StringUtils.escapeForXML(v));
|
||||
buf.append("</value>");
|
||||
}
|
||||
}
|
||||
else if (value instanceof String) {
|
||||
for (Iterator<String> i = metaData.keySet().iterator(); i.hasNext();) {
|
||||
String key = i.next();
|
||||
List<String> value = metaData.get(key);
|
||||
for (Iterator<String> it = value.iterator(); it.hasNext();) {
|
||||
String v = it.next();
|
||||
buf.append("<value name=\"").append(key).append("\">");
|
||||
buf.append(StringUtils.escapeForXML((String)value));
|
||||
buf.append(StringUtils.escapeForXML(v));
|
||||
buf.append("</value>");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -240,8 +240,6 @@ public final class ModelUtil {
|
|||
final long MS_IN_AN_HOUR = 1000 * 60 * 60;
|
||||
final long MS_IN_A_MINUTE = 1000 * 60;
|
||||
final long MS_IN_A_SECOND = 1000;
|
||||
Date currentTime = new Date();
|
||||
long numDays = diff / MS_IN_A_DAY;
|
||||
diff = diff % MS_IN_A_DAY;
|
||||
long numHours = diff / MS_IN_AN_HOUR;
|
||||
diff = diff % MS_IN_AN_HOUR;
|
||||
|
@ -249,7 +247,6 @@ public final class ModelUtil {
|
|||
diff = diff % MS_IN_A_MINUTE;
|
||||
long numSeconds = diff / MS_IN_A_SECOND;
|
||||
diff = diff % MS_IN_A_SECOND;
|
||||
long numMilliseconds = diff;
|
||||
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (numHours > 0) {
|
||||
|
@ -270,8 +267,8 @@ public final class ModelUtil {
|
|||
/**
|
||||
* Build a List of all elements in an Iterator.
|
||||
*/
|
||||
public static List iteratorAsList(Iterator i) {
|
||||
ArrayList list = new ArrayList(10);
|
||||
public static <T> List<T> iteratorAsList(Iterator<T> i) {
|
||||
ArrayList<T> list = new ArrayList<T>(10);
|
||||
while (i.hasNext()) {
|
||||
list.add(i.next());
|
||||
}
|
||||
|
@ -281,18 +278,18 @@ public final class ModelUtil {
|
|||
/**
|
||||
* Creates an Iterator that is the reverse of a ListIterator.
|
||||
*/
|
||||
public static Iterator reverseListIterator(ListIterator i) {
|
||||
return new ReverseListIterator(i);
|
||||
public static <T> Iterator<T> reverseListIterator(ListIterator<T> i) {
|
||||
return new ReverseListIterator<T>(i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An Iterator that is the reverse of a ListIterator.
|
||||
*/
|
||||
class ReverseListIterator implements Iterator {
|
||||
private ListIterator _i;
|
||||
class ReverseListIterator<T> implements Iterator<T> {
|
||||
private ListIterator<T> _i;
|
||||
|
||||
ReverseListIterator(ListIterator i) {
|
||||
ReverseListIterator(ListIterator<T> i) {
|
||||
_i = i;
|
||||
while (_i.hasNext())
|
||||
_i.next();
|
||||
|
@ -302,13 +299,14 @@ class ReverseListIterator implements Iterator {
|
|||
return _i.hasPrevious();
|
||||
}
|
||||
|
||||
public Object next() {
|
||||
public T next() {
|
||||
return _i.previous();
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
_i.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package org.jivesoftware.smack;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class SmackConfigTest
|
||||
{
|
||||
@Test
|
||||
public void validatePacketCollectorSize()
|
||||
{
|
||||
assertEquals(10000, SmackConfiguration.getPacketCollectorSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateKeepAliveInterval()
|
||||
{
|
||||
assertEquals(30000, SmackConfiguration.getKeepAliveInterval());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateLocalSocks5ProxyPort()
|
||||
{
|
||||
assertEquals(7777, SmackConfiguration.getLocalSocks5ProxyPort());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void validateIsLocalSocks5Proxy()
|
||||
{
|
||||
assertTrue(SmackConfiguration.isLocalSocks5ProxyEnabled());
|
||||
}
|
||||
}
|
|
@ -142,9 +142,9 @@ public class Protocol {
|
|||
}
|
||||
}
|
||||
|
||||
Verification<?, ?>[] verifications = verificationList.get(i);
|
||||
Verification<Packet, Packet>[] verifications = (Verification<Packet, Packet>[]) verificationList.get(i);
|
||||
if (verifications != null) {
|
||||
for (Verification verification : verifications) {
|
||||
for (Verification<Packet, Packet> verification : verifications) {
|
||||
verification.verify(request, response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
<testcase>
|
||||
|
||||
<!-- Host and port of the XMPP server to use -->
|
||||
<host>localhost</host>
|
||||
<host>sanctuary</host>
|
||||
<port>5222</port>
|
||||
|
||||
<!-- Username prefix to use for creating accounts. Same value will be used for passwords. -->
|
||||
<username>user</username>
|
||||
|
||||
<password same='true'>passw0rd</password>
|
||||
<!-- Chat and MUC domain names to use -->
|
||||
<chat>chat</chat>
|
||||
<muc>conference</muc>
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.jivesoftware.smack;
|
|||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.packet.Privacy;
|
||||
import org.jivesoftware.smack.packet.PrivacyItem;
|
||||
|
||||
/**
|
||||
* This class supports automated tests about privacy communication from the
|
||||
|
@ -27,7 +28,7 @@ public class PrivacyClient implements PrivacyListListener {
|
|||
super();
|
||||
}
|
||||
|
||||
public void setPrivacyList(String listName, List listItem) {
|
||||
public void setPrivacyList(String listName, List<PrivacyItem> listItem) {
|
||||
privacy.setPrivacyList(listName, listItem);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,8 +60,6 @@ import org.jivesoftware.smack.packet.*;
|
|||
*/
|
||||
public class PacketTypeFilterTest extends TestCase {
|
||||
|
||||
private class Dummy {}
|
||||
|
||||
private class InnerClassDummy {
|
||||
public class DummyPacket extends Packet {
|
||||
public String toXML() {
|
||||
|
@ -88,12 +86,13 @@ public class PacketTypeFilterTest extends TestCase {
|
|||
* Test case for the constructor of PacketTypeFilter objects.
|
||||
*/
|
||||
public void testConstructor() {
|
||||
// We dont need to test this since PacketTypeFilter(Class<? extends Packet> packetType) only excepts Packets
|
||||
// Test a class that is not a subclass of Packet
|
||||
try {
|
||||
new PacketTypeFilter(Dummy.class);
|
||||
fail("Parameter must be a subclass of Packet.");
|
||||
}
|
||||
catch (IllegalArgumentException e) {}
|
||||
// try {
|
||||
// new PacketTypeFilter(Dummy.class);
|
||||
// fail("Parameter must be a subclass of Packet.");
|
||||
// }
|
||||
// catch (IllegalArgumentException e) {}
|
||||
|
||||
// Test a class that is a subclass of Packet
|
||||
try {
|
||||
|
|
|
@ -52,8 +52,6 @@
|
|||
|
||||
package org.jivesoftware.smack.packet;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* A mock implementation of the Packet abstract class. Implements toXML() by returning null.
|
||||
*/
|
||||
|
|
|
@ -45,11 +45,11 @@ public class PrivacyTest extends SmackTestCase {
|
|||
|
||||
// Assert the list composition.
|
||||
assertEquals(listName, privacyManager.getActiveList().toString());
|
||||
List privacyItems = privacyManager.getPrivacyList(listName).getItems();
|
||||
List<PrivacyItem> privacyItems = privacyManager.getPrivacyList(listName).getItems();
|
||||
assertEquals(1, privacyItems.size());
|
||||
|
||||
// Assert the privacy item composition
|
||||
PrivacyItem receivedItem = (PrivacyItem) privacyItems.get(0);
|
||||
PrivacyItem receivedItem = privacyItems.get(0);
|
||||
assertEquals(1, receivedItem.getOrder());
|
||||
assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
|
||||
assertEquals(true, receivedItem.isAllow());
|
||||
|
@ -278,11 +278,11 @@ public class PrivacyTest extends SmackTestCase {
|
|||
|
||||
// Assert the list composition.
|
||||
assertEquals(listName, privacyManager.getDefaultList().toString());
|
||||
List privacyItems = privacyManager.getPrivacyList(listName).getItems();
|
||||
List<PrivacyItem> privacyItems = privacyManager.getPrivacyList(listName).getItems();
|
||||
assertEquals(1, privacyItems.size());
|
||||
|
||||
// Assert the privacy item composition
|
||||
PrivacyItem receivedItem = (PrivacyItem) privacyItems.get(0);
|
||||
PrivacyItem receivedItem = privacyItems.get(0);
|
||||
assertEquals(1, receivedItem.getOrder());
|
||||
assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
|
||||
assertEquals(true, receivedItem.isAllow());
|
||||
|
@ -427,7 +427,7 @@ public class PrivacyTest extends SmackTestCase {
|
|||
Thread.sleep(500);
|
||||
|
||||
// Assert the server list composition.
|
||||
List privacyItems = privacyManager.getPrivacyList(listName).getItems();
|
||||
List<PrivacyItem> privacyItems = privacyManager.getPrivacyList(listName).getItems();
|
||||
assertEquals(originalPrivacyItems.length, privacyItems.size());
|
||||
|
||||
// Assert the local and server privacy item composition
|
||||
|
@ -436,7 +436,7 @@ public class PrivacyTest extends SmackTestCase {
|
|||
int index;
|
||||
for (int j = 0; j < originalPrivacyItems.length; j++) {
|
||||
// Look for the same server and original items
|
||||
receivedItem = (PrivacyItem) privacyItems.get(j);
|
||||
receivedItem = privacyItems.get(j);
|
||||
index = 0;
|
||||
while ((index < originalPrivacyItems.length)
|
||||
&& (originalPrivacyItems[index].getOrder() != receivedItem.getOrder())) {
|
||||
|
|
|
@ -353,17 +353,17 @@ public abstract class SmackTestCase extends TestCase {
|
|||
try {
|
||||
boolean found = false;
|
||||
// Try to load the configutation from an XML file specific for this test case
|
||||
Enumeration resources =
|
||||
Enumeration<URL> resources =
|
||||
ClassLoader.getSystemClassLoader().getResources(getConfigurationFilename());
|
||||
while (resources.hasMoreElements()) {
|
||||
found = parseURL((URL) resources.nextElement());
|
||||
found = parseURL(resources.nextElement());
|
||||
}
|
||||
// If none was found then try to load the configuration from the default configuration
|
||||
// file (i.e. "config/test-case.xml")
|
||||
if (!found) {
|
||||
resources = ClassLoader.getSystemClassLoader().getResources("config/test-case.xml");
|
||||
while (resources.hasMoreElements()) {
|
||||
found = parseURL((URL) resources.nextElement());
|
||||
found = parseURL(resources.nextElement());
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
|
|
|
@ -57,9 +57,9 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
|
||||
Message message = new Message();
|
||||
message.setBody("Hola");
|
||||
List to = Arrays.asList(new String[]{getBareJID(1)});
|
||||
List cc = Arrays.asList(new String[]{getBareJID(2)});
|
||||
List bcc = Arrays.asList(new String[]{getBareJID(3)});
|
||||
List<String> to = Arrays.asList(new String[]{getBareJID(1)});
|
||||
List<String> cc = Arrays.asList(new String[]{getBareJID(2)});
|
||||
List<String> bcc = Arrays.asList(new String[]{getBareJID(3)});
|
||||
MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc);
|
||||
|
||||
Packet message1 = collector1.nextResult(SmackConfiguration.getPacketReplyTimeout());
|
||||
|
@ -67,7 +67,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
MultipleRecipientInfo info1 = MultipleRecipientManager.getMultipleRecipientInfo(message1);
|
||||
assertNotNull("Message 1 does not contain MultipleRecipientInfo", info1);
|
||||
assertFalse("Message 1 should be 'replyable'", info1.shouldNotReply());
|
||||
List addresses1 = info1.getTOAddresses();
|
||||
List<?> addresses1 = info1.getTOAddresses();
|
||||
assertEquals("Incorrect number of TO addresses", 1, addresses1.size());
|
||||
String address1 = ((MultipleAddresses.Address) addresses1.get(0)).getJid();
|
||||
assertEquals("Incorrect TO address", getBareJID(1), address1);
|
||||
|
@ -81,7 +81,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
MultipleRecipientInfo info2 = MultipleRecipientManager.getMultipleRecipientInfo(message2);
|
||||
assertNotNull("Message 2 does not contain MultipleRecipientInfo", info2);
|
||||
assertFalse("Message 2 should be 'replyable'", info2.shouldNotReply());
|
||||
List addresses2 = info2.getTOAddresses();
|
||||
List<MultipleAddresses.Address> addresses2 = info2.getTOAddresses();
|
||||
assertEquals("Incorrect number of TO addresses", 1, addresses2.size());
|
||||
String address2 = ((MultipleAddresses.Address) addresses2.get(0)).getJid();
|
||||
assertEquals("Incorrect TO address", getBareJID(1), address2);
|
||||
|
@ -95,7 +95,7 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
MultipleRecipientInfo info3 = MultipleRecipientManager.getMultipleRecipientInfo(message3);
|
||||
assertNotNull("Message 3 does not contain MultipleRecipientInfo", info3);
|
||||
assertFalse("Message 3 should be 'replyable'", info3.shouldNotReply());
|
||||
List addresses3 = info3.getTOAddresses();
|
||||
List<MultipleAddresses.Address> addresses3 = info3.getTOAddresses();
|
||||
assertEquals("Incorrect number of TO addresses", 1, addresses3.size());
|
||||
String address3 = ((MultipleAddresses.Address) addresses3.get(0)).getJid();
|
||||
assertEquals("Incorrect TO address", getBareJID(1), address3);
|
||||
|
@ -125,9 +125,9 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
// Send the intial message with multiple recipients
|
||||
Message message = new Message();
|
||||
message.setBody("Hola");
|
||||
List to = Arrays.asList(new String[]{getBareJID(1)});
|
||||
List cc = Arrays.asList(new String[]{getBareJID(2)});
|
||||
List bcc = Arrays.asList(new String[]{getBareJID(3)});
|
||||
List<String> to = Arrays.asList(new String[]{getBareJID(1)});
|
||||
List<String> cc = Arrays.asList(new String[]{getBareJID(2)});
|
||||
List<String> bcc = Arrays.asList(new String[]{getBareJID(3)});
|
||||
MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc);
|
||||
|
||||
// Get the message and ensure it's ok
|
||||
|
@ -205,9 +205,9 @@ public class MultipleRecipientManagerTest extends SmackTestCase {
|
|||
// Send the intial message with multiple recipients
|
||||
Message message = new Message();
|
||||
message.setBody("Hola");
|
||||
List to = Arrays.asList(new String[]{getBareJID(1)});
|
||||
List cc = Arrays.asList(new String[]{getBareJID(2)});
|
||||
List bcc = Arrays.asList(new String[]{getBareJID(3)});
|
||||
List<String> to = Arrays.asList(new String[]{getBareJID(1)});
|
||||
List<String> cc = Arrays.asList(new String[]{getBareJID(2)});
|
||||
List<String> bcc = Arrays.asList(new String[]{getBareJID(3)});
|
||||
MultipleRecipientManager.send(getConnection(0), message, to, cc, bcc, null, null, true);
|
||||
|
||||
// Get the message and ensure it's ok
|
||||
|
|
|
@ -74,22 +74,22 @@ public class OfflineMessageManagerTest extends SmackTestCase {
|
|||
OfflineMessageManager offlineManager = new OfflineMessageManager(getConnection(1));
|
||||
assertEquals("Wrong number of offline messages", 2, offlineManager.getMessageCount());
|
||||
// Check the message headers
|
||||
Iterator headers = offlineManager.getHeaders();
|
||||
Iterator<OfflineMessageHeader> headers = offlineManager.getHeaders();
|
||||
assertTrue("No message header was found", headers.hasNext());
|
||||
List<String> stamps = new ArrayList<String>();
|
||||
while (headers.hasNext()) {
|
||||
OfflineMessageHeader header = (OfflineMessageHeader) headers.next();
|
||||
OfflineMessageHeader header = headers.next();
|
||||
assertEquals("Incorrect sender", getFullJID(0), header.getJid());
|
||||
assertNotNull("No stamp was found in the message header", header.getStamp());
|
||||
stamps.add(header.getStamp());
|
||||
}
|
||||
assertEquals("Wrong number of headers", 2, stamps.size());
|
||||
// Get the offline messages
|
||||
Iterator messages = offlineManager.getMessages(stamps);
|
||||
Iterator<Message> messages = offlineManager.getMessages(stamps);
|
||||
assertTrue("No message was found", messages.hasNext());
|
||||
stamps = new ArrayList<String>();
|
||||
while (messages.hasNext()) {
|
||||
Message message = (Message) messages.next();
|
||||
Message message = messages.next();
|
||||
OfflineMessageInfo info = (OfflineMessageInfo) message.getExtension("offline",
|
||||
"http://jabber.org/protocol/offline");
|
||||
assertNotNull("No offline information was included in the offline message", info);
|
||||
|
@ -143,11 +143,11 @@ public class OfflineMessageManagerTest extends SmackTestCase {
|
|||
OfflineMessageManager offlineManager = new OfflineMessageManager(getConnection(1));
|
||||
assertEquals("Wrong number of offline messages", 2, offlineManager.getMessageCount());
|
||||
// Get all offline messages
|
||||
Iterator messages = offlineManager.getMessages();
|
||||
Iterator<Message> messages = offlineManager.getMessages();
|
||||
assertTrue("No message was found", messages.hasNext());
|
||||
List<String> stamps = new ArrayList<String>();
|
||||
while (messages.hasNext()) {
|
||||
Message message = (Message) messages.next();
|
||||
Message message = messages.next();
|
||||
OfflineMessageInfo info = (OfflineMessageInfo) message.getExtension("offline",
|
||||
"http://jabber.org/protocol/offline");
|
||||
assertNotNull("No offline information was included in the offline message", info);
|
||||
|
|
|
@ -128,14 +128,14 @@ public class RosterExchangeManagerTest extends SmackTestCase {
|
|||
|
||||
// Create a RosterExchangeListener that will iterate over the received roster entries
|
||||
RosterExchangeListener rosterExchangeListener = new RosterExchangeListener() {
|
||||
public void entriesReceived(String from, Iterator remoteRosterEntries) {
|
||||
public void entriesReceived(String from, Iterator<RemoteRosterEntry> remoteRosterEntries) {
|
||||
int received = 0;
|
||||
assertNotNull("From is null", from);
|
||||
assertNotNull("rosterEntries is null", remoteRosterEntries);
|
||||
assertTrue("Roster without entries", remoteRosterEntries.hasNext());
|
||||
while (remoteRosterEntries.hasNext()) {
|
||||
received++;
|
||||
RemoteRosterEntry remoteEntry = (RemoteRosterEntry) remoteRosterEntries.next();
|
||||
RemoteRosterEntry remoteEntry = remoteRosterEntries.next();
|
||||
System.out.println(remoteEntry);
|
||||
}
|
||||
entriesReceived = received;
|
||||
|
@ -178,7 +178,7 @@ public class RosterExchangeManagerTest extends SmackTestCase {
|
|||
|
||||
// Create a RosterExchangeListener that will accept all the received roster entries
|
||||
RosterExchangeListener rosterExchangeListener = new RosterExchangeListener() {
|
||||
public void entriesReceived(String from, Iterator remoteRosterEntries) {
|
||||
public void entriesReceived(String from, Iterator<RemoteRosterEntry> remoteRosterEntries) {
|
||||
int received = 0;
|
||||
assertNotNull("From is null", from);
|
||||
assertNotNull("remoteRosterEntries is null", remoteRosterEntries);
|
||||
|
@ -186,8 +186,7 @@ public class RosterExchangeManagerTest extends SmackTestCase {
|
|||
while (remoteRosterEntries.hasNext()) {
|
||||
received++;
|
||||
try {
|
||||
RemoteRosterEntry remoteRosterEntry =
|
||||
(RemoteRosterEntry) remoteRosterEntries.next();
|
||||
RemoteRosterEntry remoteRosterEntry = remoteRosterEntries.next();
|
||||
getConnection(1).getRoster().createEntry(
|
||||
remoteRosterEntry.getUser(),
|
||||
remoteRosterEntry.getName(),
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue