diff options
author | sss <sss@dark-alexandr.net> | 2024-10-27 12:24:49 +0300 |
---|---|---|
committer | sss <sss@dark-alexandr.net> | 2024-10-27 12:29:34 +0300 |
commit | 0ba90e004d457b50c5ae16993c22d48336f58959 (patch) | |
tree | a47c277953199169853b7a0c08f5a614ba424ceb | |
parent | e2c129c8814b6c6843d83f031e955edd3f3312ec (diff) |
omemo related patch from anonymous developer
-rw-r--r-- | protocols/JabberG/src/jabber_omemo.cpp | 24 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.h | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_userinfo.cpp | 16 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_util.cpp | 17 |
4 files changed, 49 insertions, 10 deletions
diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index 744b1cf176..1b2fd188ce 100644 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -459,6 +459,9 @@ complete: db_set_blob(0, proto->m_szModuleName, szSetting, buf.data(), buf.len());
}
signal_protocol_key_helper_key_list_free(keys_root);
+
+ if(proto->m_bJabberOnline)
+ proto->OmemoSendBundle();
}
static CMStringA getSessionSetting(const signal_protocol_address *address)
@@ -960,8 +963,10 @@ complete: MCONTACT hContact = proto->HContactFromJID(address->name);
char val = proto->getByte(hContact, TrustSettingName, FP_ABSENT);
if (val == FP_ABSENT) {
- //proto->setByte(hContact, TrustSettingName, FP_BAD);
- proto->MsgPopup(hContact, omemo::FormatFingerprint(fp_hex), TranslateT("Unknown device added"));
+ uint32_t count = 0;
+ db_enum_settings(hContact, omemo::db_enum_settings_fps_cb, proto->m_szModuleName, &count);
+ if(count)
+ proto->MsgPopup(hContact, omemo::FormatFingerprint(fp_hex), TranslateT("Unknown device added"));
}
//always return true to decrypt incoming messages from untrusted devices
@@ -1472,6 +1477,9 @@ void CJabberProto::OmemoAnnounceDevice(bool include_cache, bool include_own) // send device list back
// TODO handle response
m_ThreadInfo->send(iq);
+
+ //make it available without subscription
+ ConfigurePepNode(JABBER_FEAT_OMEMO ".devicelist", "open");
}
void CJabberProto::OmemoSendBundle()
@@ -1524,6 +1532,8 @@ void CJabberProto::OmemoSendBundle() // send bundle
//TODOL handle response
m_ThreadInfo->send(iq);
+
+ ConfigurePepNode(CMStringA(FORMAT, "%s.bundles:%u", JABBER_FEAT_OMEMO, own_id), "open");
}
bool CJabberProto::OmemoCheckSession(MCONTACT hContact, bool requestBundles)
@@ -1545,7 +1555,7 @@ bool CJabberProto::OmemoCheckSession(MCONTACT hContact, bool requestBundles) ptrA jid(ContactToJID(_hContact));
uint32_t count = 0;
- db_enum_settings(hContact, omemo::db_enum_settings_fps_cb, m_szModuleName, &count);
+ db_enum_settings(_hContact, omemo::db_enum_settings_fps_cb, m_szModuleName, &count);
for (int i = 0;; i++) {
int device_id = m_omemo.dbGetDeviceId(_hContact, i);
@@ -1569,6 +1579,14 @@ bool CJabberProto::OmemoCheckSession(MCONTACT hContact, bool requestBundles) ok = false;
}
+ else {
+ if(count == 0) {
+ MBinBuffer fp(getBlob(_hContact, omemo::IdentityPrefix + m_omemo.dbGetSuffix(_hContact, device_id)));
+ CMStringA fp_hex(omemo::hex_string(fp.data(), fp.length()));
+ setByte(hContact, "OmemoFingerprintTrusted_" + fp_hex, FP_TOFU);
+ MsgPopup(hContact, omemo::FormatFingerprint(fp_hex), TranslateT("Trust on first use"));
+ }
+ }
}
}
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 615ab8e70b..073a6de91f 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -887,6 +887,8 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface bool IsMyOwnJID(const char *szJID);
bool IsSendAck(MCONTACT hContact);
+
+ void ConfigurePepNode(const char * nodename, const char * access_model, const char * max_items = nullptr);
void __cdecl LoadHttpAvatars(void* param);
CMStringA MyNick(MCONTACT hContact = 0);
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index e61ae35ed9..a2509128ba 100644 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -819,12 +819,14 @@ public: CMStringA fp_hex;
if (!fp.isEmpty()) {
fp_hex = omemo::hex_string(fp.data(), fp.length());
- int8_t trusted = ppro->getByte(m_hContact, "OmemoFingerprintTrusted_" + fp_hex);
+ int8_t trusted = ppro->getByte(m_hContact, "OmemoFingerprintTrusted_" + fp_hex, FP_ABSENT);
if (trusted > FP_VERIFIED)
trusted = FP_ABSENT;
-
- const wchar_t *status[] = { L"Bad", L"TOFU", L"Verified" };
- wsStatus = TranslateW(status[trusted]);
+
+ if (trusted != FP_ABSENT) {
+ const wchar_t *status[] = { L"Bad", L"TOFU", L"Verified" };
+ wsStatus = TranslateW(status[trusted]);
+ }
}
MBinBuffer session(ppro->getBlob(m_hContact, "OmemoSignalSession_" + suffix));
@@ -851,16 +853,16 @@ public: CMStringA TrustSettingName("OmemoFingerprintTrusted_");
TrustSettingName.Append(omemo::hex_string(fp.data(), fp.length()));
- int8_t trusted = ppro->getByte(m_hContact, TrustSettingName);
+ int8_t trusted = ppro->getByte(m_hContact, TrustSettingName, FP_ABSENT);
bool ses = !ppro->getBlob(m_hContact, "OmemoSignalSession_" + suffix).isEmpty();
HMENU hMenu = CreatePopupMenu();
if (!owndevice) {
- AppendMenu(hMenu, MF_STRING, (UINT_PTR)1, trusted ? TranslateT("Untrust") : TranslateT("Trust"));
+ AppendMenu(hMenu, MF_STRING | (trusted != FP_ABSENT ? 0 : MF_GRAYED), (UINT_PTR)1, trusted ? TranslateT("Untrust") : TranslateT("Trust"));
AppendMenu(hMenu, MF_STRING | (ses ? 0 : MF_GRAYED), (UINT_PTR)2, TranslateT("Kill session"));
}
if (m_hContact == 0)
- AppendMenu(hMenu, MF_STRING | (!owndevice && !ppro->m_bJabberOnline ? MF_GRAYED : 0), (UINT_PTR)3, TranslateT("Remove device"));
+ AppendMenu(hMenu, MF_STRING | (!ppro->m_bJabberOnline ? MF_GRAYED : 0), (UINT_PTR)3, TranslateT("Remove device"));
int nReturnCmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pos->pt.x, pos->pt.y, 0, m_hwnd, nullptr);
switch (nReturnCmd) {
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 43fa76a620..c7f6a1fd4a 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -872,6 +872,23 @@ bool CJabberProto::IsSendAck(MCONTACT hContact) return m_bMsgAck;
}
+void CJabberProto::ConfigurePepNode(const char* nodename, const char* access_model, const char* max_items)
+{
+ char szBareJid[JABBER_MAX_JID_LEN];
+ XmlNodeIq iq("set", SerialNext());
+ iq << XATTR("from", JabberStripJid(m_ThreadInfo->fullJID, szBareJid, _countof(szBareJid)));
+
+ TiXmlElement *x_node = iq << XCHILDNS("pubsub", "http://jabber.org/protocol/pubsub#owner")
+ << XCHILD("configure") << XATTR("node", nodename)
+ << XCHILDNS("x", JABBER_FEAT_DATA_FORMS) << XATTR("type", "submit");
+ if (access_model)
+ x_node << XCHILD("field") << XATTR("var", "pubsub#access_model") << XCHILD("value", access_model);
+ if (max_items)
+ x_node << XCHILD("field") << XATTR("var", "pubsub#max_items") << XCHILD("value", max_items);
+
+ m_ThreadInfo->send(iq);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
void __cdecl CJabberProto::LoadHttpAvatars(void* param)
|