diff options
author | George Hazan <ghazan@miranda.im> | 2020-12-20 16:52:04 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-12-20 16:52:04 +0300 |
commit | e8f02156813b7153d4970fd83f2e6adac3517923 (patch) | |
tree | 49632cf70e8dc0f6b464a0bbc6e06e0c88c2ca90 /protocols/SkypeWeb/src/requests | |
parent | ab6c868bccb088d493ab4016fd1918d822adfc2b (diff) |
SkypeWeb: protocol reworked almost from scratch to support contact types other than 8 & 19
Diffstat (limited to 'protocols/SkypeWeb/src/requests')
-rw-r--r-- | protocols/SkypeWeb/src/requests/chatrooms.h | 13 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/requests/contacts.h | 12 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/requests/files.h | 2 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/requests/history.h | 4 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/requests/login.h | 8 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/requests/messages.h | 6 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/requests/oauth.h | 3 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/requests/subscriptions.h | 2 |
8 files changed, 28 insertions, 22 deletions
diff --git a/protocols/SkypeWeb/src/requests/chatrooms.h b/protocols/SkypeWeb/src/requests/chatrooms.h index aa39995f01..921f6b2519 100644 --- a/protocols/SkypeWeb/src/requests/chatrooms.h +++ b/protocols/SkypeWeb/src/requests/chatrooms.h @@ -68,8 +68,7 @@ struct CreateChatroomRequest : public AsyncHttpRequest for (auto &it : skypenames) {
JSONNode member;
- member << CHAR_PARAM("id", CMStringA(::FORMAT, "8:%s", it).GetBuffer())
- << CHAR_PARAM("role", !mir_strcmpi(it, ppro->m_szSkypename) ? "Admin" : "User");
+ member << CHAR_PARAM("id", it) << CHAR_PARAM("role", !mir_strcmpi(it, ppro->m_szSkypename) ? "Admin" : "User");
members << member;
}
node << members;
@@ -79,10 +78,10 @@ struct CreateChatroomRequest : public AsyncHttpRequest struct GetChatInfoRequest : public AsyncHttpRequest
{
- GetChatInfoRequest(const char *chatId, const CMStringW topic) :
+ GetChatInfoRequest(const char *chatId, const CMStringW &topic) :
AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, 0, &CSkypeProto::OnGetChatInfo)
{
- m_szUrl.AppendFormat("/threads/%s%s", strstr(chatId, "19:") == chatId ? "" : "19:", chatId);
+ m_szUrl.AppendFormat("/threads/%s", chatId);
pUserInfo = topic.Detach();
this << CHAR_PARAM("view", "msnp24Equivalent");
@@ -94,7 +93,7 @@ struct InviteUserToChatRequest : public AsyncHttpRequest InviteUserToChatRequest(const char *chatId, const char *skypename, const char *role) :
AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT)
{
- m_szUrl.AppendFormat("/threads/19:%s/members/8:%s", chatId, skypename);
+ m_szUrl.AppendFormat("/threads/%s/members/%s", chatId, skypename);
JSONNode node;
node << CHAR_PARAM("role", role);
@@ -107,7 +106,7 @@ struct KickUserRequest : public AsyncHttpRequest KickUserRequest(const char *chatId, const char *skypename) :
AsyncHttpRequest(REQUEST_DELETE, HOST_DEFAULT)
{
- m_szUrl.AppendFormat("/threads/19:%s/members/8:%s", chatId, skypename);
+ m_szUrl.AppendFormat("/threads/%s/members/%s", chatId, skypename);
}
};
@@ -116,7 +115,7 @@ struct SetChatPropertiesRequest : public AsyncHttpRequest SetChatPropertiesRequest(const char *chatId, const char *propname, const char *value) :
AsyncHttpRequest(REQUEST_PUT, HOST_DEFAULT)
{
- m_szUrl.AppendFormat("/threads/19:%s/properties?name=%s", chatId, propname);
+ m_szUrl.AppendFormat("/threads/%s/properties?name=%s", chatId, propname);
JSONNode node;
node << CHAR_PARAM(propname, value);
diff --git a/protocols/SkypeWeb/src/requests/contacts.h b/protocols/SkypeWeb/src/requests/contacts.h index 5791d96517..d66eb1476d 100644 --- a/protocols/SkypeWeb/src/requests/contacts.h +++ b/protocols/SkypeWeb/src/requests/contacts.h @@ -48,7 +48,7 @@ struct AddContactRequest : public AsyncHttpRequest AddHeader("Accept", "application/json");
JSONNode node;
- node << CHAR_PARAM("mri", CMStringA(::FORMAT, "8:%s", who)) << CHAR_PARAM("greeting", greeting);
+ node << CHAR_PARAM("mri", who) << CHAR_PARAM("greeting", greeting);
m_szParam = node.write().c_str();
}
};
@@ -56,7 +56,7 @@ struct AddContactRequest : public AsyncHttpRequest struct DeleteContactRequest : public AsyncHttpRequest
{
DeleteContactRequest(const char *who) :
- AsyncHttpRequest(REQUEST_DELETE, HOST_CONTACTS, "/contacts/v2/users/SELF/contacts/8:" + mir_urlEncode(who))
+ AsyncHttpRequest(REQUEST_DELETE, HOST_CONTACTS, "/contacts/v2/users/SELF/contacts/" + mir_urlEncode(who))
{
AddHeader("Accept", "application/json");
}
@@ -67,7 +67,7 @@ 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);
+ m_szUrl.AppendFormat("/contacts/v2/users/SELF/invites/%s/accept", who);
AddHeader("Accept", "application/json");
}
@@ -78,7 +78,7 @@ 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);
+ m_szUrl.AppendFormat("/contacts/v2/users/SELF/invites/%s/decline", who);
AddHeader("Accept", "application/json");
}
@@ -89,7 +89,7 @@ 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_szUrl.AppendFormat("/contacts/v2/users/SELF/contacts/blocklist/%s", ppro->getId(hContact).c_str());
m_szParam = "{\"report_abuse\":\"false\",\"ui_version\":\"skype.com\"}";
pUserInfo = (void *)hContact;
@@ -102,7 +102,7 @@ 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());
+ m_szUrl.AppendFormat("/contacts/v2/users/SELF/contacts/blocklist/%s", ppro->getId(hContact).c_str());
pUserInfo = (void *)hContact;
AddHeader("Accept", "application/json");
diff --git a/protocols/SkypeWeb/src/requests/files.h b/protocols/SkypeWeb/src/requests/files.h index 6afd64d7f5..0b46644c7f 100644 --- a/protocols/SkypeWeb/src/requests/files.h +++ b/protocols/SkypeWeb/src/requests/files.h @@ -12,7 +12,7 @@ struct ASMObjectCreateRequest : public AsyncHttpRequest AddHeader("Content-Type", "text/json"); AddHeader("X-Client-Version", "0/0.0.0.0"); - CMStringA szContact(FORMAT, "%d:%s", ppro->isChatRoom(fup->hContact) ? 19 : 8, ppro->getId(fup->hContact).c_str()); + CMStringA szContact(ppro->getId(fup->hContact)); T2Utf uszFileName(fup->tszFileName); const char *szFileName = strrchr(uszFileName.get() + 1, '\\'); diff --git a/protocols/SkypeWeb/src/requests/history.h b/protocols/SkypeWeb/src/requests/history.h index 4c2394ed0c..6be005ae57 100644 --- a/protocols/SkypeWeb/src/requests/history.h +++ b/protocols/SkypeWeb/src/requests/history.h @@ -35,10 +35,10 @@ struct SyncHistoryFirstRequest : public AsyncHttpRequest struct GetHistoryRequest : public AsyncHttpRequest
{
- GetHistoryRequest(const char *username, int pageSize, bool isChat, LONGLONG timestamp) :
+ GetHistoryRequest(const char *username, int pageSize, LONGLONG timestamp) :
AsyncHttpRequest(REQUEST_GET, HOST_DEFAULT, 0, &CSkypeProto::OnGetServerHistory)
{
- m_szUrl.AppendFormat("/users/ME/conversations/%d:%s/messages", isChat ? 19 : 8, mir_urlEncode(username).c_str());
+ m_szUrl.AppendFormat("/users/ME/conversations/%s/messages", 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");
diff --git a/protocols/SkypeWeb/src/requests/login.h b/protocols/SkypeWeb/src/requests/login.h index da293572e5..fa3a9148c6 100644 --- a/protocols/SkypeWeb/src/requests/login.h +++ b/protocols/SkypeWeb/src/requests/login.h @@ -24,14 +24,18 @@ struct LoginOAuthRequest : public AsyncHttpRequest AsyncHttpRequest(REQUEST_POST, HOST_API, "/login/skypetoken", &CSkypeProto::OnLoginOAuth)
{
username.MakeLower();
- CMStringA hashStr(::FORMAT, "%s\nskyper\n%s", username.c_str(), password);
+ const char *pszLogin = username;
+ if (int iOffset = username.Find(':'))
+ pszLogin += iOffset + 1;
+
+ CMStringA hashStr(::FORMAT, "%s\nskyper\n%s", pszLogin, password);
BYTE digest[16];
mir_md5_hash((const BYTE*)hashStr.GetString(), hashStr.GetLength(), digest);
this << CHAR_PARAM("scopes", "client")
<< CHAR_PARAM("clientVersion", mir_urlEncode("0/7.4.85.102/259/").c_str())
- << CHAR_PARAM("username", mir_urlEncode(username).c_str())
+ << CHAR_PARAM("username", mir_urlEncode(pszLogin).c_str())
<< CHAR_PARAM("passwordHash", mir_urlEncode(ptrA(mir_base64_encode(digest, sizeof(digest)))).c_str());
}
};
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h index da5c37662e..e523b184c3 100644 --- a/protocols/SkypeWeb/src/requests/messages.h +++ b/protocols/SkypeWeb/src/requests/messages.h @@ -29,7 +29,7 @@ struct SendMessageRequest : public AsyncHttpRequest SendMessageRequest(const char *username, time_t timestamp, const char *message, const char *MessageType = nullptr) :
AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, 0, &CSkypeProto::OnMessageSent)
{
- m_szUrl.AppendFormat("/users/ME/conversations/8:%s/messages", username);
+ m_szUrl.AppendFormat("/users/ME/conversations/%s/messages", username);
JSONNode node;
node << INT64_PARAM("clientmessageid", timestamp) << CHAR_PARAM("messagetype", MessageType ? MessageType : "Text")
@@ -43,7 +43,7 @@ struct SendActionRequest : public AsyncHttpRequest SendActionRequest(const char *username, time_t timestamp, const char *message, CSkypeProto *ppro) :
AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, 0, &CSkypeProto::OnMessageSent)
{
- m_szUrl.AppendFormat("/users/ME/conversations/8:%s/messages", username);
+ m_szUrl.AppendFormat("/users/ME/conversations/%s/messages", username);
CMStringA content;
content.AppendFormat("%s %s", ppro->m_szSkypename.c_str(), message);
@@ -58,7 +58,7 @@ struct SendActionRequest : public AsyncHttpRequest struct SendTypingRequest : public AsyncHttpRequest
{
SendTypingRequest(const char *username, int iState) :
- AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, "/users/ME/conversations/8:" + mir_urlEncode(username) + "/messages")
+ AsyncHttpRequest(REQUEST_POST, HOST_DEFAULT, "/users/ME/conversations/" + mir_urlEncode(username) + "/messages")
{
const char *state = (iState == PROTOTYPE_SELFTYPING_ON) ? "Control/Typing" : "Control/ClearTyping";
diff --git a/protocols/SkypeWeb/src/requests/oauth.h b/protocols/SkypeWeb/src/requests/oauth.h index 32cee1ec76..ccd9a9d2fc 100644 --- a/protocols/SkypeWeb/src/requests/oauth.h +++ b/protocols/SkypeWeb/src/requests/oauth.h @@ -41,6 +41,9 @@ struct OAuthRequest : public AsyncHttpRequest AddHeader("Cookie", cookies); + if (auto *delim = strchr(login, ':')) + login = delim + 1; + this << CHAR_PARAM("login", login) << CHAR_PARAM("passwd", password) << CHAR_PARAM("PPFT", ppft); } diff --git a/protocols/SkypeWeb/src/requests/subscriptions.h b/protocols/SkypeWeb/src/requests/subscriptions.h index 1f8717e91d..19b8deb355 100644 --- a/protocols/SkypeWeb/src/requests/subscriptions.h +++ b/protocols/SkypeWeb/src/requests/subscriptions.h @@ -43,7 +43,7 @@ struct CreateContactsSubscriptionRequest : public AsyncHttpRequest JSONNode contacts(JSON_ARRAY); contacts.set_name("contacts");
for (auto &it : skypenames) {
JSONNode contact;
- contact << CHAR_PARAM("id", CMStringA(::FORMAT, "8:%s", it));
+ contact << CHAR_PARAM("id", it);
contacts << contact;
}
|