diff options
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp | 37 |
1 files changed, 22 insertions, 15 deletions
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 <ctime>
-#include <stdlib.h>
-#include <algorithm>
-#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<int> (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)
|