aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs')
-rw-r--r--src/eu/siacs/conversations/crypto/OtrEngine.java1
-rw-r--r--src/eu/siacs/conversations/entities/MucOptions.java15
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java24
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java12
-rw-r--r--src/eu/siacs/conversations/utils/MessageParser.java7
5 files changed, 26 insertions, 33 deletions
diff --git a/src/eu/siacs/conversations/crypto/OtrEngine.java b/src/eu/siacs/conversations/crypto/OtrEngine.java
index 32cd26b6..3aa87658 100644
--- a/src/eu/siacs/conversations/crypto/OtrEngine.java
+++ b/src/eu/siacs/conversations/crypto/OtrEngine.java
@@ -162,6 +162,7 @@ public class OtrEngine implements OtrEngineHost {
privateTag.setAttribute("xmlns","urn:xmpp:carbons:2");
packet.addChild(privateTag);
packet.setType(MessagePacket.TYPE_CHAT);
+ Log.d(LOGTAG,packet.toString());
account.getXmppConnection().sendMessagePacket(packet);
}
diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java
index 16d9c6a8..4ed83a5a 100644
--- a/src/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/eu/siacs/conversations/entities/MucOptions.java
@@ -76,6 +76,7 @@ public class MucOptions {
private boolean isOnline = false;
private int error = 0;
private OnRenameListener renameListener = null;
+ private boolean aboutToRename = false;
private User self = new User();
private String subject = null;
@@ -121,6 +122,7 @@ public class MucOptions {
Element item = packet.findChild("x").findChild("item");
String nick = item.getAttribute("nick");
if (nick!=null) {
+ aboutToRename = false;
if (renameListener!=null) {
renameListener.onRename(true);
}
@@ -131,7 +133,14 @@ public class MucOptions {
} else if (type.equals("error")) {
Element error = packet.findChild("error");
if (error.hasChild("conflict")) {
- this.error = ERROR_NICK_IN_USE;
+ if (aboutToRename) {
+ if (renameListener!=null) {
+ renameListener.onRename(false);
+ }
+ aboutToRename = false;
+ } else {
+ this.error = ERROR_NICK_IN_USE;
+ }
}
}
}
@@ -195,4 +204,8 @@ public class MucOptions {
public String getSubject() {
return this.subject;
}
+
+ public void flagAboutToRename() {
+ this.aboutToRename = true;
+ }
} \ No newline at end of file
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index c1136f5e..72f660b3 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -1035,34 +1035,14 @@ public class XmppConnectionService extends Service {
}
}
});
+ options.flagAboutToRename();
PresencePacket packet = new PresencePacket();
packet.setAttribute("to",
conversation.getContactJid().split("/")[0] + "/" + nick);
packet.setAttribute("from", conversation.getAccount().getFullJid());
conversation.getAccount().getXmppConnection()
- .sendPresencePacket(packet, new OnPresencePacketReceived() {
-
- @Override
- public void onPresencePacketReceived(Account account,
- PresencePacket packet) {
- final boolean changed;
- String type = packet.getAttribute("type");
- changed = (!"error".equals(type));
- if (!changed) {
- options.getOnRenameListener().onRename(false);
- } else {
- if (type == null) {
- options.getOnRenameListener()
- .onRename(true);
- options.setNick(packet.getAttribute("from")
- .split("/")[1]);
- } else {
- options.processPacket(packet);
- }
- }
- }
- });
+ .sendPresencePacket(packet, null);
} else {
String jid = conversation.getContactJid().split("/")[0] + "/"
+ nick;
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index dc8c3d5d..968e1647 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -43,13 +43,17 @@ public abstract class XmppActivity extends Activity {
protected void onStart() {
super.onStart();
if (!xmppConnectionServiceBound) {
- Intent intent = new Intent(this, XmppConnectionService.class);
- intent.setAction("ui");
- startService(intent);
- bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
+ connectToBackend();
}
}
+ public void connectToBackend() {
+ Intent intent = new Intent(this, XmppConnectionService.class);
+ intent.setAction("ui");
+ startService(intent);
+ bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
+ }
+
@Override
protected void onStop() {
super.onStop();
diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java
index 4abd781e..d6f86900 100644
--- a/src/eu/siacs/conversations/utils/MessageParser.java
+++ b/src/eu/siacs/conversations/utils/MessageParser.java
@@ -40,11 +40,7 @@ public class MessageParser {
String foreignPresence = conversation.getOtrSession().getSessionID().getUserID();
if (!foreignPresence.equals(fromParts[1])) {
Log.d(LOGTAG,"new otr during existing otr session requested. ending old one");
- try {
- conversation.getOtrSession().endSession();
- } catch (OtrException e) {
- Log.d("xmppService","couldnt end old session");
- }
+ conversation.resetOtrSession();
Log.d("xmppService","starting new one with "+fromParts[1]);
conversation.startOtrSession(service.getApplicationContext(), fromParts[1]);
}
@@ -80,7 +76,6 @@ public class MessageParser {
Log.d(LOGTAG,"otr session stoped");
}
} catch (Exception e) {
- Log.d(LOGTAG, "error receiving otr. resetting");
conversation.resetOtrSession();
return null;
}