summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-01-25 22:07:28 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-01-25 22:07:28 +0000
commit97ba0b94c5da04f0d03945baa21c338c77c9dc20 (patch)
tree55d1b4c131a616b8c660128c70418df95de99b90 /protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp
parent4b9da6b7ea643ac4917440880583d507b697cf9a (diff)
- correct writing of tokens, especially extended
- further code optimizations git-svn-id: http://svn.miranda-ng.org/main/trunk@11911 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp')
-rw-r--r--protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp
index a4f79baf17..227857a522 100644
--- a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp
+++ b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp
@@ -17,11 +17,6 @@ BinTreeNodeWriter::BinTreeNodeWriter(WAConnection* conn, ISocketConnection* conn
this->conn = conn;
this->out = new ByteArrayOutputStream(2048);
this->realOut = connection;
- for (int i = 0; i < WAConnection::DICTIONARY_LEN; i++) {
- std::string token(WAConnection::dictionary[i]);
- if (token.compare("") != 0)
- this->tokenMap[token] = i;
- }
this->dataBegin = 0;
}
@@ -135,9 +130,9 @@ void BinTreeNodeWriter::writeAttributes(std::map<string, string>* attributes)
void BinTreeNodeWriter::writeString(const std::string& tag)
{
- std::map<string, int>::iterator it = this->tokenMap.find(tag);
- if (it != this->tokenMap.end())
- writeToken(it->second);
+ int token = WAConnection::tokenLookup(tag);
+ if (token != -1)
+ writeToken(token);
else {
size_t atIndex = tag.find('@');
if (atIndex == 0 || atIndex == string::npos)
@@ -164,12 +159,11 @@ void BinTreeNodeWriter::writeJid(std::string* user, const std::string& server)
void BinTreeNodeWriter::writeToken(int intValue)
{
- if (intValue < 245)
- this->out->write(intValue);
- else if (intValue <= 500) {
- this->out->write(254);
- this->out->write(intValue - 245);
+ if (intValue & 0x100) {
+ this->out->write(236);
+ this->out->write(intValue & 0xFF);
}
+ else this->out->write(intValue);
}
void BinTreeNodeWriter::writeBytes(unsigned char* bytes, int length)