From 24da6586bfdb3e41cc8240e41162b016e10b68c3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 28 Apr 2025 15:21:18 +0300 Subject: =?UTF-8?q?fixes=20#4998=20(=D0=92=20=D0=BE=D0=BA=D0=BD=D0=B5=20?= =?UTF-8?q?=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B9=20Dummy-?= =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=82=D0=B0=D0=BA=D1=82=D0=B0=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=20=D0=B2=D0=B2=D0=BE=D0=B4=D0=B0=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BA=D1=81=D1=82=D0=B0=20=D0=BD=D0=B5=20=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Dummy/src/dummy.h | 1 - protocols/Dummy/src/dummy_options.cpp | 5 ++--- protocols/Dummy/src/dummy_proto.cpp | 7 ++++--- protocols/Dummy/src/dummy_proto.h | 3 ++- protocols/Dummy/src/main.cpp | 15 ++++++++------- 5 files changed, 16 insertions(+), 15 deletions(-) (limited to 'protocols') diff --git a/protocols/Dummy/src/dummy.h b/protocols/Dummy/src/dummy.h index e06e8d81ac..69d250ca03 100644 --- a/protocols/Dummy/src/dummy.h +++ b/protocols/Dummy/src/dummy.h @@ -22,7 +22,6 @@ struct CDummyProto; #define DUMMY_ID_TEMPLATE "Template" #define DUMMY_ID_TEXT "UniqueIdText" #define DUMMY_ID_SETTING "UniqueIdSetting" -#define DUMMY_KEY_ALLOW_SENDING "AllowSending" struct ttemplate { diff --git a/protocols/Dummy/src/dummy_options.cpp b/protocols/Dummy/src/dummy_options.cpp index 226b1825ca..205a74814d 100644 --- a/protocols/Dummy/src/dummy_options.cpp +++ b/protocols/Dummy/src/dummy_options.cpp @@ -38,8 +38,7 @@ INT_PTR CALLBACK DummyAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM int templateId = ppro->getTemplateId(); SendDlgItemMessage(hwndDlg, IDC_TEMPLATE, CB_SETCURSEL, templateId, 0); - boolean allowSending = ppro->getByte(DUMMY_KEY_ALLOW_SENDING, 0); - CheckDlgButton(hwndDlg, IDC_ALLOW_SENDING, allowSending ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ALLOW_SENDING, ppro->bAllowSending ? BST_CHECKED : BST_UNCHECKED); ppro->selectTemplate(hwndDlg, templateId); } @@ -81,7 +80,7 @@ INT_PTR CALLBACK DummyAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM ppro->setString(DUMMY_ID_SETTING, str); } - ppro->setByte(DUMMY_KEY_ALLOW_SENDING, IsDlgButtonChecked(hwndDlg, IDC_ALLOW_SENDING)); + ppro->bAllowSending = IsDlgButtonChecked(hwndDlg, IDC_ALLOW_SENDING); } break; diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp index 295872252a..db82416df5 100644 --- a/protocols/Dummy/src/dummy_proto.cpp +++ b/protocols/Dummy/src/dummy_proto.cpp @@ -81,7 +81,8 @@ static int sttCompareProtocols(const CDummyProto *p1, const CDummyProto *p2) } CDummyProto::CDummyProto(const char *szModuleName, const wchar_t *ptszUserName) : - PROTO(szModuleName, ptszUserName) + PROTO(szModuleName, ptszUserName), + bAllowSending(szModuleName, "AllowSending", false) { msgid = 0; @@ -139,7 +140,7 @@ INT_PTR CDummyProto::GetCaps(int type, MCONTACT) { switch(type) { case PFLAGNUM_1: - return PF1_IM | PF1_BASICSEARCH | PF1_ADDSEARCHRES; + return PF1_BASICSEARCH | PF1_ADDSEARCHRES | (bAllowSending ? PF1_IM : 0); case PFLAGNUM_4: return PF4_AVATARS | PF4_NOAUTHDENYREASON | PF4_NOCUSTOMAUTH; @@ -191,7 +192,7 @@ int CDummyProto::SendMsg(MCONTACT hContact, MEVENT, const char *msg) std::string message = msg; unsigned int id = InterlockedIncrement(&msgid); - if (getByte(DUMMY_KEY_ALLOW_SENDING, 0)) + if (bAllowSending) ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id); else ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)id, (LPARAM)TranslateT("This Dummy account has disabled sending messages. Enable it in account options.")); diff --git a/protocols/Dummy/src/dummy_proto.h b/protocols/Dummy/src/dummy_proto.h index adbfd643b4..573d24cc0e 100644 --- a/protocols/Dummy/src/dummy_proto.h +++ b/protocols/Dummy/src/dummy_proto.h @@ -38,7 +38,7 @@ struct CDummyProto : public PROTO MCONTACT AddToList(int flags, PROTOSEARCHRESULT* psr) override; - //==== Events ========================================================================== + //====================================================================================== MWindow OnCreateAccMgrUI(MWindow) override; @@ -50,5 +50,6 @@ struct CDummyProto : public PROTO int getTemplateId(); void selectTemplate(HWND, int templateId); + CMOption bAllowSending; volatile unsigned int msgid; }; diff --git a/protocols/Dummy/src/main.cpp b/protocols/Dummy/src/main.cpp index 034231f0b5..23c47005a4 100644 --- a/protocols/Dummy/src/main.cpp +++ b/protocols/Dummy/src/main.cpp @@ -54,13 +54,14 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC static int OnDummyDoubleClicked(WPARAM hContact, LPARAM) { if (auto *pa = Proto_GetContactAccount(hContact)) - if (pa->ppro && pa->ppro->GetCaps(1000)) { - if (Contact::IsGroupChat(hContact)) - CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0); - else - CallService(MS_MSG_SENDMESSAGE, hContact, 0); - return 1; - } + if (auto *ppro = (CDummyProto*)pa->ppro) + if (ppro->GetCaps(1000)) { + if (Contact::IsGroupChat(hContact) || !ppro->bAllowSending) + CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0); + else + CallService(MS_MSG_SENDMESSAGE, hContact, 0); + return 1; + } return 0; } -- cgit v1.2.3