diff options
author | George Hazan <ghazan@miranda.im> | 2019-01-03 20:06:56 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-01-03 20:07:18 +0300 |
commit | 5ce1ad352934754832199a375276328bb20a3b67 (patch) | |
tree | db290fa71e30521b5a9c06eb86d6a9793c9c5fdf /protocols | |
parent | 1692510f17043da142e2a000d3b714cd053605b3 (diff) |
fixes #1714 (ICQ10: phone number validator)
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Icq10/src/options.cpp | 27 | ||||
-rw-r--r-- | protocols/Icq10/src/proto.h | 1 |
2 files changed, 25 insertions, 3 deletions
diff --git a/protocols/Icq10/src/options.cpp b/protocols/Icq10/src/options.cpp index 9a39928596..67a2c03663 100644 --- a/protocols/Icq10/src/options.cpp +++ b/protocols/Icq10/src/options.cpp @@ -22,7 +22,7 @@ struct CIcqRegistrationDlg : public CProtoDlgBase<CIcqProto> { - CMStringA szTrans; + CMStringA szTrans, szMsisdn; int iErrorCode; CCtrlEdit edtPhone, edtCode; @@ -41,7 +41,7 @@ struct CIcqRegistrationDlg : public CProtoDlgBase<CIcqProto> bool OnApply() override { auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, "https://www.icq.com/smsreg/loginWithPhoneNumber.php", &CIcqProto::OnLoginViaPhone); - pReq << CHAR_PARAM("locale", "en") << WCHAR_PARAM("msisdn", ptrW(edtPhone.GetText())) << CHAR_PARAM("trans_id", szTrans) << CHAR_PARAM("k", ICQ_APP_ID) + pReq << CHAR_PARAM("locale", "en") << CHAR_PARAM("msisdn", szMsisdn) << CHAR_PARAM("trans_id", szTrans) << CHAR_PARAM("k", ICQ_APP_ID) << CHAR_PARAM("r", pReq->m_reqId) << CHAR_PARAM("f", "json") << WCHAR_PARAM("sms_code", ptrW(edtCode.GetText())) << INT_PARAM("create_account", 1); pReq->pUserInfo = this; @@ -68,7 +68,7 @@ struct CIcqRegistrationDlg : public CProtoDlgBase<CIcqProto> void onClick_SendSms(CCtrlButton*) { auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, "https://www.icq.com/smsreg/requestPhoneValidation.php", &CIcqProto::OnValidateSms); - pReq << CHAR_PARAM("locale", "en") << WCHAR_PARAM("msisdn", ptrW(edtPhone.GetText())) << CHAR_PARAM("r", pReq->m_reqId) + pReq << CHAR_PARAM("locale", "en") << CHAR_PARAM("msisdn", szMsisdn) << CHAR_PARAM("r", pReq->m_reqId) << CHAR_PARAM("smsFormatType", "human") << CHAR_PARAM("k", ICQ_APP_ID); pReq->pUserInfo = this; m_proto->Push(pReq); @@ -91,6 +91,27 @@ void CIcqProto::OnCheckPhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) return; } + CMStringA szPhoneNumber((*root)["typing_check"]["modified_phone_number"].as_mstring()); + CMStringA szPrefix((*root)["modified_prefix"].as_mstring()); + + auto *pNew = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, "https://www.icq.com/smsreg/normalizePhoneNumber.php", &CIcqProto::OnNormalizePhone); + pNew << CHAR_PARAM("countryCode", szPrefix) << CHAR_PARAM("phoneNumber", szPhoneNumber.c_str() + szPrefix.GetLength()) + << CHAR_PARAM("k", ICQ_APP_ID) << CHAR_PARAM("r", pReq->m_reqId); + pNew->pUserInfo = pDlg; + Push(pNew); +} + +void CIcqProto::OnNormalizePhone(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) +{ + CIcqRegistrationDlg *pDlg = (CIcqRegistrationDlg*)pReq->pUserInfo; + + JsonReply root(pReply); + pDlg->iErrorCode = root.error(); + if (root.error() != 200) + return; + + const JSONNode &data = root.data(); + pDlg->szMsisdn = data["msisdn"].as_mstring(); pDlg->btnSendSms.Enable(); } diff --git a/protocols/Icq10/src/proto.h b/protocols/Icq10/src/proto.h index ec693efaea..634689ad99 100644 --- a/protocols/Icq10/src/proto.h +++ b/protocols/Icq10/src/proto.h @@ -86,6 +86,7 @@ class CIcqProto : public PROTO<CIcqProto> void OnFetchEvents(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnGetUserInfo(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnLoginViaPhone(NETLIBHTTPREQUEST*, AsyncHttpRequest*); + void OnNormalizePhone(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnReceiveAvatar(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnSearchResults(NETLIBHTTPREQUEST*, AsyncHttpRequest*); void OnSendMessage(NETLIBHTTPREQUEST*, AsyncHttpRequest*); |