mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +01:00
SMACK-534 Refactored all System.out/err and printStackTrace calls with appropriate Java util logging calls.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_4_0@13887 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
9bb940da4b
commit
1b651d4939
30 changed files with 189 additions and 183 deletions
|
@ -32,6 +32,8 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows creation and management of accounts on an XMPP server.
|
* Allows creation and management of accounts on an XMPP server.
|
||||||
|
@ -40,7 +42,8 @@ import java.util.Map;
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
public class AccountManager {
|
public class AccountManager {
|
||||||
|
private static Logger logger = Logger.getLogger(AccountManager.class.getName());
|
||||||
|
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
private Registration info = null;
|
private Registration info = null;
|
||||||
|
|
||||||
|
@ -134,7 +137,7 @@ public class AccountManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (XMPPException xe) {
|
catch (XMPPException xe) {
|
||||||
xe.printStackTrace();
|
logger.log(Level.SEVERE, "Error retrieving account attributes from server", xe);
|
||||||
}
|
}
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
|
@ -155,7 +158,7 @@ public class AccountManager {
|
||||||
return info.getAttributes().get(name);
|
return info.getAttributes().get(name);
|
||||||
}
|
}
|
||||||
catch (XMPPException xe) {
|
catch (XMPPException xe) {
|
||||||
xe.printStackTrace();
|
logger.log(Level.SEVERE, "Error retrieving account attribute " + name + " info from server", xe);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -175,6 +178,7 @@ public class AccountManager {
|
||||||
return info.getInstructions();
|
return info.getInstructions();
|
||||||
}
|
}
|
||||||
catch (XMPPException xe) {
|
catch (XMPPException xe) {
|
||||||
|
logger.log(Level.SEVERE, "Error retrieving account instructions from server", xe);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.compression.JzlibInputOutputStream;
|
import org.jivesoftware.smack.compression.JzlibInputOutputStream;
|
||||||
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
|
import org.jivesoftware.smack.compression.XMPPInputOutputStream;
|
||||||
|
@ -83,7 +84,8 @@ import org.jivesoftware.smack.packet.Presence;
|
||||||
* @author Guenther Niess
|
* @author Guenther Niess
|
||||||
*/
|
*/
|
||||||
public abstract class Connection {
|
public abstract class Connection {
|
||||||
|
private static Logger log = Logger.getLogger(Connection.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Counter to uniquely identify connections that are created.
|
* Counter to uniquely identify connections that are created.
|
||||||
*/
|
*/
|
||||||
|
@ -764,7 +766,7 @@ public abstract class Connection {
|
||||||
debuggerClass = Class.forName(className);
|
debuggerClass = Class.forName(className);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.warning("Unabled to instantiate debugger class " + className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debuggerClass == null) {
|
if (debuggerClass == null) {
|
||||||
|
@ -778,7 +780,7 @@ public abstract class Connection {
|
||||||
Class.forName("org.jivesoftware.smack.debugger.LiteDebugger");
|
Class.forName("org.jivesoftware.smack.debugger.LiteDebugger");
|
||||||
}
|
}
|
||||||
catch (Exception ex2) {
|
catch (Exception ex2) {
|
||||||
ex2.printStackTrace();
|
log.warning("Unabled to instantiate either Smack debugger class");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listens for XML traffic from the XMPP server and parses it into packet objects.
|
* Listens for XML traffic from the XMPP server and parses it into packet objects.
|
||||||
|
@ -45,6 +47,8 @@ import java.util.concurrent.*;
|
||||||
*/
|
*/
|
||||||
class PacketReader {
|
class PacketReader {
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(PacketReader.class.getName());
|
||||||
|
|
||||||
private Thread readerThread;
|
private Thread readerThread;
|
||||||
private ExecutorService listenerExecutor;
|
private ExecutorService listenerExecutor;
|
||||||
|
|
||||||
|
@ -134,7 +138,7 @@ class PacketReader {
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
// Catch and print any exception so we can recover
|
// Catch and print any exception so we can recover
|
||||||
// from a faulty listener and finish the shutdown process
|
// from a faulty listener and finish the shutdown process
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error in listener while closing connection", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +160,7 @@ class PacketReader {
|
||||||
parser.setInput(connection.reader);
|
parser.setInput(connection.reader);
|
||||||
}
|
}
|
||||||
catch (XmlPullParserException xppe) {
|
catch (XmlPullParserException xppe) {
|
||||||
xppe.printStackTrace();
|
log.log(Level.WARNING, "Error while resetting parser", xppe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,8 +455,7 @@ class PacketReader {
|
||||||
try {
|
try {
|
||||||
listenerWrapper.notifyListener(packet);
|
listenerWrapper.notifyListener(packet);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Exception in packet listener: " + e);
|
log.log(Level.SEVERE, "Exception in packet listener", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes packets to a XMPP server. Packets are sent using a dedicated thread. Packet
|
* Writes packets to a XMPP server. Packets are sent using a dedicated thread. Packet
|
||||||
|
@ -38,7 +40,8 @@ import java.util.concurrent.BlockingQueue;
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
class PacketWriter {
|
class PacketWriter {
|
||||||
|
private static Logger log = Logger.getLogger(PacketWriter.class.getName());
|
||||||
|
|
||||||
private Thread writerThread;
|
private Thread writerThread;
|
||||||
private Writer writer;
|
private Writer writer;
|
||||||
private XMPPConnection connection;
|
private XMPPConnection connection;
|
||||||
|
@ -88,7 +91,7 @@ class PacketWriter {
|
||||||
queue.put(packet);
|
queue.put(packet);
|
||||||
}
|
}
|
||||||
catch (InterruptedException ie) {
|
catch (InterruptedException ie) {
|
||||||
ie.printStackTrace();
|
log.log(Level.SEVERE, "Failed to queue packet to send to server: " + packet.toString(), ie);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
synchronized (queue) {
|
synchronized (queue) {
|
||||||
|
@ -165,14 +168,14 @@ class PacketWriter {
|
||||||
// we won't have time to entirely flush it before the socket is forced closed
|
// we won't have time to entirely flush it before the socket is forced closed
|
||||||
// by the shutdown process.
|
// by the shutdown process.
|
||||||
try {
|
try {
|
||||||
while (!queue.isEmpty()) {
|
while (!queue.isEmpty()) {
|
||||||
Packet packet = queue.remove();
|
Packet packet = queue.remove();
|
||||||
writer.write(packet.toXML());
|
writer.write(packet.toXML());
|
||||||
}
|
}
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.warning("Error flushing queue during shutdown, ignore and continue");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the queue contents (hopefully nothing is left).
|
// Delete the queue contents (hopefully nothing is left).
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.jivesoftware.smack;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.StreamError;
|
import org.jivesoftware.smack.packet.StreamError;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.logging.Logger;
|
||||||
/**
|
/**
|
||||||
* Handles the automatic reconnection process. Every time a connection is dropped without
|
* Handles the automatic reconnection process. Every time a connection is dropped without
|
||||||
* the application explictly closing it, the manager automatically tries to reconnect to
|
* the application explictly closing it, the manager automatically tries to reconnect to
|
||||||
|
@ -34,7 +35,8 @@ import java.util.Random;
|
||||||
* @author Francisco Vives
|
* @author Francisco Vives
|
||||||
*/
|
*/
|
||||||
public class ReconnectionManager implements ConnectionListener {
|
public class ReconnectionManager implements ConnectionListener {
|
||||||
|
private static Logger log = Logger.getLogger(ReconnectionManager.class.getName());
|
||||||
|
|
||||||
// Holds the connection to the server
|
// Holds the connection to the server
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
private Thread reconnectionThread;
|
private Thread reconnectionThread;
|
||||||
|
@ -132,8 +134,8 @@ public class ReconnectionManager implements ConnectionListener {
|
||||||
ReconnectionManager.this
|
ReconnectionManager.this
|
||||||
.notifyAttemptToReconnectIn(remainingSeconds);
|
.notifyAttemptToReconnectIn(remainingSeconds);
|
||||||
}
|
}
|
||||||
catch (InterruptedException e1) {
|
catch (InterruptedException e1) {
|
||||||
e1.printStackTrace();
|
log.warning("Sleeping thread interrupted");
|
||||||
// Notify the reconnection has failed
|
// Notify the reconnection has failed
|
||||||
ReconnectionManager.this.notifyReconnectionFailed(e1);
|
ReconnectionManager.this.notifyReconnectionFailed(e1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.security.cert.CertificateException;
|
||||||
import java.security.cert.CertificateParsingException;
|
import java.security.cert.CertificateParsingException;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -41,7 +42,8 @@ import java.util.regex.Pattern;
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
*/
|
*/
|
||||||
class ServerTrustManager implements X509TrustManager {
|
class ServerTrustManager implements X509TrustManager {
|
||||||
|
private static Logger log = Logger.getLogger(ServerTrustManager.class.getName());
|
||||||
|
|
||||||
private static Pattern cnPattern = Pattern.compile("(?i)(cn=)([^,]*)");
|
private static Pattern cnPattern = Pattern.compile("(?i)(cn=)([^,]*)");
|
||||||
|
|
||||||
private ConnectionConfiguration configuration;
|
private ConnectionConfiguration configuration;
|
||||||
|
@ -153,8 +155,7 @@ class ServerTrustManager implements X509TrustManager {
|
||||||
trusted = trustStore.getCertificateAlias(x509Certificates[nSize - 1]) != null;
|
trusted = trustStore.getCertificateAlias(x509Certificates[nSize - 1]) != null;
|
||||||
if (!trusted && nSize == 1 && configuration.isSelfSignedCertificateEnabled())
|
if (!trusted && nSize == 1 && configuration.isSelfSignedCertificateEnabled())
|
||||||
{
|
{
|
||||||
System.out.println("Accepting self-signed certificate of remote server: " +
|
log.info("Accepting self-signed certificate of remote server: " + peerIdentities);
|
||||||
peerIdentities);
|
|
||||||
trusted = true;
|
trusted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -268,7 +269,7 @@ class ServerTrustManager implements X509TrustManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Other types are not good for XMPP so ignore them
|
// Other types are not good for XMPP so ignore them
|
||||||
System.out.println("SubjectAltName of invalid type found: " + certificate);
|
log.info("SubjectAltName of invalid type found: " + certificate);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
catch (CertificateParsingException e) {
|
catch (CertificateParsingException e) {
|
||||||
|
|
|
@ -788,7 +788,6 @@ public class XMPPConnection extends Connection {
|
||||||
if(config.getCallbackHandler() == null) {
|
if(config.getCallbackHandler() == null) {
|
||||||
ks = null;
|
ks = null;
|
||||||
} else if (context == null) {
|
} else if (context == null) {
|
||||||
//System.out.println("Keystore type: "+configuration.getKeystoreType());
|
|
||||||
if(config.getKeystoreType().equals("NONE")) {
|
if(config.getKeystoreType().equals("NONE")) {
|
||||||
ks = null;
|
ks = null;
|
||||||
pcb = null;
|
pcb = null;
|
||||||
|
|
|
@ -27,6 +27,8 @@ import java.io.ObjectOutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for XMPP packets. Every packet has a unique ID (which is automatically
|
* Base class for XMPP packets. Every packet has a unique ID (which is automatically
|
||||||
|
@ -41,7 +43,8 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
public abstract class Packet {
|
public abstract class Packet {
|
||||||
|
private static Logger log = Logger.getLogger(Packet.class.getName());
|
||||||
|
|
||||||
protected static final String DEFAULT_LANGUAGE =
|
protected static final String DEFAULT_LANGUAGE =
|
||||||
java.util.Locale.getDefault().getLanguage().toLowerCase();
|
java.util.Locale.getDefault().getLanguage().toLowerCase();
|
||||||
|
|
||||||
|
@ -411,7 +414,7 @@ public abstract class Packet {
|
||||||
buf.append(encodedVal).append("</value>");
|
buf.append(encodedVal).append("</value>");
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error encoding java object", e);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
|
|
|
@ -20,18 +20,21 @@
|
||||||
|
|
||||||
package org.jivesoftware.smack.parsing;
|
package org.jivesoftware.smack.parsing;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple parsing exception callback that only logs the encountered parsing exception to stderr.
|
* Simple parsing exception callback that only logs the encountered parsing exception to java util logging.
|
||||||
*
|
*
|
||||||
* @author Florian Schmaus
|
* @author Florian Schmaus
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ExceptionLoggingCallback extends ParsingExceptionCallback {
|
public class ExceptionLoggingCallback extends ParsingExceptionCallback {
|
||||||
|
private static Logger log = Logger.getLogger(ExceptionLoggingCallback.class.getName());
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleUnparsablePacket(UnparsablePacket unparsed) throws Exception {
|
public void handleUnparsablePacket(UnparsablePacket unparsed) throws Exception {
|
||||||
System.err.print("Smack message parsing exception: " + unparsed.getParsingException().getMessage());
|
log.log(Level.SEVERE, "Smack message parsing exception: ", unparsed.getParsingException());
|
||||||
unparsed.getParsingException().printStackTrace();
|
log.severe("Unparsed content: " + unparsed.getContent());
|
||||||
System.err.println("Unparsed content: " + unparsed.getContent());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,9 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smack.util;
|
package org.jivesoftware.smack.util;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Encodes and decodes to and from Base64 notation.</p>
|
* <p>Encodes and decodes to and from Base64 notation.</p>
|
||||||
|
@ -17,9 +20,9 @@ package org.jivesoftware.smack.util;
|
||||||
*/
|
*/
|
||||||
public class Base64
|
public class Base64
|
||||||
{
|
{
|
||||||
|
private static Logger log = Logger.getLogger(Base64.class.getName());
|
||||||
/* ******** P U B L I C F I E L D S ******** */
|
|
||||||
|
/* ******** P U B L I C F I E L D S ******** */
|
||||||
|
|
||||||
/** No options specified. Value is zero. */
|
/** No options specified. Value is zero. */
|
||||||
public final static int NO_OPTIONS = 0;
|
public final static int NO_OPTIONS = 0;
|
||||||
|
@ -311,18 +314,6 @@ public class Base64
|
||||||
/** Defeats instantiation. */
|
/** Defeats instantiation. */
|
||||||
private Base64(){}
|
private Base64(){}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints command line usage.
|
|
||||||
*
|
|
||||||
* @param msg A message to include with usage info.
|
|
||||||
*/
|
|
||||||
private final static void usage( String msg )
|
|
||||||
{
|
|
||||||
System.err.println( msg );
|
|
||||||
System.err.println( "Usage: java Base64 -e|-d inputfile outputfile" );
|
|
||||||
} // end usage
|
|
||||||
|
|
||||||
|
|
||||||
/* ******** E N C O D I N G M E T H O D S ******** */
|
/* ******** E N C O D I N G M E T H O D S ******** */
|
||||||
|
|
||||||
|
|
||||||
|
@ -494,7 +485,7 @@ public class Base64
|
||||||
} // end try
|
} // end try
|
||||||
catch( java.io.IOException e )
|
catch( java.io.IOException e )
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error encoding object", e);
|
||||||
return null;
|
return null;
|
||||||
} // end catch
|
} // end catch
|
||||||
finally
|
finally
|
||||||
|
@ -623,7 +614,7 @@ public class Base64
|
||||||
} // end try
|
} // end try
|
||||||
catch( java.io.IOException e )
|
catch( java.io.IOException e )
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error encoding bytes", e);
|
||||||
return null;
|
return null;
|
||||||
} // end catch
|
} // end catch
|
||||||
finally
|
finally
|
||||||
|
@ -777,11 +768,12 @@ public class Base64
|
||||||
destination[ destOffset + 2 ] = (byte)( outBuff );
|
destination[ destOffset + 2 ] = (byte)( outBuff );
|
||||||
|
|
||||||
return 3;
|
return 3;
|
||||||
}catch( Exception e){
|
}catch( Exception e){
|
||||||
System.out.println(""+source[srcOffset]+ ": " + ( DECODABET[ source[ srcOffset ] ] ) );
|
log.log(Level.SEVERE, e.getMessage(), e);
|
||||||
System.out.println(""+source[srcOffset+1]+ ": " + ( DECODABET[ source[ srcOffset + 1 ] ] ) );
|
log.severe(""+source[srcOffset]+ ": " + ( DECODABET[ source[ srcOffset ] ] ) );
|
||||||
System.out.println(""+source[srcOffset+2]+ ": " + ( DECODABET[ source[ srcOffset + 2 ] ] ) );
|
log.severe(""+source[srcOffset+1]+ ": " + ( DECODABET[ source[ srcOffset + 1 ] ] ) );
|
||||||
System.out.println(""+source[srcOffset+3]+ ": " + ( DECODABET[ source[ srcOffset + 3 ] ] ) );
|
log.severe(""+source[srcOffset+2]+ ": " + ( DECODABET[ source[ srcOffset + 2 ] ] ) );
|
||||||
|
log.severe(""+source[srcOffset+3]+ ": " + ( DECODABET[ source[ srcOffset + 3 ] ] ) );
|
||||||
return -1;
|
return -1;
|
||||||
} // end catch
|
} // end catch
|
||||||
}
|
}
|
||||||
|
@ -839,7 +831,7 @@ public class Base64
|
||||||
} // end if: white space, equals sign or better
|
} // end if: white space, equals sign or better
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.err.println( "Bad Base64 input character at " + i + ": " + source[i] + "(decimal)" );
|
log.warning("Bad Base64 input character at " + i + ": " + source[i] + "(decimal)");
|
||||||
return null;
|
return null;
|
||||||
} // end else:
|
} // end else:
|
||||||
} // each input character
|
} // each input character
|
||||||
|
@ -967,12 +959,12 @@ public class Base64
|
||||||
} // end try
|
} // end try
|
||||||
catch( java.io.IOException e )
|
catch( java.io.IOException e )
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error reading object", e);
|
||||||
obj = null;
|
obj = null;
|
||||||
} // end catch
|
} // end catch
|
||||||
catch( java.lang.ClassNotFoundException e )
|
catch( java.lang.ClassNotFoundException e )
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Class not found for encoded object", e);
|
||||||
obj = null;
|
obj = null;
|
||||||
} // end catch
|
} // end catch
|
||||||
finally
|
finally
|
||||||
|
@ -1079,7 +1071,7 @@ public class Base64
|
||||||
// Check for size of file
|
// Check for size of file
|
||||||
if( file.length() > Integer.MAX_VALUE )
|
if( file.length() > Integer.MAX_VALUE )
|
||||||
{
|
{
|
||||||
System.err.println( "File is too big for this convenience method (" + file.length() + " bytes)." );
|
log.warning("File is too big for this convenience method (" + file.length() + " bytes).");
|
||||||
return null;
|
return null;
|
||||||
} // end if: file too big for int index
|
} // end if: file too big for int index
|
||||||
buffer = new byte[ (int)file.length() ];
|
buffer = new byte[ (int)file.length() ];
|
||||||
|
@ -1100,7 +1092,7 @@ public class Base64
|
||||||
} // end try
|
} // end try
|
||||||
catch( java.io.IOException e )
|
catch( java.io.IOException e )
|
||||||
{
|
{
|
||||||
System.err.println( "Error decoding from file " + filename );
|
log.log(Level.SEVERE, "Error decoding from file " + filename, e);
|
||||||
} // end catch: IOException
|
} // end catch: IOException
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1148,7 +1140,7 @@ public class Base64
|
||||||
} // end try
|
} // end try
|
||||||
catch( java.io.IOException e )
|
catch( java.io.IOException e )
|
||||||
{
|
{
|
||||||
System.err.println( "Error encoding from file " + filename );
|
log.log(Level.SEVERE, "Error encoding from file " + filename, e);
|
||||||
} // end catch: IOException
|
} // end catch: IOException
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -1175,7 +1167,7 @@ public class Base64
|
||||||
out.write( encoded.getBytes("US-ASCII") ); // Strict, 7-bit output.
|
out.write( encoded.getBytes("US-ASCII") ); // Strict, 7-bit output.
|
||||||
} // end try
|
} // end try
|
||||||
catch( java.io.IOException ex ) {
|
catch( java.io.IOException ex ) {
|
||||||
ex.printStackTrace();
|
log.log(Level.SEVERE, "Error encoding file " + infile, ex);
|
||||||
} // end catch
|
} // end catch
|
||||||
finally {
|
finally {
|
||||||
try { out.close(); }
|
try { out.close(); }
|
||||||
|
@ -1201,7 +1193,7 @@ public class Base64
|
||||||
out.write( decoded );
|
out.write( decoded );
|
||||||
} // end try
|
} // end try
|
||||||
catch( java.io.IOException ex ) {
|
catch( java.io.IOException ex ) {
|
||||||
ex.printStackTrace();
|
log.log(Level.SEVERE, "Error decoding file " + infile, ex);
|
||||||
} // end catch
|
} // end catch
|
||||||
finally {
|
finally {
|
||||||
try { out.close(); }
|
try { out.close(); }
|
||||||
|
|
|
@ -22,6 +22,7 @@ package org.jivesoftware.smack.util;
|
||||||
import org.jivesoftware.smack.util.collections.AbstractMapEntry;
|
import org.jivesoftware.smack.util.collections.AbstractMapEntry;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A specialized Map that is size-limited (using an LRU algorithm) and
|
* A specialized Map that is size-limited (using an LRU algorithm) and
|
||||||
|
@ -49,7 +50,7 @@ import java.util.*;
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
public class Cache<K, V> implements Map<K, V> {
|
public class Cache<K, V> implements Map<K, V> {
|
||||||
|
private static Logger log = Logger.getLogger(Cache.class.getName());
|
||||||
/**
|
/**
|
||||||
* The map the keys and values are stored in.
|
* The map the keys and values are stored in.
|
||||||
*/
|
*/
|
||||||
|
@ -382,8 +383,7 @@ public class Cache<K, V> implements Map<K, V> {
|
||||||
|
|
||||||
while (expireTime > node.timestamp) {
|
while (expireTime > node.timestamp) {
|
||||||
if (remove(node.object, true) == null) {
|
if (remove(node.object, true) == null) {
|
||||||
System.err.println("Error attempting to remove(" + node.object.toString() +
|
log.warning("Error attempting to remove(" + node.object.toString() + ") - cacheObject not found in cache!");
|
||||||
") - cacheObject not found in cache!");
|
|
||||||
// remove from the ageList
|
// remove from the ageList
|
||||||
node.remove();
|
node.remove();
|
||||||
}
|
}
|
||||||
|
@ -417,9 +417,7 @@ public class Cache<K, V> implements Map<K, V> {
|
||||||
for (int i=map.size(); i>desiredSize; i--) {
|
for (int i=map.size(); i>desiredSize; i--) {
|
||||||
// Get the key and invoke the remove method on it.
|
// Get the key and invoke the remove method on it.
|
||||||
if (remove(lastAccessedList.getLast().object, true) == null) {
|
if (remove(lastAccessedList.getLast().object, true) == null) {
|
||||||
System.err.println("Error attempting to cullCache with remove(" +
|
log.warning("Error attempting to cullCache with remove(" + lastAccessedList.getLast().object.toString() + ") - cacheObject not found in cache!");
|
||||||
lastAccessedList.getLast().object.toString() + ") - " +
|
|
||||||
"cacheObject not found in cache!");
|
|
||||||
lastAccessedList.getLast().remove();
|
lastAccessedList.getLast().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.Connection;
|
||||||
import org.jivesoftware.smack.packet.Authentication;
|
import org.jivesoftware.smack.packet.Authentication;
|
||||||
|
@ -57,7 +59,8 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
*/
|
*/
|
||||||
public class PacketParserUtils {
|
public class PacketParserUtils {
|
||||||
|
private static Logger logger = Logger.getLogger(PacketParserUtils.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Namespace used to store packet properties.
|
* Namespace used to store packet properties.
|
||||||
*/
|
*/
|
||||||
|
@ -198,7 +201,7 @@ public class PacketParserUtils {
|
||||||
type = Presence.Type.valueOf(typeString);
|
type = Presence.Type.valueOf(typeString);
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException iae) {
|
catch (IllegalArgumentException iae) {
|
||||||
System.err.println("Found invalid presence type " + typeString);
|
logger.warning("Found invalid presence type " + typeString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Presence presence = new Presence(type);
|
Presence presence = new Presence(type);
|
||||||
|
@ -242,7 +245,7 @@ public class PacketParserUtils {
|
||||||
presence.setMode(Presence.Mode.valueOf(modeText));
|
presence.setMode(Presence.Mode.valueOf(modeText));
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException iae) {
|
catch (IllegalArgumentException iae) {
|
||||||
System.err.println("Found invalid presence mode " + modeText);
|
logger.warning("Found invalid presence mode " + modeText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (elementName.equals("error")) {
|
else if (elementName.equals("error")) {
|
||||||
|
@ -263,7 +266,7 @@ public class PacketParserUtils {
|
||||||
presence.addExtension(PacketParserUtils.parsePacketExtension(elementName, namespace, parser));
|
presence.addExtension(PacketParserUtils.parsePacketExtension(elementName, namespace, parser));
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
System.err.println("Failed to parse extension packet in Presence packet.");
|
logger.warning("Failed to parse extension packet in Presence packet.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -639,7 +642,7 @@ public class PacketParserUtils {
|
||||||
value = in.readObject();
|
value = in.readObject();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
logger.log(Level.SEVERE, "Error parsing java object", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (name != null && value != null) {
|
if (name != null && value != null) {
|
||||||
|
@ -782,8 +785,7 @@ public class PacketParserUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException iae) {
|
catch (IllegalArgumentException iae) {
|
||||||
// Print stack trace. We shouldn't be getting an illegal error type.
|
logger.log(Level.SEVERE, "Could not find error type for " + type.toUpperCase(), iae);
|
||||||
iae.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return new XMPPError(Integer.parseInt(errorCode), errorType, condition, message, extensions);
|
return new XMPPError(Integer.parseInt(errorCode), errorType, condition, message, extensions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,8 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -41,7 +43,8 @@ import java.util.regex.Pattern;
|
||||||
* A collection of utility methods for String objects.
|
* A collection of utility methods for String objects.
|
||||||
*/
|
*/
|
||||||
public class StringUtils {
|
public class StringUtils {
|
||||||
|
private static Logger log = Logger.getLogger(StringUtils.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Date format as defined in XEP-0082 - XMPP Date and Time Profiles. The time zone is set to
|
* Date format as defined in XEP-0082 - XMPP Date and Time Profiles. The time zone is set to
|
||||||
* UTC.
|
* UTC.
|
||||||
|
@ -619,8 +622,7 @@ public class StringUtils {
|
||||||
digest = MessageDigest.getInstance("SHA-1");
|
digest = MessageDigest.getInstance("SHA-1");
|
||||||
}
|
}
|
||||||
catch (NoSuchAlgorithmException nsae) {
|
catch (NoSuchAlgorithmException nsae) {
|
||||||
System.err.println("Failed to load the SHA-1 MessageDigest. " +
|
log.log(Level.SEVERE, "Failed to load the SHA-1 MessageDigest. Smack will be unable to function normally.", nsae);
|
||||||
"Jive will be unable to function normally.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Now, compute hash.
|
// Now, compute hash.
|
||||||
|
@ -628,7 +630,7 @@ public class StringUtils {
|
||||||
digest.update(data.getBytes("UTF-8"));
|
digest.update(data.getBytes("UTF-8"));
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException e) {
|
catch (UnsupportedEncodingException e) {
|
||||||
System.err.println(e);
|
log.log(Level.SEVERE, "Error computing hash", e);
|
||||||
}
|
}
|
||||||
return encodeHex(digest.digest());
|
return encodeHex(digest.digest());
|
||||||
}
|
}
|
||||||
|
@ -664,7 +666,7 @@ public class StringUtils {
|
||||||
bytes = data.getBytes("ISO-8859-1");
|
bytes = data.getBytes("ISO-8859-1");
|
||||||
}
|
}
|
||||||
catch (UnsupportedEncodingException uee) {
|
catch (UnsupportedEncodingException uee) {
|
||||||
uee.printStackTrace();
|
throw new IllegalStateException(uee);
|
||||||
}
|
}
|
||||||
return encodeBase64(bytes);
|
return encodeBase64(bytes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,8 @@ import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.Connection;
|
||||||
|
@ -42,7 +44,8 @@ import org.jivesoftware.smackx.packet.MessageEvent;
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
*/
|
*/
|
||||||
public class MessageEventManager {
|
public class MessageEventManager {
|
||||||
|
private static Logger log = Logger.getLogger(MessageEventManager.class.getName());
|
||||||
|
|
||||||
private List<MessageEventNotificationListener> messageEventNotificationListeners = new ArrayList<MessageEventNotificationListener>();
|
private List<MessageEventNotificationListener> messageEventNotificationListeners = new ArrayList<MessageEventNotificationListener>();
|
||||||
private List<MessageEventRequestListener> messageEventRequestListeners = new ArrayList<MessageEventRequestListener>();
|
private List<MessageEventRequestListener> messageEventRequestListeners = new ArrayList<MessageEventRequestListener>();
|
||||||
|
|
||||||
|
@ -157,12 +160,8 @@ public class MessageEventManager {
|
||||||
for (int i = 0; i < listeners.length; i++) {
|
for (int i = 0; i < listeners.length; i++) {
|
||||||
method.invoke(listeners[i], new Object[] { from, packetID, this });
|
method.invoke(listeners[i], new Object[] { from, packetID, this });
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error while invoking MessageEventRequestListener", e);
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,12 +187,8 @@ public class MessageEventManager {
|
||||||
for (int i = 0; i < listeners.length; i++) {
|
for (int i = 0; i < listeners.length; i++) {
|
||||||
method.invoke(listeners[i], new Object[] { from, packetID });
|
method.invoke(listeners[i], new Object[] { from, packetID });
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error while invoking MessageEventNotificationListener", e);
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,8 @@ import org.jivesoftware.smackx.packet.MultipleAddresses;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A MultipleRecipientManager allows to send packets to multiple recipients by making use of
|
* A MultipleRecipientManager allows to send packets to multiple recipients by making use of
|
||||||
|
@ -42,7 +44,8 @@ import java.util.List;
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
*/
|
*/
|
||||||
public class MultipleRecipientManager {
|
public class MultipleRecipientManager {
|
||||||
|
private static Logger log = Logger.getLogger(MultipleRecipientManager.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a cache to hold the 100 most recently accessed elements for a period of
|
* Create a cache to hold the 100 most recently accessed elements for a period of
|
||||||
* 24 hours.
|
* 24 hours.
|
||||||
|
@ -309,13 +312,12 @@ public class MultipleRecipientManager {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Cache the discovered information
|
// Cache the discovered information
|
||||||
services.put(serviceName, serviceAddress == null ? "" : serviceAddress);
|
services.put(serviceName, serviceAddress == null ? "" : serviceAddress);
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error occurred retrieving multiple recipients service", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ import org.jivesoftware.smackx.packet.DiscoverInfo;
|
||||||
import org.jivesoftware.smackx.packet.XHTMLExtension;
|
import org.jivesoftware.smackx.packet.XHTMLExtension;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages XHTML formatted texts within messages. A XHTMLManager provides a high level access to
|
* Manages XHTML formatted texts within messages. A XHTMLManager provides a high level access to
|
||||||
|
@ -38,6 +40,8 @@ import java.util.Iterator;
|
||||||
*/
|
*/
|
||||||
public class XHTMLManager {
|
public class XHTMLManager {
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(XHTMLManager.class.getName());
|
||||||
|
|
||||||
private final static String namespace = "http://jabber.org/protocol/xhtml-im";
|
private final static String namespace = "http://jabber.org/protocol/xhtml-im";
|
||||||
|
|
||||||
// Enable the XHTML support on every established connection
|
// Enable the XHTML support on every established connection
|
||||||
|
@ -137,7 +141,7 @@ public class XHTMLManager {
|
||||||
return result.containsFeature(namespace);
|
return result.containsFeature(namespace);
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error checking if service is available", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.SmackConfiguration;
|
import org.jivesoftware.smack.SmackConfiguration;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
|
@ -67,7 +69,8 @@ import org.jivesoftware.smack.XMPPException;
|
||||||
* @author Henning Staib
|
* @author Henning Staib
|
||||||
*/
|
*/
|
||||||
public class Socks5Proxy {
|
public class Socks5Proxy {
|
||||||
|
private static Logger log = Logger.getLogger(Socks5Proxy.class.getName());
|
||||||
|
|
||||||
/* SOCKS5 proxy singleton */
|
/* SOCKS5 proxy singleton */
|
||||||
private static Socks5Proxy socks5Server;
|
private static Socks5Proxy socks5Server;
|
||||||
|
|
||||||
|
@ -150,8 +153,7 @@ public class Socks5Proxy {
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
// couldn't setup server
|
// couldn't setup server
|
||||||
System.err.println("couldn't setup local SOCKS5 proxy on port "
|
log.log(Level.SEVERE, "couldn't setup local SOCKS5 proxy on port " + SmackConfiguration.getLocalSocks5ProxyPort(), e);
|
||||||
+ SmackConfiguration.getLocalSocks5ProxyPort() + ": " + e.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An AdHocCommandManager is responsible for keeping the list of available
|
* An AdHocCommandManager is responsible for keeping the list of available
|
||||||
|
@ -58,7 +59,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
* @author Gabriel Guardincerri
|
* @author Gabriel Guardincerri
|
||||||
*/
|
*/
|
||||||
public class AdHocCommandManager {
|
public class AdHocCommandManager {
|
||||||
|
|
||||||
private static final String DISCO_NAMESPACE = "http://jabber.org/protocol/commands";
|
private static final String DISCO_NAMESPACE = "http://jabber.org/protocol/commands";
|
||||||
|
|
||||||
private static final String discoNode = DISCO_NAMESPACE;
|
private static final String discoNode = DISCO_NAMESPACE;
|
||||||
|
@ -470,7 +470,6 @@ public class AdHocCommandManager {
|
||||||
executingCommands.remove(sessionId);
|
executingCommands.remove(sessionId);
|
||||||
}
|
}
|
||||||
respondError(response, error);
|
respondError(response, error);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -527,7 +526,7 @@ public class AdHocCommandManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO: Check that all the requierd fields of the form are
|
// TODO: Check that all the required fields of the form are
|
||||||
// TODO: filled, if not throw an exception. This will simplify the
|
// TODO: filled, if not throw an exception. This will simplify the
|
||||||
// TODO: construction of new commands
|
// TODO: construction of new commands
|
||||||
|
|
||||||
|
@ -585,8 +584,6 @@ public class AdHocCommandManager {
|
||||||
executingCommands.remove(sessionId);
|
executingCommands.remove(sessionId);
|
||||||
}
|
}
|
||||||
respondError(response, error);
|
respondError(response, error);
|
||||||
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -650,12 +647,10 @@ public class AdHocCommandManager {
|
||||||
command.setNode(commandInfo.getNode());
|
command.setNode(commandInfo.getNode());
|
||||||
}
|
}
|
||||||
catch (InstantiationException e) {
|
catch (InstantiationException e) {
|
||||||
e.printStackTrace();
|
|
||||||
throw new XMPPException(new XMPPError(
|
throw new XMPPException(new XMPPError(
|
||||||
XMPPError.Condition.interna_server_error));
|
XMPPError.Condition.interna_server_error));
|
||||||
}
|
}
|
||||||
catch (IllegalAccessException e) {
|
catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
|
||||||
throw new XMPPException(new XMPPError(
|
throw new XMPPException(new XMPPError(
|
||||||
XMPPError.Condition.interna_server_error));
|
XMPPError.Condition.interna_server_error));
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ import java.io.Writer;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The EnhancedDebugger is a debugger that allows to debug sent, received and interpreted messages
|
* The EnhancedDebugger is a debugger that allows to debug sent, received and interpreted messages
|
||||||
|
@ -64,6 +66,8 @@ import java.util.Date;
|
||||||
*/
|
*/
|
||||||
public class EnhancedDebugger implements SmackDebugger {
|
public class EnhancedDebugger implements SmackDebugger {
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(EnhancedDebugger.class.getName());
|
||||||
|
|
||||||
private static final String NEWLINE = "\n";
|
private static final String NEWLINE = "\n";
|
||||||
|
|
||||||
private static ImageIcon packetReceivedIcon;
|
private static ImageIcon packetReceivedIcon;
|
||||||
|
@ -427,7 +431,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
receivedText.replaceRange("", 0, receivedText.getLineEndOffset(0));
|
receivedText.replaceRange("", 0, receivedText.getLineEndOffset(0));
|
||||||
}
|
}
|
||||||
catch (BadLocationException e) {
|
catch (BadLocationException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error with line offset, MAX_TABLE_ROWS is set too low: " + EnhancedDebuggerWindow.MAX_TABLE_ROWS, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
receivedText.append(str.substring(0, index + 1));
|
receivedText.append(str.substring(0, index + 1));
|
||||||
|
@ -462,7 +466,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
sentText.replaceRange("", 0, sentText.getLineEndOffset(0));
|
sentText.replaceRange("", 0, sentText.getLineEndOffset(0));
|
||||||
}
|
}
|
||||||
catch (BadLocationException e) {
|
catch (BadLocationException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error with line offset, MAX_TABLE_ROWS is set too low: " + EnhancedDebuggerWindow.MAX_TABLE_ROWS, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -895,28 +899,10 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (TransformerConfigurationException tce) {
|
catch (TransformerConfigurationException tce) {
|
||||||
// Error generated by the parser
|
log.log(Level.SEVERE, "Transformer Factory error", tce);
|
||||||
System.out.println("\n** Transformer Factory error");
|
|
||||||
System.out.println(" " + tce.getMessage());
|
|
||||||
|
|
||||||
// Use the contained exception, if any
|
|
||||||
Throwable x = tce;
|
|
||||||
if (tce.getException() != null)
|
|
||||||
x = tce.getException();
|
|
||||||
x.printStackTrace();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (TransformerException te) {
|
catch (TransformerException te) {
|
||||||
// Error generated by the parser
|
log.log(Level.SEVERE, "Transformation error", te);
|
||||||
System.out.println("\n** Transformation error");
|
|
||||||
System.out.println(" " + te.getMessage());
|
|
||||||
|
|
||||||
// Use the contained exception, if any
|
|
||||||
Throwable x = te;
|
|
||||||
if (te.getException() != null)
|
|
||||||
x = te.getException();
|
|
||||||
x.printStackTrace();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.provider.IQProvider;
|
import org.jivesoftware.smack.provider.IQProvider;
|
||||||
|
@ -40,13 +42,14 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||||
/**
|
/**
|
||||||
* Simple implementation of an EntityCapsPersistentCache that uses a directory
|
* Simple implementation of an EntityCapsPersistentCache that uses a directory
|
||||||
* to store the Caps information for every known node. Every node is represented
|
* to store the Caps information for every known node. Every node is represented
|
||||||
* by an file.
|
* by a file.
|
||||||
*
|
*
|
||||||
* @author Florian Schmaus
|
* @author Florian Schmaus
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache {
|
public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache {
|
||||||
|
private static Logger log = Logger.getLogger(SimpleDirectoryPersistentCache.class.getName());
|
||||||
|
|
||||||
private File cacheDir;
|
private File cacheDir;
|
||||||
private StringEncoder filenameEncoder;
|
private StringEncoder filenameEncoder;
|
||||||
|
|
||||||
|
@ -55,7 +58,7 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
||||||
* cacheDir exists and that it's an directory.
|
* cacheDir exists and that it's an directory.
|
||||||
* <p>
|
* <p>
|
||||||
* Default filename encoder {@link Base32Encoder}, as this will work on all
|
* Default filename encoder {@link Base32Encoder}, as this will work on all
|
||||||
* filesystems, both case sensitive and case insensitive. It does however
|
* file systems, both case sensitive and case insensitive. It does however
|
||||||
* produce longer filenames.
|
* produce longer filenames.
|
||||||
*
|
*
|
||||||
* @param cacheDir
|
* @param cacheDir
|
||||||
|
@ -92,7 +95,7 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
||||||
if (nodeFile.createNewFile())
|
if (nodeFile.createNewFile())
|
||||||
writeInfoToFile(nodeFile, info);
|
writeInfoToFile(nodeFile, info);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Failed to write disco info to file", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +164,7 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
||||||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
|
||||||
parser.setInput(reader);
|
parser.setInput(reader);
|
||||||
} catch (XmlPullParserException xppe) {
|
} catch (XmlPullParserException xppe) {
|
||||||
xppe.printStackTrace();
|
log.log(Level.SEVERE, "Exception initializing parser", xppe);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Chat;
|
import org.jivesoftware.smack.Chat;
|
||||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||||
|
@ -76,7 +78,8 @@ import org.jivesoftware.smackx.packet.MUCUser;
|
||||||
* @author Gaston Dombiak, Larry Kirschner
|
* @author Gaston Dombiak, Larry Kirschner
|
||||||
*/
|
*/
|
||||||
public class MultiUserChat {
|
public class MultiUserChat {
|
||||||
|
private static Logger log = Logger.getLogger(MultiUserChat.class.getName());
|
||||||
|
|
||||||
private final static String discoNamespace = "http://jabber.org/protocol/muc";
|
private final static String discoNamespace = "http://jabber.org/protocol/muc";
|
||||||
private final static String discoNode = "http://jabber.org/protocol/muc#rooms";
|
private final static String discoNode = "http://jabber.org/protocol/muc#rooms";
|
||||||
|
|
||||||
|
@ -179,7 +182,7 @@ public class MultiUserChat {
|
||||||
return result.containsFeature(discoNamespace);
|
return result.containsFeature(discoNamespace);
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error checking user [" + user + "] for MUC support", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,7 +225,7 @@ public class MultiUserChat {
|
||||||
return answer.iterator();
|
return answer.iterator();
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error getting joined rooms for user [" + user + "]", e);
|
||||||
// Return an iterator on an empty collection
|
// Return an iterator on an empty collection
|
||||||
return new ArrayList<String>().iterator();
|
return new ArrayList<String>().iterator();
|
||||||
}
|
}
|
||||||
|
@ -953,13 +956,12 @@ public class MultiUserChat {
|
||||||
DiscoverInfo.Identity identity = identities.next();
|
DiscoverInfo.Identity identity = identities.next();
|
||||||
return identity.getName();
|
return identity.getName();
|
||||||
}
|
}
|
||||||
// If no Identity was found then the user does not have a reserved room nickname
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
catch (XMPPException e) {
|
catch (XMPPException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error retrieving room nickname", e);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
// If no Identity was found then the user does not have a reserved room nickname
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2061,11 +2063,11 @@ public class MultiUserChat {
|
||||||
method.invoke(listener, params);
|
method.invoke(listener, params);
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Failed to invoke method on UserStatusListener", e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Failed to invoke method on UserStatusListener", e);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Failed to invoke method on UserStatusListener", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2112,11 +2114,11 @@ public class MultiUserChat {
|
||||||
method.invoke(listener, params.toArray());
|
method.invoke(listener, params.toArray());
|
||||||
}
|
}
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Failed to invoke method on ParticipantStatusListener", e);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Failed to invoke method on ParticipantStatusListener", e);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Failed to invoke method on ParticipantStatusListener", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,8 @@ import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Time IQ packet, which is used by XMPP clients to exchange their respective local
|
* A Time IQ packet, which is used by XMPP clients to exchange their respective local
|
||||||
|
@ -61,7 +63,8 @@ import java.util.TimeZone;
|
||||||
* @author Matt Tucker
|
* @author Matt Tucker
|
||||||
*/
|
*/
|
||||||
public class Time extends IQ {
|
public class Time extends IQ {
|
||||||
|
private static Logger log = Logger.getLogger(Time.class.getName());
|
||||||
|
|
||||||
private static SimpleDateFormat utcFormat = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
|
private static SimpleDateFormat utcFormat = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
|
||||||
private static DateFormat displayFormat = DateFormat.getDateTimeInstance();
|
private static DateFormat displayFormat = DateFormat.getDateTimeInstance();
|
||||||
|
|
||||||
|
@ -94,7 +97,7 @@ public class Time extends IQ {
|
||||||
/**
|
/**
|
||||||
* Returns the local time or <tt>null</tt> if the time hasn't been set.
|
* Returns the local time or <tt>null</tt> if the time hasn't been set.
|
||||||
*
|
*
|
||||||
* @return the lcocal time.
|
* @return the local time.
|
||||||
*/
|
*/
|
||||||
public Date getTime() {
|
public Date getTime() {
|
||||||
if (utc == null) {
|
if (utc == null) {
|
||||||
|
@ -109,7 +112,7 @@ public class Time extends IQ {
|
||||||
date = cal.getTime();
|
date = cal.getTime();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error getting local time", e);
|
||||||
}
|
}
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,8 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.Connection;
|
import org.jivesoftware.smack.Connection;
|
||||||
import org.jivesoftware.smack.PacketCollector;
|
import org.jivesoftware.smack.PacketCollector;
|
||||||
|
@ -85,6 +87,8 @@ import org.jivesoftware.smack.util.StringUtils;
|
||||||
* @author Kirill Maximov (kir@maxkir.com)
|
* @author Kirill Maximov (kir@maxkir.com)
|
||||||
*/
|
*/
|
||||||
public class VCard extends IQ {
|
public class VCard extends IQ {
|
||||||
|
private static Logger log = Logger.getLogger(VCard.class.getName());
|
||||||
|
|
||||||
private static final String DEFAULT_MIME_TYPE = "image/jpeg";
|
private static final String DEFAULT_MIME_TYPE = "image/jpeg";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -332,7 +336,7 @@ public class VCard extends IQ {
|
||||||
bytes = getBytes(avatarURL);
|
bytes = getBytes(avatarURL);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error getting bytes from URL: " + avatarURL, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAvatar(bytes);
|
setAvatar(bytes);
|
||||||
|
@ -489,7 +493,7 @@ public class VCard extends IQ {
|
||||||
digest = MessageDigest.getInstance("SHA-1");
|
digest = MessageDigest.getInstance("SHA-1");
|
||||||
}
|
}
|
||||||
catch (NoSuchAlgorithmException e) {
|
catch (NoSuchAlgorithmException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Failed to get message digest", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,7 +586,7 @@ public class VCard extends IQ {
|
||||||
result = (VCard) packet;
|
result = (VCard) packet;
|
||||||
}
|
}
|
||||||
catch (ClassCastException e) {
|
catch (ClassCastException e) {
|
||||||
System.out.println("No VCard for " + user);
|
log.log(Level.SEVERE, "No VCard for " + user, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ package org.jivesoftware.smackx.provider;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.IQ;
|
import org.jivesoftware.smack.packet.IQ;
|
||||||
import org.jivesoftware.smack.provider.IQProvider;
|
import org.jivesoftware.smack.provider.IQProvider;
|
||||||
|
@ -37,7 +39,8 @@ import org.xmlpull.v1.XmlPullParser;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class StreamInitiationProvider implements IQProvider {
|
public class StreamInitiationProvider implements IQProvider {
|
||||||
|
private static Logger log = Logger.getLogger(StreamInitiationProvider.class.getName());
|
||||||
|
|
||||||
public IQ parseIQ(final XmlPullParser parser) throws Exception {
|
public IQ parseIQ(final XmlPullParser parser) throws Exception {
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
|
|
||||||
|
@ -90,7 +93,7 @@ public class StreamInitiationProvider implements IQProvider {
|
||||||
fileSize = Long.parseLong(size);
|
fileSize = Long.parseLong(size);
|
||||||
}
|
}
|
||||||
catch (NumberFormatException e) {
|
catch (NumberFormatException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Failed to parse file size from " + fileSize, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vCard provider.
|
* vCard provider.
|
||||||
|
@ -42,7 +44,8 @@ import java.util.List;
|
||||||
* @author Derek DeMoro
|
* @author Derek DeMoro
|
||||||
*/
|
*/
|
||||||
public class VCardProvider implements IQProvider {
|
public class VCardProvider implements IQProvider {
|
||||||
|
private static Logger log = Logger.getLogger(VCardProvider.class.getName());
|
||||||
|
|
||||||
private static final String PREFERRED_ENCODING = "UTF-8";
|
private static final String PREFERRED_ENCODING = "UTF-8";
|
||||||
|
|
||||||
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
public IQ parseIQ(XmlPullParser parser) throws Exception {
|
||||||
|
@ -71,10 +74,10 @@ public class VCardProvider implements IQProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (XmlPullParserException e) {
|
catch (XmlPullParserException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Exception parsing VCard", e);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Exception parsing VCard", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
String xmlText = sb.toString();
|
String xmlText = sb.toString();
|
||||||
|
|
|
@ -37,6 +37,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manges information about the agents in a workgroup and their presence.
|
* Manges information about the agents in a workgroup and their presence.
|
||||||
|
@ -45,7 +46,7 @@ import java.util.Set;
|
||||||
* @see AgentSession#getAgentRoster()
|
* @see AgentSession#getAgentRoster()
|
||||||
*/
|
*/
|
||||||
public class AgentRoster {
|
public class AgentRoster {
|
||||||
|
private static Logger log = Logger.getLogger(AgentRoster.class.getName());
|
||||||
private static final int EVENT_AGENT_ADDED = 0;
|
private static final int EVENT_AGENT_ADDED = 0;
|
||||||
private static final int EVENT_AGENT_REMOVED = 1;
|
private static final int EVENT_AGENT_REMOVED = 1;
|
||||||
private static final int EVENT_PRESENCE_CHANGED = 2;
|
private static final int EVENT_PRESENCE_CHANGED = 2;
|
||||||
|
@ -284,7 +285,7 @@ public class AgentRoster {
|
||||||
String from = presence.getFrom();
|
String from = presence.getFrom();
|
||||||
if (from == null) {
|
if (from == null) {
|
||||||
// TODO Check if we need to ignore these presences or this is a server bug?
|
// TODO Check if we need to ignore these presences or this is a server bug?
|
||||||
System.out.println("Presence with no FROM: " + presence.toXML());
|
log.warning("Presence with no FROM: " + presence.toXML());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String key = getPresenceMapKey(from);
|
String key = getPresenceMapKey(from);
|
||||||
|
|
|
@ -40,6 +40,8 @@ import org.jivesoftware.smackx.ReportedData;
|
||||||
import org.jivesoftware.smackx.packet.MUCUser;
|
import org.jivesoftware.smackx.packet.MUCUser;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class embodies the agent's active presence within a given workgroup. The application
|
* This class embodies the agent's active presence within a given workgroup. The application
|
||||||
|
@ -53,7 +55,8 @@ import java.util.*;
|
||||||
* @author Derek DeMoro
|
* @author Derek DeMoro
|
||||||
*/
|
*/
|
||||||
public class AgentSession {
|
public class AgentSession {
|
||||||
|
private static Logger log = Logger.getLogger(AgentSession.class.getName());
|
||||||
|
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
private String workgroupJID;
|
private String workgroupJID;
|
||||||
|
@ -118,7 +121,7 @@ public class AgentSession {
|
||||||
handlePacket(packet);
|
handlePacket(packet);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
log.log(Level.SEVERE, "Error processing packet", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,13 +29,15 @@ import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue details packet extension, which contains details about the users
|
* Queue details packet extension, which contains details about the users
|
||||||
* currently in a queue.
|
* currently in a queue.
|
||||||
*/
|
*/
|
||||||
public class QueueDetails implements PacketExtension {
|
public class QueueDetails implements PacketExtension {
|
||||||
|
private static Logger log = Logger.getLogger(QueueDetails.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Element name of the packet extension.
|
* Element name of the packet extension.
|
||||||
*/
|
*/
|
||||||
|
@ -178,7 +180,7 @@ public class QueueDetails implements PacketExtension {
|
||||||
}
|
}
|
||||||
else if( parser.getName().equals( "waitTime" ) ) {
|
else if( parser.getName().equals( "waitTime" ) ) {
|
||||||
Date wait = dateFormat.parse(parser.nextText());
|
Date wait = dateFormat.parse(parser.nextText());
|
||||||
System.out.println( wait );
|
log.fine(wait.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
eventType = parser.next();
|
eventType = parser.next();
|
||||||
|
|
|
@ -849,20 +849,4 @@ public class Workgroup {
|
||||||
}
|
}
|
||||||
return Form.getFormFrom(response);
|
return Form.getFormFrom(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public static void main(String args[]) throws Exception {
|
|
||||||
Connection con = new XMPPConnection("anteros");
|
|
||||||
con.connect();
|
|
||||||
con.loginAnonymously();
|
|
||||||
|
|
||||||
Workgroup workgroup = new Workgroup("demo@workgroup.anteros", con);
|
|
||||||
WorkgroupProperties props = workgroup.getWorkgroupProperties("derek@anteros.com");
|
|
||||||
|
|
||||||
System.out.print(props);
|
|
||||||
con.disconnect();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -19,6 +19,8 @@ package org.jivesoftware.smackx.workgroup.util;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is a very flexible event dispatcher which implements Runnable so that it can
|
* This class is a very flexible event dispatcher which implements Runnable so that it can
|
||||||
|
@ -32,8 +34,8 @@ import java.util.ListIterator;
|
||||||
*
|
*
|
||||||
* @author loki der quaeler
|
* @author loki der quaeler
|
||||||
*/
|
*/
|
||||||
public class ListenerEventDispatcher
|
public class ListenerEventDispatcher implements Runnable {
|
||||||
implements Runnable {
|
private static Logger log = Logger.getLogger(ListenerEventDispatcher.class.getName());
|
||||||
|
|
||||||
protected transient ArrayList<TripletContainer> triplets;
|
protected transient ArrayList<TripletContainer> triplets;
|
||||||
|
|
||||||
|
@ -93,9 +95,7 @@ public class ListenerEventDispatcher
|
||||||
try {
|
try {
|
||||||
tc.getListenerMethod().invoke(tc.getListenerInstance(), tc.getMethodArguments());
|
tc.getListenerMethod().invoke(tc.getListenerInstance(), tc.getMethodArguments());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Exception dispatching an event: " + e);
|
log.log(Level.SEVERE, "Exception dispatching an event", e);
|
||||||
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue