diff options
author | George Hazan <ghazan@miranda.im> | 2022-10-01 14:20:05 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-10-01 14:20:05 +0300 |
commit | 87ff6ba67d4df0b4c0ae3db86220b816ec6a1e75 (patch) | |
tree | 9927b65a05688d70cf1fef5ef52a7fe956138de2 /protocols/WhatsAppWeb/src/proto.cpp | |
parent | 6de31630215f88f3639efb834be02e5af9bfce57 (diff) |
WhatsApp:
- first version that registers ok in the phone (YAHOO!!);
- the rest of legacy code removed;
- class WAJid introduced to handle various perversions;
- ServerThread behavior changed to use global variables instead of locals;
- IQ processing core extracted to the separate module;
- added <stream:error> processing
Diffstat (limited to 'protocols/WhatsAppWeb/src/proto.cpp')
-rw-r--r-- | protocols/WhatsAppWeb/src/proto.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/protocols/WhatsAppWeb/src/proto.cpp b/protocols/WhatsAppWeb/src/proto.cpp index c3d965e919..8e94628b92 100644 --- a/protocols/WhatsAppWeb/src/proto.cpp +++ b/protocols/WhatsAppWeb/src/proto.cpp @@ -30,6 +30,7 @@ static int CompareUsers(const WAUser *p1, const WAUser *p2) WhatsAppProto::WhatsAppProto(const char *proto_name, const wchar_t *username) : PROTO<WhatsAppProto>(proto_name, username), m_impl(*this), + m_szJid(getMStringA(DBKEY_JID)), m_tszDefaultGroup(getWStringA(DBKEY_DEF_GROUP)), m_arUsers(10, CompareUsers), m_arOwnMsgs(1, CompareOwnMsgs), @@ -49,18 +50,7 @@ WhatsAppProto::WhatsAppProto(const char *proto_name, const wchar_t *username) : HookProtoEvent(ME_OPT_INITIALISE, &WhatsAppProto::OnOptionsInit); - m_arPersistent.insert(new WAPersistentHandler("iq", "md", "pair-device", &WhatsAppProto::OnIqPairDevice)); - m_arPersistent.insert(new WAPersistentHandler("iq", "md", "pair-success", &WhatsAppProto::OnIqPairSuccess)); - - // Client id generation - m_szClientId = getMStringA(DBKEY_CLIENT_ID); - if (m_szClientId.IsEmpty()) { - int8_t randBytes[16]; - Utils_GetRandom(randBytes, sizeof(randBytes)); - - m_szClientId = ptrA(mir_base64_encode(randBytes, sizeof(randBytes))); - setString(DBKEY_CLIENT_ID, m_szClientId); - } + InitPersistentHandlers(); // Create standard network connection wchar_t descr[512]; @@ -72,6 +62,7 @@ WhatsAppProto::WhatsAppProto(const char *proto_name, const wchar_t *username) : nlu.szDescriptiveName.w = descr; m_hNetlibUser = Netlib_RegisterUser(&nlu); + // Avatars folder m_tszAvatarFolder = CMStringW(VARSW(L"%miranda_avatarcache%")) + L"\\" + m_tszUserName; DWORD dwAttributes = GetFileAttributes(m_tszAvatarFolder.c_str()); if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0) @@ -101,7 +92,7 @@ void WhatsAppProto::OnModulesLoaded() { // initialize contacts cache for (auto &cc : AccContacts()) { - CMStringA szId(getMStringA(cc, isChatRoom(cc) ? "ChatRoomID" : DBKEY_ID)); + CMStringA szId(getMStringA(cc, isChatRoom(cc) ? "ChatRoomID" : DBKEY_JID)); if (!szId.IsEmpty()) m_arUsers.insert(new WAUser(cc, szId)); } @@ -225,7 +216,7 @@ void WhatsAppProto::OnSendMessage(const JSONNode &node, void*) int WhatsAppProto::SendMsg(MCONTACT hContact, int, const char *pszMsg) { - ptrA jid(getStringA(hContact, DBKEY_ID)); + ptrA jid(getStringA(hContact, DBKEY_JID)); if (jid == nullptr || pszMsg == nullptr) return 0; @@ -267,7 +258,7 @@ int WhatsAppProto::SendMsg(MCONTACT hContact, int, const char *pszMsg) int WhatsAppProto::UserIsTyping(MCONTACT hContact, int) { if (hContact && isOnline()) { - ptrA jid(getStringA(hContact, DBKEY_ID)); + ptrA jid(getStringA(hContact, DBKEY_JID)); if (jid && isOnline()) { } } |