From ae6d0b3c9f732c3770fc4bf00ba2e52012671108 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 7 Oct 2013 12:19:50 +0000 Subject: STL removed git-svn-id: http://svn.miranda-ng.org/main/trunk@6395 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/VKontakte/src/misc.cpp | 15 +++++++++++++++ protocols/VKontakte/src/stdafx.h | 2 -- protocols/VKontakte/src/vk_proto.h | 1 + protocols/VKontakte/src/vk_thread.cpp | 12 ++++++------ protocols/VKontakte/vk_10.vcxproj | 6 ++++++ protocols/VKontakte/vk_11.vcxproj | 6 ++++++ 6 files changed, 34 insertions(+), 8 deletions(-) (limited to 'protocols/VKontakte') diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index a7486fce91..a59a4a16b4 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -52,6 +52,21 @@ LPCSTR findHeader(NETLIBHTTPREQUEST *pReq, LPCSTR szField) return NULL; } +bool CVkProto::CheckJsonResult(JSONNODE *pNode) +{ + if (pNode == NULL) + return false; + + JSONNODE *pError = json_get(pNode, "error"), *pErrorCode = json_get(pError, "error_code"); + if (pError == NULL || pErrorCode == NULL) + return true; + + int iErrorCode = json_as_int(pErrorCode); + if (iErrorCode == ERROR_ACCESS_DENIED) + ConnectionFailed(LOGINERR_WRONGPASSWORD); + return iErrorCode == 0; +} + ///////////////////////////////////////////////////////////////////////////////////////// // Quick & dirty form parser diff --git a/protocols/VKontakte/src/stdafx.h b/protocols/VKontakte/src/stdafx.h index 1cd26ecd8d..94469d2b79 100644 --- a/protocols/VKontakte/src/stdafx.h +++ b/protocols/VKontakte/src/stdafx.h @@ -28,8 +28,6 @@ along with this program. If not, see . #include #include -#include - #include #include #include diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 63cfb05cb9..c8ee1a21cb 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -120,6 +120,7 @@ private: CMStringA AutoFillForm(char*, CMStringA&); void ConnectionFailed(int iReason); + bool CheckJsonResult(JSONNODE*); void OnLoggedIn(); void OnLoggedOut(); void ShutdownSession(); diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 1510b5feea..18b10add99 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -149,7 +149,7 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply) } JSONNODE *pRoot = json_parse(reply->pData); - if (pRoot == NULL) + if ( !CheckJsonResult(pRoot)) return; JSONNODE *pResponse = json_get(pRoot, "response"); @@ -160,21 +160,21 @@ void CVkProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *reply) JSONNODE *it = json_at(pResponse, i); LPCSTR id = json_name(it); if ( !_stricmp(id, "user_id")) - setString("ID", json_as_pstring(it).c_str()); + setTString("ID", ptrT( json_as_string(it))); else if ( !_stricmp(id, "user_name")) - setTString("Nick", ptrT( mir_utf8decodeT( json_as_pstring(it).c_str()))); + setTString("Nick", ptrT( json_as_string(it))); else if ( !_stricmp(id, "user_sex")) setByte("Gender", json_as_int(it) == 2 ? 'M' : 'F'); else if ( !_stricmp(id, "user_bdate")) { - std::string date = json_as_pstring(it); + ptrT date( json_as_string(it)); int d, m, y; - if ( sscanf(date.c_str(), "%d.%d.%d", &d, &m, &y) == 3) { + if ( _tscanf(date, _T("%d.%d.%d"), &d, &m, &y) == 3) { setByte("BirthDay", d); setByte("BirthMonth", m); setByte("BirthYear", y); } } else if ( !_stricmp(id, "user_photo")) - setString("Photo", json_as_pstring(it).c_str()); + setTString("Photo", ptrT( json_as_string(it))); } } diff --git a/protocols/VKontakte/vk_10.vcxproj b/protocols/VKontakte/vk_10.vcxproj index 2897473b2e..6d68d67a49 100644 --- a/protocols/VKontakte/vk_10.vcxproj +++ b/protocols/VKontakte/vk_10.vcxproj @@ -80,6 +80,7 @@ Level3 EditAndContinue Use + false true @@ -102,6 +103,7 @@ MultiThreadedDebugDLL Level3 Use + false true @@ -124,6 +126,8 @@ OnlyExplicitInline Size Use + false + true true @@ -149,6 +153,8 @@ OnlyExplicitInline Size Use + false + true true diff --git a/protocols/VKontakte/vk_11.vcxproj b/protocols/VKontakte/vk_11.vcxproj index afb873f2ed..1770c97512 100644 --- a/protocols/VKontakte/vk_11.vcxproj +++ b/protocols/VKontakte/vk_11.vcxproj @@ -84,6 +84,7 @@ Level3 EditAndContinue Use + false true @@ -107,6 +108,7 @@ MultiThreadedDebugDLL Level3 Use + false true @@ -129,6 +131,8 @@ OnlyExplicitInline Size Use + false + true true @@ -153,6 +157,8 @@ OnlyExplicitInline Size Use + false + true true -- cgit v1.2.3