summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_options.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-03-03 16:35:09 +0300
committeraunsane <aunsane@gmail.com>2018-03-03 16:35:33 +0300
commitfa58f69fe117640e29cefb1b699bede4d045bc2f (patch)
treea1bf8406d63e2b246bebdc572ceccfaabcffa359 /protocols/Tox/src/tox_options.cpp
parent0e8f5a3aa5f5e73b413c5646444751783e367f2b (diff)
Tox:
- updated toxcore due to release v0.2 - removed message correction - reworked nodes update
Diffstat (limited to 'protocols/Tox/src/tox_options.cpp')
-rw-r--r--protocols/Tox/src/tox_options.cpp44
1 files changed, 11 insertions, 33 deletions
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp
index 119bce5a0d..f52202c1eb 100644
--- a/protocols/Tox/src/tox_options.cpp
+++ b/protocols/Tox/src/tox_options.cpp
@@ -439,42 +439,20 @@ void CToxOptionsNodeList::ReloadNodeList()
int iItem = -1;
- VARSW path(_A2W(TOX_JSON_PATH));
- if (CToxProto::IsFileExists(path)) {
- ptrA json;
-
- FILE *hFile = _wfopen(path, L"r");
- if (hFile != nullptr) {
- _fseeki64(hFile, 0, SEEK_END);
- size_t size = _ftelli64(hFile);
- json = (char*)mir_calloc(size);
- rewind(hFile);
- fread(json, sizeof(char), size, hFile);
- fclose(hFile);
- }
-
- if (json) {
- JSONNode root = JSONNode::parse(json);
- if (!root.empty()) {
- JSONNode nodes = root.at("nodes").as_array();
- for (size_t i = 0; i < nodes.size(); i++) {
- JSONNode node = nodes[i];
+ JSONNode nodes = m_proto->ParseNodes();
+ for (const auto &node : nodes) {
+ ptrW ipv4(mir_utf8decodeW(node.at("ipv4").as_string().c_str()));
+ iItem = m_nodes.AddItem(ipv4, -1, NULL, 0);
- ptrW ipv4(mir_utf8decodeW(node.at("ipv4").as_string().c_str()));
- iItem = m_nodes.AddItem(ipv4, -1, NULL, 0);
+ ptrW ipv6(mir_utf8decodeW(node.at("ipv6").as_string().c_str()));
+ if (mir_wstrcmp(ipv6, L"-"))
+ m_nodes.SetItem(iItem, 1, ipv6);
- ptrW ipv6(mir_utf8decodeW(node.at("ipv6").as_string().c_str()));
- if (mir_wstrcmp(ipv6, L"-"))
- m_nodes.SetItem(iItem, 1, ipv6);
+ ptrW port(mir_utf8decodeW(node.at("port").as_string().c_str()));
+ m_nodes.SetItem(iItem, 2, port);
- ptrW port(mir_utf8decodeW(node.at("port").as_string().c_str()));
- m_nodes.SetItem(iItem, 2, port);
-
- ptrW pubKey(mir_utf8decodeW(node.at("public_key").as_string().c_str()));
- m_nodes.SetItem(iItem, 3, pubKey);
- }
- }
- }
+ ptrW pubKey(mir_utf8decodeW(node.at("public_key").as_string().c_str()));
+ m_nodes.SetItem(iItem, 3, pubKey);
}
char module[MAX_PATH], setting[MAX_PATH];