summaryrefslogtreecommitdiff
path: root/protocols/Tox
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
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')
-rw-r--r--protocols/Tox/src/tox_network.cpp14
-rw-r--r--protocols/Tox/src/tox_options.cpp12
2 files changed, 18 insertions, 8 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()
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp
index b248deabea..30227f1b7f 100644
--- a/protocols/Tox/src/tox_options.cpp
+++ b/protocols/Tox/src/tox_options.cpp
@@ -359,6 +359,8 @@ void CToxNodeEditor::OnOk(CCtrlBase*)
m_list->SetItem(m_iItem, 4, _T(""), 0);
m_list->SetItem(m_iItem, 5, _T(""), 1);
+ SendMessage(GetParent(GetParent(m_list->GetHwnd())), PSM_CHANGED, 0, 0);
+
EndDialog(m_hwnd, 1);
}
@@ -471,7 +473,7 @@ void CToxOptionsNodeList::OnNodeListClick(CCtrlListView::TEventInfo *evt)
if (MessageBox(m_hwnd, TranslateT("Are you sure?"), TranslateT("Node deleting"), MB_YESNO | MB_ICONWARNING) == IDYES)
{
m_nodes.DeleteItem(lvi.iItem);
- SendMessage(GetParent(GetParent(m_hwnd)), PSM_CHANGED, 0, 0);
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, 0, 0);
}
}
}
@@ -485,14 +487,10 @@ void CToxOptionsNodeList::OnNodeListKeyDown(CCtrlListView::TEventInfo *evt)
if (lvi.iGroupId && lvi.iItem != -1 && (evt->nmlvkey)->wVKey == VK_DELETE)
{
- if (MessageBox(
- GetParent(m_hwnd),
- TranslateT("Are you sure?"),
- TranslateT("Node deleting"),
- MB_YESNO | MB_ICONWARNING) == IDYES)
+ if (MessageBox(GetParent(m_hwnd), TranslateT("Are you sure?"), TranslateT("Node deleting"), MB_YESNO | MB_ICONWARNING) == IDYES)
{
m_nodes.DeleteItem(lvi.iItem);
- SendMessage(GetParent(GetParent(m_hwnd)), PSM_CHANGED, 0, 0);
+ SendMessage(GetParent(m_hwnd), PSM_CHANGED, 0, 0);
}
}
}