use of org.jivesoftware.smackx.omemo.internal.CipherAndAuthTag in project Zom-Android by zom.
the class XmppConnection method initOmemo.
private synchronized Omemo initOmemo(XMPPTCPConnection conn) throws Exception {
if (conn != null && conn.isConnected()) {
mOmemoInstance = new Omemo(conn, mUserJid);
mOmemoInstance.getManager().addOmemoMessageListener(new OmemoMessageListener() {
@Override
public void onOmemoKeyTransportReceived(CipherAndAuthTag cipherAndAuthTag, org.jivesoftware.smack.packet.Message message, org.jivesoftware.smack.packet.Message message1, OmemoMessageInformation omemoMessageInformation) {
debug(TAG, "omemo key transport received");
}
@Override
public void onOmemoMessageReceived(String body, org.jivesoftware.smack.packet.Message message, org.jivesoftware.smack.packet.Message message1, OmemoMessageInformation omemoMessageInformation) {
if (body != null) {
debug(TAG, "got inbound message omemo: from:" + message.getFrom() + "=" + message.getBody());
message.setBody(body);
handleMessage(message, true, true);
} else {
debug(TAG, "got empty ibound message omemo: from:" + message.getFrom().toString());
}
}
});
mOmemoInstance.getManager().addOmemoMucMessageListener(new OmemoMucMessageListener() {
@Override
public void onOmemoMucMessageReceived(MultiUserChat muc, BareJid from, String decryptedBody, org.jivesoftware.smack.packet.Message message, org.jivesoftware.smack.packet.Message wrappingMessage, OmemoMessageInformation omemoInformation) {
if (decryptedBody != null) {
debug(TAG, "got inbound MUC message omemo: from:" + message.getFrom() + "=" + message.getBody());
org.jivesoftware.smack.packet.Message messagePlain = new org.jivesoftware.smack.packet.Message();
messagePlain.setType(message.getType());
messagePlain.setFrom(message.getFrom());
messagePlain.setTo(message.getTo());
messagePlain.setBody(decryptedBody);
messagePlain.setStanzaId(message.getStanzaId());
messagePlain.addExtensions(message.getExtensions());
messagePlain.setThread(message.getThread());
messagePlain.setSubject(message.getSubject());
handleMessage(messagePlain, true, true);
} else {
debug(TAG, "got empty ibound MUC message omemo: from:" + message.getFrom().toString());
}
}
@Override
public void onOmemoKeyTransportReceived(MultiUserChat muc, BareJid from, CipherAndAuthTag cipherAndAuthTag, org.jivesoftware.smack.packet.Message message, org.jivesoftware.smack.packet.Message wrappingMessage, OmemoMessageInformation omemoInformation) {
debug(TAG, "got OmemoKey Transport from: " + from.toString());
}
});
addOmemoListener(mOmemoInstance.getManager());
}
return mOmemoInstance;
}
Aggregations