summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_mslogin.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-05-29 23:45:19 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-05-29 23:45:19 +0300
commitf63eb2bfc28dff8bbf9d56dd57b2bc6b53487f56 (patch)
treef2c2a56e945fc1ea44d5f22f95cd397a0d251fa2 /protocols/SkypeWeb/src/skype_mslogin.cpp
parent133826f5022c5b0d9beca9285d66afcb604e2fc4 (diff)
Skype:
- fixes #829; - massive code cleaning
Diffstat (limited to 'protocols/SkypeWeb/src/skype_mslogin.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_mslogin.cpp55
1 files changed, 20 insertions, 35 deletions
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 <http://www.gnu.org/licenses/>.
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 = "<input type=\"hidden\" name=\"PPFT\" id=\"i0327\" value=\"(.+?)\"/>";
- 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 = "<meta name=\"PageID\" content=\"(.+?)\"/>";
- 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 = "<input type=\"hidden\" name=\"t\" id=\"t\" value=\"(.+?)\">";
-
- 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 = "<input type=\"hidden\" name=\"t\" value=\"(.+?)\"/>";
- 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 = "<input type=\"hidden\" name=\"skypetoken\" value=\"(.+?)\"/>";
- if (!std::regex_search(content, match, regex))
- {
+ regex = "<input type=\"hidden\" name=\"skypetoken\" value=\"(.+?)\"/>";
+ 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 = "<input type=\"hidden\" name=\"expires_in\" value=\"(.+?)\"/>";
+ setString("TokenSecret", token.c_str());
+ regex = "<input type=\"hidden\" name=\"expires_in\" value=\"(.+?)\"/>";
- 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
+}