summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-05-29 17:41:01 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-05-29 17:41:01 +0300
commit8c2efbf3effd0190e2f98613cf783d411f7b43ee (patch)
treed04f7d8e0d327fdc286bf5c7966736fae3574bd9
parent6ab37acb07eb3b1c7db377671ac5f9ce7f2bec53 (diff)
fixes #2911 (Add OMEMO-related info to user info)
-rw-r--r--protocols/JabberG/jabber.vcxproj51
-rw-r--r--protocols/JabberG/jabber.vcxproj.filters149
-rw-r--r--protocols/JabberG/res/jabber.rc4
-rw-r--r--protocols/JabberG/src/jabber_omemo.h1
-rw-r--r--protocols/JabberG/src/jabber_userinfo.cpp77
-rw-r--r--protocols/JabberG/src/jabber_vcard.cpp9
6 files changed, 269 insertions, 22 deletions
diff --git a/protocols/JabberG/jabber.vcxproj b/protocols/JabberG/jabber.vcxproj
index 632ea83ce6..66f77c1e19 100644
--- a/protocols/JabberG/jabber.vcxproj
+++ b/protocols/JabberG/jabber.vcxproj
@@ -126,4 +126,55 @@
<ResourceCompile Include="res\jabber.rc" />
<ResourceCompile Include="res\version.rc" />
</ItemGroup>
+ <ItemGroup>
+ <Image Include="res\addcontact.ico" />
+ <Image Include="res\arrow_down.ico" />
+ <Image Include="res\arrow_up.ico" />
+ <Image Include="res\bookmarks.ico" />
+ <Image Include="res\command.ico" />
+ <Image Include="res\console.ico" />
+ <Image Include="res\delete.ico" />
+ <Image Include="res\disco_fail.ico" />
+ <Image Include="res\disco_in_progress.ico" />
+ <Image Include="res\disco_ok.ico" />
+ <Image Include="res\filter.ico" />
+ <Image Include="res\go.ico" />
+ <Image Include="res\group.ico" />
+ <Image Include="res\home.ico" />
+ <Image Include="res\jabber.ico" />
+ <Image Include="res\login.ico" />
+ <Image Include="res\message_allow.ico" />
+ <Image Include="res\message_deny.ico" />
+ <Image Include="res\notes.ico" />
+ <Image Include="res\open.ico" />
+ <Image Include="res\openid.ico" />
+ <Image Include="res\pages.ico" />
+ <Image Include="res\plist_active.ico" />
+ <Image Include="res\plist_any.ico" />
+ <Image Include="res\plist_default.ico" />
+ <Image Include="res\presence_in_allow.ico" />
+ <Image Include="res\presence_in_deny.ico" />
+ <Image Include="res\presence_out_allow.ico" />
+ <Image Include="res\presence_out_deny.ico" />
+ <Image Include="res\privacy_lists.ico" />
+ <Image Include="res\query_allow.ico" />
+ <Image Include="res\query_deny.ico" />
+ <Image Include="res\refresh.ico" />
+ <Image Include="res\refresh_node.ico" />
+ <Image Include="res\rename.ico" />
+ <Image Include="res\reset_filter.ico" />
+ <Image Include="res\roster.ico" />
+ <Image Include="res\rss.ico" />
+ <Image Include="res\save.ico" />
+ <Image Include="res\send_note.ico" />
+ <Image Include="res\server.ico" />
+ <Image Include="res\service_discovery.ico" />
+ <Image Include="res\store.ico" />
+ <Image Include="res\transport.ico" />
+ <Image Include="res\transport_local.ico" />
+ <Image Include="res\user2room.ico" />
+ <Image Include="res\view_as_list.ico" />
+ <Image Include="res\view_as_tree.ico" />
+ <Image Include="res\weather.ico" />
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/protocols/JabberG/jabber.vcxproj.filters b/protocols/JabberG/jabber.vcxproj.filters
index 8f8f5a9e4e..6fb571920e 100644
--- a/protocols/JabberG/jabber.vcxproj.filters
+++ b/protocols/JabberG/jabber.vcxproj.filters
@@ -244,4 +244,153 @@
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
+ <ItemGroup>
+ <Image Include="res\jabber.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\arrow_down.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\arrow_up.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\disco_in_progress.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\rss.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\server.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\store.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\weather.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\disco_ok.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\disco_fail.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\group.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\addcontact.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\roster.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\pages.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\delete.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\rename.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\open.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\user2room.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\save.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\login.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\refresh.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\command.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\bookmarks.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\privacy_lists.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\service_discovery.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\view_as_list.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\view_as_tree.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\filter.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\go.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\home.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\refresh_node.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\reset_filter.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\console.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\message_allow.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\message_deny.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\presence_in_allow.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\presence_in_deny.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\presence_out_allow.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\presence_out_deny.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\query_allow.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\query_deny.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\plist_active.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\plist_any.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\plist_default.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\transport.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\transport_local.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\openid.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\notes.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ <Image Include="res\send_note.ico">
+ <Filter>Resource Files</Filter>
+ </Image>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/protocols/JabberG/res/jabber.rc b/protocols/JabberG/res/jabber.rc
index 5016761346..44b2ed6c07 100644
--- a/protocols/JabberG/res/jabber.rc
+++ b/protocols/JabberG/res/jabber.rc
@@ -321,12 +321,13 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,96,88,50,14
END
-IDD_INFO_OMEMO DIALOGEX 0, 0, 222, 132
+IDD_INFO_OMEMO DIALOGEX 0, 0, 222, 153
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,0,0,221,131
+ LTEXT "(*) marks the current session",IDC_STATIC,4,137,214,8
END
IDD_VCARD_PHOTO DIALOGEX 0, 0, 222, 132
@@ -746,6 +747,7 @@ BEGIN
IDD_INFO_OMEMO, DIALOG
BEGIN
+ BOTTOMMARGIN, 132
END
IDD_BOOKMARKS, DIALOG
diff --git a/protocols/JabberG/src/jabber_omemo.h b/protocols/JabberG/src/jabber_omemo.h
index 8d5eafd818..a5797889d6 100644
--- a/protocols/JabberG/src/jabber_omemo.h
+++ b/protocols/JabberG/src/jabber_omemo.h
@@ -33,6 +33,7 @@ struct signal_crypto_provider;
namespace omemo
{
const char IdentityPrefix[] = "OmemoSignalIdentity_";
+ const char DevicePrefix[] = "OmemoDeviceId";
struct omemo_device;
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp
index 96266010b9..a9eb606348 100644
--- a/protocols/JabberG/src/jabber_userinfo.cpp
+++ b/protocols/JabberG/src/jabber_userinfo.cpp
@@ -759,6 +759,17 @@ struct USER_OMEMO_INFO
CJabberProto *ppro;
};
+static int EnumOwnSessions(const char *szSetting, void *param)
+{
+ auto *pList = (LIST<char>*)param;
+
+ if (!memcmp(szSetting, omemo::DevicePrefix, sizeof(omemo::DevicePrefix)-1))
+ if (szSetting[sizeof(omemo::DevicePrefix)] != 0)
+ pList->insert(mir_strdup(szSetting));
+
+ return 0;
+}
+
static int EnumOmemoSessions(const char *szSetting, void *param)
{
auto *pList = (LIST<char>*)param;
@@ -769,7 +780,19 @@ static int EnumOmemoSessions(const char *szSetting, void *param)
return 0;
}
-static INT_PTR CALLBACK JabberUserOmemoDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam)
+static void AddListItem(HWND hwndList, const CMStringA &pszStr1, const CMStringA &pszStr2)
+{
+ LVITEMA lvi = {};
+ lvi.mask = LVIF_TEXT;
+ lvi.pszText = (char*)pszStr1.c_str();
+ int idx = SendMessage(hwndList, LVM_INSERTITEMA, 0, LPARAM(&lvi));
+
+ lvi.iSubItem = 1;
+ lvi.pszText = (char *)pszStr2.c_str();
+ SendMessage(hwndList, LVM_SETITEMTEXTA, idx, LPARAM(&lvi));
+}
+
+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);
@@ -794,6 +817,9 @@ static INT_PTR CALLBACK JabberUserOmemoDlgProc(HWND hwndDlg, UINT msg, WPARAM, L
lvc.pszText = TranslateT("Fingerprint");
ListView_InsertColumn(hwndList, 2, &lvc);
}
+
+ if (lParam == 0)
+ PostMessage(hwndDlg, WM_PROTO_REFRESH, 0, 0);
break;
case WM_NOTIFY:
@@ -815,28 +841,37 @@ static INT_PTR CALLBACK JabberUserOmemoDlgProc(HWND hwndDlg, UINT msg, WPARAM, L
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);
+ if (pInfo->hContact == 0) {
+ uint32_t ownDeviceId = pInfo->ppro->getDword("OmemoDeviceId");
+ CMStringA str1(FORMAT, "* %X", ownDeviceId);
+ CMStringA str2(pInfo->ppro->getMStringA("OmemoFingerprintOwn"));
+ AddListItem(hwndList, str1, str2);
- LVITEMA lvi = {};
- lvi.mask = LVIF_TEXT;
- lvi.pszText = szText.GetBuffer();
- int idx = SendMessage(hwndList, LVM_INSERTITEMA, 0, LPARAM(&lvi));
+ LIST<char> arSettings(1);
+ db_enum_settings(pInfo->hContact, EnumOwnSessions, pInfo->ppro->m_szModuleName, &arSettings);
- 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));
+ str2 = "";
+ for (auto &it : arSettings) {
+ str1.Format("%X", pInfo->ppro->getDword(it));
+ AddListItem(hwndList, str1, str2);
+ }
+ }
+ else {
+ 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 str1(FORMAT, "%X", deviceId), str2;
+ str2.Truncate(int(len) * 2);
+ bin2hex(binVal, len - sizeof(uint32_t), str2.GetBuffer());
+ AddListItem(hwndList, str1, str2);
+ }
}
break;
}
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp
index 11ff67829c..6bd987f2a0 100644
--- a/protocols/JabberG/src/jabber_vcard.cpp
+++ b/protocols/JabberG/src/jabber_vcard.cpp
@@ -1174,6 +1174,8 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, wchar_t *szPhotoFileName)
/////////////////////////////////////////////////////////////////////////////////////////
+INT_PTR CALLBACK JabberUserOmemoDlgProc(HWND hwndDlg, UINT msg, WPARAM, LPARAM lParam);
+
void CJabberProto::OnUserInfoInit_VCard(WPARAM wParam, LPARAM)
{
m_vCardUpdates = 0;
@@ -1215,5 +1217,12 @@ void CJabberProto::OnUserInfoInit_VCard(WPARAM wParam, LPARAM)
odp.szTab.w = LPGENW("Note");
g_plugin.addUserInfo(wParam, &odp);
+ if (m_bUseOMEMO) {
+ odp.pfnDlgProc = JabberUserOmemoDlgProc;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_OMEMO);
+ odp.szTab.w = LPGENW("OMEMO");
+ g_plugin.addUserInfo(wParam, &odp);
+ }
+
SendGetVcard(0);
}