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
|
/*
Copyright (c) 2015-20 Miranda NG team (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_CONTACTS_H_
#define _SKYPE_REQUEST_CONTACTS_H_
struct GetContactListRequest : public AsyncHttpRequest
{
GetContactListRequest(CSkypeProto *ppro, const char *filter) :
AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, 0, &CSkypeProto::LoadContactList)
{
m_szUrl.AppendFormat("/contacts/v1/users/%s/contacts", ppro->m_szSkypename.MakeLower().GetBuffer());
// ?filter=contacts[?(@.type="skype" or @.type="msn")]
if (filter != NULL)
this << CHAR_PARAM("filter", filter);
AddHeader("X-SkypeToken", ppro->m_szApiToken);
}
};
struct GetContactsAuthRequest : public AsyncHttpRequest
{
GetContactsAuthRequest() :
AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, "/contacts/v2/users/SELF/invites", &CSkypeProto::LoadContactsAuth)
{
AddHeader("Accept", "application/json");
}
};
struct AddContactRequest : public AsyncHttpRequest
{
AddContactRequest(const char *who, const char *greeting = "") :
AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS, "/contacts/v2/users/SELF/contacts")
{
AddHeader("Accept", "application/json");
JSONNode node;
node << CHAR_PARAM("mri", CMStringA(::FORMAT, "8:", who).GetString()) << CHAR_PARAM("greeting", greeting);
m_szParam = node.write().c_str();
}
};
struct DeleteContactRequest : public AsyncHttpRequest
{
DeleteContactRequest(const char *who) :
AsyncHttpRequest(REQUEST_DELETE, HOST_CONTACTS)
{
m_szUrl.AppendFormat("/contacts/v2/users/SELF/contacts/8:%s", who);
AddHeader("Accept", "application/json");
}
};
struct AuthAcceptRequest : public AsyncHttpRequest
{
AuthAcceptRequest(const char *who) :
AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS)
{
m_szUrl.AppendFormat("/contacts/v2/users/SELF/invites/8:%s/accept", who);
AddHeader("Accept", "application/json");
}
};
struct AuthDeclineRequest : public AsyncHttpRequest
{
AuthDeclineRequest(const char *who) :
AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS)
{
m_szUrl.AppendFormat("/contacts/v2/users/SELF/invites/8:%s/decline", who);
AddHeader("Accept", "application/json");
}
};
struct BlockContactRequest : public AsyncHttpRequest
{
BlockContactRequest(CSkypeProto *ppro, MCONTACT hContact) :
AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS, 0, &CSkypeProto::OnBlockContact)
{
m_szUrl.AppendFormat("/contacts/v2/users/SELF/contacts/blocklist/8:%s", ppro->getId(hContact).c_str());
m_szParam = "{\"report_abuse\":\"false\",\"ui_version\":\"skype.com\"}";
pUserInfo = (void *)hContact;
AddHeader("Accept", "application/json");
}
};
struct UnblockContactRequest : public AsyncHttpRequest
{
UnblockContactRequest(CSkypeProto *ppro, MCONTACT hContact) :
AsyncHttpRequest(REQUEST_DELETE, HOST_CONTACTS, 0, &CSkypeProto::OnUnblockContact)
{
m_szUrl.AppendFormat("/contacts/v2/users/SELF/contacts/blocklist/8:%s", ppro->getId(hContact).c_str());
pUserInfo = (void *)hContact;
AddHeader("Accept", "application/json");
// TODO: user ip address
this << CHAR_PARAM("reporterIp", "123.123.123.123") << CHAR_PARAM("uiVersion", g_szMirVer);
}
};
#endif //_SKYPE_REQUEST_CONTACTS_H_
|