From ddb498e9d73f3cba46791983ecece2371796f29b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 29 Jan 2015 14:07:23 +0000 Subject: more cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@11949 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp | 3 +-- .../WhatsApp/src/WhatsAPI++/BinTreeNodeReader.h | 2 +- .../WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp | 11 +++++---- .../WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.h | 2 +- protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 8 +++---- protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp | 26 ++++++++++------------ protocols/WhatsApp/src/WhatsAPI++/WALogin.h | 7 +++--- 7 files changed, 27 insertions(+), 32 deletions(-) (limited to 'protocols/WhatsApp/src') diff --git a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp index 0cb12b2e93..ead6a9ac06 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp @@ -25,8 +25,7 @@ BinTreeNodeReader::BinTreeNodeReader(WAConnection *conn, ISocketConnection *conn BinTreeNodeReader::~BinTreeNodeReader() { - if (this->in != NULL) - delete this->in; + delete this->in; } ProtocolTreeNode* BinTreeNodeReader::nextTreeInternal() diff --git a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.h b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.h index 29fdf4ec0a..eb8761ce12 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.h +++ b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.h @@ -63,7 +63,7 @@ private: public: BinTreeNodeReader(WAConnection* conn, ISocketConnection* connection); - virtual ~BinTreeNodeReader(); + ~BinTreeNodeReader(); ProtocolTreeNode* nextTree(); void streamStart(); diff --git a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp index cdd39a6509..035a3c9d39 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp @@ -20,6 +20,11 @@ BinTreeNodeWriter::BinTreeNodeWriter(WAConnection* conn, ISocketConnection* conn this->dataBegin = 0; } +BinTreeNodeWriter::~BinTreeNodeWriter() +{ + delete this->out; +} + void BinTreeNodeWriter::writeDummyHeader() { int num = 3; @@ -278,9 +283,3 @@ void BinTreeNodeWriter::write(const ProtocolTreeNode &node, bool needsFlush) } this->mutex->unlock(); } - -BinTreeNodeWriter::~BinTreeNodeWriter() -{ - if (this->out != NULL) - delete this->out; -} diff --git a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.h b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.h index fa5d7f68b0..5a43d660b1 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.h +++ b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.h @@ -58,7 +58,7 @@ private: public: BinTreeNodeWriter(WAConnection* conn, ISocketConnection* connection, IMutex* mutex); - virtual ~BinTreeNodeWriter(); + ~BinTreeNodeWriter(); void streamStart(std::string domain, std::string resource); void flushBuffer(bool flushNetwork); diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp index e1175d26a6..5566d23145 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp @@ -169,11 +169,11 @@ std::string WAConnection::removeResourceFromJid(const std::string &jid) void WAConnection::setLogin(WALogin* login) { - if (login->expire_date != 0L) - this->expire_date = login->expire_date; + if (login->m_tExpireDate != 0L) + this->expire_date = login->m_tExpireDate; - if (login->account_kind != -1) - this->account_kind = login->account_kind; + if (login->m_iAccountKind != -1) + this->account_kind = login->m_iAccountKind; } void WAConnection::setVerboseId(bool b) diff --git a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp index 1f8c46faf2..edec990dfa 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp @@ -18,14 +18,12 @@ using namespace Utilities; -const std::string WALogin::NONCE_KEY = "nonce=\""; - WALogin::WALogin(WAConnection* connection, const std::string& password) { m_pConnection = connection; - this->password = password; - this->account_kind = -1; - this->expire_date = 0L; + m_szPassword = password; + m_iAccountKind = -1; + m_tExpireDate = 0L; } std::vector WALogin::login(const std::vector& authBlob) @@ -71,7 +69,7 @@ void WALogin::sendAuth(const std::vector& existingChallenge) { std::vector* data = NULL; if (!existingChallenge.empty()) - data = this->getAuthBlob(existingChallenge); + data = getAuthBlob(existingChallenge); m_pConnection->out.write(ProtocolTreeNode("auth", data) << XATTR("mechanism", "WAUTH-2") << XATTR("user", m_pConnection->user), true); @@ -80,7 +78,7 @@ void WALogin::sendAuth(const std::vector& existingChallenge) std::vector* WALogin::getAuthBlob(const std::vector& nonce) { unsigned char out[4*20]; - KeyStream::keyFromPasswordAndNonce(this->password, nonce, out); + KeyStream::keyFromPasswordAndNonce(m_szPassword, nonce, out); m_pConnection->inputKey.init(out + 40, out + 60); m_pConnection->outputKey.init(out, out + 20); @@ -135,18 +133,18 @@ void WALogin::parseSuccessNode(ProtocolTreeNode* node) const string &expiration = node->getAttributeValue("expiration"); if (!expiration.empty()) { - this->expire_date = atol(expiration.c_str()); - if (this->expire_date == 0) + m_tExpireDate = atol(expiration.c_str()); + if (m_tExpireDate == 0) throw WAException("invalid expire date: " + expiration); } const string &kind = node->getAttributeValue("kind"); if (kind == "paid") - this->account_kind = 1; + m_iAccountKind = 1; else if (kind == "free") - this->account_kind = 0; + m_iAccountKind = 0; else - this->account_kind = -1; + m_iAccountKind = -1; } std::vector WALogin::readSuccess() @@ -164,7 +162,7 @@ std::vector WALogin::readSuccess() const string &status = node->getAttributeValue("status"); if (status == "expired") { delete node; - throw WAException("Account expired on" + std::string(ctime(&this->expire_date)), WAException::LOGIN_FAILURE_EX, WAException::LOGIN_FAILURE_EX_TYPE_EXPIRED, this->expire_date); + throw WAException("Account expired on" + std::string(ctime(&m_tExpireDate)), WAException::LOGIN_FAILURE_EX, WAException::LOGIN_FAILURE_EX_TYPE_EXPIRED, m_tExpireDate); } if (status == "active") { if (node->getAttributeValue("expiration").empty()) { @@ -172,7 +170,7 @@ std::vector WALogin::readSuccess() throw WAException("active account with no expiration"); } } - else this->account_kind = -1; + else m_iAccountKind = -1; std::vector data = *node->data; delete node; diff --git a/protocols/WhatsApp/src/WhatsAPI++/WALogin.h b/protocols/WhatsApp/src/WhatsAPI++/WALogin.h index 1e4269b531..30c5937810 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WALogin.h +++ b/protocols/WhatsApp/src/WhatsAPI++/WALogin.h @@ -43,7 +43,6 @@ public: class WALogin { private: - static const std::string NONCE_KEY; WAConnection *m_pConnection; std::vector* getAuthBlob(const std::vector& nonce); @@ -55,9 +54,9 @@ private: std::vector readSuccess(); public: - time_t expire_date; - int account_kind; - std::string password; + time_t m_tExpireDate; + int m_iAccountKind; + std::string m_szPassword; WALogin(WAConnection* connection, const std::string& password); ~WALogin(); -- cgit v1.2.3