cleaned up some code. log last tag
This commit is contained in:
parent
8b44400940
commit
76828950ee
|
@ -29,7 +29,6 @@ import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
@ -286,7 +285,7 @@ public class XmppConnection implements Runnable {
|
||||||
Tag nextTag;
|
Tag nextTag;
|
||||||
while ((nextTag = tagReader.readTag()) != null) {
|
while ((nextTag = tagReader.readTag()) != null) {
|
||||||
if (nextTag.isStart("stream")) {
|
if (nextTag.isStart("stream")) {
|
||||||
processStream(nextTag);
|
processStream();
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("unknown tag on connect");
|
throw new IOException("unknown tag on connect");
|
||||||
|
@ -338,11 +337,9 @@ public class XmppConnection implements Runnable {
|
||||||
connect();
|
connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processStream(final Tag currentTag) throws XmlPullParserException,
|
private void processStream() throws XmlPullParserException, IOException, NoSuchAlgorithmException {
|
||||||
IOException, NoSuchAlgorithmException {
|
|
||||||
Tag nextTag = tagReader.readTag();
|
Tag nextTag = tagReader.readTag();
|
||||||
|
while (nextTag != null && !nextTag.isEnd("stream")) {
|
||||||
while ((nextTag != null) && (!nextTag.isEnd("stream"))) {
|
|
||||||
if (nextTag.isStart("error")) {
|
if (nextTag.isStart("error")) {
|
||||||
processStreamError(nextTag);
|
processStreamError(nextTag);
|
||||||
} else if (nextTag.isStart("features")) {
|
} else if (nextTag.isStart("features")) {
|
||||||
|
@ -362,7 +359,11 @@ public class XmppConnection implements Runnable {
|
||||||
String.valueOf(saslMechanism.getPriority()));
|
String.valueOf(saslMechanism.getPriority()));
|
||||||
tagReader.reset();
|
tagReader.reset();
|
||||||
sendStartStream();
|
sendStartStream();
|
||||||
processStream(tagReader.readTag());
|
if (tagReader.readTag().isStart("stream")) {
|
||||||
|
processStream();
|
||||||
|
} else {
|
||||||
|
throw new IOException("server didn't restart stream after successful auth");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
} else if (nextTag.isStart("failure")) {
|
} else if (nextTag.isStart("failure")) {
|
||||||
throw new UnauthorizedException();
|
throw new UnauthorizedException();
|
||||||
|
@ -458,6 +459,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
nextTag = tagReader.readTag();
|
nextTag = tagReader.readTag();
|
||||||
}
|
}
|
||||||
|
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": last tag was "+nextTag);
|
||||||
if (account.getStatus() == Account.State.ONLINE) {
|
if (account.getStatus() == Account.State.ONLINE) {
|
||||||
account. setStatus(Account.State.OFFLINE);
|
account. setStatus(Account.State.OFFLINE);
|
||||||
if (statusListener != null) {
|
if (statusListener != null) {
|
||||||
|
@ -644,7 +646,11 @@ public class XmppConnection implements Runnable {
|
||||||
sendStartStream();
|
sendStartStream();
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid()+ ": TLS connection established");
|
Log.d(Config.LOGTAG, account.getJid().toBareJid()+ ": TLS connection established");
|
||||||
features.encryptionEnabled = true;
|
features.encryptionEnabled = true;
|
||||||
processStream(tagReader.readTag());
|
if (tagReader.readTag().isStart("stream")) {
|
||||||
|
processStream();
|
||||||
|
} else {
|
||||||
|
throw new IOException("server didn't restart stream after STARTTLS");
|
||||||
|
}
|
||||||
sslSocket.close();
|
sslSocket.close();
|
||||||
} catch (final NoSuchAlgorithmException | KeyManagementException e1) {
|
} catch (final NoSuchAlgorithmException | KeyManagementException e1) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": TLS certificate verification failed");
|
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": TLS certificate verification failed");
|
||||||
|
|
Loading…
Reference in a new issue