diff options
-rw-r--r-- | protocols/JabberG/src/jabber_archive.cpp | 8 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.h | 11 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_thread.cpp | 54 |
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 67d35bec19..a373f04df6 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 c4584ebfdc..549a98795b 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1123,7 +1123,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()
@@ -1143,6 +1148,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()
@@ -1195,7 +1212,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");
@@ -1268,18 +1284,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");
@@ -1304,12 +1308,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)) {
@@ -1435,7 +1434,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)
@@ -1451,17 +1454,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();
|