From f63eb2bfc28dff8bbf9d56dd57b2bc6b53487f56 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 29 May 2017 23:45:19 +0300 Subject: Skype: - fixes #829; - massive code cleaning --- protocols/SkypeWeb/src/skype_mslogin.cpp | 55 ++++++++++++-------------------- 1 file changed, 20 insertions(+), 35 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_mslogin.cpp') diff --git a/protocols/SkypeWeb/src/skype_mslogin.cpp b/protocols/SkypeWeb/src/skype_mslogin.cpp index 9f8a7e0f26..c0bf3036b8 100644 --- a/protocols/SkypeWeb/src/skype_mslogin.cpp +++ b/protocols/SkypeWeb/src/skype_mslogin.cpp @@ -19,8 +19,7 @@ along with this program. If not, see . void CSkypeProto::OnMSLoginFirst(const NETLIBHTTPREQUEST *response) { - if (response == NULL || response->pData == NULL) - { + if (response == NULL || response->pData == NULL) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); SetStatus(ID_STATUS_OFFLINE); return; @@ -33,16 +32,14 @@ void CSkypeProto::OnMSLoginFirst(const NETLIBHTTPREQUEST *response) regex = ""; - if (!std::regex_search(content, match, regex)) - { + if (!std::regex_search(content, match, regex)) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); SetStatus(ID_STATUS_OFFLINE); return; } std::string PPTF = match[1]; - - for (int i = 0; i < response->headersCount; i++) - { + + for (int i = 0; i < response->headersCount; i++) { if (mir_strcmpi(response->headers[i].szName, "Set-Cookie")) continue; @@ -54,13 +51,12 @@ void CSkypeProto::OnMSLoginFirst(const NETLIBHTTPREQUEST *response) CMStringA mscookies(FORMAT, "MSPRequ=%s;MSPOK=%s;CkTst=G%lld;", scookies["MSPRequ"].c_str(), scookies["MSPOK"].c_str(), time(NULL)); - SendRequest (new LoginMSRequest(ptrA(getStringA(SKYPE_SETTINGS_ID)), ptrA(getStringA(SKYPE_SETTINGS_PASSWORD)), mscookies.c_str(), PPTF.c_str()), &CSkypeProto::OnMSLoginSecond); + SendRequest(new LoginMSRequest(ptrA(getStringA(SKYPE_SETTINGS_ID)), ptrA(getStringA(SKYPE_SETTINGS_PASSWORD)), mscookies.c_str(), PPTF.c_str()), &CSkypeProto::OnMSLoginSecond); } void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response) { - if (response == NULL || response->pData == NULL) - { + if (response == NULL || response->pData == NULL) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); SetStatus(ID_STATUS_OFFLINE); return; @@ -72,13 +68,10 @@ void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response) ptrA szContent(response->pData); regex = ""; - if (std::regex_search(content, match, regex)) - { - if (match[1] == "i5600") - { + if (std::regex_search(content, match, regex)) { + if (match[1] == "i5600") { CMStringA szCookies; - for (int i = 0; i < response->headersCount; i++) - { + for (int i = 0; i < response->headersCount; i++) { if (mir_strcmpi(response->headers[i].szName, "Set-Cookie")) continue; @@ -91,7 +84,7 @@ void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response) CMStringA url(GetStringChunk(szContent, "urlPost:'", "'")); CMStringA ppft(GetStringChunk(szContent, "sFT:'", "'")); - + ptrA code(mir_utf8encodeW(RunConfirmationCode())); @@ -100,11 +93,8 @@ void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response) } } - regex = ""; - - if (!std::regex_search(content, match, regex)) - { + if (!std::regex_search(content, match, regex)) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); SetStatus(ID_STATUS_OFFLINE); return; @@ -116,8 +106,7 @@ void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response) void CSkypeProto::OnMSLoginThird(const NETLIBHTTPREQUEST *response) { - if (response == NULL || response->pData == NULL) - { + if (response == NULL || response->pData == NULL) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); SetStatus(ID_STATUS_OFFLINE); return; @@ -129,8 +118,7 @@ void CSkypeProto::OnMSLoginThird(const NETLIBHTTPREQUEST *response) regex = ""; - if (!std::regex_search(content, match, regex)) - { + if (!std::regex_search(content, match, regex)) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); SetStatus(ID_STATUS_OFFLINE); return; @@ -142,8 +130,7 @@ void CSkypeProto::OnMSLoginThird(const NETLIBHTTPREQUEST *response) void CSkypeProto::OnMSLoginEnd(const NETLIBHTTPREQUEST *response) { - if (response == NULL || response->pData == NULL) - { + if (response == NULL || response->pData == NULL) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); SetStatus(ID_STATUS_OFFLINE); return; @@ -153,19 +140,17 @@ void CSkypeProto::OnMSLoginEnd(const NETLIBHTTPREQUEST *response) std::smatch match; std::string content = response->pData; - regex = ""; - if (!std::regex_search(content, match, regex)) - { + regex = ""; + if (!std::regex_search(content, match, regex)) { ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGIN_ERROR_UNKNOWN); SetStatus(ID_STATUS_OFFLINE); return; } std::string token = match[1]; - setString("TokenSecret", token.c_str()); - regex = ""; + setString("TokenSecret", token.c_str()); + regex = ""; - if (std::regex_search(content, match, regex)) - { + if (std::regex_search(content, match, regex)) { std::string expiresIn = match[1]; int seconds = atoi(expiresIn.c_str()); setDword("TokenExpiresIn", time(NULL) + seconds); @@ -183,4 +168,4 @@ CMStringW CSkypeProto::RunConfirmationCode() pForm.ptszInitVal = NULL; pForm.szModuleName = m_szModuleName; return (!EnterString(&pForm)) ? CMStringW() : CMStringW(ptrW(pForm.ptszResult)); -} \ No newline at end of file +} -- cgit v1.2.3