diff options
Diffstat (limited to 'RealtimeSync')
-rw-r--r-- | RealtimeSync/RealtimeSync.cbp | 14 | ||||
-rw-r--r-- | RealtimeSync/RealtimeSync.vcxproj | 18 | ||||
-rw-r--r-- | RealtimeSync/functions.cpp | 22 | ||||
-rw-r--r-- | RealtimeSync/functions.h | 21 | ||||
-rw-r--r-- | RealtimeSync/gui_generated.cpp | 10 | ||||
-rw-r--r-- | RealtimeSync/gui_generated.h | 8 | ||||
-rw-r--r-- | RealtimeSync/main_dlg.cpp | 64 | ||||
-rw-r--r-- | RealtimeSync/main_dlg.h | 28 | ||||
-rw-r--r-- | RealtimeSync/makefile | 12 | ||||
-rw-r--r-- | RealtimeSync/notify.cpp | 10 | ||||
-rw-r--r-- | RealtimeSync/resource.rc | 16 | ||||
-rw-r--r-- | RealtimeSync/tray_menu.cpp | 136 | ||||
-rw-r--r-- | RealtimeSync/watcher.cpp | 6 | ||||
-rw-r--r-- | RealtimeSync/xml_ffs.cpp | 2 | ||||
-rw-r--r-- | RealtimeSync/xml_proc.h | 2 |
15 files changed, 196 insertions, 173 deletions
diff --git a/RealtimeSync/RealtimeSync.cbp b/RealtimeSync/RealtimeSync.cbp index e423cbfb..701e8c9c 100644 --- a/RealtimeSync/RealtimeSync.cbp +++ b/RealtimeSync/RealtimeSync.cbp @@ -27,7 +27,7 @@ <Add library="libwxbase28u.a" /> <Add library="libwxpng.a" /> <Add library="libwxzlib.a" /> - <Add library="libboost_thread-mgw45-mt-s-1_43.a" /> + <Add library="libboost_thread-mgw45-mt-s-1_44.a" /> <Add directory="C:\Programme\C++\wxWidgets\lib\gcc_lib" /> </Linker> </Target> @@ -51,7 +51,7 @@ <Add library="libwxbase28ud.a" /> <Add library="libwxpngd.a" /> <Add library="libwxzlibd.a" /> - <Add library="libboost_thread-mgw45-mt-sd-1_43.a" /> + <Add library="libboost_thread-mgw45-mt-sd-1_44.a" /> <Add directory="C:\Program Files\C++\wxWidgets\lib\gcc_dll" /> </Linker> </Target> @@ -68,8 +68,9 @@ <Add option="-D__WXMSW__" /> <Add option="-DwxUSE_UNICODE" /> <Add option="-DFFS_WIN" /> - <Add option="-DZSTRING_WIDE_CHAR" /> <Add option="-DTIXML_USE_STL" /> + <Add option="-DBOOST_THREAD_NO_LIB" /> + <Add option="-DBOOST_THREAD_USE_LIB" /> <Add directory="C:\Programme\C++\wxWidgets\include" /> <Add directory="C:\Program Files\C++\Boost" /> </Compiler> @@ -94,7 +95,6 @@ <Unit filename="WxWizDialog.fbp" /> <Unit filename="application.cpp" /> <Unit filename="application.h" /> - <Unit filename="functions.cpp" /> <Unit filename="functions.h" /> <Unit filename="gui_generated.cpp" /> <Unit filename="gui_generated.h" /> @@ -122,14 +122,16 @@ <Unit filename="xml_proc.h" /> <Unit filename="..\Shared\custom_button.cpp" /> <Unit filename="..\Shared\custom_button.h" /> - <Unit filename="..\Shared\drag_n_drop.cpp" /> - <Unit filename="..\Shared\drag_n_drop.h" /> + <Unit filename="..\Shared\dir_name.cpp" /> + <Unit filename="..\Shared\dir_name.h" /> <Unit filename="..\Shared\zstring.cpp" /> <Unit filename="..\Shared\zstring.h" /> <Unit filename="..\library\process_xml.cpp" /> <Unit filename="..\shared\check_exist.cpp" /> <Unit filename="..\shared\dll_loader.cpp" /> <Unit filename="..\shared\dll_loader.h" /> + <Unit filename="..\shared\dst_hack.cpp" /> + <Unit filename="..\shared\dst_hack.h" /> <Unit filename="..\shared\file_error.h" /> <Unit filename="..\shared\file_handling.cpp" /> <Unit filename="..\shared\file_handling.h" /> diff --git a/RealtimeSync/RealtimeSync.vcxproj b/RealtimeSync/RealtimeSync.vcxproj index 4812a3d0..858c909b 100644 --- a/RealtimeSync/RealtimeSync.vcxproj +++ b/RealtimeSync/RealtimeSync.vcxproj @@ -99,10 +99,10 @@ <PrecompiledHeader>Use</PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;__WXDEBUG__;TIXML_USE_STL;ZSTRING_WIDE_CHAR</PreprocessorDefinitions> + <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;__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> <PrecompiledHeaderFile>$(ProjectDir)/pch.h</PrecompiledHeaderFile> - <DisableSpecificWarnings>4100</DisableSpecificWarnings> + <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings> <MultiProcessorCompilation>false</MultiProcessorCompilation> <DisableLanguageExtensions>false</DisableLanguageExtensions> <PrecompiledHeaderOutputFile>$(IntDir)pch.obj</PrecompiledHeaderOutputFile> @@ -129,10 +129,10 @@ <PrecompiledHeader>Use</PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;__WXDEBUG__;TIXML_USE_STL;ZSTRING_WIDE_CHAR</PreprocessorDefinitions> + <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;__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> <PrecompiledHeaderFile>$(ProjectDir)/pch.h</PrecompiledHeaderFile> - <DisableSpecificWarnings>4100</DisableSpecificWarnings> + <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings> <MultiProcessorCompilation>false</MultiProcessorCompilation> <DisableLanguageExtensions>false</DisableLanguageExtensions> <PrecompiledHeaderOutputFile>$(IntDir)pch.obj</PrecompiledHeaderOutputFile> @@ -162,7 +162,7 @@ <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;NDEBUG;TIXML_USE_STL;ZSTRING_WIDE_CHAR</PreprocessorDefinitions> + <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;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> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings> @@ -196,10 +196,10 @@ <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;NDEBUG;TIXML_USE_STL;ZSTRING_WIDE_CHAR</PreprocessorDefinitions> + <PreprocessorDefinitions>wxUSE_UNICODE;__WXMSW__;FFS_WIN;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> <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> - <DisableSpecificWarnings>4100</DisableSpecificWarnings> + <DisableSpecificWarnings>4100;4996</DisableSpecificWarnings> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <MultiProcessorCompilation>true</MultiProcessorCompilation> <DisableLanguageExtensions>false</DisableLanguageExtensions> @@ -229,7 +229,8 @@ <ClCompile Include="..\shared\check_exist.cpp" /> <ClCompile Include="..\shared\custom_button.cpp" /> <ClCompile Include="..\shared\dll_loader.cpp" /> - <ClCompile Include="..\shared\drag_n_drop.cpp" /> + <ClCompile Include="..\shared\dir_name.cpp" /> + <ClCompile Include="..\shared\dst_hack.cpp" /> <ClCompile Include="..\shared\file_handling.cpp" /> <ClCompile Include="..\shared\file_io.cpp" /> <ClCompile Include="..\shared\file_traverser.cpp" /> @@ -251,7 +252,6 @@ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> <PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)/pch.h</PrecompiledHeaderFile> </ClCompile> - <ClCompile Include="functions.cpp" /> <ClCompile Include="gui_generated.cpp" /> <ClCompile Include="main_dlg.cpp" /> <ClCompile Include="notify.cpp" /> diff --git a/RealtimeSync/functions.cpp b/RealtimeSync/functions.cpp deleted file mode 100644 index f66db6b4..00000000 --- a/RealtimeSync/functions.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// ************************************************************************** -// * 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-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// -#include "functions.h" -#include <wx/textctrl.h> -#include <wx/filepicker.h> -#include "../shared/string_conv.h" -#include "../shared/file_handling.h" - -using namespace ffs3; - -void rts::setDirectoryName(const wxString& dirname, wxTextCtrl* txtCtrl, wxDirPickerCtrl* dirPicker) -{ - txtCtrl->SetValue(dirname); - const Zstring leftDirFormatted = ffs3::getFormattedDirectoryName(wxToZ(dirname)); - if (dirExists(leftDirFormatted)) - dirPicker->SetPath(zToWx(leftDirFormatted)); -} - diff --git a/RealtimeSync/functions.h b/RealtimeSync/functions.h deleted file mode 100644 index 5b20ee9e..00000000 --- a/RealtimeSync/functions.h +++ /dev/null @@ -1,21 +0,0 @@ -// ************************************************************************** -// * 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-2010 ZenJu (zhnmju123 AT gmx.de) * -// ************************************************************************** -// -#ifndef FUNCTIONS_H_INCLUDED -#define FUNCTIONS_H_INCLUDED - -#include <wx/string.h> - -class wxTextCtrl; -class wxDirPickerCtrl; - - -namespace rts -{ -void setDirectoryName(const wxString& dirname, wxTextCtrl* txtCtrl, wxDirPickerCtrl* dirPicker); -} - -#endif // FUNCTIONS_H_INCLUDED diff --git a/RealtimeSync/gui_generated.cpp b/RealtimeSync/gui_generated.cpp index 5bdae20e..6b15a5eb 100644 --- a/RealtimeSync/gui_generated.cpp +++ b/RealtimeSync/gui_generated.cpp @@ -152,19 +152,19 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr bSizer1->Add( sbSizer3, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 ); - m_staticline1 = new wxStaticLine( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizer1->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxBOTTOM, 10 ); - wxStaticBoxSizer* sbSizer4; - sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( m_panelMain, wxID_ANY, _("Delay") ), wxVERTICAL ); + sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( m_panelMain, wxID_ANY, _("Minimum Idle Time") ), wxVERTICAL ); m_spinCtrlDelay = new wxSpinCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 2000000000, 0 ); - m_spinCtrlDelay->SetToolTip( _("Delay between detection of changes and execution of command line in seconds") ); + m_spinCtrlDelay->SetToolTip( _("Idle time between detection of last change and execution of command line in seconds") ); sbSizer4->Add( m_spinCtrlDelay, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_HORIZONTAL, 5 ); bSizer1->Add( sbSizer4, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + m_staticline1 = new wxStaticLine( m_panelMain, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer1->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxBOTTOM, 10 ); + m_buttonStart = new wxButtonWithImage( m_panelMain, wxID_ANY, _("Start"), wxDefaultPosition, wxSize( -1,40 ), 0 ); m_buttonStart->SetDefault(); m_buttonStart->SetFont( wxFont( 14, 74, 90, 92, false, wxT("Arial Black") ) ); diff --git a/RealtimeSync/gui_generated.h b/RealtimeSync/gui_generated.h index 7be541d4..2b00d1bc 100644 --- a/RealtimeSync/gui_generated.h +++ b/RealtimeSync/gui_generated.h @@ -5,8 +5,8 @@ // PLEASE DO "NOT" EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#ifndef __guiGenerated__ -#define __guiGenerated__ +#ifndef __gui_generated__ +#define __gui_generated__ #include <wx/intl.h> @@ -65,8 +65,8 @@ class MainDlgGenerated : public wxFrame wxScrolledWindow* m_scrolledWinFolders; wxBoxSizer* bSizerFolders; wxTextCtrl* m_textCtrlCommand; - wxStaticLine* m_staticline1; wxSpinCtrl* m_spinCtrlDelay; + wxStaticLine* m_staticline1; wxButtonWithImage* m_buttonStart; wxButton* m_buttonCancel; @@ -107,4 +107,4 @@ class FolderGenerated : public wxPanel }; -#endif //__guiGenerated__ +#endif //__gui_generated__ diff --git a/RealtimeSync/main_dlg.cpp b/RealtimeSync/main_dlg.cpp index d1a30c48..447f1f01 100644 --- a/RealtimeSync/main_dlg.cpp +++ b/RealtimeSync/main_dlg.cpp @@ -8,7 +8,7 @@ #include "resources.h" #include "../shared/custom_button.h" #include "../shared/standard_paths.h" -#include "functions.h" +//#include "functions.h" #include <wx/msgdlg.h> #include <wx/wupdlock.h> #include "watcher.h" @@ -43,7 +43,7 @@ MainDialog::MainDialog(wxDialog *dlg, Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(MainDialog::OnKeyPressed), NULL, this); //prepare drag & drop - dragDropOnFolder.reset(new ffs3::DragDropOnDlg(m_panelMainFolder, m_dirPickerMain, m_txtCtrlDirectoryMain)); + dirNameFirst.reset(new ffs3::DirectoryName(m_panelMainFolder, m_dirPickerMain, m_txtCtrlDirectoryMain)); //load config values xmlAccess::XmlRealConfig newConfig; @@ -141,7 +141,7 @@ void MainDialog::OnShowHelp(wxCommandEvent& event) void MainDialog::OnMenuAbout(wxCommandEvent& event) { - //build information + //build information wxString build = __TDATE__; #if wxUSE_UNICODE build += wxT(" - Unicode"); @@ -156,8 +156,8 @@ void MainDialog::OnMenuAbout(wxCommandEvent& event) build += wxT(" x86"); assert_static(util::is32BitBuild || util::is64BitBuild); -wxString buildFormatted = _("(Build: %x)"); -buildFormatted.Replace(wxT("%x"), build); + wxString buildFormatted = _("(Build: %x)"); + buildFormatted.Replace(wxT("%x"), build); wxMessageDialog* aboutDlg = new wxMessageDialog(this, wxString(wxT("RealtimeSync")) + wxT("\n\n") + buildFormatted, _("About"), wxOK); aboutDlg->ShowModal(); @@ -270,19 +270,14 @@ void MainDialog::OnLoadConfig(wxCommandEvent& event) void MainDialog::setConfiguration(const xmlAccess::XmlRealConfig& cfg) { //clear existing folders - m_txtCtrlDirectoryMain->ChangeValue(wxEmptyString); - m_dirPickerMain->SetPath(wxEmptyString); + dirNameFirst->setName(Zstring()); clearAddFolders(); if (!cfg.directories.empty()) { //fill top folder - m_txtCtrlDirectoryMain->SetValue(*cfg.directories.begin()); - - const Zstring dirFormatted = ffs3::getFormattedDirectoryName(wxToZ(*cfg.directories.begin())); - if (dirExists(dirFormatted)) - m_dirPickerMain->SetPath(zToWx(dirFormatted)); + dirNameFirst->setName(wxToZ(*cfg.directories.begin())); //fill additional folders addFolder(std::vector<wxString>(cfg.directories.begin() + 1, cfg.directories.end())); @@ -300,9 +295,9 @@ xmlAccess::XmlRealConfig MainDialog::getConfiguration() { xmlAccess::XmlRealConfig output; - output.directories.push_back(m_txtCtrlDirectoryMain->GetValue()); - for (std::vector<FolderPanel*>::const_iterator i = additionalFolders.begin(); i != additionalFolders.end(); ++i) - output.directories.push_back((*i)->m_txtCtrlDirectory->GetValue()); + output.directories.push_back(zToWx(dirNameFirst->getName())); + for (std::vector<DirectoryPanel*>::const_iterator i = dirNamesExtra.begin(); i != dirNamesExtra.end(); ++i) + output.directories.push_back(zToWx((*i)->getName())); output.commandline = m_textCtrlCommand->GetValue(); output.delay = m_spinCtrlDelay->GetValue();; @@ -313,13 +308,13 @@ xmlAccess::XmlRealConfig MainDialog::getConfiguration() void MainDialog::OnAddFolder(wxCommandEvent& event) { - const wxString topFolder = m_txtCtrlDirectoryMain->GetValue(); + const wxString topFolder = zToWx(dirNameFirst->getName()); //clear existing top folder first - rts::setDirectoryName(wxEmptyString, m_txtCtrlDirectoryMain, m_dirPickerMain); + dirNameFirst->setName(Zstring()); std::vector<wxString> newFolders; - newFolders.push_back(topFolder.c_str()); + newFolders.push_back(topFolder); addFolder(newFolders, true); //add pair in front of additonal pairs } @@ -329,11 +324,11 @@ void MainDialog::OnRemoveFolder(wxCommandEvent& event) { //find folder pair originating the event const wxObject* const eventObj = event.GetEventObject(); - for (std::vector<FolderPanel*>::const_iterator i = additionalFolders.begin(); i != additionalFolders.end(); ++i) + for (std::vector<DirectoryPanel*>::const_iterator i = dirNamesExtra.begin(); i != dirNamesExtra.end(); ++i) { if (eventObj == static_cast<wxObject*>((*i)->m_bpButtonRemoveFolder)) { - removeAddFolder(i - additionalFolders.begin()); + removeAddFolder(i - dirNamesExtra.begin()); return; } } @@ -342,10 +337,11 @@ void MainDialog::OnRemoveFolder(wxCommandEvent& event) void MainDialog::OnRemoveTopFolder(wxCommandEvent& event) { - if (additionalFolders.size() > 0) + if (dirNamesExtra.size() > 0) { - const wxString topDir = (*additionalFolders.begin())->m_txtCtrlDirectory->GetValue().c_str(); - rts::setDirectoryName(topDir, m_txtCtrlDirectoryMain, m_dirPickerMain); + const wxString topDir = (*dirNamesExtra.begin())->getName().c_str(); + + dirNameFirst->setName(wxToZ(topDir)); removeAddFolder(0); //remove first of additional folders } @@ -370,7 +366,7 @@ void MainDialog::addFolder(const std::vector<wxString>& newFolders, bool addFron for (std::vector<wxString>::const_iterator i = newFolders.begin(); i != newFolders.end(); ++i) { //add new folder pair - FolderPanel* newFolder = new FolderPanel(m_scrolledWinFolders); + DirectoryPanel* newFolder = new DirectoryPanel(m_scrolledWinFolders); newFolder->m_bpButtonRemoveFolder->SetBitmapLabel(GlobalResources::getInstance().getImageByName(wxT("removeFolderPair"))); //get size of scrolled window @@ -379,23 +375,23 @@ void MainDialog::addFolder(const std::vector<wxString>& newFolders, bool addFron if (addFront) { bSizerFolders->Insert(0, newFolder, 0, wxEXPAND, 5); - additionalFolders.insert(additionalFolders.begin(), newFolder); + dirNamesExtra.insert(dirNamesExtra.begin(), newFolder); } else { bSizerFolders->Add(newFolder, 0, wxEXPAND, 5); - additionalFolders.push_back(newFolder); + dirNamesExtra.push_back(newFolder); } //register events newFolder->m_bpButtonRemoveFolder->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MainDialog::OnRemoveFolder), NULL, this ); //insert directory name - rts::setDirectoryName(*i, newFolder->m_txtCtrlDirectory, newFolder->m_dirPicker); + newFolder->setName(wxToZ(*i)); } //set size of scrolled window - const size_t additionalRows = std::min(additionalFolders.size(), MAX_ADD_FOLDERS); //up to MAX_ADD_FOLDERS additional folders shall be shown + const size_t additionalRows = std::min(dirNamesExtra.size(), MAX_ADD_FOLDERS); //up to MAX_ADD_FOLDERS additional folders shall be shown m_scrolledWinFolders->SetMinSize(wxSize( -1, folderHeight * static_cast<int>(additionalRows))); //adapt delete top folder pair button @@ -414,23 +410,23 @@ void MainDialog::removeAddFolder(const int pos) { wxWindowUpdateLocker dummy(this); //avoid display distortion - if (0 <= pos && pos < int(additionalFolders.size())) + if (0 <= pos && pos < int(dirNamesExtra.size())) { //remove folder pairs from window - FolderPanel* dirToDelete = additionalFolders[pos]; + DirectoryPanel* dirToDelete = dirNamesExtra[pos]; const int folderHeight = dirToDelete->GetSize().GetHeight(); bSizerFolders->Detach(dirToDelete); //Remove() does not work on Window*, so do it manually dirToDelete->Destroy(); // - additionalFolders.erase(additionalFolders.begin() + pos); //remove last element in vector + dirNamesExtra.erase(dirNamesExtra.begin() + pos); //remove last element in vector //set size of scrolled window - const size_t additionalRows = std::min(additionalFolders.size(), MAX_ADD_FOLDERS); //up to MAX_ADD_FOLDERS additional folders shall be shown + const size_t additionalRows = std::min(dirNamesExtra.size(), MAX_ADD_FOLDERS); //up to MAX_ADD_FOLDERS additional folders shall be shown m_scrolledWinFolders->SetMinSize(wxSize( -1, folderHeight * static_cast<int>(additionalRows))); //adapt delete top folder pair button - if (additionalFolders.size() == 0) + if (dirNamesExtra.size() == 0) { m_bpButtonRemoveTopFolder->Hide(); m_panelMainFolder->Layout(); @@ -448,7 +444,7 @@ void MainDialog::clearAddFolders() { wxWindowUpdateLocker dummy(this); //avoid display distortion - additionalFolders.clear(); + dirNamesExtra.clear(); bSizerFolders->Clear(true); m_bpButtonRemoveTopFolder->Hide(); diff --git a/RealtimeSync/main_dlg.h b/RealtimeSync/main_dlg.h index 0f408f6d..22c39146 100644 --- a/RealtimeSync/main_dlg.h +++ b/RealtimeSync/main_dlg.h @@ -10,7 +10,7 @@ #include "gui_generated.h" #include <vector> #include <memory> -#include "../shared/drag_n_drop.h" +#include "../shared/dir_name.h" namespace xmlAccess { @@ -18,16 +18,25 @@ struct XmlRealConfig; } -class FolderPanel : public FolderGenerated +class DirectoryPanel : public FolderGenerated { public: - FolderPanel(wxWindow* parent) : + DirectoryPanel(wxWindow* parent) : FolderGenerated(parent), - dragDropOnFolder(new ffs3::DragDropOnDlg(this, m_dirPicker, m_txtCtrlDirectory)) {} + dirName(this, m_dirPicker, m_txtCtrlDirectory) {} + + void setName(const Zstring& dirname) + { + dirName.setName(dirname); + } + + Zstring getName() const + { + return dirName.getName(); + } private: - //support for drag and drop - std::auto_ptr<ffs3::DragDropOnDlg> dragDropOnFolder; + ffs3::DirectoryName dirName; }; @@ -65,11 +74,8 @@ private: static const wxString& lastConfigFileName(); - //additional folders - std::vector<FolderPanel*> additionalFolders; //additional pairs to the standard pair - - //support for drag and drop on main folder - std::auto_ptr<ffs3::DragDropOnDlg> dragDropOnFolder; + std::auto_ptr<ffs3::DirectoryName> dirNameFirst; + std::vector<DirectoryPanel*> dirNamesExtra; //additional pairs to the standard pair }; #endif // REALTIMESYNCMAIN_H diff --git a/RealtimeSync/makefile b/RealtimeSync/makefile index 764cb5f9..cf7aca36 100644 --- a/RealtimeSync/makefile +++ b/RealtimeSync/makefile @@ -3,12 +3,11 @@ APPNAME = RealtimeSync prefix = /usr BINDIR = $(DESTDIR)$(prefix)/bin -FFS_CPPFLAGS=-Wall -pipe -DNDEBUG -DwxUSE_UNICODE `wx-config --cxxflags --debug=no --unicode=yes` `pkg-config --cflags gtk+-2.0` -DFFS_LINUX -DTIXML_USE_STL -DZSTRING_CHAR -O3 -pthread -c -LINKFLAGS=`wx-config --libs --debug=no --unicode=yes` -lboost_thread -O3 -pthread +FFS_CPPFLAGS=-Wall -pipe -DNDEBUG -DwxUSE_UNICODE `wx-config --cxxflags --debug=no --unicode=yes --static=yes` `pkg-config --cflags gtk+-2.0` -DFFS_LINUX -DTIXML_USE_STL -O3 -pthread +LINKFLAGS=`wx-config --libs --debug=no --unicode=yes --static=yes` /usr/local/lib/libboost_thread.a -O3 -pthread FILE_LIST= #internal list of all *.cpp files needed for compilation FILE_LIST+=application.cpp -FILE_LIST+=functions.cpp FILE_LIST+=gui_generated.cpp FILE_LIST+=main_dlg.cpp FILE_LIST+=resources.cpp @@ -26,7 +25,7 @@ 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/drag_n_drop.cpp +FILE_LIST+=../shared/dir_name.cpp FILE_LIST+=../shared/zstring.cpp FILE_LIST+=../shared/xml_base.cpp FILE_LIST+=../shared/custom_button.cpp @@ -55,10 +54,11 @@ removeBOM: ../tools/remove_BOM.cpp %.dep : %.cpp #strip path information - g++ $(FFS_CPPFLAGS) $< -o OBJ/$(subst .cpp,.o,$(notdir $<)) + g++ $(FFS_CPPFLAGS) -c $< -o OBJ/$(subst .cpp,.o,$(notdir $<)) RealtimeSync: init removeBOM $(DEP_LIST) - g++ $(LINKFLAGS) -o ../BUILD/$(APPNAME) $(OBJECT_LIST) +#respect linker order: wxWidgets libraries last + g++ -o ../BUILD/$(APPNAME) $(OBJECT_LIST) $(LINKFLAGS) clean: rm -rf OBJ diff --git a/RealtimeSync/notify.cpp b/RealtimeSync/notify.cpp index fc9ac8cc..599259e6 100644 --- a/RealtimeSync/notify.cpp +++ b/RealtimeSync/notify.cpp @@ -196,9 +196,13 @@ public: &filter, //__in LPVOID NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE); //__in DWORD Flags if (hNotfication == NULL) - throw ffs3::FileError(wxString(wxT("Could not register device removal notifications:")) + wxT("\n\n") + ffs3::getLastErrorFormatted()); - - notifications.insert(hNotfication); + { + const DWORD lastError = ::GetLastError(); + if (lastError != ERROR_CALL_NOT_IMPLEMENTED) //fail on SAMBA share: this shouldn't be a showstopper! + throw ffs3::FileError(wxString(wxT("Could not register device removal notifications:")) + wxT("\n\n") + ffs3::getLastErrorFormatted(lastError)); + } + else + notifications.insert(hNotfication); } } catch (...) diff --git a/RealtimeSync/resource.rc b/RealtimeSync/resource.rc index 1b70fa6a..f3dfb090 100644 --- a/RealtimeSync/resource.rc +++ b/RealtimeSync/resource.rc @@ -1,24 +1,26 @@ #define IDR_VERSION1 1 +#include "Winver.h" #include "wx/msw/wx.rc" #include "../version/version.rc" A_PROGRAM_ICON ICON DISCARDABLE "RealtimeSync.ico" -IDR_VERSION1 VERSIONINFO -FILEVERSION VER_FREEFILESYNC +IDR_VERSION1 VERSIONINFO +FILEVERSION VER_FREEFILESYNC PRODUCTVERSION VER_FREEFILESYNC -FILEOS 0x00000004 -FILETYPE 0x00000001 +FILEOS VOS__WINDOWS32 +FILETYPE VFT_APP BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "FFFF04B0" BEGIN - VALUE "ProductVersion", VER_FREEFILESYNC_STR VALUE "FileDescription", "Realtime Application Launcher\0" - VALUE "LegalCopyright", "(c) 2008 - 2010 ZenJu\0" - VALUE "ProductName", "RealtimeSync\0" + VALUE "FileVersion", VER_FREEFILESYNC_STR + VALUE "ProductName", "RealtimeSync\0" + VALUE "ProductVersion", VER_FREEFILESYNC_STR + VALUE "LegalCopyright", "(c) 2008 - 2010 ZenJu\0" END END BLOCK "VarFileInfo" diff --git a/RealtimeSync/tray_menu.cpp b/RealtimeSync/tray_menu.cpp index 1ea7416c..9c0db35a 100644 --- a/RealtimeSync/tray_menu.cpp +++ b/RealtimeSync/tray_menu.cpp @@ -21,18 +21,18 @@ #include "../shared/build_info.h" #include <wx/icon.h> //Linux needs this #include <wx/timer.h> +#include <limits> using namespace rts; -class WaitCallbackImpl : private wxEvtHandler, public rts::WaitCallback //keep this order: else VC++ generates wrong code +class TrayIconHolder : private wxEvtHandler { public: - WaitCallbackImpl(); - ~WaitCallbackImpl(); - - virtual void requestUiRefresh(); + TrayIconHolder(); + ~TrayIconHolder(); + void doUiRefreshNow(); void showIconActive(); void showIconWaiting(); @@ -65,10 +65,10 @@ private: //RtsTrayIcon shall be a dumb class whose sole purpose is to enable wxWidgets deferred deletion -class WaitCallbackImpl::RtsTrayIcon : public wxTaskBarIcon +class TrayIconHolder::RtsTrayIcon : public wxTaskBarIcon { public: - RtsTrayIcon(WaitCallbackImpl* parent) : parent_(parent) {} + RtsTrayIcon(TrayIconHolder* parent) : parent_(parent) {} void parentHasDied() //call before tray icon is marked for deferred deletion { @@ -87,12 +87,12 @@ private: contextMenu->AppendSeparator(); contextMenu->Append(CONTEXT_ABORT, _("&Exit")); //event handling - contextMenu->Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WaitCallbackImpl::OnContextMenuSelection), NULL, parent_); + contextMenu->Connect(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TrayIconHolder::OnContextMenuSelection), NULL, parent_); return contextMenu; //ownership transferred to caller } - WaitCallbackImpl* parent_; + TrayIconHolder* parent_; }; //############################################################################################################## @@ -113,7 +113,7 @@ private: //############################################################################################################## -WaitCallbackImpl::WaitCallbackImpl() : +TrayIconHolder::TrayIconHolder() : m_abortRequested(false), m_resumeRequested(false) { @@ -122,13 +122,13 @@ WaitCallbackImpl::WaitCallbackImpl() : showIconActive(); //register double-click - trayMenu->Connect(wxEVT_TASKBAR_LEFT_DCLICK, wxCommandEventHandler(WaitCallbackImpl::OnRequestResume), NULL, this); + trayMenu->Connect(wxEVT_TASKBAR_LEFT_DCLICK, wxCommandEventHandler(TrayIconHolder::OnRequestResume), NULL, this); } -WaitCallbackImpl::~WaitCallbackImpl() +TrayIconHolder::~TrayIconHolder() { - trayMenu->Disconnect(wxEVT_TASKBAR_LEFT_DCLICK, wxCommandEventHandler(WaitCallbackImpl::OnRequestResume), NULL, this); + trayMenu->Disconnect(wxEVT_TASKBAR_LEFT_DCLICK, wxCommandEventHandler(TrayIconHolder::OnRequestResume), NULL, this); trayMenu->RemoveIcon(); //(try to) hide icon until final deletion takes place trayMenu->parentHasDied(); @@ -138,7 +138,7 @@ WaitCallbackImpl::~WaitCallbackImpl() } -void WaitCallbackImpl::showIconActive() +void TrayIconHolder::showIconActive() { wxIcon realtimeIcon; #ifdef FFS_WIN @@ -150,7 +150,7 @@ void WaitCallbackImpl::showIconActive() } -void WaitCallbackImpl::showIconWaiting() +void TrayIconHolder::showIconWaiting() { wxIcon realtimeIcon; #ifdef FFS_WIN @@ -162,7 +162,7 @@ void WaitCallbackImpl::showIconWaiting() } -void WaitCallbackImpl::OnContextMenuSelection(wxCommandEvent& event) +void TrayIconHolder::OnContextMenuSelection(wxCommandEvent& event) { const int eventId = event.GetId(); switch (static_cast<Selection>(eventId)) @@ -201,10 +201,9 @@ void WaitCallbackImpl::OnContextMenuSelection(wxCommandEvent& event) } -void WaitCallbackImpl::requestUiRefresh() +void TrayIconHolder::doUiRefreshNow() { - if (updateUiIsAllowed()) - wxTheApp->Yield(); + wxTheApp->Yield(); if (m_abortRequested) throw ::AbortThisProcess(QUIT); @@ -226,6 +225,60 @@ std::vector<Zstring> convert(const std::vector<wxString>& dirList) } +class StartSyncNowException {}; + + +class WaitCallbackImpl : public rts::WaitCallback +{ +public: + WaitCallbackImpl() : nextSyncStart_(std::numeric_limits<long>::max()) {} + + void notifyAllDirectoriesExist() + { + trayIcon.showIconActive(); + } + + void notifyDirectoryMissing() + { + trayIcon.showIconWaiting(); + } + + virtual void requestUiRefresh() //throw StartSyncNowException() + { + if (nextSyncStart_ <= wxGetLocalTime()) + throw StartSyncNowException(); //abort wait and start sync + + if (updateUiIsAllowed()) + trayIcon.doUiRefreshNow(); + } + + void scheduleNextSync(long nextSyncStart) + { + nextSyncStart_ = nextSyncStart; + } + +private: + TrayIconHolder trayIcon; + long nextSyncStart_; +}; + +/* +Data Flow: +---------- + +TrayIconHolder (GUI output) + /|\ + | +WaitCallbackImpl (higher level "interface") + /|\ + | +startDirectoryMonitor() (wire dir-changes and execution of commandline) + /|\ + | +watcher.h (low level wait for directory changes) +*/ + + rts::MonitorResponse rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig& config) { const std::vector<Zstring> dirList = convert(config.directories); @@ -237,35 +290,38 @@ rts::MonitorResponse rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig& if (config.commandline.empty()) throw ffs3::FileError(_("Command line is empty!")); + callback.notifyDirectoryMissing(); + waitForMissingDirs(dirList, &callback); + callback.notifyAllDirectoriesExist(); + while (true) { - //execute commandline - callback.showIconWaiting(); - waitForMissingDirs(dirList, &callback); - callback.showIconActive(); - wxExecute(config.commandline, wxEXEC_SYNC); //execute command wxLog::FlushActive(); //show wxWidgets error messages (if any) - //wait for changes (and for all directories to become available) - switch (waitForChanges(dirList, &callback)) - { - case CHANGE_DIR_MISSING: //don't execute the commandline before all directories are available! - callback.showIconWaiting(); - waitForMissingDirs(dirList, &callback); - callback.showIconActive(); - break; - case CHANGE_DETECTED: - break; - } + callback.scheduleNextSync(std::numeric_limits<long>::max()); //next sync not scheduled (yet) - //some delay - const long nextExec = wxGetLocalTime() + static_cast<long>(config.delay); - while (wxGetLocalTime() < nextExec) + try { - callback.requestUiRefresh(); - wxMilliSleep(rts::UI_UPDATE_INTERVAL); + while (true) + { + //wait for changes (and for all directories to become available) + switch (waitForChanges(dirList, &callback)) + { + case CHANGE_DIR_MISSING: //don't execute the commandline before all directories are available! + callback.scheduleNextSync(std::numeric_limits<long>::max()); //next sync not scheduled (yet) + callback.notifyDirectoryMissing(); + waitForMissingDirs(dirList, &callback); + callback.notifyAllDirectoriesExist(); + break; + case CHANGE_DETECTED: + break; + } + + callback.scheduleNextSync(wxGetLocalTime() + static_cast<long>(config.delay)); + } } + catch (StartSyncNowException) {} } } catch (const ::AbortThisProcess& ab) diff --git a/RealtimeSync/watcher.cpp b/RealtimeSync/watcher.cpp index 89fc5e61..cf2791ad 100644 --- a/RealtimeSync/watcher.cpp +++ b/RealtimeSync/watcher.cpp @@ -59,9 +59,9 @@ class DirsOnlyTraverser : public ffs3::TraverseCallback public: DirsOnlyTraverser(std::vector<std::string>& dirs) : m_dirs(dirs) {} - virtual void onFile(const DefaultChar* shortName, const Zstring& fullName, const FileInfo& details) {} - virtual void onSymlink(const DefaultChar* shortName, const Zstring& fullName, const SymlinkInfo& details) {} - virtual ReturnValDir onDir(const DefaultChar* shortName, const Zstring& fullName) + virtual void onFile(const Zchar* shortName, const Zstring& fullName, const FileInfo& details) {} + virtual void onSymlink(const Zchar* shortName, const Zstring& fullName, const SymlinkInfo& details) {} + virtual ReturnValDir onDir(const Zchar* shortName, const Zstring& fullName) { m_dirs.push_back(fullName.c_str()); return ReturnValDir(Loki::Int2Type<ReturnValDir::TRAVERSING_DIR_CONTINUE>(), this); diff --git a/RealtimeSync/xml_ffs.cpp b/RealtimeSync/xml_ffs.cpp index 3f87b20f..864ceff9 100644 --- a/RealtimeSync/xml_ffs.cpp +++ b/RealtimeSync/xml_ffs.cpp @@ -8,7 +8,7 @@ #include "../shared/standard_paths.h" #include "../shared/global_func.h" #include "../shared/zstring.h" -#include "functions.h" +//#include "functions.h" #include "../shared/xml_base.h" #include "../shared/string_conv.h" diff --git a/RealtimeSync/xml_proc.h b/RealtimeSync/xml_proc.h index bac42f1e..3e6c0c0a 100644 --- a/RealtimeSync/xml_proc.h +++ b/RealtimeSync/xml_proc.h @@ -16,7 +16,7 @@ namespace xmlAccess { struct XmlRealConfig { - XmlRealConfig() : delay(5) {} + XmlRealConfig() : delay(10) {} std::vector<wxString> directories; wxString commandline; size_t delay; |