mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-23 06:42:05 +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:
parent
991e958097
commit
523beeac55
4 changed files with 68 additions and 4 deletions
|
@ -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) {
|
public void userHasLogged(String user) {
|
||||||
boolean isAnonymous = "".equals(StringUtils.parseName(user));
|
boolean isAnonymous = "".equals(StringUtils.parseName(user));
|
||||||
String title =
|
String title =
|
||||||
"User logged (" + connection.hashCode() + "): "
|
"User logged (" + connection.hashCode() + "): "
|
||||||
+ (isAnonymous ? "" : StringUtils.parseBareAddress(user))
|
+ (isAnonymous ? "" : StringUtils.parseBareAddress(user))
|
||||||
+ "@"
|
+ "@"
|
||||||
+ connection.getHost()
|
+ connection.getServiceName()
|
||||||
+ ":"
|
+ ":"
|
||||||
+ connection.getPort();
|
+ connection.getPort();
|
||||||
title += "/" + StringUtils.parseResource(user);
|
title += "/" + StringUtils.parseResource(user);
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class LiteDebugger implements SmackDebugger {
|
||||||
* Creates the debug process, which is a GUI window that displays XML traffic.
|
* Creates the debug process, which is a GUI window that displays XML traffic.
|
||||||
*/
|
*/
|
||||||
private void createDebug() {
|
private void createDebug() {
|
||||||
frame = new JFrame("Smack Debug Window -- " + connection.getHost() + ":" +
|
frame = new JFrame("Smack Debug Window -- " + connection.getServiceName() + ":" +
|
||||||
connection.getPort());
|
connection.getPort());
|
||||||
|
|
||||||
// Add listener for window closing event
|
// 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) {
|
public void userHasLogged(String user) {
|
||||||
boolean isAnonymous = "".equals(StringUtils.parseName(user));
|
boolean isAnonymous = "".equals(StringUtils.parseName(user));
|
||||||
String title =
|
String title =
|
||||||
"Smack Debug Window -- "
|
"Smack Debug Window -- "
|
||||||
+ (isAnonymous ? "" : StringUtils.parseBareAddress(user))
|
+ (isAnonymous ? "" : StringUtils.parseBareAddress(user))
|
||||||
+ "@"
|
+ "@"
|
||||||
+ connection.getHost()
|
+ connection.getServiceName()
|
||||||
+ ":"
|
+ ":"
|
||||||
+ connection.getPort();
|
+ connection.getPort();
|
||||||
title += "/" + StringUtils.parseResource(user);
|
title += "/" + StringUtils.parseResource(user);
|
||||||
|
|
|
@ -58,6 +58,22 @@ public interface SmackDebugger {
|
||||||
*/
|
*/
|
||||||
public abstract Writer getWriter();
|
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.
|
* 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
|
* This is what we call "interpreted" packet data, since it's the packet data as Smack sees
|
||||||
|
|
|
@ -452,7 +452,7 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
connPanel.add(
|
connPanel.add(
|
||||||
label,
|
label,
|
||||||
new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 21, 0, new Insets(0, 0, 0, 0), 0, 0));
|
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.setMinimumSize(new java.awt.Dimension(150, 20));
|
||||||
field.setMaximumSize(new java.awt.Dimension(150, 20));
|
field.setMaximumSize(new java.awt.Dimension(150, 20));
|
||||||
field.setEditable(false);
|
field.setEditable(false);
|
||||||
|
@ -561,6 +561,22 @@ public class EnhancedDebugger implements SmackDebugger {
|
||||||
tabbedPane.setToolTipTextAt(4, "Information and statistics about the debugged connection");
|
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) {
|
public void userHasLogged(String user) {
|
||||||
userField.setText(user);
|
userField.setText(user);
|
||||||
EnhancedDebuggerWindow.userHasLogged(this, user);
|
EnhancedDebuggerWindow.userHasLogged(this, user);
|
||||||
|
|
Loading…
Reference in a new issue