summaryrefslogtreecommitdiff
path: root/structures.h
diff options
context:
space:
mode:
Diffstat (limited to 'structures.h')
-rw-r--r--structures.h242
1 files changed, 165 insertions, 77 deletions
diff --git a/structures.h b/structures.h
index 6146865e..c492ed85 100644
--- a/structures.h
+++ b/structures.h
@@ -13,9 +13,11 @@
#include "shared/system_constants.h"
#include "shared/assert_static.h"
#include <boost/shared_ptr.hpp>
+#include "shared/int64.h"
-namespace ffs3
+
+namespace zen
{
enum CompareVariant
{
@@ -108,10 +110,9 @@ wxString getSymbol(SyncOperation op);
class AbortThisProcess {};
-struct SyncConfiguration //technical representation of sync-config: not to be edited by GUI directly!
+struct DirectionSet
{
- SyncConfiguration() :
- automatic(true),
+ DirectionSet() :
exLeftSideOnly( SYNC_DIR_RIGHT),
exRightSideOnly(SYNC_DIR_LEFT),
leftNewer( SYNC_DIR_RIGHT),
@@ -119,27 +120,6 @@ struct SyncConfiguration //technical representation of sync-config: not to be ed
different( SYNC_DIR_NONE),
conflict( SYNC_DIR_NONE) {}
- enum Variant
- {
- AUTOMATIC,
- MIRROR,
- UPDATE,
- CUSTOM
- };
-
- bool operator==(const SyncConfiguration& other) const
- {
- return automatic == other.automatic &&
- (automatic || //if automatic is on, other settings are not relevant
- (exLeftSideOnly == other.exLeftSideOnly &&
- exRightSideOnly == other.exRightSideOnly &&
- leftNewer == other.leftNewer &&
- rightNewer == other.rightNewer &&
- different == other.different &&
- conflict == other.conflict));
- }
-
- bool automatic; //use sync-database
SyncDirection exLeftSideOnly;
SyncDirection exRightSideOnly;
SyncDirection leftNewer;
@@ -148,11 +128,49 @@ struct SyncConfiguration //technical representation of sync-config: not to be ed
SyncDirection conflict;
};
+DirectionSet getTwoWaySet();
+
+inline
+bool operator==(const DirectionSet& lhs, const DirectionSet& rhs)
+{
+ return lhs.exLeftSideOnly == rhs.exLeftSideOnly &&
+ lhs.exRightSideOnly == rhs.exRightSideOnly &&
+ lhs.leftNewer == rhs.leftNewer &&
+ lhs.rightNewer == rhs.rightNewer &&
+ lhs.different == rhs.different &&
+ lhs.conflict == rhs.conflict;
+}
+
+struct SyncConfig //technical representation of sync-config
+{
+ enum Variant
+ {
+ AUTOMATIC, //use sync-database to determine directions
+ MIRROR, //predefined
+ UPDATE, //
+ CUSTOM //use custom directions
+ };
+
+ SyncConfig() : var(AUTOMATIC) {}
+
+ Variant var;
+
+ //custom sync directions
+ DirectionSet custom;
+};
+
+inline
+bool operator==(const SyncConfig& lhs, const SyncConfig& rhs)
+{
+ return lhs.var == rhs.var &&
+ (lhs.var != SyncConfig::CUSTOM || lhs.custom == rhs.custom); //directions are only relevant if variant "custom" is active
+}
+
+//get sync directions: DON'T call for variant AUTOMATIC!
+DirectionSet extractDirections(const SyncConfig& cfg);
+
+wxString getVariantName(SyncConfig::Variant var);
-SyncConfiguration::Variant getVariant(const SyncConfiguration& syncCfg);
-void setVariant(SyncConfiguration& syncCfg, const SyncConfiguration::Variant var);
-wxString getVariantName(const SyncConfiguration& syncCfg);
-void setTwoWay(SyncConfiguration& syncCfg); //helper method used by <Automatic> mode fallback to overwrite old with newer files
enum DeletionPolicy
@@ -165,9 +183,9 @@ enum DeletionPolicy
struct AlternateSyncConfig
{
- AlternateSyncConfig(const SyncConfiguration& syncCfg,
- const DeletionPolicy handleDel,
- const wxString& customDelDir) :
+ AlternateSyncConfig(const SyncConfig& syncCfg,
+ const DeletionPolicy handleDel,
+ const wxString& customDelDir) :
syncConfiguration(syncCfg),
handleDeletion(handleDel),
customDeletionDirectory(customDelDir) {};
@@ -176,43 +194,102 @@ struct AlternateSyncConfig
handleDeletion(MOVE_TO_RECYCLE_BIN) {}
//Synchronisation settings
- SyncConfiguration syncConfiguration;
+ SyncConfig 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;
- }
};
-//standard exclude filter settings, OS dependent
-Zstring standardExcludeFilter();
+inline
+bool operator==(const AlternateSyncConfig& lhs, const AlternateSyncConfig& rhs)
+{
+ return lhs.syncConfiguration == rhs.syncConfiguration &&
+ lhs.handleDeletion == rhs.handleDeletion &&
+ lhs.customDeletionDirectory == rhs.customDeletionDirectory;
+}
-struct FilterConfig
+enum UnitSize
{
- FilterConfig(const Zstring& include, const Zstring& exclude) :
- includeFilter(include),
- excludeFilter(exclude) {}
+ USIZE_NONE,
+ USIZE_BYTE,
+ USIZE_KB,
+ USIZE_MB
+};
- FilterConfig() : //construct with default values
- includeFilter(Zstr("*")) {}
+enum UnitTime
+{
+ UTIME_NONE,
+ UTIME_SEC,
+ UTIME_MIN,
+ UTIME_HOUR,
+ UTIME_DAY
+};
+struct FilterConfig
+{
+ FilterConfig(const Zstring& include = Zstr("*"),
+ const Zstring& exclude = Zstring(),
+ size_t timeSpanIn = 0,
+ UnitTime unitTimeSpanIn = UTIME_NONE,
+ size_t sizeMinIn = 0,
+ UnitSize unitSizeMinIn = USIZE_NONE,
+ size_t sizeMaxIn = 0,
+ UnitSize unitSizeMaxIn = USIZE_NONE) :
+ includeFilter(include),
+ excludeFilter(exclude),
+ timeSpan (timeSpanIn),
+ unitTimeSpan (unitTimeSpanIn),
+ sizeMin (sizeMinIn),
+ unitSizeMin (unitSizeMinIn),
+ sizeMax (sizeMaxIn),
+ unitSizeMax (unitSizeMaxIn) {}
+
+ /*
+ Semantics of HardFilter:
+ 1. using it creates a NEW folder hierarchy! -> must be considered by <Automatic>-mode! (fortunately it turns out, doing nothing already has perfect semantics :)
+ 2. it applies equally to both sides => it always matches either both sides or none! => can be used while traversing a single folder!
+ */
Zstring includeFilter;
Zstring excludeFilter;
- bool operator==(const FilterConfig& other) const
- {
- return includeFilter == other.includeFilter &&
- excludeFilter == other.excludeFilter;
- }
+ /*
+ Semantics of SoftFilter:
+ 1. It potentially may match only one side => it MUST NOT be applied while traversing a single folder to avoid mismatches
+ 2. => it is applied after traversing and just marks rows, (NO deletions after comparison are allowed)
+ 3. => equivalent to a user temporarily (de-)selecting rows -> not relevant for <Automatic>-mode! ;)
+ */
+ size_t timeSpan;
+ UnitTime unitTimeSpan;
+
+ size_t sizeMin;
+ UnitSize unitSizeMin;
+
+ size_t sizeMax;
+ UnitSize unitSizeMax;
};
+inline
+bool operator==(const FilterConfig& lhs, const FilterConfig& rhs)
+{
+ return lhs.includeFilter == rhs.includeFilter &&
+ lhs.excludeFilter == rhs.excludeFilter &&
+ lhs.timeSpan == rhs.timeSpan &&
+ lhs.unitTimeSpan == rhs.unitTimeSpan &&
+ lhs.sizeMin == rhs.sizeMin &&
+ lhs.unitSizeMin == rhs.unitSizeMin &&
+ lhs.sizeMax == rhs.sizeMax &&
+ lhs.unitSizeMax == rhs.unitSizeMax;
+}
+
+void resolveUnits(size_t timeSpan, UnitTime unitTimeSpan,
+ size_t sizeMin, UnitSize unitSizeMin,
+ size_t sizeMax, UnitSize unitSizeMax,
+ zen::Int64& timeSpanSec, //unit: seconds
+ zen::UInt64& sizeMinBy, //unit: bytes
+ zen::UInt64& sizeMaxBy); //unit: bytes
+
struct FolderPairEnh //enhanced folder pairs with (optional) alternate configuration
{
@@ -232,20 +309,21 @@ struct FolderPairEnh //enhanced folder pairs with (optional) alternate configura
boost::shared_ptr<const AlternateSyncConfig> altSyncConfig; //optional
FilterConfig localFilter;
+};
- 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()) &&
+inline
+bool operator==(const FolderPairEnh& lhs, const FolderPairEnh& rhs)
+{
+ return lhs.leftDirectory == rhs.leftDirectory &&
+ lhs.rightDirectory == rhs.rightDirectory &&
- localFilter == other.localFilter;
- }
-};
+ (lhs.altSyncConfig.get() && rhs.altSyncConfig.get() ?
+ *lhs.altSyncConfig == *rhs.altSyncConfig :
+ lhs.altSyncConfig.get() == rhs.altSyncConfig.get()) &&
+ lhs.localFilter == rhs.localFilter;
+}
enum SymLinkHandling
{
@@ -260,7 +338,15 @@ struct MainConfiguration
MainConfiguration() :
compareVar(CMP_BY_TIME_SIZE),
handleSymlinks(SYMLINK_IGNORE),
- globalFilter(Zstr("*"), standardExcludeFilter()),
+#ifdef FFS_WIN
+ globalFilter(Zstr("*"), Zstr("\
+\\System Volume Information\\\n\
+\\RECYCLER\\\n\
+\\RECYCLED\\\n\
+\\$Recycle.Bin\\")), //exclude Recycle Bin
+#elif defined FFS_LINUX
+ //exclude nothing
+#endif
handleDeletion(MOVE_TO_RECYCLE_BIN) {}
FolderPairEnh firstPair; //there needs to be at least one pair!
@@ -275,25 +361,27 @@ struct MainConfiguration
FilterConfig globalFilter;
//Synchronisation settings
- SyncConfiguration syncConfiguration;
+ SyncConfig syncConfiguration;
DeletionPolicy handleDeletion; //use Recycle, delete permanently or move to user-defined location
wxString customDeletionDirectory;
wxString getSyncVariantName();
-
- bool operator==(const MainConfiguration& other) const
- {
- return firstPair == other.firstPair &&
- additionalPairs == other.additionalPairs &&
- compareVar == other.compareVar &&
- handleSymlinks == other.handleSymlinks &&
- syncConfiguration == other.syncConfiguration &&
- globalFilter == other.globalFilter &&
- handleDeletion == other.handleDeletion &&
- customDeletionDirectory == other.customDeletionDirectory;
- }
};
+
+inline
+bool operator==(const MainConfiguration& lhs, const MainConfiguration& rhs)
+{
+ return lhs.firstPair == rhs.firstPair &&
+ lhs.additionalPairs == rhs.additionalPairs &&
+ lhs.compareVar == rhs.compareVar &&
+ lhs.handleSymlinks == rhs.handleSymlinks &&
+ lhs.syncConfiguration == rhs.syncConfiguration &&
+ lhs.globalFilter == rhs.globalFilter &&
+ lhs.handleDeletion == rhs.handleDeletion &&
+ lhs.customDeletionDirectory == rhs.customDeletionDirectory;
+}
+
//facilitate drag & drop config merge:
MainConfiguration merge(const std::vector<MainConfiguration>& mainCfgs);
}
bgstack15