From c64e697b69c0c36c034f00683011894b7a41efea Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 12 Feb 2020 20:49:26 +0300 Subject: Jabber: XEP-0333 implementation (chat markers) --- protocols/JabberG/src/jabber_proto.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'protocols/JabberG/src/jabber_proto.cpp') diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 74b957ef82..9a3008cfa8 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -56,6 +56,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : PROTO(aProtoName, aUserName), m_impl(*this), m_omemo(this), + m_arChatMarks(50, NumericKeySortT), m_lstTransports(50, compareTransports), m_lstRoster(50, compareListItems), m_iqManager(this), @@ -184,6 +185,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : HookProtoEvent(ME_LANGPACK_CHANGED, &CJabberProto::OnLangChanged); HookProtoEvent(ME_OPT_INITIALISE, &CJabberProto::OnOptionsInit); HookProtoEvent(ME_SKIN_ICONSCHANGED, &CJabberProto::OnReloadIcons); + HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CJabberProto::OnDbMarkedRead); HookProtoEvent(ME_DB_CONTACT_SETTINGCHANGED, &CJabberProto::OnDbSettingChanged); m_iqManager.FillPermanentHandlers(); @@ -905,6 +907,18 @@ HANDLE CJabberProto::SendFile(MCONTACT hContact, const wchar_t *szDescription, w return ft; } +//////////////////////////////////////////////////////////////////////////////////////// +// receives a message + +MEVENT CJabberProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre) +{ + MEVENT res = CSuper::RecvMsg(hContact, pre); + if (pre->szMsgId) + m_arChatMarks.insert(new CChatMark(res, pre->szMsgId, (const char*)pre->lParam)); + + return res; +} + //////////////////////////////////////////////////////////////////////////////////////// // JabberSendMessage - sends a message @@ -956,7 +970,7 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *psz int isEncrypted, id = SerialNext(); if (!strncmp(pszSrc, PGP_PROLOG, mir_strlen(PGP_PROLOG))) { const char *szEnd = strstr(pszSrc, PGP_EPILOG); - char *tempstring = (char*)alloca(mir_strlen(pszSrc) + 2); + char *tempstring = (char *)alloca(mir_strlen(pszSrc) + 2); size_t nStrippedLength = mir_strlen(pszSrc) - mir_strlen(PGP_PROLOG) - (szEnd ? mir_strlen(szEnd) : 0) + 1; strncpy_s(tempstring, nStrippedLength, pszSrc + mir_strlen(PGP_PROLOG), _TRUNCATE); tempstring[nStrippedLength] = 0; @@ -1006,8 +1020,10 @@ int CJabberProto::SendMsg(MCONTACT hContact, int unused_unknown, const char *psz m << XATTR("to", szClientJid); bool bSendReceipt = (m_bMsgAck || getByte(hContact, "MsgAck", false)); - if (bSendReceipt) + if (bSendReceipt) { m << XCHILDNS("request", JABBER_FEAT_MESSAGE_RECEIPTS); + m << XCHILDNS("markable", JABBER_FEAT_CHAT_MARKERS); + } if ( // if message delivery check disabled by entity caps manager -- cgit v1.2.3