summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/VKontakte/src/misc.cpp15
-rw-r--r--protocols/VKontakte/src/stdafx.h2
-rw-r--r--protocols/VKontakte/src/vk_proto.h1
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp12
-rw-r--r--protocols/VKontakte/vk_10.vcxproj6
-rw-r--r--protocols/VKontakte/vk_11.vcxproj6
6 files changed, 34 insertions, 8 deletions
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 <http://www.gnu.org/licenses/>.
#include <tchar.h>
#include <time.h>
-#include <string>
-
#include <newpluginapi.h>
#include <m_system.h>
#include <m_system_cpp.h>
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 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<PrecompiledHeader>Use</PrecompiledHeader>
+ <ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -102,6 +103,7 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
+ <ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -124,6 +126,8 @@
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<PrecompiledHeader>Use</PrecompiledHeader>
+ <ExceptionHandling>false</ExceptionHandling>
+ <StringPooling>true</StringPooling>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -149,6 +153,8 @@
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<PrecompiledHeader>Use</PrecompiledHeader>
+ <ExceptionHandling>false</ExceptionHandling>
+ <StringPooling>true</StringPooling>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
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 @@
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<PrecompiledHeader>Use</PrecompiledHeader>
+ <ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -107,6 +108,7 @@
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
+ <ExceptionHandling>false</ExceptionHandling>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -129,6 +131,8 @@
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<PrecompiledHeader>Use</PrecompiledHeader>
+ <ExceptionHandling>false</ExceptionHandling>
+ <StringPooling>true</StringPooling>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@@ -153,6 +157,8 @@
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<PrecompiledHeader>Use</PrecompiledHeader>
+ <ExceptionHandling>false</ExceptionHandling>
+ <StringPooling>true</StringPooling>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>