diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2017-04-05 22:54:45 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2017-04-05 23:04:05 +0300 |
commit | 379c01d539737afbe1c32e09a492a240400774e4 (patch) | |
tree | 425f021ed16c7f6947a4808854821125b505336d /protocols/JabberG/src/jabber_proto.cpp | |
parent | dc38d017dab888de1e2d530b916c94989489af94 (diff) |
jabber: omemo: working on 4.4
started implementation of omemo session setup (4.4)
currently trying to setup session on outgoing message send attempt for simplicity, this must be changed in future
fixed bug in incomming message handler (4.7)
Diffstat (limited to 'protocols/JabberG/src/jabber_proto.cpp')
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 8960a70166..b5bb2108ed 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -919,6 +919,16 @@ int __cdecl CJabberProto::SendMsg(MCONTACT hContact, int, const char* pszSrc) return 1;
}
+ if (m_options.UseOMEMO)
+ {
+ if (!OmemoCheckSession(hContact)) //check omemo session state and build new session if necessary
+ {
+ TFakeAckParams *param = new TFakeAckParams(hContact, Translate("Protocol is offline or no JID"));
+ ForkThread(&CJabberProto::SendMessageAckThread, param);
+ return 1;
+ }
+ }
+
int isEncrypted, id = SerialNext();
if (!strncmp(pszSrc, PGP_PROLOG, mir_strlen(PGP_PROLOG))) {
const char *szEnd = strstr(pszSrc, PGP_EPILOG);
@@ -941,15 +951,24 @@ int __cdecl CJabberProto::SendMsg(MCONTACT hContact, int, const char* pszSrc) msgType = L"groupchat";
else
msgType = L"chat";
+ XmlNode m(L"message");
- XmlNode m(L"message"); XmlAddAttr(m, L"type", msgType);
- if (!isEncrypted)
- m << XCHILD(L"body", msg);
- else {
- m << XCHILD(L"body", L"[This message is encrypted.]");
- m << XCHILD(L"x", msg) << XATTR(L"xmlns", L"jabber:x:encrypted");
+ if(m_options.UseOMEMO && OmemoIsEnabled(hContact) && !mir_wstrcmp(msgType, L"chat")) //omemo enabled in options, omemo enabled for contact
+ {
+ OmemoEncryptMessage(m, msg);
+ }
+ else
+ {
+
+ XmlAddAttr(m, L"type", msgType);
+ if (!isEncrypted)
+ m << XCHILD(L"body", msg);
+ else {
+ m << XCHILD(L"body", L"[This message is encrypted.]");
+ m << XCHILD(L"x", msg) << XATTR(L"xmlns", L"jabber:x:encrypted");
+ }
+ mir_free(msg);
}
- mir_free(msg);
pResourceStatus r(ResourceInfoFromJID(szClientJid));
if (r)
|