summaryrefslogtreecommitdiff
path: root/structures.cpp
blob: 90dd07477feb3ceb7c88bb4b40ac93105dd74f50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "structures.h"
#include "shared/fileHandling.h"
#include <wx/intl.h>
#include "shared/globalFunctions.h"


FreeFileSync::MainConfiguration::MainConfiguration() :
        compareVar(CMP_BY_TIME_SIZE),
        filterIsActive(false),        //do not filter by default
        includeFilter(wxT("*")),      //include all files/folders
        excludeFilter(wxEmptyString), //exclude nothing
        handleDeletion(FreeFileSync::recycleBinExists() ? MOVE_TO_RECYCLE_BIN : DELETE_PERMANENTLY) {} //enable if OS supports it; else user will have to activate first and then get an error message


wxString FreeFileSync::getVariantName(CompareVariant var)
{
    switch (var)
    {
    case CMP_BY_CONTENT:
        return _("File content");
    case CMP_BY_TIME_SIZE:
        return _("File size and date");
    }

    assert(false);
    return wxEmptyString;
}


using FreeFileSync::SyncConfiguration;


SyncConfiguration::Variant SyncConfiguration::getVariant()
{
    if (    exLeftSideOnly  == SYNC_DIR_CFG_RIGHT &&
            exRightSideOnly == SYNC_DIR_CFG_RIGHT &&
            leftNewer       == SYNC_DIR_CFG_RIGHT &&
            rightNewer      == SYNC_DIR_CFG_RIGHT &&
            different       == SYNC_DIR_CFG_RIGHT)
        return MIRROR;    //one way ->

    else if (exLeftSideOnly  == SYNC_DIR_CFG_RIGHT &&
             exRightSideOnly == SYNC_DIR_CFG_NONE  &&
             leftNewer       == SYNC_DIR_CFG_RIGHT &&
             rightNewer      == SYNC_DIR_CFG_NONE  &&
             different       == SYNC_DIR_CFG_NONE)
        return UPDATE;    //Update ->

    else if (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)
        return TWOWAY;    //two way <->
    else
        return CUSTOM;    //other
}


wxString SyncConfiguration::getVariantName()
{
    switch (getVariant())
    {
    case MIRROR:
        return _("Mirror ->>");
    case UPDATE:
        return _("Update ->");
    case TWOWAY:
        return _("Two way <->");
    case CUSTOM:
        return _("Custom");
    }

    return _("Error");
}


void SyncConfiguration::setVariant(const Variant var)
{
    switch (var)
    {
    case MIRROR:
        exLeftSideOnly  = SYNC_DIR_CFG_RIGHT;
        exRightSideOnly = SYNC_DIR_CFG_RIGHT;
        leftNewer       = SYNC_DIR_CFG_RIGHT;
        rightNewer      = SYNC_DIR_CFG_RIGHT;
        different       = SYNC_DIR_CFG_RIGHT;
        break;
    case UPDATE:
        exLeftSideOnly  = SYNC_DIR_CFG_RIGHT;
        exRightSideOnly = SYNC_DIR_CFG_NONE;
        leftNewer       = SYNC_DIR_CFG_RIGHT;
        rightNewer      = SYNC_DIR_CFG_NONE;
        different       = SYNC_DIR_CFG_NONE;
        break;
    case TWOWAY:
        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;
        break;
    case CUSTOM:
        assert(false);
        break;
    }
}
bgstack15