summaryrefslogtreecommitdiffstats
path: root/src/Protocol/MojangAPI.cpp
diff options
context:
space:
mode:
authorpeterbell10 <peterbell10@live.co.uk>2020-05-09 16:51:15 +0200
committerGitHub <noreply@github.com>2020-05-09 16:51:15 +0200
commite6634ed26c50e99f6ccd285235fe477cb4168b06 (patch)
treeb533a69db545835a886bcd8c5b05609b4c830d11 /src/Protocol/MojangAPI.cpp
parentUpgrade to C++17 [CI] (#4716) (diff)
downloadcuberite-e6634ed26c50e99f6ccd285235fe477cb4168b06.tar
cuberite-e6634ed26c50e99f6ccd285235fe477cb4168b06.tar.gz
cuberite-e6634ed26c50e99f6ccd285235fe477cb4168b06.tar.bz2
cuberite-e6634ed26c50e99f6ccd285235fe477cb4168b06.tar.lz
cuberite-e6634ed26c50e99f6ccd285235fe477cb4168b06.tar.xz
cuberite-e6634ed26c50e99f6ccd285235fe477cb4168b06.tar.zst
cuberite-e6634ed26c50e99f6ccd285235fe477cb4168b06.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/MojangAPI.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Protocol/MojangAPI.cpp b/src/Protocol/MojangAPI.cpp
index be6ee35e2..8a3868ecc 100644
--- a/src/Protocol/MojangAPI.cpp
+++ b/src/Protocol/MojangAPI.cpp
@@ -8,6 +8,7 @@
#include "SQLiteCpp/Database.h"
#include "SQLiteCpp/Statement.h"
#include "../IniFile.h"
+#include "../JsonUtils.h"
#include "json/json.h"
#include "../mbedTLS++/BlockingSslClientSocket.h"
#include "../mbedTLS++/SslConfig.h"
@@ -514,7 +515,7 @@ void cMojangAPI::LoadCachesFromDisk(void)
try
{
// Open up the SQLite DB:
- SQLite::Database db("MojangAPI.sqlite", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
+ SQLite::Database db("MojangAPI.sqlite", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
db.exec("CREATE TABLE IF NOT EXISTS PlayerNameToUUID (PlayerName, UUID, DateTime)");
db.exec("CREATE TABLE IF NOT EXISTS UUIDToProfile (UUID, PlayerName, Textures, TexturesSignature, DateTime)");
@@ -572,7 +573,7 @@ void cMojangAPI::SaveCachesToDisk(void)
try
{
// Open up the SQLite DB:
- SQLite::Database db("MojangAPI.sqlite", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE);
+ SQLite::Database db("MojangAPI.sqlite", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
db.exec("CREATE TABLE IF NOT EXISTS PlayerNameToUUID (PlayerName, UUID, DateTime)");
db.exec("CREATE TABLE IF NOT EXISTS UUIDToProfile (UUID, PlayerName, Textures, TexturesSignature, DateTime)");
@@ -670,8 +671,7 @@ void cMojangAPI::QueryNamesToUUIDs(AStringVector & a_NamesToQuery)
root.append(req);
} // for itr - a_PlayerNames[]
a_NamesToQuery.erase(a_NamesToQuery.begin(), itr);
- Json::FastWriter Writer;
- AString RequestBody = Writer.write(root);
+ auto RequestBody = JsonUtils::WriteFastString(root);
// Create the HTTP request:
AString Request;
@@ -712,11 +712,11 @@ void cMojangAPI::QueryNamesToUUIDs(AStringVector & a_NamesToQuery)
Response.erase(0, idxHeadersEnd + 4);
// Parse the returned string into Json:
- Json::Reader reader;
- if (!reader.parse(Response, root, false) || !root.isArray())
+ AString ParseError;
+ if (!JsonUtils::ParseString(Response, root, &ParseError) || !root.isArray())
{
- LOGWARNING("%s failed: Cannot parse received data (NameToUUID) to JSON: \"%s\"", __FUNCTION__, reader.getFormattedErrorMessages().c_str());
- LOGD("Response body:\n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
+ LOGWARNING("%s failed: Cannot parse received data (NameToUUID) to JSON: \"%s\"", __FUNCTION__, ParseError);
+ LOGD("Response body:\n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16));
continue;
}
@@ -822,11 +822,11 @@ void cMojangAPI::QueryUUIDToProfile(const cUUID & a_UUID)
Response.erase(0, idxHeadersEnd + 4);
// Parse the returned string into Json:
- Json::Reader reader;
Json::Value root;
- if (!reader.parse(Response, root, false) || !root.isObject())
+ AString ParseError;
+ if (!JsonUtils::ParseString(Response, root, &ParseError) || !root.isObject())
{
- LOGWARNING("%s failed: Cannot parse received data (NameToUUID) to JSON: \"%s\"", __FUNCTION__, reader.getFormattedErrorMessages().c_str());
+ LOGWARNING("%s failed: Cannot parse received data (NameToUUID) to JSON: \"%s\"", __FUNCTION__, ParseError);
LOGD("Response body:\n%s", CreateHexDump(HexDump, Response.data(), Response.size(), 16).c_str());
return;
}