1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-23 21:17:58 +01:00

Added option to recreate wrappers of new reader and writer. SMACK-76

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2730 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2005-08-27 02:23:36 +00:00 committed by gato
parent 991e958097
commit 523beeac55
4 changed files with 68 additions and 4 deletions

View file

@ -111,13 +111,29 @@ public class ConsoleDebugger implements SmackDebugger {
};
}
public Reader newConnectionReader(Reader newReader) {
((ObservableReader)reader).removeReaderListener(readerListener);
ObservableReader debugReader = new ObservableReader(newReader);
debugReader.addReaderListener(readerListener);
reader = debugReader;
return reader;
}
public Writer newConnectionWriter(Writer newWriter) {
((ObservableWriter)writer).removeWriterListener(writerListener);
ObservableWriter debugWriter = new ObservableWriter(newWriter);
debugWriter.addWriterListener(writerListener);
writer = debugWriter;
return writer;
}
public void userHasLogged(String user) {
boolean isAnonymous = "".equals(StringUtils.parseName(user));
String title =
"User logged (" + connection.hashCode() + "): "
+ (isAnonymous ? "" : StringUtils.parseBareAddress(user))
+ "@"
+ connection.getHost()
+ connection.getServiceName()
+ ":"
+ connection.getPort();
title += "/" + StringUtils.parseResource(user);

View file

@ -62,7 +62,7 @@ public class LiteDebugger implements SmackDebugger {
* Creates the debug process, which is a GUI window that displays XML traffic.
*/
private void createDebug() {
frame = new JFrame("Smack Debug Window -- " + connection.getHost() + ":" +
frame = new JFrame("Smack Debug Window -- " + connection.getServiceName() + ":" +
connection.getPort());
// Add listener for window closing event
@ -289,13 +289,29 @@ public class LiteDebugger implements SmackDebugger {
}
}
public Reader newConnectionReader(Reader newReader) {
((ObservableReader)reader).removeReaderListener(readerListener);
ObservableReader debugReader = new ObservableReader(newReader);
debugReader.addReaderListener(readerListener);
reader = debugReader;
return reader;
}
public Writer newConnectionWriter(Writer newWriter) {
((ObservableWriter)writer).removeWriterListener(writerListener);
ObservableWriter debugWriter = new ObservableWriter(newWriter);
debugWriter.addWriterListener(writerListener);
writer = debugWriter;
return writer;
}
public void userHasLogged(String user) {
boolean isAnonymous = "".equals(StringUtils.parseName(user));
String title =
"Smack Debug Window -- "
+ (isAnonymous ? "" : StringUtils.parseBareAddress(user))
+ "@"
+ connection.getHost()
+ connection.getServiceName()
+ ":"
+ connection.getPort();
title += "/" + StringUtils.parseResource(user);

View file

@ -58,6 +58,22 @@ public interface SmackDebugger {
*/
public abstract Writer getWriter();
/**
* Returns a new special Reader that wraps the new connection Reader. The connection
* has been secured so he now have a new reader and writer.
*
* @return a new special Reader that wraps the new connection Reader.
*/
public abstract Reader newConnectionReader(Reader reader);
/**
* Returns a new special Writer that wraps the new connection Writer. The connection
* has been secured so he now have a new reader and writer.
*
* @return a new special Writer that wraps the new connection Writer.
*/
public abstract Writer newConnectionWriter(Writer writer);
/**
* Returns the thread that will listen for all incoming packets and write them to the GUI.
* This is what we call "interpreted" packet data, since it's the packet data as Smack sees

View file

@ -452,7 +452,7 @@ public class EnhancedDebugger implements SmackDebugger {
connPanel.add(
label,
new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
JFormattedTextField field = new JFormattedTextField(connection.getHost());
JFormattedTextField field = new JFormattedTextField(connection.getServiceName());
field.setMinimumSize(new java.awt.Dimension(150, 20));
field.setMaximumSize(new java.awt.Dimension(150, 20));
field.setEditable(false);
@ -561,6 +561,22 @@ public class EnhancedDebugger implements SmackDebugger {
tabbedPane.setToolTipTextAt(4, "Information and statistics about the debugged connection");
}
public Reader newConnectionReader(Reader newReader) {
((ObservableReader)reader).removeReaderListener(readerListener);
ObservableReader debugReader = new ObservableReader(newReader);
debugReader.addReaderListener(readerListener);
reader = debugReader;
return reader;
}
public Writer newConnectionWriter(Writer newWriter) {
((ObservableWriter)writer).removeWriterListener(writerListener);
ObservableWriter debugWriter = new ObservableWriter(newWriter);
debugWriter.addWriterListener(writerListener);
writer = debugWriter;
return writer;
}
public void userHasLogged(String user) {
userField.setText(user);
EnhancedDebuggerWindow.userHasLogged(this, user);