Index: src/ch/FeedbackHandler.cpp =================================================================== diff -u -r22bbc4a87fa0b249e1e02ba385f28da9d77a4aa1 -r8068e0c351055554340ac9755d1bc846893bf2b8 --- src/ch/FeedbackHandler.cpp (.../FeedbackHandler.cpp) (revision 22bbc4a87fa0b249e1e02ba385f28da9d77a4aa1) +++ src/ch/FeedbackHandler.cpp (.../FeedbackHandler.cpp) (revision 8068e0c351055554340ac9755d1bc846893bf2b8) @@ -17,133 +17,89 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "stdafx.h" -#include "FileInfo.h" +#include "../libchcore/TFileInfo.h" #include "FeedbackHandler.h" #include "FeedbackReplaceDlg.h" #include "FeedbackFileErrorDlg.h" #include "FeedbackNotEnoughSpaceDlg.h" #include "ch.h" #include "mmsystem.h" +#include "CfgProperties.h" +using namespace chcore; + CFeedbackHandler::CFeedbackHandler() : - chcore::IFeedbackHandler() + TFeedbackHandlerBase() { - memset(m_aeFeedbackTypeStatus, 0, sizeof(m_aeFeedbackTypeStatus)); } CFeedbackHandler::~CFeedbackHandler() { - } -ull_t CFeedbackHandler::RequestFeedback(ull_t ullFeedbackID, ptr_t pFeedbackParam) +TFeedbackResult CFeedbackHandler::FileError(const TString& strSrcPath, const TString& strDstPath, EFileError /*eFileError*/, unsigned long ulError) { - BOOST_ASSERT(ullFeedbackID < eFT_LastType); - if(ullFeedbackID >= eFT_LastType) - return eResult_Unknown; + EFeedbackResult eResult = eResult_Unknown; + if(HasFileErrorPermanentResponse(eResult)) + return TFeedbackResult(eResult, true); - // if we have an action selected for this type (e.g. by selecting 'use for all items') - if(m_aeFeedbackTypeStatus[ullFeedbackID] != eResult_Unknown) - return m_aeFeedbackTypeStatus[ullFeedbackID]; + CFeedbackFileErrorDlg dlg(strSrcPath.c_str(), strDstPath.c_str(), ulError); + eResult = (EFeedbackResult)dlg.DoModal(); - // standard processing of feedback - EFeedbackResult eFeedbackResult = eResult_Unknown; - BOOL bUseForAllItems = FALSE; - switch(ullFeedbackID) - { - case eFT_FileAlreadyExists: - { - BOOST_ASSERT(pFeedbackParam); - if(!pFeedbackParam) - return eResult_Unknown; + if (dlg.m_bAllItems) + SetFileErrorPermanentResponse(eResult); - FEEDBACK_ALREADYEXISTS* pData = (FEEDBACK_ALREADYEXISTS*)pFeedbackParam; - CFeedbackReplaceDlg dlg(pData->spSrcFileInfo, pData->spDstFileInfo); - eFeedbackResult = (EFeedbackResult)dlg.DoModal(); - bUseForAllItems = dlg.m_bAllItems; + return TFeedbackResult(eResult, false); +} - break; - } - case eFT_FileError: - { - BOOST_ASSERT(pFeedbackParam); - if(!pFeedbackParam) - return eResult_Unknown; +TFeedbackResult CFeedbackHandler::FileAlreadyExists(const TFileInfo& spSrcFileInfo, const TFileInfo& spDstFileInfo) +{ + EFeedbackResult eResult = eResult_Unknown; + if(HasFileAlreadyExistsPermanentResponse(eResult)) + return TFeedbackResult(eResult, true); - FEEDBACK_FILEERROR* pData = (FEEDBACK_FILEERROR*)pFeedbackParam; - CFeedbackFileErrorDlg dlg(pData->pszSrcPath, pData->pszDstPath, pData->ulError); - eFeedbackResult = (EFeedbackResult)dlg.DoModal(); - bUseForAllItems = dlg.m_bAllItems; + CFeedbackReplaceDlg dlg(spSrcFileInfo, spDstFileInfo); + eResult = (EFeedbackResult)dlg.DoModal(); - break; - } - case eFT_NotEnoughSpace: - { - BOOST_ASSERT(pFeedbackParam); - if(!pFeedbackParam) - return eResult_Unknown; + if(dlg.IsApplyToAllItemsChecked()) + SetFileAlreadyExistsPermanentResponse(eResult); - FEEDBACK_NOTENOUGHSPACE* pData = (FEEDBACK_NOTENOUGHSPACE*)pFeedbackParam; - CFeedbackNotEnoughSpaceDlg dlg(pData->ullRequiredSize, pData->pszSrcPath, pData->pszDstPath); - eFeedbackResult = (EFeedbackResult)dlg.DoModal(); - bUseForAllItems = dlg.m_bAllItems; + return TFeedbackResult(eResult, false); +} - break; - } - case eFT_OperationFinished: - { - if(GetConfig().get_bool(PP_SNDPLAYSOUNDS)) - { - TCHAR* pszPath = new TCHAR[_MAX_PATH]; - GetConfig().get_string(PP_SNDFINISHEDSOUNDPATH, pszPath, _MAX_PATH); - GetApp().ExpandPath(pszPath); - PlaySound(pszPath, NULL, SND_FILENAME | SND_ASYNC); - delete [] pszPath; - } +TFeedbackResult CFeedbackHandler::NotEnoughSpace(const TString& strSrcPath, const TString& strDstPath, unsigned long long ullRequiredSize) +{ + EFeedbackResult eResult = eResult_Unknown; + if(HasNotEnoughSpacePermanentResponse(eResult)) + return TFeedbackResult(eResult, true); - break; - } - case eFT_OperationError: - { - if(GetConfig().get_bool(PP_SNDPLAYSOUNDS)) - { - TCHAR* pszPath = new TCHAR[_MAX_PATH]; - GetConfig().get_string(PP_SNDERRORSOUNDPATH, pszPath, _MAX_PATH); - GetApp().ExpandPath(pszPath); - PlaySound(pszPath, NULL, SND_FILENAME | SND_ASYNC); - delete [] pszPath; - } + CFeedbackNotEnoughSpaceDlg dlg(ullRequiredSize, strSrcPath.c_str(), strDstPath.c_str()); + eResult = (EFeedbackResult) dlg.DoModal(); - break; - } - default: - BOOST_ASSERT(false); - return eResult_Unknown; - } + if (dlg.m_bAllItems) + SetNotEnoughSpacePermanentResponse(eResult); - // remember feedback option for next time - if(bUseForAllItems) - m_aeFeedbackTypeStatus[ullFeedbackID] = eFeedbackResult; - - return eFeedbackResult; + return TFeedbackResult(eResult, false); } -void CFeedbackHandler::Delete() +TFeedbackResult CFeedbackHandler::OperationFinished() { - delete this; -} + if (GetPropValue(GetConfig())) + { + CString strPath = GetPropValue(GetConfig()); + PlaySound(GetApp().ExpandPath(strPath), nullptr, SND_FILENAME | SND_ASYNC); + } -chcore::IFeedbackHandler* CFeedbackHandlerFactory::Create() -{ - return new CFeedbackHandler; + return TFeedbackResult(eResult_Unknown, true); } -chcore::IFeedbackHandlerFactory* CFeedbackHandlerFactory::CreateFactory() +TFeedbackResult CFeedbackHandler::OperationError() { - return new CFeedbackHandlerFactory; -} + if (GetPropValue(GetConfig())) + { + CString strPath = GetPropValue(GetConfig()); + PlaySound(GetApp().ExpandPath(strPath), nullptr, SND_FILENAME | SND_ASYNC); + } -void CFeedbackHandlerFactory::Delete() -{ - delete this; + return TFeedbackResult(eResult_Unknown, true); }