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
|
// *****************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0 *
// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
// *****************************************************************************
#ifndef PROCESS_XML_H_28345825704254262435
#define PROCESS_XML_H_28345825704254262435
#include <wx/gdicmn.h>
#include <zen/file_access.h>
#include "localization.h"
#include "base/structures.h"
#include "ui/file_grid_attr.h"
#include "ui/tree_grid_attr.h" //RTS: avoid tree grid's "file_hierarchy.h" dependency!
#include "ui/cfg_grid.h"
#include "log_file.h"
//#include "version/version.h"
namespace fff
{
enum class BatchErrorHandling
{
showPopup,
cancel
};
enum class PostBatchAction
{
none,
sleep,
shutdown
};
struct ExternalApp
{
std::wstring description; //must be translated *after* loading from config file
Zstring cmdLine;
};
extern const ExternalApp extCommandFileManager;
extern const ExternalApp extCommandOpenDefault;
//---------------------------------------------------------------------
struct XmlGuiConfig
{
MainConfiguration mainCfg;
GridViewType gridViewType = GridViewType::action; //keep "visual" setting out of "MainConfiguration"
bool operator==(const XmlGuiConfig&) const = default;
};
struct BatchExclusiveConfig
{
bool runMinimized = false;
bool autoCloseSummary = false;
BatchErrorHandling batchErrorHandling = BatchErrorHandling::showPopup;
PostBatchAction postBatchAction = PostBatchAction::none;
};
struct XmlBatchConfig
{
XmlGuiConfig guiCfg; //batch config can be used in GUI (but not the other way round)
BatchExclusiveConfig batchExCfg;
};
struct ConfirmationDialogs
{
bool confirmSaveConfig = true;
bool confirmSyncStart = true;
bool confirmCommandMassInvoke = true;
bool confirmSwapSides = true;
bool operator==(const ConfirmationDialogs&) const = default;
};
enum class GridIconSize
{
small,
medium,
large
};
struct ViewFilterDefault
{
//shared
bool equal = false;
bool conflict = true;
bool excluded = false;
//difference view
bool leftOnly = true;
bool rightOnly = true;
bool leftNewer = true;
bool rightNewer = true;
bool different = true;
//action view
bool createLeft = true;
bool createRight = true;
bool updateLeft = true;
bool updateRight = true;
bool deleteLeft = true;
bool deleteRight = true;
bool doNothing = true;
};
Zstring getGlobalConfigDefaultPath();
Zstring getLogFolderDefaultPath();
struct DpiLayout
{
struct
{
std::optional<wxSize> size;
std::optional<wxPoint> pos;
bool isMaximized = false;
} mainDlg; //WindowLayout::getBeforeClose()
struct
{
std::optional<wxSize> size;
//std::optional<wxPoint> pos; -> most users probably want it centered, but others at a fixed (relative??) location
bool isMaximized = false;
} progressDlg;
wxString panelLayout; //for wxAuiManager::LoadPerspective
std::vector<ColAttributesCfg> configColumnAttribs = getCfgGridDefaultColAttribs();
std::vector<ColumnAttribOverview> overviewColumnAttribs = getOverviewDefaultColAttribs();
std::vector<ColAttributesRim> fileColumnAttribsLeft = getFileGridDefaultColAttribsLeft();
std::vector<ColAttributesRim> fileColumnAttribsRight = getFileGridDefaultColAttribsRight();
};
struct XmlGlobalSettings
{
XmlGlobalSettings();
//---------------------------------------------------------------------
//Shared (GUI/BATCH) settings
wxLanguage programLanguage = getDefaultLanguage();
bool failSafeFileCopy = true;
bool copyLockedFiles = false; //safer default: avoid copies of partially written files
bool copyFilePermissions = false;
unsigned int fileTimeTolerance = zen::FAT_FILE_TIME_PRECISION_SEC; //default 2s: FAT vs NTFS
bool runWithBackgroundPriority = false;
bool createLockFile = true;
bool verifyFileCopy = false;
int logfilesMaxAgeDays = 30; //<= 0 := no limit; for log files under %AppData%\FreeFileSync\Logs
LogFileFormat logFormat = LogFileFormat::html;
Zstring soundFileCompareFinished;
Zstring soundFileSyncFinished;
Zstring soundFileAlertPending;
ConfirmationDialogs confirmDlgs;
WarningDialogs warnDlgs;
//---------------------------------------------------------------------
struct
{
bool textSearchRespectCase = false; //good default for Linux, too!
int folderPairsVisibleMax = 6;
struct
{
size_t topRowPos = 0;
int syncOverdueDays = 7;
ColumnTypeCfg lastSortColumn = cfgGridLastSortColumnDefault;
bool lastSortAscending = getDefaultSortDirection(cfgGridLastSortColumnDefault);
size_t histItemsMax = 100; //do we need to limit config items at all?
Zstring lastSelectedFile;
std::vector<ConfigFileItem> fileHistory;
std::vector<Zstring> lastUsedFiles;
} config;
struct
{
bool showPercentBar = overviewPanelShowPercentageDefault;
ColumnTypeOverview lastSortColumn = overviewPanelLastSortColumnDefault; //remember sort on overview panel
bool lastSortAscending = getDefaultSortDirection(overviewPanelLastSortColumnDefault); //
} overview;
struct
{
bool keepRelPaths = false;
bool overwriteIfExists = false;
Zstring targetFolderPath;
Zstring targetFolderLastSelected;
std::vector<Zstring> folderHistory;
} copyToCfg;
std::vector<Zstring> folderHistoryLeft;
std::vector<Zstring> folderHistoryRight;
Zstring folderLastSelectedLeft;
Zstring folderLastSelectedRight;
bool showIcons = true;
GridIconSize iconSize = GridIconSize::small;
int sashOffset = 0;
ItemPathFormat itemPathFormatLeftGrid = defaultItemPathFormatLeftGrid;
ItemPathFormat itemPathFormatRightGrid = defaultItemPathFormatRightGrid;
ViewFilterDefault viewFilterDefault;
} mainDlg;
bool progressDlgAutoClose = false;
FilterConfig defaultFilter = []
{
FilterConfig def;
assert(def.excludeFilter.empty());
def.excludeFilter =
"*/.Trash-*/" "\n"
"*/.recycle/";
return def;
}();
size_t folderHistoryMax = 20;
Zstring sftpKeyFileLastSelected;
std::vector<Zstring> versioningFolderHistory;
Zstring versioningFolderLastSelected;
Zstring logFolderPhrase = getLogFolderDefaultPath();
std::vector<Zstring> logFolderHistory;
Zstring logFolderLastSelected;
std::vector<Zstring> emailHistory;
size_t emailHistoryMax = 10;
std::vector<Zstring> commandHistory;
size_t commandHistoryMax = 10;
std::vector<ExternalApp> externalApps{extCommandFileManager, extCommandOpenDefault};
time_t lastUpdateCheck = 0; //number of seconds since Jan 1, 1970 GMT
std::string lastOnlineVersion;
std::string welcomeDialogLastVersion;
std::unordered_map<int /*scale percent*/, DpiLayout> dpiLayouts;
};
//read/write specific config types
std::pair<XmlGuiConfig, std::wstring /*warningMsg*/> readGuiConfig (const Zstring& filePath); //
std::pair<XmlBatchConfig, std::wstring /*warningMsg*/> readBatchConfig (const Zstring& filePath); //throw FileError
std::pair<XmlGlobalSettings, std::wstring /*warningMsg*/> readGlobalConfig(const Zstring& filePath); //
void writeConfig(const XmlGuiConfig& cfg, const Zstring& filePath); //
void writeConfig(const XmlBatchConfig& cfg, const Zstring& filePath); //throw FileError
void writeConfig(const XmlGlobalSettings& cfg, const Zstring& filePath); //
//convert (multiple) *.ffs_gui, *.ffs_batch files or combinations of both into target config structure:
std::pair<XmlGuiConfig, std::wstring /*warningMsg*/> readAnyConfig(const std::vector<Zstring>& filePaths); //throw FileError
std::wstring extractJobName(const Zstring& cfgFilePath);
//human-readable/editable format suitable for clipboard
std::string serializeFilter(const FilterConfig& filterCfg);
std::optional<FilterConfig> parseFilterBuf(const std::string& filterBuf);
void saveErrorLog(const zen::ErrorLog& log, const Zstring& filePath); //throw FileError
zen::ErrorLog loadErrorLog(const Zstring& filePath); //throw FileError
}
#endif //PROCESS_XML_H_28345825704254262435
|