diff options
39 files changed, 8527 insertions, 896 deletions
diff --git a/Application.cpp b/Application.cpp index 260a5943..371e7107 100644 --- a/Application.cpp +++ b/Application.cpp @@ -1,4 +1,4 @@ -/*************************************************************** +/*******#include <wx/msgdlg.h>******************************************************** * Name: FreeFileSyncApp.cpp * Purpose: Code for Application Class * Author: ZenJu (zhnmju123@gmx.de) @@ -12,6 +12,7 @@ #include <wx/stdpaths.h> #include <wx/filename.h> #include "library/globalFunctions.h" +#include <wx/msgdlg.h> IMPLEMENT_APP(Application); @@ -59,7 +60,7 @@ void Application::initialize() wxString configFileForUI = FreeFileSync::FfsLastConfigFile; if (argc > 1) { - if (FreeFileSync::isFFS_ConfigFile(argv[1])) + if (FreeFileSync::isFfsConfigFile(argv[1])) configFileForUI = argv[1]; else //start in commandline mode? { @@ -191,7 +192,7 @@ void Application::parseCommandline() { wxCMD_LINE_OPTION, - GlobalResources::paramCfg, + GlobalResources::paramSync, NULL, wxString(_("Specify the sync-direction used for each type of file by a string of five chars:\n\n")) + _("\t\tChar 1: Folders/files that exist on left side only\n") + @@ -255,7 +256,7 @@ void Application::parseCommandline() GlobalResources::paramSilent, NULL, wxString(_("Do not show graphical status and error messages but write to a logfile instead.\n\n")) + - _("\tExamples:\n\n\t1.) FreeFileSync -cmp SIZEDATE -cfg RRRRR C:\\Source C:\\Target\n\t2.) FreeFileSync -cmp sizedate -cfg rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n") + + _("\tExamples:\n\n\t1.) FreeFileSync -comp SIZEDATE -sync RRRRR C:\\Source C:\\Target\n\t2.) FreeFileSync -comp sizedate -sync rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n") + _("\t1: Creates a mirror backup of the left directory\n\t2: Synchronizes all *.doc files from both directories simultaneously\n\n") + _("\tHint: You can easily generate a batch file by chosing \"Create batch job\" from the GUI menubar.\n") }, @@ -268,12 +269,12 @@ void Application::parseCommandline() //now set the parser with all MANDATORY options and parameters wxCmdLineParser parser(cmdLineDesc, argc, argv); parser.SetSwitchChars(wxT("-")); - if (parser.Parse() != 0) //if commandline is used incorrectly display help dialog and exit program + if (parser.Parse() != 0) //if commandline is used incorrectly: display help dialog and exit program return; //commandline parameters wxString cmp; - wxString cfg; + wxString syncCfg; wxString leftDir; wxString rightDir; wxString included; @@ -286,8 +287,8 @@ void Application::parseCommandline() //check existence of all commandline parameters - if (!parser.Found(GlobalResources::paramCompare, &cmp) || - !parser.Found(GlobalResources::paramCfg, &cfg) || + if ( !parser.Found(GlobalResources::paramCompare, &cmp) || + !parser.Found(GlobalResources::paramSync, &syncCfg) || parser.GetParamCount() != 2) { parser.Usage(); @@ -295,7 +296,7 @@ void Application::parseCommandline() } cmp.UpperCase(); - cfg.UpperCase(); + syncCfg.UpperCase(); leftDir = parser.GetParam(0); rightDir = parser.GetParam(1); @@ -316,12 +317,12 @@ void Application::parseCommandline() //check consistency of all commandline parameters if ((cmp != GlobalResources::valueSizeDate && cmp != GlobalResources::valueContent) || - cfg.Len() != 5 || - (cfg[0] != 'L' && cfg[0] != 'R' && cfg[0] != 'N') || - (cfg[1] != 'L' && cfg[1] != 'R' && cfg[1] != 'N') || - (cfg[2] != 'L' && cfg[2] != 'R' && cfg[2] != 'N') || - (cfg[3] != 'L' && cfg[3] != 'R' && cfg[3] != 'N') || - (cfg[4] != 'L' && cfg[4] != 'R' && cfg[4] != 'N')) + syncCfg.Len() != 5 || + (syncCfg[0] != 'L' && syncCfg[0] != 'R' && syncCfg[0] != 'N') || + (syncCfg[1] != 'L' && syncCfg[1] != 'R' && syncCfg[1] != 'N') || + (syncCfg[2] != 'L' && syncCfg[2] != 'R' && syncCfg[2] != 'N') || + (syncCfg[3] != 'L' && syncCfg[3] != 'R' && syncCfg[3] != 'N') || + (syncCfg[4] != 'L' && syncCfg[4] != 'R' && syncCfg[4] != 'N')) { parser.Usage(); return; @@ -333,7 +334,7 @@ void Application::parseCommandline() wxString logText; //check if directories exist - if (!wxDirExists(leftDir)) + if (!wxDirExists(FreeFileSync::getFormattedDirectoryName(leftDir))) { wxString errorMessage = wxString(_("Directory ")) + wxT("\"") + leftDir + wxT("\"") + _(" does not exist."); wxString statusMessage = wxString(_("Synchronization aborted!")); @@ -347,7 +348,7 @@ void Application::parseCommandline() returnValue = -2; return; } - else if (!wxDirExists(rightDir)) + else if (!wxDirExists(FreeFileSync::getFormattedDirectoryName(rightDir))) { wxString errorMessage = wxString(_("Directory ")) + wxT("\"") + rightDir + wxT("\"") + _(" does not exist."); wxString statusMessage = wxString(_("Synchronization aborted!")); @@ -395,11 +396,11 @@ void Application::parseCommandline() else assert (false); - syncConfiguration.exLeftSideOnly = convertCmdlineCfg(cfg, 0); - syncConfiguration.exRightSideOnly = convertCmdlineCfg(cfg, 1); - syncConfiguration.leftNewer = convertCmdlineCfg(cfg, 2); - syncConfiguration.rightNewer = convertCmdlineCfg(cfg, 3); - syncConfiguration.different = convertCmdlineCfg(cfg, 4); + syncConfiguration.exLeftSideOnly = convertCmdlineCfg(syncCfg, 0); + syncConfiguration.exRightSideOnly = convertCmdlineCfg(syncCfg, 1); + syncConfiguration.leftNewer = convertCmdlineCfg(syncCfg, 2); + syncConfiguration.rightNewer = convertCmdlineCfg(syncCfg, 3); + syncConfiguration.different = convertCmdlineCfg(syncCfg, 4); //begin of synchronization process (all in one try-catch block) try @@ -632,14 +633,16 @@ int CommandLineStatusUpdater::reportError(const wxString& text) inline -void CommandLineStatusUpdater::triggerUI_Refresh(bool asyncProcessActive) +void CommandLineStatusUpdater::forceUiRefresh() { - if (abortionRequested && !asyncProcessActive) - throw AbortThisProcess(); //may be triggered by the SyncStatusDialog - if (!silentMode) - if (updateUI_IsAllowed()) //test if specific time span between ui updates is over - syncStatusFrame->updateStatusDialogNow(); + syncStatusFrame->updateStatusDialogNow(); +} + + +void CommandLineStatusUpdater::abortThisProcess() +{ + throw AbortThisProcess(); //abort can be triggered by syncStatusFrame } diff --git a/Application.h b/Application.h index c3f02efe..eb209783 100644 --- a/Application.h +++ b/Application.h @@ -55,11 +55,13 @@ public: void initNewProcess(int objectsTotal, double dataTotal, int processID); void updateProcessedData(int objectsProcessed, double dataProcessed); int reportError(const wxString& text); - void triggerUI_Refresh(bool asyncProcessActive); + void forceUiRefresh(); void noSynchronizationNeeded(); private: + void abortThisProcess(); + Application* app; SyncStatus* syncStatusFrame; bool continueErrors; diff --git a/Changelog.txt b/Changelog.txt index ec93a2e6..5e1a98b2 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,19 @@ FreeFileSync ------------ +Changelog v1.10 +-------------- +Transformed configuration file format to XML +Exchanged batch files with shell links for full Unicode support (Windows-only) +Improved Filter usage: ignore leading/trailing whitespace, upper/lower-case (Windows-only) chars +Removed screen-flicker when clicking on compare: +Added elapsed time to compare status +Calculate height of middle grid independently from OS window layout +Multiple GUI improvements +Added Japanese translation +Updated translation files + + Changelog v1.9 -------------- Fixed wxWidgets multithreading issue that could cause synchronization to hang occasionally diff --git a/FreeFileSync - ANSI.cbp b/FreeFileSync - ANSI.cbp index 78ca07bc..2f25d1ba 100644 --- a/FreeFileSync - ANSI.cbp +++ b/FreeFileSync - ANSI.cbp @@ -62,6 +62,7 @@ <Add option="-D__GNUWIN32__" /> <Add option="-D__WXMSW__" /> <Add option="-DFFS_WIN" /> + <Add option="-DTIXML_USE_STL" /> <Add directory="C:\Programme\CodeBlocks\wxWidgets\include" /> <Add directory="C:\Programme\CodeBlocks\wxWidgets\contrib\include" /> </Compiler> @@ -97,9 +98,15 @@ <Unit filename="library\misc.h" /> <Unit filename="library\multithreading.cpp" /> <Unit filename="library\multithreading.h" /> + <Unit filename="library\pch.h"> + <Option weight="0" /> + </Unit> <Unit filename="library\resources.cpp" /> <Unit filename="library\resources.h" /> - <Unit filename="library\wxWidgets.h" /> + <Unit filename="library\tinyxml\tinystr.cpp" /> + <Unit filename="library\tinyxml\tinyxml.cpp" /> + <Unit filename="library\tinyxml\tinyxmlerror.cpp" /> + <Unit filename="library\tinyxml\tinyxmlparser.cpp" /> <Unit filename="resource.rc"> <Option compilerVar="WINDRES" /> </Unit> diff --git a/FreeFileSync - Unicode.cbp b/FreeFileSync - Unicode.cbp index 95254fa4..8c88f8b7 100644 --- a/FreeFileSync - Unicode.cbp +++ b/FreeFileSync - Unicode.cbp @@ -63,6 +63,7 @@ <Add option="-D__WXMSW__" /> <Add option="-DFFS_WIN" /> <Add option="-DwxUSE_UNICODE" /> + <Add option="-DTIXML_USE_STL" /> <Add directory="C:\Programme\CodeBlocks\wxWidgets\include" /> <Add directory="C:\Programme\CodeBlocks\wxWidgets\contrib\include" /> </Compiler> @@ -98,9 +99,15 @@ <Unit filename="library\misc.h" /> <Unit filename="library\multithreading.cpp" /> <Unit filename="library\multithreading.h" /> + <Unit filename="library\pch.h"> + <Option weight="0" /> + </Unit> <Unit filename="library\resources.cpp" /> <Unit filename="library\resources.h" /> - <Unit filename="library\wxWidgets.h" /> + <Unit filename="library\tinyxml\tinystr.cpp" /> + <Unit filename="library\tinyxml\tinyxml.cpp" /> + <Unit filename="library\tinyxml\tinyxmlerror.cpp" /> + <Unit filename="library\tinyxml\tinyxmlparser.cpp" /> <Unit filename="resource.rc"> <Option compilerVar="WINDRES" /> </Unit> diff --git a/FreeFileSync.cpp b/FreeFileSync.cpp index c7c07667..74c558b9 100644 --- a/FreeFileSync.cpp +++ b/FreeFileSync.cpp @@ -7,6 +7,7 @@ #include "library/resources.h" #include <sys/stat.h> #include <wx/ffile.h> +#include "library/tinyxml/tinyxml.h" #ifdef FFS_WIN #include <windows.h> @@ -61,14 +62,14 @@ void FreeFileSync::getFileInformation(FileInfo& output, const wxString& filename FindClose(fileHandle); if (FileTimeToLocalFileTime( - &winFileInfo.ftLastWriteTime, // pointer to UTC file time to convert - &localFileTime // pointer to converted file time + &winFileInfo.ftLastWriteTime, //pointer to UTC file time to convert + &localFileTime //pointer to converted file time ) == 0) throw RuntimeException(_("Error converting FILETIME to local FILETIME")); if (FileTimeToSystemTime( - &localFileTime, // pointer to file time to convert - &time // pointer to structure to receive system time + &localFileTime, //pointer to file time to convert + &time //pointer to structure to receive system time ) == 0) throw RuntimeException(_("Error converting FILETIME to SYSTEMTIME")); @@ -79,8 +80,8 @@ void FreeFileSync::getFileInformation(FileInfo& output, const wxString& filename formatTime(time.wMinute) + wxT(":") + formatTime(time.wSecond); - //UTC time - output.lastWriteTimeRaw = wxULongLong(winFileInfo.ftLastWriteTime.dwHighDateTime, winFileInfo.ftLastWriteTime.dwLowDateTime); + //local time + output.lastWriteTimeRaw = wxULongLong(localFileTime.dwHighDateTime, localFileTime.dwLowDateTime); //reduce precision to 1 second (FILETIME has unit 10^-7 s) output.lastWriteTimeRaw/= 10000000; // <- time is used for comparison only: unit switched to seconds @@ -99,7 +100,8 @@ void FreeFileSync::getFileInformation(FileInfo& output, const wxString& filename //local time output.lastWriteTime = buffer; - //unit: 1 second + + //UTC time; unit: 1 second output.lastWriteTimeRaw = fileInfo.st_mtime; output.fileSize = fileInfo.st_size; @@ -121,7 +123,7 @@ struct MemoryAllocator delete [] buffer2; } - static const unsigned int bufferSize = 1024 * 256; //256 kb seems to be the perfect buffer size + static const unsigned int bufferSize = 1024 * 512; //512 kb seems to be the perfect buffer size unsigned char* buffer1; unsigned char* buffer2; }; @@ -255,7 +257,9 @@ void calcTotalDataForCompare(int& objectsTotal, double& dataTotal, const FileCom void FreeFileSync::startCompareProcess(FileCompareResult& output, const wxString& dirLeft, const wxString& dirRight, CompareVariant cmpVar, StatusUpdater* statusUpdater) { - wxLogNull dummy; //hide wxWidgets log messages +#ifndef __WXDEBUG__ + wxLogNull dummy; //hide wxWidgets log messages in release build +#endif assert (statusUpdater); @@ -267,8 +271,7 @@ void FreeFileSync::startCompareProcess(FileCompareResult& output, const wxString FileCompareResult output_tmp; //write to output not before END of process! try - { - //retrieve sets of files (with description data) + { //retrieve sets of files (with description data) DirectoryDescrType directoryLeft; DirectoryDescrType directoryRight; @@ -276,6 +279,7 @@ void FreeFileSync::startCompareProcess(FileCompareResult& output, const wxString generateFileAndFolderDescriptions(directoryLeft, dirLeft, statusUpdater); generateFileAndFolderDescriptions(directoryRight, dirRight, statusUpdater); //wxMessageBox(numberToWxString(unsigned(GetTickCount()) - startTime)); + statusUpdater->forceUiRefresh(); FileCompareLine newline; @@ -334,7 +338,7 @@ void FreeFileSync::startCompareProcess(FileCompareResult& output, const wxString else if (cmpVar == CMP_BY_TIME_SIZE) { //check files that exist in left and right model but have different properties - //last write time may differ up to 2 seconds (NTFS vs FAT32) + //last write time may differ by up to 2 seconds (NTFS vs FAT32) bool sameWriteTime; if (i->lastWriteTimeRaw < j->lastWriteTimeRaw) sameWriteTime = (j->lastWriteTimeRaw - i->lastWriteTimeRaw <= 2); @@ -410,7 +414,7 @@ void FreeFileSync::startCompareProcess(FileCompareResult& output, const wxString while (true) { //trigger display refresh - statusUpdater->triggerUI_Refresh(); + statusUpdater->requestUiRefresh(); try { @@ -445,7 +449,7 @@ void FreeFileSync::startCompareProcess(FileCompareResult& output, const wxString } //wxMessageBox(numberToWxString(unsigned(GetTickCount()) - startTime3)); - statusUpdater->triggerUI_Refresh(); + statusUpdater->requestUiRefresh(); } catch (const RuntimeException& theException) { @@ -526,7 +530,7 @@ wxDirTraverseResult GetAllFilesFull::OnFile(const wxString& filename) //add 1 element to the progress indicator statusUpdater->updateProcessedData(1, 0); // NO performance issue at all //trigger display refresh - statusUpdater->triggerUI_Refresh(); + statusUpdater->requestUiRefresh(); return wxDIR_CONTINUE; } @@ -573,7 +577,7 @@ wxDirTraverseResult GetAllFilesFull::OnDir(const wxString& dirname) //add 1 element to the progress indicator statusUpdater->updateProcessedData(1, 0); // NO performance issue at all //trigger display refresh - statusUpdater->triggerUI_Refresh(); + statusUpdater->requestUiRefresh(); return wxDIR_CONTINUE; } @@ -628,7 +632,7 @@ public: recycleBinAvailable(false) { #ifdef FFS_WIN - recycleBinAvailable = true; + recycleBinAvailable = true; #endif // FFS_WIN } @@ -658,7 +662,7 @@ public: fileOp.lpszProgressTitle = NULL; if (SHFileOperation(&fileOp //pointer to an SHFILEOPSTRUCT structure that contains information the function needs to carry out - ) != 0 || fileOp.fAnyOperationsAborted) throw FileError(wxString(_("Error moving file ")) + wxT("\"") + filename + wxT("\"") + _(" to recycle bin!")); + ) != 0 || fileOp.fAnyOperationsAborted) throw FileError(wxString(_("Error moving file ")) + wxT("\"") + filename + wxT("\"") + _(" to recycle bin!")); #endif // FFS_WIN } @@ -683,10 +687,10 @@ void FreeFileSync::removeFile(const wxString& filename) #ifdef FFS_WIN if (!SetFileAttributes( - filename.c_str(), // address of filename - FILE_ATTRIBUTE_NORMAL // attributes to set + filename.c_str(), //address of filename + FILE_ATTRIBUTE_NORMAL //attributes to set )) throw FileError(wxString(_("Error deleting file ")) + wxT("\"") + filename + wxT("\"")); -#endif // FFS_WIN +#endif //FFS_WIN if (!wxRemoveFile(filename)) throw FileError(wxString(_("Error deleting file ")) + wxT("\"") + filename + wxT("\"")); @@ -779,14 +783,9 @@ void FreeFileSync::copyCreatingDirs(const wxString& source, const wxString& targ class UpdateWhileCopying : public UpdateWhileExecuting { public: - UpdateWhileCopying() - { //prevent wxWidgets logging - noWxLogs = new wxLogNull; - } - ~UpdateWhileCopying() - { - delete noWxLogs; - } + UpdateWhileCopying() {} + ~UpdateWhileCopying() {} + wxString source; wxString target; bool success; @@ -826,7 +825,10 @@ private: success = true; } - wxLogNull* noWxLogs; +#ifndef __WXDEBUG__ + //prevent wxWidgets logging + wxLogNull noWxLogs; +#endif }; @@ -849,17 +851,9 @@ void FreeFileSync::copyfileMultithreaded(const wxString& source, const wxString& FreeFileSync::FreeFileSync(bool useRecycleBin) : - recycleBinShouldBeUsed(useRecycleBin) -{ - //prevent wxWidgets logging - noWxLogs = new wxLogNull; -} + recycleBinShouldBeUsed(useRecycleBin) {} - -FreeFileSync::~FreeFileSync() -{ - delete noWxLogs; -} +FreeFileSync::~FreeFileSync() {} bool FreeFileSync::recycleBinExists() @@ -1251,6 +1245,39 @@ wxString FreeFileSync::formatFilesizeToShortString(const double filesize) } +inline +void formatFilterString(wxString& filter) +{ + filter.Trim(true); //remove whitespace characters from right + filter.Trim(false); //remove whitespace characters from left + +#ifdef FFS_WIN + //Windows does NOT distinguish between upper/lower-case + filter.MakeLower(); +#elif defined FFS_LINUX + //Linux DOES distinguish between upper/lower-case +//nothing to do here +#else + assert(false); +#endif +} + + +inline +void formatFilenameString(wxString& filename) +{ +#ifdef FFS_WIN + //Windows does NOT distinguish between upper/lower-case + filename.MakeLower(); +#elif defined FFS_LINUX + //Linux DOES distinguish between upper/lower-case +//nothing to do here +#else + assert(false); +#endif +} + + void FreeFileSync::filterCurrentGridData(FileCompareResult& currentGridData, const wxString& includeFilter, const wxString& excludeFilter) { wxString includeFilterTmp(includeFilter); @@ -1271,16 +1298,24 @@ void FreeFileSync::filterCurrentGridData(FileCompareResult& currentGridData, con while ((indexEnd = includeFilterTmp.find(';', indexStart )) != string::npos) { if (indexStart != indexEnd) //do not add empty strings - includeList.push_back( includeFilterTmp.substr(indexStart, indexEnd - indexStart) ); + { + wxString newEntry = includeFilterTmp.substr(indexStart, indexEnd - indexStart); + formatFilterString(newEntry); + includeList.push_back(newEntry); + } indexStart = indexEnd + 1; } indexStart = 0; - indexEnd = 0; + indexEnd = 0; while ((indexEnd = excludeFilterTmp.find(';', indexStart )) != string::npos) { if (indexStart != indexEnd) //do not add empty strings - excludeList.push_back( excludeFilterTmp.substr(indexStart, indexEnd - indexStart) ); + { + wxString newEntry = excludeFilterTmp.substr(indexStart, indexEnd - indexStart); + formatFilterString(newEntry); + excludeList.push_back(newEntry); + } indexStart = indexEnd + 1; } @@ -1289,12 +1324,18 @@ void FreeFileSync::filterCurrentGridData(FileCompareResult& currentGridData, con //filter currentGridData for (FileCompareResult::iterator i = currentGridData.begin(); i != currentGridData.end(); ++i) { + wxString filenameLeft = i->fileDescrLeft.filename; + wxString filenameRight = i->fileDescrRight.filename; + + formatFilenameString(filenameLeft); + formatFilenameString(filenameRight); + //process include filters if (i->fileDescrLeft.objType != TYPE_NOTHING) { bool includedLeft = false; for (vector<wxString>::const_iterator j = includeList.begin(); j != includeList.end(); ++j) - if (i->fileDescrLeft.filename.Matches(*j)) + if (filenameLeft.Matches(*j)) { includedLeft = true; break; @@ -1311,7 +1352,7 @@ void FreeFileSync::filterCurrentGridData(FileCompareResult& currentGridData, con { bool includedRight = false; for (vector<wxString>::const_iterator j = includeList.begin(); j != includeList.end(); ++j) - if (i->fileDescrRight.filename.Matches(*j)) + if (filenameRight.Matches(*j)) { includedRight = true; break; @@ -1327,8 +1368,7 @@ void FreeFileSync::filterCurrentGridData(FileCompareResult& currentGridData, con //process exclude filters bool excluded = false; for (vector<wxString>::const_iterator j = excludeList.begin(); j != excludeList.end(); ++j) - if (i->fileDescrLeft.filename.Matches(*j) || - i->fileDescrRight.filename.Matches(*j)) + if (filenameLeft.Matches(*j) || filenameRight.Matches(*j)) { excluded = true; break; @@ -1344,6 +1384,7 @@ void FreeFileSync::filterCurrentGridData(FileCompareResult& currentGridData, con } } + void FreeFileSync::removeFilterOnCurrentGridData(FileCompareResult& currentGridData) { //remove all filters on currentGridData @@ -1353,11 +1394,15 @@ void FreeFileSync::removeFilterOnCurrentGridData(FileCompareResult& currentGridD wxString FreeFileSync::getFormattedDirectoryName(const wxString& dirname) -{ //this formatting is needed since functions in FreeFileSync.cpp expect the directory to end with '\' to be able to split the relative names - //Actually all it needs, is the length of the directory +{ //formatting is needed since functions in FreeFileSync.cpp expect the directory to end with '\' to be able to split the relative names + //actually all it needs, is the length of the directory + + wxString dirnameTmp = dirname; + dirnameTmp.Trim(true); //remove whitespace characters from right + dirnameTmp.Trim(false); //remove whitespace characters from left //let wxWidgets do the directory formatting, e.g. replace '/' with '\' for Windows - wxString result = wxDir(dirname).GetName(); + wxString result = wxDir(dirnameTmp).GetName(); result.Append(GlobalResources::fileNameSeparator); return result; @@ -1434,7 +1479,7 @@ void FreeFileSync::startSynchronizationProcess(FileCompareResult& grid, const Sy { while (true) { //trigger display refresh - statusUpdater->triggerUI_Refresh(); + statusUpdater->requestUiRefresh(); try { @@ -1477,7 +1522,7 @@ void FreeFileSync::startSynchronizationProcess(FileCompareResult& grid, const Sy { while (true) { //trigger display refresh - statusUpdater->triggerUI_Refresh(); + statusUpdater->requestUiRefresh(); try { @@ -1528,25 +1573,26 @@ void FreeFileSync::startSynchronizationProcess(FileCompareResult& grid, const Sy } -bool FreeFileSync::isFFS_ConfigFile(const wxString& filename) +bool FreeFileSync::isFfsConfigFile(const wxString& filename) { if (!wxFileExists(filename)) return false; + //workaround to get a FILE* from a unicode filename wxFFile configFile(filename, wxT("rb")); if (!configFile.IsOpened()) return false; - char buffer[FreeFileSync::FfsConfigFileID.size() + 1]; + FILE* inputFile = configFile.fp(); - //read FFS identifier - size_t bytesRead = configFile.Read(buffer, FreeFileSync::FfsConfigFileID.size()); + TiXmlDocument doc; + if (!doc.LoadFile(inputFile)) //fails if inputFile is no proper XML + return false; - if (!configFile.Error() && bytesRead < 1000) - { - buffer[bytesRead] = 0; - return (FfsConfigFileID == string(buffer)); - } + TiXmlElement* root = doc.RootElement(); + + if (root && (root->ValueStr() == string("FreeFileSync"))) //check for FFS configuration xml + return true; else return false; } @@ -1567,7 +1613,7 @@ void FreeFileSync::addSubElements(set<int>& subElements, const FileCompareResult return; for (FileCompareResult::const_iterator i = grid.begin(); i != grid.end(); ++i) - if (i->fileDescrLeft.relFilename.StartsWith(relevantDirectory) || + if ( i->fileDescrLeft.relFilename.StartsWith(relevantDirectory) || i->fileDescrRight.relFilename.StartsWith(relevantDirectory)) subElements.insert(i - grid.begin()); } @@ -1628,28 +1674,3 @@ void FreeFileSync::deleteOnGridAndHD(FileCompareResult& grid, const set<int>& ro //remove deleted rows from grid removeRowsFromVector(grid, rowsToDeleteInGrid); } - - -void updateUI_Now() -{ - //process UI events and prevent application from "not responding" -> NO performance issue! - wxTheApp->Yield(); - - // while (wxTheApp->Pending()) - // wxTheApp->Dispatch(); -} - - -bool updateUI_IsAllowed() -{ - static wxLongLong lastExec = 0; - - wxLongLong newExec = wxGetLocalTimeMillis(); - - if (newExec - lastExec >= UI_UPDATE_INTERVAL) //perform ui updates not more often than necessary - { - lastExec = newExec; - return true; - } - return false; -} diff --git a/FreeFileSync.h b/FreeFileSync.h index cf17a5d7..496a6c13 100644 --- a/FreeFileSync.h +++ b/FreeFileSync.h @@ -1,7 +1,6 @@ #ifndef FREEFILESYNC_H_INCLUDED #define FREEFILESYNC_H_INCLUDED -#include "library/wxWidgets.h" #include <wx/string.h> #include <set> #include <vector> @@ -41,12 +40,12 @@ struct Configuration SyncConfiguration syncConfiguration; //Filter setting + bool filterIsActive; + bool hideFiltered; wxString includeFilter; wxString excludeFilter; - bool hideFiltered; - bool filterIsActive; - //other options + //misc options bool useRecycleBin; //use Recycle bin when deleting or overwriting files while synchronizing bool continueOnError; //hides error messages during synchronization }; @@ -109,7 +108,7 @@ struct FileDescrLine return (relFilename.Cmp(b.relFilename) == 0); } #else - assert(false); + adapt this #endif }; typedef set<FileDescrLine> DirectoryDescrType; @@ -163,10 +162,6 @@ private: StatusUpdater* statusUpdater; }; -bool updateUI_IsAllowed(); //test if a specific amount of time is over -void updateUI_Now(); //do the updating - - //Note: the following lines are a performance optimization for deleting elements from a vector. It is incredibly faster to create a new //vector and leave specific elements out than to delete row by row and force recopying of most elements for each single deletion (linear vs quadratic runtime) template <class T> @@ -235,7 +230,7 @@ public: static void swapGrids(FileCompareResult& grid); - static bool isFFS_ConfigFile(const wxString& filename); + static bool isFfsConfigFile(const wxString& filename); static const string FfsConfigFileID; static const wxString FfsLastConfigFile; @@ -257,7 +252,10 @@ private: bool recycleBinShouldBeUsed; static RecycleBin recycler; - wxLogNull* noWxLogs; +#ifndef __WXDEBUG__ + //prevent wxWidgets logging + wxLogNull noWxLogs; +#endif }; @@ -1,4 +1,4 @@ -CPPFLAGS=-Wall -pipe -DNDEBUG `wx-config --cppflags` -DFFS_LINUX -O3 -pthread -c +CPPFLAGS=-Wall -pipe -DNDEBUG `wx-config --cppflags` -DFFS_LINUX -DTIXML_USE_STL -O3 -pthread -c ENDFLAGS=`wx-config --libs` -lwx_gtk2_aui-2.8 -O3 -pthread all: FreeFileSync @@ -36,8 +36,21 @@ obj/smallDialogs.o: ui/smallDialogs.cpp obj/misc.o: library/misc.cpp g++ $(CPPFLAGS) library/misc.cpp -o obj/misc.o -FreeFileSync: obj/FreeFileSync.o obj/application.o obj/globalFunctions.o obj/guiGenerated.o obj/mainDialog.o obj/syncDialog.o obj/customGrid.o obj/resources.o obj/smallDialogs.o obj/multithreading.o obj/misc.o - g++ $(ENDFLAGS) -o FreeFileSync obj/application.o obj/FreeFileSync.o obj/globalFunctions.o obj/guiGenerated.o obj/mainDialog.o obj/syncDialog.o obj/customGrid.o obj/resources.o obj/smallDialogs.o obj/multithreading.o obj/misc.o +obj/tinyxml.o: library/tinyxml/tinyxml.cpp + g++ $(CPPFLAGS) library/tinyxml/tinyxml.cpp -o obj/tinyxml.o + +obj/tinystr.o: library/tinyxml/tinystr.cpp + g++ $(CPPFLAGS) library/tinyxml/tinystr.cpp -o obj/tinystr.o + +obj/tinyxmlerror.o: library/tinyxml/tinyxmlerror.cpp + g++ $(CPPFLAGS) library/tinyxml/tinyxmlerror.cpp -o obj/tinyxmlerror.o + +obj/tinyxmlparser.o: library/tinyxml/tinyxmlparser.cpp + g++ $(CPPFLAGS) library/tinyxml/tinyxmlparser.cpp -o obj/tinyxmlparser.o + + +FreeFileSync: obj/FreeFileSync.o obj/application.o obj/globalFunctions.o obj/guiGenerated.o obj/mainDialog.o obj/syncDialog.o obj/customGrid.o obj/resources.o obj/smallDialogs.o obj/multithreading.o obj/misc.o obj/tinyxml.o obj/tinystr.o obj/tinyxmlerror.o obj/tinyxmlparser.o + g++ $(ENDFLAGS) -o FreeFileSync obj/application.o obj/FreeFileSync.o obj/globalFunctions.o obj/guiGenerated.o obj/mainDialog.o obj/syncDialog.o obj/customGrid.o obj/resources.o obj/smallDialogs.o obj/multithreading.o obj/misc.o obj/tinyxml.o obj/tinystr.o obj/tinyxmlerror.o obj/tinyxmlparser.o clean: diff --git a/Makefile_Win_ANSI.cmd b/Makefile_Win_ANSI.cmd index 5b9a84be..a586b60c 100644 --- a/Makefile_Win_ANSI.cmd +++ b/Makefile_Win_ANSI.cmd @@ -8,7 +8,7 @@ path=%path%;%mingw% ::convert file from UTF-8 to standard ANSI encoding; ICONV is part of MinGW - MSYS Supplementary Tools iconv -f UTF-8 -t ISO-8859-1 %sources%\ui\guiGenerated.cpp > %sources%\ui\guiGenerated_ansi.cpp -set parameters=-Wall -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DFFS_WIN -O2 -DNDEBUG +set parameters=-Wall -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DFFS_WIN -O2 -DNDEBUG -DTIXML_USE_STL if not exist obj md obj mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\application.cpp -o obj\Application.o mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\FreeFileSync.cpp -o obj\FreeFileSync.o @@ -21,7 +21,12 @@ mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I% mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\resources.cpp -o obj\Resources.o mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\misc.cpp -o obj\misc.o mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\ui\smallDialogs.cpp -o obj\SmallDialogs.o +mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\tinyxml\tinyxml.cpp -o obj\tinyxml.o +mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\tinyxml\tinystr.cpp -o obj\tinystr.o +mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\tinyxml\tinyxmlerror.cpp -o obj\tinyxmlerror.o +mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\tinyxml\tinyxmlparser.cpp -o obj\tinyxmlparser.o + windres.exe -i %sources%\resource.rc -J rc -o obj\resource.res -O coff -I%widgets%\include -I%widgetslib% -mingw32-g++.exe -L%widgets%\lib\gcc_lib -o FreeFileSync.exe obj\Application.o obj\FreeFileSync.o obj\globalFunctions.o obj\multithreading.o obj\misc.o obj\GUI_Generated.o obj\MainDialog.o obj\SyncDialog.o obj\CustomGrid.o obj\Resources.o obj\SmallDialogs.o obj\resource.res -s -mthreads -lwxmsw28_adv -lwxmsw28_core -lwxbase28 -lwxpng -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows +mingw32-g++.exe -L%widgets%\lib\gcc_lib -o FreeFileSync.exe obj\Application.o obj\FreeFileSync.o obj\globalFunctions.o obj\multithreading.o obj\misc.o obj\GUI_Generated.o obj\MainDialog.o obj\SyncDialog.o obj\CustomGrid.o obj\Resources.o obj\SmallDialogs.o obj\resource.res obj\tinyxml.o obj\tinystr.o obj\tinyxmlerror.o obj\tinyxmlparser.o -s -mthreads -lwxmsw28_adv -lwxmsw28_core -lwxbase28 -lwxpng -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows del %sources%\ui\guiGenerated_ansi.cpp pause
\ No newline at end of file diff --git a/Makefile_Win_Unicode.cmd b/Makefile_Win_Unicode.cmd index e1f54f67..5ec2b89d 100644 --- a/Makefile_Win_Unicode.cmd +++ b/Makefile_Win_Unicode.cmd @@ -4,7 +4,7 @@ set widgetslib=C:\Programme\CodeBlocks\wxWidgets\lib\gcc_lib\mswu set sources=C:\Programme\CodeBlocks\Projects\FreeFileSync set mingw=C:\Programme\CodeBlocks\MinGW\bin -set parameters=-Wall -pipe -mthreads -D__GNUWIN32__ -DwxUSE_UNICODE -D__WXMSW__ -DFFS_WIN -O2 -DNDEBUG +set parameters=-Wall -pipe -mthreads -D__GNUWIN32__ -DwxUSE_UNICODE -D__WXMSW__ -DFFS_WIN -O2 -DNDEBUG -DTIXML_USE_STL path=%path%;%mingw% if not exist obj md obj mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\application.cpp -o obj\Application.o @@ -18,6 +18,11 @@ mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I% mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\resources.cpp -o obj\Resources.o mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\misc.cpp -o obj\misc.o mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\ui\smallDialogs.cpp -o obj\SmallDialogs.o +mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\tinyxml\tinyxml.cpp -o obj\tinyxml.o +mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\tinyxml\tinystr.cpp -o obj\tinystr.o +mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\tinyxml\tinyxmlerror.cpp -o obj\tinyxmlerror.o +mingw32-g++.exe %parameters% -I%widgets%\include -I%widgets%\contrib\include -I%widgetslib% -c %sources%\library\tinyxml\tinyxmlparser.cpp -o obj\tinyxmlparser.o + windres.exe -i %sources%\resource.rc -J rc -o obj\resource.res -O coff -I%widgets%\include -I%widgetslib% -mingw32-g++.exe -L%widgets%\lib\gcc_lib -o FreeFileSync.exe obj\Application.o obj\FreeFileSync.o obj\globalFunctions.o obj\multithreading.o obj\misc.o obj\GUI_Generated.o obj\MainDialog.o obj\SyncDialog.o obj\CustomGrid.o obj\Resources.o obj\SmallDialogs.o obj\resource.res -s -mthreads -lwxmsw28u_adv -lwxmsw28u_core -lwxbase28u -lwxpng -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows +mingw32-g++.exe -L%widgets%\lib\gcc_lib -o FreeFileSync.exe obj\Application.o obj\FreeFileSync.o obj\globalFunctions.o obj\multithreading.o obj\misc.o obj\GUI_Generated.o obj\MainDialog.o obj\SyncDialog.o obj\CustomGrid.o obj\Resources.o obj\SmallDialogs.o obj\resource.res obj\tinyxml.o obj\tinystr.o obj\tinyxmlerror.o obj\tinyxmlparser.o -s -mthreads -lwxmsw28u_adv -lwxmsw28u_core -lwxbase28u -lwxpng -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -mwindows pause
\ No newline at end of file @@ -1,4 +1,4 @@ -FreeFileSync v1.9 +FreeFileSync v1.10 ----------------- Usage @@ -33,7 +33,7 @@ Key Features 11. Support for filesizes > 4 GB. 12. Option to move files to Recycle Bin instead of deleting/overwriting them. 13. Automatically ignore directories "\RECYCLER" and "\System Volume Information" when comparing and sync'ing. (Windows only) -14. Localized English, French and German versions available. +14. Localized English, German, French and Japanese versions available. 15. Delete before copy: Avoid disc space shortages with large sync-operations. 16. Based on wxWidgets framework => Portable to many operating systems. 17. Filter functionality to include/exclude files from synchronization (without re-compare!). diff --git a/Resources.dat b/Resources.dat Binary files differindex c607e687..9ec9f5d7 100644 --- a/Resources.dat +++ b/Resources.dat @@ -96,8 +96,8 @@ -Synchronisation de fichiers Open-Source- . , -1. Enter full file or directory names separated by ';'.\n2. Wildcard characters '*' and '?' are supported.\n3. Case sensitive expressions!\n\nExample: *.tmp;*\\filename.dat;*\\directory\\* -1. Entrer les noms complets des fichiers ou répertoires séparés par des ';'.\n2. Les caractères génériques '*' et '?' sont supportés.\n3. La distinction est faite entre majuscules et minuscules!\n\nExemple: *.tmp;*\\fichier.dat;*\\repert\\* +1. Enter full file or directory names separated by ';'.\n2. Wildcard characters '*' and '?' are supported.\n3. Case sensitive expressions! +1. Entrer les noms complets des fichiers ou répertoires séparés par des ';'.\n2. Les caractères génériques '*' et '?' sont supportés.\n3. La distinction est faite entre majuscules et minuscules! : check file content\n : Contrôle le contenu du fichier\n : check filesize and date\n\t\t @@ -366,8 +366,8 @@ Information Information Initialization of Recycle Bin failed! It cannot be used! Erreur lors de l'initialisation de la corbeille ! La corbeille ne peut être utilisée! -It was not possible to gain access to Recycle Bin!\n\nIt's likely that you are not using Windows XP. (Probably Vista)\nIf you want this feature included, please contact the author. :) -Impossible d'accéder à la corbeille!\n\nIl est probable que vous n'utilisez pas Windows XP. (Peut-être Vista?)\nSi vous désirez utilisee cette fonctionnalité, veuillez contacter l'auteur. :) +It was not possible to initialize the Recycle Bin!\n\nIt's likely that you are not using Windows.\nIf you want this feature included, please contact the author. :) +Impossible d'accéder à la corbeille!\n\nIl est probable que vous n'utilisez pas Windows.\nSi vous désirez utilisee cette fonctionnalité, veuillez contacter l'auteur. :) Left directory does not exist. Please select a new one! Le répertoire de gauche n'existe pas. Veuillez en choisir un autre! Left folder: @@ -534,8 +534,8 @@ Attention : la synchronisation a échoué à cause de \n\t\tDirection de la synchronisation: L: vers la gauche, R: vers la droite, N: ne rien faire\n \t1: Creates a mirror backup of the left directory\n\t2: Synchronizes all *.doc files from both directories simultaneously\n\n \t1: Crée une sauvegarde miroir du répertoire de gauche\n\t2: Synchronise tous les fichiers *.doc sur les deux répertoires\n\n -\tExamples:\n\n\t1.) FreeFileSync -cmp SIZEDATE -cfg RRRRR C:\\Source C:\\Target\n\t2.) FreeFileSync -cmp sizedate -cfg rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n -\tExemples :\n\n\t1.) FreeFileSync -cmp SIZEDATE -cfg RRRRR C:\\Source C:\\Target\n\t2.) FreeFileSync -cmp sizedate -cfg rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n +\tExamples:\n\n\t1.) FreeFileSync -cmp SIZEDATE -sync RRRRR C:\\Source C:\\Target\n\t2.) FreeFileSync -cmp sizedate -sync rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n +\tExemples :\n\n\t1.) FreeFileSync -cmp SIZEDATE -sync RRRRR C:\\Source C:\\Target\n\t2.) FreeFileSync -cmp sizedate -sync rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n \tHint: You can easily generate a batch file by chosing \"Create batch job\" from the GUI menubar.\n \t\tChar 1: Folders/files that exist on left side only\n @@ -1,3 +1,5 @@ + MinGW \t- Windows port of GNU Compiler Collection\n wxWidgets \t- Open-Source GUI framework\n wxFormBuilder\t- wxWidgets GUI-builder\n CodeBlocks \t- Open-Source IDE + MinGW \t- Windows port of GNU Compiler Collection\n wxWidgets \t- Open-Source GUI framework\n wxFormBuilder\t- wxWidgets GUI-builder\n CodeBlocks \t- Open-Source IDE Time: Uhrzeit: Byte @@ -86,18 +88,36 @@ (-) nicht synchronisieren\n , . +- different +- verschieden +- different (same date, different size) +- verschieden (gleiches Datum, unterschiedliche Größe) +- equal +- gleich +- exists left only +- existiert nur links +- exists right only +- existiert nur rechts +- left +- links +- left newer +- links neuer +- right +- rechts +- right newer +- rechts neuer +- same date (different size) +- gleiches Datum (unterschiedliche Größe) ------------------------------------------------- ----------------------------------------------------- ---------\n -----------\n ---.-- ---.-- -Open-Source file synchronization- -Open-Source Datei-Synchronisation- . , -1. Enter full file or directory names separated by ';'.\n2. Wildcard characters '*' and '?' are supported.\n3. Case sensitive expressions!\n\nExample: *.tmp;*\\filename.dat;*\\directory\\* -1. Komplette Datei- oder Verzeichnisnamen getrennt durch ';' eingeben.\n2. Die Platzhalter '*' und '?' werden unterstützt.\n3. Groß-/Kleinschreibung wird unterschieden!\n\nBeispiel: *.tmp;*\\filename.dat;*\\directory\\* +1. Enter full file or directory names separated by ';'.\n2. Wildcard characters '*' and '?' are supported. +1. Komplette Datei- oder Verzeichnisnamen getrennt durch ';' eingeben.\n2. Die Platzhalter '*' und '?' werden unterstützt. : check file content\n : Prüfung auf Dateiinhalt\n : check filesize and date\n\t\t @@ -132,24 +152,34 @@ An error occured Fehler An exception occured! Eine Exception wurde geworfen! +As a result 6 different status can be returned to categorize all files: +Als Ergebnis werden 6 verschiedene Status zurückgegeben, um Dateien zu kategorisieren: +As a result the files are separated into the following categories: +Das Ergebnis ist eine Aufteilung in folgende Kategorien: +As the name suggests, two files which share the same name are marked as equal if and only if they have the same content. This option is useful for consistency checks rather than backup operations. Therefore the file times are not taken into account at all.\n\nWith this option enabled the decision tree is smaller: +Wie der Name bereits sagt, werden zwei Dateien mit gleichem Namen genau dann als gleich angesehen, wenn sie den gleichen Dateiinhalt haben. Diese Einstellung ist eher für Konsistenzprüfungen geeignet als für Backup-Operationen. Aus diesem Grund wird der Zeitpunkt der letzten Änderung der Dateien nicht berücksichtigt.\n\nDer Entscheidungsbaum ist in diesem Fall kleiner: Assemble a batch file with the following settings. To start synchronization in batch mode simply execute this file or schedule it in your operating system's task planner. Erzeuge eine Batch-Datei mit den folgenden Parametern. Um im Batch-Modus zu synchronisieren, kann diese einfach gestartet oder in den Task-Planer des Betriebssystems eingetragen werden. Batch file created successfully! Batch-Datei wurde erfolgreich erstellt! +Big thanks for localizing FreeFileSync goes out to: +Vielen Dank für die Lokalisation von FreeFileSync an: Build: Build: Choose to hide filtered files/directories from list Gefilterte Dateien ein-/ausblenden Comma separated list Kommagetrennte Liste -Command file -Command Datei Compare both sides Beide Seiten vergleichen -Compare by \"File size and date\"\n----------------------------------------\nThis variant evaluates two equally named files as being equal when they have the same file size AND the same last write date and time. Notice that the file time is allowed to deviate by up to 2 seconds. This ensures synchronization with the lower-precision file system FAT32 works correctly.\n\nWhen \"Compare\" is triggered with this option set the following decision tree is processed:\n\n -----------------\n |Decision tree|\n -----------------\n ________|___________\n | |\n file exists on both sides on one side only\n _____|______ __|___\n | | | |\nequal different left right\n _________|__________\n | | |\n left newer right newer same date\n\nAs a result 6 different status can be returned to categorize all files:\n\n- exists left only\n- exists right only\n- left newer\n- right newer\n- different filesize (but same date)\n- equal\n\n\nCompare by \"File content\"\n----------------------------------------\nAs the name suggests, two files which share the same name are marked as equal if and only if they have the same content. This option is useful for consistency checks rather than backup operations. Therefore the file times are not taken into account at all.\n\nWith this option enabled the decision tree is smaller:\n\n -----------------\n |Decision tree|\n -----------------\n ________|___________\n | |\n file exists on both sides on one side only\n _____|______ __|___\n | | | |\nequal different left right\n\nAs a result the files are separated into the following categories:\n\n- exists left only\n- exists right only\n- different\n- equal -Vergleichen nach \"Dateigröße und -datum\"\n---------------------------------------------------\nDiese Variante identifiziert zwei gleichnamige Dateien als gleich, wenn sie die gleiche Dateigröße haben UND der Zeitpunkt der letzten Änderung derselbe ist. Dabei wird eine Abweichung von bis zu zwei Sekunden toleriert. So ist sichergestellt, dass eine Synchronisation gegen ein FAT32 Dateisystem korrekt funktioniert.\n\nNachdem \"Compare\" mit dieser Einstellung gestartet wurde, wird der folgende Entscheidungsbaum abgearbeitet:\n\n -------------------------\n |Entscheidungsbaum|\n -------------------------\n __________|___________\n | |\n Datei ex. auf beiden Seiten nur auf einer Seite\n ________|____ __|___\n | | | |\n gleich verschieden links rechts\n __________|___________\n | | |\n links neuer rechts neuer gleiches Datum\n\nAls Ergebnis werden 6 verschiedene Status zurückgegeben, um Dateien zu kategorisieren:\n\n- existiert nur links\n- existiert nur rechts\n- links neuer\n- rechts neuer\n- verschiedene Dateigrößen (bei gleichem Datum)\n- gleich\n\n\nVergleichen nach \"Dateiinhalt\"\n------------------------------------\nWie der Name bereits sagt, werden zwei Dateien mit gleichem Namen genau dann als gleich angesehen, wenn sie den gleichen Dateiinhalt haben. Diese Einstellung ist eher für Konsistenzprüfungen geeignet als für Backup-Operationen. Aus diesem Grund wird der Zeitpunkt der letzten Änderung der Dateien nicht berücksichtigt.\n\nDer Entscheidungsbaum ist in diesem Fall kleiner:\n\n -------------------------\n |Entscheidungsbaum|\n -------------------------\n __________|___________\n | |\n Datei ex. auf beiden Seiten nur auf einer Seite\n ________|____ __|___\n | | | |\n gleich verschieden links rechts\n\nDas Ergebnis ist eine Aufteilung in folgende Kategorien:\n\n- existiert nur links\n- existiert nur rechts\n- verschieden\n- gleich +Compare by \"File content\" +Vergleich nach \"Dateiinhalt\" +Compare by \"File size and date\" +Vergleich nach \"Dateigröße und -datum\" Compare by... Vergleichen nach... +Comparing content +Vergleiche Dateiinhalt Comparing content of files Vergleiche Inhalt der Dateien Comparing... @@ -190,6 +220,10 @@ Copy to clipboard\tCTRL+C Kopiere in Zwischenablage\tCTRL+C Copying file Kopiere Datei +Could not create file +Fehler beim Erstellen der Datei +Could not open configuration file +Fehler beim Öffnen der Datei Could not open file: Fehler beim Öffnen der Datei: Could not read configuration file @@ -200,6 +234,8 @@ Could not retrieve file info for: Fehler beim Lesen der Dateiattribute von: Could not set working directory to directory containing executable file! Arbeitsverzeichnisses konnte nicht auf Pfad der .exe-Datei gelegt werden! +Could not write configuration file +Fehler beim Schreiben der Konfigurationsdatei Could not write to Fehler beim Schreiben von Create a batch job @@ -212,10 +248,10 @@ Current operation: Aktuelle Operation: Custom Eigene +DECISION TREE +ENTSCHEIDUNGSBAUM Data remaining: Verbliebene Daten: -Data to compare: -Zu vergleichende Daten: Data: Daten: Date @@ -252,8 +288,8 @@ Do you really want to delete the following objects(s)? Sollen die folgenden Elemente wirklich gelöscht werden? Do you really want to move the following objects(s) to the recycle bin? Sollen die folgenden Elemente wirklich in den Papierkorb verschoben werden? -Donate with Paypal -Spenden mit Paypal +Donate with PayPal +Spenden mit PayPal Drag && drop Drag && Drop Email: @@ -278,6 +314,8 @@ Error deleting file Fehler beim Löschen der Datei Error moving file Fehler beim Verschieben der Datei +Error parsing configuration file +Fehler beim Auswerten der Konfigurationsdatei Error reading file: Fehler beim Lesen der Datei: Error traversing directory @@ -290,6 +328,8 @@ Error when converting wxString to long Fehler bei Konvertierung (wxString nach long) Error: Source directory does not exist anymore: Fehler: Quellverzeichnis existiert nicht mehr: +Example +Beispiel Exclude Ausschließen Feedback and suggestions are welcome at: @@ -306,6 +346,8 @@ Files are found equal if\n - file content\nis the same. Dateien gelten als gleich, wenn\n - der Inhalt\ngleich ist. Files are found equal if\n - filesize\n - last write time (UTC) and date\nare the same. Dateien gelten als gleich, wenn\n - die Größe\n - Datum und Uhrzeit(UTC) der letzten Änderung\ngleich sind. +Files remaining: +Verbliebene Dateien: Files that exist on both sides and have different content Dateien, die auf beiden Seiten existieren und unterschiedlichen Inhalt haben Files that exist on both sides, have same date but different filesizes @@ -314,8 +356,6 @@ Files that exist on both sides, left one is newer Dateien, die auf beiden Seiten existieren; linke Datei ist neuer Files that exist on both sides, right one is newer Dateien, die auf beiden Seiten existieren; rechte Datei ist neuer -Files to compare: -Zu vergleichende Dateien: Files/folders remaining: Verbliebene Dateien/Ordner: Files/folders scanned: @@ -338,6 +378,8 @@ FreeFileSync (Date: FreeFileSync (Datum: FreeFileSync - Folder Comparison and Synchronization FreeFileSync - Verzeichnisvergleich und -synchronisation +FreeFileSync Batch Job +FreeFileSync Batchdatei FreeFileSync at Sourceforge FreeFileSync auf Sourceforge FreeFileSync configuration @@ -360,14 +402,16 @@ If you like FFS: FFS unterstützen: Include Einschließen +Include: *.doc;*.zip;*.exe\nExclude: *\\tempfolder\\* +Einschließen: *.doc;*.zip;*.exe\nAusschließen: *\\TempOrdner\\* Info Info Information Information Initialization of Recycle Bin failed! It cannot be used! Die Initialisierung des Papierkorbs ist fehlgeschlagen! Er kann nicht verwendet werden! -It was not possible to gain access to Recycle Bin!\n\nIt's likely that you are not using Windows XP. (Probably Vista)\nIf you want this feature included, please contact the author. :) -Die Papierkorbfunktion steht nicht zur Verfügung!\n\nWahrscheinlich ist das aktuelle Betriebssystem nicht Windows XP. (Möglicherweise Vista)\nWenn Sie diese Funktion wirklich benötigen kontaktieren Sie bitte den Autor. :) +It was not possible to initialize the Recycle Bin!\n\nIt's likely that you are not using Windows.\nIf you want this feature included, please contact the author. :) +Die Papierkorbfunktion steht nicht zur Verfügung!\n\nWahrscheinlich ist das aktuelle Betriebssystem nicht Windows.\nWenn Sie diese Funktion wirklich benötigen, kontaktieren Sie bitte den Autor. :) Left directory does not exist. Please select a new one! Verzeichnis auf der linken Seite existiert nicht. Bitte ein anderes auswählen! Left folder: @@ -375,7 +419,7 @@ Linker Ordner: Legend\n Legende\n Load configuration via...\n - this list (press DEL to delete items)\n - drag & drop to this window\n - startup parameter -Lade Konfiguration über...\n - diese Liste (DEL-Taste löscht Einträge)\n - Drag & Drop in dieses Fenster\n - Startupparameter +Lade Konfiguration über...\n - diese Liste (DEL-Taste löscht Einträge)\n - Drag & Drop auf dieses Fenster\n - Startupparameter Load from file... Lade aus Datei... Log-messages:\n------------- @@ -396,8 +440,8 @@ Number of files that will be overwritten Anzahl der Dateien, die überschrieben werden One way -> Nach rechts -> -Only files/directories that pass filtering will be selected for synchronization. -Bei der Synchronisation werden nur die Dateien/Ordner berücksichtigt, die zu\nden Filtereinstellungen passen. +Only files/directories that pass filtering will be selected for synchronization.\nThe filter will be applied to the full name including path prefix. +Bei der Synchronisation werden nur die Dateien/Ordner berücksichtigt, die zu den Filtereinstellungen passen.\nDer Filter wird dabei auf den kompletten Dateinamen einschließlich Pfadprefix angewandt. Open synchronization dialog Zeige Synchronisationseinstellungen Open with Explorer\tD-Click @@ -410,8 +454,6 @@ Pause Pause Please select both left and right directories! Bitte für beide Seiten ein Verzeichnis wählen! -Please select directories for both sides! -Bitte für beide Seiten ein Verzeichnis wählen! Press button to activate filter Auswählen, um Filter zu aktivieren Preview @@ -422,8 +464,6 @@ Quit Beenden Relative path Relativer Pfad -Remaining time: -Verbliebene Zeit: Result Ergebnis Right directory does not exist. Please select a new one! @@ -444,6 +484,8 @@ Select variant: Variante auswählen: Set filter for synchronization Filter einstellen +Shell link +Shell Link Shell script Shell Skript Show files that are different @@ -462,8 +504,8 @@ Silent mode Stiller Modus Size Größe -Source code written completely in C++ utilizing:\n\n MinGW \t\t- Windows port of GNU Compiler Collection\n wxWidgets \t- Open-Source GUI framework\n wxFormBuilder\t- wxWidgets GUI-builder\n CodeBlocks \t- Open-Source IDE\n\n by ZenJu -Sourcecode komplett in C++ geschrieben unter Verwendung von:\n\n MinGW \t\t- Windows-Port der GNU Compiler Collection\n wxWidgets \t- Open-Source GUI-Framework\n wxFormBuilder\t- wxWidgets GUI-Builder\n CodeBlocks \t- Open-Source IDE\n\n ZenJu +Source code written completely in C++ utilizing: +Sourcecode komplett in C++ geschrieben mit Hilfe von: Specify algorithm to test if files are equal:\n\n\t\t Algorithmus wählen, um gleiche Dateien zu erkennen:\n\n\t\t Specify names to be excluded separated by ';'. Wildcards '*' and '?' are supported. Default: \"\"\n @@ -480,6 +522,10 @@ Stop Stop Swap sides Vertausche Seiten +SyncJob.lnk +SyncJob.lnk +SyncJob.sh +SyncJob.sh Synchronization aborted! Synchronisation abgebrochen! Synchronization completed successfully. @@ -490,16 +536,18 @@ Synchronization settings Synchronisationseinstellungen Synchronization status Synchronisation: Status +Synchronize all .doc, .zip and .exe files except everything from folder \"tempfolder\". +Synchronisiere alle .doc, .zip und .exe Dateien mit Ausnahme des Ordners \"TempOrdner\". Synchronize both sides simultaneously: Copy new or updated files in both directions. Beide Seiten gleichzeitig synchronisieren: Neue oder aktualisierte Dateien werden auf die jeweils andere Seite kopiert. Synchronizing... Synchronisiere... -Thanks to Jean-François Hartmann for doing the French translation! -Vielen Dank an Jean-François Hartmann für die französische Übersetzung! The selected file does not contain a valid configuration! Die ausgewählte Datei enthält keine gültige Konfiguration! The selected file does not exist anymore! Die gewählte Datei existiert nicht mehr! +This variant evaluates two equally named files as being equal when they have the same file size AND the same last write date and time. Notice that the file time is allowed to deviate by up to 2 seconds. This ensures synchronization with the lower-precision file system FAT32 works correctly. +Diese Variante identifiziert zwei gleichnamige Dateien als gleich, wenn sie die gleiche Dateigröße haben UND der Zeitpunkt der letzten Änderung derselbe ist. Dabei wird eine Abweichung von bis zu zwei Sekunden toleriert. So ist sichergestellt, dass eine Synchronisation gegen ein FAT32 Dateisystem korrekt funktioniert. Time elapsed: Vergangene Zeit: Total amount of data that will be transferred @@ -524,6 +572,8 @@ Warning Warnung Warning: Synchronization failed for Warnung: Synchronisation fehlgeschlagen für +When \"Compare\" is triggered with this option set the following decision tree is processed: +Nachdem \"Compare\" mit dieser Einstellung gestartet wurde, wird der folgende Entscheidungsbaum abgearbeitet: \n\nContinue with next object, retry or abort comparison? \n\nMit nächstem Objekt fortfahren, wiederholen oder abbrechen? \n\nContinue with next object, retry or abort synchronization? @@ -534,8 +584,8 @@ Warnung: Synchronisation fehlgeschlagen für \n\t\tSynchronisationsrichtung: L: links, R: rechts, N: nichts tun\n \t1: Creates a mirror backup of the left directory\n\t2: Synchronizes all *.doc files from both directories simultaneously\n\n \t1: Erzeugt ein Spiegel-Backup des linken Verzeichnisses\n\t2: Synchronisiert alle *.doc Dateien aus beiden Verzeichnissen\n\n -\tExamples:\n\n\t1.) FreeFileSync -cmp SIZEDATE -cfg RRRRR C:\\Source C:\\Target\n\t2.) FreeFileSync -cmp sizedate -cfg rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n -\tBeispiele:\n\n\t1.) FreeFileSync -cmp SIZEDATE -cfg RRRRR C:\\Quelle C:\\Ziel\n\t2.) FreeFileSync -cmp sizedate -cfg rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n +\tExamples:\n\n\t1.) FreeFileSync -comp SIZEDATE -sync RRRRR C:\\Source C:\\Target\n\t2.) FreeFileSync -comp sizedate -sync rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n +\tBeispiele:\n\n\t1.) FreeFileSync -comp SIZEDATE -sync RRRRR C:\\Quelle C:\\Ziel\n\t2.) FreeFileSync -comp sizedate -sync rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n \tHint: You can easily generate a batch file by chosing \"Create batch job\" from the GUI menubar.\n \tTipp: Eine Batchdatei kann auch über das Menü der graphischen Benutzeroberfläche unter \"Erstelle Batch-Job\" generiert werden.\n \t\tChar 1: Folders/files that exist on left side only\n @@ -547,6 +597,14 @@ Warnung: Synchronisation fehlgeschlagen für \t\tChar 4: Files that exist on both sides, right one is newer\n \t\t4. Zeichen: Dateien, die auf beiden Seiten existieren; rechte Datei ist neuer\n \t\tChar 5: Files that exist on both sides and are different\n -\t\t5. Zeichen: Dateien, die auf beiden Seiten existieren und verschieden sind\n\n +\t\t5. Zeichen: Dateien, die auf beiden Seiten existieren und verschieden sind\n +by ZenJu +von ZenJu +different +verschieden +file exists on both sides +Datei ex. auf beiden Seiten +on one side only +nur auf einer Seite |> file on right side only\n |> Datei existiert nur rechts\n diff --git a/japanese.lng b/japanese.lng new file mode 100644 index 00000000..cf74e30f --- /dev/null +++ b/japanese.lng @@ -0,0 +1,606 @@ + MinGW \t- Windows port of GNU Compiler Collection\n wxWidgets \t- Open-Source GUI framework\n wxFormBuilder\t- wxWidgets GUI-builder\n CodeBlocks \t- Open-Source IDE + MinGW \t- Windows port of GNU Compiler Collection\n wxWidgets \t- Open-Source GUI framework\n wxFormBuilder\t- wxWidgets GUI-builder\n CodeBlocks \t- Open-Source IDE + Time: + 時間: + Byte + バイト + GB + GB + MB + MB + PB + PB + TB + TB + You may try to synchronize remaining items again (WITHOUT having to re-compare)! + 残っているファイルは、再び同期することができます (再比較とは別の動作)! + already exists. Overwrite? + すでに存在します.. 上書きしますか? + directories + ディレクトリ + directory + ディレクトリ + does not exist. + 存在しません + file, + つのファイル, + files, + つのファイル, + item(s):\n\n + つのアイテム(複):\n\n + kB + kB + of + / + overwriting + 上書き中 + row in view + 列を表示 + rows in view + 列を表示 + to + から + to recycle bin! + ゴミ箱に移動! +!= files are different\n +!= ファイルは異なっています\n +&Abort +情報(&A) +&About... +情報(&A)... +&Advanced +拡張(&A) +&Back +戻る(&B) +&Cancel +キャンセル(&C) +&Compare +比較(&C) +&Continue +続行(&C) +&Create +作成(&C) +&Create batch job +一括ジョブを作成(&C) +&Default +デフォルト(&D) +&Export file list +ファイル一覧をエクスポート(&E) +&File +ファイル(&F) +&Help +ヘルプ(&H) +&Language +使用言語(&L) +&OK +&OK +&Pause +一時停止(&P) +&Quit +終了(&Q) +&Retry +再試行(&R) +&Start +開始(&S) +&Synchronize +同期(&S) +(-) filtered out from sync-process\n +(-) 同期処理対象から除外\n +, +. +- different +- 差異あり +- different (same date, different size) +- 差異あり(日付は同一、サイズが異なります) +- equal +- 同一 +- exists left only +- 左側にのみ存在 +- exists right only +- 右側にのみ存在 +- left +- 左側 +- left newer +- 左側の方が新しい +- right +- 右側 +- right newer +- 右側の方が新しい +- same date (different size) +- 日付は同一(サイズに差異あり) +------------------------------------------------- +----------------------------------------------------- +---------\n +-----------\n +-Open-Source file synchronization- +-Open-Source ファイル同期ツール- +. +, +1. Enter full file or directory names separated by ';'.\n2. Wildcard characters '*' and '?' are supported. +1. ファイル/ディレクトリ名を ' ; ' で区切って入力してください\n2. ワイルドカード ' * ' と ' ? ' に対応しています。 +: check file content\n +: ファイル内容を確認\n +: check filesize and date\n\t\t +: ファイルサイズと日付を確認\n\t\t +<< left file is newer\n +<< 左側の方が新しい\n +<Directory> +<ディレクトリ> +<left directory> +<左のディレクトリ> +<right directory> +<右のディレクトリ> +<| file on left side only\n +<| 左側のみに存在するファイル\n +== files are equal\n\n +== 同じ内容のファイル\n\n +>> right file is newer\n +>> 右側の方が新しい\n +Abort +中断 +Abort requested: Waiting for current operation to finish... +ユーザによる中断: 現在の処理を終了しています.. お待ちください... +Aborted +中断 +About +情報 +Action +操作 +All items have been synchronized! +すべてのアイテムは同期されました! +An error occured +エラーが発生 +An exception occured! +例外が発生しました! +As a result 6 different status can be returned to categorize all files: +すべてのファイルのカテゴリ別に、6 つの異なるステータスを結果に返す事が出来ます。 +As a result the files are separated into the following categories: +ファイルは以下のカテゴリに分類されます: +As the name suggests, two files which share the same name are marked as equal if and only if they have the same content. This option is useful for consistency checks rather than backup operations. Therefore the file times are not taken into account at all.\n\nWith this option enabled the decision tree is smaller: +このオプションでは、同じ名前を共有するファイルで内容が同じ場合は、同一として扱われます。 バックアップ操作より、むしろ整合性のチェックを行う時に役立つオプションです。 従ってファイルの日時については全く考慮されていません。\n\n設定が有効な時は、ツリー表示が小さくなります。 +Assemble a batch file with the following settings. To start synchronization in batch mode simply execute this file or schedule it in your operating system's task planner. +以下の設定で一括処理(バッチ)ファイルを作成します。使用方法は、そのままファイルを実行するか、OS のタスクスケジューラを利用して実行することもできます。 +Batch file created successfully! +バッチファイルが作成されました! +Big thanks for localizing FreeFileSync goes out to: +FreeFileSync のローカライズへの協力に感謝します: +Build: +ビルド: +Choose to hide filtered files/directories from list +リストから除外したいファイル/ディレクトリを選択 +Comma separated list +カンマ区切り +Compare both sides +両方を比較 +Compare by \"File content\" +\"ファイルの内容\" を比較 +Compare by \"File size and date\" +\"ファイルサイズと日付\" を比較 +Compare by... +比較対象... +Comparing content +内容の比較中 +Comparing content of files +ファイルの内容を比較中 +Comparing... +比較中... +Completed +完了しました +Configuration +構成設定 +Configuration loaded! +構成設定を読み込み中! +Configuration overview: +構成設定の概要: +Configuration saved! +構成設定は保存されました! +Configure filter +フィルター設定 +Configure filter... +フィルター設定... +Configure your own synchronization rules. +あなたの設定した同期規則 +Confirm +確認 +Continue +続行 +Continue on error +エラーでも続行 +Continue on next errors +次のエラーまで続行 +Copy from left to right +左から右にコピー +Copy from left to right overwriting +左から右に上書きコピー +Copy from right to left +右から左にコピー +Copy from right to left overwriting +右から左に上書きコピー +Copy to clipboard\tCTRL+C +クリップボードにコピー\tCTRL+C +Copying file +ファイルをコピー中 +Could not create file +ファイルを作成できません +Could not open configuration file +構成ファイルを開けませんでした。 +Could not open file: +ファイルを開けません: +Could not read configuration file +構成ファイルを読み込めません +Could not read language file +言語ファイルを読み込めません +Could not retrieve file info for: +ファイル情報を取得できません: +Could not set working directory to directory containing executable file! +実行ファイルが含まれるディレクトリは、作業ディレクトリとして利用できません! +Could not write configuration file +構成ファイルに書き込めませんでした。 +Could not write to +書き込みに失敗 +Create a batch job +一括ジョブを作成 +Create: +作成: +Creating folder +作成するフォルダ +Current operation: +現在の操作: +Custom +カスタム +DECISION TREE +[判定ツリー] +Data remaining: +残りのデータ: +Data: +データ: +Date +データ +Delete files/folders existing on left side only +左側のみに存在するファイル/フォルダを削除 +Delete files/folders existing on right side only +右側のみに存在するファイル/フォルダを削除 +Delete files\tDEL +ファイルを削除\tDEL +Delete: +削除: +Deleting file +ファイルを削除中 +Deleting folder +フォルダを削除中 +Directory +ディレクトリ +Directory on the left does not exist. Please select a new one! +左側のディレクトリには存在しません、新たに選択してください! +Directory on the right does not exist. Please select a new one! +右側のディレクトリには存在しません、新たに選択してください! +Displays help on the command line parameters\n +コマンドラインパラメータを表示\n +Do not show graphical status and error messages but write to a logfile instead +進捗状況、及びエラーを表示しないで、代わりにログファイルに書き込む +Do not show graphical status and error messages but write to a logfile instead.\n\n +進捗状況、及びエラーを表示しないで、代わりにログファイルに書き込む.\n\n +Do nothing +何もしない +Do you really want to delete the following objects(s)? +本当に以下のオブジェクトを削除しますか? +Do you really want to move the following objects(s) to the recycle bin? +本当に以下のオブジェクトをゴミ箱に移動しますか? +Donate with PayPal +PayPal から寄付する +Drag && drop +ドラッグ && ドロップ +Email: +E-メール: +Error +エラー +Error adapting modification time of file +ファイルの更新時間の適合エラー +Error converting FILETIME to SYSTEMTIME +FILETIME から SYSTEMTIME への変換エラー +Error converting FILETIME to local FILETIME +FILETIME から local FILETIME への変換エラー +Error copying file +ファイルのコピーに失敗 +Error creating directory +ディレクトリの作成に失敗 +Error deleting directory +ディレクトリの削除に失敗 +Error deleting file +ファイルの削除に失敗 +Error moving file +ファイルの移動に失敗 +Error parsing configuration file +構成ファイルの構文に誤りがあります +Error reading file: +ファイル読み込みエラー: +Error traversing directory +ディレクトリの移動エラー +Error when converting int to wxString +wxString の変換エラー +Error when converting wxString to double +wxString の変換エラー(double) +Error when converting wxString to long +wxString の変換エラー(long) +Error: Source directory does not exist anymore: +エラー: ソースディレクトリが存在しません: +Example +例 +Exclude +除外 +Feedback and suggestions are welcome at: +フィードバック、提案など: +File content +ファイルの内容 +File list exported! +ファイル一覧のエクスポートが完了! +File size and date +ファイルサイズと日付 +Filename +ファイル名 +Files are found equal if\n - file content\nis the same. +ファイルが同様だった場合\n - ファイル内容\nで判断する +Files are found equal if\n - filesize\n - last write time (UTC) and date\nare the same. +ファイルが同様だった場合\n - ファイルサイズ\n - 最終書き込み時間(UTC)と日付\nで判断する +Files remaining: +残りのファイル: +Files that exist on both sides and have different content +両側に存在するが、内容が異なるファイル +Files that exist on both sides, have same date but different filesizes +両側に存在して、日付は同じだが、ファイルサイズが異なるファイル +Files that exist on both sides, left one is newer +両側に存在するが、左側の方がより新しい +Files that exist on both sides, right one is newer +両側に存在するが、右側の方がより新しい +Files/folders remaining: +ファイル/フォルダのリネーム: +Files/folders scanned: +ファイル/フォルダのスキャン: +Files/folders that exist on left side only +左側のみに存在するファイル/フォルダ +Files/folders that exist on right side only +右側のみに存在するファイル/フォルダ +Filter +フィルター +Filter active: Press again to deactivate +フィルター有効化: 再度押すと無効化 +Filter files +ファイルフィルター +Filter manually +手動フィルター +Filter view +表示フィルター +FreeFileSync (Date: +FreeFileSync (日付: +FreeFileSync - Folder Comparison and Synchronization +FreeFileSync - Folder Comparison and Synchronization +FreeFileSync Batch Job +FreeFileSync 一括ジョブ +FreeFileSync at Sourceforge +FreeFileSync at Sourceforge +FreeFileSync configuration +FreeFileSync 構成設定 +Help +ヘルプ +Hide filtered items +適合するアイテムを非表示にする +Hide further error messages during the current process and continue +現在の処理を続行する間は、以降のエラーメッセージを表示しない +Hides error messages during synchronization:\nThey are collected and shown as a list at the end of the process +同期処理中のエラーメッセージを非表示にする:\n非表示にしたメッセージは、処理の終了後に一覧表示されます。 +Hints: +ヒント: +Homepage: +ホームページ: +If errors occur during folder comparison or synchronization they are ignored and the process continues.\n +フォルダの比較、または同期処理中のエラーは無視して処理を続行する\n +If you like FFS: +FFS が気に入った場合: +Include +含める +Include: *.doc;*.zip;*.exe\nExclude: *\\tempfolder\\* +含める: *.doc;*.zip;*.exe\n除外: *\\一時フォルダ\\* +Info +情報 +Information +インフォメーション +Initialization of Recycle Bin failed! It cannot be used! +ゴミ箱の初期化に失敗しました! 使用できない状態です! +It was not possible to initialize the Recycle Bin!\n\nIt's likely that you are not using Windows.\nIf you want this feature included, please contact the author. :) +ゴミ箱を初期化することが出来ませんでした!\n\n使用している OS が、Windows 以外の OS です。\nこの機能を使用したい場合は、作者までご連絡ください :) +Left directory does not exist. Please select a new one! +左のディレクトリは存在しません、再選択してください! +Left folder: +左側フォルダ: +Legend\n +履歴\n +Load configuration via...\n - this list (press DEL to delete items)\n - drag & drop to this window\n - startup parameter +構成ファイルの読み込み...\n - リスト (DEL-でアイテムを削除)\n - ウィンドウにドラッグ & ドロップ\n - 起動時のパラメータ +Load from file... +ファイルから読み込み... +Log-messages:\n------------- +ログメッセージ:\n--------------- +Mirror backup of left folder: Right folder will be overwritten and exactly match left folder after synchronization. +左側フォルダをミラーリングバックアップ: 同期完了後は、左側フォルダに合わせて右側フォルダは上書きされます。 +Move files to Recycle Bin instead of deleting or overwriting them directly.\n +直接上書きするか、または上書きする代わりにファイルをゴミ箱に移動する\n +Not all items were synchronized! Have a look at the list. +すべてのアイテムは同期されていません! 詳細はリストをご覧ください。 +Nothing to synchronize. Both directories adhere to the sync-configuration! +同期対象がありません。両方のディレクトリに対する同期設定を確認してください! +Number of files and directories that will be created +作成されたファイルとディレクトリ数 +Number of files and directories that will be deleted +削除されたファイルとディレクトリ数 +Number of files that will be overwritten +上書きされたファイル数 +One way -> +一方通行 -> +Only files/directories that pass filtering will be selected for synchronization.\nThe filter will be applied to the full name including path prefix. +選択されたファイル/ディレクトリを同期処理する時だけフィルタリングされます。\nこのフィルターは、接頭語を含むパスと完全な名前にのみ適用されます。 +Open synchronization dialog +同期ダイアログを開く +Open with Explorer\tD-Click +エクスプローラで開く\tD-Click +Operation aborted! +操作の中断! +Operation: +操作: +Pause +一時停止 +Please select both left and right directories! +左と右両方のディレクトリを選択してください! +Press button to activate filter +ボタンをクリックで有効化 +Preview +プレビュー +Published under the GNU General Public License: +Published under the GNU General Public License: +Quit +終了 +Relative path +相対パス +Result +結果 +Right directory does not exist. Please select a new one! +右側のディレクトリが存在しません。再選択してください! +Right folder: +右側フォルダ: +Save current configuration to file +現在の設定をファイルに保存 +Saved aborted! +保存の中断! +Scanning +スキャン +Scanning... +スキャン中... +Select a folder +フォルダを選択 +Select variant: +変数を選択: +Set filter for synchronization +同期フィルターを設定 +Shell link +Shell リンク +Shell script +Shell スクリプト +Show files that are different +差異のあるファイルを表示 +Show files that are equal +同じ内容のファイルを表示 +Show files that are newer on left +左側の新しいファイルを表示 +Show files that are newer on right +右側の新しいファイルを表示 +Show files that exist on left side only +左側のみに存在するファイルを表示 +Show files that exist on right side only +右側のみに存在するファイルを表示 +Silent mode +サイレントモード +Size +サイズ +Source code written completely in C++ utilizing: +ソースコードは C++ で書かれ、コンパイルされています: +Specify algorithm to test if files are equal:\n\n\t\t +指定したアルゴリズムで同等のファイルをテスト:\n\n\t\t +Specify names to be excluded separated by ';'. Wildcards '*' and '?' are supported. Default: \"\"\n +名前を指定する時は、 ' ; ' で区切ってください。また、デフォルトでワイルドカード ' * ' と ' ? ' に対応しています: \"\"\n +Specify names to be included separated by ';'. Wildcards '*' and '?' are supported. Default: \"*\"\n +Einzuschließende Namen, getrennt durch ';' angeben. Platzhalter '*' und '?' werden unterstützt. Standard: \"*\"\n +Specify the sync-direction used for each type of file by a string of five chars:\n\n +同期方向を指定する場合は、各ファイル形式に5 つの文字列を使用してください:\n\n +Start +開始 +Start synchronization +同期の開始 +Stop +停止 +Swap sides +パネルを入れ替え +SyncJob.lnk +SyncJob.lnk +SyncJob.sh +SyncJob.sh +Synchronization aborted! +同期処理を中断! +Synchronization completed successfully. +同期処理はすべて正常に完了しました。 +Synchronization completed with errors! +同期処理は、エラーで終了しています! +Synchronization settings +同期処理設定 +Synchronization status +同期処理: ステータス +Synchronize all .doc, .zip and .exe files except everything from folder \"tempfolder\". +.doc, .zip と .exe ファイルを除いて、\"一時フォルダ\" からすべてのファイルを同期 +Synchronize both sides simultaneously: Copy new or updated files in both directions. +両側を同時に処理: 両方のディレクトリのより新しいファイルをコピー +Synchronizing... +同期処理中... +The selected file does not contain a valid configuration! +選択されたファイルには有効な構成が含まれていません! +The selected file does not exist anymore! +選択されたファイルはそれ以上存在しません! +This variant evaluates two equally named files as being equal when they have the same file size AND the same last write date and time. Notice that the file time is allowed to deviate by up to 2 seconds. This ensures synchronization with the lower-precision file system FAT32 works correctly. +この変数では、ふたつの同名ファイルが存在した場合、 それぞれのファイルサイズと最終更新日付/時間を比較します。\nファイル時間の差異が 2 秒以内の場合は検出されないということに注意してください。 (これは、FAT32システムで正確に同期を行うことができる最小値です) +Time elapsed: +経過時間: +Total amount of data that will be transferred +転送されたデータの総量 +Total time: +合計時間: +Two way <-> +両方向 <-> +Unable to create logfile! +ログファイルを作成出来ません! +Unable to initialize Recycle Bin! +ゴミ箱の初期化が出来ません! +Unable to load Resources.dat! +Resources.dat を読み込むことが出来ません! +Update: +アップデート: +Use Recycle Bin +ゴミ箱を使用 +Use Recycle Bin when deleting or overwriting files during synchronization +同期処理の間、ファイルの上書き/削除をする時にゴミ箱を使用 +Warning +警告 +Warning: Synchronization failed for +警告: 同期処理に失敗 +When \"Compare\" is triggered with this option set the following decision tree is processed: +この設定で \"比較\" トリガが実行された場合は、以下のツリーに従って処理されていきます。 +\n\nContinue with next object, retry or abort comparison? +\n\n次のオブジェクトの比較を続行しますか? 中断しますか? +\n\nContinue with next object, retry or abort synchronization? +\n\n次のオブジェクトの同期を続行しますか? 中断しますか? +\n\nInformation: If you skip the error and continue or abort a re-compare will be necessary! +\n\nインフォメーション: エラーをスキップして続行/中断した場合、再比較を行う必要があります! +\n\t\tSync-direction: L: left, R: right, N: none\n +\n\t\t同期方向: L: 左側, R: 右側, N: なし\n +\t1: Creates a mirror backup of the left directory\n\t2: Synchronizes all *.doc files from both directories simultaneously\n\n +\t1: 左側ディレクトリのミラーバックアップを作成\n\t2: 両側ディレクトリのすべての*.doc ファイルの同期を実行\n\n +\tExamples:\n\n\t1.) FreeFileSync -comp SIZEDATE -sync RRRRR C:\\Source C:\\Target\n\t2.) FreeFileSync -comp sizedate -sync rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n +\t例:\n\n\t1.) FreeFileSync -comp SIZEDATE -sync RRRRR C:\\Source C:\\Target\n\t2.) FreeFileSync -comp sizedate -sync rlrln c:\\dir1 c:\\dir2 -incl *.doc\n\n +\tHint: You can easily generate a batch file by chosing \"Create batch job\" from the GUI menubar.\n +\tヒント: メニューバーの\"一括ジョブを作成\" を選択することで、簡単にバッチファイルを作成することができます。\n +\t\tChar 1: Folders/files that exist on left side only\n +\t\t1. 文字: 左側のみ存在するファイル/フォルダ\n +\t\tChar 2: Folders/files that exist on right side only\n +\t\t2. 文字: 右側のみ存在するファイル/フォルダ\n +\t\tChar 3: Files that exist on both sides, left one is newer\n +\t\t3. 文字: 両側にファイルが存在して、左側に、より新しいファイル\n +\t\tChar 4: Files that exist on both sides, right one is newer\n +\t\t4. 文字: 両側にファイルが存在して、右側に、より新しいファイル\n +\t\tChar 5: Files that exist on both sides and are different\n +\t\t5. 文字: 両側にファイルが存在して、異なるファイル\n\n +by ZenJu +by ZenJu +different +差異あり +file exists on both sides +両側に存在するファイル +on one side only +片側のみ +|> file on right side only\n +|> 右側のみに存在するファイル\n diff --git a/library/Batch.ico b/library/Batch.ico Binary files differnew file mode 100644 index 00000000..580be81f --- /dev/null +++ b/library/Batch.ico diff --git a/library/CustomGrid.cpp b/library/CustomGrid.cpp index 93f2107a..86a121d3 100644 --- a/library/CustomGrid.cpp +++ b/library/CustomGrid.cpp @@ -12,6 +12,7 @@ public: CustomGridTableBase(int numRows, int numCols) : wxGridStringTable(numRows, numCols), lightBlue(80, 110, 255), + lightGrey(212, 208, 200), gridIdentifier(0), gridRefUI(0), gridData(0), @@ -233,18 +234,30 @@ public: } //########################################################################### + enum RowColor {BLUE, GREY, NONE}; - bool markThisRow(int row) //rows that are filtered out are shown in different color + inline //redundant command + RowColor getRowColor(int row) //rows that are filtered out are shown in different color { if (gridRefUI) { if (unsigned(row) < gridRefUI->size()) { - if (!(*gridData)[(*gridRefUI)[row]].selectedForSynchronization) - return true; + const FileCompareLine cmpLine = (*gridData)[(*gridRefUI)[row]]; + + //mark filtered rows + if (!cmpLine.selectedForSynchronization) + return BLUE; + //mark directories + else if (gridIdentifier == 1 && cmpLine.fileDescrLeft.objType == TYPE_DIRECTORY) + return GREY; + else if (gridIdentifier == 2 && cmpLine.fileDescrRight.objType == TYPE_DIRECTORY) + return GREY; + else + return NONE; } } - return false; + return NONE; } @@ -262,16 +275,23 @@ public: result = attr; } - if (markThisRow(row)) + RowColor color = getRowColor(row); + if (color == BLUE) result->SetBackgroundColour(lightBlue); + else if (color == GREY) + result->SetBackgroundColour(lightGrey); else result->SetBackgroundColour(*wxWHITE); } else { result = new wxGridCellAttr; - if (markThisRow(row)) + + RowColor color = getRowColor(row); + if (color == BLUE) result->SetBackgroundColour(lightBlue); + else if (color == GREY) + result->SetBackgroundColour(lightGrey); } return result; @@ -279,6 +299,7 @@ public: private: wxColour lightBlue; + wxColour lightGrey; int gridIdentifier; GridView* gridRefUI; //(very fast) access to underlying grid data :) FileCompareResult* gridData; diff --git a/library/globalFunctions.cpp b/library/globalFunctions.cpp index d4579312..67b56819 100644 --- a/library/globalFunctions.cpp +++ b/library/globalFunctions.cpp @@ -11,7 +11,7 @@ int globalFunctions::round(const double d) string globalFunctions::numberToString(const unsigned int number) { char result[100]; - sprintf( result, "%u", number); + sprintf(result, "%u", number); return string(result); } @@ -19,7 +19,7 @@ string globalFunctions::numberToString(const unsigned int number) string globalFunctions::numberToString(const int number) { char result[100]; - sprintf( result, "%d", number); + sprintf(result, "%d", number); return string(result); } @@ -27,7 +27,7 @@ string globalFunctions::numberToString(const int number) string globalFunctions::numberToString(const float number) { char result[100]; - sprintf( result, "%f", number); + sprintf(result, "%f", number); return string(result); } @@ -50,7 +50,6 @@ wxString globalFunctions::numberToWxString(const float number) } -inline int globalFunctions::stringToInt(const string& number) { return atoi(number.c_str()); diff --git a/library/misc.cpp b/library/misc.cpp index 71bbe608..5fbeb655 100644 --- a/library/misc.cpp +++ b/library/misc.cpp @@ -4,15 +4,52 @@ #include "resources.h" #include "globalFunctions.h" + const string CustomLocale::FfsLanguageDat = "language.dat"; + void exchangeEscapeChars(wxString& data) { - data.Replace(wxT("\\\\"), wxT("\\")); - data.Replace(wxT("\\n"), wxT("\n")); - data.Replace(wxT("\\t"), wxT("\t")); - data.Replace(wxT("\"\""), wxT("""")); - data.Replace(wxT("\\\""), wxT("\"")); + wxString output; + + const wxChar* input = data.c_str(); + + wxChar value; + while ((value = *input) != wxChar(0)) + { + //read backslash + if (value == wxChar('\\')) + { + //read next character + ++input; + value = *input; + if (value == wxChar(0)) + break; + + switch (value) + { + case wxChar('\\'): + output+= wxChar('\\'); + break; + case wxChar('n'): + output+= wxChar('\n'); + break; + case wxChar('t'): + output+= wxChar('\t'); + break; + case wxChar('\"'): + output+= wxChar('\"'); + break; + default: + output+= value; + } + } + else + output+= value; + + ++input; + } + data = output; } @@ -69,8 +106,11 @@ void CustomLocale::loadLanguageFile(int language) case wxLANGUAGE_FRENCH: languageFile = "french.lng"; break; + case wxLANGUAGE_JAPANESE: + languageFile = "japanese.lng"; + break; default: - languageFile = string(); + languageFile.clear(); currentLanguage = wxLANGUAGE_ENGLISH; } @@ -91,7 +131,7 @@ void CustomLocale::loadLanguageFile(int language) //Linux: 0xa \n //Mac: 0xd \r //Win: 0xd 0xa \r\n <- language files are in Windows format - while (langFile.getline(temp, bufferSize, 0xd)) //specify delimiter explicitely + while (langFile.getline(temp, bufferSize, 0xd)) //specify delimiter explicitly { langFile.get(); //discard the 0xa character diff --git a/library/multithreading.cpp b/library/multithreading.cpp index 19f83b94..78077f1e 100644 --- a/library/multithreading.cpp +++ b/library/multithreading.cpp @@ -1,8 +1,36 @@ #include "multithreading.h" #include <wx/utils.h> +#include <wx/app.h> +#include <wx/timer.h> + //#include "windows.h" //MessageBox(0, "hi", "", 0); +void updateUiNow() +{ + //process UI events and prevent application from "not responding" -> NO performance issue! + wxTheApp->Yield(); + + // while (wxTheApp->Pending()) + // wxTheApp->Dispatch(); +} + + +bool updateUiIsAllowed() +{ + static wxLongLong lastExec = 0; + + wxLongLong newExec = wxGetLocalTimeMillis(); + + if (newExec - lastExec >= UI_UPDATE_INTERVAL) //perform ui updates not more often than necessary + { + lastExec = newExec; + return true; + } + return false; +} + + /*choreography: ------------- --------------- @@ -149,10 +177,10 @@ void UpdateWhileExecuting::execute(StatusUpdater* statusUpdater) while (receivingResult.WaitTimeout(UI_UPDATE_INTERVAL) == wxCOND_TIMEOUT) { - statusUpdater->triggerUI_Refresh(true); //ATTENTION: Exception "AbortThisProcess" may be thrown here!!! + statusUpdater->requestUiRefresh(true); //ATTENTION: Exception "AbortThisProcess" may be thrown here!!! if (workDone == true) //workaround for a bug in wxWidgets v2.8.9 class wxCondition: signals might get lost - break; //no mutex for workDone needed here: it is changed only when maintread is in WaitTimeout() + break; //no mutex for workDone needed here: it is changed only when mainthread is in WaitTimeout() } } diff --git a/library/multithreading.h b/library/multithreading.h index feecce5f..161fd687 100644 --- a/library/multithreading.h +++ b/library/multithreading.h @@ -4,6 +4,12 @@ #include <wx/string.h> #include <wx/thread.h> +const int UI_UPDATE_INTERVAL = 100; //perform ui updates not more often than necessary, 100 seems to be a good value with only a minimal performance loss + +bool updateUiIsAllowed(); //test if a specific amount of time is over +void updateUiNow(); //do the updating + + //interface for status updates (can be implemented by UI or commandline) //overwrite virtual methods for respective functionality class StatusUpdater @@ -13,16 +19,24 @@ public: abortionRequested(false) {} virtual ~StatusUpdater() {} - //these four methods have to be implemented in the derived classes to handle error and status information + //these methods have to be implemented in the derived classes to handle error and status information virtual void updateStatusText(const wxString& text) = 0; virtual void initNewProcess(int objectsTotal, double dataTotal, int processID) = 0; //informs about the total amount of data that will be processed from now on virtual void updateProcessedData(int objectsProcessed, double dataProcessed) = 0; //called periodically after data was processed virtual int reportError(const wxString& text) = 0; - //this method is triggered repeatedly and can be used to refresh the ui by dispatching pending events - virtual void triggerUI_Refresh(bool asyncProcessActive = false) = 0; + //this method is triggered repeatedly by requestUiRefresh() and can be used to refresh the ui by dispatching pending events + virtual void forceUiRefresh() = 0; + void requestUiRefresh(bool asyncProcessActive = false) + { + if (updateUiIsAllowed()) //test if specific time span between ui updates is over + forceUiRefresh(); - void requestAbortion() //opportunity to abort must be implemented in a frequently executed method like triggerUI_Refresh() + if (abortionRequested && !asyncProcessActive) + abortThisProcess(); //abort can be triggered by requestAbortion() + } + + void requestAbortion() //opportunity to abort must be implemented in a frequently executed method like requestUiRefresh() { //currently used by the UI status information screen, when button "Abort is pressed" abortionRequested = true; } @@ -31,12 +45,12 @@ public: static const int retry = -2; protected: + virtual void abortThisProcess() = 0; + bool abortionRequested; }; -const int UI_UPDATE_INTERVAL = 100; //perform ui updates not more often than necessary, 100 seems to be a good value with only a minimal performance loss - class WorkerThread; diff --git a/library/pch.h b/library/pch.h new file mode 100644 index 00000000..37c3383f --- /dev/null +++ b/library/pch.h @@ -0,0 +1,98 @@ +#ifndef FFS_PRECOMPILED_HEADER +#define FFS_PRECOMPILED_HEADER + +DO NOT USE THIS FILE: FOR SOME REASON IT CORRUPTS COMPILATION!!! + +//##################################################### +// basic wxWidgets headers +#ifndef WX_PRECOMP +#define WX_PRECOMP +#endif + +#include <wx/wxprec.h> + +#ifndef WX_PRECOMP +#include <wx/wx.h> +#endif + +//##################################################### +// #include other rarely changing headers here + +//STL headers +#include <vector> +#include <set> +#include <string> +#include <stack> +#include <algorithm> +#include <map> + +//C headers +#include <fstream> + +#ifdef FFS_LINUX +#include <utime.h> +#endif //FFS_LINUX + +//other wxWidgets headers +#include <wx/grid.h> +#include <sys/stat.h> +#include <wx/animate.h> +#include <wx/app.h> +#include <wx/arrstr.h> +#include <wx/bitmap.h> +#include <wx/bmpbuttn.h> +#include <wx/button.h> +#include <wx/checkbox.h> +#include <wx/choice.h> +#include <wx/clipbrd.h> +#include <wx/cmdline.h> +#include <wx/colour.h> +#include <wx/config.h> +#include <wx/dc.h> +#include <wx/dialog.h> +#include <wx/dir.h> +#include <wx/dnd.h> +#include <wx/file.h> +#include <wx/filename.h> +#include <wx/filepicker.h> +#include <wx/font.h> +#include <wx/frame.h> +#include <wx/gauge.h> +#include <wx/gdicmn.h> +#include <wx/grid.h> +#include <wx/hyperlink.h> +#include <wx/icon.h> +#include <wx/image.h> +#include <wx/intl.h> +#include <wx/log.h> +#include <wx/menu.h> +#include <wx/msgdlg.h> +#include <wx/panel.h> +#include <wx/radiobut.h> +#include <wx/settings.h> +#include <wx/sizer.h> +#include <wx/statbmp.h> +#include <wx/statbox.h> +#include <wx/statline.h> +#include <wx/stattext.h> +#include <wx/stdpaths.h> +#include <wx/stopwatch.h> +#include <wx/stream.h> +#include <wx/string.h> +#include <wx/textctrl.h> +#include <wx/thread.h> +#include <wx/utils.h> +#include <wx/wfstream.h> +#include <wx/zipstrm.h> +#include <wx/scrolwin.h> +#include <wx/notebook.h> + +//other +#include "tinyxml/tinyxml.h" + +#ifdef FFS_WIN +#include <windows.h> +#endif //FFS_WIN +//##################################################### + +#endif //FFS_PRECOMPILED_HEADER diff --git a/library/resources.cpp b/library/resources.cpp index 6e5feaf7..d2dc36e8 100644 --- a/library/resources.cpp +++ b/library/resources.cpp @@ -19,8 +19,8 @@ const wxChar* GlobalResources::thousandsSeparator = wxEmptyString; //command line parameters -const wxChar* GlobalResources::paramCompare = wxT("cmp"); -const wxChar* GlobalResources::paramCfg = wxT("cfg"); +const wxChar* GlobalResources::paramCompare = wxT("comp"); +const wxChar* GlobalResources::paramSync = wxT("sync"); const wxChar* GlobalResources::paramInclude = wxT("incl"); const wxChar* GlobalResources::paramExclude = wxT("excl"); const wxChar* GlobalResources::paramContinueError = wxT("continue"); @@ -33,12 +33,15 @@ const wxChar* GlobalResources::valueContent = wxT("CONTENT"); map<wxString, wxBitmap*> GlobalResources::bitmapResource; -wxBitmap* GlobalResources::bitmapLeftArrow = 0; -wxBitmap* GlobalResources::bitmapRightArrow = 0; -wxBitmap* GlobalResources::bitmapNoArrow = 0; +wxBitmap* GlobalResources::bitmapArrowLeft = 0; +wxBitmap* GlobalResources::bitmapArrowRight = 0; +wxBitmap* GlobalResources::bitmapArrowLeftCr = 0; +wxBitmap* GlobalResources::bitmapArrowRightCr = 0; +wxBitmap* GlobalResources::bitmapArrowNone = 0; wxBitmap* GlobalResources::bitmapStartSync = 0; wxBitmap* GlobalResources::bitmapStartSyncDis = 0; -wxBitmap* GlobalResources::bitmapDelete = 0; +wxBitmap* GlobalResources::bitmapDeleteLeft = 0; +wxBitmap* GlobalResources::bitmapDeleteRight = 0; wxBitmap* GlobalResources::bitmapEmail = 0; wxBitmap* GlobalResources::bitmapAbout = 0; wxBitmap* GlobalResources::bitmapWebsite = 0; @@ -90,12 +93,15 @@ wxIcon* GlobalResources::programIcon = 0; void GlobalResources::loadResourceFiles() { //map, allocate and initialize pictures - bitmapResource[wxT("left arrow.png")] = (bitmapLeftArrow = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("right arrow.png")] = (bitmapRightArrow = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("no arrow.png")] = (bitmapNoArrow = 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)); + bitmapResource[wxT("right arrow create.png")]= (bitmapArrowRightCr = new wxBitmap(wxNullBitmap)); + bitmapResource[wxT("no arrow.png")] = (bitmapArrowNone = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("start sync.png")] = (bitmapStartSync = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("start sync dis.png")] = (bitmapStartSyncDis = new wxBitmap(wxNullBitmap)); - bitmapResource[wxT("delete.png")] = (bitmapDelete = new wxBitmap(wxNullBitmap)); + bitmapResource[wxT("left delete.png")] = (bitmapDeleteLeft = new wxBitmap(wxNullBitmap)); + bitmapResource[wxT("right delete.png")] = (bitmapDeleteRight = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("email.png")] = (bitmapEmail = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("about.png")] = (bitmapAbout = new wxBitmap(wxNullBitmap)); bitmapResource[wxT("website.png")] = (bitmapWebsite = new wxBitmap(wxNullBitmap)); @@ -163,7 +169,7 @@ void GlobalResources::loadResourceFiles() animationSync->LoadFile(wxT("Resources.a02")); #ifdef FFS_WIN - programIcon = new wxIcon(wxT("winIcon")); + programIcon = new wxIcon(wxT("ffsIcon1")); #else #include "FreeFileSync.xpm" programIcon = new wxIcon(FreeFileSync_xpm); diff --git a/library/resources.h b/library/resources.h index de70198f..5f97e582 100644 --- a/library/resources.h +++ b/library/resources.h @@ -22,7 +22,7 @@ public: //command line parameters static const wxChar* paramCompare; - static const wxChar* paramCfg; + static const wxChar* paramSync; static const wxChar* paramInclude; static const wxChar* paramExclude; static const wxChar* paramContinueError; @@ -33,12 +33,15 @@ public: static const wxChar* valueContent; //image resource objects - static wxBitmap* bitmapLeftArrow; - static wxBitmap* bitmapRightArrow; - static wxBitmap* bitmapNoArrow; + static wxBitmap* bitmapArrowLeft; + static wxBitmap* bitmapArrowRight; + static wxBitmap* bitmapArrowLeftCr; + static wxBitmap* bitmapArrowRightCr; + static wxBitmap* bitmapArrowNone; static wxBitmap* bitmapStartSync; static wxBitmap* bitmapStartSyncDis; - static wxBitmap* bitmapDelete; + static wxBitmap* bitmapDeleteLeft; + static wxBitmap* bitmapDeleteRight; static wxBitmap* bitmapEmail; static wxBitmap* bitmapAbout; static wxBitmap* bitmapWebsite; diff --git a/library/tinyxml/tinystr.cpp b/library/tinyxml/tinystr.cpp new file mode 100644 index 00000000..2b9b5467 --- /dev/null +++ b/library/tinyxml/tinystr.cpp @@ -0,0 +1,116 @@ +/* +www.sourceforge.net/projects/tinyxml +Original file by Yves Berquin. + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +/* + * THIS FILE WAS ALTERED BY Tyge Lvset, 7. April 2005. + */ + + +#ifndef TIXML_USE_STL + +#include "tinystr.h" + +// Error value for find primitive +const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); + + +// Null rep. +TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; + + +void TiXmlString::reserve (size_type cap) +{ + if (cap > capacity()) + { + TiXmlString tmp; + tmp.init(length(), cap); + memcpy(tmp.start(), data(), length()); + swap(tmp); + } +} + + +TiXmlString& TiXmlString::assign(const char* str, size_type len) +{ + size_type cap = capacity(); + if (len > cap || cap > 3*(len + 8)) + { + TiXmlString tmp; + tmp.init(len); + memcpy(tmp.start(), str, len); + swap(tmp); + } + else + { + memmove(start(), str, len); + set_size(len); + } + return *this; +} + + +TiXmlString& TiXmlString::append(const char* str, size_type len) +{ + size_type newsize = length() + len; + if (newsize > capacity()) + { + reserve (newsize + capacity()); + } + memmove(finish(), str, len); + set_size(newsize); + return *this; +} + + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) +{ + TiXmlString tmp; + tmp.reserve(a.length() + b.length()); + tmp += a; + tmp += b; + return tmp; +} + +TiXmlString operator + (const TiXmlString & a, const char* b) +{ + TiXmlString tmp; + TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) ); + tmp.reserve(a.length() + b_len); + tmp += a; + tmp.append(b, b_len); + return tmp; +} + +TiXmlString operator + (const char* a, const TiXmlString & b) +{ + TiXmlString tmp; + TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) ); + tmp.reserve(a_len + b.length()); + tmp.append(a, a_len); + tmp += b; + return tmp; +} + + +#endif // TIXML_USE_STL diff --git a/library/tinyxml/tinystr.h b/library/tinyxml/tinystr.h new file mode 100644 index 00000000..3c2aa9d5 --- /dev/null +++ b/library/tinyxml/tinystr.h @@ -0,0 +1,319 @@ +/* +www.sourceforge.net/projects/tinyxml +Original file by Yves Berquin. + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +/* + * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005. + * + * - completely rewritten. compact, clean, and fast implementation. + * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems) + * - fixed reserve() to work as per specification. + * - fixed buggy compares operator==(), operator<(), and operator>() + * - fixed operator+=() to take a const ref argument, following spec. + * - added "copy" constructor with length, and most compare operators. + * - added swap(), clear(), size(), capacity(), operator+(). + */ + +#ifndef TIXML_USE_STL + +#ifndef TIXML_STRING_INCLUDED +#define TIXML_STRING_INCLUDED + +#include <assert.h> +#include <string.h> + +/* The support for explicit isn't that universal, and it isn't really + required - it is used to check that the TiXmlString class isn't incorrectly + used. Be nice to old compilers and macro it here: +*/ +#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + #define TIXML_EXPLICIT explicit +#elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + #define TIXML_EXPLICIT explicit +#else + #define TIXML_EXPLICIT +#endif + + +/* + TiXmlString is an emulation of a subset of the std::string template. + Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. + Only the member functions relevant to the TinyXML project have been implemented. + The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase + a string and there's no more room, we allocate a buffer twice as big as we need. +*/ +class TiXmlString +{ + public : + // The size type used + typedef size_t size_type; + + // Error value for find primitive + static const size_type npos; // = -1; + + + // TiXmlString empty constructor + TiXmlString () : rep_(&nullrep_) + { + } + + // TiXmlString copy constructor + TiXmlString ( const TiXmlString & copy) : rep_(0) + { + init(copy.length()); + memcpy(start(), copy.data(), length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) + { + init( static_cast<size_type>( strlen(copy) )); + memcpy(start(), copy, length()); + } + + // TiXmlString constructor, based on a string + TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) + { + init(len); + memcpy(start(), str, len); + } + + // TiXmlString destructor + ~TiXmlString () + { + quit(); + } + + // = operator + TiXmlString& operator = (const char * copy) + { + return assign( copy, (size_type)strlen(copy)); + } + + // = operator + TiXmlString& operator = (const TiXmlString & copy) + { + return assign(copy.start(), copy.length()); + } + + + // += operator. Maps to append + TiXmlString& operator += (const char * suffix) + { + return append(suffix, static_cast<size_type>( strlen(suffix) )); + } + + // += operator. Maps to append + TiXmlString& operator += (char single) + { + return append(&single, 1); + } + + // += operator. Maps to append + TiXmlString& operator += (const TiXmlString & suffix) + { + return append(suffix.data(), suffix.length()); + } + + + // Convert a TiXmlString into a null-terminated char * + const char * c_str () const { return rep_->str; } + + // Convert a TiXmlString into a char * (need not be null terminated). + const char * data () const { return rep_->str; } + + // Return the length of a TiXmlString + size_type length () const { return rep_->size; } + + // Alias for length() + size_type size () const { return rep_->size; } + + // Checks if a TiXmlString is empty + bool empty () const { return rep_->size == 0; } + + // Return capacity of string + size_type capacity () const { return rep_->capacity; } + + + // single char extraction + const char& at (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // [] operator + char& operator [] (size_type index) const + { + assert( index < length() ); + return rep_->str[ index ]; + } + + // find a char in a string. Return TiXmlString::npos if not found + size_type find (char lookup) const + { + return find(lookup, 0); + } + + // find a char in a string from an offset. Return TiXmlString::npos if not found + size_type find (char tofind, size_type offset) const + { + if (offset >= length()) return npos; + + for (const char* p = c_str() + offset; *p != '\0'; ++p) + { + if (*p == tofind) return static_cast< size_type >( p - c_str() ); + } + return npos; + } + + void clear () + { + //Lee: + //The original was just too strange, though correct: + // TiXmlString().swap(*this); + //Instead use the quit & re-init: + quit(); + init(0,0); + } + + /* Function to reserve a big amount of data when we know we'll need it. Be aware that this + function DOES NOT clear the content of the TiXmlString if any exists. + */ + void reserve (size_type cap); + + TiXmlString& assign (const char* str, size_type len); + + TiXmlString& append (const char* str, size_type len); + + void swap (TiXmlString& other) + { + Rep* r = rep_; + rep_ = other.rep_; + other.rep_ = r; + } + + private: + + void init(size_type sz) { init(sz, sz); } + void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } + char* start() const { return rep_->str; } + char* finish() const { return rep_->str + rep_->size; } + + struct Rep + { + size_type size, capacity; + char str[1]; + }; + + void init(size_type sz, size_type cap) + { + if (cap) + { + // Lee: the original form: + // rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap)); + // doesn't work in some cases of new being overloaded. Switching + // to the normal allocation, although use an 'int' for systems + // that are overly picky about structure alignment. + const size_type bytesNeeded = sizeof(Rep) + cap; + const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); + rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] ); + + rep_->str[ rep_->size = sz ] = '\0'; + rep_->capacity = cap; + } + else + { + rep_ = &nullrep_; + } + } + + void quit() + { + if (rep_ != &nullrep_) + { + // The rep_ is really an array of ints. (see the allocator, above). + // Cast it back before delete, so the compiler won't incorrectly call destructors. + delete [] ( reinterpret_cast<int*>( rep_ ) ); + } + } + + Rep * rep_; + static Rep nullrep_; + +} ; + + +inline bool operator == (const TiXmlString & a, const TiXmlString & b) +{ + return ( a.length() == b.length() ) // optimization on some platforms + && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare +} +inline bool operator < (const TiXmlString & a, const TiXmlString & b) +{ + return strcmp(a.c_str(), b.c_str()) < 0; +} + +inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } +inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } +inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } +inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } + +inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } +inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } +inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } +inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } + +TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); +TiXmlString operator + (const TiXmlString & a, const char* b); +TiXmlString operator + (const char* a, const TiXmlString & b); + + +/* + TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. + Only the operators that we need for TinyXML have been developped. +*/ +class TiXmlOutStream : public TiXmlString +{ +public : + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const TiXmlString & in) + { + *this += in; + return *this; + } + + // TiXmlOutStream << operator. + TiXmlOutStream & operator << (const char * in) + { + *this += in; + return *this; + } + +} ; + +#endif // TIXML_STRING_INCLUDED +#endif // TIXML_USE_STL diff --git a/library/tinyxml/tinyxml.cpp b/library/tinyxml/tinyxml.cpp new file mode 100644 index 00000000..aa13deec --- /dev/null +++ b/library/tinyxml/tinyxml.cpp @@ -0,0 +1,1942 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include <ctype.h> + +#ifdef TIXML_USE_STL +#include <sstream> +#include <iostream> +#endif + +#include "tinyxml.h" + + +bool TiXmlBase::condenseWhiteSpace = true; + +// Microsoft compiler security +FILE* TiXmlFOpen( const char* filename, const char* mode ) +{ +#if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + FILE* fp = 0; + errno_t err = fopen_s( &fp, filename, mode ); + if ( !err && fp ) + return fp; + return 0; +#else + return fopen( filename, mode ); +#endif +} + +void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) +{ + int i=0; + + while ( i<(int)str.length() ) + { + unsigned char c = (unsigned char) str[i]; + + if ( c == '&' + && i < ( (int)str.length() - 2 ) + && str[i+1] == '#' + && str[i+2] == 'x' ) + { + // Hexadecimal character reference. + // Pass through unchanged. + // © -- copyright symbol, for example. + // + // The -1 is a bug fix from Rob Laveaux. It keeps + // an overflow from happening if there is no ';'. + // There are actually 2 ways to exit this loop - + // while fails (error case) and break (semicolon found). + // However, there is no mechanism (currently) for + // this function to return an error. + while ( i<(int)str.length()-1 ) + { + outString->append( str.c_str() + i, 1 ); + ++i; + if ( str[i] == ';' ) + break; + } + } + else if ( c == '&' ) + { + outString->append( entity[0].str, entity[0].strLength ); + ++i; + } + else if ( c == '<' ) + { + outString->append( entity[1].str, entity[1].strLength ); + ++i; + } + else if ( c == '>' ) + { + outString->append( entity[2].str, entity[2].strLength ); + ++i; + } + else if ( c == '\"' ) + { + outString->append( entity[3].str, entity[3].strLength ); + ++i; + } + else if ( c == '\'' ) + { + outString->append( entity[4].str, entity[4].strLength ); + ++i; + } + else if ( c < 32 ) + { + // Easy pass at non-alpha/numeric/symbol + // Below 32 is symbolic. + char buf[ 32 ]; + +#if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); +#else + sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); +#endif + + //*ME: warning C4267: convert 'size_t' to 'int' + //*ME: Int-Cast to make compiler happy ... + outString->append( buf, (int)strlen( buf ) ); + ++i; + } + else + { + //char realc = (char) c; + //outString->append( &realc, 1 ); + *outString += (char) c; // somewhat more efficient function call. + ++i; + } + } +} + + +TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() +{ + parent = 0; + type = _type; + firstChild = 0; + lastChild = 0; + prev = 0; + next = 0; +} + + +TiXmlNode::~TiXmlNode() +{ + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; + + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } +} + + +void TiXmlNode::CopyTo( TiXmlNode* target ) const +{ + target->SetValue (value.c_str() ); + target->userData = userData; +} + + +void TiXmlNode::Clear() +{ + TiXmlNode* node = firstChild; + TiXmlNode* temp = 0; + + while ( node ) + { + temp = node; + node = node->next; + delete temp; + } + + firstChild = 0; + lastChild = 0; +} + + +TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) +{ + assert( node->parent == 0 || node->parent == this ); + assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); + + if ( node->Type() == TiXmlNode::DOCUMENT ) + { + delete node; + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + node->parent = this; + + node->prev = lastChild; + node->next = 0; + + if ( lastChild ) + lastChild->next = node; + else + firstChild = node; // it was an empty list. + + lastChild = node; + return node; +} + + +TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) +{ + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + + return LinkEndChild( node ); +} + + +TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) +{ + if ( !beforeThis || beforeThis->parent != this ) + { + return 0; + } + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->next = beforeThis; + node->prev = beforeThis->prev; + if ( beforeThis->prev ) + { + beforeThis->prev->next = node; + } + else + { + assert( firstChild == beforeThis ); + firstChild = node; + } + beforeThis->prev = node; + return node; +} + + +TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) +{ + if ( !afterThis || afterThis->parent != this ) + { + return 0; + } + if ( addThis.Type() == TiXmlNode::DOCUMENT ) + { + if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + TiXmlNode* node = addThis.Clone(); + if ( !node ) + return 0; + node->parent = this; + + node->prev = afterThis; + node->next = afterThis->next; + if ( afterThis->next ) + { + afterThis->next->prev = node; + } + else + { + assert( lastChild == afterThis ); + lastChild = node; + } + afterThis->next = node; + return node; +} + + +TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) +{ + if ( replaceThis->parent != this ) + return 0; + + TiXmlNode* node = withThis.Clone(); + if ( !node ) + return 0; + + node->next = replaceThis->next; + node->prev = replaceThis->prev; + + if ( replaceThis->next ) + replaceThis->next->prev = node; + else + lastChild = node; + + if ( replaceThis->prev ) + replaceThis->prev->next = node; + else + firstChild = node; + + delete replaceThis; + node->parent = this; + return node; +} + + +bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) +{ + if ( removeThis->parent != this ) + { + assert( 0 ); + return false; + } + + if ( removeThis->next ) + removeThis->next->prev = removeThis->prev; + else + lastChild = removeThis->prev; + + if ( removeThis->prev ) + removeThis->prev->next = removeThis->next; + else + firstChild = removeThis->next; + + delete removeThis; + return true; +} + +const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = firstChild; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = lastChild; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const +{ + if ( !previous ) + { + return FirstChild(); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling(); + } +} + + +const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const +{ + if ( !previous ) + { + return FirstChild( val ); + } + else + { + assert( previous->parent == this ); + return previous->NextSibling( val ); + } +} + + +const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = next; node; node = node->next ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const +{ + const TiXmlNode* node; + for ( node = prev; node; node = node->prev ) + { + if ( strcmp( node->Value(), _value ) == 0 ) + return node; + } + return 0; +} + + +void TiXmlElement::RemoveAttribute( const char * name ) +{ +#ifdef TIXML_USE_STL + TIXML_STRING str( name ); + TiXmlAttribute* node = attributeSet.Find( str ); +#else + TiXmlAttribute* node = attributeSet.Find( name ); +#endif + if ( node ) + { + attributeSet.Remove( node ); + delete node; + } +} + +const TiXmlElement* TiXmlNode::FirstChildElement() const +{ + const TiXmlNode* node; + + for ( node = FirstChild(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const +{ + const TiXmlNode* node; + + for ( node = FirstChild( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::NextSiblingElement() const +{ + const TiXmlNode* node; + + for ( node = NextSibling(); + node; + node = node->NextSibling() ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const +{ + const TiXmlNode* node; + + for ( node = NextSibling( _value ); + node; + node = node->NextSibling( _value ) ) + { + if ( node->ToElement() ) + return node->ToElement(); + } + return 0; +} + + +const TiXmlDocument* TiXmlNode::GetDocument() const +{ + const TiXmlNode* node; + + for ( node = this; node; node = node->parent ) + { + if ( node->ToDocument() ) + return node->ToDocument(); + } + return 0; +} + + +TiXmlElement::TiXmlElement (const char * _value) + : TiXmlNode( TiXmlNode::ELEMENT ) +{ + firstChild = lastChild = 0; + value = _value; +} + + +#ifdef TIXML_USE_STL +TiXmlElement::TiXmlElement( const std::string& _value ) + : TiXmlNode( TiXmlNode::ELEMENT ) +{ + firstChild = lastChild = 0; + value = _value; +} +#endif + + +TiXmlElement::TiXmlElement( const TiXmlElement& copy) + : TiXmlNode( TiXmlNode::ELEMENT ) +{ + firstChild = lastChild = 0; + copy.CopyTo( this ); +} + + +void TiXmlElement::operator=( const TiXmlElement& base ) +{ + ClearThis(); + base.CopyTo( this ); +} + + +TiXmlElement::~TiXmlElement() +{ + ClearThis(); +} + + +void TiXmlElement::ClearThis() +{ + Clear(); + while ( attributeSet.First() ) + { + TiXmlAttribute* node = attributeSet.First(); + attributeSet.Remove( node ); + delete node; + } +} + + +const char* TiXmlElement::Attribute( const char* name ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return node->Value(); + return 0; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + return &node->ValueStr(); + return 0; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, int* i ) const +{ + const char* s = Attribute( name ); + if ( i ) + { + if ( s ) + { + *i = atoi( s ); + } + else + { + *i = 0; + } + } + return s; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const +{ + const std::string* s = Attribute( name ); + if ( i ) + { + if ( s ) + { + *i = atoi( s->c_str() ); + } + else + { + *i = 0; + } + } + return s; +} +#endif + + +const char* TiXmlElement::Attribute( const char* name, double* d ) const +{ + const char* s = Attribute( name ); + if ( d ) + { + if ( s ) + { + *d = atof( s ); + } + else + { + *d = 0; + } + } + return s; +} + + +#ifdef TIXML_USE_STL +const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const +{ + const std::string* s = Attribute( name ); + if ( d ) + { + if ( s ) + { + *d = atof( s->c_str() ); + } + else + { + *d = 0; + } + } + return s; +} +#endif + + +int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryIntValue( ival ); +} + + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryIntValue( ival ); +} +#endif + + +int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryDoubleValue( dval ); +} + + +#ifdef TIXML_USE_STL +int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const +{ + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + return node->QueryDoubleValue( dval ); +} +#endif + + +void TiXmlElement::SetAttribute( const char * name, int val ) +{ + char buf[64]; +#if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%d", val ); +#else + sprintf( buf, "%d", val ); +#endif + SetAttribute( name, buf ); +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& name, int val ) +{ + std::ostringstream oss; + oss << val; + SetAttribute( name, oss.str() ); +} +#endif + + +void TiXmlElement::SetDoubleAttribute( const char * name, double val ) +{ + char buf[256]; +#if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%f", val ); +#else + sprintf( buf, "%f", val ); +#endif + SetAttribute( name, buf ); +} + + +void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) +{ +#ifdef TIXML_USE_STL + TIXML_STRING _name( cname ); + TIXML_STRING _value( cvalue ); +#else + const char* _name = cname; + const char* _value = cvalue; +#endif + + TiXmlAttribute* node = attributeSet.Find( _name ); + if ( node ) + { + node->SetValue( _value ); + return; + } + + TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue ); + if ( attrib ) + { + attributeSet.Add( attrib ); + } + else + { + TiXmlDocument* document = GetDocument(); + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } +} + + +#ifdef TIXML_USE_STL +void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value ) +{ + TiXmlAttribute* node = attributeSet.Find( name ); + if ( node ) + { + node->SetValue( _value ); + return; + } + + TiXmlAttribute* attrib = new TiXmlAttribute( name, _value ); + if ( attrib ) + { + attributeSet.Add( attrib ); + } + else + { + TiXmlDocument* document = GetDocument(); + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } +} +#endif + + +void TiXmlElement::Print( FILE* cfile, int depth ) const +{ + int i; + assert( cfile ); + for ( i=0; i<depth; i++ ) + { + fprintf( cfile, " " ); + } + + fprintf( cfile, "<%s", value.c_str() ); + + const TiXmlAttribute* attrib; + for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() ) + { + fprintf( cfile, " " ); + attrib->Print( cfile, depth ); + } + + // There are 3 different formatting approaches: + // 1) An element without children is printed as a <foo /> node + // 2) An element with only a text child is printed as <foo> text </foo> + // 3) An element with children is printed on multiple lines. + TiXmlNode* node; + if ( !firstChild ) + { + fprintf( cfile, " />" ); + } + else if ( firstChild == lastChild && firstChild->ToText() ) + { + fprintf( cfile, ">" ); + firstChild->Print( cfile, depth + 1 ); + fprintf( cfile, "</%s>", value.c_str() ); + } + else + { + fprintf( cfile, ">" ); + + for ( node = firstChild; node; node=node->NextSibling() ) + { + if ( !node->ToText() ) + { + fprintf( cfile, "\n" ); + } + node->Print( cfile, depth+1 ); + } + fprintf( cfile, "\n" ); + for ( i=0; i<depth; ++i ) + { + fprintf( cfile, " " ); + } + fprintf( cfile, "</%s>", value.c_str() ); + } +} + + +void TiXmlElement::CopyTo( TiXmlElement* target ) const +{ + // superclass: + TiXmlNode::CopyTo( target ); + + // Element class: + // Clone the attributes, then clone the children. + const TiXmlAttribute* attribute = 0; + for ( attribute = attributeSet.First(); + attribute; + attribute = attribute->Next() ) + { + target->SetAttribute( attribute->Name(), attribute->Value() ); + } + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } +} + +bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this, attributeSet.First() ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + + +TiXmlNode* TiXmlElement::Clone() const +{ + TiXmlElement* clone = new TiXmlElement( Value() ); + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +const char* TiXmlElement::GetText() const +{ + const TiXmlNode* child = this->FirstChild(); + if ( child ) + { + const TiXmlText* childText = child->ToText(); + if ( childText ) + { + return childText->Value(); + } + } + return 0; +} + + +TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + ClearError(); +} + +TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); +} + + +#ifdef TIXML_USE_STL +TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + tabsize = 4; + useMicrosoftBOM = false; + value = documentName; + ClearError(); +} +#endif + + +TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT ) +{ + copy.CopyTo( this ); +} + + +void TiXmlDocument::operator=( const TiXmlDocument& copy ) +{ + Clear(); + copy.CopyTo( this ); +} + + +bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) +{ + // See STL_STRING_BUG below. + //StringToBuffer buf( value ); + + return LoadFile( Value(), encoding ); +} + + +bool TiXmlDocument::SaveFile() const +{ + // See STL_STRING_BUG below. +// StringToBuffer buf( value ); +// +// if ( buf.buffer && SaveFile( buf.buffer ) ) +// return true; +// +// return false; + return SaveFile( Value() ); +} + +bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) +{ + // There was a really terrifying little bug here. The code: + // value = filename + // in the STL case, cause the assignment method of the std::string to + // be called. What is strange, is that the std::string had the same + // address as it's c_str() method, and so bad things happen. Looks + // like a bug in the Microsoft STL implementation. + // Add an extra string to avoid the crash. + TIXML_STRING filename( _filename ); + value = filename; + + // reading in binary mode so that tinyxml can normalize the EOL + FILE* file = TiXmlFOpen( value.c_str (), "rb" ); + + if ( file ) + { + bool result = LoadFile( file, encoding ); + fclose( file ); + return result; + } + else + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } +} + +bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) +{ + if ( !file ) + { + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // Delete the existing data: + Clear(); + location.Clear(); + + // Get the file size, so we can pre-allocate the string. HUGE speed impact. + long length = 0; + fseek( file, 0, SEEK_END ); + length = ftell( file ); + fseek( file, 0, SEEK_SET ); + + // Strange case, but good to handle up front. + if ( length <= 0 ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + // If we have a file, assume it is all one big XML file, and read it in. + // The document parser may decide the document ends sooner than the entire file, however. + TIXML_STRING data; + data.reserve( length ); + + // Subtle bug here. TinyXml did use fgets. But from the XML spec: + // 2.11 End-of-Line Handling + // <snip> + // <quote> + // ...the XML processor MUST behave as if it normalized all line breaks in external + // parsed entities (including the document entity) on input, before parsing, by translating + // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to + // a single #xA character. + // </quote> + // + // It is not clear fgets does that, and certainly isn't clear it works cross platform. + // Generally, you expect fgets to translate from the convention of the OS to the c/unix + // convention, and not work generally. + + /* + while( fgets( buf, sizeof(buf), file ) ) + { + data += buf; + } + */ + + char* buf = new char[ length+1 ]; + buf[0] = 0; + + if ( fread( buf, length, 1, file ) != 1 ) + { + delete [] buf; + SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); + return false; + } + + const char* lastPos = buf; + const char* p = buf; + + buf[length] = 0; + while ( *p ) + { + assert( p < (buf+length) ); + if ( *p == 0xa ) + { + // Newline character. No special rules for this. Append all the characters + // since the last string, and include the newline. + data.append( lastPos, (p-lastPos+1) ); // append, include the newline + ++p; // move past the newline + lastPos = p; // and point to the new buffer (may be 0) + assert( p <= (buf+length) ); + } + else if ( *p == 0xd ) + { + // Carriage return. Append what we have so far, then + // handle moving forward in the buffer. + if ( (p-lastPos) > 0 ) + { + data.append( lastPos, p-lastPos ); // do not add the CR + } + data += (char)0xa; // a proper newline + + if ( *(p+1) == 0xa ) + { + // Carriage return - new line sequence + p += 2; + lastPos = p; + assert( p <= (buf+length) ); + } + else + { + // it was followed by something else...that is presumably characters again. + ++p; + lastPos = p; + assert( p <= (buf+length) ); + } + } + else + { + ++p; + } + } + // Handle any left over characters. + if ( p-lastPos ) + { + data.append( lastPos, p-lastPos ); + } + delete [] buf; + buf = 0; + + Parse( data.c_str(), 0, encoding ); + + if ( Error() ) + return false; + else + return true; +} + + +bool TiXmlDocument::SaveFile( const char * filename ) const +{ + // The old c stuff lives on... + FILE* fp = TiXmlFOpen( filename, "w" ); + if ( fp ) + { + bool result = SaveFile( fp ); + fclose( fp ); + return result; + } + return false; +} + + +bool TiXmlDocument::SaveFile( FILE* fp ) const +{ + if ( useMicrosoftBOM ) + { + const unsigned char TIXML_UTF_LEAD_0 = 0xefU; + const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; + const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + + fputc( TIXML_UTF_LEAD_0, fp ); + fputc( TIXML_UTF_LEAD_1, fp ); + fputc( TIXML_UTF_LEAD_2, fp ); + } + Print( fp, 0 ); + return (ferror(fp) == 0); +} + + +void TiXmlDocument::CopyTo( TiXmlDocument* target ) const +{ + TiXmlNode::CopyTo( target ); + + target->error = error; + target->errorId = errorId; + target->errorDesc = errorDesc; + target->tabsize = tabsize; + target->errorLocation = errorLocation; + target->useMicrosoftBOM = useMicrosoftBOM; + + TiXmlNode* node = 0; + for ( node = firstChild; node; node = node->NextSibling() ) + { + target->LinkEndChild( node->Clone() ); + } +} + + +TiXmlNode* TiXmlDocument::Clone() const +{ + TiXmlDocument* clone = new TiXmlDocument(); + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlDocument::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + node->Print( cfile, depth ); + fprintf( cfile, "\n" ); + } +} + + +bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const +{ + if ( visitor->VisitEnter( *this ) ) + { + for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) + { + if ( !node->Accept( visitor ) ) + break; + } + } + return visitor->VisitExit( *this ); +} + + +const TiXmlAttribute* TiXmlAttribute::Next() const +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} + +/* +TiXmlAttribute* TiXmlAttribute::Next() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( next->value.empty() && next->name.empty() ) + return 0; + return next; +} +*/ + +const TiXmlAttribute* TiXmlAttribute::Previous() const +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} + +/* +TiXmlAttribute* TiXmlAttribute::Previous() +{ + // We are using knowledge of the sentinel. The sentinel + // have a value or name. + if ( prev->value.empty() && prev->name.empty() ) + return 0; + return prev; +} +*/ + +void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const +{ + TIXML_STRING n, v; + + EncodeString( name, &n ); + EncodeString( value, &v ); + + if (value.find ('\"') == TIXML_STRING::npos) + { + if ( cfile ) + { + fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); + } + if ( str ) + { + (*str) += n; + (*str) += "=\""; + (*str) += v; + (*str) += "\""; + } + } + else + { + if ( cfile ) + { + fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); + } + if ( str ) + { + (*str) += n; + (*str) += "='"; + (*str) += v; + (*str) += "'"; + } + } +} + + +int TiXmlAttribute::QueryIntValue( int* ival ) const +{ + if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; +} + +int TiXmlAttribute::QueryDoubleValue( double* dval ) const +{ + if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; +} + +void TiXmlAttribute::SetIntValue( int _value ) +{ + char buf [64]; +#if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); +#else + sprintf (buf, "%d", _value); +#endif + SetValue (buf); +} + +void TiXmlAttribute::SetDoubleValue( double _value ) +{ + char buf [256]; +#if defined(TIXML_SNPRINTF) + TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value); +#else + sprintf (buf, "%lf", _value); +#endif + SetValue (buf); +} + +int TiXmlAttribute::IntValue() const +{ + return atoi (value.c_str ()); +} + +double TiXmlAttribute::DoubleValue() const +{ + return atof (value.c_str ()); +} + + +TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT ) +{ + copy.CopyTo( this ); +} + + +void TiXmlComment::operator=( const TiXmlComment& base ) +{ + Clear(); + base.CopyTo( this ); +} + + +void TiXmlComment::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + for ( int i=0; i<depth; i++ ) + { + fprintf( cfile, " " ); + } + fprintf( cfile, "<!--%s-->", value.c_str() ); +} + + +void TiXmlComment::CopyTo( TiXmlComment* target ) const +{ + TiXmlNode::CopyTo( target ); +} + + +bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlComment::Clone() const +{ + TiXmlComment* clone = new TiXmlComment(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlText::Print( FILE* cfile, int depth ) const +{ + assert( cfile ); + if ( cdata ) + { + int i; + fprintf( cfile, "\n" ); + for ( i=0; i<depth; i++ ) + { + fprintf( cfile, " " ); + } + fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() ); // unformatted output + } + else + { + TIXML_STRING buffer; + EncodeString( value, &buffer ); + fprintf( cfile, "%s", buffer.c_str() ); + } +} + + +void TiXmlText::CopyTo( TiXmlText* target ) const +{ + TiXmlNode::CopyTo( target ); + target->cdata = cdata; +} + + +bool TiXmlText::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlText::Clone() const +{ + TiXmlText* clone = 0; + clone = new TiXmlText( "" ); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +TiXmlDeclaration::TiXmlDeclaration( const char * _version, + const char * _encoding, + const char * _standalone ) + : TiXmlNode( TiXmlNode::DECLARATION ) +{ + version = _version; + encoding = _encoding; + standalone = _standalone; +} + + +#ifdef TIXML_USE_STL +TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ) + : TiXmlNode( TiXmlNode::DECLARATION ) +{ + version = _version; + encoding = _encoding; + standalone = _standalone; +} +#endif + + +TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) + : TiXmlNode( TiXmlNode::DECLARATION ) +{ + copy.CopyTo( this ); +} + + +void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) +{ + Clear(); + copy.CopyTo( this ); +} + + +void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const +{ + if ( cfile ) fprintf( cfile, "<?xml " ); + if ( str ) (*str) += "<?xml "; + + if ( !version.empty() ) + { + if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ()); + if ( str ) + { + (*str) += "version=\""; + (*str) += version; + (*str) += "\" "; + } + } + if ( !encoding.empty() ) + { + if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ()); + if ( str ) + { + (*str) += "encoding=\""; + (*str) += encoding; + (*str) += "\" "; + } + } + if ( !standalone.empty() ) + { + if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ()); + if ( str ) + { + (*str) += "standalone=\""; + (*str) += standalone; + (*str) += "\" "; + } + } + if ( cfile ) fprintf( cfile, "?>" ); + if ( str ) (*str) += "?>"; +} + + +void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const +{ + TiXmlNode::CopyTo( target ); + + target->version = version; + target->encoding = encoding; + target->standalone = standalone; +} + + +bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlDeclaration::Clone() const +{ + TiXmlDeclaration* clone = new TiXmlDeclaration(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +void TiXmlUnknown::Print( FILE* cfile, int depth ) const +{ + for ( int i=0; i<depth; i++ ) + fprintf( cfile, " " ); + fprintf( cfile, "<%s>", value.c_str() ); +} + + +void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const +{ + TiXmlNode::CopyTo( target ); +} + + +bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const +{ + return visitor->Visit( *this ); +} + + +TiXmlNode* TiXmlUnknown::Clone() const +{ + TiXmlUnknown* clone = new TiXmlUnknown(); + + if ( !clone ) + return 0; + + CopyTo( clone ); + return clone; +} + + +TiXmlAttributeSet::TiXmlAttributeSet() +{ + sentinel.next = &sentinel; + sentinel.prev = &sentinel; +} + + +TiXmlAttributeSet::~TiXmlAttributeSet() +{ + assert( sentinel.next == &sentinel ); + assert( sentinel.prev == &sentinel ); +} + + +void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) +{ +#ifdef TIXML_USE_STL + assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. +#else + assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. +#endif + + addMe->next = &sentinel; + addMe->prev = sentinel.prev; + + sentinel.prev->next = addMe; + sentinel.prev = addMe; +} + +void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) +{ + TiXmlAttribute* node; + + for ( node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node == removeMe ) + { + node->prev->next = node->next; + node->next->prev = node->prev; + node->next = 0; + node->prev = 0; + return; + } + } + assert( 0 ); // we tried to remove a non-linked attribute. +} + + +#ifdef TIXML_USE_STL +const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const +{ + for ( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; +} + +/* +TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( node->name == name ) + return node; + } + return 0; +} +*/ +#endif + + +const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const +{ + for ( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; +} + +/* +TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) +{ + for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) + { + if ( strcmp( node->name.c_str(), name ) == 0 ) + return node; + } + return 0; +} +*/ + +#ifdef TIXML_USE_STL +std::istream& operator>> (std::istream & in, TiXmlNode & base) +{ + TIXML_STRING tag; + tag.reserve( 8 * 1000 ); + base.StreamIn( &in, &tag ); + + base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); + return in; +} +#endif + + +#ifdef TIXML_USE_STL +std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) +{ + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out << printer.Str(); + + return out; +} + + +std::string& operator<< (std::string& out, const TiXmlNode& base ) +{ + TiXmlPrinter printer; + printer.SetStreamPrinting(); + base.Accept( &printer ); + out.append( printer.Str() ); + + return out; +} +#endif + + +TiXmlHandle TiXmlHandle::FirstChild() const +{ + if ( node ) + { + TiXmlNode* child = node->FirstChild(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const +{ + if ( node ) + { + TiXmlNode* child = node->FirstChild( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChildElement() const +{ + if ( node ) + { + TiXmlElement* child = node->FirstChildElement(); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const +{ + if ( node ) + { + TiXmlElement* child = node->FirstChildElement( value ); + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::Child( int count ) const +{ + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild(); + for ( i=0; + child && i<count; + child = child->NextSibling(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const +{ + if ( node ) + { + int i; + TiXmlNode* child = node->FirstChild( value ); + for ( i=0; + child && i<count; + child = child->NextSibling( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::ChildElement( int count ) const +{ + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement(); + for ( i=0; + child && i<count; + child = child->NextSiblingElement(), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const +{ + if ( node ) + { + int i; + TiXmlElement* child = node->FirstChildElement( value ); + for ( i=0; + child && i<count; + child = child->NextSiblingElement( value ), ++i ) + { + // nothing + } + if ( child ) + return TiXmlHandle( child ); + } + return TiXmlHandle( 0 ); +} + + +bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) +{ + return true; +} + +bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) +{ + DoIndent(); + buffer += "<"; + buffer += element.Value(); + + for ( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) + { + buffer += " "; + attrib->Print( 0, 0, &buffer ); + } + + if ( !element.FirstChild() ) + { + buffer += " />"; + DoLineBreak(); + } + else + { + buffer += ">"; + if ( element.FirstChild()->ToText() + && element.LastChild() == element.FirstChild() + && element.FirstChild()->ToText()->CDATA() == false ) + { + simpleTextPrint = true; + // no DoLineBreak()! + } + else + { + DoLineBreak(); + } + } + ++depth; + return true; +} + + +bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) +{ + --depth; + if ( !element.FirstChild() ) + { + // nothing. + } + else + { + if ( simpleTextPrint ) + { + simpleTextPrint = false; + } + else + { + DoIndent(); + } + buffer += "</"; + buffer += element.Value(); + buffer += ">"; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlText& text ) +{ + if ( text.CDATA() ) + { + DoIndent(); + buffer += "<![CDATA["; + buffer += text.Value(); + buffer += "]]>"; + DoLineBreak(); + } + else if ( simpleTextPrint ) + { + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + } + else + { + DoIndent(); + TIXML_STRING str; + TiXmlBase::EncodeString( text.ValueTStr(), &str ); + buffer += str; + DoLineBreak(); + } + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) +{ + DoIndent(); + declaration.Print( 0, 0, &buffer ); + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlComment& comment ) +{ + DoIndent(); + buffer += "<!--"; + buffer += comment.Value(); + buffer += "-->"; + DoLineBreak(); + return true; +} + + +bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) +{ + DoIndent(); + buffer += "<"; + buffer += unknown.Value(); + buffer += ">"; + DoLineBreak(); + return true; +} + diff --git a/library/tinyxml/tinyxml.h b/library/tinyxml/tinyxml.h new file mode 100644 index 00000000..c6f40cc2 --- /dev/null +++ b/library/tinyxml/tinyxml.h @@ -0,0 +1,1802 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + + +#ifndef TINYXML_INCLUDED +#define TINYXML_INCLUDED + +#ifdef _MSC_VER +#pragma warning( push ) +#pragma warning( disable : 4530 ) +#pragma warning( disable : 4786 ) +#endif + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +// Help out windows: +#if defined( _DEBUG ) && !defined( DEBUG ) +#define DEBUG +#endif + +#ifdef TIXML_USE_STL + #include <string> + #include <iostream> + #include <sstream> + #define TIXML_STRING std::string +#else + #include "tinystr.h" + #define TIXML_STRING TiXmlString +#endif + +// Deprecated library function hell. Compilers want to use the +// new safe versions. This probably doesn't fully address the problem, +// but it gets closer. There are too many compilers for me to fully +// test. If you get compilation troubles, undefine TIXML_SAFE +#define TIXML_SAFE + +#ifdef TIXML_SAFE + #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) + // Microsoft visual studio, version 2005 and higher. + #define TIXML_SNPRINTF _snprintf_s + #define TIXML_SNSCANF _snscanf_s + #define TIXML_SSCANF sscanf_s + #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) + // Microsoft visual studio, version 6 and higher. + //#pragma message( "Using _sn* functions." ) + #define TIXML_SNPRINTF _snprintf + #define TIXML_SNSCANF _snscanf + #define TIXML_SSCANF sscanf + #elif defined(__GNUC__) && (__GNUC__ >= 3 ) + // GCC version 3 and higher.s + //#warning( "Using sn* functions." ) + #define TIXML_SNPRINTF snprintf + #define TIXML_SNSCANF snscanf + #define TIXML_SSCANF sscanf + #else + #define TIXML_SSCANF sscanf + #endif +#endif + +class TiXmlDocument; +class TiXmlElement; +class TiXmlComment; +class TiXmlUnknown; +class TiXmlAttribute; +class TiXmlText; +class TiXmlDeclaration; +class TiXmlParsingData; + +const int TIXML_MAJOR_VERSION = 2; +const int TIXML_MINOR_VERSION = 5; +const int TIXML_PATCH_VERSION = 3; + +/* Internal structure for tracking location of items + in the XML file. +*/ +struct TiXmlCursor +{ + TiXmlCursor() { Clear(); } + void Clear() { row = col = -1; } + + int row; // 0 based. + int col; // 0 based. +}; + + +/** + If you call the Accept() method, it requires being passed a TiXmlVisitor + class to handle callbacks. For nodes that contain other nodes (Document, Element) + you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves + are simple called with Visit(). + + If you return 'true' from a Visit method, recursive parsing will continue. If you return + false, <b>no children of this node or its sibilings</b> will be Visited. + + All flavors of Visit methods have a default implementation that returns 'true' (continue + visiting). You need to only override methods that are interesting to you. + + Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. + + You should never change the document from a callback. + + @sa TiXmlNode::Accept() +*/ +class TiXmlVisitor +{ +public: + virtual ~TiXmlVisitor() {} + + /// Visit a document. + virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } + /// Visit a document. + virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } + + /// Visit an element. + virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } + /// Visit an element. + virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } + + /// Visit a declaration + virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } + /// Visit a text node + virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } + /// Visit a comment node + virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } + /// Visit an unknow node + virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } +}; + +// Only used by Attribute::Query functions +enum +{ + TIXML_SUCCESS, + TIXML_NO_ATTRIBUTE, + TIXML_WRONG_TYPE +}; + + +// Used by the parsing routines. +enum TiXmlEncoding +{ + TIXML_ENCODING_UNKNOWN, + TIXML_ENCODING_UTF8, + TIXML_ENCODING_LEGACY +}; + +const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; + +/** TiXmlBase is a base class for every class in TinyXml. + It does little except to establish that TinyXml classes + can be printed and provide some utility functions. + + In XML, the document and elements can contain + other elements and other types of nodes. + + @verbatim + A Document can contain: Element (container or leaf) + Comment (leaf) + Unknown (leaf) + Declaration( leaf ) + + An Element can contain: Element (container or leaf) + Text (leaf) + Attributes (not on tree) + Comment (leaf) + Unknown (leaf) + + A Decleration contains: Attributes (not on tree) + @endverbatim +*/ +class TiXmlBase +{ + friend class TiXmlNode; + friend class TiXmlElement; + friend class TiXmlDocument; + +public: + TiXmlBase() : userData(0) {} + virtual ~TiXmlBase() {} + + /** All TinyXml classes can print themselves to a filestream + or the string class (TiXmlString in non-STL mode, std::string + in STL mode.) Either or both cfile and str can be null. + + This is a formatted print, and will insert + tabs and newlines. + + (For an unformatted stream, use the << operator.) + */ + virtual void Print( FILE* cfile, int depth ) const = 0; + + /** The world does not agree on whether white space should be kept or + not. In order to make everyone happy, these global, static functions + are provided to set whether or not TinyXml will condense all white space + into a single space or not. The default is to condense. Note changing this + value is not thread safe. + */ + static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } + + /// Return the current white space setting. + static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } + + /** Return the position, in the original source file, of this node or attribute. + The row and column are 1-based. (That is the first row and first column is + 1,1). If the returns values are 0 or less, then the parser does not have + a row and column value. + + Generally, the row and column value will be set when the TiXmlDocument::Load(), + TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set + when the DOM was created from operator>>. + + The values reflect the initial load. Once the DOM is modified programmatically + (by adding or changing nodes and attributes) the new values will NOT update to + reflect changes in the document. + + There is a minor performance cost to computing the row and column. Computation + can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. + + @sa TiXmlDocument::SetTabSize() + */ + int Row() const { return location.row + 1; } + int Column() const { return location.col + 1; } ///< See Row() + + void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. + void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. + const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. + + // Table that returs, for a given lead byte, the total number of bytes + // in the UTF-8 sequence. + static const int utf8ByteTable[256]; + + virtual const char* Parse( const char* p, + TiXmlParsingData* data, + TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; + + /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, + or they will be transformed into entities! + */ + static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); + + enum + { + TIXML_NO_ERROR = 0, + TIXML_ERROR, + TIXML_ERROR_OPENING_FILE, + TIXML_ERROR_OUT_OF_MEMORY, + TIXML_ERROR_PARSING_ELEMENT, + TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, + TIXML_ERROR_READING_ELEMENT_VALUE, + TIXML_ERROR_READING_ATTRIBUTES, + TIXML_ERROR_PARSING_EMPTY, + TIXML_ERROR_READING_END_TAG, + TIXML_ERROR_PARSING_UNKNOWN, + TIXML_ERROR_PARSING_COMMENT, + TIXML_ERROR_PARSING_DECLARATION, + TIXML_ERROR_DOCUMENT_EMPTY, + TIXML_ERROR_EMBEDDED_NULL, + TIXML_ERROR_PARSING_CDATA, + TIXML_ERROR_DOCUMENT_TOP_ONLY, + + TIXML_ERROR_STRING_COUNT + }; + +protected: + + static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); + inline static bool IsWhiteSpace( char c ) + { + return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); + } + inline static bool IsWhiteSpace( int c ) + { + if ( c < 256 ) + return IsWhiteSpace( (char) c ); + return false; // Again, only truly correct for English/Latin...but usually works. + } + + #ifdef TIXML_USE_STL + static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); + static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); + #endif + + /* Reads an XML name into the string provided. Returns + a pointer just past the last character of the name, + or 0 if the function has an error. + */ + static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); + + /* Reads text. Returns a pointer past the given end tag. + Wickedly complex options, but it keeps the (sensitive) code in one place. + */ + static const char* ReadText( const char* in, // where to start + TIXML_STRING* text, // the string read + bool ignoreWhiteSpace, // whether to keep the white space + const char* endTag, // what ends this text + bool ignoreCase, // whether to ignore case in the end tag + TiXmlEncoding encoding ); // the current encoding + + // If an entity has been found, transform it into a character. + static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); + + // Get a character, while interpreting entities. + // The length can be from 0 to 4 bytes. + inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) + { + assert( p ); + if ( encoding == TIXML_ENCODING_UTF8 ) + { + *length = utf8ByteTable[ *((const unsigned char*)p) ]; + assert( *length >= 0 && *length < 5 ); + } + else + { + *length = 1; + } + + if ( *length == 1 ) + { + if ( *p == '&' ) + return GetEntity( p, _value, length, encoding ); + *_value = *p; + return p+1; + } + else if ( *length ) + { + //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), + // and the null terminator isn't needed + for( int i=0; p[i] && i<*length; ++i ) { + _value[i] = p[i]; + } + return p + (*length); + } + else + { + // Not valid text. + return 0; + } + } + + // Return true if the next characters in the stream are any of the endTag sequences. + // Ignore case only works for english, and should only be relied on when comparing + // to English words: StringEqual( p, "version", true ) is fine. + static bool StringEqual( const char* p, + const char* endTag, + bool ignoreCase, + TiXmlEncoding encoding ); + + static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; + + TiXmlCursor location; + + /// Field containing a generic user pointer + void* userData; + + // None of these methods are reliable for any language except English. + // Good for approximation, not great for accuracy. + static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); + static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); + inline static int ToLower( int v, TiXmlEncoding encoding ) + { + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( v < 128 ) return tolower( v ); + return v; + } + else + { + return tolower( v ); + } + } + static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); + +private: + TiXmlBase( const TiXmlBase& ); // not implemented. + void operator=( const TiXmlBase& base ); // not allowed. + + struct Entity + { + const char* str; + unsigned int strLength; + char chr; + }; + enum + { + NUM_ENTITY = 5, + MAX_ENTITY_LENGTH = 6 + + }; + static Entity entity[ NUM_ENTITY ]; + static bool condenseWhiteSpace; +}; + + +/** The parent class for everything in the Document Object Model. + (Except for attributes). + Nodes have siblings, a parent, and children. A node can be + in a document, or stand on its own. The type of a TiXmlNode + can be queried, and it can be cast to its more defined type. +*/ +class TiXmlNode : public TiXmlBase +{ + friend class TiXmlDocument; + friend class TiXmlElement; + +public: + #ifdef TIXML_USE_STL + + /** An input stream operator, for every class. Tolerant of newlines and + formatting, but doesn't expect them. + */ + friend std::istream& operator >> (std::istream& in, TiXmlNode& base); + + /** An output stream operator, for every class. Note that this outputs + without any newlines or formatting, as opposed to Print(), which + includes tabs and new lines. + + The operator<< and operator>> are not completely symmetric. Writing + a node to a stream is very well defined. You'll get a nice stream + of output, without any extra whitespace or newlines. + + But reading is not as well defined. (As it always is.) If you create + a TiXmlElement (for example) and read that from an input stream, + the text needs to define an element or junk will result. This is + true of all input streams, but it's worth keeping in mind. + + A TiXmlDocument will read nodes until it reads a root element, and + all the children of that root element. + */ + friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); + + /// Appends the XML node or attribute to a std::string. + friend std::string& operator<< (std::string& out, const TiXmlNode& base ); + + #endif + + /** The types of XML nodes supported by TinyXml. (All the + unsupported types are picked up by UNKNOWN.) + */ + enum NodeType + { + DOCUMENT, + ELEMENT, + COMMENT, + UNKNOWN, + TEXT, + DECLARATION, + TYPECOUNT + }; + + virtual ~TiXmlNode(); + + /** The meaning of 'value' changes for the specific type of + TiXmlNode. + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + + The subclasses will wrap this function. + */ + const char *Value() const { return value.c_str (); } + + #ifdef TIXML_USE_STL + /** Return Value() as a std::string. If you only use STL, + this is more efficient than calling Value(). + Only available in STL mode. + */ + const std::string& ValueStr() const { return value; } + #endif + + const TIXML_STRING& ValueTStr() const { return value; } + + /** Changes the value of the node. Defined as: + @verbatim + Document: filename of the xml file + Element: name of the element + Comment: the comment text + Unknown: the tag contents + Text: the text string + @endverbatim + */ + void SetValue(const char * _value) { value = _value;} + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Delete all the children of this node. Does not affect 'this'. + void Clear(); + + /// One step up the DOM. + TiXmlNode* Parent() { return parent; } + const TiXmlNode* Parent() const { return parent; } + + const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. + TiXmlNode* FirstChild() { return firstChild; } + const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. + /// The first child of this node with the matching 'value'. Will be null if none found. + TiXmlNode* FirstChild( const char * _value ) { + // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) + // call the method, cast the return back to non-const. + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); + } + const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. + TiXmlNode* LastChild() { return lastChild; } + + const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. + TiXmlNode* LastChild( const char * _value ) { + return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. + #endif + + /** An alternate way to walk the children of a node. + One way to iterate over nodes is: + @verbatim + for( child = parent->FirstChild(); child; child = child->NextSibling() ) + @endverbatim + + IterateChildren does the same thing with the syntax: + @verbatim + child = 0; + while( child = parent->IterateChildren( child ) ) + @endverbatim + + IterateChildren takes the previous child as input and finds + the next one. If the previous child is null, it returns the + first. IterateChildren will return null when done. + */ + const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); + } + + /// This flavor of IterateChildren searches for children with a particular 'value' + const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; + TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. + #endif + + /** Add a new node related to this. Adds a child past the LastChild. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); + + + /** Add a new node related to this. Adds a child past the LastChild. + + NOTE: the node to be added is passed by pointer, and will be + henceforth owned (and deleted) by tinyXml. This method is efficient + and avoids an extra copy, but should be used with care as it + uses a different memory model than the other insert functions. + + @sa InsertEndChild + */ + TiXmlNode* LinkEndChild( TiXmlNode* addThis ); + + /** Add a new node related to this. Adds a child before the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); + + /** Add a new node related to this. Adds a child after the specified child. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); + + /** Replace a child of this node. + Returns a pointer to the new object or NULL if an error occured. + */ + TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); + + /// Delete a child of this node. + bool RemoveChild( TiXmlNode* removeThis ); + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling() const { return prev; } + TiXmlNode* PreviousSibling() { return prev; } + + /// Navigate to a sibling node. + const TiXmlNode* PreviousSibling( const char * ) const; + TiXmlNode* PreviousSibling( const char *_prev ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. + const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. + TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Navigate to a sibling node. + const TiXmlNode* NextSibling() const { return next; } + TiXmlNode* NextSibling() { return next; } + + /// Navigate to a sibling node with the given 'value'. + const TiXmlNode* NextSibling( const char * ) const; + TiXmlNode* NextSibling( const char* _next ) { + return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement() const; + TiXmlElement* NextSiblingElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); + } + + /** Convenience function to get through elements. + Calls NextSibling and ToElement. Will skip all non-Element + nodes. Returns 0 if there is not another element. + */ + const TiXmlElement* NextSiblingElement( const char * ) const; + TiXmlElement* NextSiblingElement( const char *_next ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement() const; + TiXmlElement* FirstChildElement() { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); + } + + /// Convenience function to get through elements. + const TiXmlElement* FirstChildElement( const char * _value ) const; + TiXmlElement* FirstChildElement( const char * _value ) { + return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); + } + + #ifdef TIXML_USE_STL + const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. + #endif + + /** Query the type (as an enumerated value, above) of this node. + The possible types are: DOCUMENT, ELEMENT, COMMENT, + UNKNOWN, TEXT, and DECLARATION. + */ + int Type() const { return type; } + + /** Return a pointer to the Document this node lives in. + Returns null if not in a document. + */ + const TiXmlDocument* GetDocument() const; + TiXmlDocument* GetDocument() { + return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); + } + + /// Returns true if this node has no children. + bool NoChildren() const { return !firstChild; } + + virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. + + /** Create an exact duplicate of this node and return it. The memory must be deleted + by the caller. + */ + virtual TiXmlNode* Clone() const = 0; + + /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the + XML tree will be conditionally visited and the host will be called back + via the TiXmlVisitor interface. + + This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse + the XML for the callbacks, so the performance of TinyXML is unchanged by using this + interface versus any other.) + + The interface has been based on ideas from: + + - http://www.saxproject.org/ + - http://c2.com/cgi/wiki?HierarchicalVisitorPattern + + Which are both good references for "visiting". + + An example of using Accept(): + @verbatim + TiXmlPrinter printer; + tinyxmlDoc.Accept( &printer ); + const char* xmlcstr = printer.CStr(); + @endverbatim + */ + virtual bool Accept( TiXmlVisitor* visitor ) const = 0; + +protected: + TiXmlNode( NodeType _type ); + + // Copy to the allocated object. Shared functionality between Clone, Copy constructor, + // and the assignment operator. + void CopyTo( TiXmlNode* target ) const; + + #ifdef TIXML_USE_STL + // The real work of the input operator. + virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; + #endif + + // Figure out what is at *p, and parse it. Returns null if it is not an xml node. + TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); + + TiXmlNode* parent; + NodeType type; + + TiXmlNode* firstChild; + TiXmlNode* lastChild; + + TIXML_STRING value; + + TiXmlNode* prev; + TiXmlNode* next; + +private: + TiXmlNode( const TiXmlNode& ); // not implemented. + void operator=( const TiXmlNode& base ); // not allowed. +}; + + +/** An attribute is a name-value pair. Elements have an arbitrary + number of attributes, each with a unique name. + + @note The attributes are not TiXmlNodes, since they are not + part of the tinyXML document object model. There are other + suggested ways to look at this problem. +*/ +class TiXmlAttribute : public TiXmlBase +{ + friend class TiXmlAttributeSet; + +public: + /// Construct an empty attribute. + TiXmlAttribute() : TiXmlBase() + { + document = 0; + prev = next = 0; + } + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlAttribute( const std::string& _name, const std::string& _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + #endif + + /// Construct an attribute with a name and value. + TiXmlAttribute( const char * _name, const char * _value ) + { + name = _name; + value = _value; + document = 0; + prev = next = 0; + } + + const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. + const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. + #ifdef TIXML_USE_STL + const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. + #endif + int IntValue() const; ///< Return the value of this attribute, converted to an integer. + double DoubleValue() const; ///< Return the value of this attribute, converted to a double. + + // Get the tinyxml string representation + const TIXML_STRING& NameTStr() const { return name; } + + /** QueryIntValue examines the value string. It is an alternative to the + IntValue() method with richer error checking. + If the value is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. + + A specialized but useful call. Note that for success it returns 0, + which is the opposite of almost all other TinyXml calls. + */ + int QueryIntValue( int* _value ) const; + /// QueryDoubleValue examines the value string. See QueryIntValue(). + int QueryDoubleValue( double* _value ) const; + + void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. + void SetValue( const char* _value ) { value = _value; } ///< Set the value. + + void SetIntValue( int _value ); ///< Set the value from an integer. + void SetDoubleValue( double _value ); ///< Set the value from a double. + + #ifdef TIXML_USE_STL + /// STL std::string form. + void SetName( const std::string& _name ) { name = _name; } + /// STL std::string form. + void SetValue( const std::string& _value ) { value = _value; } + #endif + + /// Get the next sibling attribute in the DOM. Returns null at end. + const TiXmlAttribute* Next() const; + TiXmlAttribute* Next() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); + } + + /// Get the previous sibling attribute in the DOM. Returns null at beginning. + const TiXmlAttribute* Previous() const; + TiXmlAttribute* Previous() { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); + } + + bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } + bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } + bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } + + /* Attribute parsing starts: first letter of the name + returns: the next char after the value end quote + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + // Prints this Attribute to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + + // [internal use] + // Set the document pointer so the attribute can report errors. + void SetDocument( TiXmlDocument* doc ) { document = doc; } + +private: + TiXmlAttribute( const TiXmlAttribute& ); // not implemented. + void operator=( const TiXmlAttribute& base ); // not allowed. + + TiXmlDocument* document; // A pointer back to a document, for error reporting. + TIXML_STRING name; + TIXML_STRING value; + TiXmlAttribute* prev; + TiXmlAttribute* next; +}; + + +/* A class used to manage a group of attributes. + It is only used internally, both by the ELEMENT and the DECLARATION. + + The set can be changed transparent to the Element and Declaration + classes that use it, but NOT transparent to the Attribute + which has to implement a next() and previous() method. Which makes + it a bit problematic and prevents the use of STL. + + This version is implemented with circular lists because: + - I like circular lists + - it demonstrates some independence from the (typical) doubly linked list. +*/ +class TiXmlAttributeSet +{ +public: + TiXmlAttributeSet(); + ~TiXmlAttributeSet(); + + void Add( TiXmlAttribute* attribute ); + void Remove( TiXmlAttribute* attribute ); + + const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } + const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } + + const TiXmlAttribute* Find( const char* _name ) const; + TiXmlAttribute* Find( const char* _name ) { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); + } + #ifdef TIXML_USE_STL + const TiXmlAttribute* Find( const std::string& _name ) const; + TiXmlAttribute* Find( const std::string& _name ) { + return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) ); + } + + #endif + +private: + //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), + //*ME: this class must be also use a hidden/disabled copy-constructor !!! + TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed + void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) + + TiXmlAttribute sentinel; +}; + + +/** The element is a container class. It has a value, the element name, + and can contain other elements, text, comments, and unknowns. + Elements also contain an arbitrary number of attributes. +*/ +class TiXmlElement : public TiXmlNode +{ +public: + /// Construct an element. + TiXmlElement (const char * in_value); + + #ifdef TIXML_USE_STL + /// std::string constructor. + TiXmlElement( const std::string& _value ); + #endif + + TiXmlElement( const TiXmlElement& ); + + void operator=( const TiXmlElement& base ); + + virtual ~TiXmlElement(); + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + */ + const char* Attribute( const char* name ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an integer, + the integer value will be put in the return 'i', if 'i' + is non-null. + */ + const char* Attribute( const char* name, int* i ) const; + + /** Given an attribute name, Attribute() returns the value + for the attribute of that name, or null if none exists. + If the attribute exists and can be converted to an double, + the double value will be put in the return 'd', if 'd' + is non-null. + */ + const char* Attribute( const char* name, double* d ) const; + + /** QueryIntAttribute examines the attribute - it is an alternative to the + Attribute() method with richer error checking. + If the attribute is an integer, it is stored in 'value' and + the call returns TIXML_SUCCESS. If it is not + an integer, it returns TIXML_WRONG_TYPE. If the attribute + does not exist, then TIXML_NO_ATTRIBUTE is returned. + */ + int QueryIntAttribute( const char* name, int* _value ) const; + /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). + int QueryDoubleAttribute( const char* name, double* _value ) const; + /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). + int QueryFloatAttribute( const char* name, float* _value ) const { + double d; + int result = QueryDoubleAttribute( name, &d ); + if ( result == TIXML_SUCCESS ) { + *_value = (float)d; + } + return result; + } + + #ifdef TIXML_USE_STL + /** Template form of the attribute query which will try to read the + attribute into the specified type. Very easy, very powerful, but + be careful to make sure to call this with the correct type. + + NOTE: This method doesn't work correctly for 'string' types. + + @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE + */ + template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + + std::stringstream sstream( node->ValueStr() ); + sstream >> *outValue; + if ( !sstream.fail() ) + return TIXML_SUCCESS; + return TIXML_WRONG_TYPE; + } + /* + This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string" + but template specialization is hard to get working cross-compiler. Leaving the bug for now. + + // The above will fail for std::string because the space character is used as a seperator. + // Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string + template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const + { + const TiXmlAttribute* node = attributeSet.Find( name ); + if ( !node ) + return TIXML_NO_ATTRIBUTE; + *outValue = node->ValueStr(); + return TIXML_SUCCESS; + } + */ + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char* name, const char * _value ); + + #ifdef TIXML_USE_STL + const std::string* Attribute( const std::string& name ) const; + const std::string* Attribute( const std::string& name, int* i ) const; + const std::string* Attribute( const std::string& name, double* d ) const; + int QueryIntAttribute( const std::string& name, int* _value ) const; + int QueryDoubleAttribute( const std::string& name, double* _value ) const; + + /// STL std::string form. + void SetAttribute( const std::string& name, const std::string& _value ); + ///< STL std::string form. + void SetAttribute( const std::string& name, int _value ); + #endif + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetAttribute( const char * name, int value ); + + /** Sets an attribute of name to a given value. The attribute + will be created if it does not exist, or changed if it does. + */ + void SetDoubleAttribute( const char * name, double value ); + + /** Deletes an attribute with the given name. + */ + void RemoveAttribute( const char * name ); + #ifdef TIXML_USE_STL + void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. + #endif + + const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. + TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } + const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. + TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } + + /** Convenience function for easy access to the text inside an element. Although easy + and concise, GetText() is limited compared to getting the TiXmlText child + and accessing it directly. + + If the first child of 'this' is a TiXmlText, the GetText() + returns the character string of the Text node, else null is returned. + + This is a convenient method for getting the text of simple contained text: + @verbatim + <foo>This is text</foo> + const char* str = fooElement->GetText(); + @endverbatim + + 'str' will be a pointer to "This is text". + + Note that this function can be misleading. If the element foo was created from + this XML: + @verbatim + <foo><b>This is text</b></foo> + @endverbatim + + then the value of str would be null. The first child node isn't a text node, it is + another element. From this XML: + @verbatim + <foo>This is <b>text</b></foo> + @endverbatim + GetText() will return "This is ". + + WARNING: GetText() accesses a child node - don't become confused with the + similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are + safe type casts on the referenced node. + */ + const char* GetText() const; + + /// Creates a new Element and returns it - the returned element is a copy. + virtual TiXmlNode* Clone() const; + // Print the Element to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /* Attribtue parsing starts: next char past '<' + returns: next char past '>' + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + + void CopyTo( TiXmlElement* target ) const; + void ClearThis(); // like clear, but initializes 'this' object as well + + // Used to be public [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + /* [internal use] + Reads the "value" of the element -- another element, or text. + This should terminate with the current end tag. + */ + const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + +private: + + TiXmlAttributeSet attributeSet; +}; + + +/** An XML comment. +*/ +class TiXmlComment : public TiXmlNode +{ +public: + /// Constructs an empty comment. + TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {} + /// Construct a comment from text. + TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) { + SetValue( _value ); + } + TiXmlComment( const TiXmlComment& ); + void operator=( const TiXmlComment& base ); + + virtual ~TiXmlComment() {} + + /// Returns a copy of this Comment. + virtual TiXmlNode* Clone() const; + // Write this Comment to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /* Attribtue parsing starts: at the ! of the !-- + returns: next char past '>' + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + void CopyTo( TiXmlComment* target ) const; + + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif +// virtual void StreamOut( TIXML_OSTREAM * out ) const; + +private: + +}; + + +/** XML text. A text node can have 2 ways to output the next. "normal" output + and CDATA. It will default to the mode it was parsed from the XML file and + you generally want to leave it alone, but you can change the output mode with + SetCDATA() and query it with CDATA(). +*/ +class TiXmlText : public TiXmlNode +{ + friend class TiXmlElement; +public: + /** Constructor for text element. By default, it is treated as + normal, encoded text. If you want it be output as a CDATA text + element, set the parameter _cdata to 'true' + */ + TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT) + { + SetValue( initValue ); + cdata = false; + } + virtual ~TiXmlText() {} + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT) + { + SetValue( initValue ); + cdata = false; + } + #endif + + TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT ) { copy.CopyTo( this ); } + void operator=( const TiXmlText& base ) { base.CopyTo( this ); } + + // Write this text object to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + /// Queries whether this represents text using a CDATA section. + bool CDATA() const { return cdata; } + /// Turns on or off a CDATA representation of text. + void SetCDATA( bool _cdata ) { cdata = _cdata; } + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected : + /// [internal use] Creates a new Element and returns it. + virtual TiXmlNode* Clone() const; + void CopyTo( TiXmlText* target ) const; + + bool Blank() const; // returns true if all white space and new lines + // [internal use] + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + bool cdata; // true if this should be input and output as a CDATA style text element +}; + + +/** In correct XML the declaration is the first entry in the file. + @verbatim + <?xml version="1.0" standalone="yes"?> + @endverbatim + + TinyXml will happily read or write files without a declaration, + however. There are 3 possible attributes to the declaration: + version, encoding, and standalone. + + Note: In this version of the code, the attributes are + handled as special cases, not generic attributes, simply + because there can only be at most 3 and they are always the same. +*/ +class TiXmlDeclaration : public TiXmlNode +{ +public: + /// Construct an empty declaration. + TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {} + +#ifdef TIXML_USE_STL + /// Constructor. + TiXmlDeclaration( const std::string& _version, + const std::string& _encoding, + const std::string& _standalone ); +#endif + + /// Construct. + TiXmlDeclaration( const char* _version, + const char* _encoding, + const char* _standalone ); + + TiXmlDeclaration( const TiXmlDeclaration& copy ); + void operator=( const TiXmlDeclaration& copy ); + + virtual ~TiXmlDeclaration() {} + + /// Version. Will return an empty string if none was found. + const char *Version() const { return version.c_str (); } + /// Encoding. Will return an empty string if none was found. + const char *Encoding() const { return encoding.c_str (); } + /// Is this a standalone document? + const char *Standalone() const { return standalone.c_str (); } + + /// Creates a copy of this Declaration and returns it. + virtual TiXmlNode* Clone() const; + // Print this declaration to a FILE stream. + virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; + virtual void Print( FILE* cfile, int depth ) const { + Print( cfile, depth, 0 ); + } + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* visitor ) const; + +protected: + void CopyTo( TiXmlDeclaration* target ) const; + // used to be public + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + + TIXML_STRING version; + TIXML_STRING encoding; + TIXML_STRING standalone; +}; + + +/** Any tag that tinyXml doesn't recognize is saved as an + unknown. It is a tag of text, but should not be modified. + It will be written back to the XML, unchanged, when the file + is saved. + + DTD tags get thrown into TiXmlUnknowns. +*/ +class TiXmlUnknown : public TiXmlNode +{ +public: + TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {} + virtual ~TiXmlUnknown() {} + + TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN ) { copy.CopyTo( this ); } + void operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); } + + /// Creates a copy of this Unknown and returns it. + virtual TiXmlNode* Clone() const; + // Print this Unknown to a FILE stream. + virtual void Print( FILE* cfile, int depth ) const; + + virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); + + virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected: + void CopyTo( TiXmlUnknown* target ) const; + + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + +}; + + +/** Always the top level node. A document binds together all the + XML pieces. It can be saved, loaded, and printed to the screen. + The 'value' of a document node is the xml file name. +*/ +class TiXmlDocument : public TiXmlNode +{ +public: + /// Create an empty document, that has no name. + TiXmlDocument(); + /// Create a document with a name. The name of the document is also the filename of the xml. + TiXmlDocument( const char * documentName ); + + #ifdef TIXML_USE_STL + /// Constructor. + TiXmlDocument( const std::string& documentName ); + #endif + + TiXmlDocument( const TiXmlDocument& copy ); + void operator=( const TiXmlDocument& copy ); + + virtual ~TiXmlDocument() {} + + /** Load a file using the current document value. + Returns true if successful. Will delete any existing + document data before loading. + */ + bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the current document value. Returns true if successful. + bool SaveFile() const; + /// Load a file using the given filename. Returns true if successful. + bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given filename. Returns true if successful. + bool SaveFile( const char * filename ) const; + /** Load a file using the given FILE*. Returns true if successful. Note that this method + doesn't stream - the entire object pointed at by the FILE* + will be interpreted as an XML file. TinyXML doesn't stream in XML from the current + file location. Streaming may be added in the future. + */ + bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + /// Save a file using the given FILE*. Returns true if successful. + bool SaveFile( FILE* ) const; + + #ifdef TIXML_USE_STL + bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. + { +// StringToBuffer f( filename ); +// return ( f.buffer && LoadFile( f.buffer, encoding )); + return LoadFile( filename.c_str(), encoding ); + } + bool SaveFile( const std::string& filename ) const ///< STL std::string version. + { +// StringToBuffer f( filename ); +// return ( f.buffer && SaveFile( f.buffer )); + return SaveFile( filename.c_str() ); + } + #endif + + /** Parse the given null terminated block of xml data. Passing in an encoding to this + method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml + to use that encoding, regardless of what TinyXml might otherwise try to detect. + */ + virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); + + /** Get the root element -- the only top level element -- of the document. + In well formed XML, there should only be one. TinyXml is tolerant of + multiple elements at the document level. + */ + const TiXmlElement* RootElement() const { return FirstChildElement(); } + TiXmlElement* RootElement() { return FirstChildElement(); } + + /** If an error occurs, Error will be set to true. Also, + - The ErrorId() will contain the integer identifier of the error (not generally useful) + - The ErrorDesc() method will return the name of the error. (very useful) + - The ErrorRow() and ErrorCol() will return the location of the error (if known) + */ + bool Error() const { return error; } + + /// Contains a textual (english) description of the error if one occurs. + const char * ErrorDesc() const { return errorDesc.c_str (); } + + /** Generally, you probably want the error string ( ErrorDesc() ). But if you + prefer the ErrorId, this function will fetch it. + */ + int ErrorId() const { return errorId; } + + /** Returns the location (if known) of the error. The first column is column 1, + and the first row is row 1. A value of 0 means the row and column wasn't applicable + (memory errors, for example, have no row/column) or the parser lost the error. (An + error in the error reporting, in that case.) + + @sa SetTabSize, Row, Column + */ + int ErrorRow() const { return errorLocation.row+1; } + int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() + + /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) + to report the correct values for row and column. It does not change the output + or input in any way. + + By calling this method, with a tab size + greater than 0, the row and column of each node and attribute is stored + when the file is loaded. Very useful for tracking the DOM back in to + the source file. + + The tab size is required for calculating the location of nodes. If not + set, the default of 4 is used. The tabsize is set per document. Setting + the tabsize to 0 disables row/column tracking. + + Note that row and column tracking is not supported when using operator>>. + + The tab size needs to be enabled before the parse or load. Correct usage: + @verbatim + TiXmlDocument doc; + doc.SetTabSize( 8 ); + doc.Load( "myfile.xml" ); + @endverbatim + + @sa Row, Column + */ + void SetTabSize( int _tabsize ) { tabsize = _tabsize; } + + int TabSize() const { return tabsize; } + + /** If you have handled the error, it can be reset with this call. The error + state is automatically cleared if you Parse a new XML block. + */ + void ClearError() { error = false; + errorId = 0; + errorDesc = ""; + errorLocation.row = errorLocation.col = 0; + //errorLocation.last = 0; + } + + /** Write the document to standard out using formatted printing ("pretty print"). */ + void Print() const { Print( stdout, 0 ); } + + /* Write the document to a string using formatted printing ("pretty print"). This + will allocate a character array (new char[]) and return it as a pointer. The + calling code pust call delete[] on the return char* to avoid a memory leak. + */ + //char* PrintToMemory() const; + + /// Print this Document to a FILE stream. + virtual void Print( FILE* cfile, int depth = 0 ) const; + // [internal use] + void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); + + virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. + + /** Walk the XML tree visiting this node and all of its children. + */ + virtual bool Accept( TiXmlVisitor* content ) const; + +protected : + // [internal use] + virtual TiXmlNode* Clone() const; + #ifdef TIXML_USE_STL + virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); + #endif + +private: + void CopyTo( TiXmlDocument* target ) const; + + bool error; + int errorId; + TIXML_STRING errorDesc; + int tabsize; + TiXmlCursor errorLocation; + bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. +}; + + +/** + A TiXmlHandle is a class that wraps a node pointer with null checks; this is + an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml + DOM structure. It is a separate utility class. + + Take an example: + @verbatim + <Document> + <Element attributeA = "valueA"> + <Child attributeB = "value1" /> + <Child attributeB = "value2" /> + </Element> + <Document> + @endverbatim + + Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very + easy to write a *lot* of code that looks like: + + @verbatim + TiXmlElement* root = document.FirstChildElement( "Document" ); + if ( root ) + { + TiXmlElement* element = root->FirstChildElement( "Element" ); + if ( element ) + { + TiXmlElement* child = element->FirstChildElement( "Child" ); + if ( child ) + { + TiXmlElement* child2 = child->NextSiblingElement( "Child" ); + if ( child2 ) + { + // Finally do something useful. + @endverbatim + + And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity + of such code. A TiXmlHandle checks for null pointers so it is perfectly safe + and correct to use: + + @verbatim + TiXmlHandle docHandle( &document ); + TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); + if ( child2 ) + { + // do something useful + @endverbatim + + Which is MUCH more concise and useful. + + It is also safe to copy handles - internally they are nothing more than node pointers. + @verbatim + TiXmlHandle handleCopy = handle; + @endverbatim + + What they should not be used for is iteration: + + @verbatim + int i=0; + while ( true ) + { + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); + if ( !child ) + break; + // do something + ++i; + } + @endverbatim + + It seems reasonable, but it is in fact two embedded while loops. The Child method is + a linear walk to find the element, so this code would iterate much more than it needs + to. Instead, prefer: + + @verbatim + TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); + + for( child; child; child=child->NextSiblingElement() ) + { + // do something + } + @endverbatim +*/ +class TiXmlHandle +{ +public: + /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. + TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } + /// Copy constructor + TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } + TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; } + + /// Return a handle to the first child node. + TiXmlHandle FirstChild() const; + /// Return a handle to the first child node with the given name. + TiXmlHandle FirstChild( const char * value ) const; + /// Return a handle to the first child element. + TiXmlHandle FirstChildElement() const; + /// Return a handle to the first child element with the given name. + TiXmlHandle FirstChildElement( const char * value ) const; + + /** Return a handle to the "index" child with the given name. + The first child is 0, the second 1, etc. + */ + TiXmlHandle Child( const char* value, int index ) const; + /** Return a handle to the "index" child. + The first child is 0, the second 1, etc. + */ + TiXmlHandle Child( int index ) const; + /** Return a handle to the "index" child element with the given name. + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ + TiXmlHandle ChildElement( const char* value, int index ) const; + /** Return a handle to the "index" child element. + The first child element is 0, the second 1, etc. Note that only TiXmlElements + are indexed: other types are not counted. + */ + TiXmlHandle ChildElement( int index ) const; + + #ifdef TIXML_USE_STL + TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } + TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } + + TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } + TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } + #endif + + /** Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* ToNode() const { return node; } + /** Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } + /** Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } + /** Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } + + /** @deprecated use ToNode. + Return the handle as a TiXmlNode. This may return null. + */ + TiXmlNode* Node() const { return ToNode(); } + /** @deprecated use ToElement. + Return the handle as a TiXmlElement. This may return null. + */ + TiXmlElement* Element() const { return ToElement(); } + /** @deprecated use ToText() + Return the handle as a TiXmlText. This may return null. + */ + TiXmlText* Text() const { return ToText(); } + /** @deprecated use ToUnknown() + Return the handle as a TiXmlUnknown. This may return null. + */ + TiXmlUnknown* Unknown() const { return ToUnknown(); } + +private: + TiXmlNode* node; +}; + + +/** Print to memory functionality. The TiXmlPrinter is useful when you need to: + + -# Print to memory (especially in non-STL mode) + -# Control formatting (line endings, etc.) + + When constructed, the TiXmlPrinter is in its default "pretty printing" mode. + Before calling Accept() you can call methods to control the printing + of the XML document. After TiXmlNode::Accept() is called, the printed document can + be accessed via the CStr(), Str(), and Size() methods. + + TiXmlPrinter uses the Visitor API. + @verbatim + TiXmlPrinter printer; + printer.SetIndent( "\t" ); + + doc.Accept( &printer ); + fprintf( stdout, "%s", printer.CStr() ); + @endverbatim +*/ +class TiXmlPrinter : public TiXmlVisitor +{ +public: + TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), + buffer(), indent( " " ), lineBreak( "\n" ) {} + + virtual bool VisitEnter( const TiXmlDocument& doc ); + virtual bool VisitExit( const TiXmlDocument& doc ); + + virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); + virtual bool VisitExit( const TiXmlElement& element ); + + virtual bool Visit( const TiXmlDeclaration& declaration ); + virtual bool Visit( const TiXmlText& text ); + virtual bool Visit( const TiXmlComment& comment ); + virtual bool Visit( const TiXmlUnknown& unknown ); + + /** Set the indent characters for printing. By default 4 spaces + but tab (\t) is also useful, or null/empty string for no indentation. + */ + void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } + /// Query the indention string. + const char* Indent() { return indent.c_str(); } + /** Set the line breaking string. By default set to newline (\n). + Some operating systems prefer other characters, or can be + set to the null/empty string for no indenation. + */ + void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } + /// Query the current line breaking string. + const char* LineBreak() { return lineBreak.c_str(); } + + /** Switch over to "stream printing" which is the most dense formatting without + linebreaks. Common when the XML is needed for network transmission. + */ + void SetStreamPrinting() { indent = ""; + lineBreak = ""; + } + /// Return the result. + const char* CStr() { return buffer.c_str(); } + /// Return the length of the result string. + size_t Size() { return buffer.size(); } + + #ifdef TIXML_USE_STL + /// Return the result. + const std::string& Str() { return buffer; } + #endif + +private: + void DoIndent() { + for( int i=0; i<depth; ++i ) + buffer += indent; + } + void DoLineBreak() { + buffer += lineBreak; + } + + int depth; + bool simpleTextPrint; + TIXML_STRING buffer; + TIXML_STRING indent; + TIXML_STRING lineBreak; +}; + + +#ifdef _MSC_VER +#pragma warning( pop ) +#endif + +#endif + diff --git a/library/tinyxml/tinyxmlerror.cpp b/library/tinyxml/tinyxmlerror.cpp new file mode 100644 index 00000000..3f068f2b --- /dev/null +++ b/library/tinyxml/tinyxmlerror.cpp @@ -0,0 +1,53 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include "tinyxml.h" + +// The goal of the seperate error file is to make the first +// step towards localization. tinyxml (currently) only supports +// english error messages, but the could now be translated. +// +// It also cleans up the code a bit. +// + +const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = +{ + "No error", + "Error", + "Failed to open file", + "Memory allocation failed.", + "Error parsing Element.", + "Failed to read Element name", + "Error reading Element value.", + "Error reading Attributes.", + "Error: empty tag.", + "Error reading end tag.", + "Error parsing Unknown.", + "Error parsing Comment.", + "Error parsing Declaration.", + "Error document empty.", + "Error null (0) or unexpected EOF found in input stream.", + "Error parsing CDATA.", + "Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", +}; diff --git a/library/tinyxml/tinyxmlparser.cpp b/library/tinyxml/tinyxmlparser.cpp new file mode 100644 index 00000000..2f6c0bc1 --- /dev/null +++ b/library/tinyxml/tinyxmlparser.cpp @@ -0,0 +1,1660 @@ +/* +www.sourceforge.net/projects/tinyxml +Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include <ctype.h> +#include <stddef.h> + +#include "tinyxml.h" + +//#define DEBUG_PARSER +#if defined( DEBUG_PARSER ) +# if defined( DEBUG ) && defined( _MSC_VER ) +# include <windows.h> +# define TIXML_LOG OutputDebugString +# else +# define TIXML_LOG printf +# endif +#endif + +// Note tha "PutString" hardcodes the same list. This +// is less flexible than it appears. Changing the entries +// or order will break putstring. +TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = +{ + { "&", 5, '&' }, + { "<", 4, '<' }, + { ">", 4, '>' }, + { """, 6, '\"' }, + { "'", 6, '\'' } +}; + +// Bunch of unicode info at: +// http://www.unicode.org/faq/utf_bom.html +// Including the basic of this table, which determines the #bytes in the +// sequence from the lead byte. 1 placed for invalid sequences -- +// although the result will be junk, pass it through as much as possible. +// Beware of the non-characters in UTF-8: +// ef bb bf (Microsoft "lead bytes") +// ef bf be +// ef bf bf + +const unsigned char TIXML_UTF_LEAD_0 = 0xefU; +const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; +const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; + +const int TiXmlBase::utf8ByteTable[256] = +{ + // 0 1 2 3 4 5 6 7 8 9 a b c d e f + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte + 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid +}; + + +void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) +{ + const unsigned long BYTE_MASK = 0xBF; + const unsigned long BYTE_MARK = 0x80; + const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; + + if (input < 0x80) + *length = 1; + else if ( input < 0x800 ) + *length = 2; + else if ( input < 0x10000 ) + *length = 3; + else if ( input < 0x200000 ) + *length = 4; + else + { + *length = 0; // This code won't covert this correctly anyway. + return; + } + + output += *length; + + // Scary scary fall throughs. + switch (*length) + { + case 4: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 3: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 2: + --output; + *output = (char)((input | BYTE_MARK) & BYTE_MASK); + input >>= 6; + case 1: + --output; + *output = (char)(input | FIRST_BYTE_MARK[*length]); + } +} + + +/*static*/ +int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) +{ + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + +// if ( encoding == TIXML_ENCODING_UTF8 ) +// { + if ( anyByte < 127 ) + return isalpha( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. +// } +// else +// { +// return isalpha( anyByte ); +// } +} + + +/*static*/ +int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) +{ + // This will only work for low-ascii, everything else is assumed to be a valid + // letter. I'm not sure this is the best approach, but it is quite tricky trying + // to figure out alhabetical vs. not across encoding. So take a very + // conservative approach. + +// if ( encoding == TIXML_ENCODING_UTF8 ) +// { + if ( anyByte < 127 ) + return isalnum( anyByte ); + else + return 1; // What else to do? The unicode set is huge...get the english ones right. +// } +// else +// { +// return isalnum( anyByte ); +// } +} + + +class TiXmlParsingData +{ + friend class TiXmlDocument; +public: + void Stamp( const char* now, TiXmlEncoding encoding ); + + const TiXmlCursor& Cursor() + { + return cursor; + } + +private: + // Only used by the document! + TiXmlParsingData( const char* start, int _tabsize, int row, int col ) + { + assert( start ); + stamp = start; + tabsize = _tabsize; + cursor.row = row; + cursor.col = col; + } + + TiXmlCursor cursor; + const char* stamp; + int tabsize; +}; + + +void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) +{ + assert( now ); + + // Do nothing if the tabsize is 0. + if ( tabsize < 1 ) + { + return; + } + + // Get the current row, column. + int row = cursor.row; + int col = cursor.col; + const char* p = stamp; + assert( p ); + + while ( p < now ) + { + // Treat p as unsigned, so we have a happy compiler. + const unsigned char* pU = (const unsigned char*)p; + + // Code contributed by Fletcher Dunn: (modified by lee) + switch (*pU) + { + case 0: + // We *should* never get here, but in case we do, don't + // advance past the terminating null character, ever + return; + + case '\r': + // bump down to the next line + ++row; + col = 0; + // Eat the character + ++p; + + // Check for \r\n sequence, and treat this as a single character + if (*p == '\n') + { + ++p; + } + break; + + case '\n': + // bump down to the next line + ++row; + col = 0; + + // Eat the character + ++p; + + // Check for \n\r sequence, and treat this as a single + // character. (Yes, this bizarre thing does occur still + // on some arcane platforms...) + if (*p == '\r') + { + ++p; + } + break; + + case '\t': + // Eat the character + ++p; + + // Skip to next tab stop + col = (col / tabsize + 1) * tabsize; + break; + + case TIXML_UTF_LEAD_0: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + if ( *(p+1) && *(p+2) ) + { + // In these cases, don't advance the column. These are + // 0-width spaces. + if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) + p += 3; + else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) + p += 3; + else + { + p +=3; // A normal character. + ++col; + } + } + } + else + { + ++p; + ++col; + } + break; + + default: + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // Eat the 1 to 4 byte utf8 character. + int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; + if ( step == 0 ) + step = 1; // Error case from bad encoding, but handle gracefully. + p += step; + + // Just advance one column, of course. + ++col; + } + else + { + ++p; + ++col; + } + break; + } + } + cursor.row = row; + cursor.col = col; + assert( cursor.row >= -1 ); + assert( cursor.col >= -1 ); + stamp = p; + assert( stamp ); +} + + +const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) +{ + if ( !p || !*p ) + { + return 0; + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + while ( *p ) + { + const unsigned char* pU = (const unsigned char*)p; + + // Skip the stupid Microsoft UTF-8 Byte order marks + if ( *(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==TIXML_UTF_LEAD_1 + && *(pU+2)==TIXML_UTF_LEAD_2 ) + { + p += 3; + continue; + } + else if (*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbeU ) + { + p += 3; + continue; + } + else if (*(pU+0)==TIXML_UTF_LEAD_0 + && *(pU+1)==0xbfU + && *(pU+2)==0xbfU ) + { + p += 3; + continue; + } + + if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) // Still using old rules for white space. + ++p; + else + break; + } + } + else + { + while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' ) + ++p; + } + + return p; +} + +#ifdef TIXML_USE_STL +/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) +{ + for ( ;; ) + { + if ( !in->good() ) return false; + + int c = in->peek(); + // At this scope, we can't get to a document. So fail silently. + if ( !IsWhiteSpace( c ) || c <= 0 ) + return true; + + *tag += (char) in->get(); + } +} + +/*static*/ +bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) +{ + //assert( character > 0 && character < 128 ); // else it won't work in utf-8 + while ( in->good() ) + { + int c = in->peek(); + if ( c == character ) + return true; + if ( c <= 0 ) // Silent failure: can't get document at this scope + return false; + + in->get(); + *tag += (char) c; + } + return false; +} +#endif + +// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The +// "assign" optimization removes over 10% of the execution time. +// +const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) +{ + // Oddly, not supported on some comilers, + //name->clear(); + // So use this: + *name = ""; + assert( p ); + + // Names start with letters or underscores. + // Of course, in unicode, tinyxml has no idea what a letter *is*. The + // algorithm is generous. + // + // After that, they can be letters, underscores, numbers, + // hyphens, or colons. (Colons are valid ony for namespaces, + // but tinyxml can't tell namespaces from names.) + if ( p && *p + && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) + { + const char* start = p; + while ( p && *p + && ( IsAlphaNum( (unsigned char ) *p, encoding ) + || *p == '_' + || *p == '-' + || *p == '.' + || *p == ':' ) ) + { + //(*name) += *p; // expensive + ++p; + } + if ( p-start > 0 ) + { + name->assign( start, p-start ); + } + return p; + } + return 0; +} + +const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) +{ + // Presume an entity, and pull it out. + TIXML_STRING ent; + int i; + *length = 0; + + if ( *(p+1) && *(p+1) == '#' && *(p+2) ) + { + unsigned long ucs = 0; + ptrdiff_t delta = 0; + unsigned mult = 1; + + if ( *(p+2) == 'x' ) + { + // Hexadecimal. + if ( !*(p+3) ) return 0; + + const char* q = p+3; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != 'x' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else if ( *q >= 'a' && *q <= 'f' ) + ucs += mult * (*q - 'a' + 10); + else if ( *q >= 'A' && *q <= 'F' ) + ucs += mult * (*q - 'A' + 10 ); + else + return 0; + mult *= 16; + --q; + } + } + else + { + // Decimal. + if ( !*(p+2) ) return 0; + + const char* q = p+2; + q = strchr( q, ';' ); + + if ( !q || !*q ) return 0; + + delta = q-p; + --q; + + while ( *q != '#' ) + { + if ( *q >= '0' && *q <= '9' ) + ucs += mult * (*q - '0'); + else + return 0; + mult *= 10; + --q; + } + } + if ( encoding == TIXML_ENCODING_UTF8 ) + { + // convert the UCS to UTF-8 + ConvertUTF32ToUTF8( ucs, value, length ); + } + else + { + *value = (char)ucs; + *length = 1; + } + return p + delta + 1; + } + + // Now try to match it. + for ( i=0; i<NUM_ENTITY; ++i ) + { + if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 ) + { + assert( strlen( entity[i].str ) == entity[i].strLength ); + *value = entity[i].chr; + *length = 1; + return ( p + entity[i].strLength ); + } + } + + // So it wasn't an entity, its unrecognized, or something like that. + *value = *p; // Don't put back the last one, since we return it! + //*length = 1; // Leave unrecognized entities - this doesn't really work. + // Just writes strange XML. + return p+1; +} + + +bool TiXmlBase::StringEqual( const char* p, + const char* tag, + bool ignoreCase, + TiXmlEncoding encoding ) +{ + assert( p ); + assert( tag ); + if ( !p || !*p ) + { + assert( 0 ); + return false; + } + + const char* q = p; + + if ( ignoreCase ) + { + while ( *q && *tag && ToLower( *q, encoding ) == ToLower( *tag, encoding ) ) + { + ++q; + ++tag; + } + + if ( *tag == 0 ) + return true; + } + else + { + while ( *q && *tag && *q == *tag ) + { + ++q; + ++tag; + } + + if ( *tag == 0 ) // Have we found the end of the tag, and everything equal? + return true; + } + return false; +} + +const char* TiXmlBase::ReadText( const char* p, + TIXML_STRING * text, + bool trimWhiteSpace, + const char* endTag, + bool caseInsensitive, + TiXmlEncoding encoding ) +{ + *text = ""; + if ( !trimWhiteSpace // certain tags always keep whitespace + || !condenseWhiteSpace ) // if true, whitespace is always kept + { + // Keep all the white space. + while ( p && *p + && !StringEqual( p, endTag, caseInsensitive, encoding ) + ) + { + int len; + char cArr[4] = { 0, 0, 0, 0 }; + p = GetChar( p, cArr, &len, encoding ); + text->append( cArr, len ); + } + } + else + { + bool whitespace = false; + + // Remove leading white space: + p = SkipWhiteSpace( p, encoding ); + while ( p && *p + && !StringEqual( p, endTag, caseInsensitive, encoding ) ) + { + if ( *p == '\r' || *p == '\n' ) + { + whitespace = true; + ++p; + } + else if ( IsWhiteSpace( *p ) ) + { + whitespace = true; + ++p; + } + else + { + // If we've found whitespace, add it before the + // new character. Any whitespace just becomes a space. + if ( whitespace ) + { + (*text) += ' '; + whitespace = false; + } + int len; + char cArr[4] = { 0, 0, 0, 0 }; + p = GetChar( p, cArr, &len, encoding ); + if ( len == 1 ) + (*text) += cArr[0]; // more efficient + else + text->append( cArr, len ); + } + } + } + if ( p ) + p += strlen( endTag ); + return p; +} + +#ifdef TIXML_USE_STL + +void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + // The basic issue with a document is that we don't know what we're + // streaming. Read something presumed to be a tag (and hope), then + // identify it, and call the appropriate stream method on the tag. + // + // This "pre-streaming" will never read the closing ">" so the + // sub-tag can orient itself. + + if ( !StreamTo( in, '<', tag ) ) + { + SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + while ( in->good() ) + { + int tagIndex = (int) tag->length(); + while ( in->good() && in->peek() != '>' ) + { + int c = in->get(); + if ( c <= 0 ) + { + SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + break; + } + (*tag) += (char) c; + } + + if ( in->good() ) + { + // We now have something we presume to be a node of + // some sort. Identify it, and call the node to + // continue streaming. + TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); + + if ( node ) + { + node->StreamIn( in, tag ); + bool isElement = node->ToElement() != 0; + delete node; + node = 0; + + // If this is the root element, we're done. Parsing will be + // done by the >> operator. + if ( isElement ) + { + return; + } + } + else + { + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + } + } + // We should have returned sooner. + SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); +} + +#endif + +const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) +{ + ClearError(); + + // Parse away, at the document level. Since a document + // contains nothing but other tags, most of what happens + // here is skipping white space. + if ( !p || !*p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + // Note that, for a document, this needs to come + // before the while space skip, so that parsing + // starts from the pointer we are given. + location.Clear(); + if ( prevData ) + { + location.row = prevData->cursor.row; + location.col = prevData->cursor.col; + } + else + { + location.row = 0; + location.col = 0; + } + TiXmlParsingData data( p, TabSize(), location.row, location.col ); + location = data.Cursor(); + + if ( encoding == TIXML_ENCODING_UNKNOWN ) + { + // Check for the Microsoft UTF-8 lead bytes. + const unsigned char* pU = (const unsigned char*)p; + if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 + && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 + && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) + { + encoding = TIXML_ENCODING_UTF8; + useMicrosoftBOM = true; + } + } + + p = SkipWhiteSpace( p, encoding ); + if ( !p ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); + return 0; + } + + while ( p && *p ) + { + TiXmlNode* node = Identify( p, encoding ); + if ( node ) + { + p = node->Parse( p, &data, encoding ); + LinkEndChild( node ); + } + else + { + break; + } + + // Did we get encoding info? + if ( encoding == TIXML_ENCODING_UNKNOWN + && node->ToDeclaration() ) + { + TiXmlDeclaration* dec = node->ToDeclaration(); + const char* enc = dec->Encoding(); + assert( enc ); + + if ( *enc == 0 ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; + else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) + encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice + else + encoding = TIXML_ENCODING_LEGACY; + } + + p = SkipWhiteSpace( p, encoding ); + } + + // Was this empty? + if ( !firstChild ) + { + SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); + return 0; + } + + // All is well. + return p; +} + +void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + // The first error in a chain is more accurate - don't set again! + if ( error ) + return; + + assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); + error = true; + errorId = err; + errorDesc = errorString[ errorId ]; + + errorLocation.Clear(); + if ( pError && data ) + { + data->Stamp( pError, encoding ); + errorLocation = data->Cursor(); + } +} + + +TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) +{ + TiXmlNode* returnNode = 0; + + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p || *p != '<' ) + { + return 0; + } + + TiXmlDocument* doc = GetDocument(); + p = SkipWhiteSpace( p, encoding ); + + if ( !p || !*p ) + { + return 0; + } + + // What is this thing? + // - Elements start with a letter or underscore, but xml is reserved. + // - Comments: <!-- + // - Decleration: <?xml + // - Everthing else is unknown to tinyxml. + // + + const char* xmlHeader = { "<?xml" }; + const char* commentHeader = { "<!--" }; + const char* dtdHeader = { "<!" }; + const char* cdataHeader = { "<![CDATA[" }; + + if ( StringEqual( p, xmlHeader, true, encoding ) ) + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing Declaration\n" ); +#endif + returnNode = new TiXmlDeclaration(); + } + else if ( StringEqual( p, commentHeader, false, encoding ) ) + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing Comment\n" ); +#endif + returnNode = new TiXmlComment(); + } + else if ( StringEqual( p, cdataHeader, false, encoding ) ) + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing CDATA\n" ); +#endif + TiXmlText* text = new TiXmlText( "" ); + text->SetCDATA( true ); + returnNode = text; + } + else if ( StringEqual( p, dtdHeader, false, encoding ) ) + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing Unknown(1)\n" ); +#endif + returnNode = new TiXmlUnknown(); + } + else if ( IsAlpha( *(p+1), encoding ) + || *(p+1) == '_' ) + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing Element\n" ); +#endif + returnNode = new TiXmlElement( "" ); + } + else + { +#ifdef DEBUG_PARSER + TIXML_LOG( "XML parsing Unknown(2)\n" ); +#endif + returnNode = new TiXmlUnknown(); + } + + if ( returnNode ) + { + // Set the parent, so it can report errors + returnNode->parent = this; + } + else + { + if ( doc ) + doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN ); + } + return returnNode; +} + +#ifdef TIXML_USE_STL + +void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag) +{ + // We're called with some amount of pre-parsing. That is, some of "this" + // element is in "tag". Go ahead and stream to the closing ">" + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + (*tag) += (char) c ; + + if ( c == '>' ) + break; + } + + if ( tag->length() < 3 ) return; + + // Okay...if we are a "/>" tag, then we're done. We've read a complete tag. + // If not, identify and stream. + + if ( tag->at( tag->length() - 1 ) == '>' + && tag->at( tag->length() - 2 ) == '/' ) + { + // All good! + return; + } + else if ( tag->at( tag->length() - 1 ) == '>' ) + { + // There is more. Could be: + // text + // cdata text (which looks like another node) + // closing tag + // another node. + for ( ;; ) + { + StreamWhiteSpace( in, tag ); + + // Do we have text? + if ( in->good() && in->peek() != '<' ) + { + // Yep, text. + TiXmlText text( "" ); + text.StreamIn( in, tag ); + + // What follows text is a closing tag or another node. + // Go around again and figure it out. + continue; + } + + // We now have either a closing tag...or another node. + // We should be at a "<", regardless. + if ( !in->good() ) return; + assert( in->peek() == '<' ); + int tagIndex = (int) tag->length(); + + bool closingTag = false; + bool firstCharFound = false; + + for ( ;; ) + { + if ( !in->good() ) + return; + + int c = in->peek(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + if ( c == '>' ) + break; + + *tag += (char) c; + in->get(); + + // Early out if we find the CDATA id. + if ( c == '[' && tag->size() >= 9 ) + { + size_t len = tag->size(); + const char* start = tag->c_str() + len - 9; + if ( strcmp( start, "<![CDATA[" ) == 0 ) + { + assert( !closingTag ); + break; + } + } + + if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) ) + { + firstCharFound = true; + if ( c == '/' ) + closingTag = true; + } + } + // If it was a closing tag, then read in the closing '>' to clean up the input stream. + // If it was not, the streaming will be done by the tag. + if ( closingTag ) + { + if ( !in->good() ) + return; + + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + assert( c == '>' ); + *tag += (char) c; + + // We are done, once we've found our closing tag. + return; + } + else + { + // If not a closing tag, id it, and stream. + const char* tagloc = tag->c_str() + tagIndex; + TiXmlNode* node = Identify( tagloc, TIXML_DEFAULT_ENCODING ); + if ( !node ) + return; + node->StreamIn( in, tag ); + delete node; + node = 0; + + // No return: go around from the beginning: text, closing tag, or node. + } + } + } +} +#endif + +const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + p = SkipWhiteSpace( p, encoding ); + TiXmlDocument* document = GetDocument(); + + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding ); + return 0; + } + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + + if ( *p != '<' ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding ); + return 0; + } + + p = SkipWhiteSpace( p+1, encoding ); + + // Read the name. + const char* pErr = p; + + p = ReadName( p, &value, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding ); + return 0; + } + + TIXML_STRING endTag ("</"); + endTag += value; + endTag += ">"; + + // Check for and read attributes. Also look for an empty + // tag or an end tag. + while ( p && *p ) + { + pErr = p; + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); + return 0; + } + if ( *p == '/' ) + { + ++p; + // Empty tag. + if ( *p != '>' ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding ); + return 0; + } + return (p+1); + } + else if ( *p == '>' ) + { + // Done with attributes (if there were any.) + // Read the value -- which can include other + // elements -- read the end tag, and return. + ++p; + p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens. + if ( !p || !*p ) + { + // We were looking for the end tag, but found nothing. + // Fix for [ 1663758 ] Failure to report error on bad XML + if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); + return 0; + } + + // We should find the end tag now + if ( StringEqual( p, endTag.c_str(), false, encoding ) ) + { + p += endTag.length(); + return p; + } + else + { + if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding ); + return 0; + } + } + else + { + // Try to read an attribute: + TiXmlAttribute* attrib = new TiXmlAttribute(); + if ( !attrib ) + { + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding ); + return 0; + } + + attrib->SetDocument( document ); + pErr = p; + p = attrib->Parse( p, data, encoding ); + + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding ); + delete attrib; + return 0; + } + + // Handle the strange case of double attributes: +#ifdef TIXML_USE_STL + TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() ); +#else + TiXmlAttribute* node = attributeSet.Find( attrib->Name() ); +#endif + if ( node ) + { + node->SetValue( attrib->Value() ); + delete attrib; + return 0; + } + + attributeSet.Add( attrib ); + } + } + return p; +} + + +const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + TiXmlDocument* document = GetDocument(); + + // Read in text and elements in any order. + const char* pWithWhiteSpace = p; + p = SkipWhiteSpace( p, encoding ); + + while ( p && *p ) + { + if ( *p != '<' ) + { + // Take what we have, make a text element. + TiXmlText* textNode = new TiXmlText( "" ); + + if ( !textNode ) + { + if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding ); + return 0; + } + + if ( TiXmlBase::IsWhiteSpaceCondensed() ) + { + p = textNode->Parse( p, data, encoding ); + } + else + { + // Special case: we want to keep the white space + // so that leading spaces aren't removed. + p = textNode->Parse( pWithWhiteSpace, data, encoding ); + } + + if ( !textNode->Blank() ) + LinkEndChild( textNode ); + else + delete textNode; + } + else + { + // We hit a '<' + // Have we hit a new element or an end tag? This could also be + // a TiXmlText in the "CDATA" style. + if ( StringEqual( p, "</", false, encoding ) ) + { + return p; + } + else + { + TiXmlNode* node = Identify( p, encoding ); + if ( node ) + { + p = node->Parse( p, data, encoding ); + LinkEndChild( node ); + } + else + { + return 0; + } + } + } + pWithWhiteSpace = p; + p = SkipWhiteSpace( p, encoding ); + } + + if ( !p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding ); + } + return p; +} + + +#ifdef TIXML_USE_STL +void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + (*tag) += (char) c; + + if ( c == '>' ) + { + // All is well. + return; + } + } +} +#endif + + +const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + TiXmlDocument* document = GetDocument(); + p = SkipWhiteSpace( p, encoding ); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + if ( !p || !*p || *p != '<' ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding ); + return 0; + } + ++p; + value = ""; + + while ( p && *p && *p != '>' ) + { + value += *p; + ++p; + } + + if ( !p ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding ); + } + if ( *p == '>' ) + return p+1; + return p; +} + +#ifdef TIXML_USE_STL +void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + (*tag) += (char) c; + + if ( c == '>' + && tag->at( tag->length() - 2 ) == '-' + && tag->at( tag->length() - 3 ) == '-' ) + { + // All is well. + return; + } + } +} +#endif + + +const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + TiXmlDocument* document = GetDocument(); + value = ""; + + p = SkipWhiteSpace( p, encoding ); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + const char* startTag = "<!--"; + const char* endTag = "-->"; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // [ 1475201 ] TinyXML parses entities in comments + // Oops - ReadText doesn't work, because we don't want to parse the entities. + // p = ReadText( p, &value, false, endTag, false, encoding ); + // + // from the XML spec: + /* + [Definition: Comments may appear anywhere in a document outside other markup; in addition, + they may appear within the document type declaration at places allowed by the grammar. + They are not part of the document's character data; an XML processor MAY, but need not, + make it possible for an application to retrieve the text of comments. For compatibility, + the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity + references MUST NOT be recognized within comments. + + An example of a comment: + + <!-- declarations for <head> & <body> --> + */ + + value = ""; + // Keep all the white space. + while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) + { + value.append( p, 1 ); + ++p; + } + if ( p ) + p += strlen( endTag ); + + return p; +} + + +const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) return 0; + +// int tabsize = 4; +// if ( document ) +// tabsize = document->TabSize(); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + // Read the name, the '=' and the value. + const char* pErr = p; + p = ReadName( p, &name, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); + return 0; + } + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p || *p != '=' ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + ++p; // skip '=' + p = SkipWhiteSpace( p, encoding ); + if ( !p || !*p ) + { + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + + const char* end; + const char SINGLE_QUOTE = '\''; + const char DOUBLE_QUOTE = '\"'; + + if ( *p == SINGLE_QUOTE ) + { + ++p; + end = "\'"; // single quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else if ( *p == DOUBLE_QUOTE ) + { + ++p; + end = "\""; // double quote in string + p = ReadText( p, &value, false, end, false, encoding ); + } + else + { + // All attribute values should be in single or double quotes. + // But this is such a common error that the parser will try + // its best, even without them. + value = ""; + while ( p && *p // existence + && !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r' // whitespace + && *p != '/' && *p != '>' ) // tag end + { + if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) + { + // [ 1451649 ] Attribute values with trailing quotes not handled correctly + // We did not have an opening quote but seem to have a + // closing one. Give up and throw an error. + if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); + return 0; + } + value += *p; + ++p; + } + } + return p; +} + +#ifdef TIXML_USE_STL +void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->peek(); + if ( !cdata && (c == '<' ) ) + { + return; + } + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + + (*tag) += (char) c; + in->get(); // "commits" the peek made above + + if ( cdata && c == '>' && tag->size() >= 3 ) + { + size_t len = tag->size(); + if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) + { + // terminator of cdata. + return; + } + } + } +} +#endif + +const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) +{ + value = ""; + TiXmlDocument* document = GetDocument(); + + if ( data ) + { + data->Stamp( p, encoding ); + location = data->Cursor(); + } + + const char* const startTag = "<![CDATA["; + const char* const endTag = "]]>"; + + if ( cdata || StringEqual( p, startTag, false, encoding ) ) + { + cdata = true; + + if ( !StringEqual( p, startTag, false, encoding ) ) + { + document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); + return 0; + } + p += strlen( startTag ); + + // Keep all the white space, ignore the encoding, etc. + while ( p && *p + && !StringEqual( p, endTag, false, encoding ) + ) + { + value += *p; + ++p; + } + + TIXML_STRING dummy; + p = ReadText( p, &dummy, false, endTag, false, encoding ); + return p; + } + else + { + bool ignoreWhite = true; + + const char* end = "<"; + p = ReadText( p, &value, ignoreWhite, end, false, encoding ); + if ( p ) + return p-1; // don't truncate the '<' + return 0; + } +} + +#ifdef TIXML_USE_STL +void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) +{ + while ( in->good() ) + { + int c = in->get(); + if ( c <= 0 ) + { + TiXmlDocument* document = GetDocument(); + if ( document ) + document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); + return; + } + (*tag) += (char) c; + + if ( c == '>' ) + { + // All is well. + return; + } + } +} +#endif + +const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) +{ + p = SkipWhiteSpace( p, _encoding ); + // Find the beginning, find the end, and look for + // the stuff in-between. + TiXmlDocument* document = GetDocument(); + if ( !p || !*p || !StringEqual( p, "<?xml", true, _encoding ) ) + { + if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); + return 0; + } + if ( data ) + { + data->Stamp( p, _encoding ); + location = data->Cursor(); + } + p += 5; + + version = ""; + encoding = ""; + standalone = ""; + + while ( p && *p ) + { + if ( *p == '>' ) + { + ++p; + return p; + } + + p = SkipWhiteSpace( p, _encoding ); + if ( StringEqual( p, "version", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + version = attrib.Value(); + } + else if ( StringEqual( p, "encoding", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + encoding = attrib.Value(); + } + else if ( StringEqual( p, "standalone", true, _encoding ) ) + { + TiXmlAttribute attrib; + p = attrib.Parse( p, data, _encoding ); + standalone = attrib.Value(); + } + else + { + // Read over whatever it is. + while ( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) + ++p; + } + } + return 0; +} + +bool TiXmlText::Blank() const +{ + for ( unsigned i=0; i<value.length(); i++ ) + if ( !IsWhiteSpace( value[i] ) ) + return false; + return true; +} + diff --git a/resource.rc b/resource.rc index 575f739b..efc75705 100644 --- a/resource.rc +++ b/resource.rc @@ -1,2 +1,5 @@ #include "wx/msw/wx.rc" -winIcon ICON DISCARDABLE "library/FreeFileSync.ico" + +//naming convention to set icon sequence in executable file +ffsIcon1 ICON DISCARDABLE "library/FreeFileSync.ico" +ffsIcon2 ICON DISCARDABLE "library/Batch.ico" diff --git a/ui/MainDialog.cpp b/ui/MainDialog.cpp index 186126e2..94ad4708 100644 --- a/ui/MainDialog.cpp +++ b/ui/MainDialog.cpp @@ -15,6 +15,8 @@ #include <wx/file.h> #include "../library/customGrid.h" #include <algorithm> +#include "../library/tinyxml/tinyxml.h" +#include <wx/msgdlg.h> using namespace globalFunctions; @@ -32,8 +34,21 @@ MainDialog::MainDialog(wxFrame* frame, const wxString& cfgFileName, CustomLocale m_bpButtonCompare->SetLabel(_("&Compare")); m_bpButtonSync->SetLabel(_("&Synchronize")); - //initialize sync configuration - readConfigurationFromHD(cfgFileName, true); + //load list of last used configuration files + cfgFileHistory = new wxConfig(wxT("FreeFileSync")); + for (int i = CfgHistroyLength - 1; i >= 0; --i) //put files in reverse order to history + { + const wxString key = wxString(wxT("Selection")) + numberToWxString(i); + + wxString value; + if (cfgFileHistory->Read(key, &value)) + addCfgFileToHistory(value); + } + m_choiceLoad->SetSelection(0); + + //initialize and load configuration + readConfigurationFromXml(cfgFileName, true); + //readConfigurationFromHD(cfgFileName, true); leftOnlyFilesActive = true; leftNewerFilesActive = true; @@ -149,18 +164,6 @@ MainDialog::MainDialog(wxFrame* frame, const wxString& cfgFileName, CustomLocale //mainly to update row label sizes... writeGrid(currentGridData); - //load list of last used configuration files - cfgFileHistory = new wxConfig(wxT("FreeFileSync")); - for (int i = CfgHistroyLength - 1; i >= 0; --i) //put files in reverse order to history - { - const wxString key = wxString(wxT("Selection")) + numberToWxString(i); - - wxString value; - if (cfgFileHistory->Read(key, &value)) - addCfgFileToHistory(value); - } - m_choiceLoad->SetSelection(0); - //select rows only m_grid1->SetSelectionMode(wxGrid::wxGridSelectRows); m_grid2->SetSelectionMode(wxGrid::wxGridSelectRows); @@ -186,9 +189,23 @@ MainDialog::MainDialog(wxFrame* frame, const wxString& cfgFileName, CustomLocale case wxLANGUAGE_FRENCH: m_menuItemFrench->Check(); break; + case wxLANGUAGE_JAPANESE: + m_menuItemJapanese->Check(); + break; default: m_menuItemEnglish->Check(); } + + //create the compare status panel + compareStatus = new CompareStatus(this); + bSizer1->Insert(1, compareStatus, 0, wxEXPAND | wxBOTTOM, 5 ); + Layout(); //avoid screen flicker when panel is shown + compareStatus->Hide(); + + //correct height of middle grid + wxSize dirPickersize = sbSizer2->GetSize(); + wxSize swapButtonsize = bSizer69->GetSize(); + bSizer18->Insert(1, 0, dirPickersize.GetY() - swapButtonsize.GetY(), 0); } @@ -256,12 +273,14 @@ MainDialog::~MainDialog() else { if (cfgFileHistory->Exists(key)) - cfgFileHistory->DeleteEntry(key); + cfgFileHistory->DeleteEntry(key, false); } } delete cfgFileHistory; - writeConfigurationToHD(FreeFileSync::FfsLastConfigFile); //don't trow exceptions in destructors + //save configuration + writeConfigurationToXml(FreeFileSync::FfsLastConfigFile); //don't trow exceptions in destructors + //writeConfigurationToHD(FreeFileSync::FfsLastConfigFile); if (restartOnExit) //this is needed so that restart happens AFTER configuration was written! { //create new dialog @@ -638,9 +657,10 @@ public: void updateStatusText(const wxString& text) {} void initNewProcess(int objectsTotal, double dataTotal, int processID) {} void updateProcessedData(int objectsProcessed, double dataProcessed) {} - void triggerUI_Refresh(bool asyncProcessActive) {} - + void forceUiRefresh() {} private: + void abortThisProcess() {} + bool continueOnError; bool& unsolvedErrors; }; @@ -907,8 +927,9 @@ void MainDialog::onContextMenuSelection(wxCommandEvent& event) void MainDialog::OnEnterLeftDir( wxCommandEvent& event ) { - wxString newDir = m_directoryPanel1->GetValue(); - m_dirPicker1->SetPath(newDir); + wxString newDir = FreeFileSync::getFormattedDirectoryName(m_directoryPanel1->GetValue()); + if (wxDirExists(newDir)) + m_dirPicker1->SetPath(newDir); event.Skip(); } @@ -916,8 +937,9 @@ void MainDialog::OnEnterLeftDir( wxCommandEvent& event ) void MainDialog::OnEnterRightDir( wxCommandEvent& event ) { - wxString newDir = m_directoryPanel2->GetValue(); - m_dirPicker2->SetPath(newDir); + wxString newDir = FreeFileSync::getFormattedDirectoryName(m_directoryPanel2->GetValue()); + if (wxDirExists(newDir)) + m_dirPicker2->SetPath(newDir); event.Skip(); } @@ -1060,12 +1082,11 @@ bool FileDropEvent::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& filen const wxString droppedFileName = filenames[0]; //test if ffs config file has been dropped - if (FreeFileSync::isFFS_ConfigFile(droppedFileName)) + if (FreeFileSync::isFfsConfigFile(droppedFileName)) { - mainDlg->readConfigurationFromHD(droppedFileName); + mainDlg->readConfigurationFromXml(droppedFileName); mainDlg->pushStatusInformation(_("Configuration loaded!")); } - else if (targetGrid == 1) onFilesDropped(droppedFileName, mainDlg->m_directoryPanel1, mainDlg->m_dirPicker1); @@ -1104,7 +1125,7 @@ void MainDialog::OnSaveConfig(wxCommandEvent& event) return; } } - writeConfigurationToHD(newFileName); + writeConfigurationToXml(newFileName); pushStatusInformation(_("Configuration saved!")); } @@ -1145,11 +1166,11 @@ void MainDialog::OnLoadConfiguration(wxCommandEvent& event) { if (!wxFileExists(newCfgFile)) wxMessageBox(_("The selected file does not exist anymore!"), _("Warning"), wxOK); - else if (!FreeFileSync::isFFS_ConfigFile(newCfgFile)) + else if (!FreeFileSync::isFfsConfigFile(newCfgFile)) wxMessageBox(_("The selected file does not contain a valid configuration!"), _("Warning"), wxOK); else { - readConfigurationFromHD(newCfgFile); + readConfigurationFromXml(newCfgFile); pushStatusInformation(_("Configuration loaded!")); } } @@ -1169,6 +1190,7 @@ void MainDialog::OnChoiceKeyEvent(wxKeyEvent& event) { //delete selected row cfgFileNames.erase(cfgFileNames.begin() + selectedItem - 1); m_choiceLoad->Delete(selectedItem); + m_choiceLoad->SetSelection(0); } } event.Skip(); @@ -1213,8 +1235,8 @@ void MainDialog::loadDefaultConfiguration() cfg.compareVar = CMP_BY_TIME_SIZE; //compare algorithm updateCompareButtons(); - cfg.includeFilter = wxT("*"); //include all files/folders - cfg.excludeFilter = wxEmptyString; //exlude nothing + cfg.includeFilter = wxT("*"); //include all files/folders + cfg.excludeFilter = wxEmptyString; //exclude nothing //set status of filter button cfg.filterIsActive = false; //do not filter by default @@ -1224,7 +1246,7 @@ void MainDialog::loadDefaultConfiguration() cfg.hideFiltered = false; //show filtered items m_checkBoxHideFilt->SetValue(cfg.hideFiltered); - cfg.useRecycleBin = false; //do not use: in case OS doesn't support this, user will have to activate first and then get the error message + cfg.useRecycleBin = FreeFileSync::recycleBinExists(); //set if OS supports it; else user will have to activate first and then get the error message cfg.continueOnError = false; widthNotMaximized = wxDefaultCoord; @@ -1234,8 +1256,378 @@ void MainDialog::loadDefaultConfiguration() } +inline +bool readXmlElementValue(string& output, const TiXmlElement* parent, const string& name) +{ + if (parent) + { + const TiXmlElement* child = parent->FirstChildElement(name); + if (child) + { + const char* text = child->GetText(); + if (text) //may be NULL!! + output = text; + else + output.clear(); + return true; + } + } + + return false; +} + + +inline +bool readXmlElementValue(int& output, const TiXmlElement* parent, const string& name) +{ + string temp; + if (readXmlElementValue(temp, parent, name)) + { + output = stringToInt(temp); + return true; + } + else + return false; +} + + +inline +bool readXmlElementValue(CompareVariant& output, const TiXmlElement* parent, const string& name) +{ + int dummy = 0; + if (readXmlElementValue(dummy, parent, name)) + { + output = CompareVariant(dummy); + return true; + } + else + return false; +} + + +inline +bool readXmlElementValue(SyncDirection& output, const TiXmlElement* parent, const string& name) +{ + int dummy = 0; + if (readXmlElementValue(dummy, parent, name)) + { + output = SyncDirection(dummy); + return true; + } + else + return false; +} + + +inline +bool readXmlElementValue(bool& output, const TiXmlElement* parent, const string& name) +{ + int dummy = 0; + if (readXmlElementValue(dummy, parent, name)) + { + output = bool(dummy); + return true; + } + else + return false; +} + + +bool MainDialog::parseXmlData(TiXmlElement* root, bool programStartup) +{ + if (root && (root->ValueStr() == string("FreeFileSync"))) //check for FFS configuration xml + { + TiXmlHandle hRoot(root); + + TiXmlElement* cmpSettings = hRoot.FirstChild("settings").FirstChild("comparison").ToElement(); + TiXmlElement* syncConfig = hRoot.FirstChild("settings").FirstChild("synchronization").FirstChild("directions").ToElement(); + TiXmlElement* miscSettings = hRoot.FirstChild("settings").FirstChild("miscellaneous").ToElement(); + TiXmlElement* filter = TiXmlHandle(miscSettings).FirstChild("filter").ToElement(); + + if (cmpSettings && syncConfig && miscSettings && filter) + { + string tempString; +//########################################################### + //read compare variant + if (!readXmlElementValue(cfg.compareVar, cmpSettings, "variant")) return false; + updateCompareButtons(); + + //read folder pair(s) - currently only one folderpair supported + TiXmlElement* folderPair = TiXmlHandle(cmpSettings).FirstChild("folders").FirstChild("pair").ToElement(); + if (!folderPair) return false; + + //read directories for comparison + if (!readXmlElementValue(tempString, folderPair, "left")) return false; + wxString leftDir = wxString::FromUTF8(tempString.c_str()); + m_directoryPanel1->SetValue(leftDir); + wxString leftDirFormatted = FreeFileSync::getFormattedDirectoryName(leftDir); + if (wxDirExists(leftDirFormatted)) + m_dirPicker1->SetPath(leftDirFormatted); + + if (!readXmlElementValue(tempString, folderPair, "right")) return false; + wxString rightDir = wxString::FromUTF8(tempString.c_str()); + m_directoryPanel2->SetValue(rightDir); + wxString rightDirFormatted = FreeFileSync::getFormattedDirectoryName(rightDir); + if (wxDirExists(rightDirFormatted)) + m_dirPicker2->SetPath(rightDirFormatted); +//########################################################### + //read sync configuration + if (!readXmlElementValue(cfg.syncConfiguration.exLeftSideOnly, syncConfig, "leftonly")) return false; + if (!readXmlElementValue(cfg.syncConfiguration.exRightSideOnly, syncConfig, "rightonly")) return false; + if (!readXmlElementValue(cfg.syncConfiguration.leftNewer, syncConfig, "leftnewer")) return false; + if (!readXmlElementValue(cfg.syncConfiguration.rightNewer, syncConfig, "rightnewer")) return false; + if (!readXmlElementValue(cfg.syncConfiguration.different, syncConfig, "different")) return false; +//########################################################### + //read filter settings + if (!readXmlElementValue(cfg.filterIsActive, filter, "active")) return false; + updateFilterButton(m_bpButtonFilter, cfg.filterIsActive); + + if (!readXmlElementValue(cfg.hideFiltered, filter, "hidefiltered")) return false; + m_checkBoxHideFilt->SetValue(cfg.hideFiltered); + + if (!readXmlElementValue(tempString, filter, "include")) return false; + cfg.includeFilter = wxString::FromUTF8(tempString.c_str()); + + if (!readXmlElementValue(tempString, filter, "exclude")) return false; + cfg.excludeFilter = wxString::FromUTF8(tempString.c_str()); +//########################################################### + //other + if (!readXmlElementValue(cfg.useRecycleBin, miscSettings, "recycler")) return false; + if (!readXmlElementValue(cfg.continueOnError, miscSettings, "continue")) return false; + +//########################################################### + //read GUI layout (optional!) + //apply window size and position at program startup ONLY + if (programStartup) + { + TiXmlElement* mainWindow = hRoot.FirstChild("layout").FirstChild("windows").FirstChild("main").ToElement(); + if (mainWindow) + { + //read application window size and position + int widthTmp = 0; // + int heighthTmp = 0; // + int posxTmp = 0; // read all parameters "at once" + int posyTmp = 0; // + bool maximizedTmp = false; + + if ( readXmlElementValue(widthTmp, mainWindow, "width") && + readXmlElementValue(heighthTmp, mainWindow, "height") && + readXmlElementValue(posxTmp, mainWindow, "posx") && + readXmlElementValue(posyTmp, mainWindow, "posy") && + readXmlElementValue(maximizedTmp, mainWindow, "maximized")) + { + widthNotMaximized = widthTmp; + heightNotMaximized = heighthTmp; + posXNotMaximized = posxTmp; + posYNotMaximized = posyTmp; + + //apply window size and position + SetSize(posXNotMaximized, posYNotMaximized, widthNotMaximized, heightNotMaximized); + Maximize(maximizedTmp); + } +//########################################################### + //read column widths + TiXmlElement* leftColumn = TiXmlHandle(mainWindow).FirstChild("leftcolumns").FirstChild("width").ToElement(); + for (int i = 0; i < m_grid1->GetNumberCols(); ++i) + { + if (leftColumn) + { + const char* width = leftColumn->GetText(); + if (width) //may be NULL!! + m_grid1->SetColSize(i, stringToInt(width)); + leftColumn = leftColumn->NextSiblingElement(); + } + else break; + } + + TiXmlElement* rightColumn = TiXmlHandle(mainWindow).FirstChild("rightcolumns").FirstChild("width").ToElement(); + for (int i = 0; i < m_grid2->GetNumberCols(); ++i) + { + if (rightColumn) + { + const char* width = rightColumn->GetText(); + if (width) //may be NULL!! + m_grid2->SetColSize(i, stringToInt(width)); + + rightColumn = rightColumn->NextSiblingElement(); + } + else break; + } + } + } + return true; +//########################################################### + } + } + return false; +} + + +void MainDialog::readConfigurationFromXml(const wxString& filename, bool programStartup) +{ + if (wxFileExists(filename)) + { //workaround to get a FILE* from a unicode filename + wxFFile dummyFile(filename, wxT("rb")); + if (dummyFile.IsOpened()) + { + FILE* inputFile = dummyFile.fp(); + + TiXmlBase::SetCondenseWhiteSpace(false); //do not condense whitespace characters + TiXmlDocument doc; + if ( doc.LoadFile(inputFile) && //fails if inputFile is no proper XML + parseXmlData(doc.RootElement(), programStartup)) + addCfgFileToHistory(filename); //put filename on list of last used config files + else + { //handle error: parsing + wxMessageBox(wxString(_("Error parsing configuration file ")) + wxT("\"") + filename + wxT("\""), _("Error"), wxOK | wxICON_ERROR); + if (programStartup) + loadDefaultConfiguration(); + } + return; + } + } + + //handle error: file load + if (programStartup) + loadDefaultConfiguration(); + else + wxMessageBox(wxString(_("Could not open configuration file ")) + wxT("\"") + filename + wxT("\""), _("Error"), wxOK | wxICON_ERROR); +} + + +void addXmlElement(TiXmlElement* parent, const string& name, const string& value) +{ + if (parent) + { + TiXmlElement* subElement = new TiXmlElement(name); + parent->LinkEndChild(subElement); + subElement->LinkEndChild(new TiXmlText(value)); + } +} + + +void addXmlElement(TiXmlElement* parent, const string& name, const int value) +{ + addXmlElement(parent, name, numberToString(value)); +} + + +void MainDialog::writeConfigurationToXml(const wxString& filename) +{ + //workaround to get a FILE* from a unicode filename + wxFFile dummyFile(filename, wxT("wb")); + if (!dummyFile.IsOpened()) + { + wxMessageBox(wxString(_("Could not write configuration file ")) + wxT("\"") + filename + wxT("\""), _("Error"), wxOK | wxICON_ERROR); + return; + } + FILE* outputFile = dummyFile.fp(); + + TiXmlBase::SetCondenseWhiteSpace(false); //do not condense whitespace characters + TiXmlDocument xmlDoc; + TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", ""); //delete won't be necessary later; ownership passed to TiXmlDocument! + xmlDoc.LinkEndChild(decl); + + TiXmlElement* root = new TiXmlElement("FreeFileSync"); + xmlDoc.LinkEndChild(root); + + TiXmlElement* settings = new TiXmlElement("settings"); + root->LinkEndChild(settings); + +//########################################################### + TiXmlElement* cmpSettings = new TiXmlElement("comparison"); + settings->LinkEndChild(cmpSettings); + + //write compare algorithm + addXmlElement(cmpSettings, "variant", cfg.compareVar); + + //write folder pair(s) + TiXmlElement* folders = new TiXmlElement("folders"); + cmpSettings->LinkEndChild(folders); + + TiXmlElement* folderPair = new TiXmlElement("pair"); + folders->LinkEndChild(folderPair); + + addXmlElement(folderPair, "left", string((m_directoryPanel1->GetValue()).ToUTF8())); + addXmlElement(folderPair, "right", string((m_directoryPanel2->GetValue()).ToUTF8())); + +//########################################################### + TiXmlElement* syncSettings = new TiXmlElement("synchronization"); + settings->LinkEndChild(syncSettings); + + //write sync configuration + TiXmlElement* syncConfig = new TiXmlElement("directions"); + syncSettings->LinkEndChild(syncConfig); + + addXmlElement(syncConfig, "leftonly", cfg.syncConfiguration.exLeftSideOnly); + addXmlElement(syncConfig, "rightonly", cfg.syncConfiguration.exRightSideOnly); + addXmlElement(syncConfig, "leftnewer", cfg.syncConfiguration.leftNewer); + addXmlElement(syncConfig, "rightnewer", cfg.syncConfiguration.rightNewer); + addXmlElement(syncConfig, "different", cfg.syncConfiguration.different); + +//########################################################### + TiXmlElement* miscSettings = new TiXmlElement("miscellaneous"); + settings->LinkEndChild(miscSettings); + + //write filter settings + TiXmlElement* filter = new TiXmlElement("filter"); + miscSettings->LinkEndChild(filter); + + addXmlElement(filter, "active", cfg.filterIsActive); + addXmlElement(filter, "hidefiltered", cfg.hideFiltered); + addXmlElement(filter, "include", string((cfg.includeFilter).ToUTF8())); + addXmlElement(filter, "exclude", string((cfg.excludeFilter).ToUTF8())); + + //other + addXmlElement(miscSettings, "recycler", cfg.useRecycleBin); + addXmlElement(miscSettings, "continue", cfg.continueOnError); +//########################################################### + TiXmlElement* guiLayout = new TiXmlElement("layout"); + root->LinkEndChild(guiLayout); + + TiXmlElement* windows = new TiXmlElement("windows"); + guiLayout->LinkEndChild(windows); + + TiXmlElement* mainWindow = new TiXmlElement("main"); + windows->LinkEndChild(mainWindow); + + //window size + addXmlElement(mainWindow, "width", widthNotMaximized); + addXmlElement(mainWindow, "height", heightNotMaximized); + + //window position + addXmlElement(mainWindow, "posx", posXNotMaximized); + addXmlElement(mainWindow, "posy", posYNotMaximized); + addXmlElement(mainWindow, "maximized", IsMaximized()); + + //write column sizes + TiXmlElement* leftColumn = new TiXmlElement("leftcolumns"); + mainWindow->LinkEndChild(leftColumn); + + for (int i = 0; i < m_grid1->GetNumberCols(); ++i) + addXmlElement(leftColumn, "width", m_grid1->GetColSize(i)); + + TiXmlElement* rightColumn = new TiXmlElement("rightcolumns"); + mainWindow->LinkEndChild(rightColumn); + + for (int i = 0; i < m_grid2->GetNumberCols(); ++i) + addXmlElement(rightColumn, "width", m_grid2->GetColSize(i)); + + if (!xmlDoc.SaveFile(outputFile)) + { + wxMessageBox(wxString(_("Could not write configuration file ")) + wxT("\"") + filename + wxT("\""), _("Error"), wxOK | wxICON_ERROR); + return; + } + + //put filename on list of last used config files + addCfgFileToHistory(filename); +} + + void MainDialog::readConfigurationFromHD(const wxString& filename, bool programStartup) { + assert(false); //deprecated + char bigBuffer[10000]; if (wxFileExists(filename)) @@ -1243,7 +1635,6 @@ void MainDialog::readConfigurationFromHD(const wxString& filename, bool programS wxFFileInputStream config(filename); if (config.IsOk()) { - //read FFS identifier config.Read(bigBuffer, FreeFileSync::FfsConfigFileID.size()); bigBuffer[FreeFileSync::FfsConfigFileID.size()] = 0; @@ -1340,12 +1731,14 @@ void MainDialog::readConfigurationFromHD(const wxString& filename, bool programS if (programStartup) loadDefaultConfiguration(); else - wxMessageBox(wxString(_("Could not read configuration file ")) + wxT("\"") + filename + wxT("\""), _("An exception occured!"), wxOK | wxICON_ERROR); + wxMessageBox(wxString(_("Could not read configuration file ")) + wxT("\"") + filename + wxT("\""), _("Error"), wxOK | wxICON_ERROR); } void MainDialog::writeConfigurationToHD(const wxString& filename) { + assert(false); //deprecated + wxFFileOutputStream config(filename); if (!config.IsOk()) { @@ -1609,19 +2002,19 @@ void MainDialog::OnCompare(wxCommandEvent &event) { if (m_directoryPanel1->GetValue().IsEmpty() || m_directoryPanel2->GetValue().IsEmpty()) { - wxMessageBox(_("Please select directories for both sides!"), _("Information")); + wxMessageBox(_("Please select both left and right directories!"), _("Information")); return; } clearStatusBar(); - //check if directories exist if loaded by config file - if (!wxDirExists(m_directoryPanel1->GetValue())) + //check if directories exist (if loaded by config file) + if (!wxDirExists(FreeFileSync::getFormattedDirectoryName(m_directoryPanel1->GetValue()))) { wxMessageBox(_("Directory on the left does not exist. Please select a new one!"), _("Warning"), wxICON_WARNING); return; } - else if (!wxDirExists(m_directoryPanel2->GetValue())) + else if (!wxDirExists(FreeFileSync::getFormattedDirectoryName(m_directoryPanel2->GetValue()))) { wxMessageBox(_("Directory on the right does not exist. Please select a new one!"), _("Warning"), wxICON_WARNING); return; @@ -2267,9 +2660,8 @@ CompareStatusUpdater::CompareStatusUpdater(MainDialog* dlg) : mainDialog->m_menubar1->EnableTop(2, false); //display status panel during compare - statusPanel = new CompareStatus(mainDialog); - mainDialog->bSizer1->Insert(1, statusPanel, 0, wxEXPAND | wxBOTTOM, 5 ); - + mainDialog->compareStatus->init(); //clear old values + mainDialog->compareStatus->Show(); //show abort button mainDialog->m_buttonAbort->Enable(); @@ -2278,7 +2670,7 @@ CompareStatusUpdater::CompareStatusUpdater(MainDialog* dlg) : mainDialog->m_bpButtonCompare->Hide(); mainDialog->m_buttonAbort->SetFocus(); - //updateUI_Now(); + //updateUiNow(); mainDialog->bSizer1->Layout(); //both sizers need to recalculate! mainDialog->bSizer6->Layout(); } @@ -2321,10 +2713,9 @@ CompareStatusUpdater::~CompareStatusUpdater() mainDialog->m_bpButtonCompare->Enable(); mainDialog->m_bpButtonCompare->Show(); - //remove status panel from main window - mainDialog->bSizer1->Detach(statusPanel); - statusPanel->Destroy(); - updateUI_Now(); + //hide status panel from main window + mainDialog->compareStatus->Hide(); + updateUiNow(); mainDialog->Layout(); mainDialog->Refresh(); } @@ -2333,7 +2724,7 @@ CompareStatusUpdater::~CompareStatusUpdater() inline void CompareStatusUpdater::updateStatusText(const wxString& text) { - statusPanel->setStatusText_NoUpdate(text); + mainDialog->compareStatus->setStatusText_NoUpdate(text); } @@ -2344,7 +2735,11 @@ void CompareStatusUpdater::initNewProcess(int objectsTotal, double dataTotal, in if (currentProcess == FreeFileSync::scanningFilesProcess) ; else if (currentProcess == FreeFileSync::compareFileContentProcess) - statusPanel->resetCmpGauge(objectsTotal, dataTotal); + { + mainDialog->compareStatus->switchToCompareBytewise(objectsTotal, dataTotal); + mainDialog->Layout(); + } + else assert(false); } @@ -2353,9 +2748,9 @@ inline void CompareStatusUpdater::updateProcessedData(int objectsProcessed, double dataProcessed) { if (currentProcess == FreeFileSync::scanningFilesProcess) - statusPanel->incScannedObjects_NoUpdate(objectsProcessed); + mainDialog->compareStatus->incScannedObjects_NoUpdate(objectsProcessed); else if (currentProcess == FreeFileSync::compareFileContentProcess) - statusPanel->incProcessedCmpData_NoUpdate(objectsProcessed, dataProcessed); + mainDialog->compareStatus->incProcessedCmpData_NoUpdate(objectsProcessed, dataProcessed); else assert(false); } @@ -2365,7 +2760,7 @@ int CompareStatusUpdater::reportError(const wxString& text) if (continueOnError) return StatusUpdater::continueNext; - statusPanel->updateStatusPanelNow(); + mainDialog->compareStatus->updateStatusPanelNow(); wxString errorMessage = text + _("\n\nContinue with next object, retry or abort comparison?"); @@ -2394,13 +2789,15 @@ int CompareStatusUpdater::reportError(const wxString& text) inline -void CompareStatusUpdater::triggerUI_Refresh(bool asyncProcessActive) +void CompareStatusUpdater::forceUiRefresh() { - if (abortionRequested && !asyncProcessActive) - throw AbortThisProcess(); //abort can be triggered by syncStatusFrame + mainDialog->compareStatus->updateStatusPanelNow(); +} + - if (updateUI_IsAllowed()) //test if specific time span between ui updates is over - statusPanel->updateStatusPanelNow(); +void CompareStatusUpdater::abortThisProcess() +{ + throw AbortThisProcess(); //abort can be triggered by syncStatusFrame } //######################################################################################################## @@ -2410,7 +2807,7 @@ SyncStatusUpdater::SyncStatusUpdater(wxWindow* dlg, bool continueOnError) : { syncStatusFrame = new SyncStatus(this, dlg); syncStatusFrame->Show(); - updateUI_Now(); + updateUiNow(); } @@ -2507,15 +2904,16 @@ int SyncStatusUpdater::reportError(const wxString& text) } -void SyncStatusUpdater::triggerUI_Refresh(bool asyncProcessActive) +void SyncStatusUpdater::forceUiRefresh() { - if (abortionRequested && !asyncProcessActive) - throw AbortThisProcess(); //abort can be triggered by syncStatusFrame - - if (updateUI_IsAllowed()) //test if specific time span between ui updates is over - syncStatusFrame->updateStatusDialogNow(); + syncStatusFrame->updateStatusDialogNow(); } + +void SyncStatusUpdater::abortThisProcess() +{ + throw AbortThisProcess(); //abort can be triggered by syncStatusFrame +} //######################################################################################################## @@ -2635,3 +3033,11 @@ void MainDialog::OnMenuLangFrench(wxCommandEvent& event) event.Skip(); } + +void MainDialog::OnMenuLangJapanese(wxCommandEvent& event) +{ + programLanguage->loadLanguageFile(wxLANGUAGE_JAPANESE); //language is a global attribute + restartOnExit = true; + Destroy(); + event.Skip(); +} diff --git a/ui/MainDialog.h b/ui/MainDialog.h index 3ef7dbf5..4bf5504c 100644 --- a/ui/MainDialog.h +++ b/ui/MainDialog.h @@ -10,7 +10,6 @@ #ifndef MAINDIALOG_H #define MAINDIALOG_H -#include "../library/wxWidgets.h" #include "guiGenerated.h" #include "../FreeFileSync.h" #include "syncDialog.h" @@ -36,6 +35,7 @@ extern int leadingPanel; class CompareStatusUpdater; class FileDropEvent; +class TiXmlElement; class MainDialog : public GuiGenerated { @@ -47,9 +47,16 @@ public: ~MainDialog(); private: + void loadDefaultConfiguration(); + + void readConfigurationFromXml(const wxString& filename, bool programStartup = false); + bool parseXmlData(TiXmlElement* root, bool programStartup); + void writeConfigurationToXml(const wxString& filename); + + //deprecated void readConfigurationFromHD(const wxString& filename, bool programStartup = false); void writeConfigurationToHD(const wxString& filename); - void loadDefaultConfiguration(); + // void updateViewFilterButtons(); void updateFilterButton(wxBitmapButton* filterButton, bool isActive); @@ -137,6 +144,7 @@ private: void OnMenuLangEnglish( wxCommandEvent& event); void OnMenuLangGerman( wxCommandEvent& event); void OnMenuLangFrench( wxCommandEvent& event); + void OnMenuLangJapanese( wxCommandEvent& event); void enableSynchronization(bool value); @@ -174,6 +182,9 @@ private: wxLongLong lastStatusChange; stack<wxString> stackObjects; + //compare status panel (hidden on start, shown when comparing) + CompareStatus* compareStatus; + //save the last used config filenames wxConfig* cfgFileHistory; vector<wxString> cfgFileNames; @@ -228,11 +239,12 @@ public: void updateProcessedData(int objectsProcessed, double dataProcessed); int reportError(const wxString& text); - void triggerUI_Refresh(bool asyncProcessActive); + void forceUiRefresh(); private: + void abortThisProcess(); + MainDialog* mainDialog; - CompareStatus* statusPanel; bool continueOnError; int currentProcess; }; @@ -249,11 +261,12 @@ public: void updateProcessedData(int objectsProcessed, double dataProcessed); int reportError(const wxString& text); - void triggerUI_Refresh(bool asyncProcessActive); + void forceUiRefresh(); private: - SyncStatus* syncStatusFrame; + void abortThisProcess(); + SyncStatus* syncStatusFrame; bool continueError; wxArrayString unhandledErrors; //list of non-resolved errors }; diff --git a/ui/SmallDialogs.cpp b/ui/SmallDialogs.cpp index 7965a5c9..dfd16108 100644 --- a/ui/SmallDialogs.cpp +++ b/ui/SmallDialogs.cpp @@ -25,9 +25,10 @@ AboutDlg::AboutDlg(wxWindow* window) : AboutDlgGenerated(window) m_animationControl1->SetAnimation(*GlobalResources::animationMoney); m_animationControl1->Play(); //Note: The animation is created hidden(!) to not disturb constraint based window creation; - m_animationControl1->Show(); //an empty animation consumes a lot of space that later is NOT removed anymore. + m_animationControl1->Show(); // m_button8->SetFocus(); + Fit(); } @@ -49,9 +50,40 @@ void AboutDlg::OnOK(wxCommandEvent& event) HelpDlg::HelpDlg(wxWindow* window) : HelpDlgGenerated(window) { - m_button8->SetFocus(); + m_notebook1->SetFocus(); + + //populate decision trees: "compare by date" + wxTreeItemId treeRoot = m_treeCtrl1->AddRoot(_("DECISION TREE")); + wxTreeItemId treeBothSides = m_treeCtrl1->AppendItem(treeRoot, _("file exists on both sides")); + wxTreeItemId treeOneSide = m_treeCtrl1->AppendItem(treeRoot, _("on one side only")); + + m_treeCtrl1->AppendItem(treeOneSide, _("- left")); + m_treeCtrl1->AppendItem(treeOneSide, _("- right")); + + m_treeCtrl1->AppendItem(treeBothSides, _("- equal")); + wxTreeItemId treeDifferent = m_treeCtrl1->AppendItem(treeBothSides, _("different")); + + m_treeCtrl1->AppendItem(treeDifferent, _("- left newer")); + m_treeCtrl1->AppendItem(treeDifferent, _("- right newer")); + m_treeCtrl1->AppendItem(treeDifferent, _("- same date (different size)")); + + m_treeCtrl1->ExpandAll(); + + //populate decision trees: "compare by content" + wxTreeItemId tree2Root = m_treeCtrl2->AddRoot(_("DECISION TREE")); + wxTreeItemId tree2BothSides = m_treeCtrl2->AppendItem(tree2Root, _("file exists on both sides")); + wxTreeItemId tree2OneSide = m_treeCtrl2->AppendItem(tree2Root, _("on one side only")); + + m_treeCtrl2->AppendItem(tree2OneSide, _("- left")); + m_treeCtrl2->AppendItem(tree2OneSide, _("- right")); + + m_treeCtrl2->AppendItem(tree2BothSides, _("- equal")); + m_treeCtrl2->AppendItem(tree2BothSides, _("- different")); + + m_treeCtrl2->ExpandAll(); } + HelpDlg::~HelpDlg() {} @@ -76,17 +108,35 @@ FilterDlg::FilterDlg(wxWindow* window, wxString& filterIncl, wxString& filterExc m_bitmap8->SetBitmap(*GlobalResources::bitmapInclude); m_bitmap9->SetBitmap(*GlobalResources::bitmapExclude); + m_bpButtonHelp->SetBitmapLabel(*GlobalResources::bitmapHelp); m_textCtrlInclude->SetValue(includeFilter); m_textCtrlExclude->SetValue(excludeFilter); + + m_panel13->Hide(); + Fit(); } FilterDlg::~FilterDlg() {} -void FilterDlg::OnClose(wxCloseEvent& event) +void FilterDlg::OnHelp(wxCommandEvent& event) { - EndModal(0); + m_bpButtonHelp->Hide(); + m_panel13->Show(); + Fit(); + + event.Skip(); +} + + +void FilterDlg::OnDefault(wxCommandEvent& event) +{ + m_textCtrlInclude->SetValue(wxT("*")); + m_textCtrlExclude->SetValue(wxEmptyString); + + //changes to mainDialog are only committed when the OK button is pressed + event.Skip(); } @@ -107,13 +157,9 @@ void FilterDlg::OnCancel(wxCommandEvent& event) } -void FilterDlg::OnDefault(wxCommandEvent& event) +void FilterDlg::OnClose(wxCloseEvent& event) { - m_textCtrlInclude->SetValue(wxT("*")); - m_textCtrlExclude->SetValue(wxEmptyString); - - //changes to mainDialog are only committed when the OK button is pressed - event.Skip(); + EndModal(0); } //######################################################################################## @@ -370,13 +416,13 @@ void SyncStatus::updateStatusDialogNow() //do the ui update bSizer28->Layout(); bSizer31->Layout(); - updateUI_Now(); + updateUiNow(); //support for pause button while (processPaused && currentProcessIsRunning) { wxMilliSleep(UI_UPDATE_INTERVAL); - updateUI_Now(); + updateUiNow(); } } @@ -501,29 +547,47 @@ void SyncStatus::OnClose(wxCloseEvent& event) CompareStatus::CompareStatus(wxWindow* parentWindow) : CompareStatusGenerated(parentWindow), scannedObjects(0), + scalingFactorCmp(0), totalCmpData(0), processedCmpData(0), - scalingFactorCmp(0), - processedCmpObjects(0), - totalCmpObjects(0) + totalCmpObjects(0), + processedCmpObjects(0) /*timeRemaining(0), timeRemainingTimeStamp(0)*/ +{ + init(); +} + + +CompareStatus::~CompareStatus() {} + -{ //initialize gauge +void CompareStatus::init() +{ + //initialize gauge m_gauge2->SetRange(50000); m_gauge2->SetValue(0); //initially hide status that's relevant for comparing bytewise only bSizer42->Hide(sbSizer13); - bSizer42->Hide(sbSizer11); + m_gauge2->Hide(); bSizer42->Layout(); -} + scannedObjects = 0; + scalingFactorCmp = 0; -CompareStatus::~CompareStatus() {} + totalCmpData = 0; + processedCmpData = 0; + totalCmpObjects = 0; + processedCmpObjects = 0; + + timeElapsed.Start(); //measure total time + + updateStatusPanelNow(); +} -void CompareStatus::resetCmpGauge(int totalCmpObjectsToProcess, double totalCmpDataToProcess) +void CompareStatus::switchToCompareBytewise(int totalCmpObjectsToProcess, double totalCmpDataToProcess) { processedCmpData = 0; totalCmpData = totalCmpDataToProcess; @@ -538,7 +602,7 @@ void CompareStatus::resetCmpGauge(int totalCmpObjectsToProcess, double totalCmpD //show status for comparing bytewise bSizer42->Show(sbSizer13); - bSizer42->Show(sbSizer11); + m_gauge2->Show(); bSizer42->Layout(); } @@ -581,6 +645,7 @@ void CompareStatus::updateStatusPanelNow() //remaining bytes left for file comparison const wxString remainingBytes = FreeFileSync::formatFilesizeToShortString(totalCmpData - processedCmpData); m_staticTextDataToCompare->SetLabel(remainingBytes); + /* //remaining time in seconds if (timeRemaining != 0) @@ -589,7 +654,11 @@ void CompareStatus::updateStatusPanelNow() m_staticTextRemainingTime->SetLabel(numberToWxString(time) + " s"); } */ + + //time elapsed + m_staticTextTimeElapsed->SetLabel((wxTimeSpan::Milliseconds(timeElapsed.Time())).Format()); + //do the ui update bSizer42->Layout(); - updateUI_Now(); + updateUiNow(); } diff --git a/ui/SmallDialogs.h b/ui/SmallDialogs.h index e97362d5..b70e6105 100644 --- a/ui/SmallDialogs.h +++ b/ui/SmallDialogs.h @@ -38,6 +38,7 @@ public: static const int okayButtonPressed = 25; private: + void OnHelp(wxCommandEvent& event); void OnDefault(wxCommandEvent& event); void OnOK(wxCommandEvent& event); void OnCancel(wxCommandEvent& event); @@ -164,7 +165,9 @@ public: CompareStatus(wxWindow* parentWindow); ~CompareStatus(); - void resetCmpGauge(int totalCmpObjectsToProcess, double totalCmpDataToProcess); + void init(); //initialize all status values + + void switchToCompareBytewise(int totalCmpObjectsToProcess, double totalCmpDataToProcess); void incScannedObjects_NoUpdate(int number); void incProcessedCmpData_NoUpdate(int objectsProcessed, double dataProcessed); void setStatusText_NoUpdate(const wxString& text); @@ -175,12 +178,14 @@ private: unsigned int scannedObjects; wxString currentStatusText; + wxStopWatch timeElapsed; + //gauge variables + double scalingFactorCmp; //nr of elements has to be normalized to smaller nr. because of range of int limitation double totalCmpData; //each data element represents one byte for proper progress indicator scaling double processedCmpData; - double scalingFactorCmp; //nr of elements has to be normalized to smaller nr. because of range of int limitation - int processedCmpObjects; //each object represents a file or directory processed int totalCmpObjects; + int processedCmpObjects; //each object represents a file or directory processed /* //remaining time RemainingTime calcTimeLeft; diff --git a/ui/SyncDialog.cpp b/ui/SyncDialog.cpp index 3fa8619c..6d838f05 100644 --- a/ui/SyncDialog.cpp +++ b/ui/SyncDialog.cpp @@ -4,6 +4,10 @@ #include <wx/msgdlg.h> #include <wx/stdpaths.h> #include <wx/ffile.h> +#ifdef FFS_WIN +#include <windows.h> +#include <shlobj.h> +#endif // FFS_WIN using namespace std; @@ -80,81 +84,81 @@ void SyncDialog::updateConfigIcons(wxBitmapButton* button1, { if (syncConfig.exLeftSideOnly == SYNC_DIR_RIGHT) { - button1->SetBitmapLabel(*GlobalResources::bitmapRightArrow); + button1->SetBitmapLabel(*GlobalResources::bitmapArrowRightCr); button1->SetToolTip(_("Copy from left to right")); } else if (syncConfig.exLeftSideOnly == SYNC_DIR_LEFT) { - button1->SetBitmapLabel(*GlobalResources::bitmapDelete); + button1->SetBitmapLabel(*GlobalResources::bitmapDeleteLeft); button1->SetToolTip(_("Delete files/folders existing on left side only")); } else if (syncConfig.exLeftSideOnly == SYNC_DIR_NONE) { - button1->SetBitmapLabel(*GlobalResources::bitmapNoArrow); + button1->SetBitmapLabel(*GlobalResources::bitmapArrowNone); button1->SetToolTip(_("Do nothing")); } if (syncConfig.exRightSideOnly == SYNC_DIR_RIGHT) { - button2->SetBitmapLabel(*GlobalResources::bitmapDelete); + button2->SetBitmapLabel(*GlobalResources::bitmapDeleteRight); button2->SetToolTip(_("Delete files/folders existing on right side only")); } else if (syncConfig.exRightSideOnly == SYNC_DIR_LEFT) { - button2->SetBitmapLabel(*GlobalResources::bitmapLeftArrow); + button2->SetBitmapLabel(*GlobalResources::bitmapArrowLeftCr); button2->SetToolTip(_("Copy from right to left")); } else if (syncConfig.exRightSideOnly == SYNC_DIR_NONE) { - button2->SetBitmapLabel(*GlobalResources::bitmapNoArrow); + button2->SetBitmapLabel(*GlobalResources::bitmapArrowNone); button2->SetToolTip(_("Do nothing")); } if (syncConfig.leftNewer == SYNC_DIR_RIGHT) { - button3->SetBitmapLabel(*GlobalResources::bitmapRightArrow); + button3->SetBitmapLabel(*GlobalResources::bitmapArrowRight); button3->SetToolTip(_("Copy from left to right overwriting")); } else if (syncConfig.leftNewer == SYNC_DIR_LEFT) { - button3->SetBitmapLabel(*GlobalResources::bitmapLeftArrow); + button3->SetBitmapLabel(*GlobalResources::bitmapArrowLeft); button3->SetToolTip(_("Copy from right to left overwriting")); } else if (syncConfig.leftNewer == SYNC_DIR_NONE) { - button3->SetBitmapLabel(*GlobalResources::bitmapNoArrow); + button3->SetBitmapLabel(*GlobalResources::bitmapArrowNone); button3->SetToolTip(_("Do nothing")); } if (syncConfig.rightNewer == SYNC_DIR_RIGHT) { - button4->SetBitmapLabel(*GlobalResources::bitmapRightArrow); + button4->SetBitmapLabel(*GlobalResources::bitmapArrowRight); button4->SetToolTip(_("Copy from left to right overwriting")); } else if (syncConfig.rightNewer == SYNC_DIR_LEFT) { - button4->SetBitmapLabel(*GlobalResources::bitmapLeftArrow); + button4->SetBitmapLabel(*GlobalResources::bitmapArrowLeft); button4->SetToolTip(_("Copy from right to left overwriting")); } else if (syncConfig.rightNewer == SYNC_DIR_NONE) { - button4->SetBitmapLabel(*GlobalResources::bitmapNoArrow); + button4->SetBitmapLabel(*GlobalResources::bitmapArrowNone); button4->SetToolTip(_("Do nothing")); } if (syncConfig.different == SYNC_DIR_RIGHT) { - button5->SetBitmapLabel(*GlobalResources::bitmapRightArrow); + button5->SetBitmapLabel(*GlobalResources::bitmapArrowRight); button5->SetToolTip(_("Copy from left to right overwriting")); } else if (syncConfig.different == SYNC_DIR_LEFT) { - button5->SetBitmapLabel(*GlobalResources::bitmapLeftArrow); + button5->SetBitmapLabel(*GlobalResources::bitmapArrowLeft); button5->SetToolTip(_("Copy from right to left overwriting")); } else if (syncConfig.different == SYNC_DIR_NONE) { - button5->SetBitmapLabel(*GlobalResources::bitmapNoArrow); + button5->SetBitmapLabel(*GlobalResources::bitmapArrowNone); button5->SetToolTip(_("Do nothing")); } } @@ -245,7 +249,7 @@ void SyncDialog::OnSelectRecycleBin(wxCommandEvent& event) { if (!FreeFileSync::recycleBinExists()) { - wxMessageBox(_("It was not possible to gain access to Recycle Bin!\n\nIt's likely that you are not using Windows XP. (Probably Vista)\nIf you want this feature included, please contact the author. :)"), _("Error") , wxOK | wxICON_ERROR); + wxMessageBox(_("It was not possible to initialize the Recycle Bin!\n\nIt's likely that you are not using Windows.\nIf you want this feature included, please contact the author. :)"), _("Error") , wxOK | wxICON_ERROR); m_checkBoxUseRecycler->SetValue(false); } } @@ -461,7 +465,7 @@ void BatchDialog::OnSelectRecycleBin(wxCommandEvent& event) { if (!FreeFileSync::recycleBinExists()) { - wxMessageBox(_("It was not possible to gain access to Recycle Bin!\n\nIt's likely that you are not using Windows XP. (Probably Vista)\nIf you want this feature included, please contact the author. :)"), _("Error") , wxOK | wxICON_ERROR); + wxMessageBox(_("It was not possible to initialize the Recycle Bin!\n\nIt's likely that you are not using Windows.\nIf you want this feature included, please contact the author. :)"), _("Error") , wxOK | wxICON_ERROR); m_checkBoxUseRecycler->SetValue(false); } } @@ -498,7 +502,7 @@ void BatchDialog::OnCancel(wxCommandEvent& event) } -void BatchDialog::OnCreateJob(wxCommandEvent& event) +void BatchDialog::OnCreateBatchJob(wxCommandEvent& event) { if (m_directoryPanel1->GetValue().IsEmpty() || m_directoryPanel2->GetValue().IsEmpty()) { @@ -507,12 +511,12 @@ void BatchDialog::OnCreateJob(wxCommandEvent& event) } //check if directories exist if loaded by config file - if (!wxDirExists(m_directoryPanel1->GetValue())) + if (!wxDirExists(FreeFileSync::getFormattedDirectoryName(m_directoryPanel1->GetValue()))) { wxMessageBox(_("Left directory does not exist. Please select a new one!"), _("Warning"), wxICON_WARNING); return; } - else if (!wxDirExists(m_directoryPanel2->GetValue())) + else if (!wxDirExists(FreeFileSync::getFormattedDirectoryName(m_directoryPanel2->GetValue()))) { wxMessageBox(_("Right directory does not exist. Please select a new one!"), _("Warning"), wxICON_WARNING); return; @@ -520,10 +524,10 @@ void BatchDialog::OnCreateJob(wxCommandEvent& event) //get a filename #ifdef FFS_WIN - wxString fileName = wxT("SyncJob.cmd"); //proposal - wxFileDialog* filePicker = new wxFileDialog(this, wxEmptyString, wxEmptyString, fileName, wxString(_("Command file")) + wxT(" (*.cmd)|*.cmd"), wxFD_SAVE); + wxString fileName = _("SyncJob.lnk"); //proposal + wxFileDialog* filePicker = new wxFileDialog(this, wxEmptyString, wxEmptyString, fileName, wxString(_("Shell link")) + wxT(" (*.lnk)|*.lnk"), wxFD_SAVE); #elif defined FFS_LINUX - wxString fileName = wxT("SyncJob.sh"); //proposal + wxString fileName = _("SyncJob.sh"); //proposal wxFileDialog* filePicker = new wxFileDialog(this, wxEmptyString, wxEmptyString, fileName, wxString(_("Shell script")) + wxT(" (*.sh)|*.sh"), wxFD_SAVE); #else assert(false); @@ -540,34 +544,11 @@ void BatchDialog::OnCreateJob(wxCommandEvent& event) return; } - //assemble command line parameters - wxString outputString; - try - { - outputString+= parseConfiguration(); - } - catch (const FileError& error) - { - wxMessageBox(error.show(), _("Error"), wxOK | wxICON_ERROR); - return; - } - - //write export file - wxFFile output(fileName, wxT("w")); - if (output.IsOpened()) - { - output.Write(outputString); - -#ifdef FFS_LINUX - //for linux the batch file needs the executable flag - output.Close(); - wxExecute(wxString(wxT("chmod +x ")) + fileName); -#endif // FFS_LINUX - + //create batch file + if (createBatchFile(fileName)) EndModal(batchFileCreated); - } else - wxMessageBox(wxString(_("Could not write to ")) + wxT("\"") + fileName + wxT("\""), _("Error"), wxOK | wxICON_ERROR); + wxMessageBox(wxString(_("Could not create file ")) + wxT("\"") + fileName + wxT("\""), _("Error"), wxOK | wxICON_ERROR); } } @@ -588,17 +569,11 @@ wxString getFormattedSyncDirection(const SyncDirection direction) } -wxString BatchDialog::parseConfiguration() +wxString BatchDialog::getCommandlineArguments() { wxString output; -#ifdef FFS_LINUX - //shell script identifier - output+= wxT("#!/bin/bash\n"); -#endif - output+= wxString(wxT("\"")) + wxStandardPaths::Get().GetExecutablePath() + wxT("\""); - - output+= wxString(wxT(" -")) + GlobalResources::paramCompare + wxT(" "); + output+= wxString(wxT("-")) + GlobalResources::paramCompare + wxT(" "); if (m_radioBtnSizeDate->GetValue()) output+= GlobalResources::valueSizeDate; else if (m_radioBtnContent->GetValue()) @@ -606,7 +581,7 @@ wxString BatchDialog::parseConfiguration() else assert(false); - output+= wxString(wxT(" -")) + GlobalResources::paramCfg + wxT(" ") + + output+= wxString(wxT(" -")) + GlobalResources::paramSync + wxT(" ") + getFormattedSyncDirection(localSyncConfiguration.exLeftSideOnly) + getFormattedSyncDirection(localSyncConfiguration.exRightSideOnly) + getFormattedSyncDirection(localSyncConfiguration.leftNewer) + @@ -631,31 +606,100 @@ wxString BatchDialog::parseConfiguration() if (m_checkBoxSilent->GetValue()) output+= wxString(wxT(" -")) + GlobalResources::paramSilent; -#ifdef FFS_WIN - //retrieve 8.3 directory names to handle unicode names in batch file correctly - wxChar buffer[MAX_PATH]; - if (GetShortPathName( - (m_directoryPanel1->GetValue()).c_str(), // points to a null-terminated path string - buffer, // points to a buffer to receive the null-terminated short form of the path - MAX_PATH // specifies the size of the buffer pointed to by lpszShortPath - ) == 0) - throw FileError(wxString(_("Could not retrieve the 8.3 directory name of ")) + wxT("\"") + m_directoryPanel1->GetValue() + wxT("\"")); - output+= wxString(wxT(" ")) + buffer; - - if (GetShortPathName( - (m_directoryPanel2->GetValue()).c_str(), // points to a null-terminated path string - buffer, // points to a buffer to receive the null-terminated short form of the path - MAX_PATH // specifies the size of the buffer pointed to by lpszShortPath - ) == 0) - throw FileError(wxString(_("Could not retrieve the 8.3 directory name of ")) + wxT("\"") + m_directoryPanel2->GetValue() + wxT("\"")); - output+= wxString(wxT(" ")) + buffer; -#else - output+= wxString(wxT(" ")) + wxT("\"") + wxDir(m_directoryPanel1->GetValue()).GetName() + wxT("\""); //directory WITHOUT trailing path separator - output+= wxString(wxT(" ")) + wxT("\"") + wxDir(m_directoryPanel2->GetValue()).GetName() + wxT("\""); //needed since e.g. "C:\" isn't parsed correctly by commandline -#endif // FFS_WIN + wxString leftDir = FreeFileSync::getFormattedDirectoryName(m_directoryPanel1->GetValue()); + wxString rightDir = FreeFileSync::getFormattedDirectoryName(m_directoryPanel2->GetValue()); - output+= wxT("\n"); + output+= wxString(wxT(" \"")) + wxDir(leftDir).GetName() + wxT("\""); //directory WITHOUT trailing path separator + output+= wxString(wxT(" \"")) + wxDir(rightDir).GetName() + wxT("\""); //needed since e.g. "C:\" isn't parsed correctly by commandline return output; } + +template <typename T> +struct CleanUp +{ + CleanUp(T* element) : m_element(element) {} + + ~CleanUp() + { + m_element->Release(); + } + + T* m_element; +}; + + +bool BatchDialog::createBatchFile(const wxString& filename) +{ +#ifdef FFS_WIN + //create shell link (instead of batch file) for full Unicode support + HRESULT hResult = E_FAIL; + IShellLink* pShellLink = NULL; + + if (FAILED(CoCreateInstance(CLSID_ShellLink, //class identifier + NULL, //object isn't part of an aggregate + CLSCTX_INPROC_SERVER, //context for running executable code + IID_IShellLink, //interface identifier + (void**)&pShellLink))) //pointer to storage of interface pointer + return false; + CleanUp<IShellLink> cleanOnExit(pShellLink); + + wxString freeFileSyncExe = wxStandardPaths::Get().GetExecutablePath(); + if (FAILED(pShellLink->SetPath(freeFileSyncExe.c_str()))) + return false; + + if (FAILED(pShellLink->SetArguments(getCommandlineArguments().c_str()))) + return false; + + if (FAILED(pShellLink->SetIconLocation(freeFileSyncExe.c_str(), 1))) //second icon from executable file is used + return false; + + if (FAILED(pShellLink->SetDescription(_("FreeFileSync Batch Job")))) + return false; + + IPersistFile* pPersistFile = NULL; + if (FAILED(pShellLink->QueryInterface(IID_IPersistFile, (void**)&pPersistFile))) + return false; + CleanUp<IPersistFile> cleanOnExit2(pPersistFile); + + //pPersistFile->Save accepts unicode input only +#ifdef _UNICODE + hResult = pPersistFile->Save(filename.c_str(), TRUE); +#else + WCHAR wszTemp [MAX_PATH]; + if (MultiByteToWideChar(CP_ACP, 0, filename.c_str(), -1, wszTemp, MAX_PATH) == 0) + return false; + + hResult = pPersistFile->Save(wszTemp, TRUE); +#endif + if (FAILED(hResult)) + return false; + + return true; + +//############################################################################ +#elif defined FFS_LINUX + //create shell script + wxFFile output(filename, wxT("w")); + if (output.IsOpened()) + { + wxString outputString; + outputString+= wxT("#!/bin/bash\n"); //shell script identifier + outputString+= wxString(wxT("\"")) + wxStandardPaths::Get().GetExecutablePath() + wxT("\" "); + outputString+= getCommandlineArguments() + wxT("\n"); + + if (!output.Write(outputString)) + return false; + + //for linux the batch file needs the executable flag + output.Close(); + wxExecute(wxString(wxT("chmod +x ")) + filename); + return true; + } + else + return false; +#else + adapt this! +#endif // FFS_LINUX +} diff --git a/ui/SyncDialog.h b/ui/SyncDialog.h index 3eee6400..bf2da634 100644 --- a/ui/SyncDialog.h +++ b/ui/SyncDialog.h @@ -76,10 +76,11 @@ private: void OnClose( wxCloseEvent& event); void OnCancel( wxCommandEvent& event); - void OnCreateJob( wxCommandEvent& event); + void OnCreateBatchJob( wxCommandEvent& event); void updateFilterButton(); - wxString parseConfiguration(); + wxString getCommandlineArguments(); + bool createBatchFile(const wxString& filename); SyncConfiguration localSyncConfiguration; bool filterIsActive; diff --git a/ui/guiGenerated.cpp b/ui/guiGenerated.cpp index d1a1c183..59362a9a 100644 --- a/ui/guiGenerated.cpp +++ b/ui/guiGenerated.cpp @@ -5,16 +5,6 @@ // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif //__BORLANDC__ - -#ifndef WX_PRECOMP -#include <wx/wx.h> -#endif //WX_PRECOMP - #include "../library/customGrid.h" #include "guiGenerated.h" @@ -48,6 +38,9 @@ GuiGenerated::GuiGenerated( wxWindow* parent, wxWindowID id, const wxString& tit m_menuItemFrench = new wxMenuItem( m_menu31, wxID_ANY, wxString( _("Français") ) , wxEmptyString, wxITEM_RADIO ); m_menu31->Append( m_menuItemFrench ); + m_menuItemJapanese = new wxMenuItem( m_menu31, wxID_ANY, wxString( _("日本語") ) , wxEmptyString, wxITEM_RADIO ); + m_menu31->Append( m_menuItemJapanese ); + m_menu3->Append( -1, _("&Language"), m_menu31 ); m_menu3->AppendSeparator(); @@ -120,6 +113,10 @@ GuiGenerated::GuiGenerated( wxWindow* parent, wxWindowID id, const wxString& tit sbSizer6->Add( bSizer45, 0, wxALIGN_CENTER_VERTICAL, 5 ); m_bpButton14 = new wxBitmapButton( m_panel71, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + m_bpButton14->SetToolTip( _("Help") ); + + m_bpButton14->SetToolTip( _("Help") ); + sbSizer6->Add( m_bpButton14, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); bSizer55->Add( sbSizer6, 0, wxALIGN_CENTER_VERTICAL, 2 ); @@ -189,7 +186,6 @@ GuiGenerated::GuiGenerated( wxWindow* parent, wxWindowID id, const wxString& tit wxBoxSizer* bSizer7; bSizer7 = new wxBoxSizer( wxVERTICAL ); - wxStaticBoxSizer* sbSizer2; sbSizer2 = new wxStaticBoxSizer( new wxStaticBox( m_panel1, wxID_ANY, _("Drag && drop") ), wxHORIZONTAL ); m_directoryPanel1 = new wxTextCtrl( m_panel1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); @@ -240,15 +236,18 @@ GuiGenerated::GuiGenerated( wxWindow* parent, wxWindowID id, const wxString& tit bSizer2->Add( m_panel1, 1, wxEXPAND, 5 ); m_panel3 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizer18; bSizer18 = new wxBoxSizer( wxVERTICAL ); + bSizer69 = new wxBoxSizer( wxVERTICAL ); + m_bpButtonSwap = new wxBitmapButton( m_panel3, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); m_bpButtonSwap->SetToolTip( _("Swap sides") ); m_bpButtonSwap->SetToolTip( _("Swap sides") ); - bSizer18->Add( m_bpButtonSwap, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP, 3 ); + bSizer69->Add( m_bpButtonSwap, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP, 5 ); + + bSizer18->Add( bSizer69, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); m_grid3 = new CustomGrid( m_panel3, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); @@ -525,6 +524,7 @@ GuiGenerated::GuiGenerated( wxWindow* parent, wxWindowID id, const wxString& tit this->Connect( m_menuItemEnglish->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuLangEnglish ) ); this->Connect( m_menuItemGerman->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuLangGerman ) ); this->Connect( m_menuItemFrench->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuLangFrench ) ); + this->Connect( m_menuItemJapanese->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuLangJapanese ) ); this->Connect( m_menuItem7->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuBatchJob ) ); this->Connect( m_menuItem3->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuAbout ) ); m_bpButtonCompare->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GuiGenerated::OnCompare ), NULL, this ); @@ -569,6 +569,7 @@ GuiGenerated::~GuiGenerated() this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuLangEnglish ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuLangGerman ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuLangFrench ) ); + this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuLangJapanese ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuBatchJob ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GuiGenerated::OnMenuAbout ) ); m_bpButtonCompare->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GuiGenerated::OnCompare ), NULL, this ); @@ -604,6 +605,344 @@ GuiGenerated::~GuiGenerated() m_bpButton10->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( GuiGenerated::OnQuit ), NULL, this ); } +BatchDlgGenerated::BatchDlgGenerated( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizer54; + bSizer54 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer69; + bSizer69 = new wxBoxSizer( wxVERTICAL ); + + m_panel8 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER|wxTAB_TRAVERSAL ); + m_panel8->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); + + wxBoxSizer* bSizer72; + bSizer72 = new wxBoxSizer( wxVERTICAL ); + + m_staticText56 = new wxStaticText( m_panel8, wxID_ANY, _("Create a batch job"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText56->Wrap( -1 ); + m_staticText56->SetFont( wxFont( 16, 74, 90, 92, false, wxT("Tahoma") ) ); + + bSizer72->Add( m_staticText56, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_panel8->SetSizer( bSizer72 ); + m_panel8->Layout(); + bSizer72->Fit( m_panel8 ); + bSizer69->Add( m_panel8, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + + + bSizer69->Add( 0, 5, 0, 0, 5 ); + + m_staticText54 = new wxStaticText( this, wxID_ANY, _("Assemble a batch file with the following settings. To start synchronization in batch mode simply execute this file or schedule it in your operating system's task planner."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText54->Wrap( 380 ); + m_staticText54->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxT("Tahoma") ) ); + + bSizer69->Add( m_staticText54, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + + bSizer69->Add( 0, 5, 0, 0, 5 ); + + m_staticline10 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer69->Add( m_staticline10, 0, wxEXPAND|wxTOP, 5 ); + + m_staticText531 = new wxStaticText( this, wxID_ANY, _("Configuration overview:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText531->Wrap( -1 ); + m_staticText531->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Arial Black") ) ); + + bSizer69->Add( m_staticText531, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + wxStaticBoxSizer* sbSizer20; + sbSizer20 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); + + wxFlexGridSizer* fgSizer9; + fgSizer9 = new wxFlexGridSizer( 2, 2, 5, 5 ); + fgSizer9->AddGrowableCol( 1 ); + fgSizer9->SetFlexibleDirection( wxHORIZONTAL ); + fgSizer9->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); + + m_staticText53 = new wxStaticText( this, wxID_ANY, _("Left folder:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText53->Wrap( -1 ); + m_staticText53->SetFont( wxFont( 8, 74, 90, 92, false, wxT("Tahoma") ) ); + + fgSizer9->Add( m_staticText53, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_directoryPanel1 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer9->Add( m_directoryPanel1, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + m_staticText541 = new wxStaticText( this, wxID_ANY, _("Right folder:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText541->Wrap( -1 ); + m_staticText541->SetFont( wxFont( 8, 74, 90, 92, false, wxT("Tahoma") ) ); + + fgSizer9->Add( m_staticText541, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + m_directoryPanel2 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + fgSizer9->Add( m_directoryPanel2, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + sbSizer20->Add( fgSizer9, 0, wxEXPAND, 5 ); + + bSizer69->Add( sbSizer20, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + wxBoxSizer* bSizer67; + bSizer67 = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bSizer57; + bSizer57 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer71; + bSizer71 = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bSizer721; + bSizer721 = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* sbSizer6; + sbSizer6 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Compare by...") ), wxVERTICAL ); + + m_radioBtnSizeDate = new wxRadioButton( this, wxID_ANY, _("File size and date"), wxDefaultPosition, wxDefaultSize, 0 ); + m_radioBtnSizeDate->SetValue( true ); + m_radioBtnSizeDate->SetToolTip( _("Files are found equal if\n - filesize\n - last write time (UTC) and date\nare the same.") ); + + sbSizer6->Add( m_radioBtnSizeDate, 0, 0, 5 ); + + m_radioBtnContent = new wxRadioButton( this, wxID_ANY, _("File content"), wxDefaultPosition, wxDefaultSize, 0 ); + m_radioBtnContent->SetToolTip( _("Files are found equal if\n - file content\nis the same.") ); + + sbSizer6->Add( m_radioBtnContent, 0, wxTOP, 5 ); + + bSizer721->Add( sbSizer6, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizer721->Add( 0, 10, 1, 0, 5 ); + + wxBoxSizer* bSizer38; + bSizer38 = new wxBoxSizer( wxVERTICAL ); + + m_checkBoxUseRecycler = new wxCheckBox( this, wxID_ANY, _("Use Recycle Bin"), wxDefaultPosition, wxDefaultSize, 0 ); + + m_checkBoxUseRecycler->SetToolTip( _("Use Recycle Bin when deleting or overwriting files during synchronization") ); + + bSizer38->Add( m_checkBoxUseRecycler, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + m_checkBoxContinueError = new wxCheckBox( this, wxID_ANY, _("Continue on error"), wxDefaultPosition, wxDefaultSize, 0 ); + + m_checkBoxContinueError->SetToolTip( _("Hides error messages during synchronization:\nThey are collected and shown as a list at the end of the process") ); + + bSizer38->Add( m_checkBoxContinueError, 0, wxALL, 5 ); + + m_checkBoxSilent = new wxCheckBox( this, wxID_ANY, _("Silent mode"), wxDefaultPosition, wxDefaultSize, 0 ); + + m_checkBoxSilent->SetToolTip( _("Do not show graphical status and error messages but write to a logfile instead") ); + + bSizer38->Add( m_checkBoxSilent, 0, wxALL, 5 ); + + bSizer721->Add( bSizer38, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + + bSizer721->Add( 0, 10, 1, 0, 5 ); + + bSizer71->Add( bSizer721, 0, wxEXPAND, 5 ); + + + bSizer71->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_bpButtonFilter = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|wxFULL_REPAINT_ON_RESIZE ); + bSizer71->Add( m_bpButtonFilter, 0, wxALIGN_BOTTOM|wxRIGHT, 5 ); + + bSizer57->Add( bSizer71, 0, wxEXPAND, 5 ); + + wxStaticBoxSizer* sbSizer8; + sbSizer8 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); + + wxBoxSizer* bSizer671; + bSizer671 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer681; + bSizer681 = new wxBoxSizer( wxHORIZONTAL ); + + m_bitmap8 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 30,30 ), 0 ); + bSizer681->Add( m_bitmap8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_staticText15 = new wxStaticText( this, wxID_ANY, _("Include"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText15->Wrap( -1 ); + m_staticText15->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); + + bSizer681->Add( m_staticText15, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + bSizer671->Add( bSizer681, 1, wxEXPAND, 5 ); + + m_textCtrlInclude = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 250,-1 ), 0 ); + bSizer671->Add( m_textCtrlInclude, 0, wxALL, 5 ); + + sbSizer8->Add( bSizer671, 0, 0, 5 ); + + + sbSizer8->Add( 0, 10, 0, 0, 5 ); + + wxBoxSizer* bSizer691; + bSizer691 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer70; + bSizer70 = new wxBoxSizer( wxHORIZONTAL ); + + m_bitmap9 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 30,30 ), 0 ); + bSizer70->Add( m_bitmap9, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + + m_staticText16 = new wxStaticText( this, wxID_ANY, _("Exclude"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText16->Wrap( -1 ); + m_staticText16->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); + + bSizer70->Add( m_staticText16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + bSizer691->Add( bSizer70, 1, wxEXPAND, 5 ); + + m_textCtrlExclude = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 250,-1 ), 0 ); + bSizer691->Add( m_textCtrlExclude, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + sbSizer8->Add( bSizer691, 0, 0, 5 ); + + bSizer57->Add( sbSizer8, 0, 0, 5 ); + + bSizer67->Add( bSizer57, 0, 0, 5 ); + + + bSizer67->Add( 10, 0, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + wxStaticBoxSizer* sbSizer61; + sbSizer61 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Configuration") ), wxVERTICAL ); + + wxGridSizer* gSizer3; + gSizer3 = new wxGridSizer( 1, 2, 0, 5 ); + + m_staticText211 = new wxStaticText( this, wxID_ANY, _("Result"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText211->Wrap( -1 ); + m_staticText211->SetFont( wxFont( 8, 74, 90, 92, false, wxT("Tahoma") ) ); + + gSizer3->Add( m_staticText211, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_staticText311 = new wxStaticText( this, wxID_ANY, _("Action"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText311->Wrap( -1 ); + m_staticText311->SetFont( wxFont( 8, 74, 90, 92, false, wxT("Tahoma") ) ); + + gSizer3->Add( m_staticText311, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + sbSizer61->Add( gSizer3, 0, wxEXPAND, 5 ); + + m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + sbSizer61->Add( m_staticline3, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxBOTTOM, 5 ); + + wxGridSizer* gSizer1; + gSizer1 = new wxGridSizer( 5, 2, 0, 5 ); + + m_bitmap13 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 48,48 ), 0 ); + m_bitmap13->SetToolTip( _("Files/folders that exist on left side only") ); + + gSizer1->Add( m_bitmap13, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bpButton5 = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); + gSizer1->Add( m_bpButton5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bitmap14 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 48,48 ), 0 ); + m_bitmap14->SetToolTip( _("Files/folders that exist on right side only") ); + + gSizer1->Add( m_bitmap14, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bpButton6 = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); + gSizer1->Add( m_bpButton6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bitmap15 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 48,48 ), 0 ); + m_bitmap15->SetToolTip( _("Files that exist on both sides, left one is newer") ); + + gSizer1->Add( m_bitmap15, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bpButton7 = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); + gSizer1->Add( m_bpButton7, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bitmap16 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 48,48 ), 0 ); + m_bitmap16->SetToolTip( _("Files that exist on both sides, right one is newer") ); + + gSizer1->Add( m_bitmap16, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bpButton8 = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); + gSizer1->Add( m_bpButton8, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bitmap17 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 48,48 ), 0 ); + m_bitmap17->SetToolTip( _("dummy") ); + + gSizer1->Add( m_bitmap17, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bpButton9 = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); + gSizer1->Add( m_bpButton9, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + sbSizer61->Add( gSizer1, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + bSizer67->Add( sbSizer61, 0, 0, 5 ); + + bSizer69->Add( bSizer67, 0, wxALL, 5 ); + + m_staticline9 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer69->Add( m_staticline9, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + wxBoxSizer* bSizer68; + bSizer68 = new wxBoxSizer( wxHORIZONTAL ); + + m_button6 = new wxButton( this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxSize( -1,30 ), 0 ); + m_button6->SetFont( wxFont( 10, 74, 90, 90, false, wxT("Tahoma") ) ); + + bSizer68->Add( m_button6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_buttonCreate = new wxButton( this, wxID_ANY, _("&Create"), wxDefaultPosition, wxSize( 120,35 ), 0 ); + m_buttonCreate->SetDefault(); + m_buttonCreate->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); + + bSizer68->Add( m_buttonCreate, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + bSizer69->Add( bSizer68, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + + bSizer54->Add( bSizer69, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + this->SetSizer( bSizer54 ); + this->Layout(); + bSizer54->Fit( this ); + + this->Centre( wxBOTH ); + + // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( BatchDlgGenerated::OnClose ) ); + m_directoryPanel1->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BatchDlgGenerated::OnEnterLeftDir ), NULL, this ); + m_directoryPanel2->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BatchDlgGenerated::OnEnterRightDir ), NULL, this ); + m_radioBtnSizeDate->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BatchDlgGenerated::OnChangeCompareVar ), NULL, this ); + m_radioBtnContent->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BatchDlgGenerated::OnChangeCompareVar ), NULL, this ); + m_checkBoxUseRecycler->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnSelectRecycleBin ), NULL, this ); + m_bpButtonFilter->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnFilterButton ), NULL, this ); + m_bpButton5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnExLeftSideOnly ), NULL, this ); + m_bpButton6->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnExRightSideOnly ), NULL, this ); + m_bpButton7->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnLeftNewer ), NULL, this ); + m_bpButton8->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnRightNewer ), NULL, this ); + m_bpButton9->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnDifferent ), NULL, this ); + m_button6->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnCancel ), NULL, this ); + m_buttonCreate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnCreateBatchJob ), NULL, this ); +} + +BatchDlgGenerated::~BatchDlgGenerated() +{ + // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( BatchDlgGenerated::OnClose ) ); + m_directoryPanel1->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BatchDlgGenerated::OnEnterLeftDir ), NULL, this ); + m_directoryPanel2->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BatchDlgGenerated::OnEnterRightDir ), NULL, this ); + m_radioBtnSizeDate->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BatchDlgGenerated::OnChangeCompareVar ), NULL, this ); + m_radioBtnContent->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BatchDlgGenerated::OnChangeCompareVar ), NULL, this ); + m_checkBoxUseRecycler->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnSelectRecycleBin ), NULL, this ); + m_bpButtonFilter->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnFilterButton ), NULL, this ); + m_bpButton5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnExLeftSideOnly ), NULL, this ); + m_bpButton6->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnExRightSideOnly ), NULL, this ); + m_bpButton7->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnLeftNewer ), NULL, this ); + m_bpButton8->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnRightNewer ), NULL, this ); + m_bpButton9->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnDifferent ), NULL, this ); + m_button6->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnCancel ), NULL, this ); + m_buttonCreate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnCreateBatchJob ), NULL, this ); +} + CompareStatusGenerated::CompareStatusGenerated( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style ) { wxBoxSizer* bSizer40; @@ -626,45 +965,45 @@ CompareStatusGenerated::CompareStatusGenerated( wxWindow* parent, wxWindowID id, sbSizer10->Add( m_staticTextScanned, 0, wxALIGN_CENTER_VERTICAL, 5 ); - bSizer42->Add( sbSizer10, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + bSizer42->Add( sbSizer10, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer42->Add( 0, 0, 1, wxEXPAND, 5 ); - sbSizer13 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxHORIZONTAL ); + sbSizer13 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Comparing content") ), wxVERTICAL ); + + wxFlexGridSizer* fgSizer8; + fgSizer8 = new wxFlexGridSizer( 2, 2, 3, 0 ); + fgSizer8->SetFlexibleDirection( wxBOTH ); + fgSizer8->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - m_staticText46 = new wxStaticText( this, wxID_ANY, _("Files to compare:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText46 = new wxStaticText( this, wxID_ANY, _("Files remaining:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText46->Wrap( -1 ); m_staticText46->SetFont( wxFont( 10, 74, 90, 90, false, wxT("Tahoma") ) ); - sbSizer13->Add( m_staticText46, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); + fgSizer8->Add( m_staticText46, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_staticTextFilesToCompare = new wxStaticText( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextFilesToCompare->Wrap( -1 ); m_staticTextFilesToCompare->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); - sbSizer13->Add( m_staticTextFilesToCompare, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 5 ); + fgSizer8->Add( m_staticTextFilesToCompare, 0, wxALIGN_CENTER_VERTICAL, 5 ); - bSizer42->Add( sbSizer13, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); - - - bSizer42->Add( 0, 0, 1, wxEXPAND, 5 ); - - sbSizer11 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxHORIZONTAL ); - - m_staticText32 = new wxStaticText( this, wxID_ANY, _("Data to compare:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText32 = new wxStaticText( this, wxID_ANY, _("Data remaining:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText32->Wrap( -1 ); m_staticText32->SetFont( wxFont( 10, 74, 90, 90, false, wxT("Tahoma") ) ); - sbSizer11->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxRIGHT, 5 ); + fgSizer8->Add( m_staticText32, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_staticTextDataToCompare = new wxStaticText( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextDataToCompare->Wrap( -1 ); m_staticTextDataToCompare->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); - sbSizer11->Add( m_staticTextDataToCompare, 0, wxALIGN_CENTER_VERTICAL, 5 ); + fgSizer8->Add( m_staticTextDataToCompare, 0, wxALIGN_CENTER_VERTICAL, 5 ); + + sbSizer13->Add( fgSizer8, 0, 0, 5 ); - bSizer42->Add( sbSizer11, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + bSizer42->Add( sbSizer13, 0, wxALIGN_CENTER_VERTICAL, 5 ); bSizer42->Add( 0, 0, 1, wxEXPAND, 5 ); @@ -672,21 +1011,19 @@ CompareStatusGenerated::CompareStatusGenerated( wxWindow* parent, wxWindowID id, wxStaticBoxSizer* sbSizer131; sbSizer131 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxHORIZONTAL ); - m_staticText37 = new wxStaticText( this, wxID_ANY, _("Remaining time:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText37 = new wxStaticText( this, wxID_ANY, _("Time elapsed:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText37->Wrap( -1 ); m_staticText37->SetFont( wxFont( 10, 74, 90, 90, false, wxT("Tahoma") ) ); - m_staticText37->Hide(); sbSizer131->Add( m_staticText37, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - m_staticTextRemainingTime = new wxStaticText( this, wxID_ANY, _("--.--"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextRemainingTime->Wrap( -1 ); - m_staticTextRemainingTime->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); - m_staticTextRemainingTime->Hide(); + m_staticTextTimeElapsed = new wxStaticText( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextTimeElapsed->Wrap( -1 ); + m_staticTextTimeElapsed->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); - sbSizer131->Add( m_staticTextRemainingTime, 0, wxALIGN_CENTER_VERTICAL, 5 ); + sbSizer131->Add( m_staticTextTimeElapsed, 0, wxALIGN_CENTER_VERTICAL, 5 ); - bSizer42->Add( sbSizer131, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 ); + bSizer42->Add( sbSizer131, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); bSizer40->Add( bSizer42, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxALL, 5 ); @@ -1145,22 +1482,22 @@ SyncStatusDlgGenerated::SyncStatusDlgGenerated( wxWindow* parent, wxWindowID id, bSizer28 = new wxBoxSizer( wxHORIZONTAL ); - wxBoxSizer* bSizer32; - bSizer32 = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizer33; + bSizer33 = new wxBoxSizer( wxHORIZONTAL ); - m_staticText26 = new wxStaticText( this, wxID_ANY, _("Data remaining:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText26->Wrap( -1 ); - m_staticText26->SetFont( wxFont( 10, 74, 93, 90, false, wxT("Tahoma") ) ); + m_staticText25 = new wxStaticText( this, wxID_ANY, _("Files/folders remaining:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText25->Wrap( -1 ); + m_staticText25->SetFont( wxFont( 10, 74, 93, 90, false, wxT("Tahoma") ) ); - bSizer32->Add( m_staticText26, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bSizer33->Add( m_staticText25, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); - m_staticTextDataRemaining = new wxStaticText( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextDataRemaining->Wrap( -1 ); - m_staticTextDataRemaining->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); + m_staticTextRemainingObj = new wxStaticText( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); + m_staticTextRemainingObj->Wrap( -1 ); + m_staticTextRemainingObj->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); - bSizer32->Add( m_staticTextDataRemaining, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + bSizer33->Add( m_staticTextRemainingObj, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - bSizer28->Add( bSizer32, 0, wxALIGN_CENTER_VERTICAL, 5 ); + bSizer28->Add( bSizer33, 0, wxALIGN_CENTER_VERTICAL, 5 ); bSizer28->Add( 0, 0, 1, 0, 5 ); @@ -1185,22 +1522,22 @@ SyncStatusDlgGenerated::SyncStatusDlgGenerated( wxWindow* parent, wxWindowID id, bSizer28->Add( 0, 0, 1, 0, 5 ); - wxBoxSizer* bSizer33; - bSizer33 = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizer32; + bSizer32 = new wxBoxSizer( wxHORIZONTAL ); - m_staticText25 = new wxStaticText( this, wxID_ANY, _("Files/folders remaining:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText25->Wrap( -1 ); - m_staticText25->SetFont( wxFont( 10, 74, 93, 90, false, wxT("Tahoma") ) ); + m_staticText26 = new wxStaticText( this, wxID_ANY, _("Data remaining:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText26->Wrap( -1 ); + m_staticText26->SetFont( wxFont( 10, 74, 93, 90, false, wxT("Tahoma") ) ); - bSizer33->Add( m_staticText25, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bSizer32->Add( m_staticText26, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 ); - m_staticTextRemainingObj = new wxStaticText( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - m_staticTextRemainingObj->Wrap( -1 ); - m_staticTextRemainingObj->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); + m_staticTextDataRemaining = new wxStaticText( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextDataRemaining->Wrap( -1 ); + m_staticTextDataRemaining->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); - bSizer33->Add( m_staticTextRemainingObj, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); + bSizer32->Add( m_staticTextDataRemaining, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - bSizer28->Add( bSizer33, 0, wxALIGN_CENTER_VERTICAL, 5 ); + bSizer28->Add( bSizer32, 0, wxALIGN_CENTER_VERTICAL, 5 ); bSizer27->Add( bSizer28, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); @@ -1262,10 +1599,114 @@ HelpDlgGenerated::HelpDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr bSizer20->Add( 0, 5, 0, wxEXPAND, 5 ); - m_textCtrl8 = new wxTextCtrl( this, wxID_ANY, _("Compare by \"File size and date\"\n----------------------------------------\nThis variant evaluates two equally named files as being equal when they have the same file size AND the same last write date and time. Notice that the file time is allowed to deviate by up to 2 seconds. This ensures synchronization with the lower-precision file system FAT32 works correctly.\n\nWhen \"Compare\" is triggered with this option set the following decision tree is processed:\n\n -----------------\n |Decision tree|\n -----------------\n ________|___________\n | |\n file exists on both sides on one side only\n _____|______ __|___\n | | | |\nequal different left right\n _________|__________\n | | |\n left newer right newer same date\n\nAs a result 6 different status can be returned to categorize all files:\n\n- exists left only\n- exists right only\n- left newer\n- right newer\n- different filesize (but same date)\n- equal\n\n\nCompare by \"File content\"\n----------------------------------------\nAs the name suggests, two files which share the same name are marked as equal if and only if they have the same content. This option is useful for consistency checks rather than backup operations. Therefore the file times are not taken into account at all.\n\nWith this option enabled the decision tree is smaller:\n\n -----------------\n |Decision tree|\n -----------------\n ________|___________\n | |\n file exists on both sides on one side only\n _____|______ __|___\n | | | |\nequal different left right\n\nAs a result the files are separated into the following categories:\n\n- exists left only\n- exists right only\n- different\n- equal"), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY ); - m_textCtrl8->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); + m_notebook1 = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + m_scrolledWindow1 = new wxScrolledWindow( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxSIMPLE_BORDER|wxVSCROLL ); + m_scrolledWindow1->SetScrollRate( 5, 5 ); + m_scrolledWindow1->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVEBORDER ) ); + + wxBoxSizer* bSizer70; + bSizer70 = new wxBoxSizer( wxVERTICAL ); - bSizer20->Add( m_textCtrl8, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + m_staticText59 = new wxStaticText( m_scrolledWindow1, wxID_ANY, _("Compare by \"File size and date\""), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText59->Wrap( 500 ); + m_staticText59->SetFont( wxFont( 10, 74, 90, 92, true, wxT("Tahoma") ) ); + + bSizer70->Add( m_staticText59, 0, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_staticText60 = new wxStaticText( m_scrolledWindow1, wxID_ANY, _("This variant evaluates two equally named files as being equal when they have the same file size AND the same last write date and time. Notice that the file time is allowed to deviate by up to 2 seconds. This ensures synchronization with the lower-precision file system FAT32 works correctly."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText60->Wrap( 500 ); + bSizer70->Add( m_staticText60, 0, wxALL, 5 ); + + m_staticText61 = new wxStaticText( m_scrolledWindow1, wxID_ANY, _("When \"Compare\" is triggered with this option set the following decision tree is processed:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText61->Wrap( 500 ); + bSizer70->Add( m_staticText61, 0, wxALL, 5 ); + + m_treeCtrl1 = new wxTreeCtrl( m_scrolledWindow1, wxID_ANY, wxDefaultPosition, wxSize( -1,180 ), wxTR_DEFAULT_STYLE ); + m_treeCtrl1->SetBackgroundColour( wxColour( 237, 236, 235 ) ); + + bSizer70->Add( m_treeCtrl1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + m_staticText63 = new wxStaticText( m_scrolledWindow1, wxID_ANY, _("As a result 6 different status can be returned to categorize all files:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText63->Wrap( 500 ); + bSizer70->Add( m_staticText63, 0, wxALL, 5 ); + + m_staticText75 = new wxStaticText( m_scrolledWindow1, wxID_ANY, _("- equal"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText75->Wrap( -1 ); + bSizer70->Add( m_staticText75, 0, wxRIGHT|wxLEFT, 5 ); + + m_staticText76 = new wxStaticText( m_scrolledWindow1, wxID_ANY, _("- left newer"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText76->Wrap( -1 ); + bSizer70->Add( m_staticText76, 0, wxRIGHT|wxLEFT, 5 ); + + m_staticText77 = new wxStaticText( m_scrolledWindow1, wxID_ANY, _("- right newer"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText77->Wrap( -1 ); + bSizer70->Add( m_staticText77, 0, wxRIGHT|wxLEFT, 5 ); + + m_staticText78 = new wxStaticText( m_scrolledWindow1, wxID_ANY, _("- different (same date, different size)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText78->Wrap( -1 ); + bSizer70->Add( m_staticText78, 0, wxRIGHT|wxLEFT, 5 ); + + m_staticText79 = new wxStaticText( m_scrolledWindow1, wxID_ANY, _("- exists left only"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText79->Wrap( -1 ); + bSizer70->Add( m_staticText79, 0, wxRIGHT|wxLEFT, 5 ); + + m_staticText80 = new wxStaticText( m_scrolledWindow1, wxID_ANY, _("- exists right only"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText80->Wrap( -1 ); + bSizer70->Add( m_staticText80, 0, wxRIGHT|wxLEFT, 5 ); + + m_scrolledWindow1->SetSizer( bSizer70 ); + m_scrolledWindow1->Layout(); + bSizer70->Fit( m_scrolledWindow1 ); + m_notebook1->AddPage( m_scrolledWindow1, _("File size and date"), true ); + m_scrolledWindow5 = new wxScrolledWindow( m_notebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL ); + m_scrolledWindow5->SetScrollRate( 5, 5 ); + m_scrolledWindow5->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_INACTIVEBORDER ) ); + + wxBoxSizer* bSizer74; + bSizer74 = new wxBoxSizer( wxVERTICAL ); + + m_staticText65 = new wxStaticText( m_scrolledWindow5, wxID_ANY, _("Compare by \"File content\""), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText65->Wrap( 500 ); + m_staticText65->SetFont( wxFont( 10, 74, 90, 92, true, wxT("Tahoma") ) ); + + bSizer74->Add( m_staticText65, 0, wxALL, 5 ); + + m_staticText66 = new wxStaticText( m_scrolledWindow5, wxID_ANY, _("As the name suggests, two files which share the same name are marked as equal if and only if they have the same content. This option is useful for consistency checks rather than backup operations. Therefore the file times are not taken into account at all.\n\nWith this option enabled the decision tree is smaller:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText66->Wrap( 500 ); + bSizer74->Add( m_staticText66, 0, wxALL, 5 ); + + m_treeCtrl2 = new wxTreeCtrl( m_scrolledWindow5, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE ); + m_treeCtrl2->SetBackgroundColour( wxColour( 237, 236, 235 ) ); + m_treeCtrl2->SetMinSize( wxSize( -1,130 ) ); + + bSizer74->Add( m_treeCtrl2, 0, wxALL|wxEXPAND, 5 ); + + m_staticText69 = new wxStaticText( m_scrolledWindow5, wxID_ANY, _("As a result the files are separated into the following categories:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText69->Wrap( 500 ); + bSizer74->Add( m_staticText69, 0, wxALL, 5 ); + + m_staticText81 = new wxStaticText( m_scrolledWindow5, wxID_ANY, _("- equal"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText81->Wrap( -1 ); + bSizer74->Add( m_staticText81, 0, wxRIGHT|wxLEFT, 5 ); + + m_staticText82 = new wxStaticText( m_scrolledWindow5, wxID_ANY, _("- different"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText82->Wrap( -1 ); + bSizer74->Add( m_staticText82, 0, wxRIGHT|wxLEFT, 5 ); + + m_staticText83 = new wxStaticText( m_scrolledWindow5, wxID_ANY, _("- exists left only"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText83->Wrap( -1 ); + bSizer74->Add( m_staticText83, 0, wxRIGHT|wxLEFT, 5 ); + + m_staticText84 = new wxStaticText( m_scrolledWindow5, wxID_ANY, _("- exists right only"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText84->Wrap( -1 ); + bSizer74->Add( m_staticText84, 0, wxRIGHT|wxLEFT, 5 ); + + m_scrolledWindow5->SetSizer( bSizer74 ); + m_scrolledWindow5->Layout(); + bSizer74->Fit( m_scrolledWindow5 ); + m_notebook1->AddPage( m_scrolledWindow5, _("File content"), false ); + + bSizer20->Add( m_notebook1, 1, wxEXPAND | wxALL, 5 ); m_button8 = new wxButton( this, wxID_OK, _("&OK"), wxDefaultPosition, wxSize( 100,32 ), 0 ); m_button8->SetDefault(); @@ -1330,19 +1771,79 @@ AboutDlgGenerated::AboutDlgGenerated( wxWindow* parent, wxWindowID id, const wxS wxBoxSizer* bSizer53; bSizer53 = new wxBoxSizer( wxVERTICAL ); - wxTextCtrl* m_textCtrl3; - m_textCtrl3 = new wxTextCtrl( this, wxID_ANY, _("Source code written completely in C++ utilizing:\n\n MinGW \t\t- Windows port of GNU Compiler Collection\n wxWidgets \t- Open-Source GUI framework\n wxFormBuilder\t- wxWidgets GUI-builder\n CodeBlocks \t- Open-Source IDE\n\n by ZenJu"), wxDefaultPosition, wxSize( -1,-1 ), wxTE_MULTILINE|wxTE_READONLY|wxDOUBLE_BORDER ); - m_textCtrl3->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); + m_scrolledWindow4 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDOUBLE_BORDER|wxHSCROLL|wxVSCROLL ); + m_scrolledWindow4->SetScrollRate( 5, 5 ); + m_scrolledWindow4->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); + m_scrolledWindow4->SetMinSize( wxSize( -1,125 ) ); - bSizer53->Add( m_textCtrl3, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM, 5 ); + wxBoxSizer* bSizer73; + bSizer73 = new wxBoxSizer( wxVERTICAL ); - m_staticText54 = new wxStaticText( this, wxID_ANY, _("Thanks to Jean-François Hartmann for doing the French translation!"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText72 = new wxStaticText( m_scrolledWindow4, wxID_ANY, _("Source code written completely in C++ utilizing:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText72->Wrap( -1 ); + m_staticText72->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 74, 90, 92, false, wxT("Tahoma") ) ); + + bSizer73->Add( m_staticText72, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_staticText73 = new wxStaticText( m_scrolledWindow4, wxID_ANY, _(" MinGW \t- Windows port of GNU Compiler Collection\n wxWidgets \t- Open-Source GUI framework\n wxFormBuilder\t- wxWidgets GUI-builder\n CodeBlocks \t- Open-Source IDE"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText73->Wrap( -1 ); + bSizer73->Add( m_staticText73, 0, wxALL|wxEXPAND, 5 ); + + m_staticText74 = new wxStaticText( m_scrolledWindow4, wxID_ANY, _("- ZenJu -"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText74->Wrap( -1 ); + m_staticText74->SetFont( wxFont( 10, 74, 93, 90, false, wxT("Tahoma") ) ); + + bSizer73->Add( m_staticText74, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); + + m_scrolledWindow4->SetSizer( bSizer73 ); + m_scrolledWindow4->Layout(); + bSizer73->Fit( m_scrolledWindow4 ); + bSizer53->Add( m_scrolledWindow4, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM, 10 ); + + m_scrolledWindow3 = new wxScrolledWindow( this, wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxDOUBLE_BORDER|wxHSCROLL|wxVSCROLL ); + m_scrolledWindow3->SetScrollRate( 5, 5 ); + m_scrolledWindow3->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_ACTIVEBORDER ) ); + m_scrolledWindow3->SetMinSize( wxSize( -1,70 ) ); + m_scrolledWindow3->SetMaxSize( wxSize( -1,100 ) ); + + wxBoxSizer* bSizer72; + bSizer72 = new wxBoxSizer( wxVERTICAL ); + + m_staticText54 = new wxStaticText( m_scrolledWindow3, wxID_ANY, _("Big thanks for localizing FreeFileSync goes out to:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText54->Wrap( -1 ); - m_staticText54->SetFont( wxFont( 8, 74, 90, 90, false, wxT("Tahoma") ) ); + m_staticText54->SetFont( wxFont( 8, 74, 90, 92, false, wxT("Tahoma") ) ); - bSizer53->Add( m_staticText54, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer72->Add( m_staticText54, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxBOTTOM, 5 ); + + wxFlexGridSizer* fgSizer9; + fgSizer9 = new wxFlexGridSizer( 2, 2, 5, 20 ); + fgSizer9->SetFlexibleDirection( wxBOTH ); + fgSizer9->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - bSizer31->Add( bSizer53, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxRIGHT|wxLEFT, 30 ); + m_staticText68 = new wxStaticText( m_scrolledWindow3, wxID_ANY, _("Jean-François Hartmann"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText68->Wrap( -1 ); + fgSizer9->Add( m_staticText68, 0, 0, 5 ); + + m_staticText69 = new wxStaticText( m_scrolledWindow3, wxID_ANY, _("Français"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText69->Wrap( -1 ); + fgSizer9->Add( m_staticText69, 0, 0, 5 ); + + m_staticText70 = new wxStaticText( m_scrolledWindow3, wxID_ANY, _("Tilt"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText70->Wrap( -1 ); + fgSizer9->Add( m_staticText70, 0, 0, 5 ); + + m_staticText71 = new wxStaticText( m_scrolledWindow3, wxID_ANY, _("日本語"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText71->Wrap( -1 ); + fgSizer9->Add( m_staticText71, 0, 0, 5 ); + + bSizer72->Add( fgSizer9, 0, wxALIGN_CENTER_HORIZONTAL|wxBOTTOM, 5 ); + + m_scrolledWindow3->SetSizer( bSizer72 ); + m_scrolledWindow3->Layout(); + bSizer72->Fit( m_scrolledWindow3 ); + bSizer53->Add( m_scrolledWindow3, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); + + bSizer31->Add( bSizer53, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxEXPAND, 30 ); m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); bSizer31->Add( m_staticline3, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); @@ -1356,7 +1857,7 @@ AboutDlgGenerated::AboutDlgGenerated( wxWindow* parent, wxWindowID id, const wxS sbSizer7->Add( m_staticText131, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - bSizer31->Add( sbSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxBOTTOM, 5 ); + bSizer31->Add( sbSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); wxFlexGridSizer* fgSizer2; fgSizer2 = new wxFlexGridSizer( 3, 3, 0, 0 ); @@ -1400,7 +1901,7 @@ AboutDlgGenerated::AboutDlgGenerated( wxWindow* parent, wxWindowID id, const wxS fgSizer2->Add( m_staticText151, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - m_hyperlink3 = new wxHyperlinkCtrl( this, wxID_ANY, _("Donate with Paypal"), wxT("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=florian%2db%40gmx%2enet&no_shipping=0&no_note=1&tax=0¤cy_code=EUR&lc=DE&bn=PP%2dDonationsBF&charset=UTF%2d8"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); + m_hyperlink3 = new wxHyperlinkCtrl( this, wxID_ANY, _("Donate with PayPal"), wxT("https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=zhnmju123%40gmx%2ede&no_shipping=0&no_note=1&tax=0¤cy_code=EUR&lc=EN&bn=PP%2dDonationsBF&charset=UTF%2d8"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); fgSizer2->Add( m_hyperlink3, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); bSizer31->Add( fgSizer2, 0, wxLEFT|wxEXPAND, 10 ); @@ -1616,27 +2117,71 @@ FilterDlgGenerated::FilterDlgGenerated( wxWindow* parent, wxWindowID id, const w bSizer72->Fit( m_panel8 ); bSizer21->Add( m_panel8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10 ); - m_staticText44 = new wxStaticText( this, wxID_ANY, _("Only files/directories that pass filtering will be selected for synchronization."), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText44->Wrap( -1 ); - bSizer21->Add( m_staticText44, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + wxBoxSizer* bSizer70; + bSizer70 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText44 = new wxStaticText( this, wxID_ANY, _("Only files/directories that pass filtering will be selected for synchronization.\nThe filter will be applied to the full name including path prefix."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText44->Wrap( 400 ); + bSizer70->Add( m_staticText44, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); + + m_bpButtonHelp = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW ); + m_bpButtonHelp->SetToolTip( _("Help") ); + + m_bpButtonHelp->SetToolTip( _("Help") ); + + bSizer70->Add( m_bpButtonHelp, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + bSizer21->Add( bSizer70, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - bSizer21->Add( 0, 10, 0, 0, 5 ); + + bSizer21->Add( 0, 5, 0, 0, 5 ); + + m_panel13 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer69; + bSizer69 = new wxBoxSizer( wxVERTICAL ); + + m_staticline10 = new wxStaticLine( m_panel13, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer69->Add( m_staticline10, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); wxBoxSizer* bSizer52; bSizer52 = new wxBoxSizer( wxVERTICAL ); - m_staticText45 = new wxStaticText( this, wxID_ANY, _("Hints:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText45 = new wxStaticText( m_panel13, wxID_ANY, _("Hints:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText45->Wrap( -1 ); m_staticText45->SetFont( wxFont( 10, 74, 90, 92, true, wxT("Tahoma") ) ); bSizer52->Add( m_staticText45, 0, wxBOTTOM, 5 ); - m_staticText18 = new wxStaticText( this, wxID_ANY, _("1. Enter full file or directory names separated by ';'.\n2. Wildcard characters '*' and '?' are supported.\n3. Case sensitive expressions!\n\nExample: *.tmp;*\\filename.dat;*\\directory\\*"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText18 = new wxStaticText( m_panel13, wxID_ANY, _("1. Enter full file or directory names separated by ';'.\n2. Wildcard characters '*' and '?' are supported."), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText18->Wrap( -1 ); - bSizer52->Add( m_staticText18, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer52->Add( m_staticText18, 0, wxBOTTOM, 5 ); + + bSizer69->Add( bSizer52, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + + wxStaticBoxSizer* sbSizer21; + sbSizer21 = new wxStaticBoxSizer( new wxStaticBox( m_panel13, wxID_ANY, _("Example") ), wxVERTICAL ); + + wxBoxSizer* bSizer66; + bSizer66 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText181 = new wxStaticText( m_panel13, wxID_ANY, _("Include: *.doc;*.zip;*.exe\nExclude: *\\tempfolder\\*"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText181->Wrap( -1 ); + bSizer66->Add( m_staticText181, 0, wxRIGHT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_staticText1811 = new wxStaticText( m_panel13, wxID_ANY, _("Synchronize all .doc, .zip and .exe files except everything from folder \"tempfolder\"."), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText1811->Wrap( 250 ); + m_staticText1811->SetFont( wxFont( 8, 74, 93, 90, false, wxT("Tahoma") ) ); + + bSizer66->Add( m_staticText1811, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + + sbSizer21->Add( bSizer66, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 5 ); - bSizer21->Add( bSizer52, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer69->Add( sbSizer21, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_panel13->SetSizer( bSizer69 ); + m_panel13->Layout(); + bSizer69->Fit( m_panel13 ); + bSizer21->Add( m_panel13, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxBOTTOM, 5 ); wxStaticBoxSizer* sbSizer8; sbSizer8 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); @@ -1685,7 +2230,7 @@ FilterDlgGenerated::FilterDlgGenerated( wxWindow* parent, wxWindowID id, const w sbSizer8->Add( fgSizer4, 0, 0, 5 ); - bSizer21->Add( sbSizer8, 0, wxRIGHT|wxLEFT|wxALIGN_CENTER_HORIZONTAL, 5 ); + bSizer21->Add( sbSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT|wxEXPAND, 5 ); bSizer21->Add( 0, 0, 0, 0, 5 ); @@ -1720,6 +2265,7 @@ FilterDlgGenerated::FilterDlgGenerated( wxWindow* parent, wxWindowID id, const w // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( FilterDlgGenerated::OnClose ) ); + m_bpButtonHelp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( FilterDlgGenerated::OnHelp ), NULL, this ); m_button9->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( FilterDlgGenerated::OnDefault ), NULL, this ); m_button17->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( FilterDlgGenerated::OnCancel ), NULL, this ); m_button10->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( FilterDlgGenerated::OnOK ), NULL, this ); @@ -1729,345 +2275,8 @@ FilterDlgGenerated::~FilterDlgGenerated() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( FilterDlgGenerated::OnClose ) ); + m_bpButtonHelp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( FilterDlgGenerated::OnHelp ), NULL, this ); m_button9->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( FilterDlgGenerated::OnDefault ), NULL, this ); m_button17->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( FilterDlgGenerated::OnCancel ), NULL, this ); m_button10->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( FilterDlgGenerated::OnOK ), NULL, this ); } - -BatchDlgGenerated::BatchDlgGenerated( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) -{ - this->SetSizeHints( wxDefaultSize, wxDefaultSize ); - - wxBoxSizer* bSizer54; - bSizer54 = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bSizer69; - bSizer69 = new wxBoxSizer( wxVERTICAL ); - - m_panel8 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER|wxTAB_TRAVERSAL ); - m_panel8->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DLIGHT ) ); - - wxBoxSizer* bSizer72; - bSizer72 = new wxBoxSizer( wxVERTICAL ); - - m_staticText56 = new wxStaticText( m_panel8, wxID_ANY, _("Create a batch job"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText56->Wrap( -1 ); - m_staticText56->SetFont( wxFont( 16, 74, 90, 92, false, wxT("Tahoma") ) ); - - bSizer72->Add( m_staticText56, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - m_panel8->SetSizer( bSizer72 ); - m_panel8->Layout(); - bSizer72->Fit( m_panel8 ); - bSizer69->Add( m_panel8, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - - - bSizer69->Add( 0, 5, 0, 0, 5 ); - - m_staticText54 = new wxStaticText( this, wxID_ANY, _("Assemble a batch file with the following settings. To start synchronization in batch mode simply execute this file or schedule it in your operating system's task planner."), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText54->Wrap( 380 ); - m_staticText54->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxT("Tahoma") ) ); - - bSizer69->Add( m_staticText54, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - - bSizer69->Add( 0, 5, 0, 0, 5 ); - - m_staticline10 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizer69->Add( m_staticline10, 0, wxEXPAND|wxTOP, 5 ); - - m_staticText531 = new wxStaticText( this, wxID_ANY, _("Configuration overview:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText531->Wrap( -1 ); - m_staticText531->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Arial Black") ) ); - - bSizer69->Add( m_staticText531, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - wxStaticBoxSizer* sbSizer20; - sbSizer20 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); - - wxFlexGridSizer* fgSizer9; - fgSizer9 = new wxFlexGridSizer( 2, 2, 5, 5 ); - fgSizer9->AddGrowableCol( 1 ); - fgSizer9->SetFlexibleDirection( wxHORIZONTAL ); - fgSizer9->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - - m_staticText53 = new wxStaticText( this, wxID_ANY, _("Left folder:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText53->Wrap( -1 ); - m_staticText53->SetFont( wxFont( 8, 74, 90, 92, false, wxT("Tahoma") ) ); - - fgSizer9->Add( m_staticText53, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_directoryPanel1 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer9->Add( m_directoryPanel1, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - m_staticText541 = new wxStaticText( this, wxID_ANY, _("Right folder:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText541->Wrap( -1 ); - m_staticText541->SetFont( wxFont( 8, 74, 90, 92, false, wxT("Tahoma") ) ); - - fgSizer9->Add( m_staticText541, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - - m_directoryPanel2 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - fgSizer9->Add( m_directoryPanel2, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); - - sbSizer20->Add( fgSizer9, 0, wxEXPAND, 5 ); - - bSizer69->Add( sbSizer20, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - wxBoxSizer* bSizer67; - bSizer67 = new wxBoxSizer( wxHORIZONTAL ); - - wxBoxSizer* bSizer57; - bSizer57 = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bSizer71; - bSizer71 = new wxBoxSizer( wxHORIZONTAL ); - - wxBoxSizer* bSizer721; - bSizer721 = new wxBoxSizer( wxVERTICAL ); - - wxStaticBoxSizer* sbSizer6; - sbSizer6 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Compare by...") ), wxVERTICAL ); - - m_radioBtnSizeDate = new wxRadioButton( this, wxID_ANY, _("File size and date"), wxDefaultPosition, wxDefaultSize, 0 ); - m_radioBtnSizeDate->SetValue( true ); - m_radioBtnSizeDate->SetToolTip( _("Files are found equal if\n - filesize\n - last write time (UTC) and date\nare the same.") ); - - sbSizer6->Add( m_radioBtnSizeDate, 0, 0, 5 ); - - m_radioBtnContent = new wxRadioButton( this, wxID_ANY, _("File content"), wxDefaultPosition, wxDefaultSize, 0 ); - m_radioBtnContent->SetToolTip( _("Files are found equal if\n - file content\nis the same.") ); - - sbSizer6->Add( m_radioBtnContent, 0, wxTOP, 5 ); - - bSizer721->Add( sbSizer6, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - bSizer721->Add( 0, 10, 1, 0, 5 ); - - wxBoxSizer* bSizer38; - bSizer38 = new wxBoxSizer( wxVERTICAL ); - - m_checkBoxUseRecycler = new wxCheckBox( this, wxID_ANY, _("Use Recycle Bin"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_checkBoxUseRecycler->SetToolTip( _("Use Recycle Bin when deleting or overwriting files during synchronization") ); - - bSizer38->Add( m_checkBoxUseRecycler, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - m_checkBoxContinueError = new wxCheckBox( this, wxID_ANY, _("Continue on error"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_checkBoxContinueError->SetToolTip( _("Hides error messages during synchronization:\nThey are collected and shown as a list at the end of the process") ); - - bSizer38->Add( m_checkBoxContinueError, 0, wxALL, 5 ); - - m_checkBoxSilent = new wxCheckBox( this, wxID_ANY, _("Silent mode"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_checkBoxSilent->SetToolTip( _("Do not show graphical status and error messages but write to a logfile instead") ); - - bSizer38->Add( m_checkBoxSilent, 0, wxALL, 5 ); - - bSizer721->Add( bSizer38, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - - bSizer721->Add( 0, 10, 1, 0, 5 ); - - bSizer71->Add( bSizer721, 0, wxEXPAND, 5 ); - - - bSizer71->Add( 0, 0, 1, wxEXPAND, 5 ); - - m_bpButtonFilter = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 40,40 ), wxBU_AUTODRAW|wxFULL_REPAINT_ON_RESIZE ); - bSizer71->Add( m_bpButtonFilter, 0, wxALIGN_BOTTOM|wxRIGHT, 5 ); - - bSizer57->Add( bSizer71, 0, wxEXPAND, 5 ); - - wxStaticBoxSizer* sbSizer8; - sbSizer8 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL ); - - wxBoxSizer* bSizer671; - bSizer671 = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bSizer681; - bSizer681 = new wxBoxSizer( wxHORIZONTAL ); - - m_bitmap8 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 30,30 ), 0 ); - bSizer681->Add( m_bitmap8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_staticText15 = new wxStaticText( this, wxID_ANY, _("Include"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText15->Wrap( -1 ); - m_staticText15->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); - - bSizer681->Add( m_staticText15, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - bSizer671->Add( bSizer681, 1, wxEXPAND, 5 ); - - m_textCtrlInclude = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 250,-1 ), 0 ); - bSizer671->Add( m_textCtrlInclude, 0, wxALL, 5 ); - - sbSizer8->Add( bSizer671, 0, 0, 5 ); - - - sbSizer8->Add( 0, 10, 0, 0, 5 ); - - wxBoxSizer* bSizer691; - bSizer691 = new wxBoxSizer( wxVERTICAL ); - - wxBoxSizer* bSizer70; - bSizer70 = new wxBoxSizer( wxHORIZONTAL ); - - m_bitmap9 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 30,30 ), 0 ); - bSizer70->Add( m_bitmap9, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); - - m_staticText16 = new wxStaticText( this, wxID_ANY, _("Exclude"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText16->Wrap( -1 ); - m_staticText16->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); - - bSizer70->Add( m_staticText16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - - bSizer691->Add( bSizer70, 1, wxEXPAND, 5 ); - - m_textCtrlExclude = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 250,-1 ), 0 ); - bSizer691->Add( m_textCtrlExclude, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - sbSizer8->Add( bSizer691, 0, 0, 5 ); - - bSizer57->Add( sbSizer8, 0, 0, 5 ); - - bSizer67->Add( bSizer57, 0, 0, 5 ); - - - bSizer67->Add( 10, 0, 0, wxALIGN_CENTER_VERTICAL, 5 ); - - wxStaticBoxSizer* sbSizer61; - sbSizer61 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Configuration") ), wxVERTICAL ); - - wxGridSizer* gSizer3; - gSizer3 = new wxGridSizer( 1, 2, 0, 5 ); - - m_staticText211 = new wxStaticText( this, wxID_ANY, _("Result"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText211->Wrap( -1 ); - m_staticText211->SetFont( wxFont( 8, 74, 90, 92, false, wxT("Tahoma") ) ); - - gSizer3->Add( m_staticText211, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_staticText311 = new wxStaticText( this, wxID_ANY, _("Action"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText311->Wrap( -1 ); - m_staticText311->SetFont( wxFont( 8, 74, 90, 92, false, wxT("Tahoma") ) ); - - gSizer3->Add( m_staticText311, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - sbSizer61->Add( gSizer3, 0, wxEXPAND, 5 ); - - m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - sbSizer61->Add( m_staticline3, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND|wxTOP|wxBOTTOM, 5 ); - - wxGridSizer* gSizer1; - gSizer1 = new wxGridSizer( 5, 2, 0, 5 ); - - m_bitmap13 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 48,48 ), 0 ); - m_bitmap13->SetToolTip( _("Files/folders that exist on left side only") ); - - gSizer1->Add( m_bitmap13, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_bpButton5 = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - gSizer1->Add( m_bpButton5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_bitmap14 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 48,48 ), 0 ); - m_bitmap14->SetToolTip( _("Files/folders that exist on right side only") ); - - gSizer1->Add( m_bitmap14, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_bpButton6 = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - gSizer1->Add( m_bpButton6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_bitmap15 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 48,48 ), 0 ); - m_bitmap15->SetToolTip( _("Files that exist on both sides, left one is newer") ); - - gSizer1->Add( m_bitmap15, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_bpButton7 = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - gSizer1->Add( m_bpButton7, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_bitmap16 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 48,48 ), 0 ); - m_bitmap16->SetToolTip( _("Files that exist on both sides, right one is newer") ); - - gSizer1->Add( m_bitmap16, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_bpButton8 = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - gSizer1->Add( m_bpButton8, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_bitmap17 = new wxStaticBitmap( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 48,48 ), 0 ); - m_bitmap17->SetToolTip( _("dummy") ); - - gSizer1->Add( m_bitmap17, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_bpButton9 = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( 42,42 ), wxBU_AUTODRAW ); - gSizer1->Add( m_bpButton9, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - sbSizer61->Add( gSizer1, 0, wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); - - bSizer67->Add( sbSizer61, 0, 0, 5 ); - - bSizer69->Add( bSizer67, 0, wxALL, 5 ); - - m_staticline9 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizer69->Add( m_staticline9, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); - - wxBoxSizer* bSizer68; - bSizer68 = new wxBoxSizer( wxHORIZONTAL ); - - m_button6 = new wxButton( this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxSize( -1,30 ), 0 ); - m_button6->SetFont( wxFont( 10, 74, 90, 90, false, wxT("Tahoma") ) ); - - bSizer68->Add( m_button6, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - - m_buttonCreate = new wxButton( this, wxID_ANY, _("&Create"), wxDefaultPosition, wxSize( 120,35 ), 0 ); - m_buttonCreate->SetDefault(); - m_buttonCreate->SetFont( wxFont( 10, 74, 90, 92, false, wxT("Tahoma") ) ); - - bSizer68->Add( m_buttonCreate, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 ); - - bSizer69->Add( bSizer68, 0, wxALIGN_CENTER_HORIZONTAL, 5 ); - - bSizer54->Add( bSizer69, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); - - this->SetSizer( bSizer54 ); - this->Layout(); - bSizer54->Fit( this ); - - this->Centre( wxBOTH ); - - // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( BatchDlgGenerated::OnClose ) ); - m_directoryPanel1->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BatchDlgGenerated::OnEnterLeftDir ), NULL, this ); - m_directoryPanel2->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BatchDlgGenerated::OnEnterRightDir ), NULL, this ); - m_radioBtnSizeDate->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BatchDlgGenerated::OnChangeCompareVar ), NULL, this ); - m_radioBtnContent->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BatchDlgGenerated::OnChangeCompareVar ), NULL, this ); - m_checkBoxUseRecycler->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnSelectRecycleBin ), NULL, this ); - m_bpButtonFilter->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnFilterButton ), NULL, this ); - m_bpButton5->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnExLeftSideOnly ), NULL, this ); - m_bpButton6->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnExRightSideOnly ), NULL, this ); - m_bpButton7->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnLeftNewer ), NULL, this ); - m_bpButton8->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnRightNewer ), NULL, this ); - m_bpButton9->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnDifferent ), NULL, this ); - m_button6->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnCancel ), NULL, this ); - m_buttonCreate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnCreateJob ), NULL, this ); -} - -BatchDlgGenerated::~BatchDlgGenerated() -{ - // Disconnect Events - this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( BatchDlgGenerated::OnClose ) ); - m_directoryPanel1->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BatchDlgGenerated::OnEnterLeftDir ), NULL, this ); - m_directoryPanel2->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( BatchDlgGenerated::OnEnterRightDir ), NULL, this ); - m_radioBtnSizeDate->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BatchDlgGenerated::OnChangeCompareVar ), NULL, this ); - m_radioBtnContent->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( BatchDlgGenerated::OnChangeCompareVar ), NULL, this ); - m_checkBoxUseRecycler->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnSelectRecycleBin ), NULL, this ); - m_bpButtonFilter->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnFilterButton ), NULL, this ); - m_bpButton5->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnExLeftSideOnly ), NULL, this ); - m_bpButton6->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnExRightSideOnly ), NULL, this ); - m_bpButton7->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnLeftNewer ), NULL, this ); - m_bpButton8->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnRightNewer ), NULL, this ); - m_bpButton9->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnDifferent ), NULL, this ); - m_button6->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnCancel ), NULL, this ); - m_buttonCreate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BatchDlgGenerated::OnCreateJob ), NULL, this ); -} diff --git a/ui/guiGenerated.h b/ui/guiGenerated.h index a606fc7a..47ce567c 100644 --- a/ui/guiGenerated.h +++ b/ui/guiGenerated.h @@ -37,9 +37,12 @@ class CustomGrid; #include <wx/statline.h> #include <wx/statbmp.h> #include <wx/frame.h> -#include <wx/gauge.h> #include <wx/dialog.h> +#include <wx/gauge.h> #include <wx/animate.h> +#include <wx/treectrl.h> +#include <wx/scrolwin.h> +#include <wx/notebook.h> /////////////////////////////////////////////////////////////////////////// @@ -59,6 +62,7 @@ class GuiGenerated : public wxFrame wxMenuItem* m_menuItemEnglish; wxMenuItem* m_menuItemGerman; wxMenuItem* m_menuItemFrench; + wxMenuItem* m_menuItemJapanese; wxMenu* m_menu2; wxBoxSizer* bSizer1; wxPanel* m_panel71; @@ -78,10 +82,13 @@ class GuiGenerated : public wxFrame wxBitmapButton* m_bpButtonSync; wxPanel* m_panel1; + wxStaticBoxSizer* sbSizer2; wxTextCtrl* m_directoryPanel1; wxDirPickerCtrl* m_dirPicker1; CustomGrid* m_grid1; wxPanel* m_panel3; + wxBoxSizer* bSizer18; + wxBoxSizer* bSizer69; wxBitmapButton* m_bpButtonSwap; CustomGrid* m_grid3; wxPanel* m_panel2; @@ -124,6 +131,7 @@ class GuiGenerated : public wxFrame virtual void OnMenuLangEnglish( wxCommandEvent& event ){ event.Skip(); } virtual void OnMenuLangGerman( wxCommandEvent& event ){ event.Skip(); } virtual void OnMenuLangFrench( wxCommandEvent& event ){ event.Skip(); } + virtual void OnMenuLangJapanese( wxCommandEvent& event ){ event.Skip(); } virtual void OnMenuBatchJob( wxCommandEvent& event ){ event.Skip(); } virtual void OnMenuAbout( wxCommandEvent& event ){ event.Skip(); } virtual void OnCompare( wxCommandEvent& event ){ event.Skip(); } @@ -164,6 +172,81 @@ class GuiGenerated : public wxFrame }; /////////////////////////////////////////////////////////////////////////////// +/// Class BatchDlgGenerated +/////////////////////////////////////////////////////////////////////////////// +class BatchDlgGenerated : public wxDialog +{ + private: + + protected: + wxPanel* m_panel8; + wxStaticText* m_staticText56; + + wxStaticText* m_staticText54; + + wxStaticLine* m_staticline10; + wxStaticText* m_staticText531; + wxStaticText* m_staticText53; + wxTextCtrl* m_directoryPanel1; + wxStaticText* m_staticText541; + wxTextCtrl* m_directoryPanel2; + wxRadioButton* m_radioBtnSizeDate; + wxRadioButton* m_radioBtnContent; + + wxCheckBox* m_checkBoxUseRecycler; + wxCheckBox* m_checkBoxContinueError; + wxCheckBox* m_checkBoxSilent; + + + wxBitmapButton* m_bpButtonFilter; + wxStaticBitmap* m_bitmap8; + wxStaticText* m_staticText15; + wxTextCtrl* m_textCtrlInclude; + + wxStaticBitmap* m_bitmap9; + wxStaticText* m_staticText16; + wxTextCtrl* m_textCtrlExclude; + + wxStaticText* m_staticText211; + wxStaticText* m_staticText311; + wxStaticLine* m_staticline3; + wxStaticBitmap* m_bitmap13; + wxBitmapButton* m_bpButton5; + wxStaticBitmap* m_bitmap14; + wxBitmapButton* m_bpButton6; + wxStaticBitmap* m_bitmap15; + wxBitmapButton* m_bpButton7; + wxStaticBitmap* m_bitmap16; + wxBitmapButton* m_bpButton8; + wxStaticBitmap* m_bitmap17; + wxBitmapButton* m_bpButton9; + wxStaticLine* m_staticline9; + wxButton* m_button6; + wxButton* m_buttonCreate; + + // Virtual event handlers, overide them in your derived class + virtual void OnClose( wxCloseEvent& event ){ event.Skip(); } + virtual void OnEnterLeftDir( wxCommandEvent& event ){ event.Skip(); } + virtual void OnEnterRightDir( wxCommandEvent& event ){ event.Skip(); } + virtual void OnChangeCompareVar( wxCommandEvent& event ){ event.Skip(); } + virtual void OnSelectRecycleBin( wxCommandEvent& event ){ event.Skip(); } + virtual void OnFilterButton( wxCommandEvent& event ){ event.Skip(); } + virtual void OnExLeftSideOnly( wxCommandEvent& event ){ event.Skip(); } + virtual void OnExRightSideOnly( wxCommandEvent& event ){ event.Skip(); } + virtual void OnLeftNewer( wxCommandEvent& event ){ event.Skip(); } + virtual void OnRightNewer( wxCommandEvent& event ){ event.Skip(); } + virtual void OnDifferent( wxCommandEvent& event ){ event.Skip(); } + virtual void OnCancel( wxCommandEvent& event ){ event.Skip(); } + virtual void OnCreateBatchJob( wxCommandEvent& event ){ event.Skip(); } + + + public: + BatchDlgGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE ); + ~BatchDlgGenerated(); + +}; + +/////////////////////////////////////////////////////////////////////////////// /// Class CompareStatusGenerated /////////////////////////////////////////////////////////////////////////////// class CompareStatusGenerated : public wxPanel @@ -178,13 +261,11 @@ class CompareStatusGenerated : public wxPanel wxStaticBoxSizer* sbSizer13; wxStaticText* m_staticText46; wxStaticText* m_staticTextFilesToCompare; - - wxStaticBoxSizer* sbSizer11; wxStaticText* m_staticText32; wxStaticText* m_staticTextDataToCompare; wxStaticText* m_staticText37; - wxStaticText* m_staticTextRemainingTime; + wxStaticText* m_staticTextTimeElapsed; wxStaticText* m_staticText30; wxTextCtrl* m_textCtrlFilename; wxGauge* m_gauge2; @@ -292,15 +373,15 @@ class SyncStatusDlgGenerated : public wxDialog wxStaticText* m_staticTextTimeElapsed; wxTextCtrl* m_textCtrlInfo; wxBoxSizer* bSizer28; - wxStaticText* m_staticText26; - wxStaticText* m_staticTextDataRemaining; + wxStaticText* m_staticText25; + wxStaticText* m_staticTextRemainingObj; wxButton* m_buttonOK; wxButton* m_buttonPause; wxButton* m_buttonAbort; - wxStaticText* m_staticText25; - wxStaticText* m_staticTextRemainingObj; + wxStaticText* m_staticText26; + wxStaticText* m_staticTextDataRemaining; // Virtual event handlers, overide them in your derived class @@ -331,7 +412,28 @@ class HelpDlgGenerated : public wxDialog wxStaticText* m_staticText56; - wxTextCtrl* m_textCtrl8; + wxNotebook* m_notebook1; + wxScrolledWindow* m_scrolledWindow1; + wxStaticText* m_staticText59; + wxStaticText* m_staticText60; + wxStaticText* m_staticText61; + wxTreeCtrl* m_treeCtrl1; + wxStaticText* m_staticText63; + wxStaticText* m_staticText75; + wxStaticText* m_staticText76; + wxStaticText* m_staticText77; + wxStaticText* m_staticText78; + wxStaticText* m_staticText79; + wxStaticText* m_staticText80; + wxScrolledWindow* m_scrolledWindow5; + wxStaticText* m_staticText65; + wxStaticText* m_staticText66; + wxTreeCtrl* m_treeCtrl2; + wxStaticText* m_staticText69; + wxStaticText* m_staticText81; + wxStaticText* m_staticText82; + wxStaticText* m_staticText83; + wxStaticText* m_staticText84; wxButton* m_button8; // Virtual event handlers, overide them in your derived class @@ -340,7 +442,7 @@ class HelpDlgGenerated : public wxDialog public: - HelpDlgGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 557,385 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + HelpDlgGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 565,501 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~HelpDlgGenerated(); }; @@ -359,7 +461,16 @@ class AboutDlgGenerated : public wxDialog wxStaticText* m_staticText15; wxStaticText* m_build; + wxScrolledWindow* m_scrolledWindow4; + wxStaticText* m_staticText72; + wxStaticText* m_staticText73; + wxStaticText* m_staticText74; + wxScrolledWindow* m_scrolledWindow3; wxStaticText* m_staticText54; + wxStaticText* m_staticText68; + wxStaticText* m_staticText69; + wxStaticText* m_staticText70; + wxStaticText* m_staticText71; wxStaticLine* m_staticline3; wxStaticText* m_staticText131; wxStaticBitmap* m_bitmap9; @@ -460,9 +571,14 @@ class FilterDlgGenerated : public wxDialog wxPanel* m_panel8; wxStaticText* m_staticText56; wxStaticText* m_staticText44; + wxBitmapButton* m_bpButtonHelp; + wxPanel* m_panel13; + wxStaticLine* m_staticline10; wxStaticText* m_staticText45; wxStaticText* m_staticText18; + wxStaticText* m_staticText181; + wxStaticText* m_staticText1811; wxStaticText* m_staticText15; wxStaticBitmap* m_bitmap8; @@ -479,6 +595,7 @@ class FilterDlgGenerated : public wxDialog // Virtual event handlers, overide them in your derived class virtual void OnClose( wxCloseEvent& event ){ event.Skip(); } + virtual void OnHelp( wxCommandEvent& event ){ event.Skip(); } virtual void OnDefault( wxCommandEvent& event ){ event.Skip(); } virtual void OnCancel( wxCommandEvent& event ){ event.Skip(); } virtual void OnOK( wxCommandEvent& event ){ event.Skip(); } @@ -490,79 +607,4 @@ class FilterDlgGenerated : public wxDialog }; -/////////////////////////////////////////////////////////////////////////////// -/// Class BatchDlgGenerated -/////////////////////////////////////////////////////////////////////////////// -class BatchDlgGenerated : public wxDialog -{ - private: - - protected: - wxPanel* m_panel8; - wxStaticText* m_staticText56; - - wxStaticText* m_staticText54; - - wxStaticLine* m_staticline10; - wxStaticText* m_staticText531; - wxStaticText* m_staticText53; - wxTextCtrl* m_directoryPanel1; - wxStaticText* m_staticText541; - wxTextCtrl* m_directoryPanel2; - wxRadioButton* m_radioBtnSizeDate; - wxRadioButton* m_radioBtnContent; - - wxCheckBox* m_checkBoxUseRecycler; - wxCheckBox* m_checkBoxContinueError; - wxCheckBox* m_checkBoxSilent; - - - wxBitmapButton* m_bpButtonFilter; - wxStaticBitmap* m_bitmap8; - wxStaticText* m_staticText15; - wxTextCtrl* m_textCtrlInclude; - - wxStaticBitmap* m_bitmap9; - wxStaticText* m_staticText16; - wxTextCtrl* m_textCtrlExclude; - - wxStaticText* m_staticText211; - wxStaticText* m_staticText311; - wxStaticLine* m_staticline3; - wxStaticBitmap* m_bitmap13; - wxBitmapButton* m_bpButton5; - wxStaticBitmap* m_bitmap14; - wxBitmapButton* m_bpButton6; - wxStaticBitmap* m_bitmap15; - wxBitmapButton* m_bpButton7; - wxStaticBitmap* m_bitmap16; - wxBitmapButton* m_bpButton8; - wxStaticBitmap* m_bitmap17; - wxBitmapButton* m_bpButton9; - wxStaticLine* m_staticline9; - wxButton* m_button6; - wxButton* m_buttonCreate; - - // Virtual event handlers, overide them in your derived class - virtual void OnClose( wxCloseEvent& event ){ event.Skip(); } - virtual void OnEnterLeftDir( wxCommandEvent& event ){ event.Skip(); } - virtual void OnEnterRightDir( wxCommandEvent& event ){ event.Skip(); } - virtual void OnChangeCompareVar( wxCommandEvent& event ){ event.Skip(); } - virtual void OnSelectRecycleBin( wxCommandEvent& event ){ event.Skip(); } - virtual void OnFilterButton( wxCommandEvent& event ){ event.Skip(); } - virtual void OnExLeftSideOnly( wxCommandEvent& event ){ event.Skip(); } - virtual void OnExRightSideOnly( wxCommandEvent& event ){ event.Skip(); } - virtual void OnLeftNewer( wxCommandEvent& event ){ event.Skip(); } - virtual void OnRightNewer( wxCommandEvent& event ){ event.Skip(); } - virtual void OnDifferent( wxCommandEvent& event ){ event.Skip(); } - virtual void OnCancel( wxCommandEvent& event ){ event.Skip(); } - virtual void OnCreateJob( wxCommandEvent& event ){ event.Skip(); } - - - public: - BatchDlgGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE ); - ~BatchDlgGenerated(); - -}; - #endif //__guiGenerated__ |