diff options
Diffstat (limited to 'protocols/WhatsAppWeb/src/utils.cpp')
-rw-r--r-- | protocols/WhatsAppWeb/src/utils.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/protocols/WhatsAppWeb/src/utils.cpp b/protocols/WhatsAppWeb/src/utils.cpp new file mode 100644 index 0000000000..49ece0557a --- /dev/null +++ b/protocols/WhatsAppWeb/src/utils.cpp @@ -0,0 +1,36 @@ +/* + +WhatsAppWeb plugin for Miranda NG +Copyright © 2019 George Hazan + +*/ + +#include "stdafx.h" + +WAUser* WhatsAppProto::FindUser(const char *szId) +{ + mir_cslock lck(m_csUsers); + auto *tmp = (WAUser *)_alloca(sizeof(WAUser)); + tmp->szId = (char*)szId; + return m_arUsers.find(tmp); +} + +WAUser* WhatsAppProto::AddUser(const char *szId, bool bTemporary) +{ + auto *pUser = FindUser(szId); + if (pUser != nullptr) + return pUser; + + MCONTACT hContact = db_add_contact(); + Proto_AddToContact(hContact, m_szModuleName); + setString(hContact, DBKEY_ID, szId); + pUser = new WAUser(hContact, mir_strdup(szId)); + if (bTemporary) + Contact_RemoveFromList(hContact); + if (m_wszDefaultGroup) + Clist_SetGroup(hContact, m_wszDefaultGroup); + + mir_cslock lck(m_csUsers); + m_arUsers.insert(pUser); + return pUser; +} |