From cefe13e9c64aa74f2a9e1b2d7bd6115267911a06 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 21 Apr 2021 20:06:07 +0300 Subject: =?UTF-8?q?=D0=BD=D0=B5=20=D0=BF=D1=80=D0=B8=D0=B3=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D0=BB=D0=BE=D1=81=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/WhatsAppWeb/src/server.cpp | 11 ------- protocols/WhatsAppWeb/src/utils.cpp | 60 ------------------------------------ protocols/WhatsAppWeb/src/utils.h | 29 ----------------- 3 files changed, 100 deletions(-) (limited to 'protocols') diff --git a/protocols/WhatsAppWeb/src/server.cpp b/protocols/WhatsAppWeb/src/server.cpp index a5a3bc474b..9c7bd92832 100644 --- a/protocols/WhatsAppWeb/src/server.cpp +++ b/protocols/WhatsAppWeb/src/server.cpp @@ -452,17 +452,6 @@ void WhatsAppProto::ProcessBinaryPacket(const MBinBuffer &buf) ///////////////////////////////////////////////////////////////////////////////////////// -static WAS_Field msgFields[] = -{ - { WAS_STRING, 1, FIELD_OFFSET(WAMessage, szShit) }, - { WAS_STRING, 0, FIELD_OFFSET(WAMessage, szJid) }, - { WAS_BOOL, 0, FIELD_OFFSET(WAMessage, bFromTo) }, - { WAS_BINARY, 0, FIELD_OFFSET(WAMessage, szMsgId) }, - { WAS_INT8, 0, FIELD_OFFSET(WAMessage, iMsgType) }, - { WAS_STRING, 0, FIELD_OFFSET(WAMessage, szBody) }, - { WAS_INT64, 0, FIELD_OFFSET(WAMessage, timestamp) }, -}; - void WhatsAppProto::ProcessAdd(const JSONNode &list) { for (auto &it : list) { diff --git a/protocols/WhatsAppWeb/src/utils.cpp b/protocols/WhatsAppWeb/src/utils.cpp index 70f2f5892f..47ab78b189 100644 --- a/protocols/WhatsAppWeb/src/utils.cpp +++ b/protocols/WhatsAppWeb/src/utils.cpp @@ -344,63 +344,3 @@ CMStringA WAReader::readStringFromChars(int size) m_buf += size; return ret; } - -///////////////////////////////////////////////////////////////////////////////////////// -// Object serialization - -bool WAS_Decoder::read(void *pObj, const WAS_Field *fields, size_t iFieldCount) -{ - BYTE *pDest = (BYTE *)pObj; - - for (int i = 0; i < iFieldCount; i++) { - auto &F = fields[i]; - switch (F.type) { - case WAS_STRING: - if (*m_buf++ != 0x0A) return false; - { - char **d = (char **)&pDest[F.offset]; - int len = (F.len == 0) ? *m_buf++ : F.len; - *d = (char *)mir_strndup((char*)m_buf, len); - m_buf += len; - } - break; - - case WAS_BINARY: - if (*m_buf++ != 0x1A) return false; - { - char **d = (char **)&pDest[F.offset]; - int len = (F.len == 0) ? *m_buf++ : F.len; - *d = (char *)mir_strndup((char*)m_buf, len); - m_buf += len; - } - break; - - case WAS_BOOL: - if (*m_buf++ != 0x10) return false; - { - bool *d = (bool *)&pDest[F.offset]; - *d = *m_buf++; - } - break; - - case WAS_INT8: - if (*m_buf++ != 0x12) return false; - { - BYTE *d = (BYTE*)&pDest[F.offset]; - *d = *m_buf++; - } - break; - - case WAS_INT64: - if (*m_buf++ != 0x18) return false; - { - __int64 *d = (__int64 *)&pDest[F.offset]; - *d = *(__int64 *)m_buf; - m_buf += sizeof(__int64); - } - break; - } - } - - return true; -} diff --git a/protocols/WhatsAppWeb/src/utils.h b/protocols/WhatsAppWeb/src/utils.h index aa74f865f2..d37c8fb187 100644 --- a/protocols/WhatsAppWeb/src/utils.h +++ b/protocols/WhatsAppWeb/src/utils.h @@ -45,32 +45,3 @@ public: CMStringA readString(int tag); bool readNode(JSONNode&); }; - -///////////////////////////////////////////////////////////////////////////////////////// -// object serialization - -#define WAS_STRING 1 -#define WAS_BINARY 2 -#define WAS_BOOL 3 -#define WAS_INT8 4 -#define WAS_INT64 5 - -struct WAS_Field -{ - uint8_t type; - uint8_t len; - uint16_t offset; -}; - -class WAS_Decoder -{ - const BYTE *m_buf, *m_limit; - -public: - WAS_Decoder(const void *pData, size_t cbLen) : - m_buf((BYTE*)pData), - m_limit((BYTE*)pData + cbLen) - {} - - bool read(void *pObj, const WAS_Field *fields, size_t iFieldCount); -}; -- cgit v1.2.3