diff options
Diffstat (limited to 'RealtimeSync')
-rw-r--r-- | RealtimeSync/RealtimeSync.cbp | 71 | ||||
-rw-r--r-- | RealtimeSync/RealtimeSync.vcxproj | 71 | ||||
-rw-r--r-- | RealtimeSync/application.cpp | 44 | ||||
-rw-r--r-- | RealtimeSync/gui_generated.cpp | 55 | ||||
-rw-r--r-- | RealtimeSync/gui_generated.h | 29 | ||||
-rw-r--r-- | RealtimeSync/main_dlg.cpp | 32 | ||||
-rw-r--r-- | RealtimeSync/main_dlg.h | 4 | ||||
-rw-r--r-- | RealtimeSync/makefile | 36 | ||||
-rw-r--r-- | RealtimeSync/resources.cpp | 57 | ||||
-rw-r--r-- | RealtimeSync/resources.h | 20 | ||||
-rw-r--r-- | RealtimeSync/tray_menu.cpp | 22 | ||||
-rw-r--r-- | RealtimeSync/watcher.cpp | 76 | ||||
-rw-r--r-- | RealtimeSync/watcher.h | 4 | ||||
-rw-r--r-- | RealtimeSync/xml_ffs.cpp | 15 | ||||
-rw-r--r-- | RealtimeSync/xml_proc.cpp | 16 | ||||
-rw-r--r-- | RealtimeSync/xml_proc.h | 2 |
16 files changed, 266 insertions, 288 deletions
diff --git a/RealtimeSync/RealtimeSync.cbp b/RealtimeSync/RealtimeSync.cbp index 5a928487..5c14d918 100644 --- a/RealtimeSync/RealtimeSync.cbp +++ b/RealtimeSync/RealtimeSync.cbp @@ -27,7 +27,7 @@ <Add library="libwxbase28u.a" /> <Add library="libwxpng.a" /> <Add library="libwxzlib.a" /> - <Add library="libboost_thread-mgw45-mt-s-1_47.a" /> + <Add library="libboost_thread-mgw46-mt-s-1_47.a" /> <Add directory="C:\Programme\C++\wxWidgets\lib\gcc_lib" /> </Linker> </Target> @@ -41,7 +41,7 @@ <Compiler> <Add option="-g" /> <Add option="-Winvalid-pch" /> - <Add option='-include "../shared/pch.h"' /> + <Add option='-include "../wx+/pch.h"' /> <Add option="-D__WXDEBUG__" /> <Add directory="C:\Program Files\C++\wxWidgets\lib\gcc_dll\mswud" /> </Compiler> @@ -51,7 +51,7 @@ <Add library="libwxbase28ud.a" /> <Add library="libwxpngd.a" /> <Add library="libwxzlibd.a" /> - <Add library="libboost_thread-mgw45-mt-sd-1_47.a" /> + <Add library="libboost_thread-mgw46-mt-sd-1_47.a" /> <Add directory="C:\Program Files\C++\wxWidgets\lib\gcc_dll" /> </Linker> </Target> @@ -65,7 +65,7 @@ <Add option="-pipe" /> <Add option="-mthreads" /> <Add option="-std=gnu++0x" /> - <Add option='-include "../shared/warn_static.h"' /> + <Add option='-include "../zen/warn_static.h"' /> <Add option="-D__GNUWIN32__" /> <Add option="-D__WXMSW__" /> <Add option="-DwxUSE_UNICODE" /> @@ -76,7 +76,7 @@ <Add option="-DWXINTL_NO_GETTEXT_MACRO" /> <Add directory="C:\Programme\C++\wxWidgets\include" /> <Add directory="C:\Program Files\C++\Boost" /> - <Add directory="..\shared" /> + <Add directory="..\." /> </Compiler> <ResourceCompiler> <Add directory="C:\Programme\C++\wxWidgets\include" /> @@ -103,7 +103,6 @@ <Unit filename="gui_generated.h" /> <Unit filename="main_dlg.cpp" /> <Unit filename="main_dlg.h" /> - <Unit filename="notify.h" /> <Unit filename="resource.rc"> <Option compilerVar="WINDRES" /> </Unit> @@ -117,51 +116,29 @@ <Unit filename="xml_ffs.h" /> <Unit filename="xml_proc.cpp" /> <Unit filename="xml_proc.h" /> - <Unit filename="..\Shared\custom_button.cpp" /> - <Unit filename="..\Shared\custom_button.h" /> - <Unit filename="..\Shared\dir_name.cpp" /> - <Unit filename="..\Shared\dir_name.h" /> - <Unit filename="..\Shared\zstring.cpp" /> - <Unit filename="..\Shared\zstring.h" /> - <Unit filename="..\library\process_xml.cpp" /> - <Unit filename="..\shared\dir_watcher.cpp" /> - <Unit filename="..\shared\dir_watcher.h" /> - <Unit filename="..\shared\dll_loader.h" /> - <Unit filename="..\shared\dst_hack.cpp" /> - <Unit filename="..\shared\dst_hack.h" /> - <Unit filename="..\shared\file_error.h" /> - <Unit filename="..\shared\file_handling.cpp" /> - <Unit filename="..\shared\file_handling.h" /> - <Unit filename="..\shared\file_id.cpp" /> - <Unit filename="..\shared\file_io.cpp" /> - <Unit filename="..\shared\file_traverser.cpp" /> - <Unit filename="..\shared\folder_history_box.cpp" /> - <Unit filename="..\shared\global_func.h" /> - <Unit filename="..\shared\help_provider.cpp" /> - <Unit filename="..\shared\i18n.cpp" /> - <Unit filename="..\shared\i18n.h" /> - <Unit filename="..\shared\last_error.cpp" /> - <Unit filename="..\shared\last_error.h" /> - <Unit filename="..\shared\localization.cpp" /> - <Unit filename="..\shared\long_path_prefix.h" /> - <Unit filename="..\shared\mouse_move_dlg.cpp" /> - <Unit filename="..\shared\notify_removal.cpp" /> - <Unit filename="..\shared\notify_removal.h" /> - <Unit filename="..\shared\pch.h"> + <Unit filename="..\lib\dir_name.cpp" /> + <Unit filename="..\lib\folder_history_box.cpp" /> + <Unit filename="..\lib\localization.cpp" /> + <Unit filename="..\lib\process_xml.cpp" /> + <Unit filename="..\lib\resolve_path.cpp" /> + <Unit filename="..\lib\xml_base.cpp" /> + <Unit filename="..\structures.cpp" /> + <Unit filename="..\wx+\button.cpp" /> + <Unit filename="..\wx+\format_unit.cpp" /> + <Unit filename="..\wx+\mouse_move_dlg.cpp" /> + <Unit filename="..\wx+\pch.h"> <Option compile="1" /> <Option weight="0" /> <Option target="Debug-DLL" /> </Unit> - <Unit filename="..\shared\privilege.cpp" /> - <Unit filename="..\shared\resolve_path.cpp" /> - <Unit filename="..\shared\resolve_path.h" /> - <Unit filename="..\shared\shell_execute.h" /> - <Unit filename="..\shared\standard_paths.cpp" /> - <Unit filename="..\shared\standard_paths.h" /> - <Unit filename="..\shared\util.cpp" /> - <Unit filename="..\shared\xml_base.cpp" /> - <Unit filename="..\shared\xml_base.h" /> - <Unit filename="..\structures.cpp" /> + <Unit filename="..\zen\dir_watcher.cpp" /> + <Unit filename="..\zen\dst_hack.cpp" /> + <Unit filename="..\zen\file_handling.cpp" /> + <Unit filename="..\zen\file_io.cpp" /> + <Unit filename="..\zen\file_traverser.cpp" /> + <Unit filename="..\zen\notify_removal.cpp" /> + <Unit filename="..\zen\privilege.cpp" /> + <Unit filename="..\zen\zstring.cpp" /> <Extensions> <code_completion /> <envvars /> diff --git a/RealtimeSync/RealtimeSync.vcxproj b/RealtimeSync/RealtimeSync.vcxproj index f6f018a1..81b51005 100644 --- a/RealtimeSync/RealtimeSync.vcxproj +++ b/RealtimeSync/RealtimeSync.vcxproj @@ -100,13 +100,13 @@ <WarningLevel>Level4</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>ZEN_PLATFORM_WINDOWS;wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;__WXDEBUG__</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\shared;C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswud;C:\Program Files\C++\Boost</AdditionalIncludeDirectories> - <PrecompiledHeaderFile>$(ProjectDir)/../shared/pch.h</PrecompiledHeaderFile> - <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings> + <AdditionalIncludeDirectories>..;../zenXml;C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswud;C:\Program Files\C++\Boost</AdditionalIncludeDirectories> + <PrecompiledHeaderFile>wx+/pch.h</PrecompiledHeaderFile> + <DisableSpecificWarnings>4100;4996;4267;4512</DisableSpecificWarnings> <MultiProcessorCompilation>false</MultiProcessorCompilation> <DisableLanguageExtensions>false</DisableLanguageExtensions> <PrecompiledHeaderOutputFile>$(IntDir)pch.obj</PrecompiledHeaderOutputFile> - <ForcedIncludeFiles>$(SolutionDir)shared/warn_static.h;$(ProjectDir)/../shared/pch.h</ForcedIncludeFiles> + <ForcedIncludeFiles>zen/warn_static.h;wx+/pch.h</ForcedIncludeFiles> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> </ClCompile> <Link> @@ -130,13 +130,13 @@ <WarningLevel>Level4</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>ZEN_PLATFORM_WINDOWS;wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;__WXDEBUG__</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\shared;C:\Program Files\C++\wxWidgets-x64\include;C:\Program Files\C++\wxWidgets-x64\lib\vc_lib\mswud;C:\Program Files\C++\Boost</AdditionalIncludeDirectories> - <PrecompiledHeaderFile>$(ProjectDir)/../shared/pch.h</PrecompiledHeaderFile> - <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings> + <AdditionalIncludeDirectories>..;../zenXml;C:\Program Files\C++\wxWidgets-x64\include;C:\Program Files\C++\wxWidgets-x64\lib\vc_lib\mswud;C:\Program Files\C++\Boost</AdditionalIncludeDirectories> + <PrecompiledHeaderFile>wx+/pch.h</PrecompiledHeaderFile> + <DisableSpecificWarnings>4100;4996;4267;4512</DisableSpecificWarnings> <MultiProcessorCompilation>false</MultiProcessorCompilation> <DisableLanguageExtensions>false</DisableLanguageExtensions> <PrecompiledHeaderOutputFile>$(IntDir)pch.obj</PrecompiledHeaderOutputFile> - <ForcedIncludeFiles>$(SolutionDir)shared/warn_static.h;$(ProjectDir)/../shared/pch.h</ForcedIncludeFiles> + <ForcedIncludeFiles>zen/warn_static.h;wx+/pch.h</ForcedIncludeFiles> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <SuppressStartupBanner>true</SuppressStartupBanner> </ClCompile> @@ -163,13 +163,13 @@ <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>ZEN_PLATFORM_WINDOWS;wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\shared;C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswu;C:\Program Files\C++\Boost</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..;../zenXml;C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswu;C:\Program Files\C++\Boost</AdditionalIncludeDirectories> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> - <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings> + <DisableSpecificWarnings>4100;4996;4267;4512</DisableSpecificWarnings> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <MultiProcessorCompilation>true</MultiProcessorCompilation> <DisableLanguageExtensions>false</DisableLanguageExtensions> - <ForcedIncludeFiles>$(SolutionDir)shared/warn_static.h;</ForcedIncludeFiles> + <ForcedIncludeFiles>zen/warn_static.h</ForcedIncludeFiles> </ClCompile> <Link> <SubSystem>Windows</SubSystem> @@ -198,14 +198,14 @@ <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>ZEN_PLATFORM_WINDOWS;wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG</PreprocessorDefinitions> - <AdditionalIncludeDirectories>..\shared;C:\Program Files\C++\wxWidgets-x64\include;C:\Program Files\C++\wxWidgets-x64\lib\vc_lib\mswu;C:\Program Files\C++\Boost</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..;../zenXml;C:\Program Files\C++\wxWidgets-x64\include;C:\Program Files\C++\wxWidgets-x64\lib\vc_lib\mswu;C:\Program Files\C++\Boost</AdditionalIncludeDirectories> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> - <DisableSpecificWarnings>4512;4996;4100;4127</DisableSpecificWarnings> + <DisableSpecificWarnings>4100;4996;4267;4512</DisableSpecificWarnings> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <MultiProcessorCompilation>true</MultiProcessorCompilation> <DisableLanguageExtensions>false</DisableLanguageExtensions> <SuppressStartupBanner>true</SuppressStartupBanner> - <ForcedIncludeFiles>$(SolutionDir)shared/warn_static.h;</ForcedIncludeFiles> + <ForcedIncludeFiles>zen/warn_static.h</ForcedIncludeFiles> </ClCompile> <Link> <SubSystem>Windows</SubSystem> @@ -227,32 +227,28 @@ </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> - <ClCompile Include="..\library\process_xml.cpp" /> - <ClCompile Include="..\shared\custom_button.cpp" /> - <ClCompile Include="..\shared\dir_watcher.cpp" /> - <ClCompile Include="..\shared\dir_name.cpp" /> - <ClCompile Include="..\shared\dst_hack.cpp" /> - <ClCompile Include="..\shared\file_handling.cpp" /> - <ClCompile Include="..\shared\file_io.cpp" /> - <ClCompile Include="..\shared\file_traverser.cpp" /> - <ClCompile Include="..\shared\folder_history_box.cpp" /> - <ClCompile Include="..\shared\help_provider.cpp" /> - <ClCompile Include="..\shared\i18n.cpp" /> - <ClCompile Include="..\shared\localization.cpp" /> - <ClCompile Include="..\shared\mouse_move_dlg.cpp" /> - <ClCompile Include="..\shared\notify_removal.cpp" /> - <ClCompile Include="..\shared\privilege.cpp" /> - <ClCompile Include="..\shared\resolve_path.cpp" /> - <ClCompile Include="..\shared\standard_paths.cpp" /> - <ClCompile Include="..\shared\last_error.cpp" /> - <ClCompile Include="..\shared\util.cpp" /> - <ClCompile Include="..\shared\xml_base.cpp" /> - <ClCompile Include="..\shared\zstring.cpp" /> + <ClCompile Include="..\lib\dir_name.cpp" /> + <ClCompile Include="..\lib\folder_history_box.cpp" /> + <ClCompile Include="..\lib\localization.cpp" /> + <ClCompile Include="..\lib\process_xml.cpp" /> + <ClCompile Include="..\lib\resolve_path.cpp" /> + <ClCompile Include="..\lib\xml_base.cpp" /> <ClCompile Include="..\structures.cpp" /> + <ClCompile Include="..\wx+\button.cpp" /> + <ClCompile Include="..\wx+\format_unit.cpp" /> + <ClCompile Include="..\wx+\mouse_move_dlg.cpp" /> + <ClCompile Include="..\zen\dir_watcher.cpp" /> + <ClCompile Include="..\zen\dst_hack.cpp" /> + <ClCompile Include="..\zen\file_handling.cpp" /> + <ClCompile Include="..\zen\file_io.cpp" /> + <ClCompile Include="..\zen\file_traverser.cpp" /> + <ClCompile Include="..\zen\notify_removal.cpp" /> + <ClCompile Include="..\zen\privilege.cpp" /> + <ClCompile Include="..\zen\zstring.cpp" /> <ClCompile Include="application.cpp"> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> - <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)/../shared/pch.h</PrecompiledHeaderFile> + <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">wx+/pch.h</PrecompiledHeaderFile> </ClCompile> <ClCompile Include="gui_generated.cpp" /> <ClCompile Include="main_dlg.cpp" /> @@ -268,9 +264,6 @@ <ItemGroup> <None Include="WxWizDialog.fbp" /> </ItemGroup> - <ItemGroup> - <ClInclude Include="../shared/pch.h" /> - </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/RealtimeSync/application.cpp b/RealtimeSync/application.cpp index aa1a1385..55c2e9c3 100644 --- a/RealtimeSync/application.cpp +++ b/RealtimeSync/application.cpp @@ -9,17 +9,21 @@ #include <wx/event.h> #include "resources.h" #include <wx/msgdlg.h> -#include "../shared/localization.h" +#include "../lib/localization.h" #include "xml_ffs.h" -#include "../shared/standard_paths.h" +#include "../lib/ffs_paths.h" #include <wx/file.h> -#include "../shared/string_conv.h" +#include <wx+/string_conv.h> #include <wx/log.h> +#include <zen/file_handling.h> #ifdef FFS_LINUX #include <gtk/gtk.h> #endif +using namespace zen; + + IMPLEMENT_APP(Application); bool Application::OnInit() @@ -49,28 +53,32 @@ void Application::OnStartApplication(wxIdleEvent& event) zen::setLanguage(rts::getProgramLanguage()); //try to set config/batch-filename set by %1 parameter - wxString cfgFilename; - if (argc > 1) + std::vector<wxString> commandArgs; + for (int i = 1; i < argc; ++i) { - const wxString filename(argv[1]); - - if (wxFileExists(filename)) //load file specified by %1 parameter: - cfgFilename = filename; - else if (wxFileExists(filename + wxT(".ffs_real"))) - cfgFilename = filename + wxT(".ffs_real"); - else if (wxFileExists(filename + wxT(".ffs_batch"))) - cfgFilename = filename + wxT(".ffs_batch"); - else + Zstring filename = toZ(argv[i]); + + if (!fileExists(filename)) //be a little tolerant { - wxMessageBox(wxString(_("File does not exist:")) + wxT(" \"") + filename + wxT("\""), _("Error"), wxOK | wxICON_ERROR); - return; + if (fileExists(filename + Zstr(".ffs_real"))) + filename = filename + Zstr(".ffs_real"); + else if (fileExists(filename + Zstr(".ffs_batch"))) + filename = filename + Zstr(".ffs_batch"); + else + { + wxMessageBox(wxString(_("File does not exist:")) + wxT(" \"") + toWx(filename) + wxT("\""), _("Error"), wxOK | wxICON_ERROR); + return; + } } + commandArgs.push_back(toWx(filename)); } - GlobalResources::getInstance().load(); //loads bitmap resources on program startup + wxString cfgFilename; + if (!commandArgs.empty()) + cfgFilename = commandArgs[0]; MainDialog* frame = new MainDialog(NULL, cfgFilename); - frame->SetIcon(*GlobalResources::getInstance().programIcon); //set application icon + frame->SetIcon(GlobalResources::instance().programIcon); //set application icon frame->Show(); } diff --git a/RealtimeSync/gui_generated.cpp b/RealtimeSync/gui_generated.cpp index 2ec50c11..a8514907 100644 --- a/RealtimeSync/gui_generated.cpp +++ b/RealtimeSync/gui_generated.cpp @@ -1,12 +1,13 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Mar 22 2011) +// C++ code generated with wxFormBuilder (version Jun 30 2011) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "../shared/custom_button.h" -#include "../shared/dir_picker_i18n.h" +#include "../ui/wx_form_build_hide_warnings.h" +#include "../wx+/button.h" +#include "../wx+/dir_picker.h" #include "gui_generated.h" @@ -14,7 +15,7 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { - this->SetSizeHints( wxSize( 420, 440 ), wxDefaultSize ); + this->SetSizeHints( wxSize( 420,440 ), wxDefaultSize ); m_menubar1 = new wxMenuBar( 0 ); m_menuFile = new wxMenu(); @@ -66,7 +67,7 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr m_staticText2->Wrap( -1 ); m_staticText2->SetFont( wxFont( 10, 74, 90, 90, true, wxEmptyString ) ); - sbSizer41->Add( m_staticText2, 0, wxBOTTOM | wxRIGHT | wxLEFT, 5 ); + sbSizer41->Add( m_staticText2, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_staticText3 = new wxStaticText( m_panelMain, wxID_ANY, _("1. Select directories to monitor."), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText3->Wrap( -1 ); @@ -81,16 +82,16 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr sbSizer41->Add( m_staticText5, 0, wxLEFT, 10 ); m_staticline3 = new wxStaticLine( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - sbSizer41->Add( m_staticline3, 0, wxEXPAND | wxTOP | wxBOTTOM, 5 ); + sbSizer41->Add( m_staticline3, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); m_staticText21 = new wxStaticText( m_panelMain, wxID_ANY, _("The command line is executed each time:\n- all directories become available (e.g. USB stick insert)\n- files within these directories or subdirectories are modified"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText21->Wrap( -1 ); - sbSizer41->Add( m_staticText21, 0, wxRIGHT | wxLEFT | wxEXPAND, 5 ); + sbSizer41->Add( m_staticText21, 0, wxRIGHT|wxLEFT|wxEXPAND, 5 ); - bSizer1->Add( sbSizer41, 0, wxALIGN_CENTER_HORIZONTAL | wxRIGHT | wxLEFT | wxEXPAND, 40 ); + bSizer1->Add( sbSizer41, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxEXPAND, 40 ); m_staticline2 = new wxStaticLine( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizer1->Add( m_staticline2, 0, wxTOP | wxBOTTOM | wxEXPAND, 10 ); + bSizer1->Add( m_staticline2, 0, wxTOP|wxBOTTOM|wxEXPAND, 10 ); wxBoxSizer* bSizer8; bSizer8 = new wxBoxSizer( wxVERTICAL ); @@ -104,22 +105,22 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr wxBoxSizer* bSizer781; bSizer781 = new wxBoxSizer( wxHORIZONTAL ); - m_bpButtonAddFolder = new wxBitmapButton( m_panelMainFolder, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 19, 21 ), wxBU_AUTODRAW ); + m_bpButtonAddFolder = new wxBitmapButton( m_panelMainFolder, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 19,21 ), wxBU_AUTODRAW ); m_bpButtonAddFolder->SetToolTip( _("Add folder") ); - bSizer781->Add( m_bpButtonAddFolder, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5 ); + bSizer781->Add( m_bpButtonAddFolder, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - m_bpButtonRemoveTopFolder = new wxBitmapButton( m_panelMainFolder, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 19, 21 ), wxBU_AUTODRAW ); + m_bpButtonRemoveTopFolder = new wxBitmapButton( m_panelMainFolder, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 19,21 ), wxBU_AUTODRAW ); m_bpButtonRemoveTopFolder->SetToolTip( _("Remove folder") ); - bSizer781->Add( m_bpButtonRemoveTopFolder, 0, wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5 ); + bSizer781->Add( m_bpButtonRemoveTopFolder, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); bSizer114->Add( bSizer781, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_txtCtrlDirectoryMain = new wxTextCtrl( m_panelMainFolder, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizer114->Add( m_txtCtrlDirectoryMain, 1, wxALIGN_CENTER_VERTICAL, 5 ); - m_dirPickerMain = new FfsDirPickerCtrl( m_panelMainFolder, wxID_ANY, wxEmptyString, _("Select a folder"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dirPickerMain = new zen::DirPickerCtrl( m_panelMainFolder, wxID_ANY, wxEmptyString, _("Select a folder"), wxDefaultPosition, wxDefaultSize, 0 ); m_dirPickerMain->SetToolTip( _("Select a folder") ); bSizer114->Add( m_dirPickerMain, 0, wxALIGN_CENTER_VERTICAL, 5 ); @@ -129,7 +130,7 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr bSizer114->Fit( m_panelMainFolder ); sbSizerDirToWatch->Add( m_panelMainFolder, 0, wxEXPAND, 5 ); - m_scrolledWinFolders = new wxScrolledWindow( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL | wxVSCROLL ); + m_scrolledWinFolders = new wxScrolledWindow( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); m_scrolledWinFolders->SetScrollRate( 5, 5 ); bSizerFolders = new wxBoxSizer( wxVERTICAL ); @@ -138,17 +139,17 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr bSizerFolders->Fit( m_scrolledWinFolders ); sbSizerDirToWatch->Add( m_scrolledWinFolders, 0, wxEXPAND, 5 ); - bSizer8->Add( sbSizerDirToWatch, 0, wxEXPAND | wxBOTTOM | wxRIGHT | wxLEFT, 5 ); + bSizer8->Add( sbSizerDirToWatch, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bSizer1->Add( bSizer8, 1, wxEXPAND, 5 ); + bSizer1->Add( bSizer8, 0, wxEXPAND, 5 ); wxStaticBoxSizer* sbSizer3; sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( m_panelMain, wxID_ANY, _("Command line") ), wxVERTICAL ); m_textCtrlCommand = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - sbSizer3->Add( m_textCtrlCommand, 0, wxEXPAND | wxBOTTOM, 5 ); + sbSizer3->Add( m_textCtrlCommand, 0, wxEXPAND|wxBOTTOM, 5 ); - bSizer1->Add( sbSizer3, 0, wxEXPAND | wxTOP | wxRIGHT | wxLEFT, 5 ); + bSizer1->Add( sbSizer3, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); wxStaticBoxSizer* sbSizer4; sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( m_panelMain, wxID_ANY, _("Minimum Idle Time [seconds]") ), wxVERTICAL ); @@ -156,20 +157,20 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr m_spinCtrlDelay = new wxSpinCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 2000000000, 0 ); m_spinCtrlDelay->SetToolTip( _("Idle time between detection of last change and execution of command line in seconds") ); - sbSizer4->Add( m_spinCtrlDelay, 0, wxBOTTOM | wxRIGHT | wxLEFT | wxALIGN_CENTER_HORIZONTAL, 5 ); + sbSizer4->Add( m_spinCtrlDelay, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_HORIZONTAL, 5 ); - bSizer1->Add( sbSizer4, 0, wxEXPAND | wxRIGHT | wxLEFT, 5 ); + bSizer1->Add( sbSizer4, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); m_staticline1 = new wxStaticLine( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizer1->Add( m_staticline1, 0, wxEXPAND | wxTOP | wxBOTTOM, 10 ); + bSizer1->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxBOTTOM, 10 ); - m_buttonStart = new wxButtonWithImage( m_panelMain, wxID_ANY, _("Start"), wxDefaultPosition, wxSize( -1, 40 ), 0 ); + m_buttonStart = new zen::BitmapButton( m_panelMain, wxID_ANY, _("Start"), wxDefaultPosition, wxSize( -1,40 ), 0 ); m_buttonStart->SetDefault(); m_buttonStart->SetFont( wxFont( 14, 74, 90, 92, false, wxT("Arial Black") ) ); - bSizer1->Add( m_buttonStart, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer1->Add( m_buttonStart, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - m_buttonCancel = new wxButton( m_panelMain, wxID_CANCEL, _("dummy"), wxDefaultPosition, wxSize( 0, 0 ), 0 ); + m_buttonCancel = new wxButton( m_panelMain, wxID_CANCEL, _("dummy"), wxDefaultPosition, wxSize( 0,0 ), 0 ); bSizer1->Add( m_buttonCancel, 0, 0, 5 ); m_panelMain->SetSizer( bSizer1 ); @@ -215,7 +216,7 @@ FolderGenerated::FolderGenerated( wxWindow* parent, wxWindowID id, const wxPoint wxBoxSizer* bSizer114; bSizer114 = new wxBoxSizer( wxHORIZONTAL ); - m_bpButtonRemoveFolder = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 19, 21 ), wxBU_AUTODRAW ); + m_bpButtonRemoveFolder = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 19,21 ), wxBU_AUTODRAW ); m_bpButtonRemoveFolder->SetToolTip( _("Remove folder") ); bSizer114->Add( m_bpButtonRemoveFolder, 0, wxALIGN_CENTER_VERTICAL, 5 ); @@ -226,7 +227,7 @@ FolderGenerated::FolderGenerated( wxWindow* parent, wxWindowID id, const wxPoint m_txtCtrlDirectory = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); bSizer20->Add( m_txtCtrlDirectory, 1, wxALIGN_CENTER_VERTICAL, 5 ); - m_dirPicker = new FfsDirPickerCtrl( this, wxID_ANY, wxEmptyString, _("Select a folder"), wxDefaultPosition, wxDefaultSize, 0 ); + m_dirPicker = new zen::DirPickerCtrl( this, wxID_ANY, wxEmptyString, _("Select a folder"), wxDefaultPosition, wxDefaultSize, 0 ); m_dirPicker->SetToolTip( _("Select a folder") ); bSizer20->Add( m_dirPicker, 0, wxALIGN_CENTER_VERTICAL, 5 ); diff --git a/RealtimeSync/gui_generated.h b/RealtimeSync/gui_generated.h index fa31652f..cedd812f 100644 --- a/RealtimeSync/gui_generated.h +++ b/RealtimeSync/gui_generated.h @@ -1,17 +1,19 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Mar 22 2011) +// C++ code generated with wxFormBuilder (version Jun 30 2011) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __gui_generated__ -#define __gui_generated__ +#ifndef __GUI_GENERATED_H__ +#define __GUI_GENERATED_H__ +#include <wx/artprov.h> +#include <wx/xrc/xmlres.h> #include <wx/intl.h> - -class FfsDirPickerCtrl; -class wxButtonWithImage; +class wxStaticText; +namespace zen { class BitmapButton; } +namespace zen { class DirPickerCtrl; } #include <wx/string.h> #include <wx/bitmap.h> @@ -35,7 +37,7 @@ class wxButtonWithImage; #include <wx/spinctrl.h> #include <wx/frame.h> -#include "../shared/i18n.h" +#include "../zen/i18n.h" /////////////////////////////////////////////////////////////////////////// @@ -53,7 +55,6 @@ protected: wxMenuItem* m_menuItemAbout; wxBoxSizer* bSizerMain; wxPanel* m_panelMain; - wxStaticText* m_staticText2; wxStaticText* m_staticText3; wxStaticText* m_staticText4; @@ -71,7 +72,7 @@ protected: wxTextCtrl* m_textCtrlCommand; wxSpinCtrl* m_spinCtrlDelay; wxStaticLine* m_staticline1; - wxButtonWithImage* m_buttonStart; + zen::BitmapButton* m_buttonStart; wxButton* m_buttonCancel; // Virtual event handlers, overide them in your derived class @@ -87,9 +88,9 @@ protected: public: - FfsDirPickerCtrl* m_dirPickerMain; + zen::DirPickerCtrl* m_dirPickerMain; - MainDlgGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("RealtimeSync - Automated Synchronization"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1, -1 ), long style = wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL ); + MainDlgGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("RealtimeSync - Automated Synchronization"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); ~MainDlgGenerated(); @@ -107,11 +108,11 @@ protected: public: wxBitmapButton* m_bpButtonRemoveFolder; wxTextCtrl* m_txtCtrlDirectory; - FfsDirPickerCtrl* m_dirPicker; + zen::DirPickerCtrl* m_dirPicker; - FolderGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1, -1 ), long style = wxTAB_TRAVERSAL ); + FolderGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); ~FolderGenerated(); }; -#endif //__gui_generated__ +#endif //__GUI_GENERATED_H__ diff --git a/RealtimeSync/main_dlg.cpp b/RealtimeSync/main_dlg.cpp index 539a8bbe..15623286 100644 --- a/RealtimeSync/main_dlg.cpp +++ b/RealtimeSync/main_dlg.cpp @@ -6,22 +6,22 @@ #include "main_dlg.h" #include "resources.h" -#include "../shared/custom_button.h" -#include "../shared/standard_paths.h" +#include <wx+/button.h> +#include "../lib/ffs_paths.h" #include <wx/msgdlg.h> #include <wx/wupdlock.h> #include "watcher.h" #include <wx/utils.h> #include "xml_proc.h" #include "tray_menu.h" -#include "../shared/file_handling.h" +#include <zen/file_handling.h> #include "xml_ffs.h" -#include "../shared/string_conv.h" -#include "../shared/assert_static.h" -#include "../shared/build_info.h" -#include "../shared/help_provider.h" -#include "../shared/util.h" -#include "../shared/mouse_move_dlg.h" +#include <wx+/string_conv.h> +#include <zen/assert_static.h> +#include <zen/build_info.h> +#include "../lib/help_provider.h" +#include "../lib/process_xml.h" +#include <wx+/mouse_move_dlg.h> using namespace zen; @@ -34,9 +34,9 @@ MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName) m_bpButtonRemoveTopFolder->Hide(); m_panelMainFolder->Layout(); - m_bpButtonAddFolder->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("addFolderPair"))); - m_bpButtonRemoveTopFolder->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("removeFolderPair"))); - m_buttonStart->setBitmapFront(GlobalResources::getInstance().getImageByName(wxT("startRed"))); + m_bpButtonAddFolder->SetBitmapLabel(GlobalResources::getImage(wxT("addFolderPair"))); + m_bpButtonRemoveTopFolder->SetBitmapLabel(GlobalResources::getImage(wxT("removeFolderPair"))); + m_buttonStart->setBitmapFront(GlobalResources::getImage(wxT("startRed"))); //register key event Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(MainDialog::OnKeyPressed), NULL, this); @@ -145,11 +145,11 @@ void MainDialog::OnMenuAbout(wxCommandEvent& event) #endif //wxUSE_UNICODE //compile time info about 32/64-bit build - if (util::is64BitBuild) + if (zen::is64BitBuild) build += wxT(" x64"); else build += wxT(" x86"); - assert_static(util::is32BitBuild || util::is64BitBuild); + assert_static(zen::is32BitBuild || zen::is64BitBuild); wxString buildFormatted = _("(Build: %x)"); buildFormatted.Replace(wxT("%x"), build); @@ -176,7 +176,7 @@ void MainDialog::OnStart(wxCommandEvent& event) Hide(); - switch (rts::startDirectoryMonitor(currentCfg, zen::extractJobName(currentConfigFileName))) + switch (rts::startDirectoryMonitor(currentCfg, xmlAccess::extractJobName(currentConfigFileName))) { case rts::QUIT: { @@ -378,7 +378,7 @@ void MainDialog::addFolder(const std::vector<wxString>& newFolders, bool addFron { //add new folder pair DirectoryPanel* newFolder = new DirectoryPanel(m_scrolledWinFolders); - newFolder->m_bpButtonRemoveFolder->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("removeFolderPair"))); + newFolder->m_bpButtonRemoveFolder->SetBitmapLabel(GlobalResources::getImage(wxT("removeFolderPair"))); //get size of scrolled window folderHeight = newFolder->GetSize().GetHeight(); diff --git a/RealtimeSync/main_dlg.h b/RealtimeSync/main_dlg.h index ca054b65..5c77fa8f 100644 --- a/RealtimeSync/main_dlg.h +++ b/RealtimeSync/main_dlg.h @@ -10,8 +10,8 @@ #include "gui_generated.h" #include <vector> #include <memory> -#include "../shared/dir_name.h" -#include "../shared/dir_picker_i18n.h" +#include "../lib/dir_name.h" +#include <wx+/dir_picker.h> namespace xmlAccess { diff --git a/RealtimeSync/makefile b/RealtimeSync/makefile index c0ac3aa5..4cef8c62 100644 --- a/RealtimeSync/makefile +++ b/RealtimeSync/makefile @@ -2,7 +2,7 @@ APPNAME = RealtimeSync prefix = /usr BINDIR = $(DESTDIR)$(prefix)/bin -COMMON_COMPILE_FLAGS = -Wall -pipe `pkg-config --cflags gtk+-2.0` -O3 -pthread -std=gnu++0x -DNDEBUG -DwxUSE_UNICODE -DFFS_LINUX -DZEN_PLATFORM_OTHER -DWXINTL_NO_GETTEXT_MACRO -I../shared +COMMON_COMPILE_FLAGS = -Wall -pipe `pkg-config --cflags gtk+-2.0` -O3 -pthread -std=gnu++0x -DNDEBUG -DwxUSE_UNICODE -DFFS_LINUX -DZEN_PLATFORM_OTHER -DWXINTL_NO_GETTEXT_MACRO -I.. -I../zenXml COMMON_LINK_FLAGS = -O3 -pthread #default build @@ -15,33 +15,29 @@ FFS_CPPFLAGS = $(COMMON_COMPILE_FLAGS) `wx-config --cxxflags --debug=no --unicod LINKFLAGS = $(COMMON_LINK_FLAGS) `wx-config --libs --debug=no --unicode=yes --static=yes` /usr/local/lib/libboost_thread.a endif -FILE_LIST= #internal list of all *.cpp files needed for compilation +FILE_LIST= #internal list of all *.cpp files needed for compilation FILE_LIST+=application.cpp FILE_LIST+=gui_generated.cpp FILE_LIST+=main_dlg.cpp FILE_LIST+=resources.cpp FILE_LIST+=tray_menu.cpp FILE_LIST+=watcher.cpp -FILE_LIST+=xml_proc.cpp FILE_LIST+=xml_ffs.cpp -FILE_LIST+=../library/process_xml.cpp +FILE_LIST+=xml_proc.cpp +FILE_LIST+=../lib/dir_name.cpp +FILE_LIST+=../lib/folder_history_box.cpp +FILE_LIST+=../lib/localization.cpp +FILE_LIST+=../lib/process_xml.cpp +FILE_LIST+=../lib/resolve_path.cpp +FILE_LIST+=../lib/xml_base.cpp FILE_LIST+=../structures.cpp -FILE_LIST+=../shared/folder_history_box.cpp -FILE_LIST+=../shared/util.cpp -FILE_LIST+=../shared/i18n.cpp -FILE_LIST+=../shared/localization.cpp -FILE_LIST+=../shared/dir_watcher.cpp -FILE_LIST+=../shared/last_error.cpp -FILE_LIST+=../shared/dir_name.cpp -FILE_LIST+=../shared/zstring.cpp -FILE_LIST+=../shared/xml_base.cpp -FILE_LIST+=../shared/custom_button.cpp -FILE_LIST+=../shared/file_handling.cpp -FILE_LIST+=../shared/resolve_path.cpp -FILE_LIST+=../shared/file_traverser.cpp -FILE_LIST+=../shared/standard_paths.cpp -FILE_LIST+=../shared/help_provider.cpp -FILE_LIST+=../shared/file_io.cpp +FILE_LIST+=../wx+/button.cpp +FILE_LIST+=../wx+/format_unit.cpp +FILE_LIST+=../zen/dir_watcher.cpp +FILE_LIST+=../zen/file_handling.cpp +FILE_LIST+=../zen/file_io.cpp +FILE_LIST+=../zen/file_traverser.cpp +FILE_LIST+=../zen/zstring.cpp #list of all *.o files OBJECT_LIST=$(foreach file, $(FILE_LIST), ../OBJ/RTS_Release_GCC_Make/$(subst .cpp,.o,$(notdir $(file)))) diff --git a/RealtimeSync/resources.cpp b/RealtimeSync/resources.cpp index 2a7e2818..2936b7dc 100644 --- a/RealtimeSync/resources.cpp +++ b/RealtimeSync/resources.cpp @@ -5,42 +5,24 @@ // ************************************************************************** #include "resources.h" +#include <memory> #include <wx/wfstream.h> #include <wx/zipstrm.h> #include <wx/image.h> -#include <wx/icon.h> -#include <memory> -#include "../shared/standard_paths.h" +#include "../lib/ffs_paths.h" using namespace zen; -const GlobalResources& GlobalResources::getInstance() +const GlobalResources& GlobalResources::instance() { - static GlobalResources instance; - return instance; + static GlobalResources inst; + return inst; } GlobalResources::GlobalResources() { - programIcon = new wxIcon(wxNullIcon); -} - - -GlobalResources::~GlobalResources() -{ - //free bitmap resources - for (std::map<wxString, wxBitmap*>::iterator i = bitmapResource.begin(); i != bitmapResource.end(); ++i) - delete i->second; - - //free other resources - delete programIcon; -} - - -void GlobalResources::load() const -{ wxFFileInputStream input(zen::getResourceDir() + wxT("Resources.zip")); if (input.IsOk()) //if not... we don't want to react too harsh here { @@ -51,7 +33,7 @@ void GlobalResources::load() const while (true) { - std::auto_ptr<wxZipEntry> entry(resourceFile.GetNextEntry()); + std::unique_ptr<wxZipEntry> entry(resourceFile.GetNextEntry()); if (entry.get() == NULL) break; @@ -59,32 +41,31 @@ void GlobalResources::load() const //generic image loading if (name.EndsWith(wxT(".png"))) - { - if (bitmapResource.find(name) == bitmapResource.end()) //avoid duplicate entry: prevent memory leak! - bitmapResource[name] = new wxBitmap(wxImage(resourceFile, wxBITMAP_TYPE_PNG)); - } + bitmaps.insert(std::make_pair(name, wxImage(resourceFile, wxBITMAP_TYPE_PNG))); } } #ifdef FFS_WIN //for compatibility it seems we need to stick with a "real" icon - *programIcon = wxIcon(wxT("A_PROGRAM_ICON")); + programIcon = wxIcon(wxT("A_PROGRAM_ICON")); #else //use big logo bitmap for better quality - programIcon->CopyFromBitmap(getImageByName(wxT("RealtimeSync.png"))); + programIcon.CopyFromBitmap(getImageInt(wxT("RealtimeSync.png"))); #endif + } -const wxBitmap& GlobalResources::getImageByName(const wxString& imageName) const +const wxBitmap& GlobalResources::getImageInt(const wxString& name) const { - const std::map<wxString, wxBitmap*>::const_iterator bmp = imageName.Find(wxChar('.')) == wxNOT_FOUND ? //assume .png ending if nothing else specified - bitmapResource.find(imageName + wxT(".png")) : - bitmapResource.find(imageName); - - if (bmp != bitmapResource.end()) - return *bmp->second; + auto iter = bitmaps.find(name.Find(L'.') == wxNOT_FOUND ? //assume .png ending if nothing else specified + name + wxT(".png") : + name); + if (iter != bitmaps.end()) + return iter->second; else + { + assert(false); return wxNullBitmap; + } } - diff --git a/RealtimeSync/resources.h b/RealtimeSync/resources.h index fec82358..4c41d47d 100644 --- a/RealtimeSync/resources.h +++ b/RealtimeSync/resources.h @@ -7,29 +7,29 @@ #ifndef RESOURCES_H_INCLUDED #define RESOURCES_H_INCLUDED -#include <wx/bitmap.h> -#include <wx/string.h> #include <map> +#include <wx/bitmap.h> +#include <wx/icon.h> class GlobalResources { public: - static const GlobalResources& getInstance(); + static const GlobalResources& instance(); - const wxBitmap& getImageByName(const wxString& imageName) const; + static const wxBitmap& getImage(const wxString& name) { return instance().getImageInt(name); } //image resource objects - wxIcon* programIcon; - - void load() const; //loads bitmap resources on program startup: logical const! + wxIcon programIcon; private: GlobalResources(); - ~GlobalResources(); + GlobalResources(const GlobalResources&); //=delete + GlobalResources& operator=(const GlobalResources&); //=delete + +const wxBitmap& getImageInt(const wxString& name) const; - //resource mapping - mutable std::map<wxString, wxBitmap*> bitmapResource; + std::map<wxString, wxBitmap> bitmaps; }; #endif // RESOURCES_H_INCLUDED diff --git a/RealtimeSync/tray_menu.cpp b/RealtimeSync/tray_menu.cpp index cbdf6070..8d43cabc 100644 --- a/RealtimeSync/tray_menu.cpp +++ b/RealtimeSync/tray_menu.cpp @@ -20,11 +20,10 @@ #include <wx/icon.h> //Linux needs this #include <wx/timer.h> #include "resources.h" -#include "../shared/string_conv.h" -#include "../shared/i18n.h" -#include "../shared/assert_static.h" -#include "../shared/build_info.h" -#include "../shared/shell_execute.h" +#include <wx+/string_conv.h> +#include <zen/assert_static.h> +#include <zen/build_info.h> +#include <wx+/shell_execute.h> using namespace rts; using namespace zen; @@ -148,9 +147,9 @@ void TrayIconHolder::showIconActive() { wxIcon realtimeIcon; #ifdef FFS_WIN - realtimeIcon.CopyFromBitmap(GlobalResources::getInstance().getImageByName(wxT("RTS_tray_win.png"))); //use a 16x16 bitmap + realtimeIcon.CopyFromBitmap(GlobalResources::getImage(wxT("RTS_tray_win.png"))); //use a 16x16 bitmap #elif defined FFS_LINUX - realtimeIcon.CopyFromBitmap(GlobalResources::getInstance().getImageByName(wxT("RTS_tray_linux.png"))); //use a 22x22 bitmap for perfect fit + realtimeIcon.CopyFromBitmap(GlobalResources::getImage(wxT("RTS_tray_linux.png"))); //use a 22x22 bitmap for perfect fit #endif const wxString postFix = jobName_.empty() ? wxString() : (wxT("\n\"") + jobName_ + wxT("\"")); trayMenu->SetIcon(realtimeIcon, _("Monitoring active...") + postFix); @@ -161,9 +160,9 @@ void TrayIconHolder::showIconWaiting() { wxIcon realtimeIcon; #ifdef FFS_WIN - realtimeIcon.CopyFromBitmap(GlobalResources::getInstance().getImageByName(wxT("RTS_tray_waiting_win.png"))); //use a 16x16 bitmap + realtimeIcon.CopyFromBitmap(GlobalResources::getImage(wxT("RTS_tray_waiting_win.png"))); //use a 16x16 bitmap #elif defined FFS_LINUX - realtimeIcon.CopyFromBitmap(GlobalResources::getInstance().getImageByName(wxT("RTS_tray_waiting_linux.png"))); //use a 22x22 bitmap for perfect fit + realtimeIcon.CopyFromBitmap(GlobalResources::getImage(wxT("RTS_tray_waiting_linux.png"))); //use a 22x22 bitmap for perfect fit #endif const wxString postFix = jobName_.empty() ? wxString() : (wxT("\n\"") + jobName_ + wxT("\"")); trayMenu->SetIcon(realtimeIcon, _("Waiting for missing directories...") + postFix); @@ -192,11 +191,11 @@ void TrayIconHolder::OnContextMenuSelection(wxCommandEvent& event) #endif //wxUSE_UNICODE //compile time info about 32/64-bit build - if (util::is64BitBuild) + if (zen::is64BitBuild) build += wxT(" x64"); else build += wxT(" x86"); - assert_static(util::is32BitBuild || util::is64BitBuild); + assert_static(zen::is32BitBuild || zen::is64BitBuild); wxString buildFormatted = _("(Build: %x)"); buildFormatted.Replace(wxT("%x"), build); @@ -312,6 +311,7 @@ rts::MonitorResponse rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig& while (true) { ::wxSetEnv(L"changed_file", utf8CvrtTo<wxString>(lastFileChanged)); //some way to output what file changed to the user + lastFileChanged.clear(); //make sure old name is not shown again after a directory reappears //execute command zen::shellExecute(config.commandline, zen::EXEC_TYPE_SYNC); diff --git a/RealtimeSync/watcher.cpp b/RealtimeSync/watcher.cpp index 37664d35..97ad480a 100644 --- a/RealtimeSync/watcher.cpp +++ b/RealtimeSync/watcher.cpp @@ -5,14 +5,14 @@ // ************************************************************************** #include "watcher.h" -#include "../shared/file_handling.h" -#include "../shared/i18n.h" -#include "../shared/stl_tools.h" +#include <zen/file_handling.h> +#include <zen/stl_tools.h> #include <set> #include <wx/timer.h> -#include "../shared/resolve_path.h" -#include "../shared/dir_watcher.h" -#include "../shared/string_conv.h" +#include "../lib/resolve_path.h" +#include <zen/dir_watcher.h> +#include <wx+/string_conv.h> +#include <zen/thread.h> //#include "../library/db_file.h" //SYNC_DB_FILE_ENDING -> complete file too much of a dependency; file ending too little to decouple into single header //#include "../library/lock_holder.h" //LOCK_FILE_ENDING #include <wx/msgdlg.h> @@ -64,12 +64,15 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNamesNonFmt, const Zstring& dirnameFmt = *iter; try { - watches.push_back(std::make_pair(dirnameFmt, std::make_shared<DirWatcher>(dirnameFmt))); //throw FileError + watches.push_back(std::make_pair(dirnameFmt, std::make_shared<DirWatcher>(dirnameFmt))); //throw FileError, ErrorNotExisting } - catch (FileError&) + catch (ErrorNotExisting&) //nice atomic behavior: *no* second directory existence check!!! { - //Note: checking for directory existence is NOT transactional!!! - if (!dirExists(dirnameFmt)) //that's no good locking behavior, but better than nothing + return CHANGE_DIR_MISSING; + } + catch (FileError&) //play safe: remedy potential FileErrors that should have been ErrorNotExisting (e.g. Linux: errors during directory traversing) + { + if (!dirExists(dirnameFmt)) //not an atomic behavior!!! return CHANGE_DIR_MISSING; throw; } @@ -102,10 +105,10 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNamesNonFmt, try { - std::vector<Zstring> changedFiles = watcher.getChanges(); //throw FileError + std::vector<Zstring> changedFiles = watcher.getChanges(); //throw FileError, ErrorNotExisting //remove to be ignored changes - vector_remove_if(changedFiles, [](const Zstring & name) + vector_remove_if(changedFiles, [](const Zstring& name) { return endsWith(name, Zstr(".ffs_lock")) || //sync.ffs_lock, sync.Del.ffs_lock endsWith(name, Zstr(".ffs_db")); //sync.ffs_db, .sync.tmp.ffs_db @@ -122,10 +125,13 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNamesNonFmt, } } - catch (FileError&) + catch (ErrorNotExisting&) //nice atomic behavior: *no* second directory existence check!!! { - //Note: checking for directory existence is NOT transactional!!! - if (!dirExists(dirname)) //catch errors related to directory removal, e.g. ERROR_NETNAME_DELETED + return CHANGE_DIR_MISSING; + } + catch (FileError&) //play safe: remedy potential FileErrors that should have been ErrorNotExisting (e.g. Linux: errors during directory traversing) + { + if (!dirExists(dirname)) //not an atomic behavior!!! return CHANGE_DIR_MISSING; throw; } @@ -149,18 +155,36 @@ void rts::waitForMissingDirs(const std::vector<Zstring>& dirNamesNonFmt, WaitCal { lastCheck = current; - if (std::find_if(dirNamesNonFmt.begin(), dirNamesNonFmt.end(), - [&](const Zstring& dirnameNonFmt) -> bool - { - //support specifying volume by name => call getFormattedDirectoryName() repeatedly - const Zstring formattedDir = zen::getFormattedDirectoryName(dirnameNonFmt); - - if (formattedDir.empty()) - throw zen::FileError(_("A directory input field is empty.")); + auto ftDirMissing = async([=]() -> bool + { + return std::find_if(dirNamesNonFmt.begin(), dirNamesNonFmt.end(), + [](const Zstring& dirnameNonFmt) -> bool + { + //support specifying volume by name => call getFormattedDirectoryName() repeatedly + const Zstring dirnameFmt = zen::getFormattedDirectoryName(dirnameNonFmt); + + if (dirnameFmt.empty()) + throw zen::FileError(_("A directory input field is empty.")); +#ifdef FFS_WIN + //1. login to network share, if necessary + loginNetworkShare(dirnameFmt, false); //login networks shares, no PW prompt -> is this really RTS's task? +#endif + //2. check dir existence + return !zen::dirExists(dirnameFmt); + }) != dirNamesNonFmt.end(); + }); + while (!ftDirMissing.timed_wait(boost::posix_time::milliseconds(rts::UI_UPDATE_INTERVAL))) + statusHandler->requestUiRefresh(); //may throw! - return !dirExists(formattedDir); - }) == dirNamesNonFmt.end()) - return; + try + { + if (!ftDirMissing.get()) //throw X + return; + } + catch (...) //boost::future seems to map async exceptions to "some" boost exception type -> migrate this for C++11 + { + throw zen::FileError(_("A directory input field is empty.")); + } } wxMilliSleep(rts::UI_UPDATE_INTERVAL); diff --git a/RealtimeSync/watcher.h b/RealtimeSync/watcher.h index dd0dd88d..9d2448de 100644 --- a/RealtimeSync/watcher.h +++ b/RealtimeSync/watcher.h @@ -7,9 +7,9 @@ #ifndef WATCHER_H_INCLUDED #define WATCHER_H_INCLUDED -#include "../shared/zstring.h" +#include <zen/zstring.h> #include <vector> -#include "../shared/file_error.h" +#include <zen/file_error.h> namespace rts diff --git a/RealtimeSync/xml_ffs.cpp b/RealtimeSync/xml_ffs.cpp index 23ee1b38..32ef3b39 100644 --- a/RealtimeSync/xml_ffs.cpp +++ b/RealtimeSync/xml_ffs.cpp @@ -5,18 +5,17 @@ // ************************************************************************** #include "xml_ffs.h" -#include "../shared/standard_paths.h" -#include "../shared/zstring.h" -#include "../shared/xml_base.h" -#include "../shared/string_conv.h" +#include "../lib/ffs_paths.h" +#include <zen/zstring.h> +#include <wx+/string_conv.h> //include FreeFileSync xml headers -#include "../library/process_xml.h" +#include "../lib/process_xml.h" using namespace zen; -xmlAccess::XmlRealConfig convertBatchToReal(const xmlAccess::XmlBatchConfig& batchCfg, const wxString& filename) +xmlAccess::XmlRealConfig convertBatchToReal(const xmlAccess::XmlBatchConfig& batchCfg, const Zstring& filename) { xmlAccess::XmlRealConfig output; @@ -64,11 +63,11 @@ void rts::readRealOrBatchConfig(const wxString& filename, xmlAccess::XmlRealConf catch (const xmlAccess::FfsXmlError& e) { if (e.getSeverity() == xmlAccess::FfsXmlError::WARNING) - config = convertBatchToReal(batchCfg, filename); //do work despite parsing errors, then re-throw + config = convertBatchToReal(batchCfg, toZ(filename)); //do work despite parsing errors, then re-throw throw; // } - config = convertBatchToReal(batchCfg, filename); + config = convertBatchToReal(batchCfg, toZ(filename)); } diff --git a/RealtimeSync/xml_proc.cpp b/RealtimeSync/xml_proc.cpp index b9839f9c..8e978aed 100644 --- a/RealtimeSync/xml_proc.cpp +++ b/RealtimeSync/xml_proc.cpp @@ -6,10 +6,8 @@ #include "xml_proc.h" #include <wx/filefn.h> -#include "../shared/i18n.h" -#include <file_handling.h> -#include <string_conv.h> -#include <xml_base.h> +#include <zen/file_handling.h> +#include <wx+/string_conv.h> using namespace zen; using namespace xmlAccess; @@ -44,19 +42,19 @@ bool isXmlTypeRTS(const XmlDoc& doc) //throw() void xmlAccess::readRealConfig(const wxString& filename, XmlRealConfig& config) { if (!fileExists(toZ(filename))) - throw FfsXmlError(wxString(_("File does not exist:")) + wxT("\n\"") + filename + wxT("\"")); + throw FfsXmlError(_("File does not exist:") + "\n\"" + filename.c_str() + "\""); XmlDoc doc; - loadXmlDocument(filename, doc); //throw (FfsXmlError) + loadXmlDocument(toZ(filename), doc); //throw (FfsXmlError) if (!isXmlTypeRTS(doc)) - throw FfsXmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"")); + throw FfsXmlError(_("Error parsing configuration file:") + "\n\"" + filename.c_str() + "\""); XmlIn in(doc); ::readConfig(in, config); if (in.errorsOccured()) - throw FfsXmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"\n\n") + + throw FfsXmlError(_("Error parsing configuration file:") + "\n\"" + filename.c_str() + "\"\n\n" + getErrorMessageFormatted(in), FfsXmlError::WARNING); } @@ -80,5 +78,5 @@ void xmlAccess::writeRealConfig(const XmlRealConfig& config, const wxString& fil XmlOut out(doc); writeConfig(config, out); - saveXmlDocument(doc, filename); //throw (FfsXmlError) + saveXmlDocument(doc, toZ(filename)); //throw (FfsXmlError) } diff --git a/RealtimeSync/xml_proc.h b/RealtimeSync/xml_proc.h index 37d2e029..2fd54c37 100644 --- a/RealtimeSync/xml_proc.h +++ b/RealtimeSync/xml_proc.h @@ -9,7 +9,7 @@ #include <vector> #include <wx/string.h> -#include <xml_error.h> +#include "../lib/xml_base.h" namespace xmlAccess |