mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 04:22:05 +01:00
Fixes.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1844 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
044e9cf71c
commit
6fce8ec9f0
2 changed files with 24 additions and 11 deletions
|
@ -89,7 +89,7 @@ public class SSLXMPPConnection extends XMPPConnection {
|
||||||
throw new XMPPException("Could not connect to " + host + ":" + port + ".", uhe);
|
throw new XMPPException("Could not connect to " + host + ":" + port + ".", uhe);
|
||||||
}
|
}
|
||||||
catch (IOException ioe) {
|
catch (IOException ioe) {
|
||||||
throw new XMPPException("Error connecting to " + host + ":" + port + ".", ioe);
|
throw new XMPPException("XMPPError connecting to " + host + ":" + port + ".", ioe);
|
||||||
}
|
}
|
||||||
super.init();
|
super.init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
package org.jivesoftware.smack;
|
package org.jivesoftware.smack;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.*;
|
import org.jivesoftware.smack.packet.*;
|
||||||
import org.jivesoftware.smack.packet.Error;
|
import org.jivesoftware.smack.packet.XMPPError;
|
||||||
import org.jivesoftware.smack.filter.PacketIDFilter;
|
import org.jivesoftware.smack.filter.PacketIDFilter;
|
||||||
import org.jivesoftware.smack.filter.PacketFilter;
|
import org.jivesoftware.smack.filter.PacketFilter;
|
||||||
|
|
||||||
|
@ -98,6 +98,7 @@ public class XMPPConnection {
|
||||||
* command line such as "java SomeApp -Dsmack.debugEnabled=true".
|
* command line such as "java SomeApp -Dsmack.debugEnabled=true".
|
||||||
*/
|
*/
|
||||||
public static boolean DEBUG_ENABLED = Boolean.getBoolean("smack.debugEnabled");
|
public static boolean DEBUG_ENABLED = Boolean.getBoolean("smack.debugEnabled");
|
||||||
|
private JFrame debugFrame = null;
|
||||||
|
|
||||||
protected String host;
|
protected String host;
|
||||||
protected int port;
|
protected int port;
|
||||||
|
@ -149,7 +150,7 @@ public class XMPPConnection {
|
||||||
throw new XMPPException("Could not connect to " + host + ":" + port + ".", uhe);
|
throw new XMPPException("Could not connect to " + host + ":" + port + ".", uhe);
|
||||||
}
|
}
|
||||||
catch (IOException ioe) {
|
catch (IOException ioe) {
|
||||||
throw new XMPPException("Error connecting to " + host + ":" + port + ".", ioe);
|
throw new XMPPException("XMPPError connecting to " + host + ":" + port + ".", ioe);
|
||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
@ -228,10 +229,12 @@ public class XMPPConnection {
|
||||||
// Wait up to five seconds for a response from the server.
|
// Wait up to five seconds for a response from the server.
|
||||||
Authentication authTypes = (Authentication)collector.nextResult(5000);
|
Authentication authTypes = (Authentication)collector.nextResult(5000);
|
||||||
collector.cancel();
|
collector.cancel();
|
||||||
if (authTypes == null || authTypes.getType().equals(IQ.Type.ERROR)) {
|
if (authTypes == null) {
|
||||||
throw new XMPPException("No response from the server.");
|
throw new XMPPException("No response from the server.");
|
||||||
}
|
}
|
||||||
|
else if (authTypes.getType().equals(IQ.Type.ERROR)) {
|
||||||
|
throw new XMPPException(authTypes.getError());
|
||||||
|
}
|
||||||
|
|
||||||
// Now, create the authentication packet we'll send to the server.
|
// Now, create the authentication packet we'll send to the server.
|
||||||
Authentication auth = new Authentication();
|
Authentication auth = new Authentication();
|
||||||
|
@ -264,7 +267,7 @@ public class XMPPConnection {
|
||||||
throw new XMPPException("Authentication failed.");
|
throw new XMPPException("Authentication failed.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error error = response.getError();
|
XMPPError error = response.getError();
|
||||||
String msg = "Authentication failed -- " + error.getCode();
|
String msg = "Authentication failed -- " + error.getCode();
|
||||||
if (error.getMessage() != null) {
|
if (error.getMessage() != null) {
|
||||||
msg += ": " + error.getMessage();
|
msg += ": " + error.getMessage();
|
||||||
|
@ -280,6 +283,16 @@ public class XMPPConnection {
|
||||||
// Finally, create the roster.
|
// Finally, create the roster.
|
||||||
this.roster = new Roster(this);
|
this.roster = new Roster(this);
|
||||||
roster.reload();
|
roster.reload();
|
||||||
|
|
||||||
|
// If debugging is enabled, change the the debug window title to include the
|
||||||
|
// name we are now logged-in as.
|
||||||
|
if (DEBUG_ENABLED) {
|
||||||
|
String title = "Smack Debug Window -- " + username + "@" + getHost() + ":" + getPort();
|
||||||
|
if (resource != null) {
|
||||||
|
title += "/" + resource;
|
||||||
|
}
|
||||||
|
debugFrame.setTitle(title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Roster getRoster() {
|
public Roster getRoster() {
|
||||||
|
@ -403,7 +416,7 @@ public class XMPPConnection {
|
||||||
writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8"));
|
writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8"));
|
||||||
}
|
}
|
||||||
catch (IOException ioe) {
|
catch (IOException ioe) {
|
||||||
throw new XMPPException("Error establishing connection with server.", ioe);
|
throw new XMPPException("XMPPError establishing connection with server.", ioe);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If debugging is enabled, we open a window and write out all network traffic.
|
// If debugging is enabled, we open a window and write out all network traffic.
|
||||||
|
@ -451,7 +464,7 @@ public class XMPPConnection {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
JFrame frame = new JFrame("Smack Debug Window -- " + getHost() + ":" + getPort());
|
debugFrame = new JFrame("Smack Debug Window -- " + getHost() + ":" + getPort());
|
||||||
|
|
||||||
// We'll arrange the UI into four tabs. The first tab contains all data, the second
|
// We'll arrange the UI into four tabs. The first tab contains all data, the second
|
||||||
// client generated XML, the third server generated XML, and the fourth is packet
|
// client generated XML, the third server generated XML, and the fourth is packet
|
||||||
|
@ -492,10 +505,10 @@ public class XMPPConnection {
|
||||||
allPane.add(new JScrollPane(interpretedText1));
|
allPane.add(new JScrollPane(interpretedText1));
|
||||||
tabbedPane.add("Interpreted Packets", new JScrollPane(interpretedText2));
|
tabbedPane.add("Interpreted Packets", new JScrollPane(interpretedText2));
|
||||||
|
|
||||||
frame.getContentPane().add(tabbedPane);
|
debugFrame.getContentPane().add(tabbedPane);
|
||||||
|
|
||||||
frame.setSize(550, 400);
|
debugFrame.setSize(550, 400);
|
||||||
frame.show();
|
debugFrame.show();
|
||||||
|
|
||||||
// Create a special Reader that wraps the main Reader and logs data to the GUI.
|
// Create a special Reader that wraps the main Reader and logs data to the GUI.
|
||||||
Reader debugReader = new Reader() {
|
Reader debugReader = new Reader() {
|
||||||
|
|
Loading…
Reference in a new issue