summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsss <sss@dark-alexandr.net>2024-11-02 03:48:32 +0300
committersss <sss@dark-alexandr.net>2024-11-10 20:37:12 +0300
commit68a1d851a4a661dbadd98cb87f88593ad06d1ee9 (patch)
treec4767779766892fe12f954036a71d83800a4c315
parentf7108f89ea21d1294c818a99251f51c56935ed73 (diff)
jabber: xmppmsg: slicing
-rw-r--r--protocols/JabberG/src/jabber_archive.cpp8
-rw-r--r--protocols/JabberG/src/jabber_proto.h11
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp54
3 files changed, 35 insertions, 38 deletions
diff --git a/protocols/JabberG/src/jabber_archive.cpp b/protocols/JabberG/src/jabber_archive.cpp
index 019efcdc14..d0c6065db4 100644
--- a/protocols/JabberG/src/jabber_archive.cpp
+++ b/protocols/JabberG/src/jabber_archive.cpp
@@ -104,13 +104,9 @@ void CJabberProto::OnIqResultGetCollection(const TiXmlElement *iqNode, CJabberIq
for (auto *itemNode : TiXmlEnum(chatNode)) {
int from;
- if (m_bUseOMEMO) {
- if (auto* encNode = XmlGetChildByTag(itemNode, "encrypted", "xmlns", JABBER_FEAT_OMEMO)) {
- OmemoHandleMessage(encNode, from, msgTime, bWasSent);
- return; //we do not want any additional processing
- }
- }
+ XmppMsg msg(itemNode, this);
+ //TODO: integrate following logic into XmppMessage and remove it here
const char *itemName = itemNode->Name();
if (!mir_strcmp(itemName, "to"))
from = DBEF_SENT;
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index b0bce2db02..c88d71bdf7 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -88,11 +88,13 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
{
delete pFromResource;
}
- XmppMsg(const TiXmlElement* _node, ThreadData* _info, CJabberProto *proto):
- node(_node), info(_info), m_proto(proto)
+ XmppMsg(const TiXmlElement* _node, CJabberProto *proto):
+ node(_node), info(proto->m_ThreadInfo), m_proto(proto)
{
from = XmlGetAttr(node, "from"), type = XmlGetAttr(node, "type"),
idStr = XmlGetAttr(node, "id");
+ pFromResource = nullptr;
+ hContact = 0;
}
time_t extract_timestamp();
void process();
@@ -108,9 +110,10 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
const char* from = nullptr, * type = nullptr,
* idStr = nullptr, * szMamMsgId = nullptr;
ThreadData* info = nullptr;
- const TiXmlElement* node = nullptr;
+ const TiXmlElement *node = nullptr, *carbon = nullptr;
pResourceStatus *pFromResource;
- const TiXmlElement* carbon = nullptr;
+ DB::EventInfo dbei;
+ CMStringA szMessage;
CJabberProto* m_proto;
MCONTACT hContact;
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index bd1eeb0880..08b3329db8 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -1131,7 +1131,12 @@ void CJabberProto::XmppMsg::handle_carbon()
void CJabberProto::XmppMsg::handle_omemo()
{
-
+ if (m_proto->m_bUseOMEMO) {
+ if (auto* encNode = XmlGetChildByTag(node, "encrypted", "xmlns", JABBER_FEAT_OMEMO)) {
+ m_proto->OmemoHandleMessage(encNode, from, msgTime, bWasSent);
+ return; //we do not want any additional processing
+ }
+ }
}
void CJabberProto::XmppMsg::handle_chatstates()
@@ -1151,6 +1156,18 @@ void CJabberProto::XmppMsg::handle_chatstates()
// chatstates inactive event
if (hContact && XmlGetChildByTag(node, "inactive", "xmlns", JABBER_FEAT_CHATSTATES))
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
+ // chatstates gone event
+ if (hContact && XmlGetChildByTag(node, "gone", "xmlns", JABBER_FEAT_CHATSTATES) && m_proto->m_bLogChatstates) {
+ char bEventType = JABBER_DB_EVENT_CHATSTATES_GONE; // gone event
+ DBEVENTINFO _dbei = {};
+ _dbei.pBlob = &bEventType;
+ _dbei.cbBlob = 1;
+ _dbei.eventType = EVENTTYPE_JABBER_CHATSTATES;
+ _dbei.flags = DBEF_READ;
+ _dbei.timestamp = time(0);
+ _dbei.szModule = m_proto->m_szModuleName;
+ db_event_add(hContact, &_dbei);
+ }
}
void CJabberProto::XmppMsg::process()
@@ -1203,7 +1220,6 @@ void CJabberProto::XmppMsg::process()
}
}
- CMStringA szMessage;
auto* bodyNode = XmlGetChildByTag(node, "body", "xml:lang", m_proto->m_tszSelectedLang);
if (bodyNode == nullptr)
bodyNode = XmlFirstChild(node, "body");
@@ -1276,18 +1292,6 @@ void CJabberProto::XmppMsg::process()
NotifyEventHooks(m_proto->m_hEventNudge, hContact, 0);
}
- // chatstates gone event
- if (hContact && XmlGetChildByTag(node, "gone", "xmlns", JABBER_FEAT_CHATSTATES) && m_proto->m_bLogChatstates) {
- char bEventType = JABBER_DB_EVENT_CHATSTATES_GONE; // gone event
- DBEVENTINFO dbei = {};
- dbei.pBlob = &bEventType;
- dbei.cbBlob = 1;
- dbei.eventType = EVENTTYPE_JABBER_CHATSTATES;
- dbei.flags = DBEF_READ;
- dbei.timestamp = time(0);
- dbei.szModule = m_proto->m_szModuleName;
- db_event_add(hContact, &dbei);
- }
if (auto* n = XmlGetChildByTag(node, "confirm", "xmlns", JABBER_FEAT_HTTP_AUTH)) if (m_proto->m_bAcceptHttpAuth) {
const char* szId = XmlGetAttr(n, "id");
@@ -1312,12 +1316,7 @@ void CJabberProto::XmppMsg::process()
return;
}
- if (m_proto->m_bUseOMEMO) {
- if (auto* encNode = XmlGetChildByTag(node, "encrypted", "xmlns", JABBER_FEAT_OMEMO)) {
- m_proto->OmemoHandleMessage(encNode, from, msgTime, bWasSent);
- return; //we do not want any additional processing
- }
- }
+ handle_omemo();
// parsing extensions
for (auto* xNode : TiXmlEnum(node)) {
@@ -1443,7 +1442,11 @@ void CJabberProto::XmppMsg::process()
if (!bOffline)
CallService(MS_PROTO_CONTACTISTYPING, hContact, PROTOTYPE_CONTACTTYPING_OFF);
- DB::EventInfo dbei;
+ add_to_db();
+}
+
+void CJabberProto::XmppMsg::add_to_db()
+{
if (bCreateRead)
dbei.flags |= DBEF_READ;
if (bWasSent)
@@ -1459,17 +1462,12 @@ void CJabberProto::XmppMsg::process()
}
-void CJabberProto::XmppMsg::add_to_db()
-{
-
-}
-
-void CJabberProto::OnProcessMessage(const TiXmlElement *node, ThreadData *info)
+void CJabberProto::OnProcessMessage(const TiXmlElement *node, ThreadData *)
{
if (!node->Name() || mir_strcmp(node->Name(), "message"))
return;
- auto msg = XmppMsg(node, info, this);
+ auto msg = XmppMsg(node, this);
msg.process();