From dac1f42ef81ac1119430fd294a6b35b0b8cd6837 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 25 Jan 2015 17:45:10 +0000 Subject: - class KeyStream extracted to the separate module; - xml attributes redesigned to produce efficient code; - many small improvements git-svn-id: http://svn.miranda-ng.org/main/trunk@11905 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp | 37 +++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp') diff --git a/protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp b/protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp index c80e44c657..a684d1e3e3 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp @@ -5,10 +5,8 @@ * Author: Antonio */ -#include -#include -#include -#include "FMessage.h" +#include "../common.h" // #TODO Remove Miranda-dependency + #include "utilities.h" //SDL_mutex* FMessage::generating_lock = SDL_CreateMutex(); @@ -17,7 +15,8 @@ int FMessage::generating_id = 0; std::string FMessage::generating_header = Utilities::intToStr(static_cast (time(NULL))).append("-"); -FMessage::FMessage() { +FMessage::FMessage() +{ this->key = NULL; this->timestamp = 0; this->media_wa_type = 0; @@ -30,7 +29,8 @@ FMessage::FMessage() { this->data = ""; } -FMessage::FMessage(const std::string& remote_jid, bool from_me, const std::string& data) { +FMessage::FMessage(const std::string& remote_jid, bool from_me, const std::string& data) +{ Key* local_key; FMessage::generating_lock->lock(); FMessage::generating_id++; @@ -48,7 +48,8 @@ FMessage::FMessage(const std::string& remote_jid, bool from_me, const std::strin this->media_url = ""; } -std::string FMessage::nextKeyIdNumber() { +std::string FMessage::nextKeyIdNumber() +{ int id = 0; FMessage::generating_lock->lock(); id = (FMessage::generating_id++); @@ -56,7 +57,8 @@ std::string FMessage::nextKeyIdNumber() { return generating_header + (Utilities::intToStr(id)); } -FMessage::FMessage(Key* key) { +FMessage::FMessage(Key* key) +{ this->key = key; this->timestamp = 0; this->media_wa_type = 0; @@ -68,7 +70,8 @@ FMessage::FMessage(Key* key) { this->media_url = ""; } -std::string FMessage::getMessage_WA_Type_StrValue(unsigned char type) { +std::string FMessage::getMessage_WA_Type_StrValue(unsigned char type) +{ switch (type) { case FMessage::WA_TYPE_UNDEFINED: return ""; @@ -89,26 +92,30 @@ std::string FMessage::getMessage_WA_Type_StrValue(unsigned char type) { return ""; } -FMessage::~FMessage() { +FMessage::~FMessage() +{ if (this->key != NULL) delete key; } -Key::Key(const std::string& remote_jid, bool from_me, const std::string& id) { +Key::Key(const std::string& remote_jid, bool from_me, const std::string& id) +{ this->remote_jid = remote_jid; this->from_me = from_me; this->id = id; } -std::string Key::toString() { - return "Key[id=" + id + ", from_me=" + (from_me ? "true":"false") + ", remote_jid=" + remote_jid + "]"; +std::string Key::toString() +{ + return "Key[id=" + id + ", from_me=" + (from_me ? "true" : "false") + ", remote_jid=" + remote_jid + "]"; } -unsigned char FMessage::getMessage_WA_Type(const std::string& type) { +unsigned char FMessage::getMessage_WA_Type(const std::string& type) +{ if (type.empty()) return WA_TYPE_UNDEFINED; - + std::string typeLower = type; std::transform(typeLower.begin(), typeLower.end(), typeLower.begin(), ::tolower); if (typeLower.compare("system") == 0) -- cgit v1.2.3