diff options
author | George Hazan <george.hazan@gmail.com> | 2015-01-25 19:54:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-01-25 19:54:43 +0000 |
commit | 58ac4567a402d383c3edb0749b9f2fb88b8422d6 (patch) | |
tree | 224f909ab2abea950795d88b15b8b8a9e486551b /protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | |
parent | dac1f42ef81ac1119430fd294a6b35b0b8cd6837 (diff) |
less pointers, less memory problems
git-svn-id: http://svn.miranda-ng.org/main/trunk@11906 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 64 |
1 files changed, 39 insertions, 25 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp index 83310b4ac2..48300ad530 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp @@ -36,6 +36,34 @@ const char* WAConnection::dictionary[] = { const int WAConnection::DICTIONARY_LEN = _countof(WAConnection::dictionary);
+const char* WAConnection::extended_dict[] = { + "mpeg4", "wmv", "audio/3gpp", "audio/aac", "audio/amr", "audio/mp4", "audio/mpeg", "audio/ogg", "audio/qcelp", "audio/wav", + "audio/webm", "audio/x-caf", "audio/x-ms-wma", "image/gif", "image/jpeg", "image/png", "video/3gpp", "video/avi", "video/mp4", + "video/mpeg", "video/quicktime", "video/x-flv", "video/x-ms-asf", "302", "400", "401", "402", "403", "404", "405", "406", "407", + "409", "410", "500", "501", "503", "504", "abitrate", "acodec", "app_uptime", "asampfmt", "asampfreq", "audio", "clear", "conflict", + "conn_no_nna", "cost", "currency", "duration", "extend", "file", "fps", "g_notify", "g_sound", "gcm", "gone", "google_play", "hash", + "height", "invalid", "jid-malformed", "latitude", "lc", "lg", "live", "location", "log", "longitude", "max_groups", "max_participants", + "max_subject", "mimetype", "mode", "napi_version", "normalize", "orighash", "origin", "passive", "password", "played", + "policy-violation", "pop_mean_time", "pop_plus_minus", "price", "pricing", "redeem", "Replaced by new connection", "resume", + "signature", "size", "sound", "source", "system-shutdown", "username", "vbitrate", "vcard", "vcodec", "video", "width", + "xml-not-well-formed", "checkmarks", "image_max_edge", "image_max_kbytes", "image_quality", "ka", "ka_grow", "ka_shrink", "newmedia", + "library", "caption", "forward", "c0", "c1", "c2", "c3", "clock_skew", "cts", "k0", "k1", "login_rtt", "m_id", "nna_msg_rtt", + "nna_no_off_count", "nna_offline_ratio", "nna_push_rtt", "no_nna_con_count", "off_msg_rtt", "on_msg_rtt", "stat_name", "sts", + "suspect_conn", "lists", "self", "qr", "web", "w:b", "recipient", "w:stats", "forbidden", "aurora.m4r", "bamboo.m4r", "chord.m4r", + "circles.m4r", "complete.m4r", "hello.m4r", "input.m4r", "keys.m4r", "note.m4r", "popcorn.m4r", "pulse.m4r", "synth.m4r", "filehash", + "max_list_recipients", "en-AU", "en-GB", "es-MX", "pt-PT", "zh-Hans", "zh-Hant", "relayelection", "relaylatency", "interruption", + "Apex.m4r", "Beacon.m4r", "Bulletin.m4r", "By The Seaside.m4r", "Chimes.m4r", "Circuit.m4r", "Constellation.m4r", "Cosmic.m4r", + "Crystals.m4r", "Hillside.m4r", "Illuminate.m4r", "Night Owl.m4r", "Opening.m4r", "Playtime.m4r", "Presto.m4r", "Radar.m4r", + "Radiate.m4r", "Ripples.m4r", "Sencha.m4r", "Signal.m4r", "Silk.m4r", "Slow Rise.m4r", "Stargaze.m4r", "Summit.m4r", "Twinkle.m4r", + "Uplift.m4r", "Waves.m4r", "voip", "eligible", "upgrade", "planned", "current", "future", "disable", "expire", "start", "stop", + "accuracy", "speed", "bearing", "recording", "encrypt", "key", "identity", "w:gp2", "admin", "locked", "unlocked", "new", "battery", + "archive", "adm", "plaintext_size", "compressed_size", "delivered", "msg", "pkmsg", "everyone", "v", "transport", "call-id" +}; +
+const int WAConnection::EXTDICTIONARY_LEN = _countof(WAConnection::extended_dict);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
WAConnection::WAConnection(IMutex* mutex, WAListener* event_handler, WAGroupListener* group_event_handler)
{
this->init(event_handler, group_event_handler, mutex);
@@ -43,8 +71,6 @@ WAConnection::WAConnection(IMutex* mutex, WAListener* event_handler, WAGroupList WAConnection::~WAConnection()
{
- delete this->inputKey;
- delete this->outputKey;
delete this->in;
delete this->out;
std::map<string, IqResultHandler*>::iterator it;
@@ -54,18 +80,15 @@ WAConnection::~WAConnection() void WAConnection::init(WAListener* event_handler, WAGroupListener* group_event_handler, IMutex* mutex)
{
- this->login = NULL;
this->event_handler = event_handler;
this->group_event_handler = group_event_handler;
- this->inputKey = NULL;
- this->outputKey = NULL;
this->in = NULL;
this->out = NULL;
this->msg_id = 0;
- this->state = 0; // 0 disconnected 1 connecting 2 connected
this->retry = true;
+ this->supports_receipt_acks = false;
this->iqid = 0;
this->verbose = true;
this->lastTreeRead = 0;
@@ -76,27 +99,18 @@ void WAConnection::init(WAListener* event_handler, WAGroupListener* group_event_ void WAConnection::setLogin(WALogin* login)
{
- this->login = login;
-
- if (login->expire_date != 0L) {
+ if (login->expire_date != 0L)
this->expire_date = login->expire_date;
- }
- if (login->account_kind != -1) {
+
+ if (login->account_kind != -1)
this->account_kind = login->account_kind;
- }
- this->jid = this->login->user + "@" + this->login->domain;
- this->fromm = this->login->user + "@" + this->login->domain + "/" + this->login->resource;
+ this->jid = user + "@" + domain;
this->in = login->getTreeNodeReader();
this->out = login->getTreeNodeWriter();
}
-WALogin* WAConnection::getLogin()
-{
- return this->login;
-}
-
void WAConnection::sendMessageWithMedia(FMessage* message) throw (WAException)
{
_LOGDATA("Send message with media %s %d", message->media_name.c_str(), message->media_size);
@@ -177,7 +191,7 @@ void WAConnection::setVerboseId(bool b) void WAConnection::sendAvailableForChat() throw(WAException)
{
- this->out->write(ProtocolTreeNode("presence") << XATTR("name", this->login->push_name));
+ this->out->write(ProtocolTreeNode("presence") << XATTR("name", this->nick));
}
bool WAConnection::read() throw(WAException)
@@ -213,7 +227,7 @@ bool WAConnection::read() throw(WAException) delete it->second;
this->pending_server_requests.erase(id);
}
- else if (id.compare(0, this->login->user.size(), this->login->user) == 0) {
+ else if (id.compare(0, this->user.size(), this->user) == 0) {
ProtocolTreeNode* accountNode = node->getChild(0);
ProtocolTreeNode::require(accountNode, "account");
const string &kind = accountNode->getAttributeValue("kind");
@@ -328,7 +342,7 @@ void WAConnection::sendPing() throw(WAException) void WAConnection::sendPong(const std::string& id) throw(WAException)
{
this->out->write(ProtocolTreeNode("iq")
- << XATTR("type", "result") << XATTR("to", this->login->domain) << XATTR("id", id));
+ << XATTR("type", "result") << XATTR("to", this->domain) << XATTR("id", id));
}
void WAConnection::sendComposing(const std::string& to) throw(WAException)
@@ -400,7 +414,7 @@ void WAConnection::sendClientConfig(const std::string& sound, const std::string& this->pending_server_requests[id] = new IqSendClientConfigHandler(this);
this->out->write(ProtocolTreeNode("iq", configNode)
- << XATTR("id", id) << XATTR("type", "set") << XATTR("to", this->login->domain));
+ << XATTR("id", id) << XATTR("type", "set") << XATTR("to", this->domain));
}
void WAConnection::sendClientConfig(const std::string& pushID, bool preview, const std::string& platform, bool defaultSettings, bool groupSettings, const std::vector<GroupSetting>& groups) throw(WAException)
@@ -411,7 +425,7 @@ void WAConnection::sendClientConfig(const std::string& pushID, bool preview, con << XATTR("default", defaultSettings ? "1" : "0") << XATTR("groups", groupSettings ? "1" : "0");
std::string id = makeId("config_");
- this->out->write(ProtocolTreeNode("iq", configNode) << XATTR("id", id) << XATTR("type", "set") << XATTR("to", this->login->domain));
+ this->out->write(ProtocolTreeNode("iq", configNode) << XATTR("id", id) << XATTR("type", "set") << XATTR("to", this->domain));
}
std::vector<ProtocolTreeNode*>* WAConnection::processGroupSettings(const std::vector<GroupSetting>& groups)
@@ -658,7 +672,7 @@ void WAConnection::parseMessageInitialTagAlreadyChecked(ProtocolTreeNode* messag bool WAConnection::supportsReceiptAcks()
{
- return (this->login != NULL) && (this->login->supports_receipt_acks);
+ return supports_receipt_acks;
}
void WAConnection::sendNotificationReceived(const std::string& jid, const std::string& id) throw(WAException)
|