summaryrefslogtreecommitdiff
path: root/protocols/Discord/src/proto.h
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-02-22 18:34:13 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-02-22 18:34:13 +0300
commite166b028427169375fb5da938ada6f3f3db520d2 (patch)
tree0e2de73477db8ed1300073004d6e255baf7bcfa5 /protocols/Discord/src/proto.h
parentb36289b6ed6dfdc74e42ac89a8d873cee058453d (diff)
major rework of Discord:
- CDiscordGuild - a class to utilize all guild-related activity; - all guild related code moved to the separate module; - fix for online guild channel creation; - version bump;
Diffstat (limited to 'protocols/Discord/src/proto.h')
-rw-r--r--protocols/Discord/src/proto.h61
1 files changed, 54 insertions, 7 deletions
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index 9ab553e5a4..376f536419 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -83,7 +83,7 @@ JSONNode& operator<<(JSONNode &json, const WCHAR_PARAM &param);
struct CDiscordRole : public MZeroedObject
{
- SnowFlake id, guildId;
+ SnowFlake id;
COLORREF color;
DWORD permissions;
int position;
@@ -129,6 +129,41 @@ struct CDiscordUser : public MZeroedObject
int iDiscriminator;
};
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct CDiscordGuildMember : public MZeroedObject
+{
+ CDiscordGuildMember(SnowFlake id) :
+ userId(id)
+ {}
+
+ ~CDiscordGuildMember()
+ {}
+
+ SnowFlake userId;
+ CMStringW wszNick, wszRole;
+ int iStatus;
+};
+
+struct CDiscordGuild : public MZeroedObject
+{
+ CDiscordGuild(SnowFlake _id);
+ ~CDiscordGuild();
+
+ __forceinline CDiscordGuildMember* FindUser(SnowFlake userId)
+ { return arChatUsers.find((CDiscordGuildMember*)&userId);
+ }
+
+ SnowFlake id, ownerId;
+ CMStringW wszName;
+ MCONTACT hContact;
+
+ OBJLIST<CDiscordGuildMember> arChatUsers;
+ OBJLIST<CDiscordRole> arRoles; // guild roles
+};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
class CDiscordProto : public PROTO<CDiscordProto>
{
friend struct AsyncHttpRequest;
@@ -204,7 +239,6 @@ class CDiscordProto : public PROTO<CDiscordProto>
mir_cs csMarkReadQueue;
LIST<CDiscordUser> arMarkReadQueue;
- OBJLIST<CDiscordRole> arRoles;
OBJLIST<CDiscordUser> arUsers;
OBJLIST<SnowFlake> arOwnMessages;
CDiscordUser* FindUser(SnowFlake id);
@@ -219,10 +253,26 @@ class CDiscordProto : public PROTO<CDiscordProto>
int __cdecl OnMenuPrebuild(WPARAM, LPARAM);
+ INT_PTR __cdecl OnMenuCreateChannel(WPARAM, LPARAM);
INT_PTR __cdecl OnMenuJoinGuild(WPARAM, LPARAM);
INT_PTR __cdecl OnMenuLeaveGuild(WPARAM, LPARAM);
- HGENMENU m_hMenuLeaveGuild;
+ HGENMENU m_hMenuLeaveGuild, m_hMenuCreateChannel;
+
+ //////////////////////////////////////////////////////////////////////////////////////
+ // guilds
+
+ OBJLIST<CDiscordGuild> arGuilds;
+
+ __forceinline CDiscordGuild* FindGuild(SnowFlake id) const
+ { return arGuilds.find((CDiscordGuild*)&id);
+ }
+
+ void ProcessGuild(const JSONNode&);
+ void ApplyUsersToChannel(CDiscordGuild *guild, const CDiscordUser&);
+ CDiscordUser* ProcessGuildChannel(CDiscordGuild *guild, const JSONNode&);
+ void ProcessRole(CDiscordGuild *guild, const JSONNode&);
+ void ProcessType(CDiscordUser *pUser, const JSONNode&);
//////////////////////////////////////////////////////////////////////////////////////
// group chats
@@ -233,7 +283,7 @@ class CDiscordProto : public PROTO<CDiscordProto>
void Chat_SendPrivateMessage(GCHOOK *gch);
void Chat_ProcessLogMenu(GCHOOK *gch);
- void BuildStatusList(SnowFlake guildId, const CMStringW &wszChannelId);
+ void BuildStatusList(const CDiscordGuild *pGuild, const CMStringW &wszChannelId);
void ParseSpecialChars(SESSION_INFO *si, CMStringW &str);
//////////////////////////////////////////////////////////////////////////////////////
@@ -333,9 +383,6 @@ public:
void OnReceiveAvatar(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
// Misc
- void ProcessGuild(const JSONNode &pStatuses, const JSONNode &pRoot);
- void ProcessRole(SnowFlake guildId, const JSONNode&);
- void ProcessType(CDiscordUser *pUser, const JSONNode&);
void SetServerStatus(int iStatus);
void RemoveFriend(SnowFlake id);