diff options
author | George Hazan <ghazan@miranda.im> | 2021-04-21 20:06:07 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-04-21 20:06:07 +0300 |
commit | cefe13e9c64aa74f2a9e1b2d7bd6115267911a06 (patch) | |
tree | e6ce90fa05f9472279bae2cd2d0c70e15128dc93 /protocols/WhatsAppWeb | |
parent | 8c9108eeb7a2a4e763973ed26b1ab2c0323f5dfb (diff) |
не пригодилось
Diffstat (limited to 'protocols/WhatsAppWeb')
-rw-r--r-- | protocols/WhatsAppWeb/src/server.cpp | 11 | ||||
-rw-r--r-- | protocols/WhatsAppWeb/src/utils.cpp | 60 | ||||
-rw-r--r-- | protocols/WhatsAppWeb/src/utils.h | 29 |
3 files changed, 0 insertions, 100 deletions
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); -}; |