Index: src/ch/FeedbackHandler.cpp =================================================================== diff -u -rb9453afbc6264bc3f3c6a7f86fadab7744e0fb16 -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/ch/FeedbackHandler.cpp (.../FeedbackHandler.cpp) (revision b9453afbc6264bc3f3c6a7f86fadab7744e0fb16) +++ src/ch/FeedbackHandler.cpp (.../FeedbackHandler.cpp) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -1,21 +1,21 @@ -/*************************************************************************** - * Copyright (C) 2001-2008 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. +// ============================================================================ #include "stdafx.h" #include "FeedbackHandler.h" #include "FeedbackReplaceDlg.h" @@ -41,15 +41,17 @@ return eResult; } -chengine::EFeedbackResult CFeedbackHandler::FileAlreadyExists(const TFileInfo& spSrcFileInfo, const TFileInfo& spDstFileInfo, TString& strRenameName, FeedbackAlreadyExistsRuleList& rNewRules) +chengine::EFeedbackResult CFeedbackHandler::FileAlreadyExists(const TFileInfo& spSrcFileInfo, const TFileInfo& spDstFileInfo, TString& strRenameName, FeedbackRules& rNewRules) { - CFeedbackReplaceDlg dlg(spSrcFileInfo, spDstFileInfo, strRenameName); + rNewRules.ResetModifications(); + + CFeedbackReplaceDlg dlg(rNewRules, spSrcFileInfo, spDstFileInfo, strRenameName); EFeedbackResult eResult = (EFeedbackResult)dlg.DoModal(); if(eResult == eResult_Rename) strRenameName = dlg.GetNewName(); - if(!dlg.GetRules().IsEmpty()) + if(!dlg.GetRules().IsModified()) rNewRules = dlg.GetRules(); return eResult; Index: src/ch/FeedbackHandler.h =================================================================== diff -u -rb9453afbc6264bc3f3c6a7f86fadab7744e0fb16 -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/ch/FeedbackHandler.h (.../FeedbackHandler.h) (revision b9453afbc6264bc3f3c6a7f86fadab7744e0fb16) +++ src/ch/FeedbackHandler.h (.../FeedbackHandler.h) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -1,25 +1,25 @@ -/*************************************************************************** - * Copyright (C) 2001-2008 by Jozef 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. * - ***************************************************************************/ -#ifndef __FEEDBACKHANDLER_H__ -#define __FEEDBACKHANDLER_H__ +// ============================================================================ +// 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 "../libchengine/IFeedbackHandler.h" +#include "../libchengine/FeedbackRules.h" namespace string { @@ -30,7 +30,7 @@ { public: chengine::EFeedbackResult FileError(const string::TString& strSrcPath, const string::TString& strDstPath, chengine::EFileError eFileError, unsigned long ulError, chengine::FeedbackErrorRuleList& rNewRules) override; - chengine::EFeedbackResult FileAlreadyExists(const chengine::TFileInfo& spSrcFileInfo, const chengine::TFileInfo& spDstFileInfo, string::TString& strRenameName, chengine::FeedbackAlreadyExistsRuleList& 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; @@ -39,5 +39,3 @@ }; typedef std::shared_ptr CFeedbackHandlerPtr; - -#endif Index: src/ch/FeedbackReplaceDlg.cpp =================================================================== diff -u -rb9453afbc6264bc3f3c6a7f86fadab7744e0fb16 -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/ch/FeedbackReplaceDlg.cpp (.../FeedbackReplaceDlg.cpp) (revision b9453afbc6264bc3f3c6a7f86fadab7744e0fb16) +++ src/ch/FeedbackReplaceDlg.cpp (.../FeedbackReplaceDlg.cpp) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -16,8 +16,9 @@ IMPLEMENT_DYNAMIC(CFeedbackReplaceDlg, ictranslate::CLanguageDialog) -CFeedbackReplaceDlg::CFeedbackReplaceDlg(const chengine::TFileInfo& spSrcFile, const chengine::TFileInfo& spDstFile, const TString& strSuggestedName, CWnd* pParent /*=nullptr*/) +CFeedbackReplaceDlg::CFeedbackReplaceDlg(chengine::FeedbackRules& currentRules, const chengine::TFileInfo& spSrcFile, const chengine::TFileInfo& spDstFile, const TString& strSuggestedName, CWnd* pParent /*=nullptr*/) : ictranslate::CLanguageDialog(IDD_FEEDBACK_REPLACE_DIALOG, pParent), + m_rules(currentRules), m_rSrcFile(spSrcFile), m_rDstFile(spDstFile), m_strNewName(strSuggestedName) @@ -209,16 +210,16 @@ switch(m_btnReplace.m_nMenuResult) { case ID_FEEDBACK_REPLACE_ALLEXISTINGFILES: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_ApplyToAll, eResult_Overwrite); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_ApplyToAll, eResult_Overwrite)); break; case ID_FEEDBACK_REPLACE_FILESWITHDIFFERENTDATESORSIZES: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenDifferentDateOrSize, eResult_Overwrite); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenDifferentDateOrSize, eResult_Overwrite)); break; case ID_FEEDBACK_REPLACE_OLDERFILESWITHNEWERVERSIONS: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenNewerThanDst, eResult_Overwrite); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenNewerThanDst, eResult_Overwrite)); break; case ID_FEEDBACK_REPLACE_NEWERFILESWITHOLDERVERSIONS: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenOlderThanDst, eResult_Overwrite); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenOlderThanDst, eResult_Overwrite)); break; } @@ -232,19 +233,19 @@ switch(m_btnRename.m_nMenuResult) { case ID_FEEDBACK_RENAME_WHENDESTIONATIONFILEEXISTS: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_ApplyToAll, eResult_Rename); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_ApplyToAll, eResult_Rename)); break; case ID_FEEDBACK_RENAME_WHENDATEORSIZEDIFFERS: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenDifferentDateOrSize, eResult_Rename); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenDifferentDateOrSize, eResult_Rename)); break; case ID_FEEDBACK_RENAME_WHENDATEANDSZEARESAME: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenSameDateAndSize, eResult_Rename); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenSameDateAndSize, eResult_Rename)); break; case ID_FEEDBACK_RENAME_WHENNEWERTHANDESTINATION: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenNewerThanDst, eResult_Rename); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenNewerThanDst, eResult_Rename)); break; case ID_FEEDBACK_RENAME_WHENOLDERTHANDESTINATION: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenOlderThanDst, eResult_Rename); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenOlderThanDst, eResult_Rename)); break; default: { @@ -263,7 +264,7 @@ switch(m_btnResume.m_nMenuResult) { case ID_FEEDBACK_RESUME_WHENFILEBIGGERTHANDESTINATION: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenBiggerThanDst, eResult_CopyRest); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenBiggerThanDst, eResult_CopyRest)); break; } @@ -276,16 +277,16 @@ switch(m_btnSkip.m_nMenuResult) { case ID_FEEDBACK_SKIP_ALLEXISTINGDESTINATIONFILES: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_ApplyToAll, eResult_Skip); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_ApplyToAll, eResult_Skip)); break; case ID_FEEDBACK_SKIP_ALLFILESWITHSAMEDATESANDSIZES: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenSameDateAndSize, eResult_Skip); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenSameDateAndSize, eResult_Skip)); break; case ID_FEEDBACK_SKIP_FILESTHATAREOLDERTHANDESTINATION: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenOlderThanDst, eResult_Skip); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenOlderThanDst, eResult_Skip)); break; case ID_FEEDBACK_SKIP_FILESTHATARENEWERTHANDESTINATION: - m_feedbackRules = FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenNewerThanDst, eResult_Skip); + m_rules.GetAlreadyExistsRules().Merge(FeedbackPredefinedRules::CreateAlreadyExistsRule(EPredefinedRuleCondition::eCondition_WhenNewerThanDst, eResult_Skip)); break; } @@ -310,9 +311,9 @@ EndDialog(chengine::EFeedbackResult::eResult_Cancel); } -const chengine::FeedbackAlreadyExistsRuleList& CFeedbackReplaceDlg::GetRules() const +const chengine::FeedbackRules& CFeedbackReplaceDlg::GetRules() const { - return m_feedbackRules; + return m_rules; } void CFeedbackReplaceDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI) Index: src/ch/FeedbackReplaceDlg.h =================================================================== diff -u -rb9453afbc6264bc3f3c6a7f86fadab7744e0fb16 -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/ch/FeedbackReplaceDlg.h (.../FeedbackReplaceDlg.h) (revision b9453afbc6264bc3f3c6a7f86fadab7744e0fb16) +++ src/ch/FeedbackReplaceDlg.h (.../FeedbackReplaceDlg.h) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -19,7 +19,7 @@ #ifndef __FEEDBACKREPLACEDLG_H__ #define __FEEDBACKREPLACEDLG_H__ -#include "../libchengine/FeedbackAlreadyExistsRuleList.h" +#include "../libchengine/FeedbackRules.h" namespace chengine { @@ -31,16 +31,16 @@ DECLARE_DYNAMIC(CFeedbackReplaceDlg) public: - CFeedbackReplaceDlg(const chengine::TFileInfo& spSrcFile, const chengine::TFileInfo& spDstFile, const string::TString& strSuggestedName, CWnd* pParent = nullptr); // standard constructor + CFeedbackReplaceDlg(chengine::FeedbackRules& currentRules, const chengine::TFileInfo& spSrcFile, const chengine::TFileInfo& spDstFile, const string::TString& strSuggestedName, CWnd* pParent = nullptr); // standard constructor virtual ~CFeedbackReplaceDlg(); BOOL OnInitDialog() override; - const chengine::FeedbackAlreadyExistsRuleList& GetRules() const; + const chengine::FeedbackRules& GetRules() const; string::TString GetNewName() const { return m_strNewName; } protected: - void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support + void DoDataExchange(CDataExchange* pDX) override; void OnCancel() override; void RefreshFilesInfo(); @@ -89,7 +89,7 @@ const chengine::TFileInfo& m_rSrcFile; const chengine::TFileInfo& m_rDstFile; - chengine::FeedbackAlreadyExistsRuleList m_feedbackRules; // feedback rules resulting from choices made in this dialog box + chengine::FeedbackRules& m_rules; string::TString m_strNewName; }; Index: src/libchengine/FeedbackManager.cpp =================================================================== diff -u -rb9453afbc6264bc3f3c6a7f86fadab7744e0fb16 -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/libchengine/FeedbackManager.cpp (.../FeedbackManager.cpp) (revision b9453afbc6264bc3f3c6a7f86fadab7744e0fb16) +++ src/libchengine/FeedbackManager.cpp (.../FeedbackManager.cpp) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -94,22 +94,27 @@ } if(eResult == eResult_Unknown) { - FeedbackAlreadyExistsRuleList newRules; + FeedbackRules modRules; TString strNewPath = suggestedPath.ToWString(); { + { + boost::shared_lock lock(m_lock); + modRules = m_feedbackRules; + } + TScopedRunningTimeTrackerPause scopedTimePause(m_pTimeTracker); TScopedRunningTimeTrackerPause scopedSecondaryTimePause(m_pSecondaryTimeTracker); - eResult = m_spFeedbackHandler->FileAlreadyExists(*spSrcFileInfo, rDstFileInfo, strNewPath, newRules); + eResult = m_spFeedbackHandler->FileAlreadyExists(*spSrcFileInfo, rDstFileInfo, strNewPath, modRules); } if(eResult != eResult_Unknown) { bAutomatedResponse = false; - if(!newRules.IsEmpty()) + { boost::unique_lock lock(m_lock); - m_feedbackRules.GetAlreadyExistsRules().Merge(newRules); + m_feedbackRules = modRules; } - else if(eResult == eResult_Rename) + if(eResult == eResult_Rename) { spSrcFileInfo->SetDstRelativePath(PathFromWString(strNewPath)); } Index: src/libchengine/FeedbackRules.cpp =================================================================== diff -u -r08717141ce5f6926116c298cbc9442094a45bb67 -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/libchengine/FeedbackRules.cpp (.../FeedbackRules.cpp) (revision 08717141ce5f6926116c298cbc9442094a45bb67) +++ src/libchengine/FeedbackRules.cpp (.../FeedbackRules.cpp) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -1,3 +1,21 @@ +// ============================================================================ +// 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. +// ============================================================================ #include "stdafx.h" #include "FeedbackRules.h" #include "../libserializer/ISerializerContainer.h" @@ -78,6 +96,28 @@ m_feedbackOperationEventRules.Clear(); } +void chengine::FeedbackRules::ResetModifications() +{ + m_feedbackAlreadyExistsRules.ResetModifications(); + m_feedbackErrorRules.ResetModifications(); + m_feedbackNotEnoughSpaceRules.ResetModifications(); + m_feedbackOperationEventRules.ResetModifications(); +} + +bool chengine::FeedbackRules::IsModified() const +{ + if(m_feedbackAlreadyExistsRules.IsModified()) + return true; + if(m_feedbackErrorRules.IsModified()) + return true; + if(m_feedbackNotEnoughSpaceRules.IsModified()) + return true; + if(m_feedbackOperationEventRules.IsModified()) + return true; + + return false; +} + const chengine::FeedbackAlreadyExistsRuleList& chengine::FeedbackRules::GetAlreadyExistsRules() const { return m_feedbackAlreadyExistsRules; Index: src/libchengine/FeedbackRules.h =================================================================== diff -u -r08717141ce5f6926116c298cbc9442094a45bb67 -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/libchengine/FeedbackRules.h (.../FeedbackRules.h) (revision 08717141ce5f6926116c298cbc9442094a45bb67) +++ src/libchengine/FeedbackRules.h (.../FeedbackRules.h) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -1,3 +1,21 @@ +// ============================================================================ +// 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 "libchengine.h" @@ -22,6 +40,9 @@ void Clear(); + void ResetModifications(); + bool IsModified() const; + const FeedbackAlreadyExistsRuleList& GetAlreadyExistsRules() const; FeedbackAlreadyExistsRuleList& GetAlreadyExistsRules(); Index: src/libchengine/IFeedbackHandler.h =================================================================== diff -u -rb9453afbc6264bc3f3c6a7f86fadab7744e0fb16 -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/libchengine/IFeedbackHandler.h (.../IFeedbackHandler.h) (revision b9453afbc6264bc3f3c6a7f86fadab7744e0fb16) +++ src/libchengine/IFeedbackHandler.h (.../IFeedbackHandler.h) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2001-2008 by J�zef Starosczyk * + * Copyright (C) 2001-2020 by J�zef Starosczyk * * ixen@copyhandler.com * * * * This program is free software; you can redistribute it and/or modify * @@ -16,18 +16,16 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#ifndef __FEEDBACKHANDLERBASE_H__ -#define __FEEDBACKHANDLERBASE_H__ +#pragma once #include "EFileError.h" #include "TFeedbackResult.h" #include "../libstring/TString.h" -#include "../libserializer/ISerializerContainer.h" #include "EOperationEvent.h" #include "FeedbackErrorRuleList.h" -#include "FeedbackAlreadyExistsRuleList.h" #include "FeedbackNotEnoughSpaceRuleList.h" #include "FeedbackOperationEventRuleList.h" +#include "FeedbackRules.h" namespace chengine { @@ -39,12 +37,10 @@ virtual ~IFeedbackHandler(); virtual EFeedbackResult FileError(const string::TString& strSrcPath, const string::TString& strDstPath, EFileError eFileError, unsigned long ulError, FeedbackErrorRuleList& rNewRules) = 0; - virtual EFeedbackResult FileAlreadyExists(const TFileInfo& spSrcFileInfo, const TFileInfo& spDstFileInfo, string::TString& strRenameName, FeedbackAlreadyExistsRuleList& 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; }; typedef std::shared_ptr IFeedbackHandlerPtr; } - -#endif Index: src/libchengine/TFileFilter.cpp =================================================================== diff -u -rf3c80778cfee0736195e00274c78040f7908ac5b -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/libchengine/TFileFilter.cpp (.../TFileFilter.cpp) (revision f3c80778cfee0736195e00274c78040f7908ac5b) +++ src/libchengine/TFileFilter.cpp (.../TFileFilter.cpp) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -29,8 +29,6 @@ namespace chengine { TFileFilter::TFileFilter() : - m_oidObjectID(0), - m_setModifications(), m_bUseMask(m_setModifications, false), m_astrMask(m_setModifications), m_bUseExcludeMask(m_setModifications, false), @@ -59,15 +57,14 @@ m_iSystem(m_setModifications, 2), m_iDirectory(m_setModifications, 2) { - m_setModifications[eMod_Added] = true; + m_setModifications[FileFilterEnum::eMod_Added] = true; m_tDateTime1.Modify().SetCurrentDateTime(); m_tDateTime2.Modify().SetCurrentDateTime(); } TFileFilter::TFileFilter(const TFileFilter& rFilter) : - m_oidObjectID(rFilter.m_oidObjectID), - m_setModifications(rFilter.m_setModifications), + SerializableObject(rFilter), m_bUseMask(rFilter.m_bUseMask, m_setModifications), m_astrMask(rFilter.m_astrMask, m_setModifications), m_bUseExcludeMask(rFilter.m_bUseExcludeMask, m_setModifications), @@ -182,8 +179,7 @@ if (this == &rFilter) return *this; - m_oidObjectID = rFilter.m_oidObjectID; - m_setModifications = rFilter.m_setModifications; + __super::operator=(rFilter); SetData(rFilter); @@ -522,64 +518,64 @@ void TFileFilter::Store(const ISerializerContainerPtr& spContainer) const { - bool bAdded = m_setModifications[eMod_Added]; + bool bAdded = m_setModifications[FileFilterEnum::eMod_Added]; if (m_setModifications.any()) { ISerializerRowData& rRow = spContainer->GetRow(m_oidObjectID, bAdded); - if (bAdded || m_setModifications[eMod_UseMask]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseMask]) rRow.SetValue(_T("use_mask"), m_bUseMask); - if (bAdded || m_setModifications[eMod_Mask]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_Mask]) rRow.SetValue(_T("mask"), GetCombinedMask()); - if (bAdded || m_setModifications[eMod_UseExcludeMask]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseExcludeMask]) rRow.SetValue(_T("use_exclude_mask"), m_bUseExcludeMask); - if (bAdded || m_setModifications[eMod_ExcludeMask]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_ExcludeMask]) rRow.SetValue(_T("exclude_mask"), GetCombinedExcludeMask()); - if (bAdded || m_setModifications[eMod_UseSize1]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseSize1]) rRow.SetValue(_T("use_size_1"), m_bUseSize1); - if (bAdded || m_setModifications[eMod_SizeCmpType1]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_SizeCmpType1]) rRow.SetValue(_T("compare_type_1"), m_eSizeCmpType1); - if (bAdded || m_setModifications[eMod_Size1]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_Size1]) rRow.SetValue(_T("size_1"), m_ullSize1); - if (bAdded || m_setModifications[eMod_UseSize2]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseSize2]) rRow.SetValue(_T("use_size_2"), m_bUseSize2); - if (bAdded || m_setModifications[eMod_SizeCmpType2]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_SizeCmpType2]) rRow.SetValue(_T("compare_type_2"), m_eSizeCmpType2); - if (bAdded || m_setModifications[eMod_Size2]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_Size2]) rRow.SetValue(_T("size_2"), m_ullSize2); - if (bAdded || m_setModifications[eMod_DateType]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_DateType]) rRow.SetValue(_T("date_type"), m_eDateType); - if (bAdded || m_setModifications[eMod_UseDateTime1]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseDateTime1]) rRow.SetValue(_T("use_date_time_1"), m_bUseDateTime1); - if (bAdded || m_setModifications[eMod_DateCmpType1]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_DateCmpType1]) rRow.SetValue(_T("date_compare_type_1"), m_eDateCmpType1); - if (bAdded || m_setModifications[eMod_UseDate1]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseDate1]) rRow.SetValue(_T("use_date_1"), m_bUseDate1); - if (bAdded || m_setModifications[eMod_UseTime1]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseTime1]) rRow.SetValue(_T("use_time_1"), m_bUseTime1); - if (bAdded || m_setModifications[eMod_DateTime1]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_DateTime1]) rRow.SetValue(_T("datetime_1"), (long long)m_tDateTime1.Get().GetAsTimeT()); - if (bAdded || m_setModifications[eMod_UseDateTime2]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseDateTime2]) rRow.SetValue(_T("use_date_time_2"), m_bUseDateTime2); - if (bAdded || m_setModifications[eMod_DateCmpType2]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_DateCmpType2]) rRow.SetValue(_T("date_compare_type_2"), m_eDateCmpType2); - if (bAdded || m_setModifications[eMod_UseDate2]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseDate2]) rRow.SetValue(_T("use_date_2"), m_bUseDate2); - if (bAdded || m_setModifications[eMod_UseTime2]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseTime2]) rRow.SetValue(_T("use_time_2"), m_bUseTime2); - if (bAdded || m_setModifications[eMod_DateTime2]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_DateTime2]) rRow.SetValue(_T("datetime_2"), (long long)m_tDateTime2.Get().GetAsTimeT()); - if (bAdded || m_setModifications[eMod_UseAttributes]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_UseAttributes]) rRow.SetValue(_T("use_attributes"), m_bUseAttributes); - if (bAdded || m_setModifications[eMod_AttrArchive]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_AttrArchive]) rRow.SetValue(_T("attr_archive"), m_iArchive); - if (bAdded || m_setModifications[eMod_AttrReadOnly]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_AttrReadOnly]) rRow.SetValue(_T("attr_ro"), m_iReadOnly); - if (bAdded || m_setModifications[eMod_AttrHidden]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_AttrHidden]) rRow.SetValue(_T("attr_hidden"), m_iHidden); - if (bAdded || m_setModifications[eMod_AttrSystem]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_AttrSystem]) rRow.SetValue(_T("attr_system"), m_iSystem); - if (bAdded || m_setModifications[eMod_AttrDirectory]) + if (bAdded || m_setModifications[FileFilterEnum::eMod_AttrDirectory]) rRow.SetValue(_T("attr_directory"), m_iDirectory); m_setModifications.reset(); Index: src/libchengine/TFileFilter.h =================================================================== diff -u -rf3c80778cfee0736195e00274c78040f7908ac5b -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/libchengine/TFileFilter.h (.../TFileFilter.h) (revision f3c80778cfee0736195e00274c78040f7908ac5b) +++ src/libchengine/TFileFilter.h (.../TFileFilter.h) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -25,15 +25,55 @@ #include "../libstring/TStringPatternArray.h" #include "../libserializer/TSharedModificationTracker.h" #include "ECompareType.h" +#include "../libserializer/SerializableObject.h" namespace chengine { class TConfig; class TFileInfo; typedef std::shared_ptr TFileInfoPtr; - class LIBCHENGINE_API TFileFilter + namespace FileFilterEnum { + enum EModifications + { + eMod_Added, + eMod_UseMask, + eMod_Mask, + eMod_UseExcludeMask, + eMod_ExcludeMask, + eMod_UseSize1, + eMod_SizeCmpType1, + eMod_Size1, + eMod_UseSize2, + eMod_SizeCmpType2, + eMod_Size2, + eMod_DateType, + eMod_UseDateTime1, + eMod_DateCmpType1, + eMod_UseDate1, + eMod_UseTime1, + eMod_DateTime1, + eMod_UseDateTime2, + eMod_DateCmpType2, + eMod_UseDate2, + eMod_UseTime2, + eMod_DateTime2, + eMod_UseAttributes, + eMod_AttrArchive, + eMod_AttrReadOnly, + eMod_AttrHidden, + eMod_AttrSystem, + eMod_AttrDirectory, + + eMod_Last + }; + }; + +#pragma warning(push) +#pragma warning(disable: 4251) + class LIBCHENGINE_API TFileFilter : public serializer::SerializableObject + { public: enum EDateType { @@ -155,92 +195,51 @@ void SetDirectory(int iDirectory) { m_iDirectory = iDirectory; } private: - enum EModifications - { - eMod_Added, - eMod_UseMask, - eMod_Mask, - eMod_UseExcludeMask, - eMod_ExcludeMask, - eMod_UseSize1, - eMod_SizeCmpType1, - eMod_Size1, - eMod_UseSize2, - eMod_SizeCmpType2, - eMod_Size2, - eMod_DateType, - eMod_UseDateTime1, - eMod_DateCmpType1, - eMod_UseDate1, - eMod_UseTime1, - eMod_DateTime1, - eMod_UseDateTime2, - eMod_DateCmpType2, - eMod_UseDate2, - eMod_UseTime2, - eMod_DateTime2, - eMod_UseAttributes, - eMod_AttrArchive, - eMod_AttrReadOnly, - eMod_AttrHidden, - eMod_AttrSystem, - eMod_AttrDirectory, - - eMod_Last - }; - - // object identification - serializer::object_id_t m_oidObjectID; - // modification management -#pragma warning(push) -#pragma warning(disable: 4251) - typedef std::bitset Bitset; - mutable Bitset m_setModifications; // files mask - serializer::TSharedModificationTracker m_bUseMask; - serializer::TSharedModificationTracker m_astrMask; + serializer::TSharedModificationTracker m_bUseMask; + serializer::TSharedModificationTracker m_astrMask; // files mask- - serializer::TSharedModificationTracker m_bUseExcludeMask; - serializer::TSharedModificationTracker m_astrExcludeMask; + serializer::TSharedModificationTracker m_bUseExcludeMask; + serializer::TSharedModificationTracker m_astrExcludeMask; // size filtering - serializer::TSharedModificationTracker m_bUseSize1; - serializer::TSharedModificationTracker m_eSizeCmpType1; - serializer::TSharedModificationTracker m_ullSize1; + serializer::TSharedModificationTracker m_bUseSize1; + serializer::TSharedModificationTracker m_eSizeCmpType1; + serializer::TSharedModificationTracker m_ullSize1; - serializer::TSharedModificationTracker m_bUseSize2; - serializer::TSharedModificationTracker m_eSizeCmpType2; - serializer::TSharedModificationTracker m_ullSize2; + serializer::TSharedModificationTracker m_bUseSize2; + serializer::TSharedModificationTracker m_eSizeCmpType2; + serializer::TSharedModificationTracker m_ullSize2; // date filtering - serializer::TSharedModificationTracker m_eDateType; // created/last modified/last accessed + serializer::TSharedModificationTracker m_eDateType; // created/last modified/last accessed - serializer::TSharedModificationTracker m_bUseDateTime1; + serializer::TSharedModificationTracker m_bUseDateTime1; - serializer::TSharedModificationTracker m_eDateCmpType1; // before/after - serializer::TSharedModificationTracker m_bUseDate1; - serializer::TSharedModificationTracker m_bUseTime1; - serializer::TSharedModificationTracker m_tDateTime1; + serializer::TSharedModificationTracker m_eDateCmpType1; // before/after + serializer::TSharedModificationTracker m_bUseDate1; + serializer::TSharedModificationTracker m_bUseTime1; + serializer::TSharedModificationTracker m_tDateTime1; - serializer::TSharedModificationTracker m_bUseDateTime2; + serializer::TSharedModificationTracker m_bUseDateTime2; - serializer::TSharedModificationTracker m_eDateCmpType2; - serializer::TSharedModificationTracker m_bUseDate2; - serializer::TSharedModificationTracker m_bUseTime2; - serializer::TSharedModificationTracker m_tDateTime2; + serializer::TSharedModificationTracker m_eDateCmpType2; + serializer::TSharedModificationTracker m_bUseDate2; + serializer::TSharedModificationTracker m_bUseTime2; + serializer::TSharedModificationTracker m_tDateTime2; // attribute filtering - serializer::TSharedModificationTracker m_bUseAttributes; - serializer::TSharedModificationTracker m_iArchive; - serializer::TSharedModificationTracker m_iReadOnly; - serializer::TSharedModificationTracker m_iHidden; - serializer::TSharedModificationTracker m_iSystem; - serializer::TSharedModificationTracker m_iDirectory; -#pragma warning(pop) + serializer::TSharedModificationTracker m_bUseAttributes; + serializer::TSharedModificationTracker m_iArchive; + serializer::TSharedModificationTracker m_iReadOnly; + serializer::TSharedModificationTracker m_iHidden; + serializer::TSharedModificationTracker m_iSystem; + serializer::TSharedModificationTracker m_iDirectory; }; +#pragma warning(pop) } #endif Index: src/libserializer/SerializableContainer.h =================================================================== diff -u -re9d12da97d434708c93b6967971ce265ac933252 -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/libserializer/SerializableContainer.h (.../SerializableContainer.h) (revision e9d12da97d434708c93b6967971ce265ac933252) +++ src/libserializer/SerializableContainer.h (.../SerializableContainer.h) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -73,10 +73,7 @@ // ensure all objects have modification flag stripped to avoid unnecessary writing the same data to db again // NOTE: Load() method above should reset modification flag, but storing it in vector will set it again - hence the separate reset - for(T& rItem : m_vEntries) - { - rItem.ResetModifications(); - } + ResetModifications(); } virtual void InitColumns(const serializer::ISerializerContainerPtr& spContainer) const = 0; @@ -164,6 +161,28 @@ m_vEntries.clear(); } + void ResetModifications() + { + for(T& rEntry : m_vEntries) + { + rEntry.ResetModifications(); + } + m_setRemovedObjects.Clear(); + } + + bool IsModified() const + { + if(!m_setRemovedObjects.IsEmpty()) + return true; + + for(const T& rEntry : m_vEntries) + { + if(rEntry.IsModified()) + return true; + } + return false; + } + protected: serializer::object_id_t m_oidLastObjectID = 0; std::vector m_vEntries; Index: src/libserializer/SerializableObject.h =================================================================== diff -u -rf3c80778cfee0736195e00274c78040f7908ac5b -rf01ed9a0279a52c96a7272273ef19e57f7670f4a --- src/libserializer/SerializableObject.h (.../SerializableObject.h) (revision f3c80778cfee0736195e00274c78040f7908ac5b) +++ src/libserializer/SerializableObject.h (.../SerializableObject.h) (revision f01ed9a0279a52c96a7272273ef19e57f7670f4a) @@ -25,6 +25,7 @@ void SetObjectID(serializer::object_id_t oidObjectID); void ResetModifications(); + bool IsModified() const { return m_setModifications.any(); } protected: serializer::object_id_t m_oidObjectID = 0;