summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-05-28 15:14:10 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-05-28 15:14:10 +0300
commit373e78401f7ab116bc0c1787da125d5e46c901d5 (patch)
tree06b4ac8092c42ea5f3d039fe641fe43a895fb5c7 /protocols/SkypeWeb
parent3f8d2fd0b0022c11e30ab47046013b0c58030d47 (diff)
SkypeWeb: further shit cleaning
Diffstat (limited to 'protocols/SkypeWeb')
-rw-r--r--protocols/SkypeWeb/SkypeWeb.vcxproj2
-rw-r--r--protocols/SkypeWeb/SkypeWeb.vcxproj.filters6
-rw-r--r--protocols/SkypeWeb/src/main.cpp3
-rw-r--r--protocols/SkypeWeb/src/request_queue.cpp62
-rw-r--r--protocols/SkypeWeb/src/requests/avatars.h7
-rw-r--r--protocols/SkypeWeb/src/requests/capabilities.h29
-rw-r--r--protocols/SkypeWeb/src/requests/chatrooms.h104
-rw-r--r--protocols/SkypeWeb/src/requests/contacts.h56
-rw-r--r--protocols/SkypeWeb/src/requests/endpoint.h11
-rw-r--r--protocols/SkypeWeb/src/requests/files.h10
-rw-r--r--protocols/SkypeWeb/src/requests/history.h33
-rw-r--r--protocols/SkypeWeb/src/requests/login.h2
-rw-r--r--protocols/SkypeWeb/src/requests/messages.h63
-rw-r--r--protocols/SkypeWeb/src/requests/oauth.h9
-rw-r--r--protocols/SkypeWeb/src/requests/poll.h6
-rw-r--r--protocols/SkypeWeb/src/requests/profile.h5
-rw-r--r--protocols/SkypeWeb/src/requests/search.h5
-rw-r--r--protocols/SkypeWeb/src/requests/status.h30
-rw-r--r--protocols/SkypeWeb/src/requests/subscriptions.h38
-rw-r--r--protocols/SkypeWeb/src/requests/trouter.h146
-rw-r--r--protocols/SkypeWeb/src/skype_chatrooms.cpp24
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp8
-rw-r--r--protocols/SkypeWeb/src/skype_db.cpp20
-rw-r--r--protocols/SkypeWeb/src/skype_files.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_history_sync.cpp15
-rw-r--r--protocols/SkypeWeb/src/skype_login.cpp13
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_network.cpp11
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp26
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h44
-rw-r--r--protocols/SkypeWeb/src/skype_search.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp202
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.h21
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp50
-rw-r--r--protocols/SkypeWeb/src/stdafx.h47
35 files changed, 296 insertions, 820 deletions
diff --git a/protocols/SkypeWeb/SkypeWeb.vcxproj b/protocols/SkypeWeb/SkypeWeb.vcxproj
index f808a99e7e..3336bacc18 100644
--- a/protocols/SkypeWeb/SkypeWeb.vcxproj
+++ b/protocols/SkypeWeb/SkypeWeb.vcxproj
@@ -69,14 +69,12 @@
<ClInclude Include="src\requests\search.h" />
<ClInclude Include="src\requests\status.h" />
<ClInclude Include="src\requests\subscriptions.h" />
- <ClInclude Include="src\requests\trouter.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\skype_db.h" />
<ClInclude Include="src\skype_dialogs.h" />
<ClInclude Include="src\skype_menus.h" />
<ClInclude Include="src\skype_options.h" />
<ClInclude Include="src\skype_proto.h" />
- <ClInclude Include="src\skype_trouter.h" />
<ClInclude Include="src\skype_utils.h" />
<ClInclude Include="src\stdafx.h" />
<ClInclude Include="src\version.h" />
diff --git a/protocols/SkypeWeb/SkypeWeb.vcxproj.filters b/protocols/SkypeWeb/SkypeWeb.vcxproj.filters
index 21d335e5c5..2d8403bc77 100644
--- a/protocols/SkypeWeb/SkypeWeb.vcxproj.filters
+++ b/protocols/SkypeWeb/SkypeWeb.vcxproj.filters
@@ -132,9 +132,6 @@
<ClInclude Include="src\requests\subscriptions.h">
<Filter>Header Files\Requests</Filter>
</ClInclude>
- <ClInclude Include="src\requests\trouter.h">
- <Filter>Header Files\Requests</Filter>
- </ClInclude>
<ClInclude Include="src\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -150,9 +147,6 @@
<ClInclude Include="src\skype_options.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\skype_trouter.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\version.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp
index 530678a0db..d5d8f594db 100644
--- a/protocols/SkypeWeb/src/main.cpp
+++ b/protocols/SkypeWeb/src/main.cpp
@@ -39,7 +39,8 @@ PLUGININFOEX pluginInfoEx =
};
CMPlugin::CMPlugin() :
- ACCPROTOPLUGIN<CSkypeProto>("SKYPE", pluginInfoEx)
+ ACCPROTOPLUGIN<CSkypeProto>("SKYPE", pluginInfoEx),
+ szDefaultServer("azeus1-client-s.gateway.messenger.live.com")
{
SetUniqueId(SKYPE_SETTINGS_ID);
}
diff --git a/protocols/SkypeWeb/src/request_queue.cpp b/protocols/SkypeWeb/src/request_queue.cpp
index 45e58d92da..a463c275e4 100644
--- a/protocols/SkypeWeb/src/request_queue.cpp
+++ b/protocols/SkypeWeb/src/request_queue.cpp
@@ -52,6 +52,68 @@ void CSkypeProto::SendRequest(AsyncHttpRequest *request)
mir_forkthreadowner(&CSkypeProto::AsyncSendThread, this, request, nullptr);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+NETLIBHTTPREQUEST* CSkypeProto::DoSend(AsyncHttpRequest *pReq)
+{
+ if (pReq->m_szUrl.Find("://") == -1)
+ pReq->m_szUrl.Insert(0, ((pReq->flags & NLHRF_SSL) ? "https://" : "http://"));
+
+ if (!pReq->m_szParam.IsEmpty()) {
+ switch (pReq->requestType) {
+ case REQUEST_GET:
+ case REQUEST_DELETE:
+ pReq->m_szUrl.AppendChar('?');
+ pReq->m_szUrl.Append(pReq->m_szParam.c_str());
+ break;
+
+ case REQUEST_PUT:
+ case REQUEST_POST:
+ if (Netlib_GetHeader(pReq, "Content-Type") == nullptr) {
+ if (pReq->m_szParam[0] == '[' || pReq->m_szParam[0] == '{')
+ pReq->AddHeader("Content-Type", "application/json; charset=UTF-8");
+ else
+ pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
+ }
+ __fallthrough;
+
+ default:
+ pReq->pData = pReq->m_szParam.Detach();
+ pReq->dataLength = (int)mir_strlen(pReq->pData);
+ }
+ }
+
+ switch (pReq->m_host) {
+ case HOST_API:
+ case HOST_CONTACTS:
+ if (m_szApiToken)
+ pReq->AddHeader("X-Skypetoken", m_szApiToken);
+ pReq->AddHeader("Accept", "application/json; ver=1.0;");
+ pReq->AddHeader("X-Stratus-Caller", SKYPEWEB_CLIENTINFO_NAME);
+ pReq->AddHeader("X-Stratus-Request", "abcd1234");
+ pReq->AddHeader("Origin", "https://web.skype.com");
+ pReq->AddHeader("Referer", "https://web.skype.com/main");
+ break;
+
+ case HOST_GRAPH:
+ if (m_szApiToken)
+ pReq->AddHeader("X-Skypetoken", m_szApiToken);
+ pReq->AddHeader("Accept", "application/json");
+ break;
+
+ case HOST_DEFAULT:
+ if (m_szToken)
+ pReq->AddHeader("RegistrationToken", CMStringA(FORMAT, "registrationToken=%s", m_szToken.get()));
+ pReq->AddHeader("Accept", "application/json, text/javascript");
+ break;
+ }
+
+ pReq->szUrl = pReq->m_szUrl.GetBuffer();
+ debugLogA("Send request to %s", pReq->szUrl);
+
+ return Netlib_HttpTransaction(m_hNetlibUser, pReq);
+}
+
void CSkypeProto::Execute(AsyncHttpRequest *item)
{
NLHR_PTR response(DoSend(item));
diff --git a/protocols/SkypeWeb/src/requests/avatars.h b/protocols/SkypeWeb/src/requests/avatars.h
index 918bbf37c4..4f35f226ee 100644
--- a/protocols/SkypeWeb/src/requests/avatars.h
+++ b/protocols/SkypeWeb/src/requests/avatars.h
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct GetAvatarRequest : public AsyncHttpRequest
{
GetAvatarRequest(const char *url, MCONTACT hContact) :
- AsyncHttpRequest(REQUEST_GET, url, &CSkypeProto::OnReceiveAvatar)
+ AsyncHttpRequest(REQUEST_GET, HOST_OTHER, url, &CSkypeProto::OnReceiveAvatar)
{
flags |= NLHRF_REDIRECT;
pUserInfo = (void *)hContact;
@@ -31,11 +31,10 @@ struct GetAvatarRequest : public AsyncHttpRequest
struct SetAvatarRequest : public AsyncHttpRequest
{
SetAvatarRequest(const PBYTE data, size_t dataSize, const char *szMime, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_PUT, 0, &CSkypeProto::OnSentAvatar)
+ AsyncHttpRequest(REQUEST_PUT, HOST_API, 0, &CSkypeProto::OnSentAvatar)
{
- m_szUrl.Format("api.skype.com/users/%s/profile/avatar", ppro->m_szSkypename.MakeLower().c_str());
+ m_szUrl.AppendFormat("/users/%s/profile/avatar", ppro->m_szSkypename.MakeLower().c_str());
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
AddHeader("Content-Type", szMime);
pData = (char *)mir_alloc(dataSize);
diff --git a/protocols/SkypeWeb/src/requests/capabilities.h b/protocols/SkypeWeb/src/requests/capabilities.h
index ce53922869..c733bf633f 100644
--- a/protocols/SkypeWeb/src/requests/capabilities.h
+++ b/protocols/SkypeWeb/src/requests/capabilities.h
@@ -21,34 +21,23 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct SendCapabilitiesRequest : public AsyncHttpRequest
{
SendCapabilitiesRequest(const char *hostname, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_PUT, 0, &CSkypeProto::OnCapabilitiesSended)
+ AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT, 0, &CSkypeProto::OnCapabilitiesSended)
{
- m_szUrl.Format("/users/ME/endpoints/%s/presenceDocs/messagingService", mir_urlEncode(ppro->m_szId).c_str());
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
+ m_szUrl.AppendFormat("/users/ME/endpoints/%s/presenceDocs/messagingService", mir_urlEncode(ppro->m_szId).c_str());
JSONNode privateInfo; privateInfo.set_name("privateInfo");
- privateInfo << JSONNode("epname", hostname);
+ privateInfo << CHAR_PARAM("epname", hostname);
JSONNode publicInfo; publicInfo.set_name("publicInfo");
- publicInfo
- << JSONNode("capabilities", "Audio|Video")
- << JSONNode("typ", 125)
- << JSONNode("skypeNameVersion", "Miranda NG Skype")
- << JSONNode("nodeInfo", "xx")
- << JSONNode("version", g_szMirVer);
+ publicInfo << CHAR_PARAM("capabilities", "Audio|Video") << INT_PARAM("typ", 125)
+ << CHAR_PARAM("skypeNameVersion", "Miranda NG Skype") << CHAR_PARAM("nodeInfo", "xx") << CHAR_PARAM("version", g_szMirVer);
JSONNode node;
- node
- << JSONNode("id", "messagingService")
- << JSONNode("type", "EndpointPresenceDoc")
- << JSONNode("selfLink", "uri")
- << privateInfo
- << publicInfo;
+ node << CHAR_PARAM("id", "messagingService") << CHAR_PARAM("type", "EndpointPresenceDoc")
+ << CHAR_PARAM("selfLink", "uri") << privateInfo << publicInfo;
m_szParam = node.write().c_str();
}
};
-#endif //_SKYPE_REQUEST_CAPS_H_ \ No newline at end of file
+
+#endif //_SKYPE_REQUEST_CAPS_H_
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h
index e0dd27c739..aa39995f01 100644
--- a/protocols/SkypeWeb/src/requests/chatrooms.h
+++ b/protocols/SkypeWeb/src/requests/chatrooms.h
@@ -20,57 +20,39 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct LoadChatsRequest : public AsyncHttpRequest
{
- LoadChatsRequest(CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_GET, "/users/ME/conversations", &CSkypeProto::OnLoadChats)
+ LoadChatsRequest() :
+ AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, "/users/ME/conversations", &CSkypeProto::OnLoadChats)
{
- this << INT_PARAM("startTime", 0) << INT_PARAM("pageSize", 100)
+ this << INT_PARAM("startTime", 0) << INT_PARAM("pageSize", 100)
<< CHAR_PARAM("view", "msnp24Equivalent") << CHAR_PARAM("targetType", "Thread");
-
- AddHeader("Accept", "application/json, text/javascript");
- AddRegistrationToken(ppro);
- AddHeader("Content-Type", "application/json; charset = UTF-8");
}
};
struct SendChatMessageRequest : public AsyncHttpRequest
{
- SendChatMessageRequest(const char *to, time_t timestamp, const char *message, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_POST)
+ SendChatMessageRequest(const char *to, time_t timestamp, const char *message) :
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT)
{
- m_szUrl.Format("/users/ME/conversations/19:%s/messages", to);
-
- AddHeader("Accept", "application/json, text/javascript");
- AddRegistrationToken(ppro);
- AddHeader("Content-Type", "application/json; charset=UTF-8");
+ m_szUrl.AppendFormat("/users/ME/conversations/19:%s/messages", to);
JSONNode node;
- node
- << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu000", (ULONGLONG)timestamp))
- << JSONNode("messagetype", "RichText")
- << JSONNode("contenttype", "text")
- << JSONNode("content", message);
+ node << CHAR_PARAM("clientmessageid", CMStringA(::FORMAT, "%llu000", (ULONGLONG)timestamp))
+ << CHAR_PARAM("messagetype", "RichText") << CHAR_PARAM("contenttype", "text") << CHAR_PARAM("content", message);
m_szParam = node.write().c_str();
}
};
struct SendChatActionRequest : public AsyncHttpRequest
{
- SendChatActionRequest(const char *to, time_t timestamp, const char *message, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_POST)
+ SendChatActionRequest(const char *to, time_t timestamp, const char *message) :
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT)
{
- m_szUrl.Format("/users/ME/conversations/19:%s/messages", to);
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
+ m_szUrl.AppendFormat("/users/ME/conversations/19:%s/messages", to);
JSONNode node(JSON_NODE);
- node
- << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu000", (ULONGLONG)timestamp))
- << JSONNode("messagetype", "RichText")
- << JSONNode("contenttype", "text")
- << JSONNode("content", message)
- << JSONNode("skypeemoteoffset", 4);
+ node << CHAR_PARAM("clientmessageid", CMStringA(::FORMAT, "%llu000", (ULONGLONG)timestamp))
+ << CHAR_PARAM("messagetype", "RichText") << CHAR_PARAM("contenttype", "text")
+ << CHAR_PARAM("content", message) << INT_PARAM("skypeemoteoffset", 4);
m_szParam = node.write().c_str();
}
};
@@ -78,22 +60,16 @@ struct SendChatActionRequest : public AsyncHttpRequest
struct CreateChatroomRequest : public AsyncHttpRequest
{
CreateChatroomRequest(const LIST<char> &skypenames, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_POST, "/threads")
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, "/threads")
{
//{"members":[{"id":"8:user3","role":"User"},{"id":"8:user2","role":"User"},{"id":"8:user1","role":"Admin"}]}
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
-
JSONNode node;
JSONNode members(JSON_ARRAY); members.set_name("members");
- for (auto &it : skypenames)
- {
+ for (auto &it : skypenames) {
JSONNode member;
- member
- << JSONNode("id", CMStringA(::FORMAT, "8:%s", it).GetBuffer())
- << JSONNode("role", !mir_strcmpi(it, ppro->m_szSkypename) ? "Admin" : "User");
+ member << CHAR_PARAM("id", CMStringA(::FORMAT, "8:%s", it).GetBuffer())
+ << CHAR_PARAM("role", !mir_strcmpi(it, ppro->m_szSkypename) ? "Admin" : "User");
members << member;
}
node << members;
@@ -103,63 +79,47 @@ struct CreateChatroomRequest : public AsyncHttpRequest
struct GetChatInfoRequest : public AsyncHttpRequest
{
- GetChatInfoRequest(const char *chatId, const CMStringW topic, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_GET, 0, &CSkypeProto::OnGetChatInfo)
+ GetChatInfoRequest(const char *chatId, const CMStringW topic) :
+ AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, 0, &CSkypeProto::OnGetChatInfo)
{
- m_szUrl.Format("/threads/%s%s", ppro->m_szServer, strstr(chatId, "19:") == chatId ? "" : "19:", chatId);
+ m_szUrl.AppendFormat("/threads/%s%s", strstr(chatId, "19:") == chatId ? "" : "19:", chatId);
pUserInfo = topic.Detach();
this << CHAR_PARAM("view", "msnp24Equivalent");
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
}
};
struct InviteUserToChatRequest : public AsyncHttpRequest
{
- InviteUserToChatRequest(const char *chatId, const char *skypename, const char* role, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_PUT)
+ InviteUserToChatRequest(const char *chatId, const char *skypename, const char *role) :
+ AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT)
{
- m_szUrl.Format("/threads/19:%s/members/8:%s", chatId, skypename);
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
+ m_szUrl.AppendFormat("/threads/19:%s/members/8:%s", chatId, skypename);
JSONNode node;
- node << JSONNode("role", role);
+ node << CHAR_PARAM("role", role);
m_szParam = node.write().c_str();
}
};
struct KickUserRequest : public AsyncHttpRequest
{
- KickUserRequest(const char *chatId, const char *skypename, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_DELETE)
+ KickUserRequest(const char *chatId, const char *skypename) :
+ AsyncHttpRequest(REQUEST_DELETE, HOST_DEFAULT)
{
- m_szUrl.Format("/threads/19:%s/members/8:%s", chatId, skypename);
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
+ m_szUrl.AppendFormat("/threads/19:%s/members/8:%s", chatId, skypename);
}
};
struct SetChatPropertiesRequest : public AsyncHttpRequest
{
- SetChatPropertiesRequest(const char *chatId, const char *propname, const char *value, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_PUT)
+ SetChatPropertiesRequest(const char *chatId, const char *propname, const char *value) :
+ AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT)
{
- m_szUrl.Format("/threads/19:%s/properties?name=%s", chatId, propname);
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
+ m_szUrl.AppendFormat("/threads/19:%s/properties?name=%s", chatId, propname);
JSONNode node;
- node << JSONNode(propname, value);
+ node << CHAR_PARAM(propname, value);
m_szParam = node.write().c_str();
}
};
diff --git a/protocols/SkypeWeb/src/requests/contacts.h b/protocols/SkypeWeb/src/requests/contacts.h
index 57866eb18c..ea22bb49a0 100644
--- a/protocols/SkypeWeb/src/requests/contacts.h
+++ b/protocols/SkypeWeb/src/requests/contacts.h
@@ -21,9 +21,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct GetContactListRequest : public AsyncHttpRequest
{
GetContactListRequest(CSkypeProto *ppro, const char *filter) :
- AsyncHttpRequest(REQUEST_GET, 0, &CSkypeProto::LoadContactList)
+ AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, 0, &CSkypeProto::LoadContactList)
{
- m_szUrl.Format("contacts.skype.com/contacts/v1/users/%s/contacts", ppro->m_szSkypename.MakeLower().GetBuffer());
+ m_szUrl.AppendFormat("/contacts/v1/users/%s/contacts", ppro->m_szSkypename.MakeLower().GetBuffer());
// ?filter=contacts[?(@.type="skype" or @.type="msn")]
if (filter != NULL)
@@ -35,63 +35,55 @@ struct GetContactListRequest : public AsyncHttpRequest
struct GetContactsAuthRequest : public AsyncHttpRequest
{
- GetContactsAuthRequest(CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_GET, "contacts.skype.com/contacts/v2/users/SELF/invites", &CSkypeProto::LoadContactsAuth)
+ GetContactsAuthRequest() :
+ AsyncHttpRequest(REQUEST_GET, HOST_CONTACTS, "/contacts/v2/users/SELF/invites", &CSkypeProto::LoadContactsAuth)
{
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
AddHeader("Accept", "application/json");
}
};
struct AddContactRequest : public AsyncHttpRequest
{
- AddContactRequest(CSkypeProto *ppro, const char *who, const char *greeting = "") :
- AsyncHttpRequest(REQUEST_PUT, "contacts.skype.com/contacts/v2/users/SELF/contacts")
+ AddContactRequest(const char *who, const char *greeting = "") :
+ AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS, "/contacts/v2/users/SELF/contacts")
{
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
AddHeader("Accept", "application/json");
- AddHeader("Content-type", "application/x-www-form-urlencoded");
JSONNode node;
- node << JSONNode("mri", CMStringA(::FORMAT, "8:", who).GetString())
- << JSONNode("greeting", greeting);
-
+ node << CHAR_PARAM("mri", CMStringA(::FORMAT, "8:", who).GetString()) << CHAR_PARAM("greeting", greeting);
m_szParam = node.write().c_str();
}
};
struct DeleteContactRequest : public AsyncHttpRequest
{
- DeleteContactRequest(CSkypeProto *ppro, const char *who) :
- AsyncHttpRequest(REQUEST_DELETE)
+ DeleteContactRequest(const char *who) :
+ AsyncHttpRequest(REQUEST_DELETE, HOST_CONTACTS)
{
- m_szUrl.Format("contacts.skype.com/contacts/v2/users/SELF/contacts/8:%s", who);
+ m_szUrl.AppendFormat("/contacts/v2/users/SELF/contacts/8:%s", who);
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
AddHeader("Accept", "application/json");
}
};
struct AuthAcceptRequest : public AsyncHttpRequest
{
- AuthAcceptRequest(CSkypeProto *ppro, const char *who) :
- AsyncHttpRequest(REQUEST_PUT)
+ AuthAcceptRequest(const char *who) :
+ AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS)
{
- m_szUrl.Format("contacts.skype.com/contacts/v2/users/SELF/invites/8:%s/accept", who);
+ m_szUrl.AppendFormat("/contacts/v2/users/SELF/invites/8:%s/accept", who);
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
AddHeader("Accept", "application/json");
}
};
struct AuthDeclineRequest : public AsyncHttpRequest
{
- AuthDeclineRequest(CSkypeProto *ppro, const char *who) :
- AsyncHttpRequest(REQUEST_PUT)
+ AuthDeclineRequest(const char *who) :
+ AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS)
{
- m_szUrl.Format("contacts.skype.com/contacts/v2/users/SELF/invites/8:%s/decline", who);
+ m_szUrl.AppendFormat("/contacts/v2/users/SELF/invites/8:%s/decline", who);
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
AddHeader("Accept", "application/json");
}
};
@@ -99,32 +91,28 @@ struct AuthDeclineRequest : public AsyncHttpRequest
struct BlockContactRequest : public AsyncHttpRequest
{
BlockContactRequest(CSkypeProto *ppro, MCONTACT hContact) :
- AsyncHttpRequest(REQUEST_PUT, 0, &CSkypeProto::OnBlockContact)
+ AsyncHttpRequest(REQUEST_PUT, HOST_CONTACTS, 0, &CSkypeProto::OnBlockContact)
{
- m_szUrl.Format("contacts.skype.com/contacts/v2/users/SELF/contacts/blocklist/8:%s", ppro->getId(hContact).c_str());
+ 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("X-Skypetoken", ppro->m_szApiToken);
AddHeader("Accept", "application/json");
- AddHeader("Content-type", "application/x-www-form-urlencoded");
}
};
struct UnblockContactRequest : public AsyncHttpRequest
{
UnblockContactRequest(CSkypeProto *ppro, MCONTACT hContact) :
- AsyncHttpRequest(REQUEST_DELETE, 0, &CSkypeProto::OnUnblockContact)
+ AsyncHttpRequest(REQUEST_DELETE, HOST_CONTACTS, 0, &CSkypeProto::OnUnblockContact)
{
- m_szUrl.Format("contacts.skype.com/contacts/v2/users/SELF/contacts/blocklist/8:%s", ppro->getId(hContact).c_str());
+ m_szUrl.AppendFormat("/contacts/v2/users/SELF/contacts/blocklist/8:%s", ppro->getId(hContact).c_str());
pUserInfo = (void *)hContact;
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
AddHeader("Accept", "application/json");
- AddHeader("Content-type", "application/x-www-form-urlencoded");
- this << CHAR_PARAM("reporterIp", "123.123.123.123") // TODO: user ip address
- << CHAR_PARAM("uiVersion", g_szMirVer);
+ // TODO: user ip address
+ this << CHAR_PARAM("reporterIp", "123.123.123.123") << CHAR_PARAM("uiVersion", g_szMirVer);
}
};
diff --git a/protocols/SkypeWeb/src/requests/endpoint.h b/protocols/SkypeWeb/src/requests/endpoint.h
index 07baa3c409..135ca178dc 100644
--- a/protocols/SkypeWeb/src/requests/endpoint.h
+++ b/protocols/SkypeWeb/src/requests/endpoint.h
@@ -21,12 +21,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct CreateEndpointRequest : public AsyncHttpRequest
{
CreateEndpointRequest(CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_POST, "/users/ME/endpoints", &CSkypeProto::OnEndpointCreated)
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, "/users/ME/endpoints", &CSkypeProto::OnEndpointCreated)
{
m_szParam = "{}";
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
AddHeader("Authentication", CMStringA(FORMAT, "skypetoken=%s", ppro->m_szApiToken.get()));
}
};
@@ -34,12 +32,9 @@ struct CreateEndpointRequest : public AsyncHttpRequest
struct DeleteEndpointRequest : public AsyncHttpRequest
{
DeleteEndpointRequest(CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_DELETE)
+ AsyncHttpRequest(REQUEST_DELETE, HOST_DEFAULT)
{
- m_szUrl.Format("/users/ME/endpoints/%s", mir_urlEncode(ppro->m_szId).c_str());
-
- AddHeader("Accept", "application/json, text/javascript");
- AddRegistrationToken(ppro);
+ m_szUrl.AppendFormat("/users/ME/endpoints/%s", mir_urlEncode(ppro->m_szId).c_str());
}
};
diff --git a/protocols/SkypeWeb/src/requests/files.h b/protocols/SkypeWeb/src/requests/files.h
index 11123e3f03..6afd64d7f5 100644
--- a/protocols/SkypeWeb/src/requests/files.h
+++ b/protocols/SkypeWeb/src/requests/files.h
@@ -3,7 +3,7 @@
struct ASMObjectCreateRequest : public AsyncHttpRequest
{
ASMObjectCreateRequest(CSkypeProto *ppro, CFileUploadParam *fup) :
- AsyncHttpRequest(REQUEST_POST, "api.asm.skype.com/v1/objects", &CSkypeProto::OnASMObjectCreated)
+ AsyncHttpRequest(REQUEST_POST, HOST_OTHER, "https://api.asm.skype.com/v1/objects", &CSkypeProto::OnASMObjectCreated)
{
flags &= (~NLHRF_DUMPASTEXT);
pUserInfo = fup;
@@ -19,9 +19,9 @@ struct ASMObjectCreateRequest : public AsyncHttpRequest
JSONNode node, jPermissions, jPermission(JSON_ARRAY);
jPermissions.set_name("permissions");
jPermission.set_name(szContact.c_str());
- jPermission << JSONNode("", "read");
+ jPermission << CHAR_PARAM("", "read");
jPermissions << jPermission;
- node << JSONNode("type", "sharing/file") << JSONNode("filename", szFileName) << jPermissions;
+ node << CHAR_PARAM("type", "sharing/file") << CHAR_PARAM("filename", szFileName) << jPermissions;
m_szParam = node.write().c_str();
}
};
@@ -29,9 +29,9 @@ struct ASMObjectCreateRequest : public AsyncHttpRequest
struct ASMObjectUploadRequest : public AsyncHttpRequest
{
ASMObjectUploadRequest(CSkypeProto *ppro, const char *szObject, const PBYTE data, const size_t size, CFileUploadParam *fup) :
- AsyncHttpRequest(REQUEST_PUT, 0, &CSkypeProto::OnASMObjectUploaded)
+ AsyncHttpRequest(REQUEST_PUT, HOST_OTHER, 0, &CSkypeProto::OnASMObjectUploaded)
{
- m_szUrl.Format("api.asm.skype.com/v1/objects/%s/content/original", szObject);
+ m_szUrl.AppendFormat("https://api.asm.skype.com/v1/objects/%s/content/original", szObject);
pUserInfo = fup;
AddHeader("Authorization", CMStringA(FORMAT, "skype_token %s", ppro->m_szApiToken.get()));
diff --git a/protocols/SkypeWeb/src/requests/history.h b/protocols/SkypeWeb/src/requests/history.h
index ed65be8b2d..4c2394ed0c 100644
--- a/protocols/SkypeWeb/src/requests/history.h
+++ b/protocols/SkypeWeb/src/requests/history.h
@@ -14,55 +14,42 @@ 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_HISTORY_H_
#define _SKYPE_REQUEST_HISTORY_H_
struct SyncHistoryFirstRequest : public AsyncHttpRequest
{
- SyncHistoryFirstRequest(int pageSize, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_GET, "/users/ME/conversations", &CSkypeProto::OnSyncHistory)
+ SyncHistoryFirstRequest(int pageSize) :
+ AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, "/users/ME/conversations", &CSkypeProto::OnSyncHistory)
{
this << INT_PARAM("startTime", 0) << INT_PARAM("pageSize", pageSize)
<< CHAR_PARAM("view", "msnp24Equivalent") << CHAR_PARAM("targetType", "Passport|Skype|Lync");
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset = UTF-8");
- AddRegistrationToken(ppro);
}
- SyncHistoryFirstRequest(const char *url, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_GET, url, &CSkypeProto::OnSyncHistory)
+ SyncHistoryFirstRequest(const char *url) :
+ AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, url, &CSkypeProto::OnSyncHistory)
{
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset = UTF-8");
- AddRegistrationToken(ppro);
}
};
struct GetHistoryRequest : public AsyncHttpRequest
{
- GetHistoryRequest(const char *username, int pageSize, bool isChat, LONGLONG timestamp, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_GET, 0, &CSkypeProto::OnGetServerHistory)
+ GetHistoryRequest(const char *username, int pageSize, bool isChat, LONGLONG timestamp) :
+ AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, 0, &CSkypeProto::OnGetServerHistory)
{
- m_szUrl.Format("/users/ME/conversations/%d:%s/messages", isChat ? 19 : 8, mir_urlEncode(username).c_str());
+ m_szUrl.AppendFormat("/users/ME/conversations/%d:%s/messages", isChat ? 19 : 8, mir_urlEncode(username).c_str());
this << INT_PARAM("startTime", timestamp) << INT_PARAM("pageSize", pageSize)
<< CHAR_PARAM("view", "msnp24Equivalent") << CHAR_PARAM("targetType", "Passport|Skype|Lync|Thread");
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset = UTF-8");
- AddRegistrationToken(ppro);
}
};
struct GetHistoryOnUrlRequest : public AsyncHttpRequest
{
- GetHistoryOnUrlRequest(const char *url, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_GET, url, &CSkypeProto::OnGetServerHistory)
+ GetHistoryOnUrlRequest(const char *url) :
+ AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, url, &CSkypeProto::OnGetServerHistory)
{
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset = UTF-8");
- AddRegistrationToken(ppro);
}
};
diff --git a/protocols/SkypeWeb/src/requests/login.h b/protocols/SkypeWeb/src/requests/login.h
index bb5e5d00ad..da293572e5 100644
--- a/protocols/SkypeWeb/src/requests/login.h
+++ b/protocols/SkypeWeb/src/requests/login.h
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct LoginOAuthRequest : public AsyncHttpRequest
{
LoginOAuthRequest(CMStringA username, const char *password) :
- AsyncHttpRequest(REQUEST_POST, "api.skype.com/login/skypetoken", &CSkypeProto::OnLoginOAuth)
+ AsyncHttpRequest(REQUEST_POST, HOST_API, "/login/skypetoken", &CSkypeProto::OnLoginOAuth)
{
username.MakeLower();
CMStringA hashStr(::FORMAT, "%s\nskyper\n%s", username.c_str(), password);
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h
index fdcb8d8ae6..817d459046 100644
--- a/protocols/SkypeWeb/src/requests/messages.h
+++ b/protocols/SkypeWeb/src/requests/messages.h
@@ -26,20 +26,14 @@ struct SendMessageParam
struct SendMessageRequest : public AsyncHttpRequest
{
- SendMessageRequest(const char *username, time_t timestamp, const char *message, CSkypeProto *ppro, const char *MessageType = nullptr) :
- AsyncHttpRequest(REQUEST_POST, 0, &CSkypeProto::OnMessageSent)
+ SendMessageRequest(const char *username, time_t timestamp, const char *message, const char *MessageType = nullptr) :
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, 0, &CSkypeProto::OnMessageSent)
{
- m_szUrl.Format("/users/ME/conversations/8:%s/messages", username);
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
+ m_szUrl.AppendFormat("/users/ME/conversations/8:%s/messages", username);
JSONNode node;
- node << JSONNode("clientmessageid", CMStringA(::FORMAT, "%llu", (ULONGLONG)timestamp))
- << JSONNode("messagetype", MessageType ? MessageType : "Text")
- << JSONNode("contenttype", "text")
- << JSONNode("content", message);
+ node << INT64_PARAM("clientmessageid", timestamp) << CHAR_PARAM("messagetype", MessageType ? MessageType : "Text")
+ << CHAR_PARAM("contenttype", "text") << CHAR_PARAM("content", message);
m_szParam = node.write().c_str();
}
};
@@ -47,66 +41,45 @@ struct SendMessageRequest : public AsyncHttpRequest
struct SendActionRequest : public AsyncHttpRequest
{
SendActionRequest(const char *username, time_t timestamp, const char *message, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_POST, 0, &CSkypeProto::OnMessageSent)
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, 0, &CSkypeProto::OnMessageSent)
{
- m_szUrl.Format("/users/ME/conversations/8:%s/messages", username);
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
+ m_szUrl.AppendFormat("/users/ME/conversations/8:%s/messages", username);
CMStringA content;
content.AppendFormat("%s %s", ppro->m_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", ppro->m_szSkypename.GetLength() + 1);
+ node << INT64_PARAM("clientmessageid", timestamp) << CHAR_PARAM("messagetype", "RichText") << CHAR_PARAM("contenttype", "text")
+ << CHAR_PARAM("content", content) << INT_PARAM("skypeemoteoffset", ppro->m_szSkypename.GetLength() + 1);
m_szParam = node.write().c_str();
}
};
struct SendTypingRequest : public AsyncHttpRequest
{
- SendTypingRequest(const char *username, int iState, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_POST)
+ SendTypingRequest(const char *username, int iState) :
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT)
{
- m_szUrl.Format("/users/ME/conversations/8:%s/messages", mir_urlEncode(username).c_str());
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
+ m_szUrl.AppendFormat("/users/ME/conversations/8:%s/messages", mir_urlEncode(username).c_str());
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", "");
+ node << INT_PARAM("clientmessageid", (long)time(NULL)) << CHAR_PARAM("messagetype", state)
+ << CHAR_PARAM("contenttype", "text") << CHAR_PARAM("content", "");
m_szParam = node.write().c_str();
}
};
struct MarkMessageReadRequest : public AsyncHttpRequest
{
- MarkMessageReadRequest(const char *username, LONGLONG /*msgId*/, LONGLONG msgTimestamp, bool isChat, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_PUT)
+ MarkMessageReadRequest(const char *username, LONGLONG /*msgId*/, LONGLONG msgTimestamp, bool isChat) :
+ AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT)
{
- m_szUrl.Format("/users/ME/conversations/%d:%s/properties?name=consumptionhorizon", !isChat ? 8 : 19, username);
-
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
-
- //"lastReadMessageTimestamp;modificationTime;lastReadMessageId"
+ m_szUrl.AppendFormat("/users/ME/conversations/%d:%s/properties?name=consumptionhorizon", !isChat ? 8 : 19, username);
JSONNode node(JSON_NODE);
- node << JSONNode("consumptionhorizon", CMStringA(::FORMAT, "%lld000;%lld000;%lld000", msgTimestamp, time(NULL), msgTimestamp));
+ node << CHAR_PARAM("consumptionhorizon", CMStringA(::FORMAT, "%lld000;%lld000;%lld000", msgTimestamp, time(NULL), msgTimestamp));
m_szParam = node.write().c_str();
}
};
diff --git a/protocols/SkypeWeb/src/requests/oauth.h b/protocols/SkypeWeb/src/requests/oauth.h
index 3f23ea50e3..f5bf8afd1b 100644
--- a/protocols/SkypeWeb/src/requests/oauth.h
+++ b/protocols/SkypeWeb/src/requests/oauth.h
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct OAuthRequest : public AsyncHttpRequest
{
OAuthRequest() :
- AsyncHttpRequest(REQUEST_GET, "login.live.com/login.srf", &CSkypeProto::OnOAuthStart)
+ AsyncHttpRequest(REQUEST_GET, HOST_OTHER, "https://login.live.com/login.srf", &CSkypeProto::OnOAuthStart)
{
flags |= NLHRF_REDIRECT;
@@ -31,7 +31,7 @@ struct OAuthRequest : public AsyncHttpRequest
}
OAuthRequest(const char *login, const char *password, const char *cookies, const char *ppft) :
- AsyncHttpRequest(REQUEST_POST, "login.live.com/ppsecure/post.srf", &CSkypeProto::OnOAuthAuthorize)
+ AsyncHttpRequest(REQUEST_POST, HOST_OTHER, "https://login.live.com/ppsecure/post.srf", &CSkypeProto::OnOAuthAuthorize)
{
this << CHAR_PARAM("wa", "wsignin1.0") << CHAR_PARAM("wp", "MBI_SSL")
<< CHAR_PARAM("wreply", "https://lw.skype.com/login/oauth/proxy?site_name=lw.skype.com")
@@ -39,17 +39,14 @@ struct OAuthRequest : public AsyncHttpRequest
m_szUrl.AppendFormat("?%s", m_szParam.c_str());
m_szParam.Empty();
- AddHeader("Content-Type", "application/x-www-form-urlencoded");
AddHeader("Cookie", cookies);
this << CHAR_PARAM("login", login) << CHAR_PARAM("passwd", password) << CHAR_PARAM("PPFT", ppft);
}
OAuthRequest(const char *t) :
- AsyncHttpRequest(REQUEST_POST, "login.skype.com/login/microsoft", &CSkypeProto::OnOAuthEnd)
+ AsyncHttpRequest(REQUEST_POST, HOST_LOGIN, "/login/microsoft", &CSkypeProto::OnOAuthEnd)
{
- AddHeader("Content-Type", "application/x-www-form-urlencoded");
-
this << CHAR_PARAM ("t", t) << CHAR_PARAM("site_name", "lw.skype.com") << INT_PARAM ("oauthPartner", 999);
}
};
diff --git a/protocols/SkypeWeb/src/requests/poll.h b/protocols/SkypeWeb/src/requests/poll.h
index d74030dbd4..89aaef587b 100644
--- a/protocols/SkypeWeb/src/requests/poll.h
+++ b/protocols/SkypeWeb/src/requests/poll.h
@@ -21,19 +21,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct PollRequest : public AsyncHttpRequest
{
PollRequest(CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_POST, "/users/ME/endpoints/SELF/subscriptions/0/poll")
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, "/users/ME/endpoints/SELF/subscriptions/0/poll")
{
timeout = 120000;
if (ppro->m_iPollingId != -1)
- this << INT_PARAM("ackId", ppro->m_iPollingId);
+ m_szUrl.AppendFormat("?ackId=%d", ppro->m_iPollingId);
AddHeader("Referer", "https://web.skype.com/main");
- AddHeader("Content-Type", "application/x-www-form-urlencoded");
AddHeader("ClientInfo", "os=Windows; osVer=8.1; proc=Win32; lcid=en-us; deviceType=1; country=n/a; clientName=swx-skype.com; clientVer=908/1.85.0.29");
AddHeader("Accept", "application/json; ver=1.0");
AddHeader("Accept-Language", "en, C");
- AddRegistrationToken(ppro);
}
};
#endif //_SKYPE_POLL_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/requests/profile.h b/protocols/SkypeWeb/src/requests/profile.h
index 5f872b7fe8..802449e910 100644
--- a/protocols/SkypeWeb/src/requests/profile.h
+++ b/protocols/SkypeWeb/src/requests/profile.h
@@ -21,12 +21,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct GetProfileRequest : public AsyncHttpRequest
{
GetProfileRequest(CSkypeProto *ppro, MCONTACT hContact) :
- AsyncHttpRequest(REQUEST_GET, 0, &CSkypeProto::LoadProfile)
+ AsyncHttpRequest(REQUEST_GET, HOST_API, 0, &CSkypeProto::LoadProfile)
{
- m_szUrl.Format("api.skype.com/users/%s/profile", (hContact == 0) ? "self" : ppro->getId(hContact).c_str());
+ m_szUrl.AppendFormat("/users/%s/profile", (hContact == 0) ? "self" : ppro->getId(hContact).c_str());
pUserInfo = (void *)hContact;
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
AddHeader("Accept", "application/json");
}
};
diff --git a/protocols/SkypeWeb/src/requests/search.h b/protocols/SkypeWeb/src/requests/search.h
index 3df9f2fda2..369e19651d 100644
--- a/protocols/SkypeWeb/src/requests/search.h
+++ b/protocols/SkypeWeb/src/requests/search.h
@@ -20,14 +20,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct GetSearchRequest : public AsyncHttpRequest
{
- GetSearchRequest(const char *string, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_GET, "skypegraph.skype.com/search/v1.1/namesearch/swx/", &CSkypeProto::OnSearch)
+ GetSearchRequest(const char *string) :
+ AsyncHttpRequest(REQUEST_GET, HOST_GRAPH, "/search/v1.1/namesearch/swx/", &CSkypeProto::OnSearch)
{
this << CHAR_PARAM("requestid", "skype.com-1.48.78-00000000-0000-0000-0000-000000000000")
<< CHAR_PARAM("locale", "en-US") << CHAR_PARAM("searchstring", string);
AddHeader("Accept", "application/json");
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
}
};
diff --git a/protocols/SkypeWeb/src/requests/status.h b/protocols/SkypeWeb/src/requests/status.h
index 5b68b46ddd..166b2e7bbe 100644
--- a/protocols/SkypeWeb/src/requests/status.h
+++ b/protocols/SkypeWeb/src/requests/status.h
@@ -20,42 +20,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct GetStatusRequest : public AsyncHttpRequest
{
- GetStatusRequest(CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_GET, "/users/ME/contacts/ALL/presenceDocs/messagingService", &CSkypeProto::OnReceiveStatus)
- {
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
- }
+ GetStatusRequest() :
+ AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, "/users/ME/contacts/ALL/presenceDocs/messagingService", &CSkypeProto::OnReceiveStatus)
+ {}
};
struct SetStatusRequest : public AsyncHttpRequest
{
- SetStatusRequest(const char *status, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_PUT, "/users/ME/presenceDocs/messagingService", &CSkypeProto::OnStatusChanged)
+ SetStatusRequest(const char *status) :
+ AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT, "/users/ME/presenceDocs/messagingService", &CSkypeProto::OnStatusChanged)
{
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
-
JSONNode node(JSON_NODE);
- node << JSONNode("status", status);
+ node << CHAR_PARAM("status", status);
m_szParam = node.write().c_str();
}
};
struct SetStatusMsgRequest : public AsyncHttpRequest
{
- SetStatusMsgRequest(const char *status, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_POST, "api.skype.com/users/self/profile/partial")
+ SetStatusMsgRequest(const char *status) :
+ AsyncHttpRequest(REQUEST_POST, HOST_API, "/users/self/profile/partial")
{
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
- AddHeader("Content-Type", "application/json; charset=UTF-8");
-
JSONNode node, payload;
payload.set_name("payload");
- node << (payload << JSONNode("mood", status));
+ node << (payload << CHAR_PARAM("mood", status));
m_szParam = node.write().c_str();
}
};
diff --git a/protocols/SkypeWeb/src/requests/subscriptions.h b/protocols/SkypeWeb/src/requests/subscriptions.h
index 610373f52b..1f8717e91d 100644
--- a/protocols/SkypeWeb/src/requests/subscriptions.h
+++ b/protocols/SkypeWeb/src/requests/subscriptions.h
@@ -20,49 +20,35 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct CreateSubscriptionsRequest : public AsyncHttpRequest
{
- CreateSubscriptionsRequest(CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_POST, "/users/ME/endpoints/SELF/subscriptions", &CSkypeProto::OnSubscriptionsCreated)
+ CreateSubscriptionsRequest() :
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, "/users/ME/endpoints/SELF/subscriptions", &CSkypeProto::OnSubscriptionsCreated)
{
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
-
JSONNode interestedResources(JSON_ARRAY); interestedResources.set_name("interestedResources");
- interestedResources
- << JSONNode("", "/v1/users/ME/conversations/ALL/properties")
- << JSONNode("", "/v1/users/ME/conversations/ALL/messages")
- << JSONNode("", "/v1/users/ME/contacts/ALL")
- << JSONNode("", "/v1/threads/ALL");
+ interestedResources << CHAR_PARAM("", "/v1/users/ME/conversations/ALL/properties")
+ << CHAR_PARAM("", "/v1/users/ME/conversations/ALL/messages")
+ << CHAR_PARAM("", "/v1/users/ME/contacts/ALL")
+ << CHAR_PARAM("", "/v1/threads/ALL");
JSONNode node;
- node
- << JSONNode("channelType", "httpLongPoll")
- << JSONNode("template", "raw")
- << interestedResources;
-
+ node << CHAR_PARAM("channelType", "httpLongPoll") << CHAR_PARAM("template", "raw") << interestedResources;
m_szParam = node.write().c_str();
}
};
struct CreateContactsSubscriptionRequest : public AsyncHttpRequest
{
- CreateContactsSubscriptionRequest(const LIST<char> &skypenames, CSkypeProto *ppro) :
- AsyncHttpRequest(REQUEST_POST, "/users/ME/contacts")
+ CreateContactsSubscriptionRequest(const LIST<char> &skypenames) :
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, "/users/ME/contacts")
{
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddRegistrationToken(ppro);
-
- JSONNode node;
JSONNode contacts(JSON_ARRAY); contacts.set_name("contacts");
-
for (auto &it : skypenames) {
JSONNode contact;
- contact << JSONNode("id", CMStringA(::FORMAT, "8:%s", it));
+ contact << CHAR_PARAM("id", CMStringA(::FORMAT, "8:%s", it));
contacts << contact;
}
- node << contacts;
+ JSONNode node;
+ node << contacts;
m_szParam = node.write().c_str();
}
};
diff --git a/protocols/SkypeWeb/src/requests/trouter.h b/protocols/SkypeWeb/src/requests/trouter.h
deleted file mode 100644
index baeba2a861..0000000000
--- a/protocols/SkypeWeb/src/requests/trouter.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
-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/>.
-*/
-
-#pragma once
-
-struct CreateTrouterRequest : public AsyncHttpRequest
-{
- CreateTrouterRequest() :
- AsyncHttpRequest(REQUEST_POST, "go.trouter.io/v2/a", &CSkypeProto::OnCreateTrouter)
- {
- AddHeader("Accept", "application/json, text/javascript, text/html,application/xhtml+xml, application/xml");
- }
-};
-
-struct CreateTrouterPoliciesRequest : public AsyncHttpRequest
-{
- CreateTrouterPoliciesRequest(CSkypeProto *ppro, const char *sr) :
- AsyncHttpRequest(REQUEST_POST, "prod.tpc.skype.com/v1/policies", &CSkypeProto::OnTrouterPoliciesCreated)
- {
- AddHeader("Accept", "application/json, text/javascript");
- AddHeader("Content-Type", "application/json; charset=UTF-8");
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
-
- JSONNode node;
- node << JSONNode("sr", sr);
-
- m_szParam = node.write().c_str();
- }
-};
-
-struct RegisterTrouterRequest : public AsyncHttpRequest
-{
- RegisterTrouterRequest(CSkypeProto *ppro, const char *trouterUrl, const char *id) :
- AsyncHttpRequest(REQUEST_POST, "prod.registrar.skype.com/v2/registrations")
- {
- AddHeader("Accept", "application/json, text/javascript, text/html,application/xhtml+xml, application/xml");
- AddHeader("X-Skypetoken", ppro->m_szApiToken);
-
- JSONNode clientDescription; clientDescription.set_name("clientDescription");
- clientDescription
- << JSONNode("aesKey", "")
- << JSONNode("languageId", "en-US")
- << JSONNode("platform", "SWX")
- << JSONNode("templateKey", "SkypeWeb_1.0");
-
- JSONNode TRouter;
- TRouter
- << JSONNode("context", "")
- << JSONNode("path", trouterUrl)
- << JSONNode("ttl", 3600);
-
- JSONNode TRouters(JSON_ARRAY); TRouters.set_name("TROUTER");
- TRouters << TRouter;
-
- JSONNode transports; transports.set_name("transports");
- transports << TRouters;
-
- JSONNode node;
- node
- << JSONNode("registrationId", id)
- << JSONNode("nodeId", "")
- << clientDescription
- << transports;
-
- m_szParam = node.write().c_str();
- }
-};
-
-struct HealthTrouterRequest : public AsyncHttpRequest
-{
- HealthTrouterRequest(const char *ccid) :
- AsyncHttpRequest(REQUEST_POST, "go.trouter.io/v2/h", &CSkypeProto::OnHealth)
- {
- this << CHAR_PARAM("ccid", ccid);
-
- AddHeader("Accept", "application/json, text/javascript, text/html,application/xhtml+xml, application/xml");
-
- }
-};
-
-struct GetTrouterRequest : public AsyncHttpRequest
-{
- GetTrouterRequest(const std::string &socketio, const std::string &sr, const std::string &st, const std::string &se, const std::string &sig,
- const std::string &instance, const std::string &ccid) :
- AsyncHttpRequest(REQUEST_GET, 0, &CSkypeProto::OnGetTrouter)
- {
- m_szUrl.Format("%ssocket.io/1/", socketio.c_str());
-
- this << CHAR_PARAM("sr", sr.c_str())
- << CHAR_PARAM("issuer", "edf")
- << CHAR_PARAM("sp", "connect")
- << CHAR_PARAM("st", st.c_str())
- << CHAR_PARAM("se", se.c_str())
- << CHAR_PARAM("sig", sig.c_str())
- << CHAR_PARAM("r", instance.c_str())
- << CHAR_PARAM("v", "v2")
- << INT_PARAM("p", 443)
- << CHAR_PARAM("ccid", ccid.c_str())
- << CHAR_PARAM("tc", mir_urlEncode("{\"cv\":\"2014.8.26\",\"hr\":\"\",\"ua\":\"Miranda_NG\",\"v\":\"\"}"))
- << INT_PARAM("t", time(NULL) * 1000);
-
- AddHeader("Accept", "application/json, text/javascript, text/html,application/xhtml+xml, application/xml");
- }
-};
-
-struct TrouterPollRequest : public AsyncHttpRequest
-{
- TrouterPollRequest(const std::string &socketio, const std::string &sr, const std::string &st, const std::string &se, const std::string &sig,
- const std::string &instance, const std::string &ccid, const std::string &sessId) :
- AsyncHttpRequest(REQUEST_GET)
- {
- m_szUrl.Format("%ssocket.io/1/xhr-polling/%s", socketio.c_str(), sessId.c_str());
-
- timeout = 60000;
- flags |= NLHRF_PERSISTENT;
- this
- << CHAR_PARAM("sr", sr.c_str())
- << CHAR_PARAM("issuer", "edf")
- << CHAR_PARAM("sp", "connect")
- << CHAR_PARAM("st", st.c_str())
- << CHAR_PARAM("se", se.c_str())
- << CHAR_PARAM("sig", sig.c_str())
- << CHAR_PARAM("r", instance.c_str())
- << CHAR_PARAM("v", "v2")
- << INT_PARAM("p", 443)
- << CHAR_PARAM("ccid", ccid.c_str())
- << CHAR_PARAM("tc", mir_urlEncode("{\"cv\":\"2014.8.26\",\"hr\":\"\",\"ua\":\"Miranda_NG\",\"v\":\"\"}"))
- << INT_PARAM("t", time(NULL) * 1000);
-
- AddHeader("Accept", "application/json, text/javascript, text/html,application/xhtml+xml, application/xml");
- }
-};
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp
index ee770de407..6aeea2bab4 100644
--- a/protocols/SkypeWeb/src/skype_chatrooms.cpp
+++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp
@@ -68,7 +68,7 @@ void CSkypeProto::OnLoadChats(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
std::string syncState = metadata["syncState"].as_string();
if (totalCount >= 99 || conversations.size() >= 99)
- PushRequest(new SyncHistoryFirstRequest(syncState.c_str(), this));
+ ReadHistoryRest(syncState.c_str());
for (auto &conversation : conversations) {
if (!conversation["lastMessage"])
@@ -77,7 +77,7 @@ void CSkypeProto::OnLoadChats(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
const JSONNode &id = conversation["id"];
const JSONNode &threadProperties = conversation["threadProperties"];
CMStringW topic(threadProperties["topic"].as_mstring());
- SendRequest(new GetChatInfoRequest(id.as_string().c_str(), topic, this));
+ SendRequest(new GetChatInfoRequest(id.as_string().c_str(), topic));
}
}
@@ -127,7 +127,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
MCONTACT hContact = dlg.m_hContact;
if (hContact != NULL)
- SendRequest(new InviteUserToChatRequest(chat_id, getId(hContact), "User", this));
+ SendRequest(new InviteUserToChatRequest(chat_id, getId(hContact), "User"));
mir_cslock lck(m_InviteDialogsLock);
m_InviteDialogs.remove(&dlg);
@@ -141,7 +141,7 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
case 30:
CMStringW newTopic = ChangeTopicForm();
if (!newTopic.IsEmpty())
- SendRequest(new SetChatPropertiesRequest(chat_id, "topic", T2Utf(newTopic.GetBuffer()), this));
+ SendRequest(new SetChatPropertiesRequest(chat_id, "topic", T2Utf(newTopic.GetBuffer())));
break;
}
break;
@@ -149,13 +149,13 @@ int CSkypeProto::OnGroupChatEventHook(WPARAM, LPARAM lParam)
case GC_USER_NICKLISTMENU:
switch (gch->dwData) {
case 10:
- SendRequest(new KickUserRequest(chat_id, user_id, this));
+ SendRequest(new KickUserRequest(chat_id, user_id));
break;
case 30:
- SendRequest(new InviteUserToChatRequest(chat_id, user_id, "Admin", this));
+ SendRequest(new InviteUserToChatRequest(chat_id, user_id, "Admin"));
break;
case 40:
- SendRequest(new InviteUserToChatRequest(chat_id, user_id, "User", this));
+ SendRequest(new InviteUserToChatRequest(chat_id, user_id, "User"));
break;
case 50:
ptrA tnick_old(GetChatContactNick(chat_id, user_id, T2Utf(gch->ptszText)));
@@ -221,7 +221,7 @@ INT_PTR CSkypeProto::OnLeaveChatRoom(WPARAM hContact, LPARAM)
Chat_Control(m_szModuleName, idT, SESSION_OFFLINE);
Chat_Terminate(m_szModuleName, idT);
- SendRequest(new KickUserRequest(_T2A(idT), m_szSkypename, this));
+ SendRequest(new KickUserRequest(_T2A(idT), m_szSkypename));
db_delete_contact(hContact);
}
@@ -243,7 +243,7 @@ void CSkypeProto::OnChatEvent(const JSONNode &node)
int nEmoteOffset = node["skypeemoteoffset"].as_int();
if (FindChatRoom(szConversationName) == NULL)
- SendRequest(new GetChatInfoRequest(szConversationName, szTopic, this));
+ SendRequest(new GetChatInfoRequest(szConversationName, szTopic));
std::string messageType = node["messagetype"].as_string();
if (messageType == "Text" || messageType == "RichText") {
@@ -328,9 +328,9 @@ void CSkypeProto::OnSendChatMessage(const char *chat_id, const wchar_t *tszMessa
ptrA szMessage(mir_utf8encodeW(buf));
if (strncmp(szMessage, "/me ", 4) == 0)
- SendRequest(new SendChatActionRequest(chat_id, time(0), szMessage, this));
+ SendRequest(new SendChatActionRequest(chat_id, time(0), szMessage));
else
- SendRequest(new SendChatMessageRequest(chat_id, time(0), szMessage, this));
+ SendRequest(new SendChatMessageRequest(chat_id, time(0), szMessage));
}
void CSkypeProto::AddMessageToChat(const char *chat_id, const char *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading)
@@ -380,7 +380,7 @@ void CSkypeProto::OnGetChatInfo(NETLIBHTTPREQUEST *response, AsyncHttpRequest *p
std::string role = member["role"].as_string();
AddChatContact(chatId, username, username, role.c_str(), true);
}
- PushRequest(new GetHistoryRequest(chatId, 15, true, 0, this));
+ PushRequest(new GetHistoryRequest(chatId, 15, true, 0));
}
void CSkypeProto::RenameChat(const char *chat_id, const char *name)
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index 70e556aec3..9ae5cb008c 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -199,7 +199,7 @@ void CSkypeProto::LoadContactList(NETLIBHTTPREQUEST *response, AsyncHttpRequest*
}
}
- PushRequest(new GetContactsAuthRequest(this));
+ PushRequest(new GetContactsAuthRequest());
}
INT_PTR CSkypeProto::OnRequestAuth(WPARAM hContact, LPARAM)
@@ -207,7 +207,7 @@ INT_PTR CSkypeProto::OnRequestAuth(WPARAM hContact, LPARAM)
if (hContact == INVALID_CONTACT_ID)
return 1;
- PushRequest(new AddContactRequest(this, getId(hContact)));
+ PushRequest(new AddContactRequest(getId(hContact)));
return 0;
}
@@ -216,7 +216,7 @@ INT_PTR CSkypeProto::OnGrantAuth(WPARAM hContact, LPARAM)
if (hContact == INVALID_CONTACT_ID)
return 1;
- PushRequest(new AuthAcceptRequest(this, getId(hContact)));
+ PushRequest(new AuthAcceptRequest(getId(hContact)));
return 0;
}
@@ -224,7 +224,7 @@ void CSkypeProto::OnContactDeleted(MCONTACT hContact)
{
if (IsOnline())
if (hContact && !isChatRoom(hContact))
- PushRequest(new DeleteContactRequest(this, getId(hContact)));
+ PushRequest(new DeleteContactRequest(getId(hContact)));
}
INT_PTR CSkypeProto::BlockContact(WPARAM hContact, LPARAM)
diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp
index 1138f943e8..c5b3aa348c 100644
--- a/protocols/SkypeWeb/src/skype_db.cpp
+++ b/protocols/SkypeWeb/src/skype_db.cpp
@@ -67,29 +67,21 @@ void CSkypeProto::EditEvent(MCONTACT hContact, MEVENT hEvent, const char *szCont
return;
JSONNode jEdit;
- jEdit
- << JSONNode("time", (long)edit_time)
- << JSONNode("text", szContent);
-
+ jEdit << INT_PARAM("time", (long)edit_time) << CHAR_PARAM("text", szContent);
jEdits << jEdit;
}
}
else {
- jMsg = JSONNode();
JSONNode jOriginalMsg; jOriginalMsg.set_name("original_message");
- JSONNode jEdits(JSON_ARRAY); jEdits.set_name("edits");
- JSONNode jEdit;
-
- jOriginalMsg
- << JSONNode("time", (long)dbei.timestamp)
- << JSONNode("text", (char*)dbei.pBlob);
+ jOriginalMsg << INT_PARAM("time", (long)dbei.timestamp) << CHAR_PARAM("text", (char *)dbei.pBlob);
+ jMsg = JSONNode();
jMsg << jOriginalMsg;
- jEdit
- << JSONNode("time", (long)edit_time)
- << JSONNode("text", szContent);
+ JSONNode jEdit;
+ jEdit << INT_PARAM("time", (long)edit_time) << CHAR_PARAM("text", szContent);
+ JSONNode jEdits(JSON_ARRAY); jEdits.set_name("edits");
jEdits << jEdit;
jMsg << jEdits;
}
diff --git a/protocols/SkypeWeb/src/skype_files.cpp b/protocols/SkypeWeb/src/skype_files.cpp
index 158ba0c25e..8f0c94eaa7 100644
--- a/protocols/SkypeWeb/src/skype_files.cpp
+++ b/protocols/SkypeWeb/src/skype_files.cpp
@@ -104,7 +104,7 @@ void CSkypeProto::OnASMObjectUploaded(NETLIBHTTPREQUEST *response, AsyncHttpRequ
tinyxml2::XMLPrinter printer(0, true);
doc.Print(&printer);
- SendRequest(new SendMessageRequest(getId(fup->hContact), time(NULL), printer.CStr(), this, "RichText/Media_GenericFile"));
+ SendRequest(new SendMessageRequest(getId(fup->hContact), time(NULL), printer.CStr(), "RichText/Media_GenericFile"));
ProtoBroadcastAck(fup->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (HANDLE)fup);
delete fup;
diff --git a/protocols/SkypeWeb/src/skype_history_sync.cpp b/protocols/SkypeWeb/src/skype_history_sync.cpp
index 20cdd9850a..17f0f901eb 100644
--- a/protocols/SkypeWeb/src/skype_history_sync.cpp
+++ b/protocols/SkypeWeb/src/skype_history_sync.cpp
@@ -35,7 +35,7 @@ void CSkypeProto::OnGetServerHistory(NETLIBHTTPREQUEST *response, AsyncHttpReque
bool markAllAsUnread = getBool("MarkMesUnread", true);
if (totalCount >= 99 || conversations.size() >= 99)
- PushRequest(new GetHistoryOnUrlRequest(syncState.c_str(), this));
+ PushRequest(new GetHistoryOnUrlRequest(syncState.c_str()));
for (int i = (int)conversations.size(); i >= 0; i--) {
const JSONNode &message = conversations.at(i);
@@ -102,9 +102,16 @@ void CSkypeProto::OnGetServerHistory(NETLIBHTTPREQUEST *response, AsyncHttpReque
}
}
+void CSkypeProto::ReadHistoryRest(const char *szUrl)
+{
+ auto *p = strstr(szUrl, g_plugin.szDefaultServer);
+ if (p)
+ PushRequest(new SyncHistoryFirstRequest(p+ g_plugin.szDefaultServer.GetLength()+3));
+}
+
INT_PTR CSkypeProto::GetContactHistory(WPARAM hContact, LPARAM)
{
- PushRequest(new GetHistoryRequest(getId(hContact), 100, false, 0, this));
+ PushRequest(new GetHistoryRequest(getId(hContact), 100, false, 0));
return 0;
}
@@ -122,7 +129,7 @@ void CSkypeProto::OnSyncHistory(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
std::string syncState = metadata["syncState"].as_string();
if (totalCount >= 99 || conversations.size() >= 99)
- PushRequest(new SyncHistoryFirstRequest(syncState.c_str(), this));
+ ReadHistoryRest(syncState.c_str());
for (auto &conversation : conversations) {
const JSONNode &lastMessage = conversation["lastMessage"];
@@ -136,7 +143,7 @@ void CSkypeProto::OnSyncHistory(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
MCONTACT hContact = FindContact(szSkypename);
if (hContact != NULL)
if (getDword(hContact, "LastMsgTime", 0) < composeTime)
- PushRequest(new GetHistoryRequest(szSkypename, 100, false, 0, this));
+ PushRequest(new GetHistoryRequest(szSkypename, 100, false, 0));
}
}
}
diff --git a/protocols/SkypeWeb/src/skype_login.cpp b/protocols/SkypeWeb/src/skype_login.cpp
index 9918acc54a..316607151c 100644
--- a/protocols/SkypeWeb/src/skype_login.cpp
+++ b/protocols/SkypeWeb/src/skype_login.cpp
@@ -184,11 +184,11 @@ void CSkypeProto::OnEndpointCreated(NETLIBHTTPREQUEST *response, AsyncHttpReques
}
if (auto *hdr = Netlib_GetHeader(response, "Location"))
- m_szServer = GetServerFromUrl(hdr).Detach();
+ g_plugin.szDefaultServer = GetServerFromUrl(hdr);
RefreshStatuses();
- SendRequest(new CreateSubscriptionsRequest(this));
+ SendRequest(new CreateSubscriptionsRequest());
}
void CSkypeProto::OnSubscriptionsCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
@@ -236,26 +236,25 @@ void CSkypeProto::OnCapabilitiesSended(NETLIBHTTPREQUEST *response, AsyncHttpReq
return;
}
- SendRequest(new SetStatusRequest(MirandaToSkypeStatus(m_iDesiredStatus), this));
+ SendRequest(new SetStatusRequest(MirandaToSkypeStatus(m_iDesiredStatus)));
LIST<char> skypenames(1);
for (auto &hContact : AccContacts())
if (!isChatRoom(hContact))
skypenames.insert(getStringA(hContact, SKYPE_SETTINGS_ID));
- SendRequest(new CreateContactsSubscriptionRequest(skypenames, this));
+ SendRequest(new CreateContactsSubscriptionRequest(skypenames));
FreeList(skypenames);
skypenames.destroy();
m_hPollingEvent.Set();
- SendRequest(new LoadChatsRequest(this));
- SendRequest(new CreateTrouterRequest());
+ SendRequest(new LoadChatsRequest());
PushRequest(new GetContactListRequest(this, nullptr));
PushRequest(new GetAvatarRequest(ptrA(getStringA("AvatarUrl")), 0));
if (m_opts.bAutoHistorySync)
- PushRequest(new SyncHistoryFirstRequest(100, this));
+ PushRequest(new SyncHistoryFirstRequest(100));
JSONNode root = JSONNode::parse(response->pData);
if (root)
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index d5cd19f31d..477c271be7 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -38,7 +38,7 @@ int CSkypeProto::OnSendMessage(MCONTACT hContact, int, const char *szMessage)
if (strncmp(szMessage, "/me ", 4) == 0)
pReq = new SendActionRequest(username, param->hMessage, &szMessage[4], this);
else
- pReq = new SendMessageRequest(username, param->hMessage, szMessage, this);
+ pReq = new SendMessageRequest(username, param->hMessage, szMessage);
pReq->pUserInfo = param;
SendRequest(pReq);
{
@@ -185,7 +185,7 @@ void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent)
time_t timestamp = dbei.timestamp;
if (db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0) > (timestamp - 300))
- PushRequest(new MarkMessageReadRequest(getId(hContact), timestamp, timestamp, false, this));
+ PushRequest(new MarkMessageReadRequest(getId(hContact), timestamp, timestamp, false));
}
void CSkypeProto::ProcessContactRecv(MCONTACT hContact, time_t timestamp, const char *szContent, const char *szMessageId)
diff --git a/protocols/SkypeWeb/src/skype_network.cpp b/protocols/SkypeWeb/src/skype_network.cpp
index 2326aee297..a982b70346 100644
--- a/protocols/SkypeWeb/src/skype_network.cpp
+++ b/protocols/SkypeWeb/src/skype_network.cpp
@@ -27,14 +27,3 @@ void CSkypeProto::InitNetwork()
nlu.szSettingsModule = m_szModuleName;
m_hNetlibUser = Netlib_RegisterUser(&nlu);
}
-
-void CSkypeProto::UnInitNetwork()
-{
- ShutdownConnections();
-}
-
-void CSkypeProto::ShutdownConnections()
-{
- Netlib_CloseHandle(m_TrouterConnection);
- m_TrouterConnection = nullptr;
-} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index efa4383d7e..e910c856e1 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -24,11 +24,9 @@ CSkypeProto::CSkypeProto(const char* protoName, const wchar_t* userName) :
m_GCCreateDialogs(1),
m_OutMessages(3, PtrKeySortT),
m_bThreadsTerminated(false),
- m_TrouterConnection(nullptr),
m_opts(this),
m_impl(*this),
- m_requests(1),
- m_szServer(mir_strdup("azeus1-client-s.gateway.messenger.live.com"))
+ m_requests(1)
{
InitNetwork();
@@ -41,9 +39,6 @@ CSkypeProto::CSkypeProto(const char* protoName, const wchar_t* userName) :
CreateProtoService(PS_MENU_REQAUTH, &CSkypeProto::OnRequestAuth);
CreateProtoService(PS_MENU_GRANTAUTH, &CSkypeProto::OnGrantAuth);
- CreateProtoService("/IncomingCallCLE", &CSkypeProto::OnIncomingCallCLE);
- CreateProtoService("/IncomingCallPP", &CSkypeProto::OnIncomingCallPP);
-
HookProtoEvent(ME_OPT_INITIALISE, &CSkypeProto::OnOptionsInit);
HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CSkypeProto::OnDbEventRead);
@@ -55,7 +50,6 @@ CSkypeProto::CSkypeProto(const char* protoName, const wchar_t* userName) :
g_plugin.addSound("skype_call_canceled", L"SkypeWeb", LPGENW("Incoming call canceled"));
m_hPollingThread = ForkThreadEx(&CSkypeProto::PollingThread, NULL, NULL);
- m_hTrouterThread = ForkThreadEx(&CSkypeProto::TRouterThread, NULL, NULL);
}
CSkypeProto::~CSkypeProto()
@@ -66,18 +60,12 @@ CSkypeProto::~CSkypeProto()
m_hRequestQueueThread = nullptr;
}
- UnInitNetwork();
UninitPopups();
if (m_hPollingThread) {
WaitForSingleObject(m_hPollingThread, INFINITE);
m_hPollingThread = nullptr;
}
-
- if (m_hTrouterThread) {
- WaitForSingleObject(m_hTrouterThread, INFINITE);
- m_hTrouterThread = nullptr;
- }
}
void CSkypeProto::OnModulesLoaded()
@@ -123,7 +111,7 @@ INT_PTR CSkypeProto::GetCaps(int type, MCONTACT)
int CSkypeProto::SetAwayMsg(int, const wchar_t *msg)
{
if (IsOnline())
- PushRequest(new SetStatusMsgRequest(msg ? T2Utf(msg) : "", this));
+ PushRequest(new SetStatusMsgRequest(msg ? T2Utf(msg) : ""));
return 0;
}
@@ -196,7 +184,7 @@ int CSkypeProto::Authorize(MEVENT hDbEvent)
if (hContact == INVALID_CONTACT_ID)
return 1;
- PushRequest(new AuthAcceptRequest(this, getId(hContact)));
+ PushRequest(new AuthAcceptRequest(getId(hContact)));
return 0;
}
@@ -206,7 +194,7 @@ int CSkypeProto::AuthDeny(MEVENT hDbEvent, const wchar_t*)
if (hContact == INVALID_CONTACT_ID)
return 1;
- PushRequest(new AuthDeclineRequest(this, getId(hContact)));
+ PushRequest(new AuthDeclineRequest(getId(hContact)));
return 0;
}
@@ -220,7 +208,7 @@ int CSkypeProto::AuthRequest(MCONTACT hContact, const wchar_t *szMessage)
if (hContact == INVALID_CONTACT_ID)
return 1;
- PushRequest(new AddContactRequest(this, getId(hContact), T2Utf(szMessage)));
+ PushRequest(new AddContactRequest(getId(hContact), T2Utf(szMessage)));
return 0;
}
@@ -289,7 +277,7 @@ int CSkypeProto::SetStatus(int iNewStatus)
Login();
}
else {
- SendRequest(new SetStatusRequest(MirandaToSkypeStatus(m_iDesiredStatus), this));
+ SendRequest(new SetStatusRequest(MirandaToSkypeStatus(m_iDesiredStatus)));
}
}
@@ -299,7 +287,7 @@ int CSkypeProto::SetStatus(int iNewStatus)
int CSkypeProto::UserIsTyping(MCONTACT hContact, int type)
{
- SendRequest(new SendTypingRequest(getId(hContact), type, this));
+ SendRequest(new SendTypingRequest(getId(hContact), type));
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 32d68de785..826fdf4860 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -43,10 +43,6 @@ struct CSkypeProto : public PROTO <CSkypeProto>
} m_impl;
public:
-
- //////////////////////////////////////////////////////////////////////////////////////
- //Ctors
-
CSkypeProto(const char *protoName, const wchar_t *userName);
~CSkypeProto();
@@ -102,7 +98,7 @@ public:
CSkypeOptions m_opts;
int m_iPollingId;
- ptrA m_szApiToken, m_szToken, m_szId, m_szServer;
+ ptrA m_szApiToken, m_szToken, m_szId;
CMStringA m_szSkypename, m_szMyname;
__forceinline CMStringA getId(MCONTACT hContact) {
@@ -126,15 +122,9 @@ public:
void OnOAuthAuthorize(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnOAuthEnd(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
- void OnCreateTrouter(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
- void OnTrouterPoliciesCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
- void OnGetTrouter(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
- void OnHealth(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
-
void OnASMObjectCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void OnASMObjectUploaded(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
-
void LoadContactsAuth(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
void LoadContactList(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
@@ -158,10 +148,7 @@ private:
std::map<std::string, std::string> cookies;
static std::map<std::wstring, std::wstring> languages;
- HNETLIBCONN m_TrouterConnection;
- HANDLE m_hPollingThread, m_hTrouterThread;
-
- TRInfo TRouter;
+ HANDLE m_hPollingThread;
LIST<void> m_PopupClasses;
LIST<void> m_OutMessages;
@@ -195,11 +182,8 @@ private:
INT_PTR __cdecl SvcSetMyAvatar(WPARAM, LPARAM);
// requests
-
void InitNetwork();
- void UnInitNetwork();
- void ShutdownConnections();
-
+
bool m_isTerminated = true;
mir_cs m_requestQueueLock;
LIST<AsyncHttpRequest> m_requests;
@@ -231,10 +215,6 @@ private:
void OnLoginSuccess();
void SendPresence(bool isLogin = false);
- // TRouter
- void OnTrouterEvent(const JSONNode &body, const JSONNode &headers);
- void __cdecl TRouterThread(void*);
-
// profile
void UpdateProfileFirstName(const JSONNode &root, MCONTACT hContact = NULL);
void UpdateProfileLastName(const JSONNode &root, MCONTACT hContact = NULL);
@@ -321,6 +301,7 @@ private:
void ProcessConversationUpdate(const JSONNode &node);
void RefreshStatuses(void);
+ void ReadHistoryRest(const char *url);
// utils
template <typename T>
@@ -365,8 +346,6 @@ private:
void InitDBEvents();
//services
- INT_PTR __cdecl OnIncomingCallCLE(WPARAM wParam, LPARAM lParam);
- INT_PTR __cdecl OnIncomingCallPP(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl BlockContact(WPARAM hContact, LPARAM);
INT_PTR __cdecl UnblockContact(WPARAM hContact, LPARAM);
INT_PTR __cdecl OnRequestAuth(WPARAM hContact, LPARAM lParam);
@@ -384,19 +363,4 @@ private:
}
};
-struct AsyncHttpRequest : public MTHttpRequest<CSkypeProto>
-{
- AsyncHttpRequest(int type, LPCSTR url = nullptr, MTHttpRequestHandler pFunc = nullptr);
-
- void AddRegistrationToken(CSkypeProto *ppro);
-};
-
-struct CMPlugin : public ACCPROTOPLUGIN<CSkypeProto>
-{
- CMPlugin();
-
- int Load() override;
- int Unload() override;
-};
-
#endif //_SKYPE_PROTO_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp
index b361845bbc..7ec04060ec 100644
--- a/protocols/SkypeWeb/src/skype_search.cpp
+++ b/protocols/SkypeWeb/src/skype_search.cpp
@@ -27,7 +27,7 @@ void CSkypeProto::SearchBasicThread(void *id)
{
debugLogA("CSkypeProto::OnSearchBasicThread");
if (IsOnline())
- SendRequest(new GetSearchRequest(mir_urlEncode(T2Utf((wchar_t *)id)), this));
+ SendRequest(new GetSearchRequest(mir_urlEncode(T2Utf((wchar_t *)id))));
}
void CSkypeProto::OnSearch(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp
index 550ff54f2b..2a698af42b 100644
--- a/protocols/SkypeWeb/src/skype_trouter.cpp
+++ b/protocols/SkypeWeb/src/skype_trouter.cpp
@@ -57,7 +57,7 @@ void CSkypeProto::RefreshStatuses(void)
continue;
if (pReq == nullptr) {
- pReq = new GetStatusRequest(this);
+ pReq = new GetStatusRequest();
nRecs = 0;
}
@@ -73,203 +73,3 @@ void CSkypeProto::RefreshStatuses(void)
if (pReq)
PushRequest(pReq);
}
-
-void CSkypeProto::OnCreateTrouter(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
-{
- JsonReply reply(response);
- if (reply.error()) {
-LBL_Error:
- debugLogA("Failed to establish a TRouter connection.");
- return;
- }
-
- auto &root = reply.data();
- const JSONNode &ccid = root["ccid"];
- const JSONNode &connId = root["connId"];
- const JSONNode &instance = root["instance"];
- const JSONNode &socketio = root["socketio"];
- const JSONNode &url = root["url"];
-
- if (!ccid || !connId || !instance || !socketio || !url)
- goto LBL_Error;
-
- TRouter.ccid = ccid.as_string();
- TRouter.connId = connId.as_string();
- TRouter.instance = instance.as_string();
- TRouter.socketIo = socketio.as_string();
- TRouter.url = url.as_string();
-
- SendRequest(new CreateTrouterPoliciesRequest(this, TRouter.connId.c_str()));
-}
-
-void CSkypeProto::OnTrouterPoliciesCreated(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
-{
- JsonReply reply(response);
- if (reply.error()) {
-LBL_Error:
- debugLogA("Failed to establish a TRouter connection.");
- return;
- }
-
- auto &root = reply.data();
- const JSONNode &st = root["st"];
- const JSONNode &se = root["se"];
- const JSONNode &sig = root["sig"];
-
- if (!st || !se || !sig)
- goto LBL_Error;
-
- TRouter.st = st.as_string();
- TRouter.se = se.as_string();
- TRouter.sig = sig.as_string();
- SendRequest(new GetTrouterRequest(TRouter.socketIo, TRouter.connId, TRouter.st, TRouter.se, TRouter.sig, TRouter.instance, TRouter.ccid));
-}
-
-void CSkypeProto::OnGetTrouter(NETLIBHTTPREQUEST *response, AsyncHttpRequest*)
-{
- if (response == nullptr || response->pData == nullptr) {
- debugLogA("Failed to establish a TRouter connection.");
- return;
- }
-
- CMStringA data(response->pData);
- int iStart = 0;
- CMStringA szToken = data.Tokenize(":", iStart).Trim();
- TRouter.sessId = szToken.GetString();
-
- m_hTrouterEvent.Set();
- m_hTrouterHealthEvent.Set();
-
- if ((time(0) - TRouter.lastRegistrationTime) >= 3600) {
- SendRequest(new RegisterTrouterRequest(this, TRouter.url.c_str(), TRouter.sessId.c_str()));
- TRouter.lastRegistrationTime = time(0);
- }
-}
-
-void CSkypeProto::OnHealth(NETLIBHTTPREQUEST *, AsyncHttpRequest *)
-{
- SendRequest(new GetTrouterRequest(TRouter.socketIo, TRouter.connId, TRouter.st, TRouter.se, TRouter.sig, TRouter.instance, TRouter.ccid));
-}
-
-void CSkypeProto::TRouterThread(void*)
-{
- debugLogA(__FUNCTION__": entering");
-
- while (true) {
- m_hTrouterEvent.Wait();
- if (m_bThreadsTerminated)
- break;
-
- int errors = 0;
-
- TrouterPollRequest *request = new TrouterPollRequest(TRouter.socketIo, TRouter.connId, TRouter.st, TRouter.se, TRouter.sig, TRouter.instance, TRouter.ccid, TRouter.sessId);
-
- while (errors < POLLING_ERRORS_LIMIT && m_iStatus > ID_STATUS_OFFLINE) {
- request->nlc = m_TrouterConnection;
- NLHR_PTR response(DoSend(request));
-
- if (response == NULL) {
- m_TrouterConnection = nullptr;
- errors++;
- continue;
- }
-
- if (response->resultCode == 200) {
- errors = 0;
-
- if (response->pData) {
- char *json = strchr(response->pData, '{');
- if (json != NULL) {
- JSONNode root = JSONNode::parse(json);
- std::string szBody = root["body"].as_string();
- const JSONNode &headers = root["headers"];
- const JSONNode body = JSONNode::parse(szBody.c_str());
- OnTrouterEvent(body, headers);
- }
- }
- }
- else {
- errors++;
-
- SendRequest(new HealthTrouterRequest(TRouter.ccid.c_str()));
- m_hTrouterHealthEvent.Wait();
- }
- m_TrouterConnection = response->nlc;
- }
- delete request;
-
- if (m_iStatus != ID_STATUS_OFFLINE) {
- debugLogA(__FUNCTION__ ": unexpected termination; switching protocol to offline");
- SetStatus(ID_STATUS_OFFLINE);
- }
- }
- m_hTrouterThread = nullptr;
- m_TrouterConnection = nullptr;
- debugLogA(__FUNCTION__": leaving");
-}
-
-void CSkypeProto::OnTrouterEvent(const JSONNode &body, const JSONNode &)
-{
- //std::string displayname = body["displayName"].as_string();
- //std::string cuid = body["callerId"].as_string();
- std::string uid = body["conversationId"].as_string();
- std::string gp = body["gp"].as_string();
- int evt = body["evt"].as_int();
-
- switch (evt) {
- case 100: //incoming call
- {
- std::string callId = body["convoCallId"].as_string();
- if (!uid.empty()) {
- MCONTACT hContact = AddContact(uid.c_str(), true);
-
- MEVENT hEvent = AddDbEvent(SKYPE_DB_EVENT_TYPE_INCOMING_CALL, hContact, time(0), DBEF_READ, gp.c_str(), callId.c_str());
- Skin_PlaySound("skype_inc_call");
-
- CLISTEVENT cle = {};
- cle.flags = CLEF_UNICODE;
- cle.hContact = hContact;
- cle.hDbEvent = hEvent;
- cle.lParam = SKYPE_DB_EVENT_TYPE_INCOMING_CALL;
- cle.hIcon = g_plugin.getIcon(IDI_CALL);
-
- CMStringA service(FORMAT, "%s/IncomingCallCLE", Proto_GetBaseAccountName(hContact));
- cle.pszService = service.GetBuffer();
-
- CMStringW tooltip(FORMAT, TranslateT("Incoming call from %s"), Clist_GetContactDisplayName(hContact));
- cle.szTooltip.w = tooltip.GetBuffer();
- g_clistApi.pfnAddEvent(&cle);
-
- ShowNotification(Clist_GetContactDisplayName(hContact), TranslateT("Incoming call"), hContact, SKYPE_DB_EVENT_TYPE_INCOMING_CALL);
- }
- }
- break;
-
- case 104: //call canceled: callerId=""; conversationId=NULL; callId=call id
- // std::string callId = body["callId"].as_string();
- Skin_PlaySound("skype_call_canceled");
- break;
- }
-}
-
-INT_PTR CSkypeProto::OnIncomingCallCLE(WPARAM, LPARAM lParam)
-{
- CLISTEVENT *cle = (CLISTEVENT*)lParam;
- NotifyEventHooks(g_hCallEvent, (WPARAM)cle->hContact, (LPARAM)0);
- return 0;
-}
-
-INT_PTR CSkypeProto::OnIncomingCallPP(WPARAM wParam, LPARAM hContact)
-{
- while (CLISTEVENT *cle = g_clistApi.pfnGetEvent(hContact, 0)) {
- if (cle->lParam == SKYPE_DB_EVENT_TYPE_INCOMING_CALL) {
- g_clistApi.pfnRemoveEvent(hContact, cle->hDbEvent);
- break;
- }
- }
-
- if (wParam == 1)
- NotifyEventHooks(g_hCallEvent, (WPARAM)hContact, (LPARAM)0);
-
- return 0;
-}
diff --git a/protocols/SkypeWeb/src/skype_trouter.h b/protocols/SkypeWeb/src/skype_trouter.h
deleted file mode 100644
index f7229ad04e..0000000000
--- a/protocols/SkypeWeb/src/skype_trouter.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-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_TROUTER_H_
-#define _SKYPE_TROUTER_H_
-
-#endif //_SKYPE_TROUTER_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index f99f8bf8ac..c0ab50c155 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -603,50 +603,26 @@ INT_PTR CSkypeProto::GlobalParseSkypeUriService(WPARAM wParam, LPARAM lParam)
/////////////////////////////////////////////////////////////////////////////////////////
-AsyncHttpRequest::AsyncHttpRequest(int type, LPCSTR url, MTHttpRequestHandler pFunc)
+AsyncHttpRequest::AsyncHttpRequest(int type, SkypeHost host, LPCSTR url, MTHttpRequestHandler pFunc) :
+ m_host(host)
{
+ switch (host) {
+ case HOST_API: m_szUrl = "https://api.skype.com"; break;
+ case HOST_CONTACTS: m_szUrl = "https://contacts.skype.com"; break;
+ case HOST_GRAPH: m_szUrl = "https://skypegraph.skype.com"; break;
+ case HOST_LOGIN: m_szUrl = "https://login.skype.com"; break;
+ case HOST_DEFAULT:
+ m_szUrl.Format("https://%s/v1", g_plugin.szDefaultServer.c_str());
+ break;
+ }
+
if (url)
- m_szUrl = url;
+ m_szUrl.Append(url);
m_pFunc = pFunc;
flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_DUMPASTEXT;
requestType = type;
}
-void AsyncHttpRequest::AddRegistrationToken(CSkypeProto *ppro)
-{
- AddHeader("RegistrationToken", CMStringA(FORMAT, "registrationToken=%s", ppro->m_szToken.get()));
-}
-
-NETLIBHTTPREQUEST* CSkypeProto::DoSend(AsyncHttpRequest *pReq)
-{
- if (pReq->m_szUrl[0] == '/') {
- pReq->m_szUrl.Insert(0, "/v1"); // current API version
- pReq->m_szUrl.Insert(0, m_szServer);
- }
-
- if (pReq->m_szUrl.Find("://") == -1)
- pReq->m_szUrl.Insert(0, ((pReq->flags & NLHRF_SSL) ? "https://" : "http://"));
-
- if (!pReq->m_szParam.IsEmpty()) {
- switch (pReq->requestType) {
- case REQUEST_GET:
- case REQUEST_DELETE:
- pReq->m_szUrl.AppendChar('?');
- pReq->m_szUrl.Append(pReq->m_szParam.c_str());
- break;
-
- default:
- pReq->pData = pReq->m_szParam.Detach();
- pReq->dataLength = (int)mir_strlen(pReq->pData);
- }
- }
-
- pReq->szUrl = pReq->m_szUrl.GetBuffer();
- debugLogA("Send request to %s", pReq->szUrl);
-
- return Netlib_HttpTransaction(m_hNetlibUser, pReq);
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
JsonReply::JsonReply(NETLIBHTTPREQUEST *pReply)
diff --git a/protocols/SkypeWeb/src/stdafx.h b/protocols/SkypeWeb/src/stdafx.h
index 961e9824cc..82d3253a81 100644
--- a/protocols/SkypeWeb/src/stdafx.h
+++ b/protocols/SkypeWeb/src/stdafx.h
@@ -61,37 +61,53 @@ struct CSkypeProto;
extern char g_szMirVer[];
extern HANDLE g_hCallEvent;
-struct TRInfo
-{
- std::string socketIo,
- connId,
- st,
- se,
- instance,
- ccid,
- sessId,
- sig,
- url;
- time_t lastRegistrationTime;
-};
-
struct MessageId
{
ULONGLONG id;
HANDLE handle;
};
+struct CMPlugin : public ACCPROTOPLUGIN<CSkypeProto>
+{
+ CMPlugin();
+
+ CMStringA szDefaultServer;
+
+ int Load() override;
+ int Unload() override;
+};
#include "version.h"
#include "resource.h"
#include "skype_menus.h"
#include "skype_dialogs.h"
#include "skype_options.h"
-#include "skype_trouter.h"
#include "skype_utils.h"
#include "skype_db.h"
#include "skype_proto.h"
+/////////////////////////////////////////////////////////////////////////////////////////
+
+#define SKYPEWEB_CLIENTINFO_NAME "swx-skype.com"
+#define SKYPEWEB_CLIENTINFO_VERSION "908/1.85.0.29"
+
+enum SkypeHost
+{
+ HOST_API,
+ HOST_CONTACTS,
+ HOST_DEFAULT,
+ HOST_GRAPH,
+ HOST_LOGIN,
+ HOST_OTHER
+};
+
+struct AsyncHttpRequest : public MTHttpRequest<CSkypeProto>
+{
+ SkypeHost m_host;
+
+ AsyncHttpRequest(int type, SkypeHost host, LPCSTR url = nullptr, MTHttpRequestHandler pFunc = nullptr);
+};
+
#include "requests/avatars.h"
#include "requests/capabilities.h"
#include "requests/chatrooms.h"
@@ -107,7 +123,6 @@ struct MessageId
#include "requests/search.h"
#include "requests/status.h"
#include "requests/subscriptions.h"
-#include "requests/trouter.h"
#define MODULE "Skype"