From 40e3aefb71b033d8aeb120e33e86fe0f2c757a11 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 17 Jul 2024 14:20:18 +0300 Subject: more accurate fix for #4543 --- protocols/Dummy/src/dummy_options.cpp | 2 +- protocols/Dummy/src/dummy_proto.cpp | 17 ++++++++++------- protocols/Dummy/src/dummy_proto.h | 3 +-- protocols/Dummy/src/main.cpp | 2 +- 4 files changed, 13 insertions(+), 11 deletions(-) (limited to 'protocols/Dummy/src') diff --git a/protocols/Dummy/src/dummy_options.cpp b/protocols/Dummy/src/dummy_options.cpp index 31af8ffa80..d1d7175905 100644 --- a/protocols/Dummy/src/dummy_options.cpp +++ b/protocols/Dummy/src/dummy_options.cpp @@ -35,7 +35,7 @@ INT_PTR CALLBACK DummyAccountProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM { FillTemplateCombo(hwndDlg, IDC_TEMPLATE); - int templateId = getDummyProtocolId(ppro->m_szModuleName); + int templateId = ppro->getTemplateId(); SendDlgItemMessage(hwndDlg, IDC_TEMPLATE, CB_SETCURSEL, templateId, 0); boolean allowSending = ppro->getByte(DUMMY_KEY_ALLOW_SENDING, 0); diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp index 6864135748..bb96fcbeea 100644 --- a/protocols/Dummy/src/dummy_proto.cpp +++ b/protocols/Dummy/src/dummy_proto.cpp @@ -80,7 +80,7 @@ CDummyProto::CDummyProto(const char *szModuleName, const wchar_t *ptszUserName) { msgid = 0; - int id = getDummyProtocolId(m_szModuleName); + int id = getTemplateId(); ptrA setting(id > 0 ? mir_strdup(templates[id].setting) : getStringA(DUMMY_ID_SETTING)); if (setting != NULL) { strncpy_s(uniqueIdText, setting, _TRUNCATE); @@ -97,18 +97,18 @@ CDummyProto::~CDummyProto() ////////////////////////////////////////////////////////////////////////////// -int getDummyProtocolId(const char *pszModuleName) +int CDummyProto::getTemplateId() { - int id = db_get_b(0, pszModuleName, DUMMY_ID_TEMPLATE, -1); + int id = getByte(DUMMY_ID_TEMPLATE, -1); if (id >= 0 && id < _countof(templates)) return id; - CMStringA szProto(db_get_sm(0, pszModuleName, "AM_BaseProto")); + CMStringA szProto(getMStringA("AM_BaseProto")); for (auto &it : templates) if (!stricmp(it.name, szProto)) return int(&it - templates); - return -1; + return 0; } void CDummyProto::selectTemplate(HWND hwndDlg, int templateId) @@ -149,12 +149,15 @@ INT_PTR CDummyProto::GetCaps(int type, MCONTACT) case PFLAG_UNIQUEIDTEXT: if (uniqueIdSetting[0] == '\0') { - int id = getDummyProtocolId(m_szModuleName); + int id = getTemplateId(); ptrW setting(id > 0 ? mir_a2u(Translate(templates[id].text)) : getWStringA(DUMMY_ID_TEXT)); if (setting != NULL) wcsncpy_s(uniqueIdSetting, setting, _TRUNCATE); } return (INT_PTR)uniqueIdSetting; + + case 1000: // hidden caps + return TRUE; } return 0; } @@ -164,7 +167,7 @@ INT_PTR CDummyProto::GetCaps(int type, MCONTACT) int CDummyProto::SendMsg(MCONTACT hContact, MEVENT, const char *msg) { std::string message = msg; - unsigned int id = InterlockedIncrement(&this->msgid); + unsigned int id = InterlockedIncrement(&msgid); if (getByte(DUMMY_KEY_ALLOW_SENDING, 0)) ProtoBroadcastAsync(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)id); diff --git a/protocols/Dummy/src/dummy_proto.h b/protocols/Dummy/src/dummy_proto.h index 2138d36466..b56795eedf 100644 --- a/protocols/Dummy/src/dummy_proto.h +++ b/protocols/Dummy/src/dummy_proto.h @@ -47,9 +47,8 @@ struct CDummyProto : public PROTO char uniqueIdText[100]; wchar_t uniqueIdSetting[100]; + int getTemplateId(); void selectTemplate(HWND, int templateId); volatile unsigned int msgid; }; - -int getDummyProtocolId(const char *pszModuleName); diff --git a/protocols/Dummy/src/main.cpp b/protocols/Dummy/src/main.cpp index 70100b0ce1..0dccbb7529 100644 --- a/protocols/Dummy/src/main.cpp +++ b/protocols/Dummy/src/main.cpp @@ -54,7 +54,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC static int OnDummyDoubleClicked(WPARAM hContact, LPARAM) { if (auto *pa = Proto_GetContactAccount(hContact)) - if (getDummyProtocolId(pa->szModuleName) != -1 && Contact::IsGroupChat(hContact)) { + if (pa->ppro && pa->ppro->GetCaps(1000)) { CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0); return 1; } -- cgit v1.2.3