-
Notifications
You must be signed in to change notification settings - Fork 211
/
message.h
158 lines (120 loc) · 4.96 KB
/
message.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#ifndef __MESSAGE__H__
#define __MESSAGE__H__
#include <string>
#include <vector>
#include "AxolotlMessages.pb.h"
#define CHAT_MESSAGE 0
#define IMAGE_MESSAGE 1
#define LOCAT_MESSAGE 2
#define SOUND_MESSAGE 3
#define VIDEO_MESSAGE 4
#define CALL_MESSAGE 5
#define VCARD_MESSAGE 6
class WhatsappConnection;
class DataBuffer;
class Tree;
class Message {
public:
Message(const WhatsappConnection * wc, const std::string from, const unsigned long long time, const std::string id, const std::string author);
virtual ~ Message() {}
std::string from, server, author;
unsigned long long t;
std::string id;
WhatsappConnection *wc;
int retries;
bool axolotl;
virtual DataBuffer serialize() const = 0;
virtual int type() const = 0;
virtual Message *copy() const = 0;
};
class ChatMessage: public Message {
public:
ChatMessage(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string message, const std::string author);
int type() const { return CHAT_MESSAGE; }
std::string message; /* Message */
std::string ctype;
std::string msg_body;
DataBuffer serialize() const;
Message *copy() const;
std::string getProtoBuf() const;
static ChatMessage parseProtobuf(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string author, const std::string & buf);
};
class CipheredChatMessage: public ChatMessage {
public:
CipheredChatMessage(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string message, const std::string author, const std::string ctype);
};
class VCardMessage: public Message {
public:
VCardMessage(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string name, const std::string author, const std::string vcard);
int type() const { return VCARD_MESSAGE; }
std::string name, vcard;
DataBuffer serialize() const;
Message *copy() const;
};
class CallMessage: public Message {
public:
CallMessage(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id);
int type() const { return CALL_MESSAGE; }
DataBuffer serialize() const;
Message *copy() const;
};
class MediaMessage: public Message {
public:
MediaMessage(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string author, const std::string url, const std::string caption,
const std::string ip, const std::string hash, const std::string filetype);
std::string url, caption, hash, filetype, ip;
};
class ImageMessage: public MediaMessage {
public:
ImageMessage(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string author, const std::string url, const std::string caption, const std::string ip,
const unsigned int width, const unsigned int height, const unsigned int size, const std::string encoding,
const std::string hash, const std::string filetype, const std::string preview);
int type() const { return IMAGE_MESSAGE; }
DataBuffer serialize() const;
Message *copy() const;
std::string encoding;
std::string preview;
unsigned int width, height, size;
std::string e2e_key, e2e_iv, e2e_aeskey;
static ImageMessage parseProtobuf(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string author, const std::string & buf);
};
class SoundMessage: public MediaMessage {
public:
SoundMessage(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string author, const std::string url, const std::string caption,
const std::string hash, const std::string filetype);
int type() const { return SOUND_MESSAGE; }
Message *copy() const;
DataBuffer serialize() const;
};
class VideoMessage:public MediaMessage {
public:
VideoMessage(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string author, const std::string url, const std::string caption,
const std::string hash, const std::string filetype);
int type() const { return VIDEO_MESSAGE; }
Message *copy() const;
DataBuffer serialize() const;
};
class LocationMessage: public Message {
public:
LocationMessage(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string author, double lat, double lng, const std::string name,
std::string preview);
int type() const { return LOCAT_MESSAGE; }
Message *copy() const;
DataBuffer serialize() const;
double latitude, longitude; /* Location */
std::string name, preview;
static LocationMessage parseProtobuf(const WhatsappConnection * wc, const std::string from, const unsigned long long time,
const std::string id, const std::string author, const std::string & buf);
};
#endif