diff options
author | George Hazan <george.hazan@gmail.com> | 2013-06-24 12:29:37 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-06-24 12:29:37 +0000 |
commit | dc2a9c66749ef4c8c6a748218bf80b80d0bbe0d6 (patch) | |
tree | 4d854eda13f45812127bb1773730355c26dff417 /protocols/WhatsApp/src/WhatsAPI++ | |
parent | 852df1e2fd8a0e220065b0eb1443b3e834101531 (diff) |
- custom base64 encoder removed;
- warning fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@5117 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp | 3 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp | 2 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp | 3 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp | 1 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp | 1 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp | 20 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WAConnection.h | 6 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp | 1 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/base64.cpp | 102 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/base64.h | 16 | ||||
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/utilities.cpp | 2 |
11 files changed, 24 insertions, 133 deletions
diff --git a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp index 6a09feee64..0cb8dd512b 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeReader.cpp @@ -4,11 +4,12 @@ * Created on: 26/06/2012
* Author: Antonio
*/
+
+#include "../common.h"
#include "BinTreeNodeReader.h"
#include "WAException.h"
#include "ProtocolTreeNode.h"
#include "utilities.h"
-#include <string>
BinTreeNodeReader::BinTreeNodeReader(WAConnection* conn, ISocketConnection* connection, const char** dictionary, const int dictionarysize) {
this->conn = conn;
diff --git a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp index e2d38cf891..d50a4a91e5 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp @@ -4,6 +4,8 @@ * Created on: 26/06/2012
* Author: Antonio
*/
+
+#include "../common.h"
#include "BinTreeNodeWriter.h"
#include <cstring>
#include "utilities.h"
diff --git a/protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp b/protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp index f379a2061a..5c7d16042e 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/ByteArray.cpp @@ -5,6 +5,7 @@ * Author: Antonio
*/
+#include "../common.h"
#include "ByteArray.h"
#include "WAException.h"
#include <iostream>
@@ -116,7 +117,7 @@ int ByteArrayInputStream::read(std::vector<unsigned char>& b, size_t off, size_ }
} catch (std::exception& ) {
}
- return i;
+ return (int)i;
}
ByteArrayInputStream::~ByteArrayInputStream() {
diff --git a/protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp b/protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp index b8586eb538..03015e8e11 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/FMessage.cpp @@ -5,6 +5,7 @@ * Author: Antonio
*/
+#include "../common.h"
#include <ctime>
#include <stdlib.h>
#include <algorithm>
diff --git a/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp b/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp index be6a658acb..c3c75cbd3e 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp @@ -5,6 +5,7 @@ * Author: Antonio
*/
+#include "../common.h"
#include "WAException.h"
#include "ProtocolTreeNode.h"
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp index 0e6fa62c74..d1b4bf6a80 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.cpp @@ -5,12 +5,12 @@ * Author: Antonio
*/
+#include "../common.h"
#include "WAConnection.h"
#include "ProtocolTreeNode.h"
#include <map>
#include <vector>
#include "utilities.h"
-#include "base64.h"
const char* WAConnection::dictionary[] = {
"",
@@ -566,11 +566,11 @@ void WAConnection::sendMessageWithMedia(FMessage* message) throw (WAException) } else {
if (message->media_wa_type != FMessage::WA_TYPE_CONTACT && !message->media_name.empty() && !message->media_url.empty() && message->media_size > 0L) {
(*attribs)["file"] = message->media_name;
- (*attribs)["size"] = Utilities::intToStr(message->media_size);
+ (*attribs)["size"] = Utilities::intToStr((int)message->media_size);
(*attribs)["url"] = message->media_url;
} else {
(*attribs)["file"] = message->media_name;
- (*attribs)["size"] = Utilities::intToStr(message->media_size);
+ (*attribs)["size"] = Utilities::intToStr((int)message->media_size);
(*attribs)["url"] = message->media_url;
(*attribs)["seconds"] = Utilities::intToStr(message->media_duration_seconds);
}
@@ -986,11 +986,11 @@ std::vector<ProtocolTreeNode*>* WAConnection::processGroupSettings(const std::ve std::vector<ProtocolTreeNode*>* result = new std::vector<ProtocolTreeNode*>(groups.size());
if (!groups.empty()) {
time_t now = time(NULL);
- for (int i = 0; i < groups.size(); i++) {
+ for (size_t i = 0; i < groups.size(); i++) {
std::map<string, string>* attribs = new std::map<string, string>();
(*attribs)["jid"] = groups[i].jid;
(*attribs)["notify"] = (groups[i].enabled? "1": "0");
- (*attribs)["mute"] = Utilities::intToStr(groups[i].muteExpiry > now? (groups[i].muteExpiry - now): 0);
+ (*attribs)["mute"] = Utilities::intToStr( int(groups[i].muteExpiry > now ? (groups[i].muteExpiry - now) : 0));
_LOGDATA("mute group %s, %s", (*attribs)["jid"].c_str(), (*attribs)["mute"].c_str());
(*result)[i] = new ProtocolTreeNode("item", attribs);
@@ -1156,7 +1156,7 @@ void WAConnection::parseMessageInitialTagAlreadyChecked(ProtocolTreeNode* messag data = childNode->getDataAsString();
} else {
_LOGDATA("Media data encoding type '%s'", (encoding == NULL? "text":encoding->c_str()));
- data = (childNode->data == NULL? NULL : new std::string(base64_encode(childNode->data->data(), childNode->data->size())));
+ data = (childNode->data == NULL? NULL : new std::string(mir_base64_encode((BYTE*)childNode->data->data(), (unsigned)childNode->data->size())));
}
fmessage->data = (data == NULL? "": *data);
if (data != NULL)
@@ -1228,14 +1228,14 @@ void WAConnection::parseMessageInitialTagAlreadyChecked(ProtocolTreeNode* messag bool flag = false;
std::vector<ProtocolTreeNode*> myVector(0);
std::vector<ProtocolTreeNode*>* children = messageNode->children == NULL? &myVector: messageNode->getAllChildren();
- for (int i = 0; i < children->size(); i++) {
+ for (size_t i = 0; i < children->size(); i++) {
ProtocolTreeNode* child = (*children)[i];
if (ProtocolTreeNode::tagEquals(child, "notification")) {
std::string* type = child->getAttributeValue("type");
if ((type != NULL) && (type->compare("picture") == 0) && (this->event_handler != NULL)) {
std::vector<ProtocolTreeNode*> myVector2(0);
std::vector<ProtocolTreeNode*>* children2 = child->children == NULL? &myVector2: child->getAllChildren();
- for (int j = 0; j < children2->size(); j++) {
+ for (unsigned j = 0; j < children2->size(); j++) {
ProtocolTreeNode* child2 = (*children2)[j];
if (ProtocolTreeNode::tagEquals(child2, "set")) {
std::string* id = child2->getAttributeValue("id");
@@ -1544,7 +1544,7 @@ void WAConnection::sendRemoveParticipants(const std::string& gjid, const std::ve void WAConnection::sendVerbParticipants(const std::string& gjid, const std::vector<std::string>& participants, const std::string& id, const std::string& inner_tag) throw (WAException) {
size_t size = participants.size();
std::vector<ProtocolTreeNode*>* children = new std::vector<ProtocolTreeNode*>(size);
- for (int i = 0; i < size; i++) {
+ for (size_t i = 0; i < size; i++) {
std::map<string, string>* attribs1 = new std::map<string, string>();
(*attribs1)["jid"] = participants[i];
(*children)[i] = new ProtocolTreeNode("participant", attribs1);
@@ -1645,7 +1645,7 @@ void WAConnection::sendGetPictureIds(const std::vector<std::string>& jids) throw this->pending_server_requests[id] = new IqResultGetPictureIdsHandler(this);
std::vector<ProtocolTreeNode*>* children = new std::vector<ProtocolTreeNode*>();
- for (int i = 0; i < jids.size(); i++) {
+ for (size_t i = 0; i < jids.size(); i++) {
std::map<string, string>* attribs = new std::map<string, string>();
(*attribs)["jid"] = jids[i];
ProtocolTreeNode* child = new ProtocolTreeNode("user", attribs);
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h index 286a0eacca..9ee5d3e48f 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h +++ b/protocols/WhatsApp/src/WhatsAPI++/WAConnection.h @@ -38,7 +38,7 @@ public: virtual void onClientConfigReceived(const std::string& paramString)=0;
virtual void onLastSeen(const std::string& paramString1, int paramInt, std::string* paramString2)=0;
virtual void onIsTyping(const std::string& paramString, bool paramBoolean)=0;
- virtual void onAccountChange(int paramInt, long paramLong)=0;
+ virtual void onAccountChange(int paramInt, time_t paramLong)=0;
virtual void onPrivacyBlockListAdd(const std::string& paramString)=0;
virtual void onPrivacyBlockListClear()=0;
virtual void onDirty(const std::map<string,string>& paramHashtable)=0;
@@ -269,7 +269,7 @@ class WAConnection { if ((attributeValue != NULL) && (attributeValue->compare("result") == 0) && (this->con->event_handler != NULL)) {
std::vector<ProtocolTreeNode*>* children = node->getAllChildren("picture");
- for (int i = 0; i < children->size(); i++) {
+ for (size_t i = 0; i < children->size(); i++) {
ProtocolTreeNode* current = (*children)[i];
std::string* id = current->getAttributeValue("id");
if ((id != NULL) && (current->data != NULL) && (current->data->size() > 0)) {
@@ -317,7 +317,7 @@ class WAConnection { ProtocolTreeNode* groupNode = node->getChild("list");
std::vector<ProtocolTreeNode*>* children = groupNode->getAllChildren("user");
std::map<std::string, std::string> ids;
- for (int i = 0; i < children->size(); i++) {
+ for (size_t i = 0; i < children->size(); i++) {
std::string* jid = (*children)[i]->getAttributeValue("jid");
std::string* id = (*children)[i]->getAttributeValue("id");
if (jid != NULL) {
diff --git a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp index 37d5fe0378..0a351300a9 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/WALogin.cpp @@ -5,6 +5,7 @@ * Author: Antonio
*/
+#include "../common.h"
#include "WALogin.h"
#include "ByteArray.h"
//#include "ApplicationData.h"
diff --git a/protocols/WhatsApp/src/WhatsAPI++/base64.cpp b/protocols/WhatsApp/src/WhatsAPI++/base64.cpp deleted file mode 100644 index 03c4c827d4..0000000000 --- a/protocols/WhatsApp/src/WhatsAPI++/base64.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/*
- * Base64.cpp
- *
- * Created on: 26/06/2012
- * Author: Antonio
- */
-#include "base64.h"
-#include <iostream>
-
-static const std::string base64_chars =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "abcdefghijklmnopqrstuvwxyz"
- "0123456789+/";
-
-
-static inline bool is_base64(unsigned char c) {
- return (isalnum(c) || (c == '+') || (c == '/'));
-}
-
-std::string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len) {
- std::string ret;
- int i = 0;
- int j = 0;
- unsigned char char_array_3[3];
- unsigned char char_array_4[4];
-
- while (in_len--) {
- char_array_3[i++] = *(bytes_to_encode++);
- if (i == 3) {
- char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
- char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
- char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
- char_array_4[3] = char_array_3[2] & 0x3f;
-
- for(i = 0; (i <4) ; i++)
- ret += base64_chars[char_array_4[i]];
- i = 0;
- }
- }
-
- if (i)
- {
- for(j = i; j < 3; j++)
- char_array_3[j] = '\0';
-
- char_array_4[0] = (char_array_3[0] & 0xfc) >> 2;
- char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4);
- char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6);
- char_array_4[3] = char_array_3[2] & 0x3f;
-
- for (j = 0; (j < i + 1); j++)
- ret += base64_chars[char_array_4[j]];
-
- while((i++ < 3))
- ret += '=';
-
- }
-
- return ret;
-
-}
-
-std::string base64_decode(std::string const& encoded_string) {
- int in_len = encoded_string.size();
- int i = 0;
- int j = 0;
- int in_ = 0;
- unsigned char char_array_4[4], char_array_3[3];
- std::string ret;
-
- while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
- char_array_4[i++] = encoded_string[in_]; in_++;
- if (i ==4) {
- for (i = 0; i <4; i++)
- char_array_4[i] = base64_chars.find(char_array_4[i]);
-
- char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
- char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
- char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
-
- for (i = 0; (i < 3); i++)
- ret += char_array_3[i];
- i = 0;
- }
- }
-
- if (i) {
- for (j = i; j <4; j++)
- char_array_4[j] = 0;
-
- for (j = 0; j <4; j++)
- char_array_4[j] = base64_chars.find(char_array_4[j]);
-
- char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
- char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
- char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
-
- for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
- }
-
- return ret;
-}
diff --git a/protocols/WhatsApp/src/WhatsAPI++/base64.h b/protocols/WhatsApp/src/WhatsAPI++/base64.h deleted file mode 100644 index 2ece162b89..0000000000 --- a/protocols/WhatsApp/src/WhatsAPI++/base64.h +++ /dev/null @@ -1,16 +0,0 @@ -/*
- * Base64.h
- *
- * Created on: 26/06/2012
- * Author: Antonio
- */
-
-#ifndef BASE64_H_
-#define BASE64_H_
-
-#include <string>
-
-std::string base64_encode(unsigned char const* , unsigned int len);
-std::string base64_decode(std::string const& s);
-
-#endif /* BASE64_H_ */
diff --git a/protocols/WhatsApp/src/WhatsAPI++/utilities.cpp b/protocols/WhatsApp/src/WhatsAPI++/utilities.cpp index 90d03dbdaa..ca87822a74 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/utilities.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/utilities.cpp @@ -1,3 +1,5 @@ +
+#include "../common.h"
#include "utilities.h"
//#include "ApplicationData.h"
#include <iostream>
|