diff options
author | George Hazan <george.hazan@gmail.com> | 2013-08-06 19:28:47 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-08-06 19:28:47 +0000 |
commit | 65a53b8ae95bf7adb160b4e7cb10efc342fa75d0 (patch) | |
tree | 4c3f45764730f25010c7715e701f1c79c1120588 /protocols/WhatsApp/src | |
parent | 90fc3521557ae33352dcc7baa87828b6bb0ca2b9 (diff) |
proper cleanup for wassup
git-svn-id: http://svn.miranda-ng.org/main/trunk@5605 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 12 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp | 4 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WALogin.h | 4 | ||||
-rw-r--r-- | protocols/WhatsApp/src/connection.cpp | 30 |
4 files changed, 23 insertions, 27 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp index 49f02697c7..343f7bd1f5 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp @@ -542,8 +542,8 @@ void WAConnection::setLogin(WALogin* login) { this->jid = this->login->user + "@" + this->login->domain;
this->fromm = this->login->user + "@" + this->login->domain + "/" + this->login->resource;
- this->in = login->inn;
- this->out = login->out;
+ this->in = login->getTreeNodeReader();
+ this->out = login->getTreeNodeWriter();
}
WALogin* WAConnection::getLogin() {
@@ -635,10 +635,10 @@ void WAConnection::sendMessage(FMessage* message) throw(WAException) { WAConnection::~WAConnection() {
- if (this->inputKey != NULL)
- delete this->inputKey;
- if (this->outputKey != NULL)
- delete this->outputKey;
+ delete this->inputKey;
+ delete this->outputKey;
+ delete this->in;
+ delete this->out;
std::map<string, IqResultHandler*>::iterator it;
for (it = this->pending_server_requests.begin(); it != this->pending_server_requests.end(); it++) {
delete it->second;
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp index af21776b83..f8bf6dc993 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp @@ -179,9 +179,9 @@ std::vector<unsigned char>* WALogin::getAuthBlob(const std::vector<unsigned char this->outputKey = new KeyStream(out, 20);
std::vector<unsigned char>* list = new std::vector<unsigned char>(0);
- for (int i = 0; i < 4; i++) {
+ for (int i = 0; i < 4; i++)
list->push_back(0);
- }
+
list->insert(list->end(), this->user.begin(), this->user.end());
list->insert(list->end(), nonce.begin(), nonce.end());
std::string strTime = Utilities::intToStr( time(NULL));
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WALogin.h b/protocols/WhatsApp/src/WhatsAPI++/WALogin.h index 600dc83112..868e806880 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WALogin.h +++ b/protocols/WhatsApp/src/WhatsAPI++/WALogin.h @@ -44,6 +44,8 @@ private: static const std::string NONCE_KEY;
KeyStream* outputKey;
WAConnection* connection;
+ BinTreeNodeReader* inn;
+ BinTreeNodeWriter* out;
std::vector<unsigned char>* getAuthBlob(const std::vector<unsigned char>& nonce);
void sendResponse(const std::vector<unsigned char>& challengeData);
@@ -63,8 +65,6 @@ public: bool supports_receipt_acks;
time_t expire_date;
int account_kind;
- BinTreeNodeReader* inn;
- BinTreeNodeWriter* out;
WALogin(WAConnection* connection, BinTreeNodeReader *reader, BinTreeNodeWriter *writer, const std::string& domain, const std::string& user, const std::string& resource, const std::string& password, const std::string& push_name);
std::vector<unsigned char>* login(const std::vector<unsigned char>& blobLength);
diff --git a/protocols/WhatsApp/src/connection.cpp b/protocols/WhatsApp/src/connection.cpp index edd04248df..d7cfd7c93e 100644 --- a/protocols/WhatsApp/src/connection.cpp +++ b/protocols/WhatsApp/src/connection.cpp @@ -144,23 +144,19 @@ void WhatsAppProto::stayConnectedLoop(void*) CODE_BLOCK_TRY
unsigned passLen;
ptrA passBin((char*)mir_base64_decode(pass.c_str(), &passLen));
- std::string password(passBin, passLen);
- BYTE UseSSL = getByte(WHATSAPP_KEY_SSL, 0);
- if (UseSSL) {
- this->conn = new WASocketConnection("c.whatsapp.net", 443);
-
- connection = new WAConnection(&this->connMutex, this, this);
- login = new WALogin(connection, new BinTreeNodeReader(connection, conn, WAConnection::dictionary, WAConnection::DICTIONARY_LEN),
- new BinTreeNodeWriter(connection, conn, WAConnection::dictionary, WAConnection::DICTIONARY_LEN, &writerMutex),
- "s.whatsapp.net", this->phoneNumber, std::string(ACCOUNT_RESOURCE) +"-443", password, nick);
- } else {
- this->conn = new WASocketConnection("c.whatsapp.net", 5222);
-
- connection = new WAConnection(&this->connMutex, this, this);
- login = new WALogin(connection, new BinTreeNodeReader(connection, conn, WAConnection::dictionary, WAConnection::DICTIONARY_LEN),
- new BinTreeNodeWriter(connection, conn, WAConnection::dictionary, WAConnection::DICTIONARY_LEN, &writerMutex),
- "s.whatsapp.net", this->phoneNumber, std::string(ACCOUNT_RESOURCE) +"-5222", password, nick);
- }
+ std::string password(passBin, passLen), resource = ACCOUNT_RESOURCE;
+ int portNumber;
+ if (getByte(WHATSAPP_KEY_SSL, 0))
+ portNumber = 443, resource += "-443";
+ else
+ portNumber = 5222, resource += "-5222";
+
+ this->conn = new WASocketConnection("c.whatsapp.net", portNumber);
+
+ connection = new WAConnection(&this->connMutex, this, this);
+ login = new WALogin(connection, new BinTreeNodeReader(connection, conn, WAConnection::dictionary, WAConnection::DICTIONARY_LEN),
+ new BinTreeNodeWriter(connection, conn, WAConnection::dictionary, WAConnection::DICTIONARY_LEN, &writerMutex),
+ "s.whatsapp.net", this->phoneNumber, resource, password, nick);
std::vector<unsigned char>* nextChallenge = login->login(*this->challenge);
delete this->challenge;
|