Index: src/ch/FeedbackFileErrorDlg.cpp =================================================================== diff -u -r08717141ce5f6926116c298cbc9442094a45bb67 -r3993a75a24145732742d61be638111d1d85c367b --- src/ch/FeedbackFileErrorDlg.cpp (.../FeedbackFileErrorDlg.cpp) (revision 08717141ce5f6926116c298cbc9442094a45bb67) +++ src/ch/FeedbackFileErrorDlg.cpp (.../FeedbackFileErrorDlg.cpp) (revision 3993a75a24145732742d61be638111d1d85c367b) @@ -12,12 +12,13 @@ IMPLEMENT_DYNAMIC(CFeedbackFileErrorDlg, ictranslate::CLanguageDialog) -CFeedbackFileErrorDlg::CFeedbackFileErrorDlg(const wchar_t* pszSrcPath, const wchar_t* pszDstPath, unsigned long ulSysError, CWnd* pParent /*=nullptr*/) +CFeedbackFileErrorDlg::CFeedbackFileErrorDlg(chengine::FeedbackRules& currentRules, const wchar_t* pszSrcPath, const wchar_t* pszDstPath, unsigned long ulSysError, CWnd* pParent /*=nullptr*/) : ictranslate::CLanguageDialog(IDD_FEEDBACK_FILE_ERROR_DIALOG, pParent), m_bAllItems(FALSE), m_strSrcPath(pszSrcPath), m_strDstPath(pszDstPath), - m_ulSysError(ulSysError) + m_ulSysError(ulSysError), + m_rules(currentRules) { } @@ -30,9 +31,9 @@ return m_bAllItems; } -const chengine::FeedbackErrorRuleList& CFeedbackFileErrorDlg::GetRules() const +const chengine::FeedbackRules& CFeedbackFileErrorDlg::GetRules() const { - return m_feedbackRules; + return m_rules; } void CFeedbackFileErrorDlg::DoDataExchange(CDataExchange* pDX) Index: src/ch/FeedbackFileErrorDlg.h =================================================================== diff -u -r08717141ce5f6926116c298cbc9442094a45bb67 -r3993a75a24145732742d61be638111d1d85c367b --- src/ch/FeedbackFileErrorDlg.h (.../FeedbackFileErrorDlg.h) (revision 08717141ce5f6926116c298cbc9442094a45bb67) +++ src/ch/FeedbackFileErrorDlg.h (.../FeedbackFileErrorDlg.h) (revision 3993a75a24145732742d61be638111d1d85c367b) @@ -20,19 +20,20 @@ #define __FEEDBACKFILEERRORDLG_H__ #include "../libchengine/FeedbackErrorRuleList.h" +#include "../libchengine/FeedbackRules.h" // CFeedbackFileErrorDlg dialog class CFeedbackFileErrorDlg : public ictranslate::CLanguageDialog { DECLARE_DYNAMIC(CFeedbackFileErrorDlg) public: - CFeedbackFileErrorDlg(const wchar_t* pszSrcPath, const wchar_t* pszDstPath, unsigned long ulSysError, CWnd* pParent = nullptr); // standard constructor + CFeedbackFileErrorDlg(chengine::FeedbackRules& currentRules, const wchar_t* pszSrcPath, const wchar_t* pszDstPath, unsigned long ulSysError, CWnd* pParent = nullptr); // standard constructor virtual ~CFeedbackFileErrorDlg(); bool IsApplyToAllItemsChecked() const; - const chengine::FeedbackErrorRuleList& GetRules() const; + const chengine::FeedbackRules& GetRules() const; protected: void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support @@ -53,7 +54,7 @@ CString m_strDstPath; unsigned long m_ulSysError = 0; - chengine::FeedbackErrorRuleList m_feedbackRules; // feedback rules resulting from choices made in this dialog box + chengine::FeedbackRules& m_rules; }; #endif Index: src/ch/FeedbackHandler.cpp =================================================================== diff -u -rf01ed9a0279a52c96a7272273ef19e57f7670f4a -r3993a75a24145732742d61be638111d1d85c367b --- src/ch/FeedbackHandler.cpp (.../FeedbackHandler.cpp) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) +++ src/ch/FeedbackHandler.cpp (.../FeedbackHandler.cpp) (revision 3993a75a24145732742d61be638111d1d85c367b) @@ -30,12 +30,12 @@ using namespace chengine; using namespace string; -chengine::EFeedbackResult CFeedbackHandler::FileError(const TString& strSrcPath, const TString& strDstPath, EFileError /*eFileError*/, unsigned long ulError, FeedbackErrorRuleList& rNewRules) +chengine::EFeedbackResult CFeedbackHandler::FileError(const TString& strSrcPath, const TString& strDstPath, EFileError /*eFileError*/, unsigned long ulError, FeedbackRules& rNewRules) { - CFeedbackFileErrorDlg dlg(strSrcPath.c_str(), strDstPath.c_str(), ulError); + CFeedbackFileErrorDlg dlg(rNewRules, strSrcPath.c_str(), strDstPath.c_str(), ulError); EFeedbackResult eResult = (EFeedbackResult)dlg.DoModal(); - if(!dlg.GetRules().IsEmpty()) + if(dlg.GetRules().IsModified()) rNewRules = dlg.GetRules(); return eResult; @@ -51,24 +51,24 @@ if(eResult == eResult_Rename) strRenameName = dlg.GetNewName(); - if(!dlg.GetRules().IsModified()) + if(dlg.GetRules().IsModified()) rNewRules = dlg.GetRules(); return eResult; } -chengine::EFeedbackResult CFeedbackHandler::NotEnoughSpace(const TString& strSrcPath, const TString& strDstPath, unsigned long long ullRequiredSize, FeedbackNotEnoughSpaceRuleList& rNewRules) +chengine::EFeedbackResult CFeedbackHandler::NotEnoughSpace(const TString& strSrcPath, const TString& strDstPath, unsigned long long ullRequiredSize, FeedbackRules& rNewRules) { - CFeedbackNotEnoughSpaceDlg dlg(ullRequiredSize, strSrcPath.c_str(), strDstPath.c_str()); + CFeedbackNotEnoughSpaceDlg dlg(rNewRules, ullRequiredSize, strSrcPath.c_str(), strDstPath.c_str()); EFeedbackResult eResult = (EFeedbackResult) dlg.DoModal(); - if(!dlg.GetRules().IsEmpty()) + if(dlg.GetRules().IsModified()) rNewRules = dlg.GetRules(); return eResult; } -chengine::EFeedbackResult CFeedbackHandler::OperationEvent(EOperationEvent eEvent, FeedbackOperationEventRuleList&) +chengine::EFeedbackResult CFeedbackHandler::OperationEvent(EOperationEvent eEvent, FeedbackRules&) { switch(eEvent) { Index: src/ch/FeedbackHandler.h =================================================================== diff -u -rf01ed9a0279a52c96a7272273ef19e57f7670f4a -r3993a75a24145732742d61be638111d1d85c367b --- src/ch/FeedbackHandler.h (.../FeedbackHandler.h) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) +++ src/ch/FeedbackHandler.h (.../FeedbackHandler.h) (revision 3993a75a24145732742d61be638111d1d85c367b) @@ -29,13 +29,13 @@ class CFeedbackHandler : public chengine::IFeedbackHandler { public: - chengine::EFeedbackResult FileError(const string::TString& strSrcPath, const string::TString& strDstPath, chengine::EFileError eFileError, unsigned long ulError, chengine::FeedbackErrorRuleList& rNewRules) override; + chengine::EFeedbackResult FileError(const string::TString& strSrcPath, const string::TString& strDstPath, chengine::EFileError eFileError, unsigned long ulError, chengine::FeedbackRules& rNewRules) override; chengine::EFeedbackResult FileAlreadyExists(const chengine::TFileInfo& spSrcFileInfo, const chengine::TFileInfo& spDstFileInfo, string::TString& strRenameName, chengine::FeedbackRules& rNewRules) override; - chengine::EFeedbackResult NotEnoughSpace(const string::TString& strSrcPath, const string::TString& strDstPath, unsigned long long ullRequiredSize, chengine::FeedbackNotEnoughSpaceRuleList& rNewRules) override; - chengine::EFeedbackResult OperationEvent(chengine::EOperationEvent eEvent, chengine::FeedbackOperationEventRuleList& rNewRules) override; + chengine::EFeedbackResult NotEnoughSpace(const string::TString& strSrcPath, const string::TString& strDstPath, unsigned long long ullRequiredSize, chengine::FeedbackRules& rNewRules) override; + chengine::EFeedbackResult OperationEvent(chengine::EOperationEvent eEvent, chengine::FeedbackRules& rNewRules) override; protected: friend class CFeedbackHandlerFactory; }; -typedef std::shared_ptr CFeedbackHandlerPtr; +using CFeedbackHandlerPtr = std::shared_ptr; Index: src/ch/FeedbackNotEnoughSpaceDlg.cpp =================================================================== diff -u -r08717141ce5f6926116c298cbc9442094a45bb67 -r3993a75a24145732742d61be638111d1d85c367b --- src/ch/FeedbackNotEnoughSpaceDlg.cpp (.../FeedbackNotEnoughSpaceDlg.cpp) (revision 08717141ce5f6926116c298cbc9442094a45bb67) +++ src/ch/FeedbackNotEnoughSpaceDlg.cpp (.../FeedbackNotEnoughSpaceDlg.cpp) (revision 3993a75a24145732742d61be638111d1d85c367b) @@ -32,24 +32,25 @@ ///////////////////////////////////////////////////////////////////////////// // CFeedbackNotEnoughSpaceDlg dialog -CFeedbackNotEnoughSpaceDlg::CFeedbackNotEnoughSpaceDlg(unsigned long long ullSizeRequired, const wchar_t* pszSrcPath, const wchar_t* pszDstPath) +CFeedbackNotEnoughSpaceDlg::CFeedbackNotEnoughSpaceDlg(chengine::FeedbackRules& currentRules, unsigned long long ullSizeRequired, const wchar_t* pszSrcPath, const wchar_t* pszDstPath) :ictranslate::CLanguageDialog(IDD_FEEDBACK_NOTENOUGHSPACE_DIALOG), m_strDisk(pszDstPath), m_ullRequired(ullSizeRequired), m_bAllItems(FALSE), - m_fsLocal(GetLogFileData()) + m_fsLocal(GetLogFileData()), + m_rules(currentRules) { - m_vstrFiles.push_back(pszSrcPath); + m_vstrFiles.emplace_back(pszSrcPath); } bool CFeedbackNotEnoughSpaceDlg::IsApplyToAllItemsChecked() const { return m_bAllItems; } -const chengine::FeedbackNotEnoughSpaceRuleList& CFeedbackNotEnoughSpaceDlg::GetRules() const +const chengine::FeedbackRules& CFeedbackNotEnoughSpaceDlg::GetRules() const { - return m_feedbackRules; + return m_rules; } void CFeedbackNotEnoughSpaceDlg::DoDataExchange(CDataExchange* pDX) Index: src/ch/FeedbackNotEnoughSpaceDlg.h =================================================================== diff -u -r08717141ce5f6926116c298cbc9442094a45bb67 -r3993a75a24145732742d61be638111d1d85c367b --- src/ch/FeedbackNotEnoughSpaceDlg.h (.../FeedbackNotEnoughSpaceDlg.h) (revision 08717141ce5f6926116c298cbc9442094a45bb67) +++ src/ch/FeedbackNotEnoughSpaceDlg.h (.../FeedbackNotEnoughSpaceDlg.h) (revision 3993a75a24145732742d61be638111d1d85c367b) @@ -21,18 +21,19 @@ #include "../libchengine/TLocalFilesystem.h" #include "../libchengine/FeedbackNotEnoughSpaceRuleList.h" +#include "../libchengine/FeedbackRules.h" ///////////////////////////////////////////////////////////////////////////// // CFeedbackNotEnoughSpaceDlg dialog class CFeedbackNotEnoughSpaceDlg : public ictranslate::CLanguageDialog { public: - CFeedbackNotEnoughSpaceDlg(unsigned long long ullSizeRequired, const wchar_t* pszSrcPath, const wchar_t* pszDstPath); // standard constructor + CFeedbackNotEnoughSpaceDlg(chengine::FeedbackRules& currentRules, unsigned long long ullSizeRequired, const wchar_t* pszSrcPath, const wchar_t* pszDstPath); // standard constructor bool IsApplyToAllItemsChecked() const; - const chengine::FeedbackNotEnoughSpaceRuleList& GetRules() const; + const chengine::FeedbackRules& GetRules() const; protected: void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support @@ -58,7 +59,7 @@ CListBox m_ctlFiles; chengine::TLocalFilesystem m_fsLocal; - chengine::FeedbackNotEnoughSpaceRuleList m_feedbackRules; // feedback rules resulting from choices made in this dialog box + chengine::FeedbackRules& m_rules; }; #endif Index: src/libchengine/FeedbackManager.cpp =================================================================== diff -u -rf01ed9a0279a52c96a7272273ef19e57f7670f4a -r3993a75a24145732742d61be638111d1d85c367b --- src/libchengine/FeedbackManager.cpp (.../FeedbackManager.cpp) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) +++ src/libchengine/FeedbackManager.cpp (.../FeedbackManager.cpp) (revision 3993a75a24145732742d61be638111d1d85c367b) @@ -63,19 +63,23 @@ if(eResult == eResult_Unknown) { - FeedbackErrorRuleList newRules; + FeedbackRules modRules; { + boost::shared_lock lock(m_lock); + modRules = m_feedbackRules; + } + { TScopedRunningTimeTrackerPause scopedTimePause(m_pTimeTracker); TScopedRunningTimeTrackerPause scopedSecondaryTimePause(m_pSecondaryTimeTracker); - eResult = m_spFeedbackHandler->FileError(strSrcPath, strDstPath, eFileError, ulError, newRules); + eResult = m_spFeedbackHandler->FileError(strSrcPath, strDstPath, eFileError, ulError, modRules); } if(eResult != eResult_Unknown) { bAutomatedResponse = false; - if(!newRules.IsEmpty()) + { boost::unique_lock lock(m_lock); - m_feedbackRules.GetErrorRules().Merge(newRules); + m_feedbackRules = modRules; } } } @@ -137,19 +141,23 @@ } if(eResult == eResult_Unknown) { - FeedbackNotEnoughSpaceRuleList newRules; + FeedbackRules modRules; { + boost::shared_lock lock(m_lock); + modRules = m_feedbackRules; + } + { TScopedRunningTimeTrackerPause scopedTimePause(m_pTimeTracker); TScopedRunningTimeTrackerPause scopedSecondaryTimePause(m_pSecondaryTimeTracker); - eResult = m_spFeedbackHandler->NotEnoughSpace(strSrcPath, strDstPath, ullRequiredSize, newRules); + eResult = m_spFeedbackHandler->NotEnoughSpace(strSrcPath, strDstPath, ullRequiredSize, modRules); } if(eResult != eResult_Unknown) { bAutomatedResponse = false; - if(!newRules.IsEmpty()) + { boost::unique_lock lock(m_lock); - m_feedbackRules.GetNotEnoughSpaceRules().Merge(newRules); + m_feedbackRules = modRules; } } } @@ -168,19 +176,22 @@ } if(eResult == eResult_Unknown) { - FeedbackOperationEventRuleList newRules; + FeedbackRules modRules; { + boost::shared_lock lock(m_lock); + modRules = m_feedbackRules; + } + { TScopedRunningTimeTrackerPause scopedTimePause(m_pTimeTracker); TScopedRunningTimeTrackerPause scopedSecondaryTimePause(m_pSecondaryTimeTracker); - eResult = m_spFeedbackHandler->OperationEvent(eEvent, newRules); + eResult = m_spFeedbackHandler->OperationEvent(eEvent, modRules); } if(eResult != eResult_Unknown) { bAutomatedResponse = false; - if(!newRules.IsEmpty()) { boost::unique_lock lock(m_lock); - m_feedbackRules.GetOperationEventRules().Merge(newRules); + m_feedbackRules = modRules; } } } Index: src/libchengine/IFeedbackHandler.cpp =================================================================== diff -u -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r3993a75a24145732742d61be638111d1d85c367b --- src/libchengine/IFeedbackHandler.cpp (.../IFeedbackHandler.cpp) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187) +++ src/libchengine/IFeedbackHandler.cpp (.../IFeedbackHandler.cpp) (revision 3993a75a24145732742d61be638111d1d85c367b) @@ -1,6 +1,6 @@ // ============================================================================ -// Copyright (C) 2001-2014 by Jozef Starosczyk -// ixen@copyhandler.com +// Copyright (C) 2001-2020 by Jozef Starosczyk +// ixen {at} copyhandler [dot] com // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU Library General Public License Index: src/libchengine/IFeedbackHandler.h =================================================================== diff -u -rf01ed9a0279a52c96a7272273ef19e57f7670f4a -r3993a75a24145732742d61be638111d1d85c367b --- src/libchengine/IFeedbackHandler.h (.../IFeedbackHandler.h) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) +++ src/libchengine/IFeedbackHandler.h (.../IFeedbackHandler.h) (revision 3993a75a24145732742d61be638111d1d85c367b) @@ -1,21 +1,21 @@ -/*************************************************************************** - * Copyright (C) 2001-2020 by J�zef Starosczyk * - * ixen@copyhandler.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License * - * (version 2) as published by the Free Software Foundation; * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +// ============================================================================ +// Copyright (C) 2001-2020 by Jozef Starosczyk +// ixen {at} copyhandler [dot] com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ #pragma once #include "EFileError.h" @@ -36,11 +36,11 @@ public: virtual ~IFeedbackHandler(); - virtual EFeedbackResult FileError(const string::TString& strSrcPath, const string::TString& strDstPath, EFileError eFileError, unsigned long ulError, FeedbackErrorRuleList& rNewRules) = 0; + virtual EFeedbackResult FileError(const string::TString& strSrcPath, const string::TString& strDstPath, EFileError eFileError, unsigned long ulError, FeedbackRules& rNewRules) = 0; virtual EFeedbackResult FileAlreadyExists(const TFileInfo& spSrcFileInfo, const TFileInfo& spDstFileInfo, string::TString& strRenameName, FeedbackRules& rNewRules) = 0; - virtual EFeedbackResult NotEnoughSpace(const string::TString& strSrcPath, const string::TString& strDstPath, unsigned long long ullRequiredSize, FeedbackNotEnoughSpaceRuleList& rNewRules) = 0; - virtual EFeedbackResult OperationEvent(EOperationEvent eEvent, FeedbackOperationEventRuleList& rNewRules) = 0; + virtual EFeedbackResult NotEnoughSpace(const string::TString& strSrcPath, const string::TString& strDstPath, unsigned long long ullRequiredSize, FeedbackRules& rNewRules) = 0; + virtual EFeedbackResult OperationEvent(EOperationEvent eEvent, FeedbackRules& rNewRules) = 0; }; - typedef std::shared_ptr IFeedbackHandlerPtr; + using IFeedbackHandlerPtr = std::shared_ptr; }