summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-06-08 13:09:05 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-06-08 13:09:05 +0300
commit735abbe2e2c1e83513b5c2b32af50393a7894dfb (patch)
tree58a3b50ea85b7db840dfa8ec4fa46509fdf07aa4
parent36f4c7318b1fa7f8cb7f8e5745c7c0ffd76f2d6f (diff)
Jabber: OMEMO fingerprints formatting fix
-rw-r--r--protocols/JabberG/src/jabber_omemo.cpp21
-rw-r--r--protocols/JabberG/src/jabber_omemo.h2
-rw-r--r--protocols/JabberG/src/jabber_userinfo.cpp17
3 files changed, 25 insertions, 15 deletions
diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp
index 31390922e5..57f72ac8d4 100644
--- a/protocols/JabberG/src/jabber_omemo.cpp
+++ b/protocols/JabberG/src/jabber_omemo.cpp
@@ -1262,8 +1262,8 @@ complete:
if (val == 1)
fp_trusted = true;
if (val == -1) {
- CMStringA szMsg(FORMAT, "%s%s%s", Translate("Do you want to create OMEMO session with new device:"), "\n\n\t", fingerprint);
- int ret = MessageBoxA(nullptr, szMsg, Translate("OMEMO: New session"), MB_YESNO);
+ CMStringW szMsg(FORMAT, L"%s\n\n", TranslateT("Do you want to create OMEMO session with new device:"));
+ int ret = MessageBoxW(nullptr, szMsg + FormatFingerprint(fingerprint), TranslateT("OMEMO: New session"), MB_YESNO);
if (ret == IDYES) {
proto->setByte(hContact, szSetting, 1);
fp_trusted = true;
@@ -1352,6 +1352,23 @@ complete:
// proto->OmemoAnnounceDevice();
proto->OmemoSendBundle();
}
+
+ CMStringW FormatFingerprint(const char* pszHexString)
+ {
+ CMStringW buf;
+ if(pszHexString) {
+ int i = 0;
+ const char *p = pszHexString;
+ if(*p && *(p+1)) p+=2;
+ for (; *p; p++) {
+ buf.AppendChar(toupper(*p));
+ if (++i % 8 == 0)
+ buf.AppendChar(' ');
+ }
+ }
+
+ return buf;
+ }
};
diff --git a/protocols/JabberG/src/jabber_omemo.h b/protocols/JabberG/src/jabber_omemo.h
index a5797889d6..8563735c36 100644
--- a/protocols/JabberG/src/jabber_omemo.h
+++ b/protocols/JabberG/src/jabber_omemo.h
@@ -35,6 +35,8 @@ namespace omemo
const char IdentityPrefix[] = "OmemoSignalIdentity_";
const char DevicePrefix[] = "OmemoDeviceId";
+ CMStringW FormatFingerprint(const char* pszHexString);
+
struct omemo_device;
struct omemo_impl
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp
index 63b4100370..2b3fc7c2de 100644
--- a/protocols/JabberG/src/jabber_userinfo.cpp
+++ b/protocols/JabberG/src/jabber_userinfo.cpp
@@ -790,16 +790,8 @@ static void AddListItem(HWND hwndList, const CMStringA &pszStr1, const wchar_t *
mir_free(lvi.pszText);
ListView_SetItemText(hwndList, idx, 1, (wchar_t *)pszStr2);
-
- int i = 0;
- CMStringW buf;
- for (const char *p = pszStr3; *p; p++) {
- buf.AppendChar(*p);
- if (++i % 8 == 0)
- buf.AppendChar(' ');
- }
- buf.MakeUpper();
- ListView_SetItemText(hwndList, idx, 2, buf.GetBuffer());
+ CMStringW fp = omemo::FormatFingerprint(pszStr3);
+ ListView_SetItemText(hwndList, idx, 2, fp.GetBuffer());
}
INT_PTR CALLBACK JabberUserOmemoDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
@@ -827,7 +819,7 @@ INT_PTR CALLBACK JabberUserOmemoDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM l
lvc.pszText = TranslateT("Status");
ListView_InsertColumn(hwndList, 2, &lvc);
- lvc.cx = 500;
+ lvc.cx = 550;
lvc.pszText = TranslateT("Fingerprint");
ListView_InsertColumn(hwndList, 3, &lvc);
}
@@ -859,7 +851,7 @@ INT_PTR CALLBACK JabberUserOmemoDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM l
// GetOwnDeviceId() creates own keys if they don't exist
CMStringA str1(FORMAT, "%d", pInfo->ppro->m_omemo.GetOwnDeviceId());
CMStringA str2(pInfo->ppro->getMStringA("OmemoFingerprintOwn"));
- AddListItem(hwndList, str1, TranslateT("Own device"), str2.Mid(2));
+ AddListItem(hwndList, str1, TranslateT("Own device"), str2);
}
for (int i=0;; i++) {
@@ -891,7 +883,6 @@ INT_PTR CALLBACK JabberUserOmemoDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM l
uint8_t trusted = pInfo->ppro->getByte(pInfo->hContact, "OmemoFingerprintTrusted_" + fp_hex);
pwszStatus = trusted ? TranslateT("Trusted") : TranslateT("UNTRUSTED");
//TODO: 3 states Trusted, Untrusted, TOFU
- fp_hex = fp_hex.Mid(2);
}
else if (dbv.cpbVal)
pwszStatus = TranslateT("Unknown");