blob: d77db0d43a98b2301a70f3539af6735dd93252c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package de.thedevstack.conversationsplus.crypto.axolotl;
import de.thedevstack.android.logcat.Logging;
import de.thedevstack.conversationsplus.Config;
import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.entities.Message;
import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
/**
*/
public class AxolotlMessageParser {
public static Message parseAxolotlChat(Element axolotlMessage, Jid counterpart, Jid from, Conversation conversation) {
Jid origin;
if (conversation.getMode() == Conversation.MODE_MULTI) {
origin = conversation.getMucOptions().getTrueCounterpart(counterpart.getResourcepart());
if (origin == null) {
Logging.d(Config.LOGTAG,"axolotl message in non anonymous conference received");
return null;
}
} else {
origin = from;
}
Message finishedMessage = null;
AxolotlService service = conversation.getAccount().getAxolotlService();
XmppAxolotlMessage xmppAxolotlMessage = XmppAxolotlMessage.fromElement(axolotlMessage, from.toBareJid());
XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage = service.processReceivingPayloadMessage(xmppAxolotlMessage);
if(plaintextMessage != null) {
finishedMessage = new Message(conversation, plaintextMessage.getPlaintext(), Message.ENCRYPTION_AXOLOTL);
finishedMessage.setFingerprint(plaintextMessage.getFingerprint());
Logging.d(Config.LOGTAG, AxolotlServiceImpl.getLogprefix(finishedMessage.getConversation().getAccount())+" Received Message with session fingerprint: "+plaintextMessage.getFingerprint());
}
return finishedMessage;
}
}
|