summaryrefslogtreecommitdiff
path: root/structures.h
diff options
context:
space:
mode:
Diffstat (limited to 'structures.h')
-rw-r--r--structures.h512
1 files changed, 255 insertions, 257 deletions
diff --git a/structures.h b/structures.h
index 4d383d22..cdfea74e 100644
--- a/structures.h
+++ b/structures.h
@@ -11,309 +11,307 @@
namespace FreeFileSync
{
- enum CompareVariant
- {
- CMP_BY_TIME_SIZE,
- CMP_BY_CONTENT
- };
+enum CompareVariant
+{
+ CMP_BY_TIME_SIZE,
+ CMP_BY_CONTENT
+};
+
+wxString getVariantName(CompareVariant var);
- wxString getVariantName(CompareVariant var);
+
+enum SyncDirection
+{
+ SYNC_DIR_LEFT = 0,
+ SYNC_DIR_RIGHT,
+ SYNC_DIR_NONE, //NOTE: align with SyncDirectionIntern before adding anything here!
+};
- enum SyncDirectionCfg
+class SyncConfiguration
+{
+public:
+ SyncConfiguration() :
+ automatic(true),
+ exLeftSideOnly( SYNC_DIR_RIGHT),
+ exRightSideOnly(SYNC_DIR_LEFT),
+ leftNewer( SYNC_DIR_RIGHT),
+ rightNewer( SYNC_DIR_LEFT),
+ different( SYNC_DIR_NONE),
+ conflict( SYNC_DIR_NONE) {}
+
+ bool operator==(const SyncConfiguration& other) const
{
- SYNC_DIR_CFG_LEFT = 0,
- SYNC_DIR_CFG_RIGHT,
- SYNC_DIR_CFG_NONE
- };
- //attention make sure these /|\ \|/ two enums match!!!
- enum SyncDirection
+ return exLeftSideOnly == other.exLeftSideOnly &&
+ exRightSideOnly == other.exRightSideOnly &&
+ leftNewer == other.leftNewer &&
+ rightNewer == other.rightNewer &&
+ different == other.different &&
+ conflict == other.conflict;
+ }
+
+ //get/set default configuration variants
+ enum Variant
{
- SYNC_DIR_LEFT = SYNC_DIR_CFG_LEFT,
- SYNC_DIR_RIGHT = SYNC_DIR_CFG_RIGHT,
- SYNC_DIR_NONE = SYNC_DIR_CFG_NONE,
+ AUTOMATIC,
+ MIRROR,
+ UPDATE,
+ TWOWAY,
+ CUSTOM
};
+ Variant getVariant() const;
+ void setVariant(const Variant var);
+
+ bool automatic; //use sync-database
+ SyncDirection exLeftSideOnly;
+ SyncDirection exRightSideOnly;
+ SyncDirection leftNewer;
+ SyncDirection rightNewer;
+ SyncDirection different;
+ SyncDirection conflict;
+};
+
+
+enum DeletionPolicy
+{
+ DELETE_PERMANENTLY = 5,
+ MOVE_TO_RECYCLE_BIN,
+ MOVE_TO_CUSTOM_DIRECTORY
+};
- inline
- SyncDirection convertToSyncDirection(SyncDirectionCfg syncCfg)
+struct HiddenSettings
+{
+ HiddenSettings() :
+ fileTimeTolerance(2), //default 2s: FAT vs NTFS
+ traverseDirectorySymlinks(false),
+ copyFileSymlinks(true),
+ verifyFileCopy(false) {}
+
+ unsigned int fileTimeTolerance; //max. allowed file time deviation
+ bool traverseDirectorySymlinks;
+ bool copyFileSymlinks; //copy symbolic link instead of target file
+ bool verifyFileCopy; //verify copied files
+
+ bool operator==(const HiddenSettings& other) const
{
- return static_cast<SyncDirection>(syncCfg);
+ return fileTimeTolerance == other.fileTimeTolerance &&
+ traverseDirectorySymlinks == other.traverseDirectorySymlinks &&
+ copyFileSymlinks == other.copyFileSymlinks &&
+ verifyFileCopy == other.verifyFileCopy;
}
+};
- struct SyncConfiguration
- {
- SyncConfiguration() :
- exLeftSideOnly( SYNC_DIR_CFG_RIGHT),
- exRightSideOnly(SYNC_DIR_CFG_LEFT),
- leftNewer( SYNC_DIR_CFG_RIGHT),
- rightNewer( SYNC_DIR_CFG_LEFT),
- different( SYNC_DIR_CFG_NONE),
- conflict( SYNC_DIR_CFG_NONE) {}
-
- SyncDirectionCfg exLeftSideOnly;
- SyncDirectionCfg exRightSideOnly;
- SyncDirectionCfg leftNewer;
- SyncDirectionCfg rightNewer;
- SyncDirectionCfg different;
- SyncDirectionCfg conflict;
-
- bool operator==(const SyncConfiguration& other) const
- {
- return exLeftSideOnly == other.exLeftSideOnly &&
- exRightSideOnly == other.exRightSideOnly &&
- leftNewer == other.leftNewer &&
- rightNewer == other.rightNewer &&
- different == other.different &&
- conflict == other.conflict;
- }
-
- //get/set default configuration variants
- enum Variant
- {
- MIRROR,
- UPDATE,
- TWOWAY,
- CUSTOM
- };
- Variant getVariant() const;
- void setVariant(const Variant var);
- };
+bool recycleBinExistsWrap();
- enum DeletionPolicy
- {
- DELETE_PERMANENTLY = 5,
- MOVE_TO_RECYCLE_BIN,
- MOVE_TO_CUSTOM_DIRECTORY
- };
+struct AlternateSyncConfig
+{
+ AlternateSyncConfig(const SyncConfiguration& syncCfg,
+ const DeletionPolicy handleDel,
+ const wxString& customDelDir) :
+ syncConfiguration(syncCfg),
+ handleDeletion(handleDel),
+ customDeletionDirectory(customDelDir) {};
+ AlternateSyncConfig() : //construct with default values
+ handleDeletion(FreeFileSync::recycleBinExistsWrap() ? MOVE_TO_RECYCLE_BIN : DELETE_PERMANENTLY) {} //enable if OS supports it; else user will have to activate first and then get an error message
- struct HiddenSettings
+ //Synchronisation settings
+ SyncConfiguration syncConfiguration;
+
+ //misc options
+ DeletionPolicy handleDeletion; //use Recycle, delete permanently or move to user-defined location
+ wxString customDeletionDirectory;
+
+ bool operator==(const AlternateSyncConfig& other) const
{
- HiddenSettings() :
- fileTimeTolerance(2), //default 2s: FAT vs NTFS
- traverseDirectorySymlinks(false),
- copyFileSymlinks(true),
- verifyFileCopy(false) {}
-
- unsigned int fileTimeTolerance; //max. allowed file time deviation
- bool traverseDirectorySymlinks;
- bool copyFileSymlinks; //copy symbolic link instead of target file
- bool verifyFileCopy; //verify copied files
-
- bool operator==(const HiddenSettings& other) const
- {
- return fileTimeTolerance == other.fileTimeTolerance &&
- traverseDirectorySymlinks == other.traverseDirectorySymlinks &&
- copyFileSymlinks == other.copyFileSymlinks &&
- verifyFileCopy == other.verifyFileCopy;
- }
- };
+ return syncConfiguration == other.syncConfiguration &&
+ handleDeletion == other.handleDeletion &&
+ customDeletionDirectory == other.customDeletionDirectory;
+ }
+};
+//standard filter settings, OS dependent
+Zstring defaultIncludeFilter();
+Zstring defaultExcludeFilter();
- bool recycleBinExistsWrap();
+struct AlternateFilter
+{
+ AlternateFilter(const Zstring& include, const Zstring& exclude) :
+ includeFilter(include),
+ excludeFilter(exclude) {}
- struct AlternateSyncConfig
- {
- AlternateSyncConfig(const SyncConfiguration& syncCfg,
- const DeletionPolicy handleDel,
- const wxString& customDelDir) :
- syncConfiguration(syncCfg),
- handleDeletion(handleDel),
- customDeletionDirectory(customDelDir) {};
-
- AlternateSyncConfig() : //construct with default values
- handleDeletion(FreeFileSync::recycleBinExistsWrap() ? MOVE_TO_RECYCLE_BIN : DELETE_PERMANENTLY) {} //enable if OS supports it; else user will have to activate first and then get an error message
-
- //Synchronisation settings
- SyncConfiguration syncConfiguration;
-
- //misc options
- DeletionPolicy handleDeletion; //use Recycle, delete permanently or move to user-defined location
- wxString customDeletionDirectory;
-
- bool operator==(const AlternateSyncConfig& other) const
- {
- return syncConfiguration == other.syncConfiguration &&
- handleDeletion == other.handleDeletion &&
- customDeletionDirectory == other.customDeletionDirectory;
- }
- };
+ AlternateFilter() : //construct with default values
+ includeFilter(defaultIncludeFilter()),
+ excludeFilter(defaultExcludeFilter()) {}
+ Zstring includeFilter;
+ Zstring excludeFilter;
- struct AlternateFilter
+ bool operator==(const AlternateFilter& other) const
{
- AlternateFilter(const wxString& include, const wxString& exclude) :
- includeFilter(include),
- excludeFilter(exclude) {}
-
- AlternateFilter() : //construct with default values
- includeFilter(wxT("*")), //include all files/folders
- excludeFilter(wxEmptyString) {} //exclude nothing
-
- wxString includeFilter;
- wxString excludeFilter;
-
- bool operator==(const AlternateFilter& other) const
- {
- return includeFilter == other.includeFilter &&
- excludeFilter == other.excludeFilter;
- }
- };
+ return includeFilter == other.includeFilter &&
+ excludeFilter == other.excludeFilter;
+ }
+};
- struct FolderPair
- {
- FolderPair(const Zstring& leftDir, const Zstring& rightDir) :
- leftDirectory(leftDir),
- rightDirectory(rightDir) {}
-
- Zstring leftDirectory;
- Zstring rightDirectory;
-
- bool operator==(const FolderPair& other) const
- {
- return leftDirectory == other.leftDirectory &&
- rightDirectory == other.rightDirectory;
- }
- };
+struct FolderPair
+{
+ FolderPair(const Zstring& leftDir, const Zstring& rightDir) :
+ leftDirectory(leftDir),
+ rightDirectory(rightDir) {}
+ Zstring leftDirectory;
+ Zstring rightDirectory;
- struct FolderPairEnh //enhanced folder pairs with (optional) alternate configuration
+ bool operator==(const FolderPair& other) const
{
- FolderPairEnh() {}
-
- FolderPairEnh(const Zstring& leftDir,
- const Zstring& rightDir,
- const boost::shared_ptr<const AlternateSyncConfig>& syncConfig,
- const boost::shared_ptr<const AlternateFilter>& filter) :
- leftDirectory(leftDir),
- rightDirectory(rightDir) ,
- altSyncConfig(syncConfig),
- altFilter(filter) {}
-
- Zstring leftDirectory;
- Zstring rightDirectory;
-
- boost::shared_ptr<const AlternateSyncConfig> altSyncConfig; //optional
- boost::shared_ptr<const AlternateFilter> altFilter; //optional
-
- bool operator==(const FolderPairEnh& other) const
- {
- return leftDirectory == other.leftDirectory &&
- rightDirectory == other.rightDirectory &&
-
- (altSyncConfig.get() && other.altSyncConfig.get() ?
- *altSyncConfig == *other.altSyncConfig :
- altSyncConfig.get() == other.altSyncConfig.get()) &&
-
- (altFilter.get() && other.altFilter.get() ?
- *altFilter == *other.altFilter :
- altFilter.get() == other.altFilter.get());
- }
- };
+ return leftDirectory == other.leftDirectory &&
+ rightDirectory == other.rightDirectory;
+ }
+};
- struct MainConfiguration
- {
- MainConfiguration() :
- mainFolderPair(Zstring(), Zstring()),
- compareVar(CMP_BY_TIME_SIZE),
- filterIsActive(false), //do not filter by default
- includeFilter(wxT("*")), //include all files/folders
- excludeFilter(wxEmptyString), //exclude nothing
- handleDeletion(FreeFileSync::recycleBinExistsWrap() ? MOVE_TO_RECYCLE_BIN : DELETE_PERMANENTLY) {} //enable if OS supports it; else user will have to activate first and then get an error message
-
- FolderPair mainFolderPair;
- std::vector<FolderPairEnh> additionalPairs;
-
- //Compare setting
- CompareVariant compareVar;
-
- //Synchronisation settings
- SyncConfiguration syncConfiguration;
-
- //Filter setting
- bool filterIsActive;
- wxString includeFilter;
- wxString excludeFilter;
-
- //misc options
- HiddenSettings hidden; //settings not visible on GUI
-
- DeletionPolicy handleDeletion; //use Recycle, delete permanently or move to user-defined location
- wxString customDeletionDirectory;
-
- wxString getSyncVariantName();
-
- bool operator==(const MainConfiguration& other) const
- {
- return mainFolderPair == other.mainFolderPair &&
- additionalPairs == other.additionalPairs &&
- compareVar == other.compareVar &&
- syncConfiguration == other.syncConfiguration &&
- filterIsActive == other.filterIsActive &&
- includeFilter == other.includeFilter &&
- excludeFilter == other.excludeFilter &&
- hidden == other.hidden &&
- handleDeletion == other.handleDeletion &&
- customDeletionDirectory == other.customDeletionDirectory;
- }
- };
+struct FolderPairEnh //enhanced folder pairs with (optional) alternate configuration
+{
+ FolderPairEnh() {}
+ FolderPairEnh(const Zstring& leftDir,
+ const Zstring& rightDir,
+ const boost::shared_ptr<const AlternateSyncConfig>& syncConfig,
+ const boost::shared_ptr<const AlternateFilter>& filter) :
+ leftDirectory(leftDir),
+ rightDirectory(rightDir) ,
+ altSyncConfig(syncConfig),
+ altFilter(filter) {}
- enum CompareFilesResult
- {
- FILE_LEFT_SIDE_ONLY = 0,
- FILE_RIGHT_SIDE_ONLY,
- FILE_LEFT_NEWER,
- FILE_RIGHT_NEWER,
- FILE_DIFFERENT,
- FILE_EQUAL,
- FILE_CONFLICT
- };
- //attention make sure these /|\ \|/ two enums match!!!
- enum CompareDirResult
- {
- DIR_LEFT_SIDE_ONLY = FILE_LEFT_SIDE_ONLY,
- DIR_RIGHT_SIDE_ONLY = FILE_RIGHT_SIDE_ONLY,
- DIR_EQUAL = FILE_EQUAL
- };
+ Zstring leftDirectory;
+ Zstring rightDirectory;
+ boost::shared_ptr<const AlternateSyncConfig> altSyncConfig; //optional
+ boost::shared_ptr<const AlternateFilter> altFilter; //optional
- inline
- CompareFilesResult convertToFilesResult(CompareDirResult value)
+ bool operator==(const FolderPairEnh& other) const
{
- return static_cast<CompareFilesResult>(value);
+ return leftDirectory == other.leftDirectory &&
+ rightDirectory == other.rightDirectory &&
+
+ (altSyncConfig.get() && other.altSyncConfig.get() ?
+ *altSyncConfig == *other.altSyncConfig :
+ altSyncConfig.get() == other.altSyncConfig.get()) &&
+
+ (altFilter.get() && other.altFilter.get() ?
+ *altFilter == *other.altFilter :
+ altFilter.get() == other.altFilter.get());
}
+};
+
+
+struct MainConfiguration
+{
+ MainConfiguration() :
+ mainFolderPair(Zstring(), Zstring()),
+ compareVar(CMP_BY_TIME_SIZE),
+#ifdef FFS_WIN
+ filterIsActive(true),
+#elif defined FFS_LINUX
+ filterIsActive(false),
+#endif
+ includeFilter(defaultIncludeFilter()),
+ excludeFilter(defaultExcludeFilter()),
+ handleDeletion(FreeFileSync::recycleBinExistsWrap() ? MOVE_TO_RECYCLE_BIN : DELETE_PERMANENTLY) {} //enable if OS supports it; else user will have to activate first and then get an error message
+
+ FolderPair mainFolderPair;
+ std::vector<FolderPairEnh> additionalPairs;
+ //Compare setting
+ CompareVariant compareVar;
+ //Synchronisation settings
+ SyncConfiguration syncConfiguration;
- wxString getDescription(CompareFilesResult cmpRes);
- wxString getSymbol(CompareFilesResult cmpRes);
+ //Filter setting
+ bool filterIsActive;
+ Zstring includeFilter;
+ Zstring excludeFilter;
+ //misc options
+ HiddenSettings hidden; //settings not visible on GUI
- enum SyncOperation
+ DeletionPolicy handleDeletion; //use Recycle, delete permanently or move to user-defined location
+ wxString customDeletionDirectory;
+
+ wxString getSyncVariantName();
+
+ bool operator==(const MainConfiguration& other) const
{
- SO_CREATE_NEW_LEFT,
- SO_CREATE_NEW_RIGHT,
- SO_DELETE_LEFT,
- SO_DELETE_RIGHT,
- SO_OVERWRITE_LEFT,
- SO_OVERWRITE_RIGHT,
- SO_DO_NOTHING,
- SO_UNRESOLVED_CONFLICT
- };
+ return mainFolderPair == other.mainFolderPair &&
+ additionalPairs == other.additionalPairs &&
+ compareVar == other.compareVar &&
+ syncConfiguration == other.syncConfiguration &&
+ filterIsActive == other.filterIsActive &&
+ includeFilter == other.includeFilter &&
+ excludeFilter == other.excludeFilter &&
+ hidden == other.hidden &&
+ handleDeletion == other.handleDeletion &&
+ customDeletionDirectory == other.customDeletionDirectory;
+ }
+};
- wxString getDescription(SyncOperation op);
- wxString getSymbol(SyncOperation op);
+enum CompareFilesResult
+{
+ FILE_LEFT_SIDE_ONLY = 0,
+ FILE_RIGHT_SIDE_ONLY,
+ FILE_LEFT_NEWER,
+ FILE_RIGHT_NEWER,
+ FILE_DIFFERENT,
+ FILE_EQUAL,
+ FILE_CONFLICT
+};
+//attention make sure these /|\ \|/ two enums match!!!
+enum CompareDirResult
+{
+ DIR_LEFT_SIDE_ONLY = FILE_LEFT_SIDE_ONLY,
+ DIR_RIGHT_SIDE_ONLY = FILE_RIGHT_SIDE_ONLY,
+ DIR_EQUAL = FILE_EQUAL
+};
- //Exception class used to abort the "compare" and "sync" process
- class AbortThisProcess {};
+
+inline
+CompareFilesResult convertToFilesResult(CompareDirResult value)
+{
+ return static_cast<CompareFilesResult>(value);
+}
+
+
+
+wxString getDescription(CompareFilesResult cmpRes);
+wxString getSymbol(CompareFilesResult cmpRes);
+
+
+enum SyncOperation
+{
+ SO_CREATE_NEW_LEFT,
+ SO_CREATE_NEW_RIGHT,
+ SO_DELETE_LEFT,
+ SO_DELETE_RIGHT,
+ SO_OVERWRITE_LEFT,
+ SO_OVERWRITE_RIGHT,
+ SO_DO_NOTHING,
+ SO_UNRESOLVED_CONFLICT
+};
+
+wxString getDescription(SyncOperation op);
+wxString getSymbol(SyncOperation op);
+
+
+//Exception class used to abort the "compare" and "sync" process
+class AbortThisProcess {};
}
#endif // FREEFILESYNC_H_INCLUDED
bgstack15