summaryrefslogtreecommitdiff
path: root/structures.cpp
blob: 57bea755b964a531b7e3eeabe261807e8a7aed9d (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#include "structures.h"
#include "shared/fileHandling.h"
#include <wx/intl.h>
#include "shared/systemConstants.h"

using FreeFileSync::SyncConfiguration;
using FreeFileSync::MainConfiguration;


bool FreeFileSync::recycleBinExistsWrap()
{
    return recycleBinExists();
}


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;
}


SyncConfiguration::Variant SyncConfiguration::getVariant() const
{
    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 &&
            conflict        == SYNC_DIR_CFG_NONE)
        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  &&
             conflict        == 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  &&
             conflict        == SYNC_DIR_CFG_NONE)
        return TWOWAY;    //two way <->
    else
        return CUSTOM;    //other
}


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;
        conflict        = SYNC_DIR_CFG_NONE;
        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;
        conflict        = 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;
        conflict        = SYNC_DIR_CFG_NONE;
        break;
    case CUSTOM:
        assert(false);
        break;
    }
}

wxString MainConfiguration::getSyncVariantName()
{
    const SyncConfiguration::Variant mainVariant = syncConfiguration.getVariant();

    //test if there's a deviating variant within the additional folder pairs
    for (std::vector<FolderPairEnh>::const_iterator i = additionalPairs.begin(); i != additionalPairs.end(); ++i)
        if (i->altSyncConfig.get() && i->altSyncConfig->syncConfiguration.getVariant() != mainVariant)
            return _("Multiple...");

    //seems to be all in sync...
    switch (mainVariant)
    {
    case SyncConfiguration::MIRROR:
        return _("Mirror ->>");
    case SyncConfiguration::UPDATE:
        return _("Update ->");
    case SyncConfiguration::TWOWAY:
        return _("Two way <->");
    case SyncConfiguration::CUSTOM:
        return _("Custom");
    }

    return _("Error");
}


wxString FreeFileSync::getDescription(CompareFilesResult cmpRes)
{
    switch (cmpRes)
    {
    case FILE_LEFT_SIDE_ONLY:
        return _("Files/folders that exist on left side only");
    case FILE_RIGHT_SIDE_ONLY:
        return _("Files/folders that exist on right side only");
    case FILE_LEFT_NEWER:
        return _("Files that exist on both sides, left one is newer");
    case FILE_RIGHT_NEWER:
        return _("Files that exist on both sides, right one is newer");
    case FILE_DIFFERENT:
        return _("Files that exist on both sides and have different content");
    case FILE_EQUAL:
        return _("Files that are equal on both sides");
    case FILE_CONFLICT:
        return _("Conflicts/files that cannot be categorized");
    }

    assert(false);
    return wxEmptyString;
}


wxString FreeFileSync::getSymbol(CompareFilesResult cmpRes)
{
    switch (cmpRes)
    {
    case FILE_LEFT_SIDE_ONLY:
        return wxT("<|");
    case FILE_RIGHT_SIDE_ONLY:
        return wxT("|>");
    case FILE_LEFT_NEWER:
        return wxT("<<");
    case FILE_RIGHT_NEWER:
        return wxT(">>");
    case FILE_DIFFERENT:
        return wxT("!=");
    case FILE_EQUAL:
        return wxT("'=="); //added quotation mark to avoid error in Excel cell when exporting to *.cvs
    case FILE_CONFLICT:
        return wxT("\\/\\->");
    }

    assert(false);
    return wxEmptyString;
}


wxString FreeFileSync::getDescription(SyncOperation op)
{
    switch (op)
    {
    case SO_CREATE_NEW_LEFT:
        return _("Copy from right to left");
    case SO_CREATE_NEW_RIGHT:
        return _("Copy from left to right");
    case SO_DELETE_LEFT:
        return _("Delete files/folders existing on left side only");
    case SO_DELETE_RIGHT:
        return _("Delete files/folders existing on right side only");
    case SO_OVERWRITE_LEFT:
        return _("Copy from right to left overwriting");
    case SO_OVERWRITE_RIGHT:
        return _("Copy from left to right overwriting");
    case SO_DO_NOTHING:
        return _("Do nothing");
    case SO_UNRESOLVED_CONFLICT:
        return _("Conflicts/files that cannot be categorized");
    };

    assert(false);
    return wxEmptyString;
}


wxString FreeFileSync::getSymbol(SyncOperation op)
{
    switch (op)
    {
    case SO_CREATE_NEW_LEFT:
        return wxT("*-");
    case SO_CREATE_NEW_RIGHT:
        return wxT("-*");
    case SO_DELETE_LEFT:
        return wxT("D-");
    case SO_DELETE_RIGHT:
        return wxT("-D");
    case SO_OVERWRITE_LEFT:
        return wxT("<-");
    case SO_OVERWRITE_RIGHT:
        return wxT("->");
    case SO_DO_NOTHING:
        return wxT("-");
    case SO_UNRESOLVED_CONFLICT:
        return wxT("\\/\\->");
    };

    assert(false);
    return wxEmptyString;
}

bgstack15