diff options
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
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<unsigned char>* WALogin::login(const std::vector<unsigned char>& 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<unsigned char>* WALogin::login(const std::vector<unsigned char>& aut void WALogin::sendResponse(const std::vector<unsigned char>& challengeData)
{
std::vector<unsigned char>* 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<unsigned char>& existingChallenge)
@@ -73,8 +73,8 @@ void WALogin::sendAuth(const std::vector<unsigned char>& 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<unsigned char>* WALogin::getAuthBlob(const std::vector<unsigned char>& nonce)
@@ -82,31 +82,31 @@ std::vector<unsigned char>* WALogin::getAuthBlob(const std::vector<unsigned char unsigned char out[4*20];
KeyStream::keyFromPasswordAndNonce(this->password, 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<unsigned char>* list = new std::vector<unsigned char>(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<unsigned char>* 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<unsigned char>* WALogin::readFeaturesUntilChallengeOrSuccess() std::vector<unsigned char> challengedata(root->data->begin(), root->data->end());
delete root;
this->sendResponse(challengedata);
- connection->logData("Send response");
+ m_pConnection->logData("Send response");
std::vector<unsigned char> data = this->readSuccess();
- connection->logData("Read success");
+ m_pConnection->logData("Read success");
return new std::vector<unsigned char>(data.begin(), data.end());
}
if (ProtocolTreeNode::tagEquals(root, "success")) {
@@ -131,7 +131,7 @@ std::vector<unsigned char>* 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<unsigned char> WALogin::readSuccess()
{
- ProtocolTreeNode *node = connection->in->nextTree();
+ ProtocolTreeNode *node = m_pConnection->in->nextTree();
if (ProtocolTreeNode::tagEquals(node, "failure")) {
delete node;
|