summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-11-15 21:20:05 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-11-15 21:20:05 +0300
commit56d8aec9fd39699ea71f492741c785487e862630 (patch)
tree4ff9e431064debc794c4ec2af25e6bc8ab682485 /protocols/WhatsApp
parentabbec7be53ade1d599d1c02f91b03e2f66d82f33 (diff)
WhatsApp: fix for device list
Diffstat (limited to 'protocols/WhatsApp')
-rw-r--r--protocols/WhatsApp/src/iq.cpp4
-rw-r--r--protocols/WhatsApp/src/message.cpp4
-rw-r--r--protocols/WhatsApp/src/proto.h13
-rw-r--r--protocols/WhatsApp/src/utils.cpp4
-rw-r--r--protocols/WhatsApp/src/utils.h2
5 files changed, 8 insertions, 19 deletions
diff --git a/protocols/WhatsApp/src/iq.cpp b/protocols/WhatsApp/src/iq.cpp
index c86e1e23a1..3c0cd8c64f 100644
--- a/protocols/WhatsApp/src/iq.cpp
+++ b/protocols/WhatsApp/src/iq.cpp
@@ -13,7 +13,7 @@ void WhatsAppProto::OnAccountSync(const WANode &node)
for (auto &it : node.getChild("devices")->getChildren())
if (it->title == "device")
- m_arDevices.insert(new WADevice(it->getAttr("jid"), it->getAttrInt("key-index")));
+ m_arDevices.insert(new WAJid(it->getAttr("jid"), it->getAttrInt("key-index")));
SendAck(node);
}
@@ -91,7 +91,7 @@ void WhatsAppProto::OnIqGetUsync(const WANode &node)
if (auto *pList = nUser->getChild("devices")->getChild("device-list"))
for (auto &it : pList->getChildren())
if (it->title == "device")
- m_arDevices.insert(new WADevice(pszJid, it->getAttrInt("id")));
+ m_arDevices.insert(new WAJid(pszJid, it->getAttrInt("id")));
}
}
diff --git a/protocols/WhatsApp/src/message.cpp b/protocols/WhatsApp/src/message.cpp
index df272eb0b0..78567f355a 100644
--- a/protocols/WhatsApp/src/message.cpp
+++ b/protocols/WhatsApp/src/message.cpp
@@ -411,7 +411,7 @@ int WhatsAppProto::SendTextMessage(const char *jid, const char *pszMsg)
shouldIncludeIdentity = CreateMsgParticipant(pParticipants, WAJid(T2Utf(it->pszUID)), encodedMeMsg);
for (auto &it : m_arDevices)
- shouldIncludeIdentity |= CreateMsgParticipant(pParticipants, it->jid, encodedMeMsg);
+ shouldIncludeIdentity |= CreateMsgParticipant(pParticipants, *it, encodedMeMsg);
}
else {
Wa__Message__DeviceSentMessage sentBody;
@@ -426,7 +426,7 @@ int WhatsAppProto::SendTextMessage(const char *jid, const char *pszMsg)
shouldIncludeIdentity = CreateMsgParticipant(pParticipants, toJid, encodedMeMsg);
for (auto &it : m_arDevices)
- shouldIncludeIdentity |= CreateMsgParticipant(pParticipants, it->jid, encodedMeMsg);
+ shouldIncludeIdentity |= CreateMsgParticipant(pParticipants, *it, encodedMeMsg);
}
if (shouldIncludeIdentity) {
diff --git a/protocols/WhatsApp/src/proto.h b/protocols/WhatsApp/src/proto.h
index 4d5c8773b7..4f52f0409e 100644
--- a/protocols/WhatsApp/src/proto.h
+++ b/protocols/WhatsApp/src/proto.h
@@ -53,17 +53,6 @@ struct WARequest
void *pUserInfo;
};
-struct WADevice
-{
- WADevice(const char *_1, int _2) :
- jid(_1),
- key_index(_2)
- {}
-
- WAJid jid;
- int key_index;
-};
-
struct WAPersistentHandler
{
WAPersistentHandler(const char *_1, const char *_2, const char *_3, const char *_4, WA_PKT_HANDLER _5) :
@@ -284,7 +273,7 @@ class WhatsAppProto : public PROTO<WhatsAppProto>
mir_cs m_csOwnMessages;
OBJLIST<WAOwnMessage> m_arOwnMsgs;
- OBJLIST<WADevice> m_arDevices;
+ OBJLIST<WAJid> m_arDevices;
WAUser* FindUser(const char *szId);
WAUser* AddUser(const char *szId, bool bTemporary);
diff --git a/protocols/WhatsApp/src/utils.cpp b/protocols/WhatsApp/src/utils.cpp
index f4cc2e0e55..9f4d64a4d4 100644
--- a/protocols/WhatsApp/src/utils.cpp
+++ b/protocols/WhatsApp/src/utils.cpp
@@ -14,7 +14,7 @@ WAJid::WAJid(const char *pszUser, const char *pszServer, int iDevice, int iAgent
agent(iAgent)
{}
-WAJid::WAJid(const char *pszJid)
+WAJid::WAJid(const char *pszJid, int _id)
{
if (pszJid == nullptr)
pszJid = "";
@@ -30,7 +30,7 @@ WAJid::WAJid(const char *pszJid)
*p = 0;
device = atoi(p + 1);
}
- else device = 0;
+ else device = _id;
if (p = strrchr(tmp, '_')) {
*p = 0;
diff --git a/protocols/WhatsApp/src/utils.h b/protocols/WhatsApp/src/utils.h
index af13efd2eb..5eafb39628 100644
--- a/protocols/WhatsApp/src/utils.h
+++ b/protocols/WhatsApp/src/utils.h
@@ -160,7 +160,7 @@ struct WAJid
int device, agent;
CMStringA user, server;
- WAJid(const char *pszJid);
+ WAJid(const char *pszJid, int device = 0);
WAJid(const char *pszUser, const char *pszServer, int device = 0, int agent = 0);
CMStringA toString() const;