Index: src/ch/ch.h =================================================================== diff -u -rd5c3edd0d167db9b5d47d04248820fda49499a5e -r33b33baa373533d0cff8ea5d25154b370f2b2e05 --- src/ch/ch.h (.../ch.h) (revision d5c3edd0d167db9b5d47d04248820fda49499a5e) +++ src/ch/ch.h (.../ch.h) (revision 33b33baa373533d0cff8ea5d25154b370f2b2e05) @@ -19,85 +19,105 @@ #ifndef __COPYHANDLER_H__ #define __COPYHANDLER_H__ -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols #include "AppHelper.h" -#include "CfgProperties.h" -#include "../chext/chext.h" -//#include "LogFile.h" -#include "../libicpf/log.h" -#include "../libchcore/EngineCfg.h" #include "../libictranslate/ResourceManager.h" +#include "TShellExtensionClient.h" +#include "TCommandLineParser.h" +#include "../liblogger/TLogger.h" +#include "TShellExtensionConfig.h" +#include "../libchengine/TConfig.h" +#include "../libchengine/TCoreEngine.h" -using namespace std; - -///////////////////////////////////////////////////////////////////////////// -// CCopyHandlerApp: -// See CopyHandler.cpp for the implementation of this class -// - class CCopyHandlerApp : public CWinApp, public CAppHelper { public: CCopyHandlerApp(); ~CCopyHandlerApp(); -// Overrides -public: - virtual BOOL InitInstance(); + BOOL InitInstance() override; + int ExitInstance() override; + void HtmlHelp(DWORD_PTR dwData, UINT nCmd) override; - virtual void HtmlHelp(DWORD_PTR dwData, UINT nCmd); + PCTSTR GetHelpPath() const { return m_pszHelpFilePath; } - PCTSTR GetHelpPath() const { return m_pszHelpFilePath; }; + static int MsgBox(UINT uiID, UINT nType=MB_OK, UINT nIDHelp=0); - friend LRESULT MainRouter(ULONGLONG ullDst, UINT uiMsg, WPARAM wParam, LPARAM lParam); - friend int MsgBox(UINT uiID, UINT nType=MB_OK, UINT nIDHelp=0); - friend CCopyHandlerApp* GetApp(); - friend ictranslate::CResourceManager* GetResManager(); - friend chcore::engine_config* GetConfig(); -// friend CLogFile* GetLog(); + friend CCopyHandlerApp& GetApplication(); + static ictranslate::CResourceManager& GetResManager(); + static chengine::TConfig& GetConfig(); - bool IsShellExtEnabled() const; + logger::TLogFileDataPtr GetLogFileData() const; + logger::TMultiLoggerConfigPtr GetEngineLoggerConfig() const; + TShellExtensionConfigPtr GetShellExtensionConfig() const; - void OnConfigNotify(uint_t uiPropID); + void RegisterShellExtension(); + void UnregisterShellExtension(); + + void OnConfigNotify(const string::TStringSet& setPropNames); void OnResManNotify(UINT uiType); + + const TCommandLineParser& GetCommandLine() const { return m_cmdLineParser; } + protected: bool UpdateHelpPaths(); - HWND HHelp(HWND hwndCaller, LPCTSTR pszFile, UINT uCommand, DWORD dwData); + HWND HHelp(HWND hwndCaller, LPCTSTR pszFile, UINT uCommand, DWORD_PTR dwData); -public: - ictranslate::CResourceManager m_resManager; -// CConfigManager m_cfgManager; - chcore::engine_config m_cfgSettings; - icpf::log_file m_lfLog; + void InitShellExtension(); + bool ParseCommandLine(); - IShellExtControl* m_piShellExtControl; +protected: + logger::TMultiLoggerConfigPtr m_spAppLoggerConfig; + logger::TMultiLoggerConfigPtr m_spEngineLoggerConfig; - CWnd *m_pMainWindow; - // currently opened dialogs -// list m_lhDialogs; + logger::TLoggerPtr m_spLog; -protected: -// Implementation - HANDLE m_hMapObject; - //TCHAR m_szHelpPath[_MAX_PATH]; // full file path to the help file -// CString m_strCrashInfo; // crash info text + TCommandLineParser m_cmdLineParser; - //{{AFX_MSG(CCopyHandlerApp) - //}}AFX_MSG + chengine::TCoreEngine m_chEngine; + + TShellExtensionConfigPtr m_shellExtConfig; + TShellExtensionClient m_tShellExtClient; + + CWnd *m_pMainWindow; + bool m_bComInitialized = false; + DECLARE_MESSAGE_MAP() -public: - virtual int ExitInstance(); + +private: + void InitLoggers(); }; +CCopyHandlerApp& GetApplication(); -///////////////////////////////////////////////////////////////////////////// +inline CCopyHandlerApp& GetApp() +{ + return GetApplication(); +} -//{{AFX_INSERT_LOCATION}} -// Microsoft Developer Studio will insert additional declarations immediately before the previous line. +inline logger::TLogFileDataPtr GetLogFileData() +{ + return GetApp().GetLogFileData(); +} +inline ictranslate::CResourceManager& GetResManager() +{ + return CCopyHandlerApp::GetResManager(); +} + +inline chengine::TConfig& GetConfig() +{ + return CCopyHandlerApp::GetConfig(); +} + +inline TShellExtensionConfigPtr GetShellExtensionConfig() +{ + return GetApp().GetShellExtensionConfig(); +} + +inline int MsgBox(UINT uiID, UINT nType = MB_OK, UINT nIDHelp = 0) +{ + return GetApp().MsgBox(uiID, nType, nIDHelp); +} + #endif