summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-05-17 15:30:56 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-05-17 15:30:56 +0300
commitb187e26bed076915d6c8a8292aae404a67b585f9 (patch)
treee8c6da5b5eb62c4f2607613abeee5990362a250d
parente15fd1bc90514389019dc408115cf929db3701cf (diff)
WhatsApp: fix against wiping keys from profile
-rw-r--r--protocols/WhatsAppWeb/src/proto.h7
-rw-r--r--protocols/WhatsAppWeb/src/server.cpp16
2 files changed, 15 insertions, 8 deletions
diff --git a/protocols/WhatsAppWeb/src/proto.h b/protocols/WhatsAppWeb/src/proto.h
index 0437d4ed36..fc8f036af6 100644
--- a/protocols/WhatsAppWeb/src/proto.h
+++ b/protocols/WhatsAppWeb/src/proto.h
@@ -227,6 +227,13 @@ public:
{ return m_hServerConn != 0;
}
+ __forceinline void writeStr(const char *pszSetting, const JSONNode &node)
+ {
+ CMStringW str(node.as_mstring());
+ if (!str.IsEmpty())
+ setWString(pszSetting, str);
+ }
+
class CWhatsAppQRDlg *m_pQRDlg;
// PROTO_INTERFACE /////////////////////////////////////////////////////////////////////
diff --git a/protocols/WhatsAppWeb/src/server.cpp b/protocols/WhatsAppWeb/src/server.cpp
index ff6b0c2740..639f801eca 100644
--- a/protocols/WhatsAppWeb/src/server.cpp
+++ b/protocols/WhatsAppWeb/src/server.cpp
@@ -122,7 +122,7 @@ int WhatsAppProto::WSSendNode(const char *pszPrefix, WAMetric metric, int flags,
void WhatsAppProto::OnLoggedIn()
{
- debugLogA("CDiscordProto::OnLoggedIn");
+ debugLogA("WhatsAppProto::OnLoggedIn");
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)m_iStatus, m_iDesiredStatus);
m_iStatus = m_iDesiredStatus;
@@ -133,7 +133,7 @@ void WhatsAppProto::OnLoggedIn()
void WhatsAppProto::OnLoggedOut(void)
{
- debugLogA("CDiscordProto::OnLoggedOut");
+ debugLogA("WhatsAppProto::OnLoggedOut");
m_bTerminated = true;
m_iPktNumber = 0;
@@ -708,8 +708,8 @@ void WhatsAppProto::ProcessConn(const JSONNode &root)
{
CloseQrDialog();
- m_szJid = root["wid"].as_mstring();
- setString(DBKEY_ID, m_szJid);
+ writeStr(DBKEY_ID, root["wid"]);
+ m_szJid = getMStringA(DBKEY_ID);
CMStringA szSecret(root["secret"].as_mstring());
if (!szSecret.IsEmpty())
@@ -718,10 +718,10 @@ void WhatsAppProto::ProcessConn(const JSONNode &root)
return;
}
- setWString(DBKEY_NICK, root["pushname"].as_mstring());
- setWString(DBKEY_CLIENT_TOKEN, root["clientToken"].as_mstring());
- setWString(DBKEY_SERVER_TOKEN, root["serverToken"].as_mstring());
- setWString(DBKEY_BROWSER_TOKEN, root["browserToken"].as_mstring());
+ writeStr(DBKEY_NICK, root["pushname"]);
+ writeStr(DBKEY_CLIENT_TOKEN, root["clientToken"]);
+ writeStr(DBKEY_SERVER_TOKEN, root["serverToken"]);
+ writeStr(DBKEY_BROWSER_TOKEN, root["browserToken"]);
OnLoggedIn();
}