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
|
/*
Copyright (c) 2015-17 Miranda NG project (https://miranda-ng.org)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation version 2
of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _SKYPE_REQUEST_MESSAGES_H_
#define _SKYPE_REQUEST_MESSAGES_H_
class SendMessageRequest : public HttpRequest
{
public:
SendMessageRequest(const char *username, time_t timestamp, const char *message, LoginInfo &li, const char *MessageType = nullptr) :
HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/8:%s/messages", li.endpoint.szServer, username)
{
Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", li.endpoint.szToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
JSONNode node;
node
<< JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu", (ULONGLONG)timestamp))
<< JSONNode("messagetype", MessageType ? MessageType : "Text")
<< JSONNode("contenttype", "text")
<< JSONNode("content", message);
Body << VALUE(node.write().c_str());
}
};
class SendActionRequest : public HttpRequest
{
public:
SendActionRequest(const char *username, time_t timestamp, const char *message, LoginInfo &li) :
HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/8:%s/messages", li.endpoint.szServer, username)
{
Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", li.endpoint.szToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
CMStringA content;
content.AppendFormat("%s %s", li.szSkypename.c_str(), message);
JSONNode node;
node
<< JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu", (ULONGLONG)timestamp))
<< JSONNode("messagetype", "RichText")
<< JSONNode("contenttype", "text")
<< JSONNode("content", content)
<< JSONNode("skypeemoteoffset", li.szSkypename.GetLength() + 1);
Body << VALUE(node.write().c_str());
}
};
class SendTypingRequest : public HttpRequest
{
public:
SendTypingRequest(const char *username, int iState, LoginInfo &li) :
HttpRequest(REQUEST_POST, FORMAT, "%s/v1/users/ME/conversations/8:%s/messages", li.endpoint.szServer, ptrA(mir_urlEncode(username)))
{
Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", li.endpoint.szToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
const char *state = (iState == PROTOTYPE_SELFTYPING_ON) ? "Control/Typing" : "Control/ClearTyping";
JSONNode node;
node
<< JSONNode("clientmessageid", (long)time(NULL))
<< JSONNode("messagetype", state)
<< JSONNode("contenttype", "text")
<< JSONNode("content", "");
Body << VALUE(node.write().c_str());
}
};
class MarkMessageReadRequest : public HttpRequest
{
public:
MarkMessageReadRequest(const char *username, LONGLONG /*msgId*/, LONGLONG msgTimestamp, bool isChat, LoginInfo &li) :
HttpRequest(REQUEST_PUT, FORMAT, "%s/v1/users/ME/conversations/%d:%s/properties?name=consumptionhorizon", li.endpoint.szServer, !isChat ? 8 : 19, username)
{
Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
<< FORMAT_VALUE("RegistrationToken", "registrationToken=%s", li.endpoint.szToken)
<< CHAR_VALUE("Content-Type", "application/json; charset=UTF-8");
//"lastReadMessageTimestamp;modificationTime;lastReadMessageId"
JSONNode node(JSON_NODE);
node << JSONNode("consumptionhorizon", CMStringA(::FORMAT, "%lld000;%lld000;%lld000", msgTimestamp, time(NULL), msgTimestamp));
Body << VALUE(node.write().c_str());
}
};
#endif //_SKYPE_REQUEST_MESSAGES_H_
|