From e56bbe53cd07402970fc9015a832566f85cd890b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 6 Feb 2020 20:30:18 +0300 Subject: Jabber: - MessageState support; - minor code cleaning --- protocols/JabberG/src/jabber.cpp | 13 ++++++------- protocols/JabberG/src/jabber_proto.cpp | 3 ++- protocols/JabberG/src/jabber_thread.cpp | 8 +++++++- protocols/JabberG/src/jabber_util.cpp | 8 ++++---- protocols/JabberG/src/stdafx.h | 3 ++- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index 24bada0460..80aceb2c5b 100755 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -52,8 +52,6 @@ HANDLE hExtListInit, hDiscoInfoResult; void JabberUserInfoInit(void); void JabberUserInfoUninit(void); -bool bSecureIM, bMirOTR, bNewGPG, bPlatform; - ///////////////////////////////////////////////////////////////////////////////////////// static PLUGININFOEX pluginInfoEx = { @@ -94,9 +92,10 @@ static INT_PTR g_SvcParseXmppUri(WPARAM w, LPARAM l) static int OnLoadModule(WPARAM, LPARAM) { - bSecureIM = ServiceExists("SecureIM/IsContactSecured") != 0; - bMirOTR = GetModuleHandle(L"mirotr.dll") != nullptr; - bNewGPG = GetModuleHandle(L"new_gpg.dll") != nullptr; + g_plugin.bMessageState = ServiceExists(MS_MESSAGESTATE_UPDATE); + g_plugin.bSecureIM = ServiceExists("SecureIM/IsContactSecured") != 0; + g_plugin.bMirOTR = GetModuleHandle(L"mirotr.dll") != nullptr; + g_plugin.bNewGPG = GetModuleHandle(L"new_gpg.dll") != nullptr; return 0; } @@ -155,9 +154,9 @@ static int OnModulesLoaded(WPARAM, LPARAM) int CMPlugin::Load() { #ifdef _WIN64 - bPlatform = 1; + bPlatform = true; #else - bPlatform = 0; + bPlatform = false; #endif Miranda_GetVersionText(szCoreVersion, _countof(szCoreVersion)); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 63744c93ac..7d3fe86868 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -586,7 +586,7 @@ INT_PTR CJabberProto::GetCaps(int type, MCONTACT hContact) case PFLAGNUM_3: return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_HEAVYDND | PF2_FREECHAT; case PFLAGNUM_4: - return PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS; + return PF4_FORCEAUTH | PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_READNOTIFY; case PFLAG_UNIQUEIDTEXT: return (INT_PTR)Translate("JID"); case PFLAG_MAXCONTACTSPERPACKET: @@ -1032,6 +1032,7 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *psz m_ThreadInfo->send(m); } + return id; } diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 82a56adbbf..18cd3d03fb 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1185,8 +1185,14 @@ void CJabberProto::OnProcessMessage(const TiXmlElement *node, ThreadData *info) int nPacketId = JabberGetPacketID(n); if (nPacketId == -1) nPacketId = JabberGetPacketID(node); - if (nPacketId != -1) + if (nPacketId != -1) { ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)nPacketId, 0); + + if (g_plugin.bMessageState) { + MessageReadData readData(time(0), MRD_TYPE_READTIME); + CallService(MS_MESSAGESTATE_UPDATE, hContact, (LPARAM)&readData); + } + } } JabberReadXep203delay(node, msgTime); diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 7beb62d11b..1b0509decc 100755 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -391,19 +391,19 @@ void CJabberProto::SendPresenceTo(int status, const char *to, const TiXmlElement << XATTR("node", JABBER_CAPS_MIRANDA_NODE) << XATTR("ver", m_clientCapsManager.GetFeaturesCrc()); LIST arrExtCaps(5); - if (bSecureIM) + if (g_plugin.bSecureIM) arrExtCaps.insert(JABBER_EXT_SECUREIM); - if (bMirOTR) + if (g_plugin.bMirOTR) arrExtCaps.insert(JABBER_EXT_MIROTR); - if (bNewGPG) + if (g_plugin.bNewGPG) arrExtCaps.insert(JABBER_EXT_NEWGPG); if(m_bUseOMEMO) arrExtCaps.insert(JABBER_EXT_OMEMO); - if (bPlatform) + if (g_plugin.bPlatform) arrExtCaps.insert(JABBER_EXT_PLATFORMX64); else arrExtCaps.insert(JABBER_EXT_PLATFORMX86); diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index 9a88545bb3..befa89bac6 100755 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -73,6 +73,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #include +#include #include #include #include @@ -117,6 +118,7 @@ struct CJabberProto; struct CMPlugin : public ACCPROTOPLUGIN { + bool bMessageState = false, bSecureIM = false, bMirOTR = false, bNewGPG = false, bPlatform = false; char szRandom[17]; CMPlugin(); @@ -573,7 +575,6 @@ extern int g_cbCountries; extern struct CountryListEntry* g_countries; extern HANDLE hExtListInit, hDiscoInfoResult; -extern bool bSecureIM, bMirOTR, bNewGPG, bPlatform; /******************************************************************* * Function declarations -- cgit v1.2.3