diff options
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r-- | protocols/JabberG/src/jabber_omemo.cpp | 4 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_omemo.h | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_userinfo.cpp | 105 | ||||
-rw-r--r-- | protocols/JabberG/src/resource.h | 6 |
4 files changed, 111 insertions, 6 deletions
diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index 585195b5c9..91c42a925b 100644 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -1085,7 +1085,7 @@ complete: memcpy(id_buf.get(), address->name, address->name_len);
memcpy(id_buf.get() + address->name_len, &address->device_id, sizeof(int32_t));
- CMStringA szSetting("OmemoSignalIdentity_");
+ CMStringA szSetting(omemo::IdentityPrefix);
szSetting.Append(ptrA(mir_base64_encode(id_buf, address->name_len + sizeof(int32_t))));
if (key_data != nullptr)
@@ -1126,7 +1126,7 @@ complete: char *id_str = mir_base64_encode(id_buf, address->name_len + sizeof(int32_t));
mir_free(id_buf);
char *setting_name = (char*)mir_alloc(strlen(id_str) + 65);
- mir_snprintf(setting_name, strlen(id_str) + 64, "%s%s", "OmemoSignalIdentity_", id_str);
+ mir_snprintf(setting_name, strlen(id_str) + 64, "%s%s", omemo::IdentityPrefix, id_str);
mir_free(id_str);
diff --git a/protocols/JabberG/src/jabber_omemo.h b/protocols/JabberG/src/jabber_omemo.h index ced819f407..8d5eafd818 100644 --- a/protocols/JabberG/src/jabber_omemo.h +++ b/protocols/JabberG/src/jabber_omemo.h @@ -32,6 +32,8 @@ struct signal_crypto_provider; namespace omemo
{
+ const char IdentityPrefix[] = "OmemoSignalIdentity_";
+
struct omemo_device;
struct omemo_impl
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index b61af8c73d..96266010b9 100644 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -559,7 +559,7 @@ struct USER_PHOTO_INFO static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - USER_PHOTO_INFO *photoInfo = (USER_PHOTO_INFO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + auto *photoInfo = (USER_PHOTO_INFO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: @@ -751,6 +751,99 @@ static INT_PTR CALLBACK JabberUserPhotoDlgProc(HWND hwndDlg, UINT msg, WPARAM wP } ///////////////////////////////////////////////////////////////////////////////////////// +// JabberUserPhotoDlgProc - Jabber photo dialog + +struct USER_OMEMO_INFO +{ + MCONTACT hContact; + CJabberProto *ppro; +}; + +static int EnumOmemoSessions(const char *szSetting, void *param) +{ + auto *pList = (LIST<char>*)param; + + if (!memcmp(szSetting, omemo::IdentityPrefix, sizeof(omemo::IdentityPrefix) - 1)) + pList->insert(mir_strdup(szSetting + sizeof(omemo::IdentityPrefix))); + + return 0; +} + +static INT_PTR CALLBACK JabberUserOmemoDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam) +{ + auto *pInfo = (USER_OMEMO_INFO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST); + + switch (msg) { + case WM_INITDIALOG: + // lParam is hContact + TranslateDialogDefault(hwndDlg); + pInfo = (USER_OMEMO_INFO *)mir_alloc(sizeof(USER_OMEMO_INFO)); + pInfo->hContact = lParam; + pInfo->ppro = nullptr; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)pInfo); + { + LV_COLUMN lvc = {}; + lvc.mask = LVCF_TEXT | LVCF_WIDTH; + + lvc.cx = 80; + lvc.pszText = TranslateT("Device ID"); + ListView_InsertColumn(hwndList, 1, &lvc); + + lvc.cx = 240; + lvc.pszText = TranslateT("Fingerprint"); + ListView_InsertColumn(hwndList, 2, &lvc); + } + break; + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_INFOCHANGED: + SendMessage(hwndDlg, WM_PROTO_REFRESH, 0, 0); + break; + + case PSN_PARAMCHANGED: + pInfo->ppro = (CJabberProto *)((PSHNOTIFY *)lParam)->lParam; + break; + } + break; + } + break; + + case WM_PROTO_REFRESH: + ListView_DeleteAllItems(hwndList); + + LIST<char> arSettings(1); + db_enum_settings(pInfo->hContact, EnumOmemoSessions, pInfo->ppro->m_szModuleName, &arSettings); + for (auto &it : arSettings) { + size_t len; + ptrA binVal((char*)mir_base64_decode(it, &len)); + + if (len <= sizeof(uint32_t)) + continue; + + uint32_t deviceId = *(uint32_t *)(binVal.get() + len - sizeof(uint32_t)); + CMStringA szText(FORMAT, "%X", deviceId); + + LVITEMA lvi = {}; + lvi.mask = LVIF_TEXT; + lvi.pszText = szText.GetBuffer(); + int idx = SendMessage(hwndList, LVM_INSERTITEMA, 0, LPARAM(&lvi)); + + szText.Truncate(int(len) * 2); + bin2hex(binVal, len - sizeof(uint32_t), szText.GetBuffer()); + lvi.iSubItem = 1; + lvi.pszText = szText.GetBuffer(); + SendMessage(hwndList, LVM_SETITEMTEXTA, idx, LPARAM(&lvi)); + } + break; + } + return FALSE; +} + +///////////////////////////////////////////////////////////////////////////////////////// // OnInfoInit - initializes user info option dialogs int CJabberProto::OnUserInfoInit(WPARAM wParam, LPARAM hContact) @@ -780,8 +873,16 @@ int CJabberProto::OnUserInfoInit(WPARAM wParam, LPARAM hContact) odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_PHOTO); odp.szTitle.a = LPGEN("Photo"); g_plugin.addUserInfo(wParam, &odp); + + if (m_bUseOMEMO) { + odp.pfnDlgProc = JabberUserOmemoDlgProc; + odp.position = 2000000001; + odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_OMEMO); + odp.szTitle.a = "OMEMO"; + g_plugin.addUserInfo(wParam, &odp); + } } - //TODO: add omemo dialog to userinfo + return 0; } diff --git a/protocols/JabberG/src/resource.h b/protocols/JabberG/src/resource.h index 99b4b3d263..76b592d449 100644 --- a/protocols/JabberG/src/resource.h +++ b/protocols/JabberG/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by w:\miranda-ng\protocols\JabberG\res\jabber.rc
+// Used by C:\Users\georg\DiskW\miranda-ng\protocols\JabberG\res\jabber.rc
//
#define IDD_OPT_JABBER 101
#define IDI_JABBER 102
@@ -24,6 +24,7 @@ #define IDI_ADDCONTACT 122
#define IDI_DELETE 123
#define IDI_EDIT 124
+#define IDD_INFO_OMEMO 125
#define IDD_VCARD_HOME 126
#define IDD_VCARD_PERSONAL 127
#define IDD_VCARD_WORK 128
@@ -292,6 +293,7 @@ #define IDC_USEDOMAINLOGIN 1323
#define IDC_TXT_ALTNICK 1323
#define IDC_SAVE_PERM 1324
+#define IDC_LIST1 1326
#define IDC_BM_LIST 3002
#define IDC_ADD 3004
#define IDC_REMOVE 3005
@@ -315,7 +317,7 @@ #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 235
#define _APS_NEXT_COMMAND_VALUE 40017
-#define _APS_NEXT_CONTROL_VALUE 1325
+#define _APS_NEXT_CONTROL_VALUE 1327
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
|