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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
|
// **************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
// **************************************************************************
//
#include "process_xml.h"
#include "../shared/xml_base.h"
#include <wx/intl.h>
#include <wx/filefn.h>
#include "../shared/global_func.h"
#include "../shared/standard_paths.h"
#include "../shared/string_conv.h"
using namespace ffs3;
using namespace xmlAccess; //functionally needed!!!
class FfsXmlParser : public xmlAccess::XmlParser
{
public:
FfsXmlParser(const TiXmlElement* rootElement) : xmlAccess::XmlParser(rootElement) {}
//read gui settings, all values retrieved are optional, so check for initial values! (== -1)
void readXmlGuiConfig(xmlAccess::XmlGuiConfig& outputCfg);
//read batch settings, all values retrieved are optional
void readXmlBatchConfig(xmlAccess::XmlBatchConfig& outputCfg);
//read global settings, valid for both GUI and batch mode, independent from configuration
void readXmlGlobalSettings(xmlAccess::XmlGlobalSettings& outputCfg);
private:
//read alternate configuration (optional) => might point to NULL
void readXmlLocalConfig(const TiXmlElement& folderPair, FolderPairEnh& enhPair);
//read basic FreefileSync settings (used by commandline and GUI), return true if ALL values have been retrieved successfully
void readXmlMainConfig(MainConfiguration& mainCfg);
};
//write gui settings
bool writeXmlGuiConfig(const xmlAccess::XmlGuiConfig& outputCfg, TiXmlDocument& doc);
//write batch settings
bool writeXmlBatchConfig(const xmlAccess::XmlBatchConfig& outputCfg, TiXmlDocument& doc);
//write global settings
bool writeXmlGlobalSettings(const xmlAccess::XmlGlobalSettings& outputCfg, TiXmlDocument& doc);
//write alternate configuration (optional) => might point to NULL
void writeXmlLocalConfig(const FolderPairEnh& enhPair, TiXmlElement& parent);
//write basic FreefileSync settings (used by commandline and GUI), return true if everything was written successfully
bool writeXmlMainConfig(const MainConfiguration& mainCfg, TiXmlDocument& doc);
void xmlAccess::readConfig(const wxString& filename, xmlAccess::XmlGuiConfig& config)
{
//load XML
if (!wxFileExists(filename))
throw XmlError(wxString(_("File does not exist:")) + wxT("\n\"") + filename + wxT("\""));
TiXmlDocument doc;
loadXmlDocument(filename, XML_GUI_CONFIG, doc); //throw (XmlError)
FfsXmlParser parser(doc.RootElement());
parser.readXmlGuiConfig(config); //read GUI layout configuration
if (parser.errorsOccurred())
throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"\n\n") +
parser.getErrorMessageFormatted(), XmlError::WARNING);
}
void xmlAccess::readConfig(const wxString& filename, xmlAccess::XmlBatchConfig& config)
{
//load XML
if (!wxFileExists(filename))
throw XmlError(wxString(_("File does not exist:")) + wxT("\n\"") + filename + wxT("\""));
TiXmlDocument doc;
loadXmlDocument(filename, XML_BATCH_CONFIG, doc); //throw (XmlError)
FfsXmlParser parser(doc.RootElement());
parser.readXmlBatchConfig(config); //read GUI layout configuration
if (parser.errorsOccurred())
throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"\n\n") +
parser.getErrorMessageFormatted(), XmlError::WARNING);
}
void xmlAccess::readConfig(xmlAccess::XmlGlobalSettings& config)
{
//load XML
if (!wxFileExists(getGlobalConfigFile()))
throw XmlError(wxString(_("File does not exist:")) + wxT("\n\"") + getGlobalConfigFile() + wxT("\""));
TiXmlDocument doc;
loadXmlDocument(getGlobalConfigFile(), XML_GLOBAL_SETTINGS, doc); //throw (XmlError)
FfsXmlParser parser(doc.RootElement());
parser.readXmlGlobalSettings(config); //read GUI layout configuration
if (parser.errorsOccurred())
throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + getGlobalConfigFile() + wxT("\"\n\n") +
parser.getErrorMessageFormatted(), XmlError::WARNING);
}
void xmlAccess::writeConfig(const XmlGuiConfig& outputCfg, const wxString& filename)
{
TiXmlDocument doc;
getDefaultXmlDocument(XML_GUI_CONFIG, doc);
//populate and write XML tree
if (!writeXmlGuiConfig(outputCfg, doc)) //add GUI layout configuration settings
throw XmlError(wxString(_("Error writing file:")) + wxT("\n\"") + filename + wxT("\""));
saveXmlDocument(filename, doc); //throw (XmlError)
}
void xmlAccess::writeConfig(const XmlBatchConfig& outputCfg, const wxString& filename)
{
TiXmlDocument doc;
getDefaultXmlDocument(XML_BATCH_CONFIG, doc);
//populate and write XML tree
if (!writeXmlBatchConfig(outputCfg, doc)) //add batch configuration settings
throw XmlError(wxString(_("Error writing file:")) + wxT("\n\"") + filename + wxT("\""));
saveXmlDocument(filename, doc); //throw (XmlError)
}
void xmlAccess::writeConfig(const XmlGlobalSettings& outputCfg)
{
TiXmlDocument doc;
getDefaultXmlDocument(XML_GLOBAL_SETTINGS, doc);
//populate and write XML tree
if (!writeXmlGlobalSettings(outputCfg, doc)) //add GUI layout configuration settings
throw XmlError(wxString(_("Error writing file:")) + wxT("\n\"") + getGlobalConfigFile() + wxT("\""));
saveXmlDocument(getGlobalConfigFile(), doc); //throw (XmlError)
}
bool readXmlElement(const std::string& name, const TiXmlElement* parent, CompareVariant& output)
{
std::string dummy;
if (xmlAccess::readXmlElement(name, parent, dummy))
{
if (dummy == "ByTimeAndSize")
output = ffs3::CMP_BY_TIME_SIZE;
else if (dummy == "ByContent")
output = ffs3::CMP_BY_CONTENT;
else
return false;
return true;
}
else
return false;
}
bool readXmlElement(const std::string& name, const TiXmlElement* parent, SyncDirection& output)
{
std::string dummy;
if (xmlAccess::readXmlElement(name, parent, dummy))
{
if (dummy == "left")
output = SYNC_DIR_LEFT;
else if (dummy == "right")
output = SYNC_DIR_RIGHT;
else //treat all other input as "none"
output = SYNC_DIR_NONE;
return true;
}
else
return false;
}
bool readXmlElement(const std::string& name, const TiXmlElement* parent, xmlAccess::OnError& output)
{
std::string dummy;
if (xmlAccess::readXmlElement(name, parent, dummy))
{
if (dummy == "Ignore")
output = xmlAccess::ON_ERROR_IGNORE;
else if (dummy == "Exit")
output = xmlAccess::ON_ERROR_EXIT;
else //treat all other input as popup
output = xmlAccess::ON_ERROR_POPUP;
return true;
}
else
return false;
}
bool readXmlElement(const std::string& name, const TiXmlElement* parent , ffs3::DeletionPolicy& output)
{
std::string dummy;
if (xmlAccess::readXmlElement(name, parent, dummy))
{
if (dummy == "DeletePermanently")
output = ffs3::DELETE_PERMANENTLY;
else if (dummy == "MoveToRecycleBin")
output = ffs3::MOVE_TO_RECYCLE_BIN;
else if (dummy == "MoveToCustomDirectory")
output = ffs3::MOVE_TO_CUSTOM_DIRECTORY;
else
return false;
return true;
}
return false;
}
bool readXmlElement(const std::string& name, const TiXmlElement* parent , ffs3::SymLinkHandling& output)
{
std::string dummy;
if (xmlAccess::readXmlElement(name, parent, dummy))
{
if (dummy == "Ignore")
output = ffs3::SYMLINK_IGNORE;
else if (dummy == "UseDirectly")
output = ffs3::SYMLINK_USE_DIRECTLY;
else if (dummy == "FollowLink")
output = ffs3::SYMLINK_FOLLOW_LINK;
else
return false;
return true;
}
return false;
}
bool readXmlElement(const std::string& name, const TiXmlElement* parent, Zstring& output)
{
wxString dummy;
if (!xmlAccess::readXmlElement(name, parent, dummy))
return false;
output = wxToZ(dummy);
return true;
}
bool readXmlAttribute(const std::string& name, const TiXmlElement* node, xmlAccess::ColumnTypes& output)
{
int dummy = 0;
if (xmlAccess::readXmlAttribute(name, node, dummy))
{
output = static_cast<xmlAccess::ColumnTypes>(dummy);
return true;
}
else
return false;
}
//################################################################################################################
void FfsXmlParser::readXmlLocalConfig(const TiXmlElement& folderPair, FolderPairEnh& enhPair)
{
//read folder pairs
readXmlElementLogging("Left", &folderPair, enhPair.leftDirectory);
readXmlElementLogging("Right", &folderPair, enhPair.rightDirectory);
//###########################################################
//alternate sync configuration
const TiXmlElement* altSyncConfig = TiXmlHandleConst(&folderPair).FirstChild("AlternateSyncConfig").ToElement();
if (altSyncConfig)
{
AlternateSyncConfig* altSyncCfg = new AlternateSyncConfig;
enhPair.altSyncConfig.reset(altSyncCfg);
const TiXmlElement* syncCfg = TiXmlHandleConst(altSyncConfig).FirstChild("Synchronization").ToElement();
const TiXmlElement* syncDirections = TiXmlHandleConst(syncCfg).FirstChild("Directions").ToElement();
//read sync configuration
readXmlElementLogging("Automatic", syncCfg, altSyncCfg->syncConfiguration.automatic);
readXmlElementLogging("LeftOnly", syncDirections, altSyncCfg->syncConfiguration.exLeftSideOnly);
readXmlElementLogging("RightOnly", syncDirections, altSyncCfg->syncConfiguration.exRightSideOnly);
readXmlElementLogging("LeftNewer", syncDirections, altSyncCfg->syncConfiguration.leftNewer);
readXmlElementLogging("RightNewer", syncDirections, altSyncCfg->syncConfiguration.rightNewer);
readXmlElementLogging("Different", syncDirections, altSyncCfg->syncConfiguration.different);
readXmlElementLogging("Conflict", syncDirections, altSyncCfg->syncConfiguration.conflict);
const TiXmlElement* miscSettings = TiXmlHandleConst(&folderPair).FirstChild("AlternateSyncConfig").FirstChild("Miscellaneous").ToElement();
readXmlElementLogging("DeletionPolicy", miscSettings, altSyncCfg->handleDeletion);
readXmlElementLogging("CustomDeletionFolder", miscSettings, altSyncCfg->customDeletionDirectory);
}
//###########################################################
//alternate filter configuration
const TiXmlElement* filterCfg = TiXmlHandleConst(&folderPair).FirstChild("LocalFilter").ToElement();
if (filterCfg)
{
//read filter settings
readXmlElementLogging("Include", filterCfg, enhPair.localFilter.includeFilter);
readXmlElementLogging("Exclude", filterCfg, enhPair.localFilter.excludeFilter);
}
}
void FfsXmlParser::readXmlMainConfig(MainConfiguration& mainCfg)
{
TiXmlHandleConst hRoot(getRoot()); //custom const handle: TiXml API seems broken in this regard
//###########################################################
const TiXmlElement* cmpSettings = hRoot.FirstChild("MainConfig").FirstChild("Comparison").ToElement();
//read compare variant
readXmlElementLogging("Variant", cmpSettings, mainCfg.compareVar);
//include symbolic links at all?
readXmlElementLogging("HandleSymlinks", cmpSettings, mainCfg.handleSymlinks);
//###########################################################
const TiXmlElement* syncCfg = hRoot.FirstChild("MainConfig").FirstChild("Synchronization").ToElement();
const TiXmlElement* syncDirections = TiXmlHandleConst(syncCfg).FirstChild("Directions").ToElement();
//read sync configuration
readXmlElementLogging("Automatic", syncCfg, mainCfg.syncConfiguration.automatic);
readXmlElementLogging("LeftOnly", syncDirections, mainCfg.syncConfiguration.exLeftSideOnly);
readXmlElementLogging("RightOnly", syncDirections, mainCfg.syncConfiguration.exRightSideOnly);
readXmlElementLogging("LeftNewer", syncDirections, mainCfg.syncConfiguration.leftNewer);
readXmlElementLogging("RightNewer", syncDirections, mainCfg.syncConfiguration.rightNewer);
readXmlElementLogging("Different", syncDirections, mainCfg.syncConfiguration.different);
readXmlElementLogging("Conflict", syncDirections, mainCfg.syncConfiguration.conflict);
//###########################################################
const TiXmlElement* miscSettings = hRoot.FirstChild("MainConfig").FirstChild("Miscellaneous").ToElement();
//misc
readXmlElementLogging("DeletionPolicy", miscSettings, mainCfg.handleDeletion);
readXmlElementLogging("CustomDeletionFolder", miscSettings, mainCfg.customDeletionDirectory);
//###########################################################
const TiXmlElement* filter = TiXmlHandleConst(miscSettings).FirstChild("Filter").ToElement();
//read filter settings
Zstring includeFilter;
Zstring excludeFilter;
readXmlElementLogging("Include", filter, includeFilter);
readXmlElementLogging("Exclude", filter, excludeFilter);
mainCfg.globalFilter = FilterConfig(includeFilter, excludeFilter);
//###########################################################
const TiXmlElement* pairs = hRoot.FirstChild("MainConfig").FirstChild("FolderPairs").FirstChild("Pair").ToElement();
//read all folder pairs
mainCfg.additionalPairs.clear();
bool firstLoop = true;
while (pairs)
{
FolderPairEnh newPair;
readXmlLocalConfig(*pairs, newPair);
if (firstLoop) //read first folder pair
{
firstLoop = false;
mainCfg.firstPair = newPair;
}
else //read additional folder pairs
mainCfg.additionalPairs.push_back(newPair);
pairs = pairs->NextSiblingElement();
}
}
void FfsXmlParser::readXmlGuiConfig(xmlAccess::XmlGuiConfig& outputCfg)
{
//read main config
readXmlMainConfig(outputCfg.mainCfg);
//read GUI specific config data
const TiXmlElement* guiConfig = TiXmlHandleConst(getRoot()).FirstChild("GuiConfig").ToElement();
readXmlElementLogging("HideFiltered", guiConfig, outputCfg.hideFilteredElements);
xmlAccess::OnError errorHand = ON_ERROR_POPUP;
readXmlElementLogging("HandleError", guiConfig, errorHand);
outputCfg.ignoreErrors = errorHand == xmlAccess::ON_ERROR_IGNORE;
readXmlElementLogging("SyncPreviewActive", guiConfig, outputCfg.syncPreviewEnabled);
}
void FfsXmlParser::readXmlBatchConfig(xmlAccess::XmlBatchConfig& outputCfg)
{
//read main config
readXmlMainConfig(outputCfg.mainCfg);
//read batch specific config
const TiXmlElement* batchConfig = TiXmlHandleConst(getRoot()).FirstChild("BatchConfig").ToElement();
readXmlElementLogging("Silent", batchConfig, outputCfg.silent);
readXmlElementLogging("LogfileDirectory", batchConfig, outputCfg.logFileDirectory);
readXmlElementLogging("LogfileCountMax", batchConfig, outputCfg.logFileCountMax);
readXmlElementLogging("HandleError", batchConfig, outputCfg.handleError);
}
void FfsXmlParser::readXmlGlobalSettings(xmlAccess::XmlGlobalSettings& outputCfg)
{
//read global settings
const TiXmlElement* global = TiXmlHandleConst(getRoot()).FirstChild("Shared").ToElement();
//try to read program language setting
readXmlElementLogging("Language", global, outputCfg.programLanguage);
//copy locked files using VSS
readXmlElementLogging("CopyLockedFiles", global, outputCfg.copyLockedFiles);
//file permissions
readXmlElementLogging("CopyFilePermissions", global, outputCfg.copyFilePermissions);
//verify file copying
readXmlElementLogging("VerifyCopiedFiles", global, outputCfg.verifyFileCopy);
//max. allowed file time deviation
readXmlElementLogging("FileTimeTolerance", global, outputCfg.fileTimeTolerance);
const TiXmlElement* optionalDialogs = TiXmlHandleConst(getRoot()).FirstChild("Shared").FirstChild("ShowOptionalDialogs").ToElement();
//folder dependency check
readXmlElementLogging("CheckForDependentFolders", optionalDialogs, outputCfg.optDialogs.warningDependentFolders);
//check for multi write access for directory as part of multiple pairs
readXmlElementLogging("CheckForMultipleWriteAccess", optionalDialogs, outputCfg.optDialogs.warningMultiFolderWriteAccess);
//significant difference check
readXmlElementLogging("CheckForSignificantDifference", optionalDialogs, outputCfg.optDialogs.warningSignificantDifference);
//check free disk space
readXmlElementLogging("CheckForFreeDiskSpace", optionalDialogs, outputCfg.optDialogs.warningNotEnoughDiskSpace);
//check for unresolved conflicts
readXmlElementLogging("CheckForUnresolvedConflicts", optionalDialogs, outputCfg.optDialogs.warningUnresolvedConflicts);
readXmlElementLogging("NotifyDatabaseError", optionalDialogs, outputCfg.optDialogs.warningSyncDatabase);
readXmlElementLogging("PopupOnConfigChange", optionalDialogs, outputCfg.optDialogs.popupOnConfigChange);
readXmlElementLogging("SummaryBeforeSync", optionalDialogs, outputCfg.optDialogs.showSummaryBeforeSync);
//gui specific global settings (optional)
const TiXmlElement* gui = TiXmlHandleConst(getRoot()).FirstChild("Gui").ToElement();
const TiXmlElement* mainWindow = TiXmlHandleConst(gui).FirstChild("Windows").FirstChild("Main").ToElement();
//read application window size and position
readXmlElementLogging("Width", mainWindow, outputCfg.gui.widthNotMaximized);
readXmlElementLogging("Height", mainWindow, outputCfg.gui.heightNotMaximized);
readXmlElementLogging("PosX", mainWindow, outputCfg.gui.posXNotMaximized);
readXmlElementLogging("PosY", mainWindow, outputCfg.gui.posYNotMaximized);
readXmlElementLogging("Maximized", mainWindow, outputCfg.gui.isMaximized);
readXmlElementLogging("ManualDeletionOnBothSides", mainWindow, outputCfg.gui.deleteOnBothSides);
readXmlElementLogging("ManualDeletionUseRecycler", mainWindow, outputCfg.gui.useRecyclerForManualDeletion);
readXmlElementLogging("RespectCaseOnSearch", mainWindow, outputCfg.gui.textSearchRespectCase);
size_t folderPairMax = 0;
readXmlElementLogging("FolderPairsMax", mainWindow, folderPairMax);
if (folderPairMax != 0) //if reading fails, leave at default
outputCfg.gui.addFolderPairCountMax = std::max(static_cast<size_t>(2), folderPairMax) - 1; //map folderPairMax to additionalFolderPairMax
//###########################################################
//read column attributes
readXmlAttributeLogging("AutoAdjust", TiXmlHandleConst(mainWindow).FirstChild("LeftColumns").ToElement(), outputCfg.gui.autoAdjustColumnsLeft);
readXmlAttributeLogging("ShowFileIcons", TiXmlHandleConst(mainWindow).FirstChild("LeftColumns").ToElement(), outputCfg.gui.showFileIconsLeft);
const TiXmlElement* leftColumn = TiXmlHandleConst(mainWindow).FirstChild("LeftColumns").FirstChild("Column").ToElement();
size_t colPos = 0;
while (leftColumn)
{
ColumnAttrib newAttrib;
newAttrib.position = colPos++;
readXmlAttributeLogging("Type", leftColumn, newAttrib.type);
readXmlAttributeLogging("Visible", leftColumn, newAttrib.visible);
readXmlAttributeLogging("Width", leftColumn, newAttrib.width);
outputCfg.gui.columnAttribLeft.push_back(newAttrib);
leftColumn = leftColumn->NextSiblingElement();
}
readXmlAttributeLogging("AutoAdjust", TiXmlHandleConst(mainWindow).FirstChild("RightColumns").ToElement(), outputCfg.gui.autoAdjustColumnsRight);
readXmlAttributeLogging("ShowFileIcons", TiXmlHandleConst(mainWindow).FirstChild("RightColumns").ToElement(), outputCfg.gui.showFileIconsRight);
const TiXmlElement* rightColumn = TiXmlHandleConst(mainWindow).FirstChild("RightColumns").FirstChild("Column").ToElement();
colPos = 0;
while (rightColumn)
{
ColumnAttrib newAttrib;
newAttrib.position = colPos++;
readXmlAttributeLogging("Type", rightColumn, newAttrib.type);
readXmlAttributeLogging("Visible", rightColumn, newAttrib.visible);
readXmlAttributeLogging("Width", rightColumn, newAttrib.width);
outputCfg.gui.columnAttribRight.push_back(newAttrib);
rightColumn = rightColumn->NextSiblingElement();
}
//load folder history elements
const TiXmlElement* historyLeft = TiXmlHandleConst(mainWindow).FirstChild("FolderHistoryLeft").ToElement();
//load max. history size
readXmlAttributeLogging("MaximumSize", historyLeft, outputCfg.gui.folderHistLeftMax);
//load config history elements
readXmlElementLogging("Folder", historyLeft, outputCfg.gui.folderHistoryLeft);
const TiXmlElement* historyRight = TiXmlHandleConst(mainWindow).FirstChild("FolderHistoryRight").ToElement();
//load max. history size
readXmlAttributeLogging("MaximumSize", historyRight, outputCfg.gui.folderHistRightMax);
//load config history elements
readXmlElementLogging("Folder", historyRight, outputCfg.gui.folderHistoryRight);
readXmlElementLogging("Perspective", mainWindow, outputCfg.gui.guiPerspectiveLast);
//external applications
const TiXmlElement* extApps = TiXmlHandleConst(gui).FirstChild("ExternalApplications").FirstChild("Commandline").ToElement();
if (extApps)
{
outputCfg.gui.externelApplications.clear();
while (extApps)
{
wxString description;
wxString cmdLine;
readXmlAttributeLogging("Description", extApps, description);
const char* text = extApps->GetText();
if (text) cmdLine = wxString::FromUTF8(text); //read commandline
outputCfg.gui.externelApplications.push_back(std::make_pair(description, cmdLine));
extApps = extApps->NextSiblingElement();
}
}
//load config file history
const TiXmlElement* cfgHistory = TiXmlHandleConst(gui).FirstChild("ConfigHistory").ToElement();
//load config history elements
readXmlAttributeLogging("LastUsed", cfgHistory, outputCfg.gui.lastUsedConfigFile);
readXmlElementLogging("File", cfgHistory, outputCfg.gui.cfgFileHistory);
//last update check
readXmlElementLogging("LastUpdateCheck", gui, outputCfg.gui.lastUpdateCheck);
//batch specific global settings
//const TiXmlElement* batch = TiXmlHandleConst(root).FirstChild("Batch").ToElement();
}
void addXmlElement(const std::string& name, const CompareVariant variant, TiXmlElement* parent)
{
switch (variant)
{
case ffs3::CMP_BY_TIME_SIZE:
xmlAccess::addXmlElement(name, std::string("ByTimeAndSize"), parent);
break;
case ffs3::CMP_BY_CONTENT:
xmlAccess::addXmlElement(name, std::string("ByContent"), parent);
break;
}
}
void addXmlElement(const std::string& name, const SyncDirection value, TiXmlElement* parent)
{
switch (value)
{
case SYNC_DIR_LEFT:
xmlAccess::addXmlElement(name, std::string("left"), parent);
break;
case SYNC_DIR_RIGHT:
xmlAccess::addXmlElement(name, std::string("right"), parent);
break;
case SYNC_DIR_NONE:
xmlAccess::addXmlElement(name, std::string("none"), parent);
break;
}
}
void addXmlElement(const std::string& name, const xmlAccess::OnError value, TiXmlElement* parent)
{
switch (value)
{
case xmlAccess::ON_ERROR_IGNORE:
xmlAccess::addXmlElement(name, std::string("Ignore"), parent);
break;
case xmlAccess::ON_ERROR_EXIT:
xmlAccess::addXmlElement(name, std::string("Exit"), parent);
break;
case xmlAccess::ON_ERROR_POPUP:
xmlAccess::addXmlElement(name, std::string("Popup"), parent);
break;
}
}
void addXmlElement(const std::string& name, const ffs3::DeletionPolicy value, TiXmlElement* parent)
{
switch (value)
{
case ffs3::DELETE_PERMANENTLY:
xmlAccess::addXmlElement(name, std::string("DeletePermanently"), parent);
break;
case ffs3::MOVE_TO_RECYCLE_BIN:
xmlAccess::addXmlElement(name, std::string("MoveToRecycleBin"), parent);
break;
case ffs3::MOVE_TO_CUSTOM_DIRECTORY:
xmlAccess::addXmlElement(name, std::string("MoveToCustomDirectory"), parent);
break;
}
}
void addXmlElement(const std::string& name, const ffs3::SymLinkHandling value, TiXmlElement* parent)
{
switch (value)
{
case ffs3::SYMLINK_IGNORE:
xmlAccess::addXmlElement(name, std::string("Ignore"), parent);
break;
case ffs3::SYMLINK_USE_DIRECTLY:
xmlAccess::addXmlElement(name, std::string("UseDirectly"), parent);
break;
case ffs3::SYMLINK_FOLLOW_LINK:
xmlAccess::addXmlElement(name, std::string("FollowLink"), parent);
break;
}
}
void addXmlElement(const std::string& name, const Zstring& value, TiXmlElement* parent)
{
xmlAccess::addXmlElement(name, wxString(zToWx(value)), parent);
}
void addXmlAttribute(const std::string& name, const xmlAccess::ColumnTypes value, TiXmlElement* node)
{
xmlAccess::addXmlAttribute(name, static_cast<int>(value), node);
}
void writeXmlLocalConfig(const FolderPairEnh& enhPair, TiXmlElement& parent)
{
//write folder pairs
TiXmlElement* newfolderPair = new TiXmlElement("Pair");
parent.LinkEndChild(newfolderPair);
addXmlElement("Left", enhPair.leftDirectory, newfolderPair);
addXmlElement("Right", enhPair.rightDirectory, newfolderPair);
//alternate sync configuration
const AlternateSyncConfig* altSyncConfig = enhPair.altSyncConfig.get();
if (altSyncConfig)
{
TiXmlElement* syncCfg = new TiXmlElement("AlternateSyncConfig");
newfolderPair->LinkEndChild(syncCfg);
TiXmlElement* syncSettings = new TiXmlElement("Synchronization");
syncCfg->LinkEndChild(syncSettings);
//write sync configuration
addXmlElement("Automatic", altSyncConfig->syncConfiguration.automatic, syncSettings);
TiXmlElement* syncDirections = new TiXmlElement("Directions");
syncSettings->LinkEndChild(syncDirections);
addXmlElement("LeftOnly", altSyncConfig->syncConfiguration.exLeftSideOnly, syncDirections);
addXmlElement("RightOnly", altSyncConfig->syncConfiguration.exRightSideOnly, syncDirections);
addXmlElement("LeftNewer", altSyncConfig->syncConfiguration.leftNewer, syncDirections);
addXmlElement("RightNewer", altSyncConfig->syncConfiguration.rightNewer, syncDirections);
addXmlElement("Different", altSyncConfig->syncConfiguration.different, syncDirections);
addXmlElement("Conflict", altSyncConfig->syncConfiguration.conflict, syncDirections);
TiXmlElement* miscSettings = new TiXmlElement("Miscellaneous");
syncCfg->LinkEndChild(miscSettings);
//misc
addXmlElement("DeletionPolicy", altSyncConfig->handleDeletion, miscSettings);
addXmlElement("CustomDeletionFolder", altSyncConfig->customDeletionDirectory, miscSettings);
}
//###########################################################
//alternate filter configuration
TiXmlElement* filterCfg = new TiXmlElement("LocalFilter");
newfolderPair->LinkEndChild(filterCfg);
//write filter settings
addXmlElement("Include", enhPair.localFilter.includeFilter, filterCfg);
addXmlElement("Exclude", enhPair.localFilter.excludeFilter, filterCfg);
}
bool writeXmlMainConfig(const MainConfiguration& mainCfg, TiXmlDocument& doc)
{
TiXmlElement* root = doc.RootElement();
if (!root) return false;
TiXmlElement* settings = new TiXmlElement("MainConfig");
root->LinkEndChild(settings);
//###########################################################
TiXmlElement* cmpSettings = new TiXmlElement("Comparison");
settings->LinkEndChild(cmpSettings);
//write compare algorithm
addXmlElement("Variant", mainCfg.compareVar, cmpSettings);
//include symbolic links at all?
addXmlElement("HandleSymlinks", mainCfg.handleSymlinks, cmpSettings);
//###########################################################
TiXmlElement* syncSettings = new TiXmlElement("Synchronization");
settings->LinkEndChild(syncSettings);
//write sync configuration
addXmlElement("Automatic", mainCfg.syncConfiguration.automatic, syncSettings);
TiXmlElement* syncDirections = new TiXmlElement("Directions");
syncSettings->LinkEndChild(syncDirections);
addXmlElement("LeftOnly", mainCfg.syncConfiguration.exLeftSideOnly, syncDirections);
addXmlElement("RightOnly", mainCfg.syncConfiguration.exRightSideOnly, syncDirections);
addXmlElement("LeftNewer", mainCfg.syncConfiguration.leftNewer, syncDirections);
addXmlElement("RightNewer", mainCfg.syncConfiguration.rightNewer, syncDirections);
addXmlElement("Different", mainCfg.syncConfiguration.different, syncDirections);
addXmlElement("Conflict", mainCfg.syncConfiguration.conflict, syncDirections);
//###########################################################
TiXmlElement* miscSettings = new TiXmlElement("Miscellaneous");
settings->LinkEndChild(miscSettings);
//write filter settings
TiXmlElement* filter = new TiXmlElement("Filter");
miscSettings->LinkEndChild(filter);
addXmlElement("Include", mainCfg.globalFilter.includeFilter, filter);
addXmlElement("Exclude", mainCfg.globalFilter.excludeFilter, filter);
//other
addXmlElement("DeletionPolicy", mainCfg.handleDeletion, miscSettings);
addXmlElement("CustomDeletionFolder", mainCfg.customDeletionDirectory, miscSettings);
//###########################################################
TiXmlElement* pairs = new TiXmlElement("FolderPairs");
settings->LinkEndChild(pairs);
//write first folder pair
writeXmlLocalConfig(mainCfg.firstPair, *pairs);
//write additional folder pairs
for (std::vector<FolderPairEnh>::const_iterator i = mainCfg.additionalPairs.begin(); i != mainCfg.additionalPairs.end(); ++i)
writeXmlLocalConfig(*i, *pairs);
return true;
}
bool writeXmlGuiConfig(const xmlAccess::XmlGuiConfig& inputCfg, TiXmlDocument& doc)
{
//write main config
if (!writeXmlMainConfig(inputCfg.mainCfg, doc))
return false;
//write GUI specific config
TiXmlElement* root = doc.RootElement();
if (!root) return false;
TiXmlElement* guiConfig = new TiXmlElement("GuiConfig");
root->LinkEndChild(guiConfig);
addXmlElement("HideFiltered", inputCfg.hideFilteredElements, guiConfig);
addXmlElement("HandleError", inputCfg.ignoreErrors ? xmlAccess::ON_ERROR_IGNORE : xmlAccess::ON_ERROR_POPUP, guiConfig);
addXmlElement("SyncPreviewActive", inputCfg.syncPreviewEnabled, guiConfig);
return true;
}
bool writeXmlBatchConfig(const xmlAccess::XmlBatchConfig& inputCfg, TiXmlDocument& doc)
{
//write main config
if (!writeXmlMainConfig(inputCfg.mainCfg, doc))
return false;
//write GUI specific config
TiXmlElement* root = doc.RootElement();
if (!root) return false;
TiXmlElement* batchConfig = new TiXmlElement("BatchConfig");
root->LinkEndChild(batchConfig);
addXmlElement("Silent", inputCfg.silent, batchConfig);
addXmlElement("LogfileDirectory", inputCfg.logFileDirectory, batchConfig);
addXmlElement("LogfileCountMax", inputCfg.logFileCountMax, batchConfig);
addXmlElement("HandleError", inputCfg.handleError, batchConfig);
return true;
}
bool writeXmlGlobalSettings(const xmlAccess::XmlGlobalSettings& inputCfg, TiXmlDocument& doc)
{
TiXmlElement* root = doc.RootElement();
if (!root) return false;
//###################################################################
//write global settings
TiXmlElement* global = new TiXmlElement("Shared");
root->LinkEndChild(global);
//program language
addXmlElement("Language", inputCfg.programLanguage, global);
//copy locked files using VSS
addXmlElement("CopyLockedFiles", inputCfg.copyLockedFiles, global);
//file permissions
addXmlElement("CopyFilePermissions", inputCfg.copyFilePermissions, global);
//verify file copying
addXmlElement("VerifyCopiedFiles", inputCfg.verifyFileCopy, global);
//max. allowed file time deviation
addXmlElement("FileTimeTolerance", inputCfg.fileTimeTolerance, global);
//optional dialogs
TiXmlElement* optionalDialogs = new TiXmlElement("ShowOptionalDialogs");
global->LinkEndChild(optionalDialogs);
//warning: dependent folders
addXmlElement("CheckForDependentFolders", inputCfg.optDialogs.warningDependentFolders, optionalDialogs);
//check for multi write access for directory as part of multiple pairs
addXmlElement("CheckForMultipleWriteAccess", inputCfg.optDialogs.warningMultiFolderWriteAccess, optionalDialogs);
//significant difference check
addXmlElement("CheckForSignificantDifference", inputCfg.optDialogs.warningSignificantDifference, optionalDialogs);
//check free disk space
addXmlElement("CheckForFreeDiskSpace", inputCfg.optDialogs.warningNotEnoughDiskSpace, optionalDialogs);
//check for unresolved conflicts
addXmlElement("CheckForUnresolvedConflicts", inputCfg.optDialogs.warningUnresolvedConflicts, optionalDialogs);
addXmlElement("NotifyDatabaseError", inputCfg.optDialogs.warningSyncDatabase, optionalDialogs);
addXmlElement("PopupOnConfigChange", inputCfg.optDialogs.popupOnConfigChange, optionalDialogs);
addXmlElement("SummaryBeforeSync", inputCfg.optDialogs.showSummaryBeforeSync, optionalDialogs);
//###################################################################
//write global gui settings
TiXmlElement* gui = new TiXmlElement("Gui");
root->LinkEndChild(gui);
TiXmlElement* windows = new TiXmlElement("Windows");
gui->LinkEndChild(windows);
TiXmlElement* mainWindow = new TiXmlElement("Main");
windows->LinkEndChild(mainWindow);
//window size
addXmlElement("Width", inputCfg.gui.widthNotMaximized, mainWindow);
addXmlElement("Height", inputCfg.gui.heightNotMaximized, mainWindow);
//window position
addXmlElement("PosX", inputCfg.gui.posXNotMaximized, mainWindow);
addXmlElement("PosY", inputCfg.gui.posYNotMaximized, mainWindow);
addXmlElement("Maximized", inputCfg.gui.isMaximized, mainWindow);
addXmlElement("ManualDeletionOnBothSides", inputCfg.gui.deleteOnBothSides, mainWindow);
addXmlElement("ManualDeletionUseRecycler", inputCfg.gui.useRecyclerForManualDeletion, mainWindow);
addXmlElement("RespectCaseOnSearch", inputCfg.gui.textSearchRespectCase, mainWindow);
addXmlElement("FolderPairsMax", inputCfg.gui.addFolderPairCountMax + 1 /*add main pair*/, mainWindow);
//write column attributes
TiXmlElement* leftColumn = new TiXmlElement("LeftColumns");
mainWindow->LinkEndChild(leftColumn);
addXmlAttribute("AutoAdjust", inputCfg.gui.autoAdjustColumnsLeft, leftColumn);
addXmlAttribute("ShowFileIcons", inputCfg.gui.showFileIconsLeft, leftColumn);
ColumnAttributes columnAtrribLeftCopy = inputCfg.gui.columnAttribLeft; //can't change const vector
sort(columnAtrribLeftCopy.begin(), columnAtrribLeftCopy.end(), xmlAccess::sortByPositionOnly);
for (size_t i = 0; i < columnAtrribLeftCopy.size(); ++i)
{
TiXmlElement* subElement = new TiXmlElement("Column");
leftColumn->LinkEndChild(subElement);
const ColumnAttrib& colAttrib = columnAtrribLeftCopy[i];
addXmlAttribute("Type", colAttrib.type, subElement);
addXmlAttribute("Visible", colAttrib.visible, subElement);
addXmlAttribute("Width", colAttrib.width, subElement);
}
TiXmlElement* rightColumn = new TiXmlElement("RightColumns");
mainWindow->LinkEndChild(rightColumn);
addXmlAttribute("AutoAdjust", inputCfg.gui.autoAdjustColumnsRight, rightColumn);
addXmlAttribute("ShowFileIcons", inputCfg.gui.showFileIconsRight, rightColumn);
ColumnAttributes columnAtrribRightCopy = inputCfg.gui.columnAttribRight;
sort(columnAtrribRightCopy.begin(), columnAtrribRightCopy.end(), xmlAccess::sortByPositionOnly);
for (size_t i = 0; i < columnAtrribRightCopy.size(); ++i)
{
TiXmlElement* subElement = new TiXmlElement("Column");
rightColumn->LinkEndChild(subElement);
const ColumnAttrib& colAttrib = columnAtrribRightCopy[i];
addXmlAttribute("Type", colAttrib.type, subElement);
addXmlAttribute("Visible", colAttrib.visible, subElement);
addXmlAttribute("Width", colAttrib.width, subElement);
}
//write folder history elements
TiXmlElement* historyLeft = new TiXmlElement("FolderHistoryLeft");
mainWindow->LinkEndChild(historyLeft);
TiXmlElement* historyRight = new TiXmlElement("FolderHistoryRight");
mainWindow->LinkEndChild(historyRight);
addXmlAttribute("MaximumSize", inputCfg.gui.folderHistLeftMax, historyLeft);
addXmlAttribute("MaximumSize", inputCfg.gui.folderHistRightMax, historyRight);
addXmlElement("Folder", inputCfg.gui.folderHistoryLeft, historyLeft);
addXmlElement("Folder", inputCfg.gui.folderHistoryRight, historyRight);
addXmlElement("Perspective", inputCfg.gui.guiPerspectiveLast, mainWindow);
//external applications
TiXmlElement* extApp = new TiXmlElement("ExternalApplications");
gui->LinkEndChild(extApp);
for (ExternalApps::const_iterator i = inputCfg.gui.externelApplications.begin(); i != inputCfg.gui.externelApplications.end(); ++i)
{
TiXmlElement* newEntry = new TiXmlElement("Commandline");
extApp->LinkEndChild(newEntry);
addXmlAttribute("Description", i->first, newEntry);
newEntry->LinkEndChild(new TiXmlText(i->second.ToUTF8())); //commandline
}
//write config file history
TiXmlElement* cfgHistory = new TiXmlElement("ConfigHistory");
gui->LinkEndChild(cfgHistory);
addXmlAttribute("LastUsed", inputCfg.gui.lastUsedConfigFile, cfgHistory);
addXmlElement("File", inputCfg.gui.cfgFileHistory, cfgHistory);
//last update check
addXmlElement("LastUpdateCheck", inputCfg.gui.lastUpdateCheck, gui);
//###################################################################
//write global batch settings
TiXmlElement* batch = new TiXmlElement("Batch");
root->LinkEndChild(batch);
return true;
}
int xmlAccess::retrieveSystemLanguage()
{
return wxLocale::GetSystemLanguage();
}
wxString xmlAccess::getGlobalConfigFile()
{
return ffs3::getConfigDir() + wxT("GlobalSettings.xml");
}
void xmlAccess::OptionalDialogs::resetDialogs()
{
warningDependentFolders = true;
warningMultiFolderWriteAccess = true;
warningSignificantDifference = true;
warningNotEnoughDiskSpace = true;
warningUnresolvedConflicts = true;
warningSyncDatabase = true;
popupOnConfigChange = true;
showSummaryBeforeSync = true;
}
xmlAccess::XmlGuiConfig xmlAccess::convertBatchToGui(const xmlAccess::XmlBatchConfig& batchCfg)
{
XmlGuiConfig output;
output.mainCfg = batchCfg.mainCfg;
return output;
}
xmlAccess::XmlBatchConfig xmlAccess::convertGuiToBatch(const xmlAccess::XmlGuiConfig& guiCfg)
{
XmlBatchConfig output;
output.mainCfg = guiCfg.mainCfg;
if (guiCfg.ignoreErrors)
output.handleError = xmlAccess::ON_ERROR_IGNORE;
else
output.handleError = xmlAccess::ON_ERROR_POPUP;
return output;
}
xmlAccess::MergeType xmlAccess::getMergeType(const std::vector<wxString>& filenames) //throw ()
{
bool guiCfgExists = false;
bool batchCfgExists = false;
for (std::vector<wxString>::const_iterator i = filenames.begin(); i != filenames.end(); ++i)
{
switch (xmlAccess::getXmlType(*i)) //throw()
{
case XML_GUI_CONFIG:
guiCfgExists = true;
break;
case XML_BATCH_CONFIG:
batchCfgExists = true;
break;
case XML_GLOBAL_SETTINGS:
case XML_REAL_CONFIG:
case XML_OTHER:
return MERGE_OTHER;
}
}
if (guiCfgExists && batchCfgExists)
return MERGE_GUI_BATCH;
else if (guiCfgExists && !batchCfgExists)
return MERGE_GUI;
else if (!guiCfgExists && batchCfgExists)
return MERGE_BATCH;
else
return MERGE_OTHER;
}
namespace
{
template <class XmlCfg>
XmlCfg loadCfgImpl(const wxString& filename, std::auto_ptr<xmlAccess::XmlError>& exeption) //throw (xmlAccess::XmlError)
{
XmlCfg cfg;
try
{
xmlAccess::readConfig(filename, cfg); //throw (xmlAccess::XmlError);
}
catch (const xmlAccess::XmlError& e)
{
if (e.getSeverity() == xmlAccess::XmlError::FATAL)
throw;
else
exeption.reset(new xmlAccess::XmlError(e));
}
return cfg;
}
template <class XmlCfg>
void mergeConfigFilesImpl(const std::vector<wxString>& filenames, XmlCfg& config) //throw (xmlAccess::XmlError)
{
using namespace xmlAccess;
assert(!filenames.empty());
if (filenames.empty())
return;
std::vector<ffs3::MainConfiguration> mainCfgs;
std::auto_ptr<XmlError> savedException;
for (std::vector<wxString>::const_iterator i = filenames.begin(); i != filenames.end(); ++i)
{
switch (getXmlType(*i))
{
case XML_GUI_CONFIG:
mainCfgs.push_back(loadCfgImpl<XmlGuiConfig>(*i, savedException).mainCfg); //throw (xmlAccess::XmlError)
break;
case XML_BATCH_CONFIG:
mainCfgs.push_back(loadCfgImpl<XmlBatchConfig>(*i, savedException).mainCfg); //throw (xmlAccess::XmlError)
break;
case XML_GLOBAL_SETTINGS:
case XML_REAL_CONFIG:
case XML_OTHER:
break;
}
}
if (mainCfgs.empty())
throw XmlError(_("Invalid FreeFileSync config file!"));
try //...to init all non-"mainCfg" settings with first config file
{
xmlAccess::readConfig(filenames[0], config); //throw (xmlAccess::XmlError);
}
catch (...) {}
config.mainCfg = merge(mainCfgs);
if (savedException.get()) //"re-throw" exception
throw* savedException;
}
}
void xmlAccess::convertConfig(const std::vector<wxString>& filenames, XmlGuiConfig& config) //throw (xmlAccess::XmlError)
{
mergeConfigFilesImpl(filenames, config); //throw (xmlAccess::XmlError)
}
void xmlAccess::convertConfig(const std::vector<wxString>& filenames, XmlBatchConfig& config) //throw (xmlAccess::XmlError);
{
mergeConfigFilesImpl(filenames, config); //throw (xmlAccess::XmlError)
}
|