diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:03:20 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:03:20 +0200 |
commit | 528635604eea1d8c679a3d038e2f00030ef72444 (patch) | |
tree | 9c3cbec29aa7d3e209939662e040b9342c9e7400 /library | |
parent | 3.1 (diff) | |
download | FreeFileSync-528635604eea1d8c679a3d038e2f00030ef72444.tar.gz FreeFileSync-528635604eea1d8c679a3d038e2f00030ef72444.tar.bz2 FreeFileSync-528635604eea1d8c679a3d038e2f00030ef72444.zip |
3.2
Diffstat (limited to 'library')
-rw-r--r-- | library/CustomGrid.cpp | 40 | ||||
-rw-r--r-- | library/CustomGrid.h | 4 | ||||
-rw-r--r-- | library/ShadowCopy/ShadowDll.vcproj | 219 | ||||
-rw-r--r-- | library/ShadowCopy/Shadow_2003.vcproj | 413 | ||||
-rw-r--r-- | library/ShadowCopy/Shadow_XP.vcproj | 413 | ||||
-rw-r--r-- | library/ShadowCopy/shadow.cpp | 24 | ||||
-rw-r--r-- | library/filter.cpp | 209 | ||||
-rw-r--r-- | library/filter.h | 250 | ||||
-rw-r--r-- | library/iconBuffer.cpp | 10 | ||||
-rw-r--r-- | library/iconBuffer.h | 3 | ||||
-rw-r--r-- | library/pch.h | 1 | ||||
-rw-r--r-- | library/processXml.cpp | 72 | ||||
-rw-r--r-- | library/processXml.h | 4 | ||||
-rw-r--r-- | library/resources.cpp | 19 | ||||
-rw-r--r-- | library/resources.h | 7 | ||||
-rw-r--r-- | library/statistics.cpp | 4 | ||||
-rw-r--r-- | library/statistics.h | 4 |
17 files changed, 1265 insertions, 431 deletions
diff --git a/library/CustomGrid.cpp b/library/CustomGrid.cpp index 74ceb07f..6c72859c 100644 --- a/library/CustomGrid.cpp +++ b/library/CustomGrid.cpp @@ -2,7 +2,6 @@ #include "../shared/systemConstants.h" #include "resources.h" #include <wx/dc.h> -//#include "../algorithm.h" #include "../ui/util.h" #include "../shared/stringConv.h" #include "resources.h" @@ -76,7 +75,7 @@ public: virtual int GetNumberRows() { if (gridDataView) - return std::max(gridDataView->rowsOnView(), MIN_ROW_COUNT); + return std::max(static_cast<unsigned int>(gridDataView->rowsOnView()), MIN_ROW_COUNT); else return 0; //grid is initialized with zero number of rows } @@ -242,7 +241,8 @@ public: return xmlAccess::ColumnTypes(1000); } - virtual Zstring getFileName(const unsigned int row) const = 0; + //get filename in order to retrieve the icon from it + virtual Zstring getIconFile(const unsigned int row) const = 0; protected: template <SelectedSide side> @@ -332,7 +332,7 @@ public: return CustomGridTableRim::GetValueSub<LEFT_SIDE>(row, col); } - virtual Zstring getFileName(const unsigned int row) const + virtual Zstring getIconFile(const unsigned int row) const { const FileSystemObject* fsObj = getRawData(row); if (fsObj && !fsObj->isEmpty<LEFT_SIDE>()) @@ -351,11 +351,18 @@ public: return CustomGridTableRim::GetValueSub<RIGHT_SIDE>(row, col); } - virtual Zstring getFileName(const unsigned int row) const + virtual Zstring getIconFile(const unsigned int row) const { const FileSystemObject* fsObj = getRawData(row); if (fsObj && !fsObj->isEmpty<RIGHT_SIDE>()) - return fsObj->getFullName<RIGHT_SIDE>(); + { + //Optimization: if filename exists on both sides, always use left side's file: + //Icon should be the same on both sides anyway... + if (!fsObj->isEmpty<LEFT_SIDE>()) + return fsObj->getFullName<LEFT_SIDE>(); + else + return fsObj->getFullName<RIGHT_SIDE>(); + } else return Zstring(); } @@ -511,6 +518,9 @@ void CustomGrid::initSettings(CustomGridLeft* gridLeft, GetGridWindow()->Connect(wxEVT_RIGHT_DOWN, wxEventHandler(CustomGrid::onGridAccess), NULL, this); GetGridWindow()->Connect(wxEVT_ENTER_WINDOW, wxEventHandler(CustomGrid::adjustGridHeights), NULL, this); + + //parallel grid scrolling: do NOT use DoPrepareDC() to align grids! GDI resource leak! Use regular paint event instead: + GetGridWindow()->Connect(wxEVT_PAINT, wxEventHandler(CustomGrid::OnPaintGrid), NULL, this); } @@ -530,12 +540,11 @@ void CustomGrid::RefreshCell(int row, int col) } -void CustomGrid::DoPrepareDC(wxDC& dc) +void CustomGrid::OnPaintGrid(wxEvent& event) { - wxScrollHelper::DoPrepareDC(dc); - if (isLeadGrid()) //avoid back coupling alignOtherGrids(m_gridLeft, m_gridMiddle, m_gridRight); //scroll other grids + event.Skip(); } @@ -652,7 +661,11 @@ void execGridCommands(wxEvent& event, wxGrid* grid) } } - else //button without shift is pressed + else if (keyEvent->AltDown()) + ; + else if (keyEvent->ControlDown()) + ; + else //button without additonal control keys pressed { switch (keyEvent->GetKeyCode()) { @@ -746,7 +759,7 @@ bool gridsShouldBeCleared(const wxEvent& event) const wxKeyEvent* keyEvent = dynamic_cast<const wxKeyEvent*>(&event); if (keyEvent) { - if (keyEvent->ControlDown() || keyEvent->ShiftDown()) + if (keyEvent->ControlDown() || keyEvent->AltDown() || keyEvent->ShiftDown()) return false; switch (keyEvent->GetKeyCode()) @@ -964,7 +977,7 @@ public: //try to draw icon //retrieve grid data - const Zstring fileName = m_gridDataTable->getFileName(row); + const Zstring fileName = m_gridDataTable->getIconFile(row); if (!fileName.empty()) { wxIcon icon; @@ -1347,7 +1360,7 @@ void CustomGridRim::getIconsToBeLoaded(std::vector<Zstring>& newLoad) //loads al LoadSuccess::const_iterator j = loadIconSuccess.find(currentRow); if (j != loadIconSuccess.end() && j->second == false) //find failed attempts to load icon { - const Zstring fileName = gridDataTable->getFileName(currentRow); + const Zstring fileName = gridDataTable->getIconFile(currentRow); if (!fileName.empty()) { //test if they are already loaded in buffer: @@ -1446,6 +1459,7 @@ void CustomGridLeft::alignOtherGrids(CustomGrid* gridLeft, CustomGrid* gridMiddl int x = 0; int y = 0; GetViewStart(&x, &y); + gridMiddle->Scroll(-1, y); //scroll in y-direction only gridRight->Scroll(x, y); } diff --git a/library/CustomGrid.h b/library/CustomGrid.h index d5db71a1..2b78a6c3 100644 --- a/library/CustomGrid.h +++ b/library/CustomGrid.h @@ -83,8 +83,8 @@ protected: private: virtual void setGridDataTable(const FreeFileSync::GridView* gridDataView) = 0; -//this method is called when grid view changes: useful for parallel updating of multiple grids - virtual void DoPrepareDC(wxDC& dc); + //this method is called when grid view changes: useful for parallel updating of multiple grids + void OnPaintGrid(wxEvent& event); virtual void alignOtherGrids(CustomGrid* gridLeft, CustomGrid* gridMiddle, CustomGrid* gridRight) = 0; diff --git a/library/ShadowCopy/ShadowDll.vcproj b/library/ShadowCopy/ShadowDll.vcproj deleted file mode 100644 index 637aad0c..00000000 --- a/library/ShadowCopy/ShadowDll.vcproj +++ /dev/null @@ -1,219 +0,0 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9,00" - Name="ShadowDll" - ProjectGUID="{70394AEF-5897-4911-AFA1-82EAF0581EFA}" - RootNamespace="ShadowDll" - Keyword="Win32Proj" - TargetFrameworkVersion="196613" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="obj\$(SolutionDir)$(ConfigurationName)" - IntermediateDirectory="obj\$(ConfigurationName)" - ConfigurationType="2" - CharacterSet="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - UsePrecompiledHeader="0" - WarningLevel="3" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Shadow.dll" - LinkIncremental="2" - GenerateDebugInformation="true" - SubSystem="2" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="obj\$(ConfigurationName)" - IntermediateDirectory="obj\$(ConfigurationName)" - ConfigurationType="2" - CharacterSet="1" - WholeProgramOptimization="1" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - EnableIntrinsicFunctions="true" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS" - RuntimeLibrary="2" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - WarningLevel="3" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - OutputFile="Shadow.dll" - LinkIncremental="1" - GenerateDebugInformation="true" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Quelldateien" - Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" - > - <File - RelativePath=".\dllmain.cpp" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - UsePrecompiledHeader="0" - CompileAsManaged="0" - /> - </FileConfiguration> - </File> - <File - RelativePath=".\shadow.cpp" - > - </File> - </Filter> - <Filter - Name="Headerdateien" - Filter="h;hpp;hxx;hm;inl;inc;xsd" - UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" - > - <File - RelativePath=".\shadow.h" - > - </File> - </Filter> - <File - RelativePath=".\lib\vssapi.lib" - > - </File> - </Files> - <Globals> - </Globals> -</VisualStudioProject> diff --git a/library/ShadowCopy/Shadow_2003.vcproj b/library/ShadowCopy/Shadow_2003.vcproj new file mode 100644 index 00000000..560deb8d --- /dev/null +++ b/library/ShadowCopy/Shadow_2003.vcproj @@ -0,0 +1,413 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="Server2003" + ProjectGUID="{2F2994D6-FB89-4BAA-A5DF-03BAF7337FF2}" + RootNamespace="ShadowDll" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + <Platform + Name="x64" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" + SubSystem="2" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|x64" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" + SubSystem="2" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + LinkTimeCodeGeneration="1" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|x64" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_2003" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + LinkTimeCodeGeneration="1" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Quelldateien" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\dllmain.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug|x64" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|x64" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + </File> + <File + RelativePath=".\shadow.cpp" + > + </File> + </Filter> + <Filter + Name="Headerdateien" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\shadow.h" + > + </File> + </Filter> + <File + RelativePath=".\Server 2003\lib\$(PlatformName)\vssapi.lib" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/library/ShadowCopy/Shadow_XP.vcproj b/library/ShadowCopy/Shadow_XP.vcproj new file mode 100644 index 00000000..6c1cbaaa --- /dev/null +++ b/library/ShadowCopy/Shadow_XP.vcproj @@ -0,0 +1,413 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9,00" + Name="XP" + ProjectGUID="{70394AEF-5897-4911-AFA1-82EAF0581EFA}" + RootNamespace="ShadowDll" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + <Platform + Name="x64" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" + SubSystem="2" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Debug|x64" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_DEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(IntDir)$(TargetName).pdb" + SubSystem="2" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + LinkTimeCodeGeneration="1" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|x64" + OutputDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + IntermediateDirectory="OBJ\$(ProjectName)_$(ConfigurationName)_$(PlatformName)\" + ConfigurationType="2" + CharacterSet="1" + WholeProgramOptimization="1" + BuildLogFile="$(IntDir)\Build.html" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + TargetEnvironment="3" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + PreprocessorDefinitions="NDEBUG;_WINDOWS;_USRDLL;SHADOWDLL_EXPORTS;USE_SHADOW_XP" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + SuppressStartupBanner="false" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + OutputFile="Shadow_$(ProjectName)_$(PlatformName).dll" + LinkIncremental="1" + SuppressStartupBanner="false" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + LinkTimeCodeGeneration="1" + ProfileGuidedDatabase="" + ImportLibrary="$(IntDir)$(TargetName).lib" + TargetMachine="17" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Quelldateien" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\dllmain.cpp" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Debug|x64" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|x64" + > + <Tool + Name="VCCLCompilerTool" + UsePrecompiledHeader="0" + CompileAsManaged="0" + /> + </FileConfiguration> + </File> + <File + RelativePath=".\shadow.cpp" + > + </File> + </Filter> + <Filter + Name="Headerdateien" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\shadow.h" + > + </File> + </Filter> + <File + RelativePath=".\XP\lib\$(PlatformName)\vssapi.lib" + > + </File> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/library/ShadowCopy/shadow.cpp b/library/ShadowCopy/shadow.cpp index edc62e8b..cbc4b085 100644 --- a/library/ShadowCopy/shadow.cpp +++ b/library/ShadowCopy/shadow.cpp @@ -2,9 +2,20 @@ #define WIN32_LEAN_AND_MEAN #include "windows.h" -#include "inc/vss.h" -#include "inc/vswriter.h" -#include "inc/vsbackup.h" + +#ifdef USE_SHADOW_XP +#include "xp/inc/vss.h" +#include "xp/inc/vswriter.h" +#include "xp/inc/vsbackup.h" + +#elif defined USE_SHADOW_2003 +#include "Server 2003/inc/vss.h" +#include "Server 2003/inc/vswriter.h" +#include "Server 2003/inc/vsbackup.h" +#else +adapt! +#endif + #include <algorithm> #include <string> #include <cstdio> @@ -15,7 +26,7 @@ void writeString(const wchar_t* input, wchar_t* output, unsigned int outputBufferLen) { - const unsigned int newSize = min(wcslen(input) + 1, outputBufferLen); //including null-termination + const size_t newSize = min(wcslen(input) + 1, outputBufferLen); //including null-termination memcpy(output, input, newSize * sizeof(wchar_t)); } @@ -73,10 +84,9 @@ bool shadow::createShadowCopy(const wchar_t* volumeName, IVssAsync* pWriteMetaData = NULL; if (FAILED(hr = pBackupComponents->GatherWriterMetadata( &pWriteMetaData ))) - { + { //this can happen if XP-version of VSS is used on Windows Vista (which needs at least VSS-Server2003 build) releaseShadowCopy(pBackupComponents); - writeErrorMsg(L"\"Shadow.dll\" might be incompatible with this Operating System!\n\ - Error calling \"GatherWriterMetadata\".", hr, errorMessage, errorBufferLen); + writeErrorMsg(L"Error calling \"GatherWriterMetadata\".", hr, errorMessage, errorBufferLen); return false; } diff --git a/library/filter.cpp b/library/filter.cpp index c2d972d4..6565da2e 100644 --- a/library/filter.cpp +++ b/library/filter.cpp @@ -2,14 +2,69 @@ #include "../shared/zstring.h" #include <wx/string.h> #include <set> +#include <stdexcept> #include <vector> #include "../shared/systemConstants.h" #include "../structures.h" #include <boost/bind.hpp> +#include "../shared/loki/LokiTypeInfo.h" +#include "../shared/serialize.h" using FreeFileSync::FilterProcess; +using FreeFileSync::NameFilter; +//-------------------------------------------------------------------------------------------------- +bool FilterProcess::operator==(const FilterProcess& other) const +{ + return !(*this < other) && !(other < *this); +} + + +bool FilterProcess::operator!=(const FilterProcess& other) const +{ + return !(*this == other); +} + + +bool FilterProcess::operator<(const FilterProcess& other) const +{ + if (Loki::TypeInfo(typeid(*this)) != typeid(other)) + return Loki::TypeInfo(typeid(*this)) < typeid(other); + + //this and other are same type: + return cmpLessSameType(other); +} + + +void FilterProcess::saveFilter(wxOutputStream& stream) const //serialize derived object +{ + //save type information + Utility::writeString(stream, uniqueClassIdentifier()); + + //save actual object + save(stream); +} + + +FilterProcess::FilterRef FilterProcess::loadFilter(wxInputStream& stream) +{ + //read type information + const Zstring uniqueClassId = Utility::readString(stream); + + //read actual object + if (uniqueClassId == DefaultStr("NullFilter")) + return NullFilter::load(stream); + else if (uniqueClassId == DefaultStr("NameFilter")) + return NameFilter::load(stream); + else if (uniqueClassId == DefaultStr("CombinedFilter")) + return CombinedFilter::load(stream); + else + throw std::logic_error("Programming Error: Unknown filter!"); +} + + +//-------------------------------------------------------------------------------------------------- inline void addFilterEntry(const Zstring& filtername, std::set<Zstring>& fileFilter, std::set<Zstring>& directoryFilter) { @@ -149,10 +204,11 @@ std::vector<Zstring> compoundStringToFilter(const Zstring& filterString) return output; } -//############################################################## - -FilterProcess::FilterProcess(const Zstring& includeFilter, const Zstring& excludeFilter) +//################################################################################################# +NameFilter::NameFilter(const Zstring& includeFilter, const Zstring& excludeFilter) : + includeFilterTmp(includeFilter), //save constructor arguments for serialization + excludeFilterTmp(excludeFilter) { //no need for regular expressions! In tests wxRegex was by factor of 10 slower than wxString::Matches()!! @@ -167,15 +223,17 @@ FilterProcess::FilterProcess(const Zstring& includeFilter, const Zstring& exclud } -bool FilterProcess::passFileFilter(const DefaultChar* relFilename) const +bool NameFilter::passFileFilter(const DefaultChar* relFilename) const { return matchesFilter(relFilename, filterFileIn) && //process include filters !matchesFilter(relFilename, filterFileEx); //process exclude filters } -bool FilterProcess::passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const +bool NameFilter::passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const { + assert(subObjMightMatch == NULL || *subObjMightMatch == true); //check correct usage + if (matchesFilter(relDirname, filterFolderEx)) //process exclude filters { if (subObjMightMatch) @@ -196,147 +254,56 @@ bool FilterProcess::passDirFilter(const DefaultChar* relDirname, bool* subObjMig return false; } - assert(subObjMightMatch == NULL || *subObjMightMatch == true); return true; } -template <bool include> -class InOrExcludeAllRows +bool NameFilter::isNull() const { -public: - void operator()(FreeFileSync::BaseDirMapping& baseDirectory) const //be careful with operator() to no get called by std::for_each! - { - execute(baseDirectory); - } - - void execute(FreeFileSync::HierarchyObject& hierObj) const //don't create ambiguity by replacing with operator() - { - std::for_each(hierObj.subFiles.begin(), hierObj.subFiles.end(), *this); //files - std::for_each(hierObj.subDirs.begin(), hierObj.subDirs.end(), *this); //directories - } - -private: - template<typename Iterator, typename Function> - friend Function std::for_each(Iterator, Iterator, Function); - - void operator()(FreeFileSync::FileMapping& fileObj) const - { - fileObj.setActive(include); - } - - void operator()(FreeFileSync::DirMapping& dirObj) const - { - dirObj.setActive(include); - execute(dirObj); //recursion - } -}; - - -class FilterData -{ -public: - FilterData(const FilterProcess& filterProcIn) : filterProc(filterProcIn) {} - - void execute(FreeFileSync::HierarchyObject& hierObj) - { - //files - std::for_each(hierObj.subFiles.begin(), hierObj.subFiles.end(), *this); - - //directories - std::for_each(hierObj.subDirs.begin(), hierObj.subDirs.end(), *this); - }; - -private: - template<typename Iterator, typename Function> - friend Function std::for_each(Iterator, Iterator, Function); - - - void operator()(FreeFileSync::FileMapping& fileObj) - { - fileObj.setActive(filterProc.passFileFilter(fileObj.getObjRelativeName())); - } - - void operator()(FreeFileSync::DirMapping& dirObj) - { - bool subObjMightMatch = true; - dirObj.setActive(filterProc.passDirFilter(dirObj.getObjRelativeName(), &subObjMightMatch)); - - if (subObjMightMatch) //use same logic as within directory traversing here: evaluate filter in subdirs only if objects could match - execute(dirObj); //recursion - else - InOrExcludeAllRows<false>().execute(dirObj); //exclude all files dirs in subfolders - } - - const FilterProcess& filterProc; -}; - - -void FilterProcess::filterAll(FreeFileSync::HierarchyObject& baseDirectory) const -{ - FilterData(*this).execute(baseDirectory); + static NameFilter output(DefaultStr("*"), Zstring()); + return *this == output; } -void FilterProcess::setActiveStatus(bool newStatus, FreeFileSync::FolderComparison& folderCmp) +bool NameFilter::cmpLessSameType(const FilterProcess& other) const { - if (newStatus) - std::for_each(folderCmp.begin(), folderCmp.end(), InOrExcludeAllRows<true>()); //include all rows - else - std::for_each(folderCmp.begin(), folderCmp.end(), InOrExcludeAllRows<false>()); //exclude all rows -} + //typeid(*this) == typeid(other) in this context! + assert(typeid(*this) == typeid(other)); + const NameFilter& otherNameFilt = static_cast<const NameFilter&>(other); + if (filterFileIn != otherNameFilt.filterFileIn) + return filterFileIn < otherNameFilt.filterFileIn; -void FilterProcess::setActiveStatus(bool newStatus, FreeFileSync::FileSystemObject& fsObj) -{ - fsObj.setActive(newStatus); + if (filterFolderIn != otherNameFilt.filterFolderIn) + return filterFolderIn < otherNameFilt.filterFolderIn; - DirMapping* dirObj = dynamic_cast<DirMapping*>(&fsObj); - if (dirObj) //process subdirectories also! - { - if (newStatus) - InOrExcludeAllRows<true>().execute(*dirObj); - else - InOrExcludeAllRows<false>().execute(*dirObj); - } -} + if (filterFileEx != otherNameFilt.filterFileEx) + return filterFileEx < otherNameFilt.filterFileEx; + if (filterFolderEx != otherNameFilt.filterFolderEx) + return filterFolderEx < otherNameFilt.filterFolderEx; -const FilterProcess& FilterProcess::nullFilter() //filter equivalent to include '*', exclude '' -{ - static FilterProcess output(DefaultStr("*"), Zstring()); - return output; + return false; //vectors equal } -bool FilterProcess::operator==(const FilterProcess& other) const +Zstring NameFilter::uniqueClassIdentifier() const { - return filterFileIn == other.filterFileIn && - filterFolderIn == other.filterFolderIn && - filterFileEx == other.filterFileEx && - filterFolderEx == other.filterFolderEx; + return DefaultStr("NameFilter"); } -bool FilterProcess::operator!=(const FilterProcess& other) const +void NameFilter::save(wxOutputStream& stream) const { - return !(*this == other); + Utility::writeString(stream, includeFilterTmp); + Utility::writeString(stream, excludeFilterTmp); } -bool FilterProcess::operator<(const FilterProcess& other) const +FilterProcess::FilterRef NameFilter::load(wxInputStream& stream) //"constructor" { - if (filterFileIn != other.filterFileIn) - return filterFileIn < other.filterFileIn; - - if (filterFolderIn != other.filterFolderIn) - return filterFolderIn < other.filterFolderIn; - - if (filterFileEx != other.filterFileEx) - return filterFileEx < other.filterFileEx; + const Zstring include = Utility::readString(stream); + const Zstring exclude = Utility::readString(stream); - if (filterFolderEx != other.filterFolderEx) - return filterFolderEx < other.filterFolderEx; - - return false; //vectors equal + return FilterRef(new NameFilter(include, exclude)); } diff --git a/library/filter.h b/library/filter.h index 45aff69b..efdb01fd 100644 --- a/library/filter.h +++ b/library/filter.h @@ -3,36 +3,264 @@ #include "../shared/zstring.h" #include <set> -#include "../fileHierarchy.h" - +#include <boost/shared_ptr.hpp> +#include <wx/stream.h> namespace FreeFileSync { -class FilterProcess //relative filtering +//------------------------------------------------------------------ +/* class hierarchy: + + FilterProcess (interface) + /|\ + _________|_____________ + | | | +NullFilter NameFilter CombinedFilter +*/ + +class FilterProcess //interface for filtering { public: - FilterProcess(const Zstring& includeFilter, const Zstring& excludeFilter); + virtual ~FilterProcess() {} - bool passFileFilter(const DefaultChar* relFilename) const; - bool passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const; //subObjMightMatch: file/dir in subdirectories could(!) match + //filtering + virtual bool passFileFilter(const DefaultChar* relFilename) const = 0; + virtual bool passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const = 0; + //subObjMightMatch: file/dir in subdirectories could(!) match //note: variable is only set if passDirFilter returns false! - void filterAll(HierarchyObject& baseDirectory) const; //filter complete data: files and dirs - static void setActiveStatus(bool newStatus, FolderComparison& folderCmp); //activate or deactivate all rows - static void setActiveStatus(bool newStatus, FileSystemObject& fsObj); //activate or deactivate row: works recursively! + virtual bool isNull() const = 0; //filter is equivalent to NullFilter, but may be technically slower - static const FilterProcess& nullFilter(); //filter equivalent to include '*', exclude '' + //comparison + bool operator<(const FilterProcess& other) const; bool operator==(const FilterProcess& other) const; bool operator!=(const FilterProcess& other) const; - bool operator<(const FilterProcess& other) const; + + typedef boost::shared_ptr<const FilterProcess> FilterRef; //always bound by design! + + //serialization + void saveFilter(wxOutputStream& stream) const; //serialize derived object + static FilterRef loadFilter(wxInputStream& stream); //CAVEAT!!! adapt this method for each new derivation!!! + +private: + virtual Zstring uniqueClassIdentifier() const = 0; //get identifier, used for serialization + virtual void save(wxOutputStream& stream) const = 0; //serialization + virtual bool cmpLessSameType(const FilterProcess& other) const = 0; //typeid(*this) == typeid(other) in this context! +}; + + +class NullFilter : public FilterProcess //no filtering at all +{ +public: + static FilterRef load(wxInputStream& stream); //"serial constructor" + virtual bool passFileFilter(const DefaultChar* relFilename) const; + virtual bool passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const; + virtual bool isNull() const; + +private: + virtual Zstring uniqueClassIdentifier() const; + virtual void save(wxOutputStream& stream) const {} + virtual bool cmpLessSameType(const FilterProcess& other) const; +}; + + +class NameFilter : public FilterProcess //standard filter by filename +{ +public: + NameFilter(const Zstring& includeFilter, const Zstring& excludeFilter); + static FilterRef load(wxInputStream& stream); //"serial constructor" + + virtual bool passFileFilter(const DefaultChar* relFilename) const; + virtual bool passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const; + virtual bool isNull() const; private: + virtual Zstring uniqueClassIdentifier() const; + virtual void save(wxOutputStream& stream) const; + virtual bool cmpLessSameType(const FilterProcess& other) const; + std::set<Zstring> filterFileIn; std::set<Zstring> filterFolderIn; std::set<Zstring> filterFileEx; std::set<Zstring> filterFolderEx; + + const Zstring includeFilterTmp; //save constructor arguments for serialization + const Zstring excludeFilterTmp; // +}; + + +class CombinedFilter : public FilterProcess //combine two filters to match if and only if both match +{ +public: + CombinedFilter(const FilterRef& first, const FilterRef& second) : first_(first), second_(second) {} + static FilterRef load(wxInputStream& stream); //"serial constructor" + + virtual bool passFileFilter(const DefaultChar* relFilename) const; + virtual bool passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const; + virtual bool isNull() const; + +private: + virtual Zstring uniqueClassIdentifier() const; + virtual void save(wxOutputStream& stream) const; + virtual bool cmpLessSameType(const FilterProcess& other) const; + + const FilterRef first_; + const FilterRef second_; }; + + +//small helper method: remove Null-filters +FilterProcess::FilterRef combineFilters(const FilterProcess::FilterRef& first, + const FilterProcess::FilterRef& second); + + + + + + + + + + + + + + + + + + +//---------------Inline Implementation--------------------------------------------------- +inline +FilterProcess::FilterRef NullFilter::load(wxInputStream& stream) //"serial constructor" +{ + return FilterRef(new NullFilter); +} + + +inline +bool NullFilter::passFileFilter(const DefaultChar* relFilename) const +{ + return true; +} + + +inline +bool NullFilter::passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const +{ + assert(subObjMightMatch == NULL || *subObjMightMatch == true); //check correct usage + return true; +} + + +inline +bool NullFilter::isNull() const +{ + return true; +} + + +inline +bool NullFilter::cmpLessSameType(const FilterProcess& other) const +{ + //typeid(*this) == typeid(other) in this context! + assert(typeid(*this) == typeid(other)); + return false; +} + + +inline +Zstring NullFilter::uniqueClassIdentifier() const +{ + return DefaultStr("NullFilter"); +} + + +inline +bool CombinedFilter::passFileFilter(const DefaultChar* relFilename) const +{ + return first_->passFileFilter(relFilename) && //short-circuit behavior + second_->passFileFilter(relFilename); +} + + +inline +bool CombinedFilter::passDirFilter(const DefaultChar* relDirname, bool* subObjMightMatch) const +{ + return first_->passDirFilter(relDirname, subObjMightMatch) && //short-circuit behavior: subObjMightMatch handled correctly! + second_->passDirFilter(relDirname, subObjMightMatch); +} + + +inline +bool CombinedFilter::isNull() const +{ + return first_->isNull() && second_->isNull(); +} + + +inline +bool CombinedFilter::cmpLessSameType(const FilterProcess& other) const +{ + //typeid(*this) == typeid(other) in this context! + assert(typeid(*this) == typeid(other)); + const CombinedFilter& otherCombFilt = static_cast<const CombinedFilter&>(other); + + if (*first_ != *otherCombFilt.first_) + return *first_ < *otherCombFilt.first_; + + return *second_ < *otherCombFilt.second_; +} + + +inline +Zstring CombinedFilter::uniqueClassIdentifier() const +{ + return DefaultStr("CombinedFilter"); +} + + +inline +void CombinedFilter::save(wxOutputStream& stream) const +{ + first_->saveFilter(stream); + second_->saveFilter(stream); +} + + +inline +FilterProcess::FilterRef CombinedFilter::load(wxInputStream& stream) //"constructor" +{ + FilterRef first = loadFilter(stream); + FilterRef second = loadFilter(stream); + + return combineFilters(first, second); +} + + +inline +FilterProcess::FilterRef combineFilters(const FilterProcess::FilterRef& first, + const FilterProcess::FilterRef& second) +{ + if (first->isNull()) + { + if (second->isNull()) + return FilterProcess::FilterRef(new NullFilter); + else + return second; + } + else + { + if (second->isNull()) + return first; + else + return FilterProcess::FilterRef(new CombinedFilter(first, second)); + } +} + + } #endif // FFS_FILTER_H_INCLUDED + diff --git a/library/iconBuffer.cpp b/library/iconBuffer.cpp index 2f1e2915..d386c85a 100644 --- a/library/iconBuffer.cpp +++ b/library/iconBuffer.cpp @@ -143,14 +143,14 @@ void WorkerThread::doWork() break; //icon already in buffer: enter waiting state //despite what docu says about SHGetFileInfo() it can't handle all relative filenames, e.g. "\DirName" - const unsigned int BUFFER_SIZE = 10000; - DefaultChar fullName[BUFFER_SIZE]; + const unsigned int MAX_SIZE = 10000; + DefaultChar fullName[MAX_SIZE]; const DWORD rv = ::GetFullPathName( &fileName[0], //__in LPCTSTR lpFileName, - BUFFER_SIZE, //__in DWORD nBufferLength, + MAX_SIZE, //__in DWORD nBufferLength, fullName, //__out LPTSTR lpBuffer, NULL); //__out LPTSTR *lpFilePart - if (rv < BUFFER_SIZE && rv != 0) + if (rv < MAX_SIZE && rv != 0) { //load icon SHFILEINFO fileInfo; @@ -251,7 +251,7 @@ void IconBuffer::insertIntoBuffer(const DefaultChar* fileName, const wxIcon& ico assert(buffer->size() == bufSequence->size()); //remove elements if buffer becomes too big: - if (buffer->size() > 1000) //limit buffer size: critical because large buffers seem to cause various wxIcon/wxBitmap issues! + if (buffer->size() > BUFFER_SIZE) //limit buffer size: critical because GDI resources are limited (e.g. 10000 on XP per process) { //remove oldest element buffer->erase(bufSequence->front()); diff --git a/library/iconBuffer.h b/library/iconBuffer.h index 0604060e..e6d2bcaf 100644 --- a/library/iconBuffer.h +++ b/library/iconBuffer.h @@ -28,7 +28,8 @@ public: bool requestIcon(const Zstring& fileName, wxIcon* icon = NULL); //returns false if icon is not in buffer void setWorkload(const std::vector<Zstring>& load); //(re-)set new workload of icons to be retrieved; - static const int ICON_SIZE = 16; //size in pixel + static const int ICON_SIZE = 16; //size in pixel + static const size_t BUFFER_SIZE = 800; //maximum number if icons to buffer private: IconBuffer(); diff --git a/library/pch.h b/library/pch.h index 966bc103..af086418 100644 --- a/library/pch.h +++ b/library/pch.h @@ -85,6 +85,7 @@ do NOT use in release build! #include <wx/zipstrm.h> #include <wx/scrolwin.h> #include <wx/notebook.h> +#include <wx/help.h> //other #include "../shared/tinyxml/tinyxml.h" diff --git a/library/processXml.cpp b/library/processXml.cpp index b248cf62..af16f91e 100644 --- a/library/processXml.cpp +++ b/library/processXml.cpp @@ -29,7 +29,7 @@ public: private: //read alternate configuration (optional) => might point to NULL - void readXmlAlternateConfig(const TiXmlElement& folderPair, FolderPairEnh& enhPair); + void readXmlLocalConfig(const TiXmlElement& folderPair, FolderPairEnh& enhPair); //read basic FreefileSync settings (used by commandline and GUI), return true if ALL values have been retrieved successfully void readXmlMainConfig(MainConfiguration& mainCfg); @@ -43,7 +43,7 @@ bool writeXmlBatchConfig(const xmlAccess::XmlBatchConfig& outputCfg, TiXmlDocume //write global settings bool writeXmlGlobalSettings(const xmlAccess::XmlGlobalSettings& outputCfg, TiXmlDocument& doc); //write alternate configuration (optional) => might point to NULL -void writeXmlAlternateConfig(const FolderPairEnh& enhPair, TiXmlElement& parent); +void writeXmlLocalConfig(const FolderPairEnh& enhPair, TiXmlElement& parent); //write basic FreefileSync settings (used by commandline and GUI), return true if everything was written successfully bool writeXmlMainConfig(const MainConfiguration& mainCfg, TiXmlDocument& doc); @@ -247,7 +247,7 @@ bool readXmlAttribute(const std::string& name, const TiXmlElement* node, xmlAcce //################################################################################################################ -void FfsXmlParser::readXmlAlternateConfig(const TiXmlElement& folderPair, FolderPairEnh& enhPair) +void FfsXmlParser::readXmlLocalConfig(const TiXmlElement& folderPair, FolderPairEnh& enhPair) { //read folder pairs readXmlElementLogging("Left", &folderPair, enhPair.leftDirectory); @@ -281,15 +281,12 @@ void FfsXmlParser::readXmlAlternateConfig(const TiXmlElement& folderPair, Folder //########################################################### //alternate filter configuration - const TiXmlElement* filterCfg = TiXmlHandleConst(&folderPair).FirstChild("AlternateFilter").ToElement(); + const TiXmlElement* filterCfg = TiXmlHandleConst(&folderPair).FirstChild("LocalFilter").ToElement(); if (filterCfg) { - AlternateFilter* altFilterCfg = new AlternateFilter; - enhPair.altFilter.reset(altFilterCfg); - //read filter settings - readXmlElementLogging("Include", filterCfg, altFilterCfg->includeFilter); - readXmlElementLogging("Exclude", filterCfg, altFilterCfg->excludeFilter); + readXmlElementLogging("Include", filterCfg, enhPair.localFilter.includeFilter); + readXmlElementLogging("Exclude", filterCfg, enhPair.localFilter.excludeFilter); } } @@ -349,24 +346,21 @@ void FfsXmlParser::readXmlMainConfig(MainConfiguration& mainCfg) //########################################################### const TiXmlElement* pairs = hRoot.FirstChild("MainConfig").FirstChild("FolderPairs").FirstChild("Pair").ToElement(); - //read main folder pair - if (pairs) - { - readXmlElementLogging("Left", pairs, mainCfg.mainFolderPair.leftDirectory); - readXmlElementLogging("Right", pairs, mainCfg.mainFolderPair.rightDirectory); - pairs = pairs->NextSiblingElement(); - } - else - logError("Pair"); - - - //read additional folder pairs + //read all folder pairs mainCfg.additionalPairs.clear(); + bool firstLoop = true; while (pairs) { FolderPairEnh newPair; - readXmlAlternateConfig(*pairs, newPair); - mainCfg.additionalPairs.push_back(newPair); + readXmlLocalConfig(*pairs, newPair); + + if (firstLoop) //read first folder pair + { + firstLoop = false; + mainCfg.firstPair = newPair; + } + else //read additional folder pairs + mainCfg.additionalPairs.push_back(newPair); pairs = pairs->NextSiblingElement(); } @@ -416,6 +410,9 @@ void FfsXmlParser::readXmlGlobalSettings(xmlAccess::XmlGlobalSettings& outputCfg //ignore +/- 1 hour due to DST change readXmlElementLogging("IgnoreOneHourDifference", global, outputCfg.ignoreOneHourDiff); + //copy locked files using VSS + readXmlElementLogging("CopyLockedFiles", global, outputCfg.copyLockedFiles); + //last update check readXmlElementLogging("LastCheckForUpdates", global, outputCfg.lastUpdateCheck); @@ -617,7 +614,7 @@ void addXmlAttribute(const std::string& name, const xmlAccess::ColumnTypes value } -void writeXmlAlternateConfig(const FolderPairEnh& enhPair, TiXmlElement& parent) +void writeXmlLocalConfig(const FolderPairEnh& enhPair, TiXmlElement& parent) { //write folder pairs TiXmlElement* newfolderPair = new TiXmlElement("Pair"); @@ -661,16 +658,12 @@ void writeXmlAlternateConfig(const FolderPairEnh& enhPair, TiXmlElement& parent) //########################################################### //alternate filter configuration - const AlternateFilter* altFilter = enhPair.altFilter.get(); - if (altFilter) - { - TiXmlElement* filterCfg = new TiXmlElement("AlternateFilter"); - newfolderPair->LinkEndChild(filterCfg); + TiXmlElement* filterCfg = new TiXmlElement("LocalFilter"); + newfolderPair->LinkEndChild(filterCfg); - //write filter settings - addXmlElement("Include", altFilter->includeFilter, filterCfg); - addXmlElement("Exclude", altFilter->excludeFilter, filterCfg); - } + //write filter settings + addXmlElement("Include", enhPair.localFilter.includeFilter, filterCfg); + addXmlElement("Exclude", enhPair.localFilter.excludeFilter, filterCfg); } @@ -744,16 +737,12 @@ bool writeXmlMainConfig(const MainConfiguration& mainCfg, TiXmlDocument& doc) TiXmlElement* pairs = new TiXmlElement("FolderPairs"); settings->LinkEndChild(pairs); - //write main folder pair - TiXmlElement* mainPair = new TiXmlElement("Pair"); - pairs->LinkEndChild(mainPair); - - addXmlElement("Left", mainCfgLocal.mainFolderPair.leftDirectory, mainPair); - addXmlElement("Right", mainCfgLocal.mainFolderPair.rightDirectory, mainPair); + //write first folder pair + writeXmlLocalConfig(mainCfgLocal.firstPair, *pairs); //write additional folder pairs for (std::vector<FolderPairEnh>::const_iterator i = mainCfgLocal.additionalPairs.begin(); i != mainCfgLocal.additionalPairs.end(); ++i) - writeXmlAlternateConfig(*i, *pairs); + writeXmlLocalConfig(*i, *pairs); return true; } @@ -819,6 +808,9 @@ bool writeXmlGlobalSettings(const xmlAccess::XmlGlobalSettings& inputCfg, TiXmlD //ignore +/- 1 hour due to DST change addXmlElement("IgnoreOneHourDifference", inputCfg.ignoreOneHourDiff, global); + //copy locked files using VSS + addXmlElement("CopyLockedFiles", inputCfg.copyLockedFiles, global); + //last update check addXmlElement("LastCheckForUpdates", inputCfg.lastUpdateCheck, global); diff --git a/library/processXml.h b/library/processXml.h index aafd3131..80db71a3 100644 --- a/library/processXml.h +++ b/library/processXml.h @@ -108,10 +108,12 @@ struct XmlGlobalSettings XmlGlobalSettings() : programLanguage(retrieveSystemLanguage()), ignoreOneHourDiff(false), + copyLockedFiles(true), lastUpdateCheck(0) {} int programLanguage; bool ignoreOneHourDiff; //ignore +/- 1 hour due to DST change + bool copyLockedFiles; //VSS usage long lastUpdateCheck; //time of last update check OptionalDialogs optDialogs; @@ -137,7 +139,7 @@ struct XmlGlobalSettings showFileIconsRight(true) { #ifdef FFS_WIN - externelApplications.push_back(std::make_pair(_("Open with Explorer"), wxT("explorer /select, %name"))); + externelApplications.push_back(std::make_pair(_("Open with Explorer"), wxT("explorer /select, \"%name\""))); externelApplications.push_back(std::make_pair(_("Open directly"), wxT("cmd /c start \"\" \"%name\""))); #elif defined FFS_LINUX externelApplications.push_back(std::make_pair(_("Open with Konqueror"), wxT("konqueror \"%dir\""))); diff --git a/library/resources.cpp b/library/resources.cpp index a42f2788..02f5d701 100644 --- a/library/resources.cpp +++ b/library/resources.cpp @@ -22,6 +22,8 @@ const GlobalResources& GlobalResources::getInstance() GlobalResources::GlobalResources() { //map, allocate and initialize pictures + bitmapResource[wxT("CmpByTime.png")] = (bitmapCmpByTime = new wxBitmap(wxNullBitmap)); + bitmapResource[wxT("CmpByContent.png")] = (bitmapCmpByContent = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("left arrow.png")] = (bitmapArrowLeft = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("right arrow.png")] = (bitmapArrowRight = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("left arrow create.png")] = (bitmapArrowLeftCr = new wxBitmap(wxNullBitmap)); @@ -41,7 +43,7 @@ GlobalResources::GlobalResources() bitmapResource[wxT("sync.png")] = (bitmapSync = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("sync disabled.png")] = (bitmapSyncDisabled = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("swap.png")] = (bitmapSwap = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("swapSmall.png")] = (bitmapSwapSmall = new wxBitmap(wxNullBitmap)); + bitmapResource[wxT("swap_slim.png")] = (bitmapSwapSlim = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("help.png")] = (bitmapHelp = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("leftOnly.png")] = (bitmapLeftOnly = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("leftOnlyAct.png")] = (bitmapLeftOnlyAct = new wxBitmap(wxNullBitmap)); @@ -81,8 +83,7 @@ GlobalResources::GlobalResources() bitmapResource[wxT("saveSmall.png")] = (bitmapSaveSmall = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("loadSmall.png")] = (bitmapLoadSmall = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("newSmall.png")] = (bitmapNewSmall = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("FFS.png")] = (bitmapFFS = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("FFS paused.png")] = (bitmapFFSPaused = new wxBitmap(wxNullBitmap)); + bitmapResource[wxT("FreeFileSync.png")] = (bitmapFFS = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("deleteFile.png")] = (bitmapDeleteFile = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("gpl.png")] = (bitmapGPL = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("statusPause.png")] = (bitmapStatusPause = new wxBitmap(wxNullBitmap)); @@ -103,7 +104,6 @@ GlobalResources::GlobalResources() bitmapResource[wxT("sync_small.png")] = (bitmapSyncSmall = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("clock_small.png")] = (bitmapClockSmall = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("clock.png")] = (bitmapClock = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("filter.png")] = (bitmapFilter = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("batch.png")] = (bitmapBatch = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("batch_small.png")] = (bitmapBatchSmall = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("move up.png")] = (bitmapMoveUp = new wxBitmap(wxNullBitmap)); @@ -128,6 +128,7 @@ GlobalResources::GlobalResources() bitmapResource[wxT("holland.png")] = (bitmapHolland = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("england.png")] = (bitmapEngland = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("france.png")] = (bitmapFrance = new wxBitmap(wxNullBitmap)); + bitmapResource[wxT("finland.png")] = (bitmapFinland = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("germany.png")] = (bitmapGermany = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("hungary.png")] = (bitmapHungary = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("romania.png")] = (bitmapRomania = new wxBitmap(wxNullBitmap)); @@ -218,7 +219,7 @@ void loadAnimFromZip(wxZipInputStream& zipInput, wxAnimation* animation) void GlobalResources::load() const { - wxFFileInputStream input(FreeFileSync::getInstallationDir() + zToWx(globalFunctions::FILE_NAME_SEPARATOR) + wxT("Resources.dat")); + wxFFileInputStream input(FreeFileSync::getInstallationDir() + wxT("Resources.dat")); if (input.IsOk()) //if not... we don't want to react too harsh here { //activate support for .png files @@ -246,10 +247,14 @@ void GlobalResources::load() const } #ifdef FFS_WIN + //for compatibility it seems we need to stick with a "real" icon *programIcon = wxIcon(wxT("A_PROGRAM_ICON")); #else -#include "FreeFileSync.xpm" - *programIcon = wxIcon(FreeFileSync_xpm); + //#include "FreeFileSync.xpm" + //*programIcon = wxIcon(FreeFileSync_xpm); + + //use big FFS logo bitmap for better quality + programIcon->CopyFromBitmap(*bitmapFFS); #endif } diff --git a/library/resources.h b/library/resources.h index 432498a3..512d7ed9 100644 --- a/library/resources.h +++ b/library/resources.h @@ -15,6 +15,8 @@ public: const wxBitmap& getImageByName(const wxString& imageName) const; //image resource objects + wxBitmap* bitmapCmpByTime; + wxBitmap* bitmapCmpByContent; wxBitmap* bitmapArrowLeft; wxBitmap* bitmapArrowRight; wxBitmap* bitmapArrowLeftCr; @@ -34,7 +36,7 @@ public: wxBitmap* bitmapSync; wxBitmap* bitmapSyncDisabled; wxBitmap* bitmapSwap; - wxBitmap* bitmapSwapSmall; + wxBitmap* bitmapSwapSlim; wxBitmap* bitmapHelp; wxBitmap* bitmapLeftOnly; wxBitmap* bitmapLeftOnlyAct; @@ -75,7 +77,6 @@ public: wxBitmap* bitmapLoadSmall; wxBitmap* bitmapNewSmall; wxBitmap* bitmapFFS; - wxBitmap* bitmapFFSPaused; wxBitmap* bitmapDeleteFile; wxBitmap* bitmapGPL; wxBitmap* bitmapStatusPause; @@ -96,7 +97,6 @@ public: wxBitmap* bitmapSyncSmall; wxBitmap* bitmapClockSmall; wxBitmap* bitmapClock; - wxBitmap* bitmapFilter; wxBitmap* bitmapBatch; wxBitmap* bitmapBatchSmall; wxBitmap* bitmapMoveUp; @@ -121,6 +121,7 @@ public: wxBitmap* bitmapHolland; wxBitmap* bitmapEngland; wxBitmap* bitmapFrance; + wxBitmap* bitmapFinland; wxBitmap* bitmapGermany; wxBitmap* bitmapHungary; wxBitmap* bitmapRomania; diff --git a/library/statistics.cpp b/library/statistics.cpp index fb7f5ba4..53a75fce 100644 --- a/library/statistics.cpp +++ b/library/statistics.cpp @@ -113,6 +113,10 @@ Statistics::Statistics(const int totalObjectCount, remainingTimeLast(256*256*256*100), //something "big" timer(new wxStopWatch) {} + Statistics::~Statistics() + { + delete timer; + } void Statistics::addMeasurement(const int objectsCurrent, const double dataCurrent) { diff --git a/library/statistics.h b/library/statistics.h index fe247b47..d1b8b98b 100644 --- a/library/statistics.h +++ b/library/statistics.h @@ -39,6 +39,8 @@ public: const unsigned windowSizeRemainingTime, //time in ms const unsigned windowSizeBytesPerSecond); //time in ms + ~Statistics(); + void addMeasurement(const int objectsCurrent, const double dataCurrent); wxString getRemainingTime() const; //returns the remaining time in milliseconds wxString getBytesPerSecond() const; @@ -66,7 +68,7 @@ private: }; std::list<record> measurements; - std::auto_ptr<wxStopWatch> timer; + wxStopWatch* timer; }; #endif // STATISTICS_H_INCLUDED |