summaryrefslogtreecommitdiff
path: root/RealtimeSync
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:12:17 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:12:17 +0200
commitb654dbfa5f3e4a4d02f72023f7c5895635aa6396 (patch)
tree8c1dfe7f638c0fc7afc1d08bc2fc0fd0f8646e5e /RealtimeSync
parent3.17 (diff)
downloadFreeFileSync-b654dbfa5f3e4a4d02f72023f7c5895635aa6396.tar.gz
FreeFileSync-b654dbfa5f3e4a4d02f72023f7c5895635aa6396.tar.bz2
FreeFileSync-b654dbfa5f3e4a4d02f72023f7c5895635aa6396.zip
3.18
Diffstat (limited to 'RealtimeSync')
-rw-r--r--RealtimeSync/RealtimeSync.cbp8
-rw-r--r--RealtimeSync/RealtimeSync.vcxproj19
-rw-r--r--RealtimeSync/application.cpp2
-rw-r--r--RealtimeSync/main_dlg.cpp10
-rw-r--r--RealtimeSync/makefile5
-rw-r--r--RealtimeSync/xml_ffs.cpp10
-rw-r--r--RealtimeSync/xml_ffs.h2
-rw-r--r--RealtimeSync/xml_proc.cpp113
-rw-r--r--RealtimeSync/xml_proc.h6
9 files changed, 70 insertions, 105 deletions
diff --git a/RealtimeSync/RealtimeSync.cbp b/RealtimeSync/RealtimeSync.cbp
index a3341c94..9e81c8ea 100644
--- a/RealtimeSync/RealtimeSync.cbp
+++ b/RealtimeSync/RealtimeSync.cbp
@@ -64,16 +64,18 @@
<Add option="-Wall" />
<Add option="-pipe" />
<Add option="-mthreads" />
+ <Add option="-std=gnu++0x" />
<Add option="-D__GNUWIN32__" />
<Add option="-D__WXMSW__" />
<Add option="-DwxUSE_UNICODE" />
<Add option="-DFFS_WIN" />
- <Add option="-DTIXML_USE_STL" />
+ <Add option="-DZEN_PLATFORM_WINDOWS" />
<Add option="-DBOOST_THREAD_NO_LIB" />
<Add option="-DBOOST_THREAD_USE_LIB" />
<Add option="-DWXINTL_NO_GETTEXT_MACRO" />
<Add directory="C:\Programme\C++\wxWidgets\include" />
<Add directory="C:\Program Files\C++\Boost" />
+ <Add directory="..\shared" />
</Compiler>
<ResourceCompiler>
<Add directory="C:\Programme\C++\wxWidgets\include" />
@@ -152,10 +154,6 @@
<Unit filename="..\shared\resolve_path.h" />
<Unit filename="..\shared\standard_paths.cpp" />
<Unit filename="..\shared\standard_paths.h" />
- <Unit filename="..\shared\tinyxml\tinystr.cpp" />
- <Unit filename="..\shared\tinyxml\tinyxml.cpp" />
- <Unit filename="..\shared\tinyxml\tinyxmlerror.cpp" />
- <Unit filename="..\shared\tinyxml\tinyxmlparser.cpp" />
<Unit filename="..\shared\util.cpp" />
<Unit filename="..\shared\xml_base.cpp" />
<Unit filename="..\shared\xml_base.h" />
diff --git a/RealtimeSync/RealtimeSync.vcxproj b/RealtimeSync/RealtimeSync.vcxproj
index b141e391..12d36822 100644
--- a/RealtimeSync/RealtimeSync.vcxproj
+++ b/RealtimeSync/RealtimeSync.vcxproj
@@ -99,8 +99,8 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;__WXDEBUG__;TIXML_USE_STL</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswud;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZEN_PLATFORM_WINDOWS;wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;__WXDEBUG__</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\shared;C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswud;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
<PrecompiledHeaderFile>$(ProjectDir)/../shared/pch.h</PrecompiledHeaderFile>
<DisableSpecificWarnings>4100;4996</DisableSpecificWarnings>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
@@ -129,8 +129,8 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;__WXDEBUG__;TIXML_USE_STL</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Program Files\C++\wxWidgets-x64\include;C:\Program Files\C++\wxWidgets-x64\lib\vc_lib\mswud;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZEN_PLATFORM_WINDOWS;wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;__WXDEBUG__</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\shared;C:\Program Files\C++\wxWidgets-x64\include;C:\Program Files\C++\wxWidgets-x64\lib\vc_lib\mswud;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
<PrecompiledHeaderFile>$(ProjectDir)/../shared/pch.h</PrecompiledHeaderFile>
<DisableSpecificWarnings>4100;4996</DisableSpecificWarnings>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
@@ -162,8 +162,8 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG;TIXML_USE_STL</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswu;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZEN_PLATFORM_WINDOWS;wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\shared;C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswu;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<DisableSpecificWarnings>4100;4996</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -196,8 +196,8 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG;TIXML_USE_STL</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Program Files\C++\wxWidgets-x64\include;C:\Program Files\C++\wxWidgets-x64\lib\vc_lib\mswu;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
+ <PreprocessorDefinitions>ZEN_PLATFORM_WINDOWS;wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..\shared;C:\Program Files\C++\wxWidgets-x64\include;C:\Program Files\C++\wxWidgets-x64\lib\vc_lib\mswu;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<DisableSpecificWarnings>4100;4996</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -243,9 +243,6 @@
<ClCompile Include="..\shared\resolve_path.cpp" />
<ClCompile Include="..\shared\standard_paths.cpp" />
<ClCompile Include="..\shared\last_error.cpp" />
- <ClCompile Include="..\shared\tinyxml\tinyxml.cpp" />
- <ClCompile Include="..\shared\tinyxml\tinyxmlerror.cpp" />
- <ClCompile Include="..\shared\tinyxml\tinyxmlparser.cpp" />
<ClCompile Include="..\shared\util.cpp" />
<ClCompile Include="..\shared\xml_base.cpp" />
<ClCompile Include="..\shared\zstring.cpp" />
diff --git a/RealtimeSync/application.cpp b/RealtimeSync/application.cpp
index 88e5ab53..75f77da4 100644
--- a/RealtimeSync/application.cpp
+++ b/RealtimeSync/application.cpp
@@ -42,7 +42,7 @@ void Application::OnStartApplication(wxIdleEvent& event)
SetAppName(wxT("FreeFileSync")); //use a different app name, to have "GetUserDataDir()" return the same directory as for FreeFileSync
#ifdef FFS_LINUX
- ::gtk_rc_parse(zen::wxToZ(zen::getResourceDir()) + "styles.rc"); //remove inner border from bitmap buttons
+ ::gtk_rc_parse((zen::wxToZ(zen::getResourceDir()) + "styles.rc").c_str()); //remove inner border from bitmap buttons
#endif
//set program language
diff --git a/RealtimeSync/main_dlg.cpp b/RealtimeSync/main_dlg.cpp
index b11ff848..5a89e4cd 100644
--- a/RealtimeSync/main_dlg.cpp
+++ b/RealtimeSync/main_dlg.cpp
@@ -63,9 +63,9 @@ MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName)
rts::readRealOrBatchConfig(currentConfigFile, newConfig);
loadCfgSuccess = true;
}
- catch (const xmlAccess::XmlError& error)
+ catch (const xmlAccess::FfsXmlError& error)
{
- if (error.getSeverity() == xmlAccess::XmlError::WARNING)
+ if (error.getSeverity() == xmlAccess::FfsXmlError::WARNING)
wxMessageBox(error.msg(), _("Warning"), wxOK | wxICON_WARNING);
else
wxMessageBox(error.msg(), _("Error"), wxOK | wxICON_ERROR);
@@ -99,7 +99,7 @@ MainDialog::~MainDialog()
{
writeRealConfig(currentCfg, lastConfigFileName());
}
- catch (const xmlAccess::XmlError& error)
+ catch (const xmlAccess::FfsXmlError& error)
{
wxMessageBox(error.msg().c_str(), _("Error"), wxOK | wxICON_ERROR);
}
@@ -237,9 +237,9 @@ void MainDialog::loadConfig(const wxString& filename)
{
rts::readRealOrBatchConfig(filename, newConfig);
}
- catch (const xmlAccess::XmlError& error)
+ catch (const xmlAccess::FfsXmlError& error)
{
- if (error.getSeverity() == xmlAccess::XmlError::WARNING)
+ if (error.getSeverity() == xmlAccess::FfsXmlError::WARNING)
wxMessageBox(error.msg(), _("Warning"), wxOK | wxICON_WARNING);
else
{
diff --git a/RealtimeSync/makefile b/RealtimeSync/makefile
index 8f9e4863..56e8eb60 100644
--- a/RealtimeSync/makefile
+++ b/RealtimeSync/makefile
@@ -2,7 +2,7 @@ APPNAME = RealtimeSync
prefix = /usr
BINDIR = $(DESTDIR)$(prefix)/bin
-COMMON_COMPILE_FLAGS = -Wall -pipe `pkg-config --cflags gtk+-2.0` -O3 -pthread -DNDEBUG -DwxUSE_UNICODE -DFFS_LINUX -DTIXML_USE_STL -DWXINTL_NO_GETTEXT_MACRO
+COMMON_COMPILE_FLAGS = -Wall -pipe `pkg-config --cflags gtk+-2.0` -O3 -pthread -std=gnu++0x -DNDEBUG -DwxUSE_UNICODE -DFFS_LINUX -DZEN_PLATFORM_OTHER -DWXINTL_NO_GETTEXT_MACRO -I../shared
COMMON_LINK_FLAGS = -O3 -pthread
#default build
@@ -31,9 +31,6 @@ FILE_LIST+=../shared/check_exist.cpp
FILE_LIST+=../shared/i18n.cpp
FILE_LIST+=../shared/localization.cpp
FILE_LIST+=../shared/inotify/inotify-cxx.cpp
-FILE_LIST+=../shared/tinyxml/tinyxml.cpp
-FILE_LIST+=../shared/tinyxml/tinyxmlerror.cpp
-FILE_LIST+=../shared/tinyxml/tinyxmlparser.cpp
FILE_LIST+=../shared/global_func.cpp
FILE_LIST+=../shared/last_error.cpp
FILE_LIST+=../shared/dir_name.cpp
diff --git a/RealtimeSync/xml_ffs.cpp b/RealtimeSync/xml_ffs.cpp
index 03d266df..15e6f4c2 100644
--- a/RealtimeSync/xml_ffs.cpp
+++ b/RealtimeSync/xml_ffs.cpp
@@ -62,7 +62,7 @@ xmlAccess::XmlRealConfig convertBatchToReal(const xmlAccess::XmlBatchConfig& bat
}
-void rts::readRealOrBatchConfig(const wxString& filename, xmlAccess::XmlRealConfig& config) //throw (xmlAccess::XmlError);
+void rts::readRealOrBatchConfig(const wxString& filename, xmlAccess::XmlRealConfig& config) //throw (xmlAccess::FfsXmlError);
{
if (xmlAccess::getXmlType(filename) != xmlAccess::XML_TYPE_BATCH)
{
@@ -74,11 +74,11 @@ void rts::readRealOrBatchConfig(const wxString& filename, xmlAccess::XmlRealConf
xmlAccess::XmlBatchConfig batchCfg;
try
{
- xmlAccess::readConfig(filename, batchCfg); //throw (xmlAccess::XmlError);
+ xmlAccess::readConfig(filename, batchCfg); //throw (xmlAccess::FfsXmlError);
}
- catch (const xmlAccess::XmlError& e)
+ catch (const xmlAccess::FfsXmlError& e)
{
- if (e.getSeverity() == xmlAccess::XmlError::WARNING)
+ if (e.getSeverity() == xmlAccess::FfsXmlError::WARNING)
config = convertBatchToReal(batchCfg, filename); //do work despite parsing errors, then re-throw
throw; //
@@ -95,7 +95,7 @@ int rts::getProgramLanguage()
{
xmlAccess::readConfig(settings);
}
- catch (const xmlAccess::XmlError&) {} //user default language if error occured
+ catch (const xmlAccess::FfsXmlError&) {} //user default language if error occured
return settings.programLanguage;
}
diff --git a/RealtimeSync/xml_ffs.h b/RealtimeSync/xml_ffs.h
index 69e6e7a9..fb48712a 100644
--- a/RealtimeSync/xml_ffs.h
+++ b/RealtimeSync/xml_ffs.h
@@ -14,7 +14,7 @@
namespace rts
{
-void readRealOrBatchConfig(const wxString& filename, xmlAccess::XmlRealConfig& config); //throw (xmlAccess::XmlError);
+void readRealOrBatchConfig(const wxString& filename, xmlAccess::XmlRealConfig& config); //throw (xmlAccess::FfsXmlError);
int getProgramLanguage();
}
diff --git a/RealtimeSync/xml_proc.cpp b/RealtimeSync/xml_proc.cpp
index 4eaf8769..4ddf8bc4 100644
--- a/RealtimeSync/xml_proc.cpp
+++ b/RealtimeSync/xml_proc.cpp
@@ -7,105 +7,78 @@
#include "xml_proc.h"
#include <wx/filefn.h>
#include "../shared/i18n.h"
+#include <file_handling.h>
+#include <string_conv.h>
+#include <xml_base.h>
-
+using namespace zen;
using namespace xmlAccess;
-class RtsXmlErrorLogger : public xmlAccess::XmlErrorLogger
-{
-public:
- void readConfig(const TiXmlElement* root, xmlAccess::XmlRealConfig& outputCfg);
-};
-
-//--------------------------------------------------------------------------------
-
-
-void RtsXmlErrorLogger::readConfig(const TiXmlElement* root, xmlAccess::XmlRealConfig& outputCfg)
+namespace
{
- //read directories for monitoring
- const TiXmlElement* directoriesToWatch = TiXmlHandleConst(root).FirstChild("Directories").ToElement();
-
- readXmlElementLogging("Folder", directoriesToWatch, outputCfg.directories);
-
- //commandline to execute
- readXmlElementLogging("Commandline", root, outputCfg.commandline);
-
- //delay
- readXmlElementLogging("Delay", root, outputCfg.delay);
-}
-
-
-void writeConfig(const xmlAccess::XmlRealConfig& outputCfg, TiXmlElement& root)
+void readConfig(const XmlIn& in, XmlRealConfig& config)
{
- //directories to monitor
- TiXmlElement* directoriesToWatch = new TiXmlElement("Directories");
- root.LinkEndChild(directoriesToWatch);
- xmlAccess::addXmlElement("Folder", outputCfg.directories, directoriesToWatch);
-
- //commandline to execute
- xmlAccess::addXmlElement("Commandline", outputCfg.commandline, &root);
-
- //delay
- xmlAccess::addXmlElement("Delay", outputCfg.delay, &root);
+ in["Directories"](config.directories);
+ in["Commandline"](config.commandline);
+ in["Delay" ](config.delay);
}
-bool isXmlTypeRTS(const TiXmlDocument& doc) //throw()
+bool isXmlTypeRTS(const XmlDoc& doc) //throw()
{
- const TiXmlElement* root = doc.RootElement();
- if (root && root->ValueStr() == std::string("RealtimeSync"))
+ if (doc.root().getNameAs<std::string>() == "FreeFileSync")
{
- const char* cfgType = root->Attribute("XmlType");
- if (cfgType)
- return std::string(cfgType) == "REAL";
+ std::string type;
+ if (doc.root().getAttribute("XmlType", type))
+ {
+ if (type == "REAL")
+ return true;
+ }
}
return false;
}
-
-
-void initXmlDocument(TiXmlDocument& doc) //throw()
-{
- TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "UTF-8", ""); //delete won't be necessary later; ownership passed to TiXmlDocument!
- doc.LinkEndChild(decl);
-
- TiXmlElement* root = new TiXmlElement("RealtimeSync");
- doc.LinkEndChild(root);
-
- addXmlAttribute("XmlType", "REAL", doc.RootElement());
}
void xmlAccess::readRealConfig(const wxString& filename, XmlRealConfig& config)
{
- //load XML
- if (!wxFileExists(filename))
- throw XmlError(wxString(_("File does not exist:")) + wxT("\n\"") + filename + wxT("\""));
+ if (!fileExists(wxToZ(filename)))
+ throw FfsXmlError(wxString(_("File does not exist:")) + wxT("\n\"") + filename + wxT("\""));
- TiXmlDocument doc;
- loadXmlDocument(filename, doc); //throw (XmlError)
+ XmlDoc doc;
+ loadXmlDocument(filename, doc); //throw (FfsXmlError)
if (!isXmlTypeRTS(doc))
- throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\""));
+ throw FfsXmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\""));
- RtsXmlErrorLogger parser;
- parser.readConfig(doc.RootElement(), config); //read GUI layout configuration
+ XmlIn in(doc);
+ ::readConfig(in, config);
- if (parser.errorsOccurred())
- throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"\n\n") +
- parser.getErrorMessageFormatted(), XmlError::WARNING);
+ if (in.errorsOccured())
+ throw FfsXmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"\n\n") +
+ getErrorMessageFormatted(in), FfsXmlError::WARNING);
}
-void xmlAccess::writeRealConfig(const XmlRealConfig& outputCfg, const wxString& filename)
+namespace
{
- TiXmlDocument doc;
- initXmlDocument(doc); //throw()
+void writeConfig(const XmlRealConfig& config, XmlOut& out)
+{
+ out["Directories"](config.directories);
+ out["Commandline"](config.commandline);
+ out["Delay" ](config.delay);
+}
+}
- if (!doc.RootElement())
- throw XmlError(wxString(_("Error writing file:")) + wxT("\n\"") + filename + wxT("\""));
- writeConfig(outputCfg, *doc.RootElement()); //add GUI layout configuration settings
+void xmlAccess::writeRealConfig(const XmlRealConfig& config, const wxString& filename)
+{
+ XmlDoc doc("FreeFileSync");
+ doc.root().setAttribute("XmlType", "REAL");
+
+ XmlOut out(doc);
+ writeConfig(config, out);
- saveXmlDocument(filename, doc); //throw (XmlError)
+ saveXmlDocument(doc, filename); //throw (FfsXmlError)
}
diff --git a/RealtimeSync/xml_proc.h b/RealtimeSync/xml_proc.h
index 70a879a8..3e2549b0 100644
--- a/RealtimeSync/xml_proc.h
+++ b/RealtimeSync/xml_proc.h
@@ -9,7 +9,7 @@
#include <vector>
#include <wx/string.h>
-#include "../shared/xml_base.h"
+#include <xml_error.h>
namespace xmlAccess
@@ -22,8 +22,8 @@ struct XmlRealConfig
size_t delay;
};
-void readRealConfig(const wxString& filename, XmlRealConfig& config); //throw (xmlAccess::XmlError);
-void writeRealConfig(const XmlRealConfig& outputCfg, const wxString& filename); //throw (xmlAccess::XmlError);
+void readRealConfig(const wxString& filename, XmlRealConfig& config); //throw (xmlAccess::FfsXmlError);
+void writeRealConfig(const XmlRealConfig& config, const wxString& filename); //throw (xmlAccess::FfsXmlError);
}
#endif // XMLPROCESSING_H_INCLUDED
bgstack15