Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,954 changes: 1,954 additions & 0 deletions deps/iprogsjson.hpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deps/iprogsthreads
Submodule iprogsthreads updated 1 files
+10 −4 src/thread.cpp
2 changes: 1 addition & 1 deletion deps/mwas
Submodule mwas updated 2 files
+22 −0 include/ri/reimpl.hpp
+117 −0 src/reimpl.cpp
2 changes: 1 addition & 1 deletion src/discord/Attachment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Attachment
ContentType::eType m_contentType = ContentType::BLOB;

public:
void Load(nlohmann::json& j);
void Load(iprog::JsonObject& j);

void UpdatePreviewSize()
{
Expand Down
2 changes: 1 addition & 1 deletion src/discord/Channel.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <nlohmann/json.h>
#include <iprogsjson.hpp>
#include "Channel.hpp"
#include "ProfileCache.hpp"
#include "DiscordInstance.hpp"
Expand Down
6 changes: 3 additions & 3 deletions src/discord/DiscordClientConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ DiscordClientConfig::DiscordClientConfig()
m_secChUa = "\"Not?A_Brand\";v=\"99\", \"Chromium\";v=\"130\"";

// Ok, now serialize it
nlohmann::json j = Serialize();
iprog::JsonObject j = Serialize();

std::string str = j.dump();
m_serializedJsonBlob = str;
Expand All @@ -61,9 +61,9 @@ DiscordClientConfig::DiscordClientConfig()
m_serializedBase64Blob = dataToSend;
}

nlohmann::json DiscordClientConfig::Serialize() const
iprog::JsonObject DiscordClientConfig::Serialize() const
{
nlohmann::json j;
iprog::JsonObject j;
j["app_arch"] = m_appArch;
j["browser"] = m_browser;
j["browser_user_agent"] = m_browserUserAgent;
Expand Down
4 changes: 2 additions & 2 deletions src/discord/DiscordClientConfig.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include <nlohmann/json.h>
#include <iprogsjson.hpp>
#include <string>

class DiscordClientConfig
Expand All @@ -14,7 +14,7 @@ class DiscordClientConfig
const std::string& GetTimezone() const;
const std::string& GetOS() const;

nlohmann::json Serialize() const;
iprog::JsonObject Serialize() const;
const std::string& GetSerializedJsonBlob() const;
const std::string& GetSerializedBase64Blob() const;

Expand Down
58 changes: 29 additions & 29 deletions src/discord/DiscordInstance.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <nlohmann/json.h>
#include <iprogsjson.hpp>
#include <boost/base64/base64.hpp>
#include "DiscordInstance.hpp"
#include "WebsocketClient.hpp"
Expand All @@ -12,13 +12,13 @@

#ifndef _DEBUG
#define TRY try
#define CATCH catch (Json::exception& ex) { OnJsonException(ex); }
#define CATCH catch (std::exception& ex) { OnJsonException(ex); }
#else
#define TRY do
#define CATCH while (0)
#endif

using Json = nlohmann::json;
using Json = iprog::JsonObject;

// Creates a temporary snowflake based on time.
Snowflake CreateTemporarySnowflake()
Expand Down Expand Up @@ -65,14 +65,14 @@ void DebugResponse(NetRequest* pReq)
//OutputDebugStringA(str.c_str());
}

void OnJsonException(Json::exception & ex)
void OnJsonException(std::exception & ex)
{
GetFrontend()->OnJsonException(ex.what());
}

void DiscordInstance::OnFetchedChannels(Guild* pGld, const std::string& content)
{
Json j = Json::parse(content);
Json j = iprog::JsonParser::parse(content);

pGld->m_channels.clear();

Expand Down Expand Up @@ -649,7 +649,7 @@ void DiscordInstance::HandleRequest(NetRequest* pRequest)

if (pRequest->itype != IMAGE && pRequest->itype != IMAGE_ATTACHMENT)
{
j = Json::parse(pRequest->response);
j = iprog::JsonParser::parse(pRequest->response);
}

switch (pRequest->itype)
Expand Down Expand Up @@ -779,7 +779,7 @@ void DiscordInstance::HandleRequest(NetRequest* pRequest)
}
}
#ifndef _DEBUG
catch (Json::exception& ex)
catch (std::exception& ex)
{
OnJsonException(ex);
}
Expand Down Expand Up @@ -1159,7 +1159,7 @@ void DiscordInstance::HandleGatewayMessage(const std::string& payload)
{
DbgPrintF("Got Payload: %s [PAYLOAD ENDS HERE]", payload.c_str());

Json j = Json::parse(payload);
Json j = iprog::JsonParser::parse(payload);

int op = j["op"];
using namespace GatewayOp;
Expand Down Expand Up @@ -1716,7 +1716,7 @@ void DiscordInstance::UpdateSettingsInfo()
SetActivityStatus(GetSettingsManager()->GetOnlineIndicator(), false);
}

void DiscordInstance::ParsePermissionOverwrites(Channel& channel, nlohmann::json& j)
void DiscordInstance::ParsePermissionOverwrites(Channel& channel, iprog::JsonObject& j)
{
if (!j.contains("permission_overwrites"))
return;
Expand All @@ -1737,7 +1737,7 @@ void DiscordInstance::ParsePermissionOverwrites(Channel& channel, nlohmann::json
}
}

void DiscordInstance::ParseReadStateObject(nlohmann::json& readState, bool bAlternate)
void DiscordInstance::ParseReadStateObject(iprog::JsonObject& readState, bool bAlternate)
{
Snowflake id = GetSnowflake(readState, bAlternate ? "channel_id" : "id");
Snowflake lastMessageId = GetSnowflake(readState, bAlternate ? "message_id" : "last_message_id");
Expand Down Expand Up @@ -1770,7 +1770,7 @@ void DiscordInstance::ParseReadStateObject(nlohmann::json& readState, bool bAlte
GetFrontend()->UpdateChannelAcknowledge(id, lastMessageId);
}

void DiscordInstance::ParseChannel(Channel& c, nlohmann::json& chan, int& num)
void DiscordInstance::ParseChannel(Channel& c, iprog::JsonObject& chan, int& num)
{
c.m_snowflake = GetSnowflake(chan, "id");
c.m_channelType = Channel::eChannelType(int(chan["type"]));
Expand Down Expand Up @@ -2001,7 +2001,7 @@ bool DiscordInstance::SortGuilds()
#endif
}

void DiscordInstance::ParseAndAddGuild(nlohmann::json& elem)
void DiscordInstance::ParseAndAddGuild(iprog::JsonObject& elem)
{
std::string uu = elem.dump();

Expand Down Expand Up @@ -2165,9 +2165,9 @@ void DiscordInstance::HandleREADY_SUPPLEMENTAL(Json& j)
}

// Look for any activities -- TODO: Server specific activities
if (guildPres.contains("game") && !guildPres["game"].is_null())
pf->m_status = GetStatusStringFromGameJsonObject(guildPres["game"]);
else if (guildPres.contains("activities") && !memPres["activities"].is_null())
if (memPres.contains("game") && !memPres["game"].is_null())
pf->m_status = GetStatusStringFromGameJsonObject(memPres["game"]);
else if (memPres.contains("activities") && !memPres["activities"].is_null())
pf->m_status = GetStatusFromActivities(memPres["activities"]);
else
pf->m_status = "";
Expand Down Expand Up @@ -2458,7 +2458,7 @@ void DiscordInstance::HandleMESSAGE_DELETE(Json& j)
GetFrontend()->OnDeleteMessage(messageId);
}

void DiscordInstance::HandleMESSAGE_ACK(nlohmann::json& j)
void DiscordInstance::HandleMESSAGE_ACK(iprog::JsonObject& j)
{
Json& data = j["d"];

Expand All @@ -2467,7 +2467,7 @@ void DiscordInstance::HandleMESSAGE_ACK(nlohmann::json& j)
ParseReadStateObject(data, true);
}

void DiscordInstance::HandleUSER_GUILD_SETTINGS_UPDATE(nlohmann::json& j)
void DiscordInstance::HandleUSER_GUILD_SETTINGS_UPDATE(iprog::JsonObject& j)
{
Json& data = j["d"];
Snowflake guildID = GetSnowflake(data, "guild_id");
Expand All @@ -2476,7 +2476,7 @@ void DiscordInstance::HandleUSER_GUILD_SETTINGS_UPDATE(nlohmann::json& j)
pSettings->Load(data);
}

void DiscordInstance::HandleUSER_NOTE_UPDATE(nlohmann::json& j)
void DiscordInstance::HandleUSER_NOTE_UPDATE(iprog::JsonObject& j)
{
Json& data = j["d"];
Snowflake uid = GetSnowflake(data, "id");
Expand Down Expand Up @@ -2686,7 +2686,7 @@ void DiscordInstance::HandleGUILD_MEMBER_LIST_UPDATE(Json& j)
GetFrontend()->UpdateMemberList();
}

Snowflake DiscordInstance::ParseGuildMember(Snowflake guild, nlohmann::json& memb, Snowflake userID)
Snowflake DiscordInstance::ParseGuildMember(Snowflake guild, iprog::JsonObject& memb, Snowflake userID)
{
Json& pres = memb["presence"], &user = memb["user"], & roles = memb["roles"];
Profile* pf = nullptr;
Expand Down Expand Up @@ -2745,7 +2745,7 @@ Snowflake DiscordInstance::ParseGuildMember(Snowflake guild, nlohmann::json& mem
return userID;
}

void DiscordInstance::HandlePRESENCE_UPDATE(nlohmann::json& j)
void DiscordInstance::HandlePRESENCE_UPDATE(iprog::JsonObject& j)
{
Json& data = j["d"];

Expand Down Expand Up @@ -2775,7 +2775,7 @@ void DiscordInstance::HandlePRESENCE_UPDATE(nlohmann::json& j)
GetFrontend()->UpdateUserData(userID);
}

void DiscordInstance::HandlePASSIVE_UPDATE_V1(nlohmann::json& j)
void DiscordInstance::HandlePASSIVE_UPDATE_V1(iprog::JsonObject& j)
{
Json& data = j["d"];
Snowflake guildId = GetSnowflake(data, "guild_id");
Expand All @@ -2801,7 +2801,7 @@ void DiscordInstance::HandlePASSIVE_UPDATE_V1(nlohmann::json& j)
}
}

void DiscordInstance::HandleGUILD_MEMBERS_CHUNK(nlohmann::json& j)
void DiscordInstance::HandleGUILD_MEMBERS_CHUNK(iprog::JsonObject& j)
{
Json& data = j["d"];
Snowflake guildId = GetSnowflake(data, "guild_id");
Expand All @@ -2828,7 +2828,7 @@ void DiscordInstance::HandleGUILD_MEMBERS_CHUNK(nlohmann::json& j)
GetFrontend()->RefreshMembers(memsToRefresh);
}

void DiscordInstance::HandleTYPING_START(nlohmann::json& j)
void DiscordInstance::HandleTYPING_START(iprog::JsonObject& j)
{
Json& data = j["d"];
Snowflake guildID = 0;
Expand All @@ -2850,7 +2850,7 @@ void DiscordInstance::HandleTYPING_START(nlohmann::json& j)
GetFrontend()->OnStartTyping(userID, guildID, chanID, startTime);
}

Snowflake DiscordInstance::ParseGuildMemberOrGroup(Snowflake guild, nlohmann::json& item)
Snowflake DiscordInstance::ParseGuildMemberOrGroup(Snowflake guild, iprog::JsonObject& item)
{
if (item.contains("group")) {
Json& grp = item["group"];
Expand All @@ -2876,7 +2876,7 @@ Snowflake DiscordInstance::ParseGuildMemberOrGroup(Snowflake guild, nlohmann::js
}
}

void DiscordInstance::HandleGuildMemberListUpdate_Sync(Snowflake guild, nlohmann::json& jx)
void DiscordInstance::HandleGuildMemberListUpdate_Sync(Snowflake guild, iprog::JsonObject& jx)
{
Guild* pGld = GetGuild(guild);
assert(pGld);
Expand All @@ -2891,7 +2891,7 @@ void DiscordInstance::HandleGuildMemberListUpdate_Sync(Snowflake guild, nlohmann
pGld->m_members.push_back(ParseGuildMemberOrGroup(guild, item));
}

void DiscordInstance::HandleGuildMemberListUpdate_Insert(Snowflake guild, nlohmann::json& j)
void DiscordInstance::HandleGuildMemberListUpdate_Insert(Snowflake guild, iprog::JsonObject& j)
{
Guild* pGld = GetGuild(guild);
assert(pGld);
Expand All @@ -2909,7 +2909,7 @@ void DiscordInstance::HandleGuildMemberListUpdate_Insert(Snowflake guild, nlohma
pGld->m_members.insert(pGld->m_members.begin() + index, sf);
}

void DiscordInstance::HandleGuildMemberListUpdate_Delete(Snowflake guild, nlohmann::json& j)
void DiscordInstance::HandleGuildMemberListUpdate_Delete(Snowflake guild, iprog::JsonObject& j)
{
Guild* pGld = GetGuild(guild);
assert(pGld);
Expand All @@ -2933,7 +2933,7 @@ void DiscordInstance::HandleGuildMemberListUpdate_Delete(Snowflake guild, nlohma
pGld->m_members.erase(pGld->m_members.begin() + index);
}

void DiscordInstance::HandleGuildMemberListUpdate_Update(Snowflake guild, nlohmann::json& j)
void DiscordInstance::HandleGuildMemberListUpdate_Update(Snowflake guild, iprog::JsonObject& j)
{
Guild* pGld = GetGuild(guild);
assert(pGld);
Expand Down Expand Up @@ -2965,7 +2965,7 @@ void DiscordInstance::OnUploadAttachmentFirst(NetRequest* pReq)
return;
}

Json j = Json::parse(pReq->response);
Json j = iprog::JsonParser::parse(pReq->response);
assert(j["attachments"].size() == 1);

for (auto& att : j["attachments"])
Expand Down
Loading