summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_network.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-05-06 15:04:27 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-05-06 15:04:27 +0000
commit5b3107408e96484e0c98c172c39dde66c8fe9897 (patch)
tree11e3ea783e056863200c774fb1495ac02094a42d /protocols/Tox/src/tox_network.cpp
parentc492ee8fbc407bff76f58a30b2445d230ca0cdee (diff)
Tox: some fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@16805 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_network.cpp')
-rw-r--r--protocols/Tox/src/tox_network.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp
index 66cc86ad37..63db87cb5c 100644
--- a/protocols/Tox/src/tox_network.cpp
+++ b/protocols/Tox/src/tox_network.cpp
@@ -140,13 +140,23 @@ void CToxProto::UpdateNodes()
{
HttpRequest request(REQUEST_GET, "https://nodes.tox.chat/json");
NLHR_PTR response(request.Send(m_hNetlibUser));
-
if (response->resultCode != HTTP_CODE_OK || !response->pData)
{
debugLogA(__FUNCTION__": failed to dowload tox.json");
return;
}
+ JSONNode root = JSONNode::parse(response->pData);
+ if (root.empty())
+ {
+ debugLogA(__FUNCTION__": failed to dowload tox.json");
+ return;
+ }
+
+ long lastUpdate = root.at("last_scan").as_int();
+ if (lastUpdate <= getDword("NodesUpdate", 0))
+ return;
+
ptrT path(mir_tstrdup((TCHAR*)VARST(_T(TOX_JSON_PATH))));
if (!IsFileExists(path))
{
@@ -170,6 +180,8 @@ void CToxProto::UpdateNodes()
debugLogA(__FUNCTION__": failed to write tox.json");
fclose(hFile);
+
+ setDword("NodesUpdate", lastUpdate);
}
void CToxProto::TryConnect()