Index: src/ch/MainWnd.cpp =================================================================== diff -u -r25129f39720523eca2cb702242890a7862f70ec6 -r6f8b891b60eb0f33199fd29db75d4d9f4a22c248 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 25129f39720523eca2cb702242890a7862f70ec6) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 6f8b891b60eb0f33199fd29db75d4d9f4a22c248) @@ -46,6 +46,9 @@ #include "FeedbackHandlerFactory.h" #include "../libchcore/TTask.h" #include "TTaskManagerWrapper.h" +#include "shortcuts.h" +#include "CfgProperties.h" +#include "resource.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -95,10 +98,10 @@ wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = AfxGetInstanceHandle(); - wc.hIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(AFX_IDI_STD_FRAME)); - wc.hCursor = ::LoadCursor(NULL, IDC_ARROW); + wc.hIcon = ::LoadIcon(nullptr, MAKEINTRESOURCE(AFX_IDI_STD_FRAME)); + wc.hCursor = ::LoadCursor(nullptr, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); - wc.lpszMenuName = NULL; + wc.lpszMenuName = nullptr; wc.lpszClassName = CH_WNDCLASS_NAME; return ::AfxRegisterClass(&wc); @@ -111,7 +114,7 @@ if(!bReg) return FALSE; - return CreateEx(WS_EX_TOOLWINDOW, CH_WNDCLASS_NAME, _T("Copy Handler"), WS_OVERLAPPED, 10, 10, 10, 10, NULL, (HMENU)NULL, NULL); + return CreateEx(WS_EX_TOOLWINDOW, CH_WNDCLASS_NAME, _T("Copy Handler"), WS_OVERLAPPED, 10, 10, 10, 10, nullptr, (HMENU)nullptr, nullptr); } int CMainWnd::ShowTrayIcon() @@ -185,7 +188,7 @@ if(!LoadTaskManager()) { - LOG_ERROR(_T("Couldn't load task manager data. User did not allow re-creation of the database.")); + LOG_ERROR(GetLogger()) << _T("Couldn't load task manager data. User did not allow re-creation of the database."); return -1; } @@ -197,7 +200,7 @@ m_spTasks->TasksRetryProcessing(); // start clipboard monitoring - LOG_INFO(_T("Starting clipboard monitor...")); + LOG_INFO(GetLogger()) << _T("Starting clipboard monitor..."); CClipboardMonitor::StartMonitor(m_spTasks); CheckForUpdates(); @@ -226,7 +229,7 @@ if(bCaughtError) { - LOG_ERROR(szErrInfo.get()); + LOG_ERROR(GetLogger()) << szErrInfo.get(); return -1; } return 0; @@ -261,7 +264,7 @@ } // load last state - LOG_INFO(_T("Loading existing tasks...")); + LOG_INFO(GetLogger()) << _T("Loading existing tasks..."); // load tasks m_spTasks->Load(); @@ -289,7 +292,7 @@ if (!mMenu.Attach(hMenu)) return (LRESULT)FALSE; - if ((pSubMenu = mMenu.GetSubMenu(0)) == NULL) + if ((pSubMenu = mMenu.GetSubMenu(0)) == nullptr) return (LRESULT)FALSE; // double click received, the default action is to execute first menu item @@ -308,7 +311,7 @@ if (!mMenu.Attach(hMenu)) return (LRESULT)FALSE; - if ((pSubMenu = mMenu.GetSubMenu(0)) == NULL) + if ((pSubMenu = mMenu.GetSubMenu(0)) == nullptr) return (LRESULT)FALSE; // set menu default item @@ -368,7 +371,7 @@ m_pdlgStatus->Create(); // hide miniview if showing status - if (m_pdlgMiniView != NULL && m_pdlgMiniView->m_bLock) + if (m_pdlgMiniView != nullptr && m_pdlgMiniView->m_bLock) { if (::IsWindow(m_pdlgMiniView->m_hWnd)) m_pdlgMiniView->HideWindow(); @@ -402,7 +405,7 @@ if(!strMessage.IsEmpty()) { - LOG_ERROR(L"Failed to finalize tasks before exiting Copy Handler. Error: " + strMessage); + LOG_ERROR(GetLogger()) << L"Failed to finalize tasks before exiting Copy Handler. Error: " + strMessage; ictranslate::CFormat fmt; @@ -434,10 +437,10 @@ fmt.SetFormat(_T("Failed to autosave task. Error: %err.")); fmt.SetParam(_T("%err"), (PCTSTR)strError); - LOG_ERROR(fmt); + LOG_ERROR(GetLogger()) << fmt; } - SetTimer(1023, GetPropValue(GetConfig()), NULL); + SetTimer(1023, GetPropValue(GetConfig()), nullptr); break; } case 3245: @@ -451,7 +454,7 @@ m_pdlgStatus->SendMessage(WM_UPDATESTATUS); } - SetTimer(3245, TM_AUTOREMOVE, NULL); + SetTimer(3245, TM_AUTOREMOVE, nullptr); break; case 8743: @@ -515,7 +518,7 @@ fmt.SetParam(_T("%xml"), wstrData.c_str()); fmt.SetParam(_T("%err"), (PCTSTR)strError); - LOG_ERROR(fmt); + LOG_ERROR(GetLogger()) << fmt; fmt.SetFormat(GetResManager().LoadString(IDS_SHELLEXT_XML_IMPORT_FAILED)); fmt.SetParam(_T("%err"), (PCTSTR)strError); @@ -625,7 +628,7 @@ fmt.SetParam(_T("%path"), strPath.ToString()); fmt.SetParam(_T("%err"), szBuffer.get()); - LOG_ERROR(fmt); + LOG_ERROR(GetLogger()) << fmt; fmt.SetFormat(GetResManager().LoadString(IDS_TASK_IMPORT_FAILED)); fmt.SetParam(_T("%path"), strPath.ToString()); @@ -678,7 +681,7 @@ { OnShowMiniView(); return static_cast(0); - break; + } case WM_CONFIGNOTIFY: @@ -718,7 +721,7 @@ bool bAddedAnyOption = false; if(GetPropValue(rConfig)) { - spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUCOPY_STRING), rResManager.LoadString(IDS_MENUTIPCOPY_STRING), + spRootItem->AddChild(std::make_shared(rResManager.LoadString(IDS_MENUCOPY_STRING), rResManager.LoadString(IDS_MENUTIPCOPY_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Copy)); @@ -727,7 +730,7 @@ if(GetPropValue(rConfig)) { - spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUMOVE_STRING), rResManager.LoadString(IDS_MENUTIPMOVE_STRING), + spRootItem->AddChild(std::make_shared(rResManager.LoadString(IDS_MENUMOVE_STRING), rResManager.LoadString(IDS_MENUTIPMOVE_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), false, chcore::eOperation_Move)); @@ -736,7 +739,7 @@ if(GetPropValue(rConfig)) { - spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUCOPYMOVESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVESPECIAL_STRING), + spRootItem->AddChild(std::make_shared(rResManager.LoadString(IDS_MENUCOPYMOVESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVESPECIAL_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeIDataObject), TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializePidlFolder, chcore::TSmartPath()), true)); @@ -746,7 +749,7 @@ if(bAddedAnyOption) { // insert separator as an addition to other items - spRootItem->AddChild(boost::make_shared()); + spRootItem->AddChild(std::make_shared()); } break; } @@ -755,15 +758,15 @@ { if(GetPropValue(rConfig)) { - spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUPASTE_STRING), rResManager.LoadString(IDS_MENUTIPPASTE_STRING), + spRootItem->AddChild(std::make_shared(rResManager.LoadString(IDS_MENUPASTE_STRING), rResManager.LoadString(IDS_MENUTIPPASTE_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard), TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), false)); } if(GetPropValue(rConfig)) { - spRootItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_MENUPASTESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPPASTESPECIAL_STRING), + spRootItem->AddChild(std::make_shared(rResManager.LoadString(IDS_MENUPASTESPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPPASTESPECIAL_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Autodetect, chcore::eOperation_Copy), TSourcePathsInfo(TSourcePathsInfo::eSrcType_Clipboard), TDestinationPathInfo(TDestinationPathInfo::eDstType_InitializeAuto, chcore::TSmartPath()), true)); @@ -787,7 +790,7 @@ unsigned long long ullSize = 0; // retrieving free space might fail, but it's not critical - we just won't show the free space - if(bRetrieveFreeSpace && GetDynamicFreeSpace(tShortcut.m_strPath, &ullSize, NULL)) + if(bRetrieveFreeSpace && GetDynamicFreeSpace(tShortcut.m_strPath, &ullSize, nullptr)) { CString strNameFormat; strNameFormat.Format(_T("%s (%s)"), tShortcut.m_strName, GetSizeString(ullSize)); @@ -803,10 +806,10 @@ if(GetPropValue(rConfig)) { - boost::shared_ptr menuItem(boost::make_shared(rResManager.LoadString(IDS_MENUCOPYTO_STRING), rResManager.LoadString(IDS_MENUTIPCOPYTO_STRING))); + std::shared_ptr menuItem(std::make_shared(rResManager.LoadString(IDS_MENUCOPYTO_STRING), rResManager.LoadString(IDS_MENUTIPCOPYTO_STRING))); BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts) { - menuItem->AddChild(boost::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, + menuItem->AddChild(std::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false)); @@ -816,21 +819,21 @@ // optionally separator if(!vShortcuts.empty()) - menuItem->AddChild(boost::make_shared()); + menuItem->AddChild(std::make_shared()); // "Choose" menu option - menuItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), + menuItem->AddChild(std::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false)); } if(GetPropValue(rConfig)) { - boost::shared_ptr menuItem(boost::make_shared(rResManager.LoadString(IDS_MENUMOVETO_STRING), rResManager.LoadString(IDS_MENUTIPMOVETO_STRING))); + std::shared_ptr menuItem(std::make_shared(rResManager.LoadString(IDS_MENUMOVETO_STRING), rResManager.LoadString(IDS_MENUTIPMOVETO_STRING))); BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts) { - menuItem->AddChild(boost::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, + menuItem->AddChild(std::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), false)); @@ -840,21 +843,21 @@ // optionally separator if(!vShortcuts.empty()) - menuItem->AddChild(boost::make_shared()); + menuItem->AddChild(std::make_shared()); // "Choose" menu option - menuItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), + menuItem->AddChild(std::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Move), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), false)); } if(GetPropValue(rConfig)) { - boost::shared_ptr menuItem(boost::make_shared(rResManager.LoadString(IDS_MENUCOPYMOVETOSPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVETOSPECIAL_STRING))); + std::shared_ptr menuItem(std::make_shared(rResManager.LoadString(IDS_MENUCOPYMOVETOSPECIAL_STRING), rResManager.LoadString(IDS_MENUTIPCOPYMOVETOSPECIAL_STRING))); BOOST_FOREACH(const CShortcut& tShortcut, vShortcuts) { - menuItem->AddChild(boost::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, + menuItem->AddChild(std::make_shared((PCTSTR)tShortcut.m_strName, (PCTSTR)tShortcut.m_strPath, TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), TDestinationPathInfo(TDestinationPathInfo::eDstType_Specified, chcore::PathFromString((PCTSTR)tShortcut.m_strPath)), true)); @@ -864,10 +867,10 @@ // optionally separator if(!vShortcuts.empty()) - menuItem->AddChild(boost::make_shared()); + menuItem->AddChild(std::make_shared()); // "Choose" menu option - menuItem->AddChild(boost::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), + menuItem->AddChild(std::make_shared(rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_STRING), rResManager.LoadString(IDS_SHELLEXT_CHOOSE_DIR_TOOLTIP_STRING), TOperationTypeInfo(TOperationTypeInfo::eOpType_Specified, chcore::eOperation_Copy), TSourcePathsInfo(TSourcePathsInfo::eSrcType_InitializeAuto), TDestinationPathInfo(TDestinationPathInfo::eDstType_Choose, chcore::TSmartPath()), true)); @@ -896,7 +899,7 @@ _ASSERTE(FALSE); CString strMsg; strMsg.Format(L"Encountered problem trying to retrieve shell ext configuration.\nReason: %S", e.what()); - LOG_ERROR(strMsg); + LOG_ERROR(GetLogger()) << strMsg; return FALSE; } @@ -930,7 +933,7 @@ } case WM_STATUSCLOSING: { - if (m_pdlgMiniView != NULL && m_pdlgMiniView->m_bLock && ::IsWindow(m_pdlgMiniView->m_hWnd)) + if (m_pdlgMiniView != nullptr && m_pdlgMiniView->m_bLock && ::IsWindow(m_pdlgMiniView->m_hWnd)) m_pdlgMiniView->RefreshStatus(); break; @@ -943,7 +946,6 @@ case WM_TRAYNOTIFY: { return OnTrayNotification(wParam, lParam); - break; } } @@ -1006,7 +1008,7 @@ void CMainWnd::OnPopupHelp() { - GetApp().HtmlHelp(HH_DISPLAY_TOPIC, NULL); + GetApp().HtmlHelp(HH_DISPLAY_TOPIC, 0); } void CMainWnd::OnPopupCheckForUpdates() @@ -1054,13 +1056,13 @@ } // get last check time stored in configuration - unsigned long long ullCurrentStamp = _time64(NULL); + unsigned long long ullCurrentStamp = _time64(nullptr); unsigned long long ullTimestamp = GetPropValue(GetConfig()); // perform checking for updates only when the minimal interval has passed if(ullCurrentStamp - ullTimestamp >= ullMinInterval) { - LOG_INFO(_T("Checking for updates...")); + LOG_INFO(GetLogger()) << _T("Checking for updates..."); CUpdaterDlg* pDlg = new CUpdaterDlg(true); pDlg->m_bAutoDelete = true; @@ -1069,12 +1071,12 @@ chcore::TConfig& rConfig = GetConfig(); try { - SetPropValue(rConfig, _time64(NULL)); + SetPropValue(rConfig, _time64(nullptr)); rConfig.Write(); } catch(const std::exception& /*e*/) { - LOG_ERROR(_T("Storing last update check timestamp in configuration failed")); + LOG_ERROR(GetLogger()) << _T("Storing last update check timestamp in configuration failed"); } } } @@ -1083,8 +1085,8 @@ void CMainWnd::SetupTimers() { // start saving timer - SetTimer(1023, GetPropValue(GetConfig()), NULL); + SetTimer(1023, GetPropValue(GetConfig()), nullptr); - SetTimer(3245, TM_AUTOREMOVE, NULL); - SetTimer(8743, TM_ACCEPTING, NULL); // ends wait state in tasks + SetTimer(3245, TM_AUTOREMOVE, nullptr); + SetTimer(8743, TM_ACCEPTING, nullptr); // ends wait state in tasks }