Index: src/ch/AppHelper.cpp =================================================================== diff -u -N -raa6bff57279b9f9cfc276e9adab2763e2900878d -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/AppHelper.cpp (.../AppHelper.cpp) (revision aa6bff57279b9f9cfc276e9adab2763e2900878d) +++ src/ch/AppHelper.cpp (.../AppHelper.cpp) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -229,13 +229,13 @@ rStrPath += _T('\\'); // make sure to create the required directories if they does not exist - rStrPath += _T("\\Copy Handler"); + rStrPath += _T("Copy Handler"); if(!CreateDirectory(rStrPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) return false; // create directory for tasks - rStrPath += _T("\\Tasks"); - if(!CreateDirectory(rStrPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) +// rStrPath += _T("\\Tasks"); + if(!CreateDirectory(rStrPath + _T("\\Tasks"), NULL) && GetLastError() != ERROR_ALREADY_EXISTS) return false; return true; Index: src/ch/CfgProperties.cpp =================================================================== diff -u -N -rf34d204b8eecd6817dbe4a1c3b3541cf9a8794b0 -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/CfgProperties.cpp (.../CfgProperties.cpp) (revision f34d204b8eecd6817dbe4a1c3b3541cf9a8794b0) +++ src/ch/CfgProperties.cpp (.../CfgProperties.cpp) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -100,12 +100,9 @@ pManager->register_bool(_t("Buffer/Use no buffering for large files"), true); pManager->register_signed_num(_t("Buffer/Large files lower boundary limit"), 2097152, 1, 0xffffffff); - pManager->register_string(_t("Log file/Path to main log file"), _t("\\ch.log")); pManager->register_bool(_t("Log file/Enable logging"), true); - pManager->register_bool(_t("Log file/Enable log size limitation"), true); - pManager->register_signed_num(_t("Log file/Max log size limit"), 65535, 1024, 0xffffffff); - pManager->register_bool(_t("Log file/Precise log size limiting"), false); - pManager->register_signed_num(_t("Log file/Truncation buffer size"), 65535, 1024, 0xffffffff); + pManager->register_signed_num(_t("Log file/Max log size limit"), 512384, 1024, 0xffffffff); + pManager->register_unsigned_num(_t("Log file/Logging level"), 1, 0, 3); // 0=debug, 1=info, 2=warning, 3=error pManager->register_bool(_t("Sounds/Play sounds"), true); pManager->register_string(_t("Sounds/Error sound path"), _t("\\media\\chord.wav"), icpf::property::flag_path); Index: src/ch/CfgProperties.h =================================================================== diff -u -N -rf34d204b8eecd6817dbe4a1c3b3541cf9a8794b0 -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/CfgProperties.h (.../CfgProperties.h) (revision f34d204b8eecd6817dbe4a1c3b3541cf9a8794b0) +++ src/ch/CfgProperties.h (.../CfgProperties.h) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -95,12 +95,9 @@ PP_BFUSENOBUFFERING, PP_BFBOUNDARYLIMIT, - PP_LOGPATH, PP_LOGENABLELOGGING, - PP_LOGLIMITATION, - PP_LOGMAXLIMIT, - PP_LOGPRECISELIMITING, - PP_LOGTRUNCBUFFERSIZE, + PP_LOGMAXSIZE, + PP_LOGLEVEL, PP_SNDPLAYSOUNDS, PP_SNDERRORSOUNDPATH, Index: src/ch/ClipboardMonitor.cpp =================================================================== diff -u -N -rbfe720fda9529e7a77b4fb6410b4d4945b69188b -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/ClipboardMonitor.cpp (.../ClipboardMonitor.cpp) (revision bfe720fda9529e7a77b4fb6410b4d4945b69188b) +++ src/ch/ClipboardMonitor.cpp (.../ClipboardMonitor.cpp) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -23,7 +23,6 @@ #include "ClipboardMonitor.h" #include "ch.h" #include "task.h" -#include "../libchcore/EngineCfg.h" #include "CfgProperties.h" #include "charvect.h" #include "FolderDialog.h" @@ -106,7 +105,7 @@ LONG lFinished=0; bool bEnd=false; - chcore::engine_config& rConfig = chcore::engine_config::Acquire(); + chcore::TCoreConfig& rConfig = chcore::TCoreConfig::Acquire(); for(;;) { if (uiCounter == 0 && rConfig.get_bool(PP_PCLIPBOARDMONITORING) && IsClipboardFormatAvailable(CF_HDROP)) Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -rf34d204b8eecd6817dbe4a1c3b3541cf9a8794b0 -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision f34d204b8eecd6817dbe4a1c3b3541cf9a8794b0) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -169,7 +169,7 @@ // load last state CString strPath; GetApp().GetProgramDataPath(strPath); - strPath += _T("\\tasks"); + strPath += _T("\\Tasks\\"); m_tasks.SetTasksDir(strPath); m_tasks.LoadDataProgress(); m_tasks.TasksRetryProcessing(); Index: src/ch/OptionsDlg.cpp =================================================================== diff -u -N -r17059054c69cd5726f4c7d35357f3b9556471783 -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/OptionsDlg.cpp (.../OptionsDlg.cpp) (revision 17059054c69cd5726f4c7d35357f3b9556471783) +++ src/ch/OptionsDlg.cpp (.../OptionsDlg.cpp) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -64,28 +64,28 @@ // properties handling macros #define PROP_SEPARATOR(text)\ - m_ctlProperties.AddString(text); + m_ctlProperties.AddString(text) #define PROP_BOOL(text, value)\ - m_ctlProperties.AddString(text, ID_PROPERTY_COMBO_LIST, IDS_BOOLTEXT_STRING, (value)); + m_ctlProperties.AddString(text, ID_PROPERTY_COMBO_LIST, IDS_BOOLTEXT_STRING, (value)) #define PROP_UINT(text, value)\ - m_ctlProperties.AddString(text, ID_PROPERTY_TEXT, _itot((int)(value), m_szBuffer, 10), 0); + m_ctlProperties.AddString(text, ID_PROPERTY_TEXT, _itot((int)(value), m_szBuffer, 10), 0) #define PROP_COMBO(text, prop_text, value)\ - m_ctlProperties.AddString(text, ID_PROPERTY_COMBO_LIST, prop_text, (int)((value))); + m_ctlProperties.AddString(text, ID_PROPERTY_COMBO_LIST, prop_text, (int)((value))) #define PROP_DIR(text, prop_text, value)\ - m_ctlProperties.AddString(text, ID_PROPERTY_DIR, (value)+CString(GetResManager().LoadString(prop_text)), 0); + m_ctlProperties.AddString(text, ID_PROPERTY_DIR, (value)+CString(GetResManager().LoadString(prop_text)), 0) #define PROP_PATH(text, prop_text, value)\ - m_ctlProperties.AddString(text, ID_PROPERTY_PATH, (value)+CString(GetResManager().LoadString(prop_text)), 0); + m_ctlProperties.AddString(text, ID_PROPERTY_PATH, (value)+CString(GetResManager().LoadString(prop_text)), 0) #define PROP_CUSTOM_UINT(text, value, callback, param)\ - m_ctlProperties.AddString(text, ID_PROPERTY_CUSTOM, CString(_itot((int)(value), m_szBuffer, 10)), callback, this, param, 0); + m_ctlProperties.AddString(text, ID_PROPERTY_CUSTOM, CString(_itot((int)(value), m_szBuffer, 10)), callback, this, param, 0) #define SKIP_SEPARATOR(pos)\ - pos++; + pos++ BOOL COptionsDlg::OnInitDialog() { @@ -192,7 +192,7 @@ TCHAR szBuf[32]; PROPERTYITEM* pItem; pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex)); - pItem->csProperties.SetAt(0, _itot(pDlg->m_cvShortcuts.size(), szBuf, 10)); + pItem->csProperties.SetAt(0, _ui64tot(pDlg->m_cvShortcuts.size(), szBuf, 10)); } } @@ -212,7 +212,7 @@ TCHAR szBuf[32]; PROPERTYITEM* pItem; pItem = (PROPERTYITEM*)pList->GetAt(pList->FindIndex(iIndex)); - pItem->csProperties.SetAt(0, _itot(pDlg->m_cvRecent.size(), szBuf, 10)); + pItem->csProperties.SetAt(0, _ui64tot(pDlg->m_cvRecent.size(), szBuf, 10)); } } @@ -232,120 +232,117 @@ CString strPath; // load settings - PROP_SEPARATOR(IDS_PROGRAM_STRING) - PROP_BOOL(IDS_CLIPBOARDMONITORING_STRING, GetConfig().get_bool(PP_PCLIPBOARDMONITORING)) - PROP_UINT(IDS_CLIPBOARDINTERVAL_STRING, GetConfig().get_signed_num(PP_PMONITORSCANINTERVAL)) - PROP_BOOL(IDS_AUTORUNPROGRAM_STRING, GetConfig().get_bool(PP_PRELOADAFTERRESTART)) - PROP_BOOL(IDS_CFG_CHECK_FOR_UPDATES_AT_STARTUP, GetConfig().get_bool(PP_PCHECK_FOR_UPDATES_AT_STARTUP)) - PROP_BOOL(IDS_CFG_UPDATE_CHECK_FOR_BETA, GetConfig().get_bool(PP_PUPDATE_CHECK_FOR_BETA)) - PROP_BOOL(IDS_AUTOSHUTDOWN_STRING, GetConfig().get_bool(PP_PSHUTDOWNAFTREFINISHED)) - PROP_UINT(IDS_SHUTDOWNTIME_STRING, GetConfig().get_signed_num(PP_PTIMEBEFORESHUTDOWN)) - PROP_COMBO(IDS_FORCESHUTDOWN_STRING, IDS_FORCESHUTDOWNVALUES_STRING, GetConfig().get_bool(PP_PFORCESHUTDOWN)) - PROP_UINT(IDS_AUTOSAVEINTERVAL_STRING, GetConfig().get_signed_num(PP_PAUTOSAVEINTERVAL)) - PROP_COMBO(IDS_CFGPRIORITYCLASS_STRING, IDS_CFGPRIORITYCLASSITEMS_STRING, PriorityClassToIndex(GetConfig().get_signed_num(PP_PPROCESSPRIORITYCLASS))) - PROP_DIR(IDS_TEMPFOLDER_STRING, IDS_TEMPFOLDERCHOOSE_STRING, strPath) + PROP_SEPARATOR(IDS_PROGRAM_STRING); + PROP_BOOL(IDS_CLIPBOARDMONITORING_STRING, GetConfig().get_bool(PP_PCLIPBOARDMONITORING)); + PROP_UINT(IDS_CLIPBOARDINTERVAL_STRING, GetConfig().get_signed_num(PP_PMONITORSCANINTERVAL)); + PROP_BOOL(IDS_AUTORUNPROGRAM_STRING, GetConfig().get_bool(PP_PRELOADAFTERRESTART)); + PROP_BOOL(IDS_CFG_CHECK_FOR_UPDATES_AT_STARTUP, GetConfig().get_bool(PP_PCHECK_FOR_UPDATES_AT_STARTUP)); + PROP_BOOL(IDS_CFG_UPDATE_CHECK_FOR_BETA, GetConfig().get_bool(PP_PUPDATE_CHECK_FOR_BETA)); + PROP_BOOL(IDS_AUTOSHUTDOWN_STRING, GetConfig().get_bool(PP_PSHUTDOWNAFTREFINISHED)); + PROP_UINT(IDS_SHUTDOWNTIME_STRING, GetConfig().get_signed_num(PP_PTIMEBEFORESHUTDOWN)); + PROP_COMBO(IDS_FORCESHUTDOWN_STRING, IDS_FORCESHUTDOWNVALUES_STRING, GetConfig().get_bool(PP_PFORCESHUTDOWN)); + PROP_UINT(IDS_AUTOSAVEINTERVAL_STRING, GetConfig().get_signed_num(PP_PAUTOSAVEINTERVAL)); + PROP_COMBO(IDS_CFGPRIORITYCLASS_STRING, IDS_CFGPRIORITYCLASSITEMS_STRING, PriorityClassToIndex((int)GetConfig().get_signed_num(PP_PPROCESSPRIORITYCLASS))); + PROP_DIR(IDS_TEMPFOLDER_STRING, IDS_TEMPFOLDERCHOOSE_STRING, strPath); // lang CString strLangs; - UINT uiIndex=0; + size_t stIndex=0; for (vector::iterator it=m_vld.begin();it != m_vld.end();it++) { strLangs+=(*it).GetLangName(); strLangs+=_T("!"); if (_tcsicmp((*it).GetFilename(true), GetResManager().m_ld.GetFilename(true)) == 0) - uiIndex=it-m_vld.begin(); + stIndex = it - m_vld.begin(); } strLangs.TrimRight(_T('!')); - PROP_COMBO(IDS_LANGUAGE_STRING, strLangs, uiIndex) + PROP_COMBO(IDS_LANGUAGE_STRING, strLangs, stIndex); ///////////////// PROP_SEPARATOR(IDS_STATUSWINDOW_STRING); - PROP_UINT(IDS_REFRESHSTATUSINTERVAL_STRING, GetConfig().get_signed_num(PP_STATUSREFRESHINTERVAL)) - PROP_BOOL(IDS_STATUSSHOWDETAILS_STRING, GetConfig().get_bool(PP_STATUSSHOWDETAILS)) - PROP_BOOL(IDS_STATUSAUTOREMOVE_STRING, GetConfig().get_bool(PP_STATUSAUTOREMOVEFINISHED)) + PROP_UINT(IDS_REFRESHSTATUSINTERVAL_STRING, GetConfig().get_signed_num(PP_STATUSREFRESHINTERVAL)); + PROP_BOOL(IDS_STATUSSHOWDETAILS_STRING, GetConfig().get_bool(PP_STATUSSHOWDETAILS)); + PROP_BOOL(IDS_STATUSAUTOREMOVE_STRING, GetConfig().get_bool(PP_STATUSAUTOREMOVEFINISHED)); - PROP_SEPARATOR(IDS_MINIVIEW_STRING) - PROP_BOOL(IDS_SHOWFILENAMES_STRING, GetConfig().get_bool(PP_MVSHOWFILENAMES)) - PROP_BOOL(IDS_SHOWSINGLETASKS_STRING, GetConfig().get_bool(PP_MVSHOWSINGLETASKS)) - PROP_UINT(IDS_MINIVIEWREFRESHINTERVAL_STRING, GetConfig().get_signed_num(PP_MVREFRESHINTERVAL)) - PROP_BOOL(IDS_MINIVIEWSHOWAFTERSTART_STRING, GetConfig().get_bool(PP_MVAUTOSHOWWHENRUN)) - PROP_BOOL(IDS_MINIVIEWAUTOHIDE_STRING, GetConfig().get_bool(PP_MVAUTOHIDEWHENEMPTY)) - PROP_BOOL(IDS_MINIVIEWSMOOTHPROGRESS_STRING, GetConfig().get_bool(PP_MVUSESMOOTHPROGRESS)) + PROP_SEPARATOR(IDS_MINIVIEW_STRING); + PROP_BOOL(IDS_SHOWFILENAMES_STRING, GetConfig().get_bool(PP_MVSHOWFILENAMES)); + PROP_BOOL(IDS_SHOWSINGLETASKS_STRING, GetConfig().get_bool(PP_MVSHOWSINGLETASKS)); + PROP_UINT(IDS_MINIVIEWREFRESHINTERVAL_STRING, GetConfig().get_signed_num(PP_MVREFRESHINTERVAL)); + PROP_BOOL(IDS_MINIVIEWSHOWAFTERSTART_STRING, GetConfig().get_bool(PP_MVAUTOSHOWWHENRUN)); + PROP_BOOL(IDS_MINIVIEWAUTOHIDE_STRING, GetConfig().get_bool(PP_MVAUTOHIDEWHENEMPTY)); + PROP_BOOL(IDS_MINIVIEWSMOOTHPROGRESS_STRING, GetConfig().get_bool(PP_MVUSESMOOTHPROGRESS)); - PROP_SEPARATOR(IDS_CFGFOLDERDIALOG_STRING) - PROP_BOOL(IDS_CFGFDEXTVIEW_STRING, GetConfig().get_bool(PP_FDEXTENDEDVIEW)) - PROP_UINT(IDS_CFGFDWIDTH_STRING, GetConfig().get_signed_num(PP_FDWIDTH)) - PROP_UINT(IDS_CFGFDHEIGHT_STRING, GetConfig().get_signed_num(PP_FDHEIGHT)) - PROP_COMBO(IDS_CFGFDSHORTCUTS_STRING, IDS_CFGFDSHORTCUTSSTYLES_STRING, GetConfig().get_signed_num(PP_FDSHORTCUTLISTSTYLE)) - PROP_BOOL(IDS_CFGFDIGNOREDIALOGS_STRING, GetConfig().get_bool(PP_FDIGNORESHELLDIALOGS)) + PROP_SEPARATOR(IDS_CFGFOLDERDIALOG_STRING); + PROP_BOOL(IDS_CFGFDEXTVIEW_STRING, GetConfig().get_bool(PP_FDEXTENDEDVIEW)); + PROP_UINT(IDS_CFGFDWIDTH_STRING, GetConfig().get_signed_num(PP_FDWIDTH)); + PROP_UINT(IDS_CFGFDHEIGHT_STRING, GetConfig().get_signed_num(PP_FDHEIGHT)); + PROP_COMBO(IDS_CFGFDSHORTCUTS_STRING, IDS_CFGFDSHORTCUTSSTYLES_STRING, GetConfig().get_signed_num(PP_FDSHORTCUTLISTSTYLE)); + PROP_BOOL(IDS_CFGFDIGNOREDIALOGS_STRING, GetConfig().get_bool(PP_FDIGNORESHELLDIALOGS)); - PROP_SEPARATOR(IDS_CFGSHELL_STRING) - PROP_BOOL(IDS_CFGSHCOPY_STRING, GetConfig().get_bool(PP_SHSHOWCOPY)) - PROP_BOOL(IDS_CFGSHMOVE_STRING, GetConfig().get_bool(PP_SHSHOWMOVE)) - PROP_BOOL(IDS_CFGSHCMSPECIAL_STRING, GetConfig().get_bool(PP_SHSHOWCOPYMOVE)) - PROP_BOOL(IDS_CFGSHPASTE_STRING, GetConfig().get_bool(PP_SHSHOWPASTE)) - PROP_BOOL(IDS_CFGSHPASTESPECIAL_STRING, GetConfig().get_bool(PP_SHSHOWPASTESPECIAL)) - PROP_BOOL(IDS_CFGSHCOPYTO_STRING, GetConfig().get_bool(PP_SHSHOWCOPYTO)) - PROP_BOOL(IDS_CFGSHMOVETO_STRING, GetConfig().get_bool(PP_SHSHOWMOVETO)) - PROP_BOOL(IDS_CFGSHCMTOSPECIAL_STRING, GetConfig().get_bool(PP_SHSHOWCOPYMOVETO)) - PROP_BOOL(IDS_CFGSHSHOWFREESPACE_STRING, GetConfig().get_bool(PP_SHSHOWFREESPACE)) - PROP_BOOL(IDS_CFGSHSHOWICONS_STRING, GetConfig().get_bool(PP_SHSHOWSHELLICONS)) - PROP_BOOL(IDS_CFGSHINTERCEPTDRAG_STRING, GetConfig().get_bool(PP_SHINTERCEPTDRAGDROP)) + PROP_SEPARATOR(IDS_CFGSHELL_STRING); + PROP_BOOL(IDS_CFGSHCOPY_STRING, GetConfig().get_bool(PP_SHSHOWCOPY)); + PROP_BOOL(IDS_CFGSHMOVE_STRING, GetConfig().get_bool(PP_SHSHOWMOVE)); + PROP_BOOL(IDS_CFGSHCMSPECIAL_STRING, GetConfig().get_bool(PP_SHSHOWCOPYMOVE)); + PROP_BOOL(IDS_CFGSHPASTE_STRING, GetConfig().get_bool(PP_SHSHOWPASTE)); + PROP_BOOL(IDS_CFGSHPASTESPECIAL_STRING, GetConfig().get_bool(PP_SHSHOWPASTESPECIAL)); + PROP_BOOL(IDS_CFGSHCOPYTO_STRING, GetConfig().get_bool(PP_SHSHOWCOPYTO)); + PROP_BOOL(IDS_CFGSHMOVETO_STRING, GetConfig().get_bool(PP_SHSHOWMOVETO)); + PROP_BOOL(IDS_CFGSHCMTOSPECIAL_STRING, GetConfig().get_bool(PP_SHSHOWCOPYMOVETO)); + PROP_BOOL(IDS_CFGSHSHOWFREESPACE_STRING, GetConfig().get_bool(PP_SHSHOWFREESPACE)); + PROP_BOOL(IDS_CFGSHSHOWICONS_STRING, GetConfig().get_bool(PP_SHSHOWSHELLICONS)); + PROP_BOOL(IDS_CFGSHINTERCEPTDRAG_STRING, GetConfig().get_bool(PP_SHINTERCEPTDRAGDROP)); PROP_BOOL(IDS_CFGINTERCEPTKEYACTION_STRING, GetConfig().get_bool(PP_SHINTERCEPTKEYACTIONS)); PROP_BOOL(IDS_CFGINTERCEPTCONTEXTMENU_STRING, GetConfig().get_bool(PP_SHINTERCEPTCTXMENUACTIONS)); - PROP_SEPARATOR(IDS_PROCESSINGTHREAD_STRING) - PROP_BOOL(IDS_AUTOCOPYREST_STRING, GetConfig().get_bool(PP_CMUSEAUTOCOMPLETEFILES)) - PROP_BOOL(IDS_SETDESTATTRIB_STRING, GetConfig().get_bool(PP_CMSETDESTATTRIBUTES)) - PROP_BOOL(IDS_SETDESTTIME_STRING, GetConfig().get_bool(PP_CMSETDESTDATE)) - PROP_BOOL(IDS_PROTECTROFILES_STRING, GetConfig().get_bool(PP_CMPROTECTROFILES)) - PROP_UINT(IDS_LIMITOPERATIONS_STRING, GetConfig().get_signed_num(PP_CMLIMITMAXOPERATIONS)) - PROP_BOOL(IDS_READSIZEBEFOREBLOCK_STRING, GetConfig().get_bool(PP_CMREADSIZEBEFOREBLOCKING)) - PROP_COMBO(IDS_SHOWVISUALFEEDBACK_STRING, IDS_FEEDBACKTYPE_STRING, GetConfig().get_signed_num(PP_CMSHOWVISUALFEEDBACK)) - PROP_BOOL(IDS_USETIMEDDIALOGS_STRING, GetConfig().get_bool(PP_CMUSETIMEDFEEDBACK)) - PROP_UINT(IDS_TIMEDDIALOGINTERVAL_STRING, GetConfig().get_signed_num(PP_CMFEEDBACKTIME)) - PROP_BOOL(IDS_AUTORETRYONERROR_STRING, GetConfig().get_bool(PP_CMAUTORETRYONERROR)) - PROP_UINT(IDS_AUTORETRYINTERVAL_STRING, GetConfig().get_signed_num(PP_CMAUTORETRYINTERVAL)) - PROP_COMBO(IDS_DEFAULTPRIORITY_STRING, MakeCompoundString(IDS_PRIORITY0_STRING, 7, _T("!")), PriorityToIndex(GetConfig().get_signed_num(PP_CMDEFAULTPRIORITY))) - PROP_BOOL(IDS_CFGDISABLEPRIORITYBOOST_STRING, GetConfig().get_bool(PP_CMDISABLEPRIORITYBOOST)) - PROP_BOOL(IDS_DELETEAFTERFINISHED_STRING, GetConfig().get_bool(PP_CMDELETEAFTERFINISHED)) - PROP_BOOL(IDS_CREATELOGFILES_STRING, GetConfig().get_bool(PP_CMCREATELOG)) + PROP_SEPARATOR(IDS_PROCESSINGTHREAD_STRING); + PROP_BOOL(IDS_AUTOCOPYREST_STRING, GetConfig().get_bool(PP_CMUSEAUTOCOMPLETEFILES)); + PROP_BOOL(IDS_SETDESTATTRIB_STRING, GetConfig().get_bool(PP_CMSETDESTATTRIBUTES)); + PROP_BOOL(IDS_SETDESTTIME_STRING, GetConfig().get_bool(PP_CMSETDESTDATE)); + PROP_BOOL(IDS_PROTECTROFILES_STRING, GetConfig().get_bool(PP_CMPROTECTROFILES)); + PROP_UINT(IDS_LIMITOPERATIONS_STRING, GetConfig().get_signed_num(PP_CMLIMITMAXOPERATIONS)); + PROP_BOOL(IDS_READSIZEBEFOREBLOCK_STRING, GetConfig().get_bool(PP_CMREADSIZEBEFOREBLOCKING)); + PROP_COMBO(IDS_SHOWVISUALFEEDBACK_STRING, IDS_FEEDBACKTYPE_STRING, GetConfig().get_signed_num(PP_CMSHOWVISUALFEEDBACK)); + PROP_BOOL(IDS_USETIMEDDIALOGS_STRING, GetConfig().get_bool(PP_CMUSETIMEDFEEDBACK)); + PROP_UINT(IDS_TIMEDDIALOGINTERVAL_STRING, GetConfig().get_signed_num(PP_CMFEEDBACKTIME)); + PROP_BOOL(IDS_AUTORETRYONERROR_STRING, GetConfig().get_bool(PP_CMAUTORETRYONERROR)); + PROP_UINT(IDS_AUTORETRYINTERVAL_STRING, GetConfig().get_signed_num(PP_CMAUTORETRYINTERVAL)); + PROP_COMBO(IDS_DEFAULTPRIORITY_STRING, MakeCompoundString(IDS_PRIORITY0_STRING, 7, _T("!")), PriorityToIndex((int)GetConfig().get_signed_num(PP_CMDEFAULTPRIORITY))); + PROP_BOOL(IDS_CFGDISABLEPRIORITYBOOST_STRING, GetConfig().get_bool(PP_CMDISABLEPRIORITYBOOST)); + PROP_BOOL(IDS_DELETEAFTERFINISHED_STRING, GetConfig().get_bool(PP_CMDELETEAFTERFINISHED)); + PROP_BOOL(IDS_CREATELOGFILES_STRING, GetConfig().get_bool(PP_CMCREATELOG)); // Buffer - PROP_SEPARATOR(IDS_OPTIONSBUFFER_STRING) - PROP_BOOL(IDS_AUTODETECTBUFFERSIZE_STRING, GetConfig().get_bool(PP_BFUSEONLYDEFAULT)) - PROP_CUSTOM_UINT(IDS_DEFAULTBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_BFDEFAULT), &CustomPropertyCallbackProc, 0) - PROP_CUSTOM_UINT(IDS_ONEDISKBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_BFONEDISK), &CustomPropertyCallbackProc, 1) - PROP_CUSTOM_UINT(IDS_TWODISKSBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_BFTWODISKS), &CustomPropertyCallbackProc, 2) - PROP_CUSTOM_UINT(IDS_CDBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_BFCD), &CustomPropertyCallbackProc, 3) - PROP_CUSTOM_UINT(IDS_LANBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_BFLAN), &CustomPropertyCallbackProc, 4) - PROP_BOOL(IDS_USENOBUFFERING_STRING, GetConfig().get_bool(PP_BFUSENOBUFFERING)) - PROP_UINT(IDS_LARGEFILESMINSIZE_STRING, GetConfig().get_signed_num(PP_BFBOUNDARYLIMIT)) + PROP_SEPARATOR(IDS_OPTIONSBUFFER_STRING); + PROP_BOOL(IDS_AUTODETECTBUFFERSIZE_STRING, GetConfig().get_bool(PP_BFUSEONLYDEFAULT)); + PROP_CUSTOM_UINT(IDS_DEFAULTBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_BFDEFAULT), &CustomPropertyCallbackProc, 0); + PROP_CUSTOM_UINT(IDS_ONEDISKBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_BFONEDISK), &CustomPropertyCallbackProc, 1); + PROP_CUSTOM_UINT(IDS_TWODISKSBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_BFTWODISKS), &CustomPropertyCallbackProc, 2); + PROP_CUSTOM_UINT(IDS_CDBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_BFCD), &CustomPropertyCallbackProc, 3); + PROP_CUSTOM_UINT(IDS_LANBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_BFLAN), &CustomPropertyCallbackProc, 4); + PROP_BOOL(IDS_USENOBUFFERING_STRING, GetConfig().get_bool(PP_BFUSENOBUFFERING)); + PROP_UINT(IDS_LARGEFILESMINSIZE_STRING, GetConfig().get_signed_num(PP_BFBOUNDARYLIMIT)); + PROP_SEPARATOR(IDS_CFGLOGFILE_STRING); + PROP_BOOL(IDS_CFGENABLELOGGING_STRING, GetConfig().get_bool(PP_LOGENABLELOGGING)); + PROP_UINT(IDS_CFGMAXLIMIT_STRING, GetConfig().get_signed_num(PP_LOGMAXSIZE)); + PROP_COMBO(IDS_CFGLOGLEVEL, IDS_CFGLOGLEVEL_VALUES, GetConfig().get_unsigned_num(PP_LOGLEVEL)); // Sounds - PROP_SEPARATOR(IDS_SOUNDS_STRING) - PROP_BOOL(IDS_PLAYSOUNDS_STRING, GetConfig().get_bool(PP_SNDPLAYSOUNDS)) + PROP_SEPARATOR(IDS_SOUNDS_STRING); + PROP_BOOL(IDS_PLAYSOUNDS_STRING, GetConfig().get_bool(PP_SNDPLAYSOUNDS)); GetConfig().get_string(PP_SNDERRORSOUNDPATH, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); strPath.ReleaseBuffer(); - PROP_PATH(IDS_SOUNDONERROR_STRING, IDS_SOUNDSWAVFILTER_STRING, strPath) + PROP_PATH(IDS_SOUNDONERROR_STRING, IDS_SOUNDSWAVFILTER_STRING, strPath); GetConfig().get_string(PP_SNDFINISHEDSOUNDPATH, strPath.GetBuffer(_MAX_PATH), _MAX_PATH); strPath.ReleaseBuffer(); - PROP_PATH(IDS_SOUNDONFINISH_STRING, IDS_SOUNDSWAVFILTER_STRING, strPath) + PROP_PATH(IDS_SOUNDONFINISH_STRING, IDS_SOUNDSWAVFILTER_STRING, strPath); - PROP_SEPARATOR(IDS_CFGSHORTCUTS_STRING) - PROP_CUSTOM_UINT(IDS_CFGSCCOUNT_STRING, m_cvShortcuts.size(), &ShortcutsPropertyCallbackProc, 0) + PROP_SEPARATOR(IDS_CFGSHORTCUTS_STRING); + PROP_CUSTOM_UINT(IDS_CFGSCCOUNT_STRING, m_cvShortcuts.size(), &ShortcutsPropertyCallbackProc, 0); - PROP_SEPARATOR(IDS_CFGRECENT_STRING) - PROP_CUSTOM_UINT(IDS_CFGRPCOUNT_STRING, m_cvRecent.size(), &RecentPropertyCallbackProc, 0) - - /* PROP_SEPARATOR(IDS_CFGLOGFILE_STRING) - PROP_BOOL(IDS_CFGENABLELOGGING_STRING, GetConfig().get_bool(PP_LOGENABLELOGGING)) - PROP_BOOL(IDS_CFGLIMITATION_STRING, GetConfig().get_bool(PP_LOGLIMITATION)) - PROP_UINT(IDS_CFGMAXLIMIT_STRING, GetConfig().get_signed_num(PP_LOGMAXLIMIT)) - PROP_BOOL(IDS_CFGLOGPRECISELIMITING_STRING, GetConfig().get_bool(PP_LOGPRECISELIMITING)) - PROP_UINT(IDS_CFGTRUNCBUFFERSIZE_STRING, GetConfig().get_signed_num(PP_LOGTRUNCBUFFERSIZE))*/ + PROP_SEPARATOR(IDS_CFGRECENT_STRING); + PROP_CUSTOM_UINT(IDS_CFGRPCOUNT_STRING, m_cvRecent.size(), &RecentPropertyCallbackProc, 0); } void COptionsDlg::ApplyProperties() @@ -355,7 +352,7 @@ icpf::config& rConfig = GetConfig(); - SKIP_SEPARATOR(iPosition) + SKIP_SEPARATOR(iPosition); rConfig.set_bool(PP_PCLIPBOARDMONITORING, GetBoolProp(iPosition++)); rConfig.set_signed_num(PP_PMONITORSCANINTERVAL, GetUintProp(iPosition++)); rConfig.set_bool(PP_PRELOADAFTERRESTART, GetBoolProp(iPosition++)); @@ -378,27 +375,27 @@ else rConfig.set_string(PP_PLANGUAGE, pszSrc); - SKIP_SEPARATOR(iPosition) + SKIP_SEPARATOR(iPosition); rConfig.set_signed_num(PP_STATUSREFRESHINTERVAL, GetUintProp(iPosition++)); rConfig.set_bool(PP_STATUSSHOWDETAILS, GetBoolProp(iPosition++)); rConfig.set_bool(PP_STATUSAUTOREMOVEFINISHED, GetBoolProp(iPosition++)); - SKIP_SEPARATOR(iPosition) + SKIP_SEPARATOR(iPosition); rConfig.set_bool(PP_MVSHOWFILENAMES, GetBoolProp(iPosition++)); rConfig.set_bool(PP_MVSHOWSINGLETASKS, GetBoolProp(iPosition++)); rConfig.set_signed_num(PP_MVREFRESHINTERVAL, GetUintProp(iPosition++)); rConfig.set_bool(PP_MVAUTOSHOWWHENRUN, GetBoolProp(iPosition++)); rConfig.set_bool(PP_MVAUTOHIDEWHENEMPTY, GetBoolProp(iPosition++)); rConfig.set_bool(PP_MVUSESMOOTHPROGRESS, GetBoolProp(iPosition++)); - SKIP_SEPARATOR(iPosition) + SKIP_SEPARATOR(iPosition); rConfig.set_bool(PP_FDEXTENDEDVIEW, GetBoolProp(iPosition++)); rConfig.set_signed_num(PP_FDWIDTH, GetUintProp(iPosition++)); rConfig.set_signed_num(PP_FDHEIGHT, GetUintProp(iPosition++)); rConfig.set_signed_num(PP_FDSHORTCUTLISTSTYLE, GetIndexProp(iPosition++)); rConfig.set_bool(PP_FDIGNORESHELLDIALOGS, GetBoolProp(iPosition++)); - SKIP_SEPARATOR(iPosition) + SKIP_SEPARATOR(iPosition); rConfig.set_bool(PP_SHSHOWCOPY, GetBoolProp(iPosition++)); rConfig.set_bool(PP_SHSHOWMOVE, GetBoolProp(iPosition++)); rConfig.set_bool(PP_SHSHOWCOPYMOVE, GetBoolProp(iPosition++)); @@ -413,7 +410,7 @@ rConfig.set_bool(PP_SHINTERCEPTKEYACTIONS, GetBoolProp(iPosition++)); rConfig.set_bool(PP_SHINTERCEPTCTXMENUACTIONS, GetBoolProp(iPosition++)); - SKIP_SEPARATOR(iPosition) + SKIP_SEPARATOR(iPosition); rConfig.set_bool(PP_CMUSEAUTOCOMPLETEFILES, GetBoolProp(iPosition++)); rConfig.set_bool(PP_CMSETDESTATTRIBUTES, GetBoolProp(iPosition++)); rConfig.set_bool(PP_CMSETDESTDATE, GetBoolProp(iPosition++)); @@ -431,7 +428,7 @@ rConfig.set_bool(PP_CMCREATELOG, GetBoolProp(iPosition++)); // Buffer - SKIP_SEPARATOR(iPosition) + SKIP_SEPARATOR(iPosition); rConfig.set_bool(PP_BFUSEONLYDEFAULT, GetBoolProp(iPosition++)); rConfig.set_signed_num(PP_BFDEFAULT, GetUintProp(iPosition++)); rConfig.set_signed_num(PP_BFONEDISK, GetUintProp(iPosition++)); @@ -442,28 +439,26 @@ rConfig.set_signed_num(PP_BFBOUNDARYLIMIT, GetUintProp(iPosition++)); // log file -/* SKIP_SEPARATOR(iPosition) - pConfig->set_bool(PP_LOGENABLELOGGING, GetBoolProp(iPosition++)); - pConfig->set_bool(PP_LOGLIMITATION, GetBoolProp(iPosition++)); - pConfig->set_signed_num(PP_LOGMAXLIMIT, GetUintProp(iPosition++)); - pConfig->set_bool(PP_LOGPRECISELIMITING, GetBoolProp(iPosition++)); - pConfig->set_signed_num(PP_LOGTRUNCBUFFERSIZE, GetUintProp(iPosition++));*/ + SKIP_SEPARATOR(iPosition); + rConfig.set_bool(PP_LOGENABLELOGGING, GetBoolProp(iPosition++)); + rConfig.set_signed_num(PP_LOGMAXSIZE, GetUintProp(iPosition++)); + rConfig.set_unsigned_num(PP_LOGLEVEL, GetIndexProp(iPosition++)); // Sounds - SKIP_SEPARATOR(iPosition) + SKIP_SEPARATOR(iPosition); rConfig.set_bool(PP_SNDPLAYSOUNDS, GetBoolProp(iPosition++)); rConfig.set_string(PP_SNDERRORSOUNDPATH, GetStringProp(iPosition++)); rConfig.set_string(PP_SNDFINISHEDSOUNDPATH, GetStringProp(iPosition++)); // shortcuts & recent paths - SKIP_SEPARATOR(iPosition) + SKIP_SEPARATOR(iPosition); rConfig.clear_array_values(PP_SHORTCUTS); for(char_vector::iterator it = m_cvShortcuts.begin(); it != m_cvShortcuts.end(); it++) { rConfig.set_string(PP_SHORTCUTS, (*it), icpf::property::action_add); } - SKIP_SEPARATOR(iPosition) + SKIP_SEPARATOR(iPosition); rConfig.clear_array_values(PP_RECENTPATHS); for(char_vector::iterator it = m_cvRecent.begin(); it != m_cvRecent.end(); it++) { Index: src/ch/Stdafx.h =================================================================== diff -u -N -rf34d204b8eecd6817dbe4a1c3b3541cf9a8794b0 -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/Stdafx.h (.../Stdafx.h) (revision f34d204b8eecd6817dbe4a1c3b3541cf9a8794b0) +++ src/ch/Stdafx.h (.../Stdafx.h) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -39,6 +39,7 @@ #include "../libictranslate/LanguageDialog.h" #include #include "../common/ErrorConstants.h" +#include "../libchcore/TLogger.h" #ifdef _UNICODE #if defined _M_IX86 Index: src/ch/UpdateChecker.cpp =================================================================== diff -u -N -rf34d204b8eecd6817dbe4a1c3b3541cf9a8794b0 -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision f34d204b8eecd6817dbe4a1c3b3541cf9a8794b0) +++ src/ch/UpdateChecker.cpp (.../UpdateChecker.cpp) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -299,9 +299,13 @@ /// @param[in] lpvStatusInformation Additional status information. /// @param[in] dwStatusInformationLength Length of lpvStatusInformation. // ============================================================================ -void CAsyncHttpFile::InternetStatusCallback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD /*dwStatusInformationLength*/) +void CAsyncHttpFile::InternetStatusCallback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength) { - TRACE(_T("[InternetStatusCallback] hInternet: %p, dwInternetStatus: %lu\n"), hInternet, dwInternetStatus); + CString strMsg; + strMsg.Format(_T("[CAsyncHttpFile::InternetStatusCallback] hInternet: %p, dwContext: %lu, dwInternetStatus: %lu, lpvStatusInformation: %p, dwStatusInformationLength: %lu\n"), + hInternet, dwContext, dwInternetStatus, lpvStatusInformation, dwStatusInformationLength); + LOG_DEBUG(strMsg); + CAsyncHttpFile* pAsyncHttpFile = (CAsyncHttpFile*)dwContext; BOOST_ASSERT(pAsyncHttpFile); if(!pAsyncHttpFile) Index: src/ch/ch.cpp =================================================================== diff -u -N -rbfe720fda9529e7a77b4fb6410b4d4945b69188b -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/ch.cpp (.../ch.cpp) (revision bfe720fda9529e7a77b4fb6410b4d4945b69188b) +++ src/ch/ch.cpp (.../ch.cpp) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -83,11 +83,10 @@ } CCopyHandlerApp::CCopyHandlerApp() : - m_lfLog(), - m_piShellExtControl(NULL) + m_piShellExtControl(NULL), + m_hMapObject(NULL), + m_pMainWindow(NULL) { - m_pMainWindow=NULL; - // this is the one-instance application InitProtection(); } @@ -124,9 +123,9 @@ return ictranslate::CResourceManager::Acquire(); } -chcore::engine_config& GetConfig() +chcore::TCoreConfig& GetConfig() { - return chcore::engine_config::Acquire(); + return chcore::TCoreConfig::Acquire(); } int MsgBox(UINT uiID, UINT nType, UINT nIDHelp) @@ -210,76 +209,91 @@ BOOL CCopyHandlerApp::InitInstance() { - // set the exception handler to catch the crash dumps + // ================================= Crash handling ======================================= SetUnhandledExceptionFilter(&MyUnhandledExceptionFilter); - HRESULT hResult = CoInitializeEx(NULL, COINIT_MULTITHREADED); - if(FAILED(hResult)) - AfxMessageBox(_T("Cannot initialize COM, the application will now exit."), MB_ICONERROR | MB_OK); + // ================================= Configuration ======================================== + CString strPath; + CString strCfgPath; + CString strLogPath; - // InitCommonControlsEx() is required on Windows XP if an application - // manifest specifies use of ComCtl32.dll version 6 or later to enable - // visual styles. Otherwise, any window creation will fail. - INITCOMMONCONTROLSEX InitCtrls; - InitCtrls.dwSize = sizeof(InitCtrls); - // Set this to include all the common control classes you want to use - // in your application. - InitCtrls.dwICC = ICC_WIN95_CLASSES; - InitCommonControlsEx(&InitCtrls); + // note that the GetProgramDataPath() below should create a directory; ExpandPath() could + // depend on the directory to be created earlier + if(!GetProgramDataPath(strPath)) + { + AfxMessageBox(_T("Cannot initialize Copy Handler (data path cannot be established)."), MB_ICONERROR | MB_OK); + return FALSE; + } - EnableHtmlHelp(); - //SetHelpMode(afxHTMLHelp); + strCfgPath = strPath + _T("\\ch.ini"); - CWinApp::InitInstance(); - - m_hMapObject = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(CSharedConfigStruct), _T("CHLMFile")); - if (m_hMapObject == NULL) - return FALSE; - - // Get a pointer to the file-mapped shared memory. - g_pscsShared=(CSharedConfigStruct*)MapViewOfFile(m_hMapObject, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); - if (g_pscsShared == NULL) - return FALSE; - - chcore::engine_config& rConfig = chcore::engine_config::Acquire(); - ictranslate::CResourceManager& rResManager = ictranslate::CResourceManager::Acquire(); - - // load configuration + // initialize configuration file + chcore::TCoreConfig& rConfig = chcore::TCoreConfig::Acquire(); rConfig.set_callback(ConfigPropertyChangedCallback, NULL); - CString strPath; - // note that the GetProgramDataPath() below should create a directory; ExpandPath() could - // depend on the directory to be created earlier - if(GetProgramDataPath(strPath)) + + // read the configuration + try { - strPath += _T("\\ch.ini"); - try - { - rConfig.read(strPath); - } - catch(...) - { - } + rConfig.read(strCfgPath); } + catch(...) + { + } // set working dir for the engine - rConfig.set_base_path(strPath); + rConfig.SetBasePath(strPath); // register all properties RegisterProperties(&rConfig); - // set this process class - HANDLE hProcess=GetCurrentProcess(); - ::SetPriorityClass(hProcess, (DWORD)rConfig.get_signed_num(PP_PPROCESSPRIORITYCLASS)); + // ================================= Logging ======================================== + // initialize the global log file if it is requested by configuration file + strLogPath = strPath + + _T("\\ch.log"); + chcore::TLogger& rLogger = chcore::TLogger::Acquire(); + try + { + rLogger.init(strLogPath, (int_t)rConfig.get_signed_num(PP_LOGMAXSIZE), (int_t)rConfig.get_unsigned_num(PP_LOGLEVEL), false, false); + rLogger.Enable(rConfig.get_bool(PP_LOGENABLELOGGING)); + } + catch(...) + { + BOOST_ASSERT(false); + } + + LOG_INFO(_T("============================ Initializing Copy Handler ============================")); + LOG_INFO(_T("")); + + // ================================= COM ======================================== + LOG_INFO(_T("Initializing COM")); + + HRESULT hResult = CoInitializeEx(NULL, COINIT_MULTITHREADED); + if(FAILED(hResult)) + { + CString strMsg; + strMsg.Format(_T("Cannot initialize COM, the application will now exit (result = 0x%lx)"), hResult); + + LOG_ERROR(strMsg); + AfxMessageBox(strMsg, MB_ICONERROR | MB_OK); + return FALSE; + } + + // ================================= Resource manager ======================================== + LOG_INFO(_T("Initializing resource manager...")); + + ictranslate::CResourceManager& rResManager = ictranslate::CResourceManager::Acquire(); + // set current language TCHAR szPath[_MAX_PATH]; + rResManager.Init(AfxGetInstanceHandle()); rResManager.SetCallback(ResManCallback); rConfig.get_string(PP_PLANGUAGE, szPath, _MAX_PATH); TRACE(_T("Help path=%s\n"), szPath); - if (!rResManager.SetLanguage(ExpandPath(szPath))) + if(!rResManager.SetLanguage(ExpandPath(szPath))) { TCHAR szData[2048]; _sntprintf(szData, 2048, _T("Couldn't find the language file specified in configuration file:\n%s\nPlease correct this path to point the language file to use.\nProgram will now exit."), szPath); + LOG_ERROR(szData); AfxMessageBox(szData, MB_ICONSTOP | MB_OK); return FALSE; } @@ -289,31 +303,47 @@ // for dialogs ictranslate::CLanguageDialog::SetResManager(&rResManager); - // initialize log file - rConfig.get_string(PP_LOGPATH, szPath, _MAX_PATH); - m_lfLog.init(ExpandPath(szPath), (int_t)rConfig.get_signed_num(PP_LOGMAXLIMIT), icpf::log_file::level_debug, false, false); + EnableHtmlHelp(); - // TODO: remove unused properties from configuration -/* m_lfLog.EnableLogging(m_cfgManager.GetBoolValue(PP_LOGENABLELOGGING)); - m_lfLog.SetPreciseLimiting(m_cfgManager.GetBoolValue(PP_LOGPRECISELIMITING)); - m_lfLog.SetSizeLimit(m_cfgManager.GetBoolValue(PP_LOGLIMITATION), m_cfgManager.GetIntValue(PP_LOGMAXLIMIT)); - m_lfLog.SetTruncateBufferSize(m_cfgManager.GetIntValue(PP_LOGTRUNCBUFFERSIZE)); - m_lfLog.Init(ExpandPath(szPath), GetResManager());*/ - -#ifndef _DEBUG // for easier writing the program - doesn't collide with std CH - // set "run with system" registry settings - SetAutorun(rConfig.get_bool(PP_PRELOADAFTERRESTART)); -#endif - + // ================================= Checking for running instances of CH ======================================== // check instance - return false if it's the second one - if (!IsFirstInstance()) + LOG_INFO(_T("Checking for other running instances of Copy Handler")); + if(!IsFirstInstance()) { + LOG_WARNING(_T("Other instance of Copy Handler is already running. Exiting.")); MsgBox(IDS_ONECOPY_STRING); return FALSE; } + // ================================= Common controls ======================================== + LOG_INFO(_T("Initializing GUI common controls")); + + // InitCommonControlsEx() is required on Windows XP if an application + // manifest specifies use of ComCtl32.dll version 6 or later to enable + // visual styles. Otherwise, any window creation will fail. + INITCOMMONCONTROLSEX InitCtrls; + InitCtrls.dwSize = sizeof(InitCtrls); + // Set this to include all the common control classes you want to use + // in your application. + InitCtrls.dwICC = ICC_WIN95_CLASSES; + InitCommonControlsEx(&InitCtrls); + + // ================================= Shell extension ======================================== + LOG_INFO(_T("Initializing shared memory for communication with shell extension")); + + m_hMapObject = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(CSharedConfigStruct), _T("CHLMFile")); + if (m_hMapObject == NULL) + return FALSE; + + // Get a pointer to the file-mapped shared memory. + g_pscsShared=(CSharedConfigStruct*)MapViewOfFile(m_hMapObject, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0); + if (g_pscsShared == NULL) + return FALSE; + + LOG_INFO(_T("Checking shell extension compatibility")); + // calculate ch version - LONG lCHVersion = PRODUCT_VERSION1 << 24 | PRODUCT_VERSION2 << 16 | PRODUCT_VERSION3 << 8 | PRODUCT_VERSION4; + long lCHVersion = PRODUCT_VERSION1 << 24 | PRODUCT_VERSION2 << 16 | PRODUCT_VERSION3 << 8 | PRODUCT_VERSION4; // check the version of shell extension LONG lVersion = 0; @@ -328,6 +358,10 @@ hResult = m_piShellExtControl->SetFlags(eShellExt_Enabled, eShellExt_Enabled); if(FAILED(hResult) || lCHVersion != lVersion) { + CString strMsg; + strMsg.Format(_T("Shell extension has different version (0x%lx) than Copy Handler (0x%lx). Shell extension will be disabled."), lVersion, lCHVersion); + + LOG_WARNING(strMsg); MsgBox(IDS_SHELL_EXTENSION_MISMATCH_STRING); if(m_piShellExtControl) @@ -337,13 +371,30 @@ if(bstrVersion) ::SysFreeString(bstrVersion); + // ================================= Initial settings ======================================== + LOG_INFO(_T("Applying initial settings")); + + // set this process priority class + HANDLE hProcess=GetCurrentProcess(); + ::SetPriorityClass(hProcess, (DWORD)rConfig.get_signed_num(PP_PPROCESSPRIORITYCLASS)); + +#ifndef _DEBUG // for easier writing the program - doesn't collide with std CH + // set "run with system" registry settings + SetAutorun(rConfig.get_bool(PP_PRELOADAFTERRESTART)); +#endif + + // ================================= Main window ======================================== + LOG_INFO(_T("Creating main application window")); // create main window m_pMainWindow=new CMainWnd; if (!((CMainWnd*)m_pMainWindow)->Create()) return FALSE; // will be deleted at destructor m_pMainWnd = m_pMainWindow; + CWinApp::InitInstance(); + LOG_INFO(_T("Copy Handler initialized successfully")); + return TRUE; } @@ -362,12 +413,37 @@ void CCopyHandlerApp::OnConfigNotify(uint_t uiPropID) { // is this language - if(uiPropID == PP_PLANGUAGE) + switch(uiPropID) { - // update language in resource manager - TCHAR szPath[_MAX_PATH]; - GetConfig().get_string(PP_PLANGUAGE, szPath, _MAX_PATH); - GetResManager().SetLanguage(ExpandPath(szPath)); + case PP_PLANGUAGE: + { + // update language in resource manager + TCHAR szPath[_MAX_PATH]; + GetConfig().get_string(PP_PLANGUAGE, szPath, _MAX_PATH); + GetResManager().SetLanguage(ExpandPath(szPath)); + break; + } + case PP_LOGENABLELOGGING: + { + chcore::TLogger& rLogger = chcore::TLogger::Acquire(); + + rLogger.Enable(GetConfig().get_bool(PP_LOGENABLELOGGING)); + break; + } + case PP_LOGLEVEL: + { + chcore::TLogger& rLogger = chcore::TLogger::Acquire(); + + rLogger.set_log_level((int_t)GetConfig().get_unsigned_num(PP_LOGLEVEL)); + break; + } + case PP_LOGMAXSIZE: + { + chcore::TLogger& rLogger = chcore::TLogger::Acquire(); + + rLogger.set_max_size((int_t)GetConfig().get_signed_num(PP_LOGMAXSIZE)); + break; + } } } @@ -381,7 +457,7 @@ } } -HWND CCopyHandlerApp::HHelp(HWND hwndCaller, LPCTSTR pszFile, UINT uCommand, DWORD dwData) +HWND CCopyHandlerApp::HHelp(HWND hwndCaller, LPCTSTR pszFile, UINT uCommand, DWORD_PTR dwData) { PCTSTR pszPath=NULL; WIN32_FIND_DATA wfd; @@ -452,12 +528,17 @@ int CCopyHandlerApp::ExitInstance() { + LOG_INFO(_T("Pre-exit step - releasing shell extension")); if(m_piShellExtControl) { m_piShellExtControl->Release(); m_piShellExtControl = NULL; } + + LOG_INFO(_T("Pre-exit step - uninitializing COM")); CoUninitialize(); + LOG_INFO(_T("============================ Leaving Copy Handler ============================")); + return __super::ExitInstance(); } Index: src/ch/ch.h =================================================================== diff -u -N -r17059054c69cd5726f4c7d35357f3b9556471783 -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/ch.h (.../ch.h) (revision 17059054c69cd5726f4c7d35357f3b9556471783) +++ src/ch/ch.h (.../ch.h) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -28,8 +28,8 @@ #include "CfgProperties.h" #include "../chext/chext.h" #include "../libicpf/log.h" -#include "../libchcore/EngineCfg.h" #include "../libictranslate/ResourceManager.h" +#include "../libchcore/TCoreConfig.h" using namespace std; @@ -44,50 +44,36 @@ CCopyHandlerApp(); ~CCopyHandlerApp(); -// Overrides -public: virtual BOOL InitInstance(); + virtual int ExitInstance(); - virtual void HtmlHelp(DWORD_PTR dwData, UINT nCmd); PCTSTR GetHelpPath() const { return m_pszHelpFilePath; }; - friend LRESULT MainRouter(ULONGLONG ullDst, UINT uiMsg, WPARAM wParam, LPARAM lParam); friend int MsgBox(UINT uiID, UINT nType=MB_OK, UINT nIDHelp=0); + + friend LRESULT MainRouter(ULONGLONG ullDst, UINT uiMsg, WPARAM wParam, LPARAM lParam); friend CCopyHandlerApp& GetApp(); friend ictranslate::CResourceManager& GetResManager(); - friend chcore::engine_config& GetConfig(); -// friend CLogFile* GetLog(); + friend chcore::TCoreConfig& GetConfig(); bool IsShellExtEnabled() const; void OnConfigNotify(uint_t uiPropID); void OnResManNotify(UINT uiType); + 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: - icpf::log_file m_lfLog; - +protected: + HANDLE m_hMapObject; IShellExtControl* m_piShellExtControl; CWnd *m_pMainWindow; - // currently opened dialogs -// list m_lhDialogs; -protected: -// Implementation - HANDLE m_hMapObject; - //TCHAR m_szHelpPath[_MAX_PATH]; // full file path to the help file -// CString m_strCrashInfo; // crash info text - - //{{AFX_MSG(CCopyHandlerApp) - //}}AFX_MSG DECLARE_MESSAGE_MAP() -public: - virtual int ExitInstance(); }; Index: src/ch/ch.rc =================================================================== diff -u -N -r17059054c69cd5726f4c7d35357f3b9556471783 -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/ch.rc (.../ch.rc) (revision 17059054c69cd5726f4c7d35357f3b9556471783) +++ src/ch/ch.rc (.../ch.rc) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -1011,18 +1011,17 @@ IDS_CFGPRIORITYCLASSITEMS_STRING "Idle!Normal!High!Real-time" IDS_PLUGSFOLDER_STRING "Folder with plugins" IDS_PLUGSFOLDERCHOOSE_STRING "!Choose folder with plugins" - IDS_CFGLOGFILE_STRING "Main log file" + IDS_CFGLOGFILE_STRING "Debugging" IDS_CFGENABLELOGGING_STRING "Enable logging" - IDS_CFGLIMITATION_STRING "Use log file size limit" - IDS_CFGMAXLIMIT_STRING "Maximum size of the limited log file" - IDS_CFGLOGPRECISELIMITING_STRING "Use precise limiting of a log file" - IDS_CFGTRUNCBUFFERSIZE_STRING "Truncate buffer size" + IDS_CFGMAXLIMIT_STRING "Maximum size of the log file" IDS_CFGHELPDIR_STRING "Directory with help files" IDS_CFGHELPDIRCHOOSE_STRING "!Choose folder with program's help files" IDS_LANGUAGESFOLDER_STRING "Directory with language files" IDS_LANGSFOLDERCHOOSE_STRING "!Choose folder with language files" IDS_ABOUT_LANGUAGE_STRING "Current language: %langname, Author(s): %authors" + IDS_CFGLOGLEVEL "Log level" + IDS_CFGLOGLEVEL_VALUES "Debug!Info!Warning!Error" END STRINGTABLE Index: src/ch/resource.h =================================================================== diff -u -N -rf34d204b8eecd6817dbe4a1c3b3541cf9a8794b0 -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/resource.h (.../resource.h) (revision f34d204b8eecd6817dbe4a1c3b3541cf9a8794b0) +++ src/ch/resource.h (.../resource.h) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -414,10 +414,7 @@ #define IDS_PLUGSFOLDERCHOOSE_STRING 8084 #define IDS_CFGLOGFILE_STRING 8085 #define IDS_CFGENABLELOGGING_STRING 8086 -#define IDS_CFGLIMITATION_STRING 8087 #define IDS_CFGMAXLIMIT_STRING 8088 -#define IDS_CFGLOGPRECISELIMITING_STRING 8089 -#define IDS_CFGTRUNCBUFFERSIZE_STRING 8090 #define IDS_CFGHELPDIR_STRING 8091 #define IDS_CFGHELPDIRCHOOSE_STRING 8092 #define IDS_LANGUAGESFOLDER_STRING 8093 @@ -426,6 +423,8 @@ #define IDS_CFGINTERCEPTCONTEXTMENU_STRING 8096 #define IDS_CFG_CHECK_FOR_UPDATES_AT_STARTUP 8097 #define IDS_CFG_UPDATE_CHECK_FOR_BETA 8098 +#define IDS_CFGLOGLEVEL 8099 +#define IDS_CFGLOGLEVEL_VALUES 8100 #define IDS_MENUCOPY_STRING 9000 #define IDS_MENUMOVE_STRING 9001 #define IDS_MENUCOPYMOVESPECIAL_STRING 9002 Index: src/ch/task.cpp =================================================================== diff -u -N -r003e0baad9604efc422ecb3746154e4ff9f40156 -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/task.cpp (.../task.cpp) (revision 003e0baad9604efc422ecb3746154e4ff9f40156) +++ src/ch/task.cpp (.../task.cpp) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -1497,6 +1497,11 @@ return bFlag; } +void CTaskArray::SetTasksDir(const tchar_t* pszPath) +{ + m_strTasksDir = pszPath; +} + ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // case insensitive replacement void CTask::ReplaceNoCase(CString& rString, CString strOld, CString strNew) Index: src/ch/task.h =================================================================== diff -u -N -rf6706e71721e6828e4e3be894caec6808e27630b -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/ch/task.h (.../task.h) (revision f6706e71721e6828e4e3be894caec6808e27630b) +++ src/ch/task.h (.../task.h) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -414,7 +414,7 @@ bool IsFinished(); - void SetTasksDir(const tchar_t* pszPath) { m_strTasksDir = pszPath; } + void SetTasksDir(const tchar_t* pszPath); public: __int64 m_uhRange, m_uhPosition; Index: src/libchcore/TCoreConfig.cpp =================================================================== diff -u -N --- src/libchcore/TCoreConfig.cpp (revision 0) +++ src/libchcore/TCoreConfig.cpp (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -0,0 +1,50 @@ +/*************************************************************************** +* 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. * +***************************************************************************/ +#include "stdafx.h" +#include "../libicpf/cfg.h" +#include "TCoreConfig.h" +#include "../libicpf/exception.h" + +BEGIN_CHCORE_NAMESPACE + +TCoreConfig TCoreConfig::S_Config = icpf::config::eIni; + +TCoreConfig::TCoreConfig(icpf::config::config_base_types eType) : + icpf::config(eType) +{ +} + +TCoreConfig::~TCoreConfig() +{ +} + +void TCoreConfig::SetBasePath(const tchar_t* pszPath) +{ + if(!pszPath) + THROW(_T("Invalid argument"), 0, 0, 0); + m_strBasePath = pszPath; + m_strTasksPath = m_strBasePath + _T("\\tasks\\"); +} + +TCoreConfig& TCoreConfig::Acquire() +{ + return S_Config; +} + +END_CHCORE_NAMESPACE Index: src/libchcore/EngineCfg.cpp =================================================================== diff -u -N --- src/libchcore/EngineCfg.cpp (revision d791f35daa46db295cc0b1ebc54763e23879a351) +++ src/libchcore/EngineCfg.cpp (revision 0) @@ -1,50 +0,0 @@ -/*************************************************************************** -* 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. * -***************************************************************************/ -#include "stdafx.h" -#include "../libicpf/cfg.h" -#include "EngineCfg.h" -#include "../libicpf/exception.h" - -BEGIN_CHCORE_NAMESPACE - -engine_config engine_config::S_Config = icpf::config::eIni; - -engine_config::engine_config(icpf::config::config_base_types eType) : - icpf::config(eType) -{ -} - -engine_config::~engine_config() -{ -} - -void engine_config::set_base_path(const tchar_t* pszPath) -{ - if(!pszPath) - THROW(_T("Invalid argument"), 0, 0, 0); - m_strBasePath = pszPath; - m_strTasksPath = m_strBasePath + _T("\\tasks\\"); -} - -engine_config& engine_config::Acquire() -{ - return S_Config; -} - -END_CHCORE_NAMESPACE Index: src/libchcore/TCoreConfig.h =================================================================== diff -u -N --- src/libchcore/TCoreConfig.h (revision 0) +++ src/libchcore/TCoreConfig.h (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -0,0 +1,53 @@ +/*************************************************************************** +* 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. * +***************************************************************************/ +#ifndef __ENGINE_CFG_H__ +#define __ENGINE_CFG_H__ + +#include "libchcore.h" +#include "../libicpf/cfg.h" + +BEGIN_CHCORE_NAMESPACE + +// contains everything that could be configured inside the engine. +// supports both the informations contained in the ini file and +// ones related to current instance of CH core +class LIBCHCORE_API TCoreConfig : public icpf::config +{ +protected: + TCoreConfig(icpf::config::config_base_types eType); + virtual ~TCoreConfig(); + +public: + static TCoreConfig& Acquire(); + + // paths handling + void SetBasePath(const tchar_t* pszPath); + const tchar_t* GetBasePath() { return m_strBasePath.c_str(); } + const tchar_t* GetTasksPath() { return m_strTasksPath.c_str(); } + +private: + tstring_t m_strBasePath; + tstring_t m_strTasksPath; + + static TCoreConfig S_Config; +}; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/EngineCfg.h =================================================================== diff -u -N --- src/libchcore/EngineCfg.h (revision d791f35daa46db295cc0b1ebc54763e23879a351) +++ src/libchcore/EngineCfg.h (revision 0) @@ -1,52 +0,0 @@ -/*************************************************************************** -* 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. * -***************************************************************************/ -#ifndef __ENGINE_CFG_H__ -#define __ENGINE_CFG_H__ - -#include "libchcore.h" -#include "../libicpf/cfg.h" - -BEGIN_CHCORE_NAMESPACE - -// contains everything that could be configured inside the engine. -// supports both the informations contained in the ini file and -// ones related to current instance of CH core -class LIBCHCORE_API engine_config : public icpf::config -{ -protected: - engine_config(icpf::config::config_base_types eType); - virtual ~engine_config(); - -public: - static engine_config& Acquire(); - - // paths handling - void set_base_path(const tchar_t* pszPath); - const tchar_t* get_base_path() { return m_strBasePath.c_str(); } - const tchar_t* get_tasks_path() { return m_strTasksPath.c_str(); } - -private: - tstring_t m_strBasePath; - tstring_t m_strTasksPath; - - static engine_config S_Config; -}; - -END_CHCORE_NAMESPACE -#endif Index: src/libchcore/TLogger.cpp =================================================================== diff -u -N --- src/libchcore/TLogger.cpp (revision 0) +++ src/libchcore/TLogger.cpp (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -0,0 +1,126 @@ +// ============================================================================ +// Copyright (C) 2001-2009 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. +// ============================================================================ +/// @file TLogger.cpp +/// @date 2009/05/19 +/// @brief +// ============================================================================ +#include "stdafx.h" +#include "libchcore.h" +#include "TLogger.h" + +BEGIN_CHCORE_NAMESPACE + +TLogger TLogger::S_Logger; + +// ============================================================================ +/// chcore::TLogger::TLogger +/// @date 2009/05/23 +/// +/// @brief Constructs the TLogger object. +// ============================================================================ +TLogger::TLogger() : + m_bEnabled(false) +{ +} + +// ============================================================================ +/// chcore::TLogger::Acquire +/// @date 2009/05/20 +/// +/// @brief Acquires logger object. +/// @return Reference to the logger object. +// ============================================================================ +TLogger& TLogger::Acquire() +{ + return S_Logger; +} + +// ============================================================================ +/// chcore::TLogger::LogDebug +/// @date 2009/05/20 +/// +/// @brief Logs an information to file (debug level). +/// @param[in] pszText Text to be logged. +// ============================================================================ +void TLogger::LogDebug(const tchar_t* pszText) +{ + BOOST_ASSERT(pszText); + if(!pszText) + return; + + TLogger& rLogger = Acquire(); + if(rLogger.m_bEnabled && rLogger.is_initialized()) + rLogger.logd(pszText); +} + +// ============================================================================ +/// chcore::TLogger::LogInfo +/// @date 2009/05/20 +/// +/// @brief Logs an information to the file (info level). +/// @param[in] pszText Text to be logged. +// ============================================================================ +void TLogger::LogInfo(const tchar_t* pszText) +{ + BOOST_ASSERT(pszText); + if(!pszText) + return; + + TLogger& rLogger = Acquire(); + if(rLogger.m_bEnabled && rLogger.is_initialized()) + rLogger.logi(pszText); +} + +// ============================================================================ +/// chcore::TLogger::LogWarning +/// @date 2009/05/20 +/// +/// @brief Logs an information to the file (info level). +/// @param[in] pszText Text to be logged. +// ============================================================================ +void TLogger::LogWarning(const tchar_t* pszText) +{ + BOOST_ASSERT(pszText); + if(!pszText) + return; + + TLogger& rLogger = Acquire(); + if(rLogger.m_bEnabled && rLogger.is_initialized()) + rLogger.logw(pszText); +} + +// ============================================================================ +/// chcore::TLogger::LogError +/// @date 2009/05/20 +/// +/// @brief Logs an information to the file (info level). +/// @param[in] pszText Text to be logged. +// ============================================================================ +void TLogger::LogError(const tchar_t* pszText) +{ + BOOST_ASSERT(pszText); + if(!pszText) + return; + + TLogger& rLogger = Acquire(); + if(rLogger.m_bEnabled && rLogger.is_initialized()) + rLogger.loge(pszText); +} + +END_CHCORE_NAMESPACE Index: src/libchcore/TLogger.h =================================================================== diff -u -N --- src/libchcore/TLogger.h (revision 0) +++ src/libchcore/TLogger.h (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -0,0 +1,68 @@ +// ============================================================================ +// Copyright (C) 2001-2009 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. +// ============================================================================ +/// @file TLogger.h +/// @date 2009/05/19 +/// @brief Class contains +// ============================================================================ +#ifndef __LOGGER_H__ +#define __LOGGER_H__ + +#include "libchcore.h" +#include "../libicpf/log.h" + +#define LOG_DEBUG(text)\ + chcore::TLogger::LogDebug(text) + +#define LOG_INFO(text)\ + chcore::TLogger::LogInfo(text) + +#define LOG_WARNING(text)\ + chcore::TLogger::LogWarning(text) + +#define LOG_ERROR(text)\ + chcore::TLogger::LogError(text) + +BEGIN_CHCORE_NAMESPACE + +// Class manages logging of informations to a file. +class LIBCHCORE_API TLogger : public icpf::log_file +{ +public: + TLogger(); + + // Retrieving global object instance + static TLogger& Acquire(); ///< Acquires the Logger object + + // Logging + static void LogDebug(const tchar_t* pszText); + static void LogInfo(const tchar_t* pszText); + static void LogWarning(const tchar_t* pszText); + static void LogError(const tchar_t* pszText); + + // Initialization/settings + void Enable(bool bEnable) throw() { m_bEnabled = bEnable; } + +protected: + static TLogger S_Logger; + bool m_bEnabled; // logging enabled? +}; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -N -rcaa71fb57fcfdd3b3731ed038cecc280ff69a78e -r2457755b4084e3d1c80a8e7c77c9f0996312941b --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision caa71fb57fcfdd3b3731ed038cecc280ff69a78e) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 2457755b4084e3d1c80a8e7c77c9f0996312941b) @@ -327,111 +327,117 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - -// TODO: reference additional headers your program requires here +#include