From ecd56d476d8b0e3a8700e3a27a67f4c1e579f176 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 6 Jun 2022 21:19:49 +0300 Subject: more portable version of previous patch --- protocols/JabberG/src/jabber_events.cpp | 2 +- protocols/JabberG/src/jabber_ft.cpp | 2 +- protocols/JabberG/src/jabber_misc.cpp | 4 ++-- protocols/JabberG/src/jabber_proto.cpp | 3 +-- protocols/JabberG/src/jabber_proto.h | 2 ++ protocols/JabberG/src/jabber_util.cpp | 15 +++++++++++++++ 6 files changed, 22 insertions(+), 6 deletions(-) (limited to 'protocols/JabberG') diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp index 4116f78e4f..3dc078fa8d 100644 --- a/protocols/JabberG/src/jabber_events.cpp +++ b/protocols/JabberG/src/jabber_events.cpp @@ -170,7 +170,7 @@ int __cdecl CJabberProto::OnDbMarkedRead(WPARAM, LPARAM hDbEvent) auto *pMark = m_arChatMarks.find((CChatMark *)&hDbEvent); if (pMark) { - if(m_bMsgAck) { + if (IsSendAck(hContact)) { XmlNode reply("message"); reply << XATTR("to", pMark->szFrom) << XATTR("id", pMark->szId) << XCHILDNS("displayed", JABBER_FEAT_CHAT_MARKERS) << XATTR("id", pMark->szId); m_ThreadInfo->send(reply); diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp index bdfdffe845..55002d6f59 100644 --- a/protocols/JabberG/src/jabber_ft.cpp +++ b/protocols/JabberG/src/jabber_ft.cpp @@ -800,7 +800,7 @@ bool CJabberProto::FtTryInlineFile(filetransfer *ft) auto *nPara = nBody << XCHILD("p"); nPara << XCHILD("img") << XATTR("src", CMStringA(FORMAT, "cid:sha1+%s@bob.xmpp.org", szHash)); - if(m_bMsgAck) { + if (IsSendAck(ft->std.hContact)) { m << XCHILDNS("request", JABBER_FEAT_MESSAGE_RECEIPTS); m << XCHILDNS("markable", JABBER_FEAT_CHAT_MARKERS); } diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index c8b4562276..b73a2dba93 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -475,9 +475,9 @@ static bool SaveBlobToFile(const wchar_t *pwszFileName, const CMStringA &body) void CJabberProto::OnGetBob(const TiXmlElement *node, CJabberIqInfo *pReq) { - auto pMark = ((CChatMark *)pReq->GetUserData()); + auto *pMark = ((CChatMark *)pReq->GetUserData()); if (pMark) { - if(m_bMsgAck) { + if (m_bMsgAck) { XmlNode reply("message"); reply << XATTR("to", pMark->szFrom) << XATTR("id", pMark->szId) << XCHILDNS("displayed", JABBER_FEAT_CHAT_MARKERS) << XATTR("id", pMark->szId); m_ThreadInfo->send(reply); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index bd76fd7aa3..24c9f5b7ba 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -951,8 +951,7 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *psz m << XATTR("to", szClientJid); - bool bSendReceipt = m_bMsgAck && (jcb & (JABBER_CAPS_CHAT_MARKERS | JABBER_CAPS_MESSAGE_RECEIPTS)); - + bool bSendReceipt = IsSendAck(hContact) && (jcb & (JABBER_CAPS_CHAT_MARKERS | JABBER_CAPS_MESSAGE_RECEIPTS)); if (bSendReceipt) { m << XCHILDNS("request", JABBER_FEAT_MESSAGE_RECEIPTS); m << XCHILDNS("markable", JABBER_FEAT_CHAT_MARKERS); diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 8cd4ac4b64..bbf8fee6ce 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -870,7 +870,9 @@ struct CJabberProto : public PROTO, public IJabberInterface void ComboLoadRecentStrings(HWND hwndDlg, UINT idcCombo, char *param, int recentCount = JABBER_DEFAULT_RECENT_COUNT); void ComboAddRecentString(HWND hwndDlg, UINT idcCombo, char *param, const wchar_t *string, int recentCount = JABBER_DEFAULT_RECENT_COUNT); BOOL EnterString(CMStringW &result, const wchar_t *caption, int type, char *windowName=nullptr, int recentCount = JABBER_DEFAULT_RECENT_COUNT, int timeout = 0); + bool IsMyOwnJID(const char *szJID); + bool IsSendAck(MCONTACT hContact); void __cdecl LoadHttpAvatars(void* param); diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 8c6856e41b..f620593fed 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -890,6 +890,8 @@ bool JabberReadXep203delay(const TiXmlElement *node, time_t &msgTime) return msgTime != 0; } +///////////////////////////////////////////////////////////////////////////////////////// + bool CJabberProto::IsMyOwnJID(const char *szJID) { if (m_ThreadInfo == nullptr) @@ -914,6 +916,19 @@ bool CJabberProto::IsMyOwnJID(const char *szJID) return mir_strcmp(szFrom, szTo) == 0; } +bool CJabberProto::IsSendAck(MCONTACT hContact) +{ + if (getBool(hContact, "MsgAck")) + return true; + + if (getBool(hContact, "MsgNoAck")) + return false; + + return m_bMsgAck; +} + +///////////////////////////////////////////////////////////////////////////////////////// + void __cdecl CJabberProto::LoadHttpAvatars(void* param) { Thread_SetName("Jabber: LoadHttpAvatars"); -- cgit v1.2.3