From de6c7df3c362fa0104e7d908c29614266caaa9d6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 26 Jan 2015 16:19:13 +0000 Subject: fixed user search & addition git-svn-id: http://svn.miranda-ng.org/main/trunk@11918 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp | 30 +++++++-------- .../WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp | 26 ++++++------- protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp | 44 +++++++++++----------- protocols/WhatsApp/src/WhatsAPI++/WALogin.h | 4 +- 4 files changed, 52 insertions(+), 52 deletions(-) (limited to 'protocols/WhatsApp/src/WhatsAPI++') diff --git a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp index 99c186f126..0cb12b2e93 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp @@ -183,25 +183,25 @@ ReadData* BinTreeNodeReader::readString(int token) } return ret; - case 255: - bSize = readInt8(this->in); - { - int size = bSize & 0x7f; - int numnibbles = size * 2 - ((bSize & 0x80) ? 1 : 0); - + case 255: + bSize = readInt8(this->in); + { + int size = bSize & 0x7f; + int numnibbles = size * 2 - ((bSize & 0x80) ? 1 : 0); + std::vector tmp(size); fillArray(tmp, size, this->in); - std::string s; - for (int i = 0; i < numnibbles; i++) { - char c = (tmp[i / 2] >> (4 - ((i & 1) << 2))) & 0xF; - if (c < 10) s += (c + '0'); - else s += (c - 10 + '-'); - } - + std::string s; + for (int i = 0; i < numnibbles; i++) { + char c = (tmp[i / 2] >> (4 - ((i & 1) << 2))) & 0xF; + if (c < 10) s += (c + '0'); + else s += (c - 10 + '-'); + } + ret->type = STRING; ret->data = new std::string(s); - } - return ret; + } + return ret; case 250: std::string* user = readStringAsString(); diff --git a/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp b/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp index cb3bc19258..7ef362ef4b 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp @@ -12,35 +12,35 @@ static std::string nilstr; -ProtocolTreeNode::ProtocolTreeNode(const string& tag, vector* data, vector *children) +ProtocolTreeNode::ProtocolTreeNode(const string &_tag, vector* _data, vector *_children) : + tag(_tag) { - this->tag = tag; - this->data = data; - this->attributes = NULL; - this->children = children; + data = _data; + attributes = NULL; + children = _children; } -ProtocolTreeNode::ProtocolTreeNode(const string& tag, ProtocolTreeNode* child) +ProtocolTreeNode::ProtocolTreeNode(const string &_tag, ProtocolTreeNode *_child) : + tag(_tag) { - this->tag = tag; this->data = NULL; this->attributes = NULL; - this->children = new std::vector(1); - (*this->children)[0] = child; + this->children = new std::vector(); + children->push_back(_child); } ProtocolTreeNode::~ProtocolTreeNode() { - if (this->attributes != NULL) - delete this->attributes; + delete this->attributes; + if (this->children != NULL) { for (size_t i = 0; i < this->children->size(); i++) if (this->children->at(i) != NULL) delete this->children->at(i); delete this->children; } - if (this->data != NULL) - delete data; + + delete data; } diff --git a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp index 40471ae559..dd29850885 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp @@ -22,7 +22,7 @@ const std::string WALogin::NONCE_KEY = "nonce=\""; WALogin::WALogin(WAConnection* connection, const std::string& password) { - this->connection = connection; + m_pConnection = connection; this->password = password; this->account_kind = -1; this->expire_date = 0L; @@ -30,21 +30,21 @@ WALogin::WALogin(WAConnection* connection, const std::string& password) std::vector* WALogin::login(const std::vector& authBlob) { - connection->out->streamStart(connection->domain, connection->resource); + m_pConnection->out->streamStart(m_pConnection->domain, m_pConnection->resource); - connection->logData("sent stream start"); + m_pConnection->logData("sent stream start"); sendFeatures(); - connection->logData("sent features"); + m_pConnection->logData("sent features"); sendAuth(authBlob); - connection->logData("send auth, auth blob size %d", authBlob.size()); + m_pConnection->logData("send auth, auth blob size %d", authBlob.size()); - connection->in->streamStart(); + m_pConnection->in->streamStart(); - connection->logData("read stream start"); + m_pConnection->logData("read stream start"); return this->readFeaturesUntilChallengeOrSuccess(); } @@ -52,7 +52,7 @@ std::vector* WALogin::login(const std::vector& aut void WALogin::sendResponse(const std::vector& challengeData) { std::vector* authBlob = this->getAuthBlob(challengeData); - connection->out->write(ProtocolTreeNode("response", authBlob)); + m_pConnection->out->write(ProtocolTreeNode("response", authBlob)); } void WALogin::sendFeatures() @@ -64,7 +64,7 @@ void WALogin::sendFeatures() ProtocolTreeNode* pictureChild = new ProtocolTreeNode("w:profile:picture") << XATTR("type", "all"); children->push_back(pictureChild); - connection->out->write(ProtocolTreeNode("stream:features", NULL, children), true); + m_pConnection->out->write(ProtocolTreeNode("stream:features", NULL, children), true); } void WALogin::sendAuth(const std::vector& existingChallenge) @@ -73,8 +73,8 @@ void WALogin::sendAuth(const std::vector& existingChallenge) if (!existingChallenge.empty()) data = this->getAuthBlob(existingChallenge); - connection->out->write(ProtocolTreeNode("auth", data) << - XATTR("mechanism", "WAUTH-2") << XATTR("user", connection->user), true); + m_pConnection->out->write(ProtocolTreeNode("auth", data) << + XATTR("mechanism", "WAUTH-2") << XATTR("user", m_pConnection->user), true); } std::vector* WALogin::getAuthBlob(const std::vector& nonce) @@ -82,31 +82,31 @@ std::vector* WALogin::getAuthBlob(const std::vectorpassword, nonce, out); - this->connection->inputKey.init(out + 40, out + 60); - this->connection->outputKey.init(out, out + 20); + m_pConnection->inputKey.init(out + 40, out + 60); + m_pConnection->outputKey.init(out, out + 20); std::vector* list = new std::vector(0); for (int i = 0; i < 4; i++) list->push_back(0); - list->insert(list->end(), connection->user.begin(), connection->user.end()); + list->insert(list->end(), m_pConnection->user.begin(), m_pConnection->user.end()); list->insert(list->end(), nonce.begin(), nonce.end()); - this->connection->outputKey.encodeMessage(&((*list)[0]), 0, 4, (int)list->size() - 4); + m_pConnection->outputKey.encodeMessage(&((*list)[0]), 0, 4, (int)list->size() - 4); return list; } std::vector* WALogin::readFeaturesUntilChallengeOrSuccess() { - while (ProtocolTreeNode *root = connection->in->nextTree()) { + while (ProtocolTreeNode *root = m_pConnection->in->nextTree()) { #ifdef _DEBUG { string tmp = root->toString(); - connection->logData(tmp.c_str()); + m_pConnection->logData(tmp.c_str()); } #endif if (ProtocolTreeNode::tagEquals(root, "stream:features")) { - connection->supports_receipt_acks = root->getChild("receipt_acks") != NULL; + m_pConnection->supports_receipt_acks = root->getChild("receipt_acks") != NULL; delete root; continue; } @@ -114,9 +114,9 @@ std::vector* WALogin::readFeaturesUntilChallengeOrSuccess() std::vector challengedata(root->data->begin(), root->data->end()); delete root; this->sendResponse(challengedata); - connection->logData("Send response"); + m_pConnection->logData("Send response"); std::vector data = this->readSuccess(); - connection->logData("Read success"); + m_pConnection->logData("Read success"); return new std::vector(data.begin(), data.end()); } if (ProtocolTreeNode::tagEquals(root, "success")) { @@ -131,7 +131,7 @@ std::vector* WALogin::readFeaturesUntilChallengeOrSuccess() void WALogin::parseSuccessNode(ProtocolTreeNode* node) { - connection->out->setSecure(); + m_pConnection->out->setSecure(); const string &expiration = node->getAttributeValue("expiration"); if (!expiration.empty()) { @@ -151,7 +151,7 @@ void WALogin::parseSuccessNode(ProtocolTreeNode* node) std::vector WALogin::readSuccess() { - ProtocolTreeNode *node = connection->in->nextTree(); + ProtocolTreeNode *node = m_pConnection->in->nextTree(); if (ProtocolTreeNode::tagEquals(node, "failure")) { delete node; diff --git a/protocols/WhatsApp/src/WhatsAPI++/WALogin.h b/protocols/WhatsApp/src/WhatsAPI++/WALogin.h index 440f34f71b..05e654549e 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WALogin.h +++ b/protocols/WhatsApp/src/WhatsAPI++/WALogin.h @@ -25,7 +25,7 @@ private: RC4_KEY rc4; unsigned char key[20], keyMac[20]; int seq; - HMAC_CTX hmac; + HMAC_CTX hmac; void hmacsha1(unsigned char* text, int textLength, unsigned char *out); @@ -44,7 +44,7 @@ public: class WALogin { private: static const std::string NONCE_KEY; - WAConnection *connection; + WAConnection *m_pConnection; std::vector* getAuthBlob(const std::vector& nonce); void sendResponse(const std::vector& challengeData); -- cgit v1.2.3