diff options
author | Fishbone <fishbone@miranda-ng.org> | 2013-06-07 16:36:25 +0000 |
---|---|---|
committer | Fishbone <fishbone@miranda-ng.org> | 2013-06-07 16:36:25 +0000 |
commit | cbbbbae0ec63187368817c0c49741c4ec7a9fe41 (patch) | |
tree | fcb89bc00ceb12adbe36009e759e38f699c8de00 /protocols/WhatsApp/src/dialogs.cpp | |
parent | fa38cd5864b1b8090be141e3c4291df6d3322e30 (diff) |
WhatsApp:
- removed duplicate resource file in "src"-directory
- finished registration (we don't know, if it already works. Hopefully I didn't break code-request again)
git-svn-id: http://svn.miranda-ng.org/main/trunk@4892 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/WhatsApp/src/dialogs.cpp')
-rw-r--r-- | protocols/WhatsApp/src/dialogs.cpp | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/protocols/WhatsApp/src/dialogs.cpp b/protocols/WhatsApp/src/dialogs.cpp index 81a17351fb..ef0c2fac4c 100644 --- a/protocols/WhatsApp/src/dialogs.cpp +++ b/protocols/WhatsApp/src/dialogs.cpp @@ -52,13 +52,46 @@ INT_PTR CALLBACK WhatsAppAccountProc( HWND hwnd, UINT message, WPARAM wparam, LP return TRUE;
case WM_COMMAND:
- if (LOWORD(wparam) == IDC_BUTTON_REQUEST_CODE)
+ if (LOWORD(wparam) == IDC_BUTTON_REQUEST_CODE || LOWORD(wparam) == IDC_BUTTON_REGISTER)
{
- if (MessageBox(NULL, _T("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 simultaneousley!\nContinue?"),
- PRODUCT_NAME, MB_YESNO) == IDYES)
+ proto = reinterpret_cast<WhatsAppProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
+
+ char cc[5];
+ GetDlgItemTextA(hwnd, IDC_CC, cc, sizeof(cc));
+ char number[128];
+ GetDlgItemTextA(hwnd, IDC_LOGIN, number, sizeof(number));
+
+ if (LOWORD(wparam) == IDC_BUTTON_REQUEST_CODE)
+ {
+ if (MessageBox(NULL, TranslateT("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 simultaneousley!\nContinue?"),
+ PRODUCT_NAME, MB_YESNO) == IDYES)
+ {
+ proto->Register(REG_STATE_REQ_CODE, string(cc), string(number), string());
+ }
+ }
+ else if (LOWORD(wparam) == IDC_BUTTON_REGISTER)
{
- proto = reinterpret_cast<WhatsAppProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
- proto->RequestCode();
+ char code[7];
+ if (SendDlgItemMessage(hwnd, IDC_REG_CODE_1, WM_GETTEXTLENGTH, 0, 0) == 3 &&
+ SendDlgItemMessage(hwnd, IDC_REG_CODE_2, WM_GETTEXTLENGTH, 0, 0) == 3)
+ {
+ GetDlgItemTextA(hwnd, IDC_REG_CODE_1, code, 4);
+ GetDlgItemTextA(hwnd, IDC_REG_CODE_2, &(code[3]), 4);
+ }
+ else
+ {
+ MessageBox(NULL, TranslateT("Please correctly specify your registration code received by SMS"),
+ PRODUCT_NAME, MB_ICONEXCLAMATION);
+ return TRUE;
+ }
+ string pw = proto->Register(REG_STATE_REG_CODE, string(cc), string(number), string(code));
+ if (!pw.empty())
+ {
+ CallService(MS_DB_CRYPT_ENCODESTRING,sizeof(pw.c_str()),reinterpret_cast<LPARAM>(pw.c_str()));
+ db_set_s(0, proto->ModuleName(), WHATSAPP_KEY_PASS, pw.c_str());
+ MessageBox(NULL, TranslateT("Your password has been set automatically.\nIf you change your password manually you may lose it and need to request a new code!"),
+ PRODUCT_NAME, MB_ICONWARNING);
+ }
}
}
|