more details connection error messages
This commit is contained in:
parent
a73cc24c3f
commit
4edd623a1e
|
@ -13,8 +13,6 @@ import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.util.JsonReader;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class Account extends AbstractEntity{
|
public class Account extends AbstractEntity{
|
||||||
|
|
||||||
|
@ -41,6 +39,8 @@ public class Account extends AbstractEntity{
|
||||||
public static final int STATUS_TLS_ERROR = 4;
|
public static final int STATUS_TLS_ERROR = 4;
|
||||||
public static final int STATUS_SERVER_NOT_FOUND = 5;
|
public static final int STATUS_SERVER_NOT_FOUND = 5;
|
||||||
|
|
||||||
|
public static final int STATUS_SERVER_REQUIRES_TLS = 6;
|
||||||
|
|
||||||
protected String username;
|
protected String username;
|
||||||
protected String server;
|
protected String server;
|
||||||
protected String password;
|
protected String password;
|
||||||
|
|
|
@ -819,8 +819,12 @@ public class XmppConnectionService extends Service {
|
||||||
disconnect(account);
|
disconnect(account);
|
||||||
}
|
}
|
||||||
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
|
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
|
||||||
|
if (account.getXmppConnection()==null) {
|
||||||
account.setXmppConnection(this.createConnection(account));
|
account.setXmppConnection(this.createConnection(account));
|
||||||
}
|
}
|
||||||
|
Thread thread = new Thread(account.getXmppConnection());
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
if (accountChangedListener != null)
|
if (accountChangedListener != null)
|
||||||
accountChangedListener.onAccountListChangedListener();
|
accountChangedListener.onAccountListChangedListener();
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,10 @@ public class ManageAccountActivity extends XmppActivity {
|
||||||
statusView.setText("no internet");
|
statusView.setText("no internet");
|
||||||
statusView.setTextColor(0xFFe92727);
|
statusView.setTextColor(0xFFe92727);
|
||||||
break;
|
break;
|
||||||
|
case Account.STATUS_SERVER_REQUIRES_TLS:
|
||||||
|
statusView.setText("server requires TLS");
|
||||||
|
statusView.setTextColor(0xFFe92727);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.math.BigInteger;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
import java.security.cert.CertPathValidatorException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -75,6 +76,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void connect() {
|
protected void connect() {
|
||||||
|
Log.d(LOGTAG, "connecting");
|
||||||
try {
|
try {
|
||||||
this.changeStatus(Account.STATUS_CONNECTING);
|
this.changeStatus(Account.STATUS_CONNECTING);
|
||||||
Bundle namePort = DNSHelper.getSRVRecord(account.getServer());
|
Bundle namePort = DNSHelper.getSRVRecord(account.getServer());
|
||||||
|
@ -143,6 +145,11 @@ public class XmppConnection implements Runnable {
|
||||||
processStreamError(nextTag);
|
processStreamError(nextTag);
|
||||||
} else if (nextTag.isStart("features")) {
|
} else if (nextTag.isStart("features")) {
|
||||||
processStreamFeatures(nextTag);
|
processStreamFeatures(nextTag);
|
||||||
|
if ((streamFeatures.getChildren().size() == 1)
|
||||||
|
&& (streamFeatures.hasChild("starttls"))
|
||||||
|
&& (!account.isOptionSet(Account.OPTION_USETLS))) {
|
||||||
|
changeStatus(Account.STATUS_SERVER_REQUIRES_TLS);
|
||||||
|
}
|
||||||
} else if (nextTag.isStart("proceed")) {
|
} else if (nextTag.isStart("proceed")) {
|
||||||
switchOverToTls(nextTag);
|
switchOverToTls(nextTag);
|
||||||
} else if (nextTag.isStart("success")) {
|
} else if (nextTag.isStart("success")) {
|
||||||
|
@ -156,12 +163,7 @@ public class XmppConnection implements Runnable {
|
||||||
break;
|
break;
|
||||||
} else if (nextTag.isStart("failure")) {
|
} else if (nextTag.isStart("failure")) {
|
||||||
Element failure = tagReader.readElement(nextTag);
|
Element failure = tagReader.readElement(nextTag);
|
||||||
Log.d(LOGTAG, "read failure element" + failure.toString());
|
changeStatus(Account.STATUS_UNAUTHORIZED);
|
||||||
account.setStatus(Account.STATUS_UNAUTHORIZED);
|
|
||||||
if (statusListener != null) {
|
|
||||||
statusListener.onStatusChanged(account);
|
|
||||||
}
|
|
||||||
tagWriter.writeTag(Tag.end("stream"));
|
|
||||||
} else if (nextTag.isStart("iq")) {
|
} else if (nextTag.isStart("iq")) {
|
||||||
processIq(nextTag);
|
processIq(nextTag);
|
||||||
} else if (nextTag.isStart("message")) {
|
} else if (nextTag.isStart("message")) {
|
||||||
|
@ -215,8 +217,8 @@ public class XmppConnection implements Runnable {
|
||||||
IqPacket packet = (IqPacket) processPacket(currentTag, PACKET_IQ);
|
IqPacket packet = (IqPacket) processPacket(currentTag, PACKET_IQ);
|
||||||
if (packetCallbacks.containsKey(packet.getId())) {
|
if (packetCallbacks.containsKey(packet.getId())) {
|
||||||
if (packetCallbacks.get(packet.getId()) instanceof OnIqPacketReceived) {
|
if (packetCallbacks.get(packet.getId()) instanceof OnIqPacketReceived) {
|
||||||
((OnIqPacketReceived) packetCallbacks.get(packet.getId())).onIqPacketReceived(account,
|
((OnIqPacketReceived) packetCallbacks.get(packet.getId()))
|
||||||
packet);
|
.onIqPacketReceived(account, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
packetCallbacks.remove(packet.getId());
|
packetCallbacks.remove(packet.getId());
|
||||||
|
@ -230,10 +232,10 @@ public class XmppConnection implements Runnable {
|
||||||
MessagePacket packet = (MessagePacket) processPacket(currentTag,
|
MessagePacket packet = (MessagePacket) processPacket(currentTag,
|
||||||
PACKET_MESSAGE);
|
PACKET_MESSAGE);
|
||||||
String id = packet.getAttribute("id");
|
String id = packet.getAttribute("id");
|
||||||
if ((id!=null)&&(packetCallbacks.containsKey(id))) {
|
if ((id != null) && (packetCallbacks.containsKey(id))) {
|
||||||
if (packetCallbacks.get(id) instanceof OnMessagePacketReceived) {
|
if (packetCallbacks.get(id) instanceof OnMessagePacketReceived) {
|
||||||
((OnMessagePacketReceived) packetCallbacks.get(id)).onMessagePacketReceived(account,
|
((OnMessagePacketReceived) packetCallbacks.get(id))
|
||||||
packet);
|
.onMessagePacketReceived(account, packet);
|
||||||
}
|
}
|
||||||
packetCallbacks.remove(id);
|
packetCallbacks.remove(id);
|
||||||
} else if (this.messageListener != null) {
|
} else if (this.messageListener != null) {
|
||||||
|
@ -246,10 +248,10 @@ public class XmppConnection implements Runnable {
|
||||||
PresencePacket packet = (PresencePacket) processPacket(currentTag,
|
PresencePacket packet = (PresencePacket) processPacket(currentTag,
|
||||||
PACKET_PRESENCE);
|
PACKET_PRESENCE);
|
||||||
String id = packet.getAttribute("id");
|
String id = packet.getAttribute("id");
|
||||||
if ((id!=null)&&(packetCallbacks.containsKey(id))) {
|
if ((id != null) && (packetCallbacks.containsKey(id))) {
|
||||||
if (packetCallbacks.get(id) instanceof OnPresencePacketReceived) {
|
if (packetCallbacks.get(id) instanceof OnPresencePacketReceived) {
|
||||||
((OnPresencePacketReceived) packetCallbacks.get(id)).onPresencePacketReceived(account,
|
((OnPresencePacketReceived) packetCallbacks.get(id))
|
||||||
packet);
|
.onPresencePacketReceived(account, packet);
|
||||||
}
|
}
|
||||||
packetCallbacks.remove(id);
|
packetCallbacks.remove(id);
|
||||||
} else if (this.presenceListener != null) {
|
} else if (this.presenceListener != null) {
|
||||||
|
@ -377,7 +379,7 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendEnableCarbons() {
|
private void sendEnableCarbons() {
|
||||||
Log.d(LOGTAG,account.getJid()+": enable carbons");
|
Log.d(LOGTAG, account.getJid() + ": enable carbons");
|
||||||
IqPacket iq = new IqPacket(IqPacket.TYPE_SET);
|
IqPacket iq = new IqPacket(IqPacket.TYPE_SET);
|
||||||
Element enable = new Element("enable");
|
Element enable = new Element("enable");
|
||||||
enable.setAttribute("xmlns", "urn:xmpp:carbons:2");
|
enable.setAttribute("xmlns", "urn:xmpp:carbons:2");
|
||||||
|
@ -387,9 +389,11 @@ public class XmppConnection implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket packet) {
|
public void onIqPacketReceived(Account account, IqPacket packet) {
|
||||||
if (!packet.hasChild("error")) {
|
if (!packet.hasChild("error")) {
|
||||||
Log.d(LOGTAG,account.getJid()+": successfully enabled carbons");
|
Log.d(LOGTAG, account.getJid()
|
||||||
|
+ ": successfully enabled carbons");
|
||||||
} else {
|
} else {
|
||||||
Log.d(LOGTAG,account.getJid()+": error enableing carbons "+packet.toString());
|
Log.d(LOGTAG, account.getJid()
|
||||||
|
+ ": error enableing carbons " + packet.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -427,7 +431,8 @@ public class XmppConnection implements Runnable {
|
||||||
this.sendMessagePacket(packet, null);
|
this.sendMessagePacket(packet, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendMessagePacket(MessagePacket packet, OnMessagePacketReceived callback) {
|
public void sendMessagePacket(MessagePacket packet,
|
||||||
|
OnMessagePacketReceived callback) {
|
||||||
String id = nextRandomId();
|
String id = nextRandomId();
|
||||||
packet.setAttribute("id", id);
|
packet.setAttribute("id", id);
|
||||||
tagWriter.writeElement(packet);
|
tagWriter.writeElement(packet);
|
||||||
|
@ -440,7 +445,8 @@ public class XmppConnection implements Runnable {
|
||||||
this.sendPresencePacket(packet, null);
|
this.sendPresencePacket(packet, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PresencePacket sendPresencePacket(PresencePacket packet, OnPresencePacketReceived callback) {
|
public PresencePacket sendPresencePacket(PresencePacket packet,
|
||||||
|
OnPresencePacketReceived callback) {
|
||||||
String id = nextRandomId();
|
String id = nextRandomId();
|
||||||
packet.setAttribute("id", id);
|
packet.setAttribute("id", id);
|
||||||
tagWriter.writeElement(packet);
|
tagWriter.writeElement(packet);
|
||||||
|
|
Loading…
Reference in a new issue