From 5fdd629c6420a1ce0751291e348b3eee9c6db15e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 17 Jul 2024 13:11:49 +0300 Subject: =?UTF-8?q?fixes=20#4543=20(Dummy:=20=D0=B3=D1=80=D1=83=D0=BF?= =?UTF-8?q?=D1=87=D0=B0=D1=82=D1=8B=20=D0=B3=D0=BB=D1=8E=D1=87=D0=B0=D1=82?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Dummy/src/dummy_options.cpp | 2 +- protocols/Dummy/src/dummy_proto.cpp | 19 ++++++++----------- protocols/Dummy/src/dummy_proto.h | 3 ++- protocols/Dummy/src/main.cpp | 12 ++++++++++++ protocols/Dummy/src/stdafx.h | 1 + 5 files changed, 24 insertions(+), 13 deletions(-) (limited to 'protocols/Dummy') diff --git a/protocols/Dummy/src/dummy_options.cpp b/protocols/Dummy/src/dummy_options.cpp index d1d7175905..31af8ffa80 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 = ppro->getTemplateId(); + int templateId = getDummyProtocolId(ppro->m_szModuleName); 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 285cbe0f21..6864135748 100644 --- a/protocols/Dummy/src/dummy_proto.cpp +++ b/protocols/Dummy/src/dummy_proto.cpp @@ -19,11 +19,8 @@ along with this program. If not, see . const ttemplate templates[] = { - { LPGEN("Custom"), "", "" }, - { "AIM", "SN", LPGEN("Screen name") }, -#ifndef MIRANDA_VERSION_ISALPHA - { "Discord", "id", LPGEN("Discord ID") }, -#endif + { LPGEN("Custom"), "", "" }, + { "AIM", "SN", LPGEN("Screen name") }, { "EmLAN", "Nick", LPGEN("User name") }, { "Facebook", "ID", LPGEN("Facebook ID") }, { "GG", "UIN", LPGEN("Gadu-Gadu number") }, @@ -83,7 +80,7 @@ CDummyProto::CDummyProto(const char *szModuleName, const wchar_t *ptszUserName) { msgid = 0; - int id = getTemplateId(); + int id = getDummyProtocolId(m_szModuleName); ptrA setting(id > 0 ? mir_strdup(templates[id].setting) : getStringA(DUMMY_ID_SETTING)); if (setting != NULL) { strncpy_s(uniqueIdText, setting, _TRUNCATE); @@ -100,18 +97,18 @@ CDummyProto::~CDummyProto() ////////////////////////////////////////////////////////////////////////////// -int CDummyProto::getTemplateId() +int getDummyProtocolId(const char *pszModuleName) { - int id = this->getByte(DUMMY_ID_TEMPLATE, -1); + int id = db_get_b(0, pszModuleName, DUMMY_ID_TEMPLATE, -1); if (id >= 0 && id < _countof(templates)) return id; - CMStringA szProto(getMStringA("AM_BaseProto")); + CMStringA szProto(db_get_sm(0, pszModuleName, "AM_BaseProto")); for (auto &it : templates) if (!stricmp(it.name, szProto)) return int(&it - templates); - return 0; + return -1; } void CDummyProto::selectTemplate(HWND hwndDlg, int templateId) @@ -152,7 +149,7 @@ INT_PTR CDummyProto::GetCaps(int type, MCONTACT) case PFLAG_UNIQUEIDTEXT: if (uniqueIdSetting[0] == '\0') { - int id = getTemplateId(); + int id = getDummyProtocolId(m_szModuleName); ptrW setting(id > 0 ? mir_a2u(Translate(templates[id].text)) : getWStringA(DUMMY_ID_TEXT)); if (setting != NULL) wcsncpy_s(uniqueIdSetting, setting, _TRUNCATE); diff --git a/protocols/Dummy/src/dummy_proto.h b/protocols/Dummy/src/dummy_proto.h index b56795eedf..2138d36466 100644 --- a/protocols/Dummy/src/dummy_proto.h +++ b/protocols/Dummy/src/dummy_proto.h @@ -47,8 +47,9 @@ 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 29a6cf6ef8..70100b0ce1 100644 --- a/protocols/Dummy/src/main.cpp +++ b/protocols/Dummy/src/main.cpp @@ -51,8 +51,20 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC ///////////////////////////////////////////////////////////////////////////////////////// // OnLoad - initialize the plugin instance +static int OnDummyDoubleClicked(WPARAM hContact, LPARAM) +{ + if (auto *pa = Proto_GetContactAccount(hContact)) + if (getDummyProtocolId(pa->szModuleName) != -1 && Contact::IsGroupChat(hContact)) { + CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0); + return 1; + } + + return 0; +} + int CMPlugin::Load() { + HookEvent(ME_CLIST_DOUBLECLICKED, OnDummyDoubleClicked); return 0; } diff --git a/protocols/Dummy/src/stdafx.h b/protocols/Dummy/src/stdafx.h index 4dd662c2db..254731c90d 100644 --- a/protocols/Dummy/src/stdafx.h +++ b/protocols/Dummy/src/stdafx.h @@ -36,6 +36,7 @@ along with this program. If not, see . #include #include #include +#include #include #include #include -- cgit v1.2.3