summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-10-31 15:57:25 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-10-31 15:57:25 +0300
commit67a6c03577c66cb1b8cb69ad1f31b79fa7cc8a3c (patch)
treeb70a883d3014c8641db2a9c46c2348949c58eb7f /protocols
parent4d8882c9c68f74ae41364995720517e7dff14d33 (diff)
Discord: additional option to use special sub-groups for guilds
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Discord/discord.vcxproj4
-rw-r--r--protocols/Discord/res/discord.rc2
-rw-r--r--protocols/Discord/src/guilds.cpp23
-rw-r--r--protocols/Discord/src/options.cpp4
-rw-r--r--protocols/Discord/src/proto.cpp10
-rw-r--r--protocols/Discord/src/proto.h1
-rw-r--r--protocols/Discord/src/resource.h4
-rw-r--r--protocols/Discord/src/server.cpp2
-rw-r--r--protocols/Discord/src/stdafx.h3
9 files changed, 35 insertions, 18 deletions
diff --git a/protocols/Discord/discord.vcxproj b/protocols/Discord/discord.vcxproj
index 8f2339bc85..ef948176a8 100644
--- a/protocols/Discord/discord.vcxproj
+++ b/protocols/Discord/discord.vcxproj
@@ -41,4 +41,8 @@
<Project>{f6a9340e-b8d9-4c75-be30-47dc66d0abc7}</Project>
</ProjectReference>
</ItemGroup>
+ <ItemGroup>
+ <Image Include="res\discord.ico" />
+ <Image Include="res\groupchat.ico" />
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/protocols/Discord/res/discord.rc b/protocols/Discord/res/discord.rc
index fba3f590d7..5b0fce2d89 100644
--- a/protocols/Discord/res/discord.rc
+++ b/protocols/Discord/res/discord.rc
@@ -76,6 +76,8 @@ BEGIN
LTEXT "Default group:",IDC_STATIC,17,91,61,8,0,WS_EX_RIGHT
EDITTEXT IDC_GROUP,84,89,123,13,ES_AUTOHSCROLL
CONTROL "Hide guild chats on startup",IDC_HIDECHATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,107,248,10
+ CONTROL "Use subgroups for guild's channels (requires restart)",IDC_USEGROUPS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,121,248,10
END
IDD_OPTIONS_ACCMGR DIALOGEX 0, 0, 200, 88
diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp
index c494d141ac..7e1c2b83b7 100644
--- a/protocols/Discord/src/guilds.cpp
+++ b/protocols/Discord/src/guilds.cpp
@@ -90,12 +90,14 @@ void CDiscordProto::CreateChat(CDiscordGuild *pGuild, CDiscordUser *pUser)
si->pParent = pGuild->pParentSi;
pUser->hContact = si->hContact;
- if (pUser->parentId) {
- CDiscordUser *pParent = FindUserByChannel(pUser->parentId);
- if (pParent != nullptr)
- sttSetGroupName(pUser->hContact, pParent->wszChannelName);
+ if (m_bUseGuildGroups) {
+ if (pUser->parentId) {
+ CDiscordUser *pParent = FindUserByChannel(pUser->parentId);
+ if (pParent != nullptr)
+ sttSetGroupName(pUser->hContact, pParent->wszChannelName);
+ }
+ else sttSetGroupName(pUser->hContact, Clist_GroupGetName(pGuild->groupId));
}
- else sttSetGroupName(pUser->hContact, Clist_GroupGetName(pGuild->groupId));
BuildStatusList(pGuild, pUser->wszUsername);
@@ -172,8 +174,10 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS
arUsers.insert(pUser);
pGuild->arChannels.insert(pUser);
- MGROUP grpId = Clist_GroupCreate(pGuild->groupId, wszName);
- pUser->wszChannelName = Clist_GroupGetName(grpId);
+ if (m_bUseGuildGroups) {
+ MGROUP grpId = Clist_GroupCreate(pGuild->groupId, wszName);
+ pUser->wszChannelName = Clist_GroupGetName(grpId);
+ }
}
return pUser;
@@ -191,7 +195,10 @@ CDiscordUser* CDiscordProto::ProcessGuildChannel(CDiscordGuild *pGuild, const JS
pGuild->arChannels.insert(pUser);
pUser->wszUsername = wszChannelId;
- pUser->wszChannelName = L"#" + wszName;
+ if (m_bUseGuildGroups)
+ pUser->wszChannelName = L"#" + wszName;
+ else
+ pUser->wszChannelName = pGuild->wszName + L"#" + wszName;
pUser->wszTopic = pch["topic"].as_mstring();
pUser->pGuild = pGuild;
pUser->lastMsg = CDiscordMessage(::getId(pch["last_message_id"]));
diff --git a/protocols/Discord/src/options.cpp b/protocols/Discord/src/options.cpp
index 165535591c..1042d80dcb 100644
--- a/protocols/Discord/src/options.cpp
+++ b/protocols/Discord/src/options.cpp
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
class CDiscardAccountOptions : public CProtoDlgBase<CDiscordProto>
{
- CCtrlCheck chkHideChats;
+ CCtrlCheck chkHideChats, chkUseGroups;
CCtrlEdit m_edGroup, m_edUserName, m_edPassword;
ptrW m_wszOldGroup;
@@ -32,11 +32,13 @@ public:
m_edUserName(this, IDC_USERNAME),
m_edPassword(this, IDC_PASSWORD),
chkHideChats(this, IDC_HIDECHATS),
+ chkUseGroups(this, IDC_USEGROUPS),
m_wszOldGroup(mir_wstrdup(ppro->m_wszDefaultGroup))
{
CreateLink(m_edGroup, ppro->m_wszDefaultGroup);
CreateLink(m_edUserName, ppro->m_wszEmail);
CreateLink(chkHideChats, ppro->m_bHideGroupchats);
+ CreateLink(chkUseGroups, ppro->m_bUseGuildGroups);
}
bool OnInitDialog() override
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp
index 6ef95ffbd3..6e4164fd5b 100644
--- a/protocols/Discord/src/proto.cpp
+++ b/protocols/Discord/src/proto.cpp
@@ -41,13 +41,15 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) :
PROTO<CDiscordProto>(proto_name, username),
m_arHttpQueue(10, compareRequests),
m_evRequestsQueue(CreateEvent(nullptr, FALSE, FALSE, nullptr)),
- m_wszDefaultGroup(this, DB_KEY_GROUP, DB_KEYVAL_GROUP),
- m_wszEmail(this, DB_KEY_EMAIL, L""),
- m_bHideGroupchats(this, DB_KEY_HIDECHATS, true),
+ arUsers(10, compareUsers),
arGuilds(1, compareGuilds),
arMarkReadQueue(1, compareUsers),
arOwnMessages(1, compareMessages),
- arUsers(10, compareUsers)
+
+ m_wszEmail(this, "Email", L""),
+ m_wszDefaultGroup(this, "GroupName", DB_KEYVAL_GROUP),
+ m_bHideGroupchats(this, "HideChats", true),
+ m_bUseGuildGroups(this, "UseGuildGroups", true)
{
// Services
CreateProtoService(PS_CREATEACCMGRUI, &CDiscordProto::SvcCreateAccMgrUI);
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index 5fc60038cb..60305b3630 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -204,6 +204,7 @@ class CDiscordProto : public PROTO<CDiscordProto>
CMOption<wchar_t*> m_wszEmail; // my own email
CMOption<wchar_t*> m_wszDefaultGroup; // clist group to store contacts
CMOption<BYTE> m_bHideGroupchats; // hide guild chats on startup
+ CMOption<BYTE> m_bUseGuildGroups; // use special subgroups for guilds
//////////////////////////////////////////////////////////////////////////////////////
// common data
diff --git a/protocols/Discord/src/resource.h b/protocols/Discord/src/resource.h
index e73ee518ec..7765cedeea 100644
--- a/protocols/Discord/src/resource.h
+++ b/protocols/Discord/src/resource.h
@@ -12,6 +12,8 @@
#define IDC_GROUP 1003
#define IDC_NICK 1004
#define IDC_HIDECHATS 1005
+#define IDC_USEGROUPS 1006
+#define IDC_CHECK1 1007
// Next default values for new objects
//
@@ -19,7 +21,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1006
+#define _APS_NEXT_CONTROL_VALUE 1008
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Discord/src/server.cpp b/protocols/Discord/src/server.cpp
index b52c254569..02edcdaed0 100644
--- a/protocols/Discord/src/server.cpp
+++ b/protocols/Discord/src/server.cpp
@@ -168,7 +168,7 @@ void CDiscordProto::OnReceiveMyInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*
setByte(0, DB_KEY_MFA, root["mfa_enabled"].as_bool());
setDword(0, DB_KEY_DISCR, _wtoi(root["discriminator"].as_mstring()));
setWString(0, DB_KEY_NICK, root["username"].as_mstring());
- setWString(0, DB_KEY_EMAIL, root["email"].as_mstring());
+ m_wszEmail = root["email"].as_mstring();
m_ownId = id;
for (int i = 0; i < pReply->headersCount; i++) {
diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h
index 91c99ee7f7..70bef09fe2 100644
--- a/protocols/Discord/src/stdafx.h
+++ b/protocols/Discord/src/stdafx.h
@@ -46,18 +46,15 @@ extern IconItem g_iconList[];
extern HWND g_hwndHeartbeat;
#define DB_KEY_ID "id"
-#define DB_KEY_EMAIL "Email"
#define DB_KEY_PASSWORD "Password"
#define DB_KEY_DISCR "Discriminator"
#define DB_KEY_MFA "MfaEnabled"
#define DB_KEY_NICK "Nick"
#define DB_KEY_AVHASH "AvatarHash"
-#define DB_KEY_HIDECHATS "HideChats"
#define DB_KEY_CHANNELID "ChannelID"
#define DB_KEY_LASTMSGID "LastMessageID"
#define DB_KEY_REQAUTH "ReqAuth"
-#define DB_KEY_GROUP "GroupName"
#define DB_KEYVAL_GROUP L"Discord"
#include "version.h"