mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-25 08:58:55 -05:00
otr safety guard
This commit is contained in:
parent
bbfe102e91
commit
079712060c
@ -31,6 +31,7 @@ public class MessageParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Message parseOtrChat(MessagePacket packet, Account account, XmppConnectionService service) {
|
public static Message parseOtrChat(MessagePacket packet, Account account, XmppConnectionService service) {
|
||||||
|
boolean justStarted = false;
|
||||||
boolean properlyAddressed = (packet.getTo().split("/").length == 2) || (account.countPresences() == 1);
|
boolean properlyAddressed = (packet.getTo().split("/").length == 2) || (account.countPresences() == 1);
|
||||||
String[] fromParts = packet.getFrom().split("/");
|
String[] fromParts = packet.getFrom().split("/");
|
||||||
Conversation conversation = service.findOrCreateConversation(account, fromParts[0],false);
|
Conversation conversation = service.findOrCreateConversation(account, fromParts[0],false);
|
||||||
@ -39,6 +40,7 @@ public class MessageParser {
|
|||||||
if (properlyAddressed) {
|
if (properlyAddressed) {
|
||||||
Log.d("xmppService","starting new otr session with "+packet.getFrom()+" because no valid otr session has been found");
|
Log.d("xmppService","starting new otr session with "+packet.getFrom()+" because no valid otr session has been found");
|
||||||
conversation.startOtrSession(service.getApplicationContext(), fromParts[1]);
|
conversation.startOtrSession(service.getApplicationContext(), fromParts[1]);
|
||||||
|
justStarted = true;
|
||||||
} else {
|
} else {
|
||||||
Log.d("xmppService",account.getJid()+": ignoring otr session with "+fromParts[0]);
|
Log.d("xmppService",account.getJid()+": ignoring otr session with "+fromParts[0]);
|
||||||
return null;
|
return null;
|
||||||
@ -50,6 +52,7 @@ public class MessageParser {
|
|||||||
if (properlyAddressed) {
|
if (properlyAddressed) {
|
||||||
Log.d("xmppService","replacing otr session with "+packet.getFrom());
|
Log.d("xmppService","replacing otr session with "+packet.getFrom());
|
||||||
conversation.startOtrSession(service.getApplicationContext(), fromParts[1]);
|
conversation.startOtrSession(service.getApplicationContext(), fromParts[1]);
|
||||||
|
justStarted = true;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -86,7 +89,13 @@ public class MessageParser {
|
|||||||
Log.d(LOGTAG,"otr session stoped");
|
Log.d(LOGTAG,"otr session stoped");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
conversation.resetOtrSession();
|
Log.d(LOGTAG,"otr execption");
|
||||||
|
if (justStarted) {
|
||||||
|
Log.d(LOGTAG,"ran into safeguard");
|
||||||
|
} else {
|
||||||
|
Log.d(LOGTAG,"resett otr session");
|
||||||
|
conversation.resetOtrSession();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user