summaryrefslogtreecommitdiff
path: root/RealtimeSync
diff options
context:
space:
mode:
Diffstat (limited to 'RealtimeSync')
-rw-r--r--RealtimeSync/RealtimeSync.cbp11
-rw-r--r--RealtimeSync/RealtimeSync.vcxproj36
-rw-r--r--RealtimeSync/application.cpp8
-rw-r--r--RealtimeSync/main_dlg.cpp35
-rw-r--r--RealtimeSync/main_dlg.h15
-rw-r--r--RealtimeSync/makefile9
-rw-r--r--RealtimeSync/notify.cpp18
-rw-r--r--RealtimeSync/resources.cpp4
-rw-r--r--RealtimeSync/tray_menu.cpp19
-rw-r--r--RealtimeSync/watcher.cpp58
-rw-r--r--RealtimeSync/xml_ffs.cpp15
-rw-r--r--RealtimeSync/xml_proc.cpp114
12 files changed, 174 insertions, 168 deletions
diff --git a/RealtimeSync/RealtimeSync.cbp b/RealtimeSync/RealtimeSync.cbp
index 66fc5452..a3341c94 100644
--- a/RealtimeSync/RealtimeSync.cbp
+++ b/RealtimeSync/RealtimeSync.cbp
@@ -4,10 +4,11 @@
<Project>
<Option title="RealtimeSync" />
<Option makefile="makefile" />
+ <Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Release">
- <Option output="..\BUILD\RealtimeSync_Win32" prefix_auto="1" extension_auto="1" />
+ <Option output="..\BUILD\Bin\RealtimeSync_Win32" prefix_auto="1" extension_auto="1" />
<Option working_dir="..\BUILD" />
<Option object_output="..\OBJ\RTS_Release_32_MinGW" />
<Option type="0" />
@@ -31,7 +32,7 @@
</Linker>
</Target>
<Target title="Debug-DLL">
- <Option output="..\BUILD\RealtimeSync_Debug" prefix_auto="1" extension_auto="1" />
+ <Option output="..\BUILD\Bin\RealtimeSync_Debug" prefix_auto="1" extension_auto="1" />
<Option working_dir="..\BUILD" />
<Option object_output="..\OBJ\RTS_Debug_32_MinGW" />
<Option type="0" />
@@ -136,7 +137,9 @@
<Unit filename="..\shared\help_provider.cpp" />
<Unit filename="..\shared\i18n.cpp" />
<Unit filename="..\shared\i18n.h" />
- <Unit filename="..\shared\long_path_prefix.cpp" />
+ <Unit filename="..\shared\last_error.cpp" />
+ <Unit filename="..\shared\last_error.h" />
+ <Unit filename="..\shared\localization.cpp" />
<Unit filename="..\shared\long_path_prefix.h" />
<Unit filename="..\shared\mouse_move_dlg.cpp" />
<Unit filename="..\shared\pch.h">
@@ -149,8 +152,6 @@
<Unit filename="..\shared\resolve_path.h" />
<Unit filename="..\shared\standard_paths.cpp" />
<Unit filename="..\shared\standard_paths.h" />
- <Unit filename="..\shared\system_func.cpp" />
- <Unit filename="..\shared\system_func.h" />
<Unit filename="..\shared\tinyxml\tinystr.cpp" />
<Unit filename="..\shared\tinyxml\tinyxml.cpp" />
<Unit filename="..\shared\tinyxml\tinyxmlerror.cpp" />
diff --git a/RealtimeSync/RealtimeSync.vcxproj b/RealtimeSync/RealtimeSync.vcxproj
index fa69ffdf..b141e391 100644
--- a/RealtimeSync/RealtimeSync.vcxproj
+++ b/RealtimeSync/RealtimeSync.vcxproj
@@ -68,28 +68,28 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
- <OutDir>..\BUILD\</OutDir>
+ <OutDir>..\BUILD\Bin\</OutDir>
<IntDir>..\OBJ\$(ProjectName)_$(Configuration)_$(PlatformName)_VCPP\</IntDir>
<TargetName>$(ProjectName)_$(PlatformName)</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
- <OutDir>..\BUILD\</OutDir>
+ <OutDir>..\BUILD\Bin\</OutDir>
<IntDir>..\OBJ\$(ProjectName)_$(Configuration)_$(PlatformName)_VCPP\</IntDir>
<TargetName>$(ProjectName)_$(PlatformName)</TargetName>
<GenerateManifest>false</GenerateManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
- <OutDir>..\BUILD\</OutDir>
+ <OutDir>..\BUILD\Bin\</OutDir>
<IntDir>..\OBJ\$(ProjectName)_$(Configuration)_$(PlatformName)_VCPP\</IntDir>
<GenerateManifest>false</GenerateManifest>
<TargetName>$(ProjectName)_$(PlatformName)</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
- <OutDir>..\BUILD\</OutDir>
+ <OutDir>..\BUILD\Bin\</OutDir>
<IntDir>..\OBJ\$(ProjectName)_$(Configuration)_$(PlatformName)_VCPP\</IntDir>
<GenerateManifest>false</GenerateManifest>
<TargetName>$(ProjectName)_$(PlatformName)</TargetName>
@@ -100,7 +100,7 @@
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;__WXDEBUG__;TIXML_USE_STL</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Programme\C++\wxWidgets\include;C:\Programme\C++\wxWidgets\lib\vc_lib\mswud;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>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>
@@ -115,12 +115,12 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<AdditionalDependencies>wxmsw28ud_adv.lib;wxmsw28ud_core.lib;wxbase28ud.lib;wxpngd.lib;wxzlibd.lib;wxbase28ud_net.lib;comctl32.lib;ws2_32.lib;Rpcrt4.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>C:\Programme\C++\wxWidgets\lib\vc_lib;C:\Program Files\C++\Boost\stage\lib</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>C:\Program Files\C++\wxWidgets\lib\vc_lib;C:\Program Files\C++\Boost\stage\lib</AdditionalLibraryDirectories>
<LinkStatus>
</LinkStatus>
</Link>
<ResourceCompile>
- <AdditionalIncludeDirectories>C:\Programme\C++\wxWidgets\include;C:\Programme\C++\wxWidgets\lib\vc_lib\mswud</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswud</AdditionalIncludeDirectories>
<PreprocessorDefinitions>%(PreprocessorDefinitions);</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
@@ -130,7 +130,7 @@
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;__WXDEBUG__;TIXML_USE_STL</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Programme\C++\wxWidgets-x64\include;C:\Programme\C++\wxWidgets-x64\lib\vc_lib\mswud;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>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>
@@ -146,12 +146,12 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<AdditionalDependencies>wxmsw28ud_adv.lib;wxmsw28ud_core.lib;wxbase28ud.lib;wxpngd.lib;wxzlibd.lib;wxbase28ud_net.lib;comctl32.lib;ws2_32.lib;Rpcrt4.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <AdditionalLibraryDirectories>C:\Programme\C++\wxWidgets-x64\lib\vc_lib;C:\Program Files\C++\Boost\stage64\lib</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>C:\Program Files\C++\wxWidgets-x64\lib\vc_lib;C:\Program Files\C++\Boost\stage64\lib</AdditionalLibraryDirectories>
<LinkStatus>
</LinkStatus>
</Link>
<ResourceCompile>
- <AdditionalIncludeDirectories>C:\Programme\C++\wxWidgets\include;C:\Programme\C++\wxWidgets\lib\vc_lib\mswud</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswud</AdditionalIncludeDirectories>
<PreprocessorDefinitions>%(PreprocessorDefinitions);WX_CPU_AMD64</PreprocessorDefinitions>
</ResourceCompile>
</ItemDefinitionGroup>
@@ -163,7 +163,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG;TIXML_USE_STL</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Programme\C++\wxWidgets\include;C:\Programme\C++\wxWidgets\lib\vc_lib\mswu;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>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>
@@ -178,12 +178,12 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalDependencies>wxmsw28u_adv.lib;wxmsw28u_core.lib;wxbase28u.lib;wxpng.lib;wxzlib.lib;wxbase28u_net.lib;comctl32.lib;ws2_32.lib;winmm.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
- <AdditionalLibraryDirectories>C:\Programme\C++\wxWidgets\lib\vc_lib;C:\Program Files\C++\Boost\stage\lib</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>C:\Program Files\C++\wxWidgets\lib\vc_lib;C:\Program Files\C++\Boost\stage\lib</AdditionalLibraryDirectories>
<LinkStatus>
</LinkStatus>
</Link>
<ResourceCompile>
- <AdditionalIncludeDirectories>C:\Programme\C++\wxWidgets\include;C:\Programme\C++\wxWidgets\lib\vc_lib\mswu</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswu</AdditionalIncludeDirectories>
<PreprocessorDefinitions>%(PreprocessorDefinitions);</PreprocessorDefinitions>
<Culture>
</Culture>
@@ -197,7 +197,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;WXINTL_NO_GETTEXT_MACRO;NDEBUG;TIXML_USE_STL</PreprocessorDefinitions>
- <AdditionalIncludeDirectories>C:\Programme\C++\wxWidgets-x64\include;C:\Programme\C++\wxWidgets-x64\lib\vc_lib\mswu;C:\Program Files\C++\Boost</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>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>
@@ -213,12 +213,12 @@
<SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalDependencies>wxmsw28u_adv.lib;wxmsw28u_core.lib;wxbase28u.lib;wxpng.lib;wxzlib.lib;wxbase28u_net.lib;comctl32.lib;ws2_32.lib;winmm.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
- <AdditionalLibraryDirectories>C:\Programme\C++\wxWidgets-x64\lib\vc_lib;C:\Program Files\C++\Boost\stage64\lib</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>C:\Program Files\C++\wxWidgets-x64\lib\vc_lib;C:\Program Files\C++\Boost\stage64\lib</AdditionalLibraryDirectories>
<LinkStatus>
</LinkStatus>
</Link>
<ResourceCompile>
- <AdditionalIncludeDirectories>C:\Programme\C++\wxWidgets\include;C:\Programme\C++\wxWidgets\lib\vc_lib\mswu</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>C:\Program Files\C++\wxWidgets\include;C:\Program Files\C++\wxWidgets\lib\vc_lib\mswu</AdditionalIncludeDirectories>
<PreprocessorDefinitions>%(PreprocessorDefinitions);WX_CPU_AMD64</PreprocessorDefinitions>
<Culture>
</Culture>
@@ -237,12 +237,12 @@
<ClCompile Include="..\shared\global_func.cpp" />
<ClCompile Include="..\shared\help_provider.cpp" />
<ClCompile Include="..\shared\i18n.cpp" />
- <ClCompile Include="..\shared\long_path_prefix.cpp" />
+ <ClCompile Include="..\shared\localization.cpp" />
<ClCompile Include="..\shared\mouse_move_dlg.cpp" />
<ClCompile Include="..\shared\privilege.cpp" />
<ClCompile Include="..\shared\resolve_path.cpp" />
<ClCompile Include="..\shared\standard_paths.cpp" />
- <ClCompile Include="..\shared\system_func.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" />
diff --git a/RealtimeSync/application.cpp b/RealtimeSync/application.cpp
index 37f5c192..88e5ab53 100644
--- a/RealtimeSync/application.cpp
+++ b/RealtimeSync/application.cpp
@@ -9,7 +9,7 @@
#include <wx/event.h>
#include "resources.h"
#include <wx/msgdlg.h>
-#include "../shared/i18n.h"
+#include "../shared/localization.h"
#include "xml_ffs.h"
#include "../shared/standard_paths.h"
#include <wx/file.h>
@@ -42,11 +42,11 @@ 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(ffs3::wxToZ(ffs3::getResourceDir()) + "styles.rc"); //remove inner border from bitmap buttons
+ ::gtk_rc_parse(zen::wxToZ(zen::getResourceDir()) + "styles.rc"); //remove inner border from bitmap buttons
#endif
//set program language
- ffs3::setLanguage(rts::getProgramLanguage());
+ zen::setLanguage(rts::getProgramLanguage());
//try to set config/batch-filename set by %1 parameter
wxString cfgFilename;
@@ -90,7 +90,7 @@ int Application::OnRun()
catch (const std::exception& e) //catch all STL exceptions
{
//unfortunately it's not always possible to display a message box in this erroneous situation, however (non-stream) file output always works!
- wxFile safeOutput(ffs3::getConfigDir() + wxT("LastError.txt"), wxFile::write);
+ wxFile safeOutput(zen::getConfigDir() + wxT("LastError.txt"), wxFile::write);
safeOutput.Write(wxString::FromAscii(e.what()));
wxSafeShowMessage(_("An exception occurred!"), wxString::FromAscii(e.what()));
diff --git a/RealtimeSync/main_dlg.cpp b/RealtimeSync/main_dlg.cpp
index 05f0bc9b..b11ff848 100644
--- a/RealtimeSync/main_dlg.cpp
+++ b/RealtimeSync/main_dlg.cpp
@@ -24,7 +24,7 @@
#include "../shared/util.h"
#include "../shared/mouse_move_dlg.h"
-using namespace ffs3;
+using namespace zen;
MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName)
@@ -43,12 +43,11 @@ MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName)
Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(MainDialog::OnKeyPressed), NULL, this);
//prepare drag & drop
- dirNameFirst.reset(new ffs3::DirectoryName(*m_panelMainFolder, *m_dirPickerMain, *m_txtCtrlDirectoryMain, sbSizerDirToWatch));
+ dirNameFirst.reset(new zen::DirectoryName(*m_panelMainFolder, *m_dirPickerMain, *m_txtCtrlDirectoryMain, sbSizerDirToWatch));
#ifdef FFS_WIN
- new MouseMoveWindow(*this, //allow moving main dialog by clicking (nearly) anywhere...
- m_panelMain); //ownership passed to "this"
+ new MouseMoveWindow(*this); //ownership passed to "this"
#endif
@@ -121,7 +120,7 @@ void MainDialog::OnQuit(wxCommandEvent& event)
const wxString& MainDialog::lastConfigFileName()
{
- static wxString instance = ffs3::getConfigDir() + wxT("LastRun.ffs_real");
+ static wxString instance = zen::getConfigDir() + wxT("LastRun.ffs_real");
return instance;
}
@@ -129,9 +128,9 @@ const wxString& MainDialog::lastConfigFileName()
void MainDialog::OnShowHelp(wxCommandEvent& event)
{
#ifdef FFS_WIN
- ffs3::displayHelpEntry(wxT("html\\advanced\\RealtimeSync.html"));
+ zen::displayHelpEntry(wxT("html\\advanced\\RealtimeSync.html"));
#elif defined FFS_LINUX
- ffs3::displayHelpEntry(wxT("html/advanced/RealtimeSync.html"));
+ zen::displayHelpEntry(wxT("html/advanced/RealtimeSync.html"));
#endif
}
@@ -178,7 +177,7 @@ void MainDialog::OnStart(wxCommandEvent& event)
Hide();
- switch (rts::startDirectoryMonitor(currentCfg, ffs3::extractJobName(currentConfigFileName)))
+ switch (rts::startDirectoryMonitor(currentCfg, zen::extractJobName(currentConfigFileName)))
{
case rts::QUIT:
{
@@ -222,7 +221,7 @@ void MainDialog::OnSaveConfig(wxCommandEvent& event)
writeRealConfig(currentCfg, newFileName);
setLastUsedConfig(newFileName);
}
- catch (const ffs3::FileError& error)
+ catch (const zen::FileError& error)
{
wxMessageBox(error.msg().c_str(), _("Error"), wxOK | wxICON_ERROR);
}
@@ -283,14 +282,14 @@ void MainDialog::OnLoadConfig(wxCommandEvent& event)
void MainDialog::setConfiguration(const xmlAccess::XmlRealConfig& cfg)
{
//clear existing folders
- dirNameFirst->setName(Zstring());
+ dirNameFirst->setName(wxString());
clearAddFolders();
if (!cfg.directories.empty())
{
//fill top folder
- dirNameFirst->setName(wxToZ(*cfg.directories.begin()));
+ dirNameFirst->setName(*cfg.directories.begin());
//fill additional folders
addFolder(std::vector<wxString>(cfg.directories.begin() + 1, cfg.directories.end()));
@@ -308,9 +307,9 @@ xmlAccess::XmlRealConfig MainDialog::getConfiguration()
{
xmlAccess::XmlRealConfig output;
- output.directories.push_back(zToWx(dirNameFirst->getName()));
+ output.directories.push_back(dirNameFirst->getName());
for (std::vector<DirectoryPanel*>::const_iterator i = dirNamesExtra.begin(); i != dirNamesExtra.end(); ++i)
- output.directories.push_back(zToWx((*i)->getName()));
+ output.directories.push_back((*i)->getName());
output.commandline = m_textCtrlCommand->GetValue();
output.delay = m_spinCtrlDelay->GetValue();;
@@ -321,10 +320,10 @@ xmlAccess::XmlRealConfig MainDialog::getConfiguration()
void MainDialog::OnAddFolder(wxCommandEvent& event)
{
- const wxString topFolder = zToWx(dirNameFirst->getName());
+ const wxString topFolder = dirNameFirst->getName();
//clear existing top folder first
- dirNameFirst->setName(Zstring());
+ dirNameFirst->setName(wxString());
std::vector<wxString> newFolders;
newFolders.push_back(topFolder);
@@ -352,9 +351,9 @@ void MainDialog::OnRemoveTopFolder(wxCommandEvent& event)
{
if (dirNamesExtra.size() > 0)
{
- const wxString topDir = zToWx((*dirNamesExtra.begin())->getName());
+ const wxString topDir = (*dirNamesExtra.begin())->getName();
- dirNameFirst->setName(wxToZ(topDir));
+ dirNameFirst->setName(topDir);
removeAddFolder(0); //remove first of additional folders
}
@@ -400,7 +399,7 @@ void MainDialog::addFolder(const std::vector<wxString>& newFolders, bool addFron
newFolder->m_bpButtonRemoveFolder->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainDialog::OnRemoveFolder), NULL, this );
//insert directory name
- newFolder->setName(wxToZ(*i));
+ newFolder->setName(*i);
}
//set size of scrolled window
diff --git a/RealtimeSync/main_dlg.h b/RealtimeSync/main_dlg.h
index 8b06bec4..2ce04557 100644
--- a/RealtimeSync/main_dlg.h
+++ b/RealtimeSync/main_dlg.h
@@ -26,18 +26,11 @@ public:
FolderGenerated(parent),
dirName(*this, *m_dirPicker, *m_txtCtrlDirectory) {}
- void setName(const Zstring& dirname)
- {
- dirName.setName(dirname);
- }
-
- Zstring getName() const
- {
- return dirName.getName();
- }
+ void setName(const wxString& dirname) { dirName.setName(dirname); }
+ wxString getName() const { return dirName.getName(); }
private:
- ffs3::DirectoryName dirName;
+ zen::DirectoryName dirName;
};
@@ -76,7 +69,7 @@ private:
static const wxString& lastConfigFileName();
- std::auto_ptr<ffs3::DirectoryName> dirNameFirst;
+ std::auto_ptr<zen::DirectoryName> dirNameFirst;
std::vector<DirectoryPanel*> dirNamesExtra; //additional pairs to the standard pair
wxString currentConfigFileName;
diff --git a/RealtimeSync/makefile b/RealtimeSync/makefile
index 5f797cce..8f9e4863 100644
--- a/RealtimeSync/makefile
+++ b/RealtimeSync/makefile
@@ -28,13 +28,14 @@ FILE_LIST+=../library/process_xml.cpp
FILE_LIST+=../structures.cpp
FILE_LIST+=../shared/util.cpp
FILE_LIST+=../shared/check_exist.cpp
-FILE_LIST+=../shared/i18n_no_BOM.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/system_func.cpp
+FILE_LIST+=../shared/last_error.cpp
FILE_LIST+=../shared/dir_name.cpp
FILE_LIST+=../shared/zstring.cpp
FILE_LIST+=../shared/xml_base.cpp
@@ -58,9 +59,6 @@ all: RealtimeSync
init:
if [ ! -d ../OBJ ]; then mkdir ../OBJ; fi
if [ ! -d ../OBJ/RTS_Release_GCC_Make ]; then mkdir ../OBJ/RTS_Release_GCC_Make; fi
-#remove byte ordering mark: needed by Visual C++ but an error with GCC
- g++ -o ../OBJ/RTS_Release_GCC_Make/removeBOM ../tools/remove_BOM.cpp
- ../OBJ/RTS_Release_GCC_Make/removeBOM ../shared/i18n.cpp ../shared/i18n_no_BOM.cpp
%.dep : %.cpp
#strip path information
@@ -73,7 +71,6 @@ RealtimeSync: init $(DEP_LIST)
clean:
rm -rf ../OBJ/RTS_Release_GCC_Make
rm -f ../BUILD/$(APPNAME)
- rm -f ../shared/i18n_no_BOM.cpp
install:
if [ ! -d $(BINDIR) ] ; then mkdir -p $(BINDIR); fi
diff --git a/RealtimeSync/notify.cpp b/RealtimeSync/notify.cpp
index 62c80940..5969ee08 100644
--- a/RealtimeSync/notify.cpp
+++ b/RealtimeSync/notify.cpp
@@ -6,13 +6,13 @@
//
#include "notify.h"
#include <set>
-#include "../shared/system_func.h"
+#include "../shared/last_error.h"
#include "../shared/Loki/ScopeGuard.h"
#include <algorithm>
#include <boost/bind.hpp>
#include <dbt.h>
-using namespace ffs3;
+using namespace zen;
/*
@@ -99,8 +99,8 @@ MessageProvider::MessageProvider() :
windowHandle(NULL)
{
if (process == NULL)
- throw ffs3::FileError(wxString(wxT("Could not start monitoring window notifications:")) + wxT("\n\n") +
- ffs3::getLastErrorFormatted() + wxT(" (GetModuleHandle)"));
+ throw zen::FileError(wxString(wxT("Could not start monitoring window notifications:")) + wxT("\n\n") +
+ zen::getLastErrorFormatted() + wxT(" (GetModuleHandle)"));
//register the main window class
WNDCLASS wc = {};
@@ -109,8 +109,8 @@ MessageProvider::MessageProvider() :
wc.lpszClassName = WINDOW_NAME;
if (::RegisterClass(&wc) == 0)
- throw ffs3::FileError(wxString(wxT("Could not start monitoring window notifications:")) + wxT("\n\n") +
- ffs3::getLastErrorFormatted() + wxT(" (RegisterClass)"));
+ throw zen::FileError(wxString(wxT("Could not start monitoring window notifications:")) + wxT("\n\n") +
+ zen::getLastErrorFormatted() + wxT(" (RegisterClass)"));
Loki::ScopeGuard guardClass = Loki::MakeGuard(::UnregisterClass, WINDOW_NAME, process);
@@ -128,8 +128,8 @@ MessageProvider::MessageProvider() :
process, //HINSTANCE hInstance,
NULL); //LPVOID lpParam
if (windowHandle == NULL)
- throw ffs3::FileError(wxString(wxT("Could not start monitoring window notifications:")) + wxT("\n\n") +
- ffs3::getLastErrorFormatted() + wxT(" (CreateWindow)"));
+ throw zen::FileError(wxString(wxT("Could not start monitoring window notifications:")) + wxT("\n\n") +
+ zen::getLastErrorFormatted() + wxT(" (CreateWindow)"));
guardClass.Dismiss();
}
@@ -201,7 +201,7 @@ public:
if (lastError != ERROR_CALL_NOT_IMPLEMENTED && //fail on SAMBA share: this shouldn't be a showstopper!
lastError != ERROR_SERVICE_SPECIFIC_ERROR && //neither should be fail for "Pogoplug" mapped network drives
lastError != ERROR_INVALID_DATA) //this seems to happen for a NetDrive-mapped FTP server
- throw ffs3::FileError(wxString(wxT("Could not register device removal notifications:")) + wxT("\n\n") + ffs3::getLastErrorFormatted(lastError));
+ throw zen::FileError(wxString(wxT("Could not register device removal notifications:")) + wxT("\n\n") + zen::getLastErrorFormatted(lastError));
}
else
notifications.insert(hNotfication);
diff --git a/RealtimeSync/resources.cpp b/RealtimeSync/resources.cpp
index 64de4700..24356ff8 100644
--- a/RealtimeSync/resources.cpp
+++ b/RealtimeSync/resources.cpp
@@ -13,7 +13,7 @@
#include "../shared/standard_paths.h"
#include "../shared/system_constants.h"
-using namespace ffs3;
+using namespace zen;
const GlobalResources& GlobalResources::getInstance()
@@ -42,7 +42,7 @@ GlobalResources::~GlobalResources()
void GlobalResources::load() const
{
- wxFFileInputStream input(ffs3::getResourceDir() + wxT("Resources.dat"));
+ wxFFileInputStream input(zen::getResourceDir() + wxT("Resources.dat"));
if (input.IsOk()) //if not... we don't want to react too harsh here
{
//activate support for .png files
diff --git a/RealtimeSync/tray_menu.cpp b/RealtimeSync/tray_menu.cpp
index fbfc3167..d42aea0a 100644
--- a/RealtimeSync/tray_menu.cpp
+++ b/RealtimeSync/tray_menu.cpp
@@ -8,6 +8,7 @@
#include <algorithm>
#include <iterator>
#include <limits>
+#include <set>
#include <wx/msgdlg.h>
#include <wx/taskbar.h>
#include <wx/app.h>
@@ -23,6 +24,7 @@
#include "../shared/i18n.h"
#include "../shared/assert_static.h"
#include "../shared/build_info.h"
+#include "../shared/shell_execute.h"
using namespace rts;
@@ -225,7 +227,7 @@ std::vector<Zstring> convert(const std::vector<wxString>& dirList)
{
std::set<Zstring, LessFilename> output;
std::transform(dirList.begin(), dirList.end(),
- std::inserter(output, output.end()), static_cast<Zstring (*)(const wxString&)>(ffs3::wxToZ));
+ std::inserter(output, output.end()), static_cast<Zstring (*)(const wxString&)>(zen::wxToZ));
return std::vector<Zstring>(output.begin(), output.end());
}
}
@@ -296,7 +298,11 @@ rts::MonitorResponse rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig&
WaitCallbackImpl callback(jobname);
if (config.commandline.empty())
- throw ffs3::FileError(_("Command line is empty!"));
+ {
+ wxString errorMsg = _("Invalid commandline: \"%x\"");
+ errorMsg.Replace(L"%x", config.commandline);
+ throw zen::FileError(errorMsg);
+ }
callback.notifyDirectoryMissing();
waitForMissingDirs(dirList, &callback);
@@ -305,12 +311,7 @@ rts::MonitorResponse rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig&
while (true)
{
//execute command
- {
- //by default wxExecute uses a zero sized dummy window as a hack to keep focus which leaves a useless empty icon in ALT-TAB list
- //=> use wxEXEC_NODISABLE and roll our own window disabler! (see comment in app.cpp: void *wxGUIAppTraits::BeforeChildWaitLoop())
- wxWindowDisabler dummy; //disables all top level windows
- wxExecute(config.commandline, wxEXEC_SYNC | wxEXEC_NODISABLE);
- }
+ zen::shellExecute(config.commandline, zen::EXEC_TYPE_SYNC);
wxLog::FlushActive(); //show wxWidgets error messages (if any)
@@ -343,7 +344,7 @@ rts::MonitorResponse rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig&
{
return ab.getCommand();
}
- catch (const ffs3::FileError& error)
+ catch (const zen::FileError& error)
{
wxMessageBox(error.msg(), _("Error"), wxOK | wxICON_ERROR);
return RESUME;
diff --git a/RealtimeSync/watcher.cpp b/RealtimeSync/watcher.cpp
index a8b703a6..7cd062b7 100644
--- a/RealtimeSync/watcher.cpp
+++ b/RealtimeSync/watcher.cpp
@@ -5,7 +5,7 @@
// **************************************************************************
//
#include "watcher.h"
-#include "../shared/system_func.h"
+#include "../shared/last_error.h"
#include "../shared/string_conv.h"
#include "../shared/file_handling.h"
#include "../shared/i18n.h"
@@ -28,7 +28,7 @@
#include "../shared/file_traverser.h"
#endif
-using namespace ffs3;
+using namespace zen;
bool rts::updateUiIsAllowed()
@@ -57,7 +57,7 @@ void cleanUpChangeNotifications(const std::vector<HANDLE>* handles)
}
#elif defined FFS_LINUX
-class DirsOnlyTraverser : public ffs3::TraverseCallback
+class DirsOnlyTraverser : public zen::TraverseCallback
{
public:
DirsOnlyTraverser(std::vector<std::string>& dirs) : m_dirs(dirs) {}
@@ -71,7 +71,7 @@ public:
}
virtual void onError(const wxString& errorText)
{
- throw ffs3::FileError(errorText);
+ throw zen::FileError(errorText);
}
private:
@@ -99,7 +99,7 @@ public:
if (current - lastCheck >= UPDATE_INTERVAL)
{
lastCheck = current;
- allExisting_ = std::find_if(dirList.begin(), dirList.end(), std::not1(std::ptr_fun(&ffs3::dirExists))) == dirList.end();
+ allExisting_ = std::find_if(dirList.begin(), dirList.end(), std::not1(std::ptr_fun(&zen::dirExists))) == dirList.end();
}
return allExisting_;
@@ -119,12 +119,12 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
/*
#warning cleanup
{
- const Zstring formattedDir = ffs3::getFormattedDirectoryName(dirNames.front());
+ const Zstring formattedDir = zen::getFormattedDirectoryName(dirNames.front());
//SE_BACKUP_NAME and SE_RESTORE_NAME <- required by FILE_FLAG_BACKUP_SEMANTICS???
//open the directory to watch....
- HANDLE hDir = ::CreateFile(ffs3::applyLongPathPrefix(formattedDir).c_str(),
+ HANDLE hDir = ::CreateFile(zen::applyLongPathPrefix(formattedDir).c_str(),
FILE_LIST_DIRECTORY,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, //leaving out last flag may prevent files to be deleted WITHIN monitored dir (http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw_19.html)
NULL,
@@ -139,7 +139,7 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
return CHANGE_DIR_MISSING;
const wxString errorMessage = wxString(_("Could not initialize directory monitoring:")) + wxT("\n\"") + zToWx(formattedDir) + wxT("\"");
- throw ffs3::FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted());
+ throw zen::FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted());
}
Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hDir);
@@ -166,7 +166,7 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
NULL)) //__in_opt LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
{
const wxString errorMessage = wxString(_("Could not initialize directory monitoring:")) + wxT("\n\"") + zToWx(formattedDir) + wxT("\"");
- throw ffs3::FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted());
+ throw zen::FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted());
}
return CHANGE_DETECTED;
}
@@ -181,7 +181,7 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
if (dirNames.empty()) //pathological case, but check is needed nevertheless
- throw ffs3::FileError(_("A directory input field is empty."));
+ throw zen::FileError(_("A directory input field is empty."));
//detect when volumes are removed/are not available anymore
WatchDirectories dirWatcher;
@@ -192,15 +192,15 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
for (std::vector<Zstring>::const_iterator i = dirNames.begin(); i != dirNames.end(); ++i)
{
- const Zstring formattedDir = ffs3::getFormattedDirectoryName(*i);
+ const Zstring formattedDir = zen::getFormattedDirectoryName(*i);
if (formattedDir.empty())
- throw ffs3::FileError(_("A directory input field is empty."));
+ throw zen::FileError(_("A directory input field is empty."));
dirWatcher.addForMonitoring(formattedDir);
const HANDLE rv = ::FindFirstChangeNotification(
- ffs3::applyLongPathPrefix(formattedDir).c_str(), //__in LPCTSTR lpPathName,
+ zen::applyLongPathPrefix(formattedDir).c_str(), //__in LPCTSTR lpPathName,
true, //__in BOOL bWatchSubtree,
FILE_NOTIFY_CHANGE_FILE_NAME |
FILE_NOTIFY_CHANGE_DIR_NAME |
@@ -215,14 +215,14 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
return CHANGE_DIR_MISSING;
const wxString errorMessage = wxString(_("Could not initialize directory monitoring:")) + wxT("\n\"") + zToWx(formattedDir) + wxT("\"");
- throw ffs3::FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted());
+ throw zen::FileError(errorMessage + wxT("\n\n") + zen::getLastErrorFormatted());
}
changeNotifications->push_back(rv);
}
if (changeNotifications->size() == 0)
- throw ffs3::FileError(_("A directory input field is empty."));
+ throw zen::FileError(_("A directory input field is empty."));
//detect user request for device removal (e.g. usb stick)
@@ -272,7 +272,7 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
if (WAIT_OBJECT_0 <= rv && rv < WAIT_OBJECT_0 + changeNotifications->size())
return CHANGE_DETECTED; //directory change detected
else if (rv == WAIT_FAILED)
- throw ffs3::FileError(wxString(_("Error when monitoring directories.")) + wxT("\n\n") + ffs3::getLastErrorFormatted());
+ throw zen::FileError(wxString(_("Error when monitoring directories.")) + wxT("\n\n") + zen::getLastErrorFormatted());
//else if (rv == WAIT_TIMEOUT)
if (!dirWatcher.allExisting()) //check for removed devices:
@@ -299,10 +299,10 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
//add all subdirectories
for (std::vector<Zstring>::const_iterator i = dirNames.begin(); i != dirNames.end(); ++i)
{
- const Zstring formattedDir = ffs3::getFormattedDirectoryName(*i);
+ const Zstring formattedDir = zen::getFormattedDirectoryName(*i);
if (formattedDir.empty())
- throw ffs3::FileError(_("A directory input field is empty."));
+ throw zen::FileError(_("A directory input field is empty."));
dirWatcher.addForMonitoring(formattedDir);
@@ -312,11 +312,11 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
try //get all subdirectories
{
DirsOnlyTraverser traverser(fullDirList);
- ffs3::traverseFolder(formattedDir, false, traverser); //don't traverse into symlinks (analog to windows build)
+ zen::traverseFolder(formattedDir, false, traverser); //don't traverse into symlinks (analog to windows build)
}
- catch (const ffs3::FileError&)
+ catch (const zen::FileError&)
{
- if (!ffs3::dirExists(formattedDir)) //that's no good locking behavior, but better than nothing
+ if (!zen::dirExists(formattedDir)) //that's no good locking behavior, but better than nothing
return CHANGE_DIR_MISSING;
throw;
@@ -347,17 +347,17 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
}
catch (const InotifyException& e)
{
- if (!ffs3::dirExists(i->c_str())) //that's no good locking behavior, but better than nothing
+ if (!zen::dirExists(i->c_str())) //that's no good locking behavior, but better than nothing
return CHANGE_DIR_MISSING;
const wxString errorMessage = wxString(_("Could not initialize directory monitoring:")) + wxT("\n\"") + zToWx(i->c_str()) + wxT("\"");
- throw ffs3::FileError(errorMessage + wxT("\n\n") + zToWx(e.GetMessage().c_str()));
+ throw zen::FileError(errorMessage + wxT("\n\n") + zToWx(e.GetMessage().c_str()));
}
}
if (notifications.GetWatchCount() == 0)
- throw ffs3::FileError(_("A directory input field is empty."));
+ throw zen::FileError(_("A directory input field is empty."));
while (true)
{
@@ -375,11 +375,11 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
}
catch (const InotifyException& e)
{
- throw ffs3::FileError(wxString(_("Error when monitoring directories.")) + wxT("\n\n") + zToWx(e.GetMessage().c_str()));
+ throw zen::FileError(wxString(_("Error when monitoring directories.")) + wxT("\n\n") + zToWx(e.GetMessage().c_str()));
}
catch (const std::exception& e)
{
- throw ffs3::FileError(wxString(_("Error when monitoring directories.")) + wxT("\n\n") + zToWx(e.what()));
+ throw zen::FileError(wxString(_("Error when monitoring directories.")) + wxT("\n\n") + zToWx(e.what()));
}
#endif
}
@@ -403,12 +403,12 @@ void rts::waitForMissingDirs(const std::vector<Zstring>& dirNames, WaitCallback*
for (std::vector<Zstring>::const_iterator i = dirNames.begin(); i != dirNames.end(); ++i)
{
//support specifying volume by name => call getFormattedDirectoryName() repeatedly
- const Zstring formattedDir = ffs3::getFormattedDirectoryName(*i);
+ const Zstring formattedDir = zen::getFormattedDirectoryName(*i);
if (formattedDir.empty())
- throw ffs3::FileError(_("A directory input field is empty."));
+ throw zen::FileError(_("A directory input field is empty."));
- if (!ffs3::dirExists(formattedDir))
+ if (!zen::dirExists(formattedDir))
{
allExisting = false;
break;
diff --git a/RealtimeSync/xml_ffs.cpp b/RealtimeSync/xml_ffs.cpp
index 1c98cc57..03d266df 100644
--- a/RealtimeSync/xml_ffs.cpp
+++ b/RealtimeSync/xml_ffs.cpp
@@ -15,7 +15,7 @@
//include FreeFileSync xml headers
#include "../library/process_xml.h"
-using namespace ffs3;
+using namespace zen;
#ifdef FFS_WIN
@@ -44,7 +44,7 @@ xmlAccess::XmlRealConfig convertBatchToReal(const xmlAccess::XmlBatchConfig& bat
uniqueFolders.insert(zToWx(batchCfg.mainCfg.firstPair.rightDirectory));
//additional folders
- for (std::vector<ffs3::FolderPairEnh>::const_iterator i = batchCfg.mainCfg.additionalPairs.begin();
+ for (std::vector<zen::FolderPairEnh>::const_iterator i = batchCfg.mainCfg.additionalPairs.begin();
i != batchCfg.mainCfg.additionalPairs.end(); ++i)
{
uniqueFolders.insert(zToWx(i->leftDirectory));
@@ -55,13 +55,8 @@ xmlAccess::XmlRealConfig convertBatchToReal(const xmlAccess::XmlBatchConfig& bat
output.directories.insert(output.directories.end(), uniqueFolders.begin(), uniqueFolders.end());
- output.commandline = wxT("\"") + ffs3::getBinaryDir() +
-#ifdef FFS_WIN
- wxT("FreeFileSync.exe") +
-#elif defined FFS_LINUX
- wxT("FreeFileSync") +
-#endif
- wxT("\" \"") + filename + wxT("\"");
+ output.commandline = wxT("\"") + zen::getLauncher() + wxT("\"") +
+ wxT(" \"") + filename + wxT("\"");
return output;
}
@@ -69,7 +64,7 @@ xmlAccess::XmlRealConfig convertBatchToReal(const xmlAccess::XmlBatchConfig& bat
void rts::readRealOrBatchConfig(const wxString& filename, xmlAccess::XmlRealConfig& config) //throw (xmlAccess::XmlError);
{
- if (xmlAccess::getXmlType(filename) != xmlAccess::XML_BATCH_CONFIG)
+ if (xmlAccess::getXmlType(filename) != xmlAccess::XML_TYPE_BATCH)
{
xmlAccess::readRealConfig(filename, config);
return;
diff --git a/RealtimeSync/xml_proc.cpp b/RealtimeSync/xml_proc.cpp
index 4d7f88e0..4eaf8769 100644
--- a/RealtimeSync/xml_proc.cpp
+++ b/RealtimeSync/xml_proc.cpp
@@ -9,83 +9,103 @@
#include "../shared/i18n.h"
-class RtsXmlParser : public xmlAccess::XmlParser
+using namespace xmlAccess;
+
+class RtsXmlErrorLogger : public xmlAccess::XmlErrorLogger
{
public:
- RtsXmlParser(const TiXmlElement* rootElement) : xmlAccess::XmlParser(rootElement) {}
-
- void readXmlRealConfig(xmlAccess::XmlRealConfig& outputCfg);
+ void readConfig(const TiXmlElement* root, xmlAccess::XmlRealConfig& outputCfg);
};
-
-void readXmlRealConfig(const TiXmlDocument& doc, xmlAccess::XmlRealConfig& outputCfg);
-bool writeXmRealSettings(const xmlAccess::XmlRealConfig& outputCfg, TiXmlDocument& doc);
+//--------------------------------------------------------------------------------
-void xmlAccess::readRealConfig(const wxString& filename, XmlRealConfig& config)
+void RtsXmlErrorLogger::readConfig(const TiXmlElement* root, xmlAccess::XmlRealConfig& outputCfg)
{
- //load XML
- if (!wxFileExists(filename))
- throw XmlError(wxString(_("File does not exist:")) + wxT("\n\"") + filename + wxT("\""));
+ //read directories for monitoring
+ const TiXmlElement* directoriesToWatch = TiXmlHandleConst(root).FirstChild("Directories").ToElement();
- TiXmlDocument doc;
- loadXmlDocument(filename, XML_REAL_CONFIG, doc); //throw (XmlError)
+ readXmlElementLogging("Folder", directoriesToWatch, outputCfg.directories);
- RtsXmlParser parser(doc.RootElement());
- parser.readXmlRealConfig(config); //read GUI layout configuration
+ //commandline to execute
+ readXmlElementLogging("Commandline", root, outputCfg.commandline);
- if (parser.errorsOccurred())
- throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"\n\n") +
- parser.getErrorMessageFormatted(), XmlError::WARNING);
+ //delay
+ readXmlElementLogging("Delay", root, outputCfg.delay);
}
-void xmlAccess::writeRealConfig(const XmlRealConfig& outputCfg, const wxString& filename)
+void writeConfig(const xmlAccess::XmlRealConfig& outputCfg, TiXmlElement& root)
{
- TiXmlDocument doc;
- getDefaultXmlDocument(XML_REAL_CONFIG, doc);
+ //directories to monitor
+ TiXmlElement* directoriesToWatch = new TiXmlElement("Directories");
+ root.LinkEndChild(directoriesToWatch);
+ xmlAccess::addXmlElement("Folder", outputCfg.directories, directoriesToWatch);
- //populate and write XML tree
- if (!writeXmRealSettings(outputCfg, doc)) //add GUI layout configuration settings
- throw XmlError(wxString(_("Error writing file:")) + wxT("\n\"") + filename + wxT("\""));
+ //commandline to execute
+ xmlAccess::addXmlElement("Commandline", outputCfg.commandline, &root);
- saveXmlDocument(filename, doc); //throw (XmlError)
+ //delay
+ xmlAccess::addXmlElement("Delay", outputCfg.delay, &root);
}
-//--------------------------------------------------------------------------------
-
-void RtsXmlParser::readXmlRealConfig(xmlAccess::XmlRealConfig& outputCfg)
+bool isXmlTypeRTS(const TiXmlDocument& doc) //throw()
{
- //read directories for monitoring
- const TiXmlElement* directoriesToWatch = TiXmlHandleConst(getRoot()).FirstChild("Directories").ToElement();
+ const TiXmlElement* root = doc.RootElement();
+ if (root && root->ValueStr() == std::string("RealtimeSync"))
+ {
+ const char* cfgType = root->Attribute("XmlType");
+ if (cfgType)
+ return std::string(cfgType) == "REAL";
+ }
+ return false;
+}
- readXmlElementLogging("Folder", directoriesToWatch, outputCfg.directories);
- //commandline to execute
- readXmlElementLogging("Commandline", getRoot(), outputCfg.commandline);
+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);
- //delay
- readXmlElementLogging("Delay", getRoot(), outputCfg.delay);
+ TiXmlElement* root = new TiXmlElement("RealtimeSync");
+ doc.LinkEndChild(root);
+
+ addXmlAttribute("XmlType", "REAL", doc.RootElement());
}
-bool writeXmRealSettings(const xmlAccess::XmlRealConfig& outputCfg, TiXmlDocument& doc)
+void xmlAccess::readRealConfig(const wxString& filename, XmlRealConfig& config)
{
- TiXmlElement* root = doc.RootElement();
- if (!root) return false;
+ //load XML
+ if (!wxFileExists(filename))
+ throw XmlError(wxString(_("File does not exist:")) + wxT("\n\"") + filename + wxT("\""));
- //directories to monitor
- TiXmlElement* directoriesToWatch = new TiXmlElement("Directories");
- root->LinkEndChild(directoriesToWatch);
- xmlAccess::addXmlElement("Folder", outputCfg.directories, directoriesToWatch);
+ TiXmlDocument doc;
+ loadXmlDocument(filename, doc); //throw (XmlError)
- //commandline to execute
- xmlAccess::addXmlElement("Commandline", outputCfg.commandline, root);
+ if (!isXmlTypeRTS(doc))
+ throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\""));
- //delay
- xmlAccess::addXmlElement("Delay", outputCfg.delay, root);
+ RtsXmlErrorLogger parser;
+ parser.readConfig(doc.RootElement(), config); //read GUI layout configuration
- return true;
+ if (parser.errorsOccurred())
+ throw XmlError(wxString(_("Error parsing configuration file:")) + wxT("\n\"") + filename + wxT("\"\n\n") +
+ parser.getErrorMessageFormatted(), XmlError::WARNING);
+}
+
+
+void xmlAccess::writeRealConfig(const XmlRealConfig& outputCfg, const wxString& filename)
+{
+ TiXmlDocument doc;
+ initXmlDocument(doc); //throw()
+
+ if (!doc.RootElement())
+ throw XmlError(wxString(_("Error writing file:")) + wxT("\n\"") + filename + wxT("\""));
+
+ writeConfig(outputCfg, *doc.RootElement()); //add GUI layout configuration settings
+
+ saveXmlDocument(filename, doc); //throw (XmlError)
}
bgstack15