From d0932866332ca111c02d12cefc6373feef1a90bf Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Sat, 8 Jun 2013 14:34:56 +0000 Subject: i think fixed password saving git-svn-id: http://svn.miranda-ng.org/main/trunk@4901 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/WhatsApp/src/dialogs.cpp | 10 +++++----- protocols/WhatsApp/src/proto.cpp | 12 +++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/protocols/WhatsApp/src/dialogs.cpp b/protocols/WhatsApp/src/dialogs.cpp index ef0c2fac4c..e26086910a 100644 --- a/protocols/WhatsApp/src/dialogs.cpp +++ b/protocols/WhatsApp/src/dialogs.cpp @@ -86,11 +86,11 @@ INT_PTR CALLBACK WhatsAppAccountProc( HWND hwnd, UINT message, WPARAM wparam, LP } 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(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); + { + SetDlgItemTextA(hwnd, IDC_PW, pw.c_str()); + CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(pw.c_str()), (LPARAM)pw.c_str()); + db_set_s(NULL, 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); } } } diff --git a/protocols/WhatsApp/src/proto.cpp b/protocols/WhatsApp/src/proto.cpp index acfe83f5a6..260122efa1 100644 --- a/protocols/WhatsApp/src/proto.cpp +++ b/protocols/WhatsApp/src/proto.cpp @@ -253,12 +253,17 @@ string WhatsAppProto::Register(int state, string cc, string number, string code) NETLIBHTTPREQUEST* pnlhr = (NETLIBHTTPREQUEST*) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) WASocketConnection::hNetlibUser, (LPARAM)&nlhr); + string title = this->TranslateStr("Registration"); + if (pnlhr == NULL) { + this->NotifyEvent(title, this->TranslateStr("Registration failed. Invalid server response."), NULL, WHATSAPP_EVENT_CLIENT); + return ret; + } + LOG("Server response: %s", pnlhr->pData); MessageBoxA(NULL, pnlhr->pData, "Debug", MB_OK); cJSON* resp = cJSON_Parse(pnlhr->pData); cJSON* val; - string title = this->TranslateStr("Registration"); // Invalid if (resp == NULL) @@ -304,11 +309,8 @@ string WhatsAppProto::Register(int state, string cc, string number, string code) if (val == NULL) { this->NotifyEvent(title, this->TranslateStr("Registration failed."), NULL, WHATSAPP_EVENT_CLIENT); - } - if (strcmp(val->valuestring, "ok") == 0) - { + } else ret = val->valuestring; - } } cJSON_Delete(resp); -- cgit v1.2.3