summaryrefslogtreecommitdiff
path: root/protocols/WhatsApp/src/dialogs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/WhatsApp/src/dialogs.cpp')
-rw-r--r--protocols/WhatsApp/src/dialogs.cpp43
1 files changed, 34 insertions, 9 deletions
diff --git a/protocols/WhatsApp/src/dialogs.cpp b/protocols/WhatsApp/src/dialogs.cpp
index aba0493fda..6bc7889e06 100644
--- a/protocols/WhatsApp/src/dialogs.cpp
+++ b/protocols/WhatsApp/src/dialogs.cpp
@@ -1,13 +1,15 @@
#include "common.h"
#define szAskSendSms LPGEN("An SMS with registration code will be sent to your mobile phone.\nNotice that you are not able to use the real WhatsApp and this plugin simultaneously!\nContinue?")
-#define szPasswordSet LPGEN("Your password has been set automatically. You can proceed with login now")
+#define szAskCall LPGEN("A call with registration code will be made to your mobile phone.\nNotice that you are not able to use the real WhatsApp and this plugin simultaneously!\nContinue?")
+#define szPasswordSet LPGEN("Your password has been set automatically. You can proceed with login now.")
+#define szSpecifyCode LPGEN("Please correctly specify your registration code received by SMS/Voice.")
class COptionsDlg : public CProtoDlgBase<WhatsAppProto>
{
CCtrlEdit m_pw1, m_pw2, m_cc, m_login, m_nick, m_group;
CCtrlCheck m_ssl, m_autorun, m_remoteTime;
- CCtrlButton m_request, m_register;
+ CCtrlButton m_requestSMS, m_requestVoice, m_register;
public:
COptionsDlg(WhatsAppProto *pThis, int dlgId) :
@@ -21,7 +23,8 @@ public:
m_group(this, IDC_DEFGROUP),
m_login(this, IDC_LOGIN),
m_autorun(this, IDC_AUTORUN),
- m_request(this, IDC_BUTTON_REQUEST_CODE),
+ m_requestSMS(this, IDC_BUTTON_REQUEST_SMS_CODE),
+ m_requestVoice(this, IDC_BUTTON_REQUEST_VOICE_CODE),
m_register(this, IDC_BUTTON_REGISTER)
{
CreateLink(m_ssl, WHATSAPP_KEY_SSL, DBVT_BYTE, false);
@@ -33,7 +36,8 @@ public:
CreateLink(m_login, WHATSAPP_KEY_LOGIN, _T(""));
CreateLink(m_group, WHATSAPP_KEY_DEF_GROUP, _T(""));
- m_request.OnClick = Callback(this, &COptionsDlg::OnRequestClick);
+ m_requestSMS.OnClick = Callback(this, &COptionsDlg::OnRequestSMSClick);
+ m_requestVoice.OnClick = Callback(this, &COptionsDlg::OnRequestVoiceClick);
m_register.OnClick = Callback(this, &COptionsDlg::OnRegisterClick);
}
@@ -46,14 +50,14 @@ public:
m_pw2.Enable(bEnable);
}
- void OnRequestClick(CCtrlButton*)
+ void OnRequestVoiceClick(CCtrlButton*)
{
- if (IDYES != MessageBox(GetHwnd(), TranslateT(szAskSendSms), PRODUCT_NAME, MB_YESNO))
+ if (IDYES != MessageBox(GetHwnd(), TranslateT(szAskCall), PRODUCT_NAME, MB_YESNO))
return;
ptrA cc(m_cc.GetTextA()), number(m_login.GetTextA());
string password;
- if (m_proto->Register(REG_STATE_REQ_CODE, string(cc), string(number), string(), password)) {
+ if (m_proto->Register(REG_STATE_REQ_CODE, string(cc), string(number), "voice", password)) {
if (!password.empty()) {
MessageBox(GetHwnd(), TranslateT(szPasswordSet), PRODUCT_NAME, MB_ICONWARNING);
m_proto->setString(WHATSAPP_KEY_PASS, password.c_str());
@@ -67,10 +71,31 @@ public:
}
}
+ void OnRequestSMSClick(CCtrlButton*)
+ {
+ if (IDYES != MessageBox(GetHwnd(), TranslateT(szAskSendSms), PRODUCT_NAME, MB_YESNO))
+ return;
+
+ ptrA cc(m_cc.GetTextA()), number(m_login.GetTextA());
+ string password;
+ if (m_proto->Register(REG_STATE_REQ_CODE, string(cc), string(number), "sms", password)) {
+ if (!password.empty()) {
+ MessageBox(GetHwnd(), TranslateT(szPasswordSet), PRODUCT_NAME, MB_ICONWARNING);
+ m_proto->setString(WHATSAPP_KEY_PASS, password.c_str());
+ }
+ else {
+ // unblock sms code entry field
+ m_pw1.Enable();
+ m_pw2.Enable();
+ m_proto->setByte("CodeRequestDone", 1);
+ }
+ }
+ }
+
void OnRegisterClick(CCtrlButton*)
{
if (GetWindowTextLength(m_pw1.GetHwnd()) != 3 || GetWindowTextLength(m_pw2.GetHwnd()) != 3)
- MessageBox(GetHwnd(), TranslateT("Please correctly specify your registration code received by SMS"), PRODUCT_NAME, MB_ICONEXCLAMATION);
+ MessageBox(GetHwnd(), TranslateT(szSpecifyCode), PRODUCT_NAME, MB_ICONEXCLAMATION);
else {
char code[10];
GetWindowTextA(m_pw1.GetHwnd(), code, 4);
@@ -105,7 +130,7 @@ INT_PTR WhatsAppProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
return (INT_PTR)pDlg->GetHwnd();
}
-int WhatsAppProto::OnOptionsInit(WPARAM wParam, LPARAM lParam)
+int WhatsAppProto::OnOptionsInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.ptszTitle = m_tszUserName;