summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-05-11 17:01:18 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-05-11 17:01:18 +0300
commit298c9deaf279da60906891dfb1881cd45687f157 (patch)
tree39762b69a32c30927d716c7df31f685e1511574e /protocols
parentadc82c1bfa455a4f5482a7937e5bb6e4cf2a7ff2 (diff)
fixes #812 ([Discord] If a contact removes you from their contact list, miranda silently and deletes all contact data)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Discord/res/discord.rc6
-rw-r--r--protocols/Discord/src/dispatch.cpp14
-rw-r--r--protocols/Discord/src/options.cpp4
-rw-r--r--protocols/Discord/src/proto.cpp3
-rw-r--r--protocols/Discord/src/proto.h15
-rw-r--r--protocols/Discord/src/resource.h2
6 files changed, 29 insertions, 15 deletions
diff --git a/protocols/Discord/res/discord.rc b/protocols/Discord/res/discord.rc
index 283582c0da..3deda76b9e 100644
--- a/protocols/Discord/res/discord.rc
+++ b/protocols/Discord/res/discord.rc
@@ -66,7 +66,7 @@ IDI_VOICE_ENDED ICON "voiceEnded.ico"
// Dialog
//
-IDD_OPTIONS_ACCOUNT DIALOGEX 0, 0, 305, 228
+IDD_OPTIONS_ACCOUNT DIALOGEX 0, 0, 305, 161
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@@ -76,7 +76,7 @@ BEGIN
EDITTEXT IDC_USERNAME,84,18,123,13,ES_AUTOHSCROLL
LTEXT "Password:",IDC_STATIC,17,36,61,8,0,WS_EX_RIGHT
EDITTEXT IDC_PASSWORD,84,34,123,13,ES_PASSWORD | ES_AUTOHSCROLL
- GROUPBOX "Contacts",IDC_STATIC,7,54,291,86
+ GROUPBOX "Contacts",IDC_STATIC,7,54,291,101
LTEXT "Default group:",IDC_STATIC,17,73,61,8,0,WS_EX_RIGHT
EDITTEXT IDC_GROUP,84,71,123,13,ES_AUTOHSCROLL
CONTROL "Enable guilds (servers)",IDC_USEGUILDS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,90,275,10
@@ -87,6 +87,8 @@ BEGIN
CONTROL "Delete messages in Miranda when they are deleted from server",IDC_DELETE_MSGS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,126,275,10
PUSHBUTTON "Log out",IDC_LOGOUT,211,18,81,13
+ CONTROL "Delete contacts in Miranda when they are deleted from server",IDC_DELETE_CONTACTS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,139,275,10
END
IDD_OPTIONS_ACCMGR DIALOGEX 0, 0, 200, 88
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp
index a2a5cd8a57..09a3c3deab 100644
--- a/protocols/Discord/src/dispatch.cpp
+++ b/protocols/Discord/src/dispatch.cpp
@@ -110,7 +110,11 @@ void CDiscordProto::OnCommandChannelDeleted(const JSONNode &pRoot)
Chat_Control(si, SESSION_OFFLINE);
Chat_Terminate(si);
}
- db_delete_contact(pUser->hContact);
+
+ if (m_bSyncDeleteUsers)
+ db_delete_contact(pUser->hContact);
+ else
+ Contact::Hide(pUser->hContact);
}
else {
CDiscordGuild *pGuild = FindGuild(guildId);
@@ -236,8 +240,12 @@ void CDiscordProto::OnCommandFriendRemoved(const JSONNode &pRoot)
CDiscordUser *pUser = FindUser(id);
if (pUser != nullptr) {
if (pUser->hContact)
- if (pUser->bIsPrivate)
- db_delete_contact(pUser->hContact);
+ if (pUser->bIsPrivate) {
+ if (m_bSyncDeleteUsers)
+ db_delete_contact(pUser->hContact);
+ else
+ Contact::Hide(pUser->hContact);
+ }
arUsers.remove(pUser);
}
diff --git a/protocols/Discord/src/options.cpp b/protocols/Discord/src/options.cpp
index 8577399926..ea2d9a1598 100644
--- a/protocols/Discord/src/options.cpp
+++ b/protocols/Discord/src/options.cpp
@@ -23,7 +23,7 @@ class CDiscardAccountOptions : public CDiscordDlgBase
{
ptrW m_wszOldGroup;
CCtrlEdit m_edGroup, m_edUserName, m_edPassword;
- CCtrlCheck chkUseChats, chkHideChats, chkUseGroups, chkDeleteMsgs;
+ CCtrlCheck chkUseChats, chkHideChats, chkUseGroups, chkDeleteMsgs, chkDeleteUsers;
CCtrlButton btnLogout;
public:
@@ -37,6 +37,7 @@ public:
chkHideChats(this, IDC_HIDECHATS),
chkUseGroups(this, IDC_USEGROUPS),
chkDeleteMsgs(this, IDC_DELETE_MSGS),
+ chkDeleteUsers(this, IDC_DELETE_CONTACTS),
m_wszOldGroup(mir_wstrdup(ppro->m_wszDefaultGroup))
{
btnLogout.OnClick = Callback(this, &CDiscardAccountOptions::onClick_Logout);
@@ -48,6 +49,7 @@ public:
CreateLink(chkHideChats, ppro->m_bHideGroupchats);
CreateLink(chkUseGroups, ppro->m_bUseGuildGroups);
CreateLink(chkDeleteMsgs, ppro->m_bSyncDeleteMsgs);
+ CreateLink(chkDeleteUsers, ppro->m_bSyncDeleteUsers);
chkUseChats.OnChange = Callback(this, &CDiscardAccountOptions::onChange_GroupChats);
}
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp
index b05a46d330..5056282794 100644
--- a/protocols/Discord/src/proto.cpp
+++ b/protocols/Discord/src/proto.cpp
@@ -50,11 +50,12 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) :
m_wszEmail(this, "Email", L""),
m_wszDefaultGroup(this, "GroupName", DB_KEYVAL_GROUP),
+ m_bSyncMarkRead(this, "SendMarkRead", true),
m_bUseGroupchats(this, "UseGroupChats", true),
m_bHideGroupchats(this, "HideChats", true),
m_bUseGuildGroups(this, "UseGuildGroups", false),
m_bSyncDeleteMsgs(this, "DeleteServerMsgs", true),
- m_bSyncMarkRead(this, "SendMarkRead", true)
+ m_bSyncDeleteUsers(this, "DeleteServerUsers", true)
{
// Services
CreateProtoService(PS_GETAVATARINFO, &CDiscordProto::GetAvatarInfo);
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index f48f2db66f..438c97d6e1 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -323,13 +323,14 @@ class CDiscordProto : public PROTO<CDiscordProto>
//////////////////////////////////////////////////////////////////////////////////////
// options
- CMOption<wchar_t*> m_wszEmail; // my own email
- CMOption<wchar_t*> m_wszDefaultGroup; // clist group to store contacts
- CMOption<bool> m_bUseGroupchats; // Shall we connect Guilds at all?
- CMOption<bool> m_bHideGroupchats; // Do not open chat windows on creation
- CMOption<bool> m_bUseGuildGroups; // use special subgroups for guilds
- CMOption<bool> m_bSyncDeleteMsgs; // delete messages from Miranda if they are deleted at the server
- CMOption<bool> m_bSyncMarkRead; // hidden option: send "mark read" packet to server when Miranda displays a message
+ CMOption<wchar_t*> m_wszEmail; // my own email
+ CMOption<wchar_t*> m_wszDefaultGroup; // clist group to store contacts
+ CMOption<bool> m_bUseGroupchats; // Shall we connect Guilds at all?
+ CMOption<bool> m_bHideGroupchats; // Do not open chat windows on creation
+ CMOption<bool> m_bUseGuildGroups; // use special subgroups for guilds
+ CMOption<bool> m_bSyncDeleteMsgs; // delete messages from Miranda if they are deleted at the server
+ CMOption<bool> m_bSyncDeleteUsers; // delete contacts from Miranda if they are deleted at the server
+ CMOption<bool> m_bSyncMarkRead; // hidden option: send "mark read" packet to server when Miranda displays a message
//////////////////////////////////////////////////////////////////////////////////////
// common data
diff --git a/protocols/Discord/src/resource.h b/protocols/Discord/src/resource.h
index cf6c1a467d..db89687790 100644
--- a/protocols/Discord/src/resource.h
+++ b/protocols/Discord/src/resource.h
@@ -22,10 +22,10 @@
#define IDC_DELETE_MSGS 1009
#define IDC_ANOTHER 1009
#define IDC_LABEL 1010
+#define IDC_DELETE_CONTACTS 1010
#define IDC_LOGOUT 1011
#define IDC_CLIST 1012
-
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED