bug fixes with leaving muc on connection loss.

This commit is contained in:
Daniel Gultsch 2014-03-16 14:12:30 +01:00
parent 0b3b0da2e8
commit 0116551ca9
4 changed files with 22 additions and 15 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.siacs.conversations" package="eu.siacs.conversations"
android:versionCode="1" android:versionCode="2"
android:versionName="0.1-rc1" > android:versionName="0.1-rc2" >
<uses-sdk <uses-sdk
android:minSdkVersion="14" android:minSdkVersion="14"

View file

@ -1082,6 +1082,7 @@ public class XmppConnectionService extends Service {
public void disconnect(Account account, boolean force) { public void disconnect(Account account, boolean force) {
if ((account.getStatus() == Account.STATUS_ONLINE)||(account.getStatus() == Account.STATUS_DISABLED)) { if ((account.getStatus() == Account.STATUS_ONLINE)||(account.getStatus() == Account.STATUS_DISABLED)) {
if (!force) {
List<Conversation> conversations = getConversations(); List<Conversation> conversations = getConversations();
for (int i = 0; i < conversations.size(); i++) { for (int i = 0; i < conversations.size(); i++) {
Conversation conversation = conversations.get(i); Conversation conversation = conversations.get(i);
@ -1093,6 +1094,7 @@ public class XmppConnectionService extends Service {
} }
} }
} }
}
account.getXmppConnection().disconnect(force); account.getXmppConnection().disconnect(force);
} }
} }

View file

@ -4,8 +4,6 @@ import java.util.ArrayList;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.List; import java.util.List;
import android.util.Log;
public class Element { public class Element {
protected String name; protected String name;
protected Hashtable<String, String> attributes = new Hashtable<String, String>(); protected Hashtable<String, String> attributes = new Hashtable<String, String>();
@ -83,7 +81,7 @@ public class Element {
startTag.setAtttributes(this.attributes); startTag.setAtttributes(this.attributes);
elementOutput.append(startTag); elementOutput.append(startTag);
if (content!=null) { if (content!=null) {
elementOutput.append(content); elementOutput.append(encodeEntities(content));
} else { } else {
for(Element child : children) { for(Element child : children) {
elementOutput.append(child.toString()); elementOutput.append(child.toString());
@ -98,4 +96,13 @@ public class Element {
public String getName() { public String getName() {
return name; return name;
} }
private String encodeEntities(String content) {
content = content.replace("&","&amp;");
content = content.replace("<","&lt;");
content = content.replace(">","&gt;");
content = content.replace("\"","&quot;");
content = content.replace("'","&apos;");
return content;
}
} }

View file

@ -676,10 +676,8 @@ public class XmppConnection implements Runnable {
public void sendPing() { public void sendPing() {
if (streamFeatures.hasChild("sm")) { if (streamFeatures.hasChild("sm")) {
Log.d(LOGTAG,account.getJid()+": sending r as ping");
tagWriter.writeStanzaAsync(new RequestPacket()); tagWriter.writeStanzaAsync(new RequestPacket());
} else { } else {
Log.d(LOGTAG,account.getJid()+": sending iq as ping");
IqPacket iq = new IqPacket(IqPacket.TYPE_GET); IqPacket iq = new IqPacket(IqPacket.TYPE_GET);
Element ping = new Element("ping"); Element ping = new Element("ping");
iq.setAttribute("from",account.getFullJid()); iq.setAttribute("from",account.getFullJid());