summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2025-04-14 13:54:00 +0300
committerGeorge Hazan <george.hazan@gmail.com>2025-04-14 13:54:00 +0300
commitf860d13465dfb6e1fb8a480d3131c51c1dd9e668 (patch)
treee59ae5d6c7c6d5752c76431cdfec2d75e622768d
parent9810f9fc412bbbde03a719867dec86dd0a89b132 (diff)
fixes #4982 (Dummy: при преобразовании учётки в Dummy-учётку, выставляется Custom протокол, а не реальный)
-rw-r--r--protocols/Dummy/src/dummy_proto.cpp7
-rw-r--r--src/mir_app/src/proto_opts.cpp53
2 files changed, 37 insertions, 23 deletions
diff --git a/protocols/Dummy/src/dummy_proto.cpp b/protocols/Dummy/src/dummy_proto.cpp
index c2acbabc3e..55b4e9f224 100644
--- a/protocols/Dummy/src/dummy_proto.cpp
+++ b/protocols/Dummy/src/dummy_proto.cpp
@@ -104,9 +104,12 @@ int CDummyProto::getTemplateId()
if (id >= 0 && id < _countof(templates))
return id;
- CMStringA szProto(getMStringA("AM_BaseProto"));
+ CMStringA szProto(getMStringA("AM_PrevProto"));
+ if (szProto.IsEmpty())
+ szProto = getMStringA("AM_BaseProto");
+
for (auto &it : templates)
- if (!stricmp(it.name, szProto))
+ if (szProto == it.name)
return int(&it - templates);
return 0;
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp
index b7ccb7717b..0127fd1285 100644
--- a/src/mir_app/src/proto_opts.cpp
+++ b/src/mir_app/src/proto_opts.cpp
@@ -906,32 +906,43 @@ bool CAccountFormDlg::OnApply()
}
}
- if (m_action == PRAC_UPGRADED) {
- BOOL oldProto = m_pa->bOldProto;
- wchar_t szPlugin[MAX_PATH];
- mir_snwprintf(szPlugin, L"%S.dll", m_pa->szProtoName);
- int idx = g_arAccounts.getIndex(m_pa);
- UnloadAccount(m_pa, 0);
- g_arAccounts.remove(idx);
- if (oldProto && UnloadPlugin(szPlugin, _countof(szPlugin))) {
- wchar_t szNewName[MAX_PATH];
- mir_snwprintf(szNewName, L"%s~", szPlugin);
- MoveFileW(szPlugin, szNewName);
+ switch (m_action) {
+ case PRAC_UPGRADED:
+ {
+ // save values from m_pa before it got destroyed
+ bool oldProto = m_pa->bOldProto;
+ wchar_t szPlugin[MAX_PATH];
+ mir_snwprintf(szPlugin, L"%S.dll", m_pa->szProtoName);
+ db_set_s(0, m_pa->szModuleName, "AM_PrevProto", m_pa->szProtoName);
+
+ // remove old account
+ int idx = g_arAccounts.getIndex(m_pa);
+ UnloadAccount(m_pa, 0);
+ g_arAccounts.remove(idx);
+
+ // also rename the protocol dll for old accounts
+ if (oldProto && UnloadPlugin(szPlugin, _countof(szPlugin))) {
+ wchar_t szNewName[MAX_PATH];
+ mir_snwprintf(szNewName, L"%s~", szPlugin);
+ MoveFileW(szPlugin, szNewName);
+ }
}
- m_action = PRAC_ADDED;
- }
+ __fallthrough;
- if (m_action == PRAC_ADDED) {
+ case PRAC_ADDED:
char buf[200];
GetDlgItemTextA(m_hwnd, IDC_PROTOTYPECOMBO, buf, _countof(buf));
- char *szBaseProto = NEWSTR_ALLOCA(buf);
-
- m_internalName.GetTextA(buf, _countof(buf));
- rtrim(buf);
+ {
+ char *szBaseProto = NEWSTR_ALLOCA(buf);
+ m_internalName.GetTextA(buf, _countof(buf));
- m_pa = Proto_CreateAccount(buf, szBaseProto, wszAccName);
- }
- else {
+ rtrim(buf);
+ m_pa = Proto_CreateAccount(buf, szBaseProto, wszAccName);
+ }
+ break;
+
+ default:
+ // just change the account name and write it down
replaceStrW(m_pa->tszAccountName, wszAccName);
WriteDbAccounts();