diff options
author | Tobias Weimer <wishmaster51@googlemail.com> | 2015-09-21 19:06:14 +0000 |
---|---|---|
committer | Tobias Weimer <wishmaster51@googlemail.com> | 2015-09-21 19:06:14 +0000 |
commit | 06ca08ab518ba90cc82db8cc9ac27b5a25340510 (patch) | |
tree | fb53c39091f9106431605da5af92fab710b74242 /protocols/WhatsApp/src/WhatsAPI++ | |
parent | a8af09a3f64f5cb1b7417977ed8265b5a97e4107 (diff) |
WhatsApp:
- Request password with Voice (patch by Cassio)
- minor fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@15418 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 10 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp | 7 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp | 8 |
3 files changed, 17 insertions, 8 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp index 524bb80f2a..e6640b0156 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp @@ -875,7 +875,15 @@ void WAConnection::processUploadResponse(ProtocolTreeNode * node, FMessage * mes fileName = tempfileName.substr(index);
}
else {
- string json = MediaUploader::pushfile(node->getChild("media")->getAttributeValue("url"),message, this->user);
+ ProtocolTreeNode *media = node->getChild("media");
+ if (media == NULL)
+ return;
+
+ string url = media->getAttributeValue("url");
+ if(url.empty())
+ return;
+
+ string json = MediaUploader::pushfile(url,message, this->user);
if (json.empty())
return;
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp index 5184dab86e..efcb9551fb 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp @@ -108,9 +108,8 @@ std::vector<unsigned char> WALogin::readFeaturesUntilChallengeOrSuccess() if (ProtocolTreeNode::tagEquals(root, "stream:features")) {
m_pConnection->supports_receipt_acks = root->getChild("receipt_acks") != NULL;
delete root;
- continue;
}
- if (ProtocolTreeNode::tagEquals(root, "challenge")) {
+ else if (ProtocolTreeNode::tagEquals(root, "challenge")) {
std::vector<unsigned char> challengedata(root->data->begin(), root->data->end());
delete root;
this->sendResponse(challengedata);
@@ -119,12 +118,14 @@ std::vector<unsigned char> WALogin::readFeaturesUntilChallengeOrSuccess() m_pConnection->logData("Read success");
return std::vector<unsigned char>(data.begin(), data.end());
}
- if (ProtocolTreeNode::tagEquals(root, "success")) {
+ else if (ProtocolTreeNode::tagEquals(root, "success")) {
std::vector<unsigned char> ret(root->data->begin(), root->data->end());
this->parseSuccessNode(root);
delete root;
return ret;
}
+ else
+ delete root;
}
throw WAException("fell out of loop in readFeaturesAndChallenge", WAException::CORRUPT_STREAM_EX, 0);
}
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp b/protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp index 476bb9ced4..2bf0cb8b83 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WARegister.cpp @@ -27,7 +27,6 @@ std::string WAToken::GenerateToken(const string &number) /////////////////////////////////////////////////////////////////////////////////////////
// Account registration
-
CMStringA WARegister::RequestCodeUrl(const std::string &phoneNumber, const std::string &code)
{
try {
@@ -38,11 +37,11 @@ CMStringA WARegister::RequestCodeUrl(const std::string &phoneNumber, const std:: const char *n = pn.Number.c_str();
- if (!code.empty())
+ if (!code.empty() && code != "voice" && code != "sms")
return CMStringA(FORMAT, "https://v.whatsapp.net/v2/register?cc=%d&in=%s&id=%s&code=%s", pn.countryCode, n, id.c_str(), code.c_str());
- return CMStringA(FORMAT, "https://v.whatsapp.net/v2/code?cc=%d&in=%s&to=%d%s&method=sms&mcc=%03d&mnc=%03d&token=%s&id=%s&lg=%s&lc=%s",
- pn.countryCode, n, pn.countryCode, n, pn.mcc, pn.mnc, token.c_str(), id.c_str(), pn.ISO639, pn.ISO3166);
+ return CMStringA(FORMAT, "https://v.whatsapp.net/v2/code?cc=%d&in=%s&to=%d%s&method=%s&mcc=%03d&mnc=%03d&token=%s&id=%s&lg=%s&lc=%s",
+ pn.countryCode, n, pn.countryCode, n, code.c_str(), pn.mcc, pn.mnc, token.c_str(), id.c_str(), pn.ISO639, pn.ISO3166);
}
catch (...)
{}
@@ -50,6 +49,7 @@ CMStringA WARegister::RequestCodeUrl(const std::string &phoneNumber, const std:: return CMStringA();
}
+
std::string WARegister::GenerateIdentity(const std::string &phone)
{
std::string id = phone;
|