summaryrefslogtreecommitdiff
path: root/RealtimeSync
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:21:59 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:21:59 +0200
commitd4af25c52a28b93484ffb55e0a8027bc4ce7856f (patch)
tree853d57468d6b370711e7a5dd2c3dc7d5bac81b10 /RealtimeSync
parent5.8 (diff)
downloadFreeFileSync-d4af25c52a28b93484ffb55e0a8027bc4ce7856f.tar.gz
FreeFileSync-d4af25c52a28b93484ffb55e0a8027bc4ce7856f.tar.bz2
FreeFileSync-d4af25c52a28b93484ffb55e0a8027bc4ce7856f.zip
5.9
Diffstat (limited to 'RealtimeSync')
-rw-r--r--RealtimeSync/RealtimeSync.cbp79
-rw-r--r--RealtimeSync/RealtimeSync.icobin130761 -> 136291 bytes
-rw-r--r--RealtimeSync/RealtimeSync.vcxproj2
-rw-r--r--RealtimeSync/application.cpp5
-rw-r--r--RealtimeSync/gui_generated.cpp8
-rw-r--r--RealtimeSync/gui_generated.h5
-rw-r--r--RealtimeSync/tray_menu.cpp25
-rw-r--r--RealtimeSync/watcher.cpp26
-rw-r--r--RealtimeSync/watcher.h9
9 files changed, 92 insertions, 67 deletions
diff --git a/RealtimeSync/RealtimeSync.cbp b/RealtimeSync/RealtimeSync.cbp
index a171b55b..a5f82367 100644
--- a/RealtimeSync/RealtimeSync.cbp
+++ b/RealtimeSync/RealtimeSync.cbp
@@ -8,16 +8,16 @@
<Option compiler="gcc" />
<Build>
<Target title="Release">
- <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 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" />
<Option compiler="gcc" />
<Option projectLinkerOptionsRelation="2" />
<Compiler>
<Add option="-O3" />
<Add option="-DNDEBUG" />
- <Add directory="C:\Programme\C++\wxWidgets\lib\mingw_release_lib\mswu" />
+ <Add directory="C:/Programme/C++/wxWidgets/lib/mingw_release_lib/mswu" />
</Compiler>
<Linker>
<Add option="-s" />
@@ -27,19 +27,18 @@
<Add library="libwxbase28u.a" />
<Add library="libwxpng.a" />
<Add library="libwxzlib.a" />
- <Add library="libboost_thread-mgw47-mt-s-1_51.a" />
- <Add library="libboost_system-mgw47-mt-s-1_51.a" />
- <Add library="libboost_chrono-mgw47-mt-s-1_51.a" />
- <Add directory="C:\Programme\C++\wxWidgets\lib\mingw_release_lib" />
+ <Add library="libboost_thread-mgw47-mt-s-1_52.a" />
+ <Add library="libboost_system-mgw47-mt-s-1_52.a" />
+ <Add directory="C:/Programme/C++/wxWidgets/lib/mingw_release_lib" />
</Linker>
<ExtraCommands>
<Add after='&quot;C:\Program Files\C++\CodeSigning\SignCode.cmd&quot; &quot;$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)&quot;' />
</ExtraCommands>
</Target>
<Target title="Debug-DLL">
- <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 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" />
<Option compiler="gcc" />
<Option projectLinkerOptionsRelation="2" />
@@ -48,7 +47,7 @@
<Add option="-Winvalid-pch" />
<Add option='-include &quot;../wx+/pch.h&quot;' />
<Add option="-D__WXDEBUG__" />
- <Add directory="C:\Program Files\C++\wxWidgets\lib\mingw_debug_dll\mswud" />
+ <Add directory="C:/Program Files/C++/wxWidgets/lib/mingw_debug_dll/mswud" />
</Compiler>
<Linker>
<Add library="libwxmsw28ud_core.a" />
@@ -56,10 +55,9 @@
<Add library="libwxbase28ud.a" />
<Add library="libwxpngd.a" />
<Add library="libwxzlibd.a" />
- <Add library="libboost_thread-mgw47-mt-sd-1_51.a" />
- <Add library="libboost_system-mgw47-mt-sd-1_51.a" />
- <Add library="libboost_chrono-mgw47-mt-sd-1_51.a" />
- <Add directory="C:\Program Files\C++\wxWidgets\lib\mingw_debug_dll" />
+ <Add library="libboost_thread-mgw47-mt-sd-1_52.a" />
+ <Add library="libboost_system-mgw47-mt-sd-1_52.a" />
+ <Add directory="C:/Program Files/C++/wxWidgets/lib/mingw_debug_dll" />
</Linker>
</Target>
</Build>
@@ -83,12 +81,12 @@
<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="C:/Programme/C++/wxWidgets/include" />
+ <Add directory="C:/Program Files/C++/Boost" />
<Add directory=".." />
</Compiler>
<ResourceCompiler>
- <Add directory="C:\Programme\C++\wxWidgets\include" />
+ <Add directory="C:/Programme/C++/wxWidgets/include" />
</ResourceCompiler>
<Linker>
<Add option="-mthreads" />
@@ -104,32 +102,33 @@
<Add library="libwinspool.a" />
<Add library="libmpr.a" />
<Add library="libuxtheme.a" />
- <Add directory="C:\Program Files\C++\Boost\stage\lib" />
+ <Add directory="C:/Program Files/C++/Boost/stage/lib" />
</Linker>
- <Unit filename="..\lib\localization.cpp" />
- <Unit filename="..\lib\process_xml.cpp" />
- <Unit filename="..\lib\resolve_path.cpp" />
- <Unit filename="..\lib\xml_base.cpp" />
- <Unit filename="..\structures.cpp" />
- <Unit filename="..\ui\dir_name.cpp" />
- <Unit filename="..\ui\dir_name.h" />
- <Unit filename="..\ui\folder_history_box.cpp" />
- <Unit filename="..\ui\folder_history_box.h" />
- <Unit filename="..\wx+\button.cpp" />
- <Unit filename="..\wx+\mouse_move_dlg.cpp" />
- <Unit filename="..\wx+\pch.h">
+ <Unit filename="../lib/localization.cpp" />
+ <Unit filename="../lib/process_xml.cpp" />
+ <Unit filename="../lib/resolve_path.cpp" />
+ <Unit filename="../lib/xml_base.cpp" />
+ <Unit filename="../structures.cpp" />
+ <Unit filename="../ui/dir_name.cpp" />
+ <Unit filename="../ui/dir_name.h" />
+ <Unit filename="../ui/folder_history_box.cpp" />
+ <Unit filename="../ui/folder_history_box.h" />
+ <Unit filename="../wx+/button.cpp" />
+ <Unit filename="../wx+/mouse_move_dlg.cpp" />
+ <Unit filename="../wx+/pch.h">
<Option compile="1" />
<Option weight="0" />
<Option target="Debug-DLL" />
</Unit>
- <Unit filename="..\zen\dir_watcher.cpp" />
- <Unit filename="..\zen\dst_hack.cpp" />
- <Unit filename="..\zen\file_handling.cpp" />
- <Unit filename="..\zen\file_io.cpp" />
- <Unit filename="..\zen\file_traverser.cpp" />
- <Unit filename="..\zen\notify_removal.cpp" />
- <Unit filename="..\zen\privilege.cpp" />
- <Unit filename="..\zen\zstring.cpp" />
+ <Unit filename="../zen/dir_watcher.cpp" />
+ <Unit filename="../zen/dst_hack.cpp" />
+ <Unit filename="../zen/file_handling.cpp" />
+ <Unit filename="../zen/file_io.cpp" />
+ <Unit filename="../zen/file_traverser.cpp" />
+ <Unit filename="../zen/notify_removal.cpp" />
+ <Unit filename="../zen/privilege.cpp" />
+ <Unit filename="../zen/scroll_window_under_cursor.cpp" />
+ <Unit filename="../zen/zstring.cpp" />
<Unit filename="WxWizFrame.fbp" />
<Unit filename="application.cpp" />
<Unit filename="application.h" />
diff --git a/RealtimeSync/RealtimeSync.ico b/RealtimeSync/RealtimeSync.ico
index c42a3029..1c5a3eb6 100644
--- a/RealtimeSync/RealtimeSync.ico
+++ b/RealtimeSync/RealtimeSync.ico
Binary files differ
diff --git a/RealtimeSync/RealtimeSync.vcxproj b/RealtimeSync/RealtimeSync.vcxproj
index 6505cc9a..764ec0a9 100644
--- a/RealtimeSync/RealtimeSync.vcxproj
+++ b/RealtimeSync/RealtimeSync.vcxproj
@@ -137,6 +137,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<SuppressStartupBanner>true</SuppressStartupBanner>
<MinimalRebuild>false</MinimalRebuild>
+ <ShowIncludes>false</ShowIncludes>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -235,6 +236,7 @@
<ClCompile Include="..\zen\file_traverser.cpp" />
<ClCompile Include="..\zen\notify_removal.cpp" />
<ClCompile Include="..\zen\privilege.cpp" />
+ <ClCompile Include="..\zen\scroll_window_under_cursor.cpp" />
<ClCompile Include="..\zen\zstring.cpp" />
<ClCompile Include="application.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Use</PrecompiledHeader>
diff --git a/RealtimeSync/application.cpp b/RealtimeSync/application.cpp
index 172a8cac..435a6b86 100644
--- a/RealtimeSync/application.cpp
+++ b/RealtimeSync/application.cpp
@@ -18,7 +18,7 @@
#include "lib/error_log.h"
#ifdef FFS_WIN
-#include <zen/win_ver.h>
+#include <zen/win_ver.h>
#elif defined FFS_LINUX
#include <gtk/gtk.h>
#endif
@@ -55,13 +55,12 @@ bool Application::OnInit()
{
#ifdef FFS_WIN
std::set_terminate(onTerminationRequested); //unlike wxWidgets uncaught exception handling, this works for all worker threads
+ assert(!win8OrLater()); //another breadcrumb: test and add new OS entry to "compatibility" in application manifest
#ifdef _MSC_VER
_set_invalid_parameter_handler(crtInvalidParameterHandler); //see comment in <zen/time.h>
#endif
#endif
- assert(!win8OrLater()); //another breadcrumb: test and add new OS entry to "compatibility" in application manifest
-
//do not call wxApp::OnInit() to avoid using default commandline parser
//Note: initialization is done in the FIRST idle event instead of OnInit. Reason: Commandline mode requires the wxApp eventhandler to be established
diff --git a/RealtimeSync/gui_generated.cpp b/RealtimeSync/gui_generated.cpp
index 6dad5266..4651099c 100644
--- a/RealtimeSync/gui_generated.cpp
+++ b/RealtimeSync/gui_generated.cpp
@@ -1,10 +1,12 @@
///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Apr 10 2012)
+// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
+#include "../wx+/button.h"
+
#include "gui_generated.h"
///////////////////////////////////////////////////////////////////////////
@@ -117,6 +119,7 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr
bSizer781->Add( m_bpButtonRemoveTopFolder, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5 );
m_txtCtrlDirectoryMain = new wxTextCtrl( m_panelMainFolder, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 300,-1 ), 0 );
+ m_txtCtrlDirectoryMain->SetMaxLength( 0 );
bSizer781->Add( m_txtCtrlDirectoryMain, 1, wxALIGN_CENTER_VERTICAL, 5 );
m_buttonSelectDirMain = new wxButton( m_panelMainFolder, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
@@ -161,6 +164,7 @@ MainDlgGenerated::MainDlgGenerated( wxWindow* parent, wxWindowID id, const wxStr
sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( m_panelMain, wxID_ANY, _("Command line") ), wxVERTICAL );
m_textCtrlCommand = new wxTextCtrl( m_panelMain, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+ m_textCtrlCommand->SetMaxLength( 0 );
m_textCtrlCommand->SetToolTip( _("The command is triggered if:\n- files or subfolders change\n- new folders arrive (e.g. USB stick insert)") );
sbSizer3->Add( m_textCtrlCommand, 0, wxEXPAND, 5 );
@@ -231,6 +235,7 @@ FolderGenerated::FolderGenerated( wxWindow* parent, wxWindowID id, const wxPoint
bSizer20 = new wxBoxSizer( wxHORIZONTAL );
m_txtCtrlDirectory = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
+ m_txtCtrlDirectory->SetMaxLength( 0 );
bSizer20->Add( m_txtCtrlDirectory, 1, wxALIGN_CENTER_VERTICAL, 5 );
m_buttonSelectDir = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
@@ -269,6 +274,7 @@ ErrorDlgGenerated::ErrorDlgGenerated( wxWindow* parent, wxWindowID id, const wxS
bSizer26->Add( m_bitmap10, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_textCtrl8 = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 400,150 ), wxTE_MULTILINE|wxTE_READONLY|wxNO_BORDER );
+ m_textCtrl8->SetMaxLength( 0 );
bSizer26->Add( m_textCtrl8, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );
diff --git a/RealtimeSync/gui_generated.h b/RealtimeSync/gui_generated.h
index 1f475454..aa267a02 100644
--- a/RealtimeSync/gui_generated.h
+++ b/RealtimeSync/gui_generated.h
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
-// C++ code generated with wxFormBuilder (version Apr 10 2012)
+// C++ code generated with wxFormBuilder (version Oct 8 2012)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
@@ -11,7 +11,8 @@
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
-#include "../wx+/button.h"
+namespace zen { class BitmapButton; }
+
#include <wx/string.h>
#include <wx/bitmap.h>
#include <wx/image.h>
diff --git a/RealtimeSync/tray_menu.cpp b/RealtimeSync/tray_menu.cpp
index af37d32e..a30081bf 100644
--- a/RealtimeSync/tray_menu.cpp
+++ b/RealtimeSync/tray_menu.cpp
@@ -305,6 +305,22 @@ bool reportErrorTimeout(const std::wstring& msg) //return true if timeout or use
}
return false;
}
+
+
+inline
+wxString toString(DirWatcher::ActionType type)
+{
+ switch (type)
+ {
+ case DirWatcher::ACTION_CREATE:
+ return L"CREATE";
+ case DirWatcher::ACTION_UPDATE:
+ return L"UPDATE";
+ case DirWatcher::ACTION_DELETE:
+ return L"DELETE";
+ }
+ return L"ERROR";
+}
}
/*
@@ -341,7 +357,7 @@ rts::AbortReason rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig& conf
try
{
- Zstring lastFileChanged;
+ DirWatcher::Entry lastChangeDetected;
WaitCallbackImpl callback(jobname);
auto execMonitoring = [&] //throw FileError, AbortMonitoring
@@ -372,7 +388,7 @@ rts::AbortReason rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig& conf
break;
case CHANGE_DETECTED:
- lastFileChanged = res.filename;
+ lastChangeDetected = res.changedItem_;
break;
}
callback.scheduleNextSync(wxGetLocalTime() + static_cast<long>(config.delay));
@@ -380,8 +396,9 @@ rts::AbortReason rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig& conf
}
catch (StartSyncNowException&) {}
- ::wxSetEnv(L"changed_file", utfCvrtTo<wxString>(lastFileChanged)); //some way to output what file changed to the user
- lastFileChanged.clear(); //make sure old name is not shown again after a directory reappears
+ ::wxSetEnv(L"change_path", utfCvrtTo<wxString>(lastChangeDetected.filename_)); //some way to output what file changed to the user
+ ::wxSetEnv(L"change_action", toString(lastChangeDetected.action_)); //
+ lastChangeDetected = DirWatcher::Entry(); //make sure old name is not shown again after a directory reappears
//execute command
auto cmdLineExp = utfCvrtTo<wxString>(expandMacros(utfCvrtTo<Zstring>(cmdLine)));
diff --git a/RealtimeSync/watcher.cpp b/RealtimeSync/watcher.cpp
index e66b4723..bfdb79c2 100644
--- a/RealtimeSync/watcher.cpp
+++ b/RealtimeSync/watcher.cpp
@@ -75,18 +75,18 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNamesNonFmt,
while (!ftDirExists.timed_wait(boost::posix_time::milliseconds(UI_UPDATE_INTERVAL)))
statusHandler.requestUiRefresh(); //may throw!
if (!ftDirExists.get())
- return WaitResult(CHANGE_DIR_MISSING, dirnameFmt);
+ return WaitResult(dirnameFmt);
watches.push_back(std::make_pair(dirnameFmt, std::make_shared<DirWatcher>(dirnameFmt))); //throw FileError, ErrorNotExisting
}
catch (ErrorNotExisting&) //nice atomic behavior: *no* second directory existence check!!!
{
- return WaitResult(CHANGE_DIR_MISSING, dirnameFmt);
+ return WaitResult(dirnameFmt);
}
catch (FileError&) //play safe: remedy potential FileErrors that should have been ErrorNotExisting (e.g. Linux: errors during directory traversing)
{
if (!dirExists(dirnameFmt)) //file system race condition!!
- return WaitResult(CHANGE_DIR_MISSING, dirnameFmt);
+ return WaitResult(dirnameFmt);
throw;
}
}
@@ -115,38 +115,38 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNamesNonFmt,
//IMPORTANT CHECK: dirwatcher has problems detecting removal of top watched directories!
if (checkDirExistNow)
if (!dirExists(dirname)) //catch errors related to directory removal, e.g. ERROR_NETNAME_DELETED
- return WaitResult(CHANGE_DIR_MISSING, dirname);
+ return WaitResult(dirname);
try
{
- std::vector<Zstring> changedFiles = watcher.getChanges([&] { statusHandler.requestUiRefresh(); }); //throw FileError, ErrorNotExisting
+ std::vector<DirWatcher::Entry> changedItems = watcher.getChanges([&] { statusHandler.requestUiRefresh(); }); //throw FileError, ErrorNotExisting
//remove to be ignored changes
- vector_remove_if(changedFiles, [](const Zstring& name)
+ vector_remove_if(changedItems, [](const DirWatcher::Entry& e)
{
- return endsWith(name, Zstr(".ffs_lock")) || //sync.ffs_lock, sync.Del.ffs_lock
- endsWith(name, Zstr(".ffs_db")); //sync.ffs_db, .sync.tmp.ffs_db
+ return endsWith(e.filename_, Zstr(".ffs_lock")) || //sync.ffs_lock, sync.Del.ffs_lock
+ endsWith(e.filename_, Zstr(".ffs_db")); //sync.ffs_db, .sync.tmp.ffs_db
//no need to ignore temporal recycle bin directory: this must be caused by a file deletion anyway
});
- if (!changedFiles.empty())
+ if (!changedItems.empty())
{
/*
- std::for_each(changedFiles.begin(), changedFiles.end(),
+ std::for_each(changedItems.begin(), changedItems.end(),
[](const Zstring& fn) { wxMessageBox(toWx(fn));});
*/
- return WaitResult(CHANGE_DETECTED, changedFiles[0]); //directory change detected
+ return WaitResult(changedItems[0]); //directory change detected
}
}
catch (ErrorNotExisting&) //nice atomic behavior: *no* second directory existence check!!!
{
- return WaitResult(CHANGE_DIR_MISSING, dirname);
+ return WaitResult(dirname);
}
catch (FileError&) //play safe: remedy potential FileErrors that should have been ErrorNotExisting (e.g. Linux: errors during directory traversing)
{
if (!dirExists(dirname)) //file system race condition!!
- return WaitResult(CHANGE_DIR_MISSING, dirname);
+ return WaitResult(dirname);
throw;
}
}
diff --git a/RealtimeSync/watcher.h b/RealtimeSync/watcher.h
index 014101da..2fd32119 100644
--- a/RealtimeSync/watcher.h
+++ b/RealtimeSync/watcher.h
@@ -7,8 +7,7 @@
#ifndef WATCHER_H_INCLUDED
#define WATCHER_H_INCLUDED
-#include <zen/zstring.h>
-#include <vector>
+#include <zen/dir_watcher.h>
#include <zen/file_error.h>
@@ -35,10 +34,12 @@ enum ChangeType
struct WaitResult
{
- WaitResult(ChangeType tp, const Zstring& chgFile) : type(tp), filename(chgFile) {}
+ WaitResult(const zen::DirWatcher::Entry& changedItem) : type(CHANGE_DETECTED), changedItem_(changedItem) {}
+ WaitResult(const Zstring& dirname) : type(CHANGE_DIR_MISSING), dirname_(dirname) {}
ChangeType type;
- Zstring filename; //file or directory name
+ zen::DirWatcher::Entry changedItem_; //for type == CHANGE_DETECTED: file or directory
+ Zstring dirname_; //for type == CHANGE_DIR_MISSING
};
WaitResult waitForChanges(const std::vector<Zstring>& dirNamesNonFmt,
bgstack15