summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-06-17 14:17:35 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-06-17 14:17:35 +0300
commitb4794ea974e77df6c8e6e096eaad562b8c3eda07 (patch)
tree352c8dd75701b1e80373d94129b3b7e7d6125353
parent1923923f9c370f19491b347675a3a1d108bf7eac (diff)
fixes #4474 (Msg_Export: при удалении учётной записи плагин сперва предлагает переименовать файл, а потом удалить)
-rw-r--r--plugins/Msg_Export/src/utils.cpp11
-rw-r--r--plugins/Msg_Export/src/utils.h2
2 files changed, 8 insertions, 5 deletions
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp
index 97bae746d1..8544154802 100644
--- a/plugins/Msg_Export/src/utils.cpp
+++ b/plugins/Msg_Export/src/utils.cpp
@@ -184,11 +184,11 @@ int nContactDeleted(WPARAM hContact, LPARAM)
if (g_enDeleteAction == eDANothing)
return 0;
- wstring sFilePath = GetFilePathFromUser(hContact);
+ wstring sFilePath = GetFilePathFromUser(hContact, true);
// Test if there is another user using this file
for (auto &hOtherContact : Contacts())
- if (hContact != hOtherContact && sFilePath == GetFilePathFromUser(hOtherContact))
+ if (hContact != hOtherContact && sFilePath == GetFilePathFromUser(hOtherContact, true))
return 0; // we found another contact abort mission :-)
// Test to see if there is a file to delete
@@ -241,8 +241,12 @@ static bool CompareNoExt(const wstring &s1, const wstring &s2)
return t1 == t2;
}
-wstring GetFilePathFromUser(MCONTACT hContact)
+wstring GetFilePathFromUser(MCONTACT hContact, bool bIgnoreRename)
{
+ wstring sPrevFileName = _DBGetStringW(hContact, MODULENAME, "PrevFileName", L"");
+ if (!sPrevFileName.empty() && bIgnoreRename)
+ return sPrevFileName;
+
wstring sFilePath = g_sExportDir + _DBGetStringW(hContact, MODULENAME, "FileName", g_sDefaultFile.c_str());
if (g_bUseJson)
sFilePath += L".json";
@@ -257,7 +261,6 @@ wstring GetFilePathFromUser(MCONTACT hContact)
ReplaceDBPath(sFilePath);
// Previous file name check to see if it has changed !!
- wstring sPrevFileName = _DBGetStringW(hContact, MODULENAME, "PrevFileName", L"");
if (!CompareNoExt(sNoDBPath, sPrevFileName)) {
if (!sPrevFileName.empty()) {
ReplaceDBPath(sPrevFileName);
diff --git a/plugins/Msg_Export/src/utils.h b/plugins/Msg_Export/src/utils.h
index 19a31de5b4..c39b0770ae 100644
--- a/plugins/Msg_Export/src/utils.h
+++ b/plugins/Msg_Export/src/utils.h
@@ -56,7 +56,7 @@ wstring __inline _DBGetStringW(MCONTACT hContact, const char *szModule, const ch
void UpdateFileToColWidth();
-wstring GetFilePathFromUser(MCONTACT hContact);
+wstring GetFilePathFromUser(MCONTACT hContact, bool bIgnoreRename = false);
void ReplaceDefines(MCONTACT hContact, wstring &sTarget);
void ReplaceTimeVariables(wstring &sRet);