diff options
Diffstat (limited to 'RealtimeSync')
-rw-r--r-- | RealtimeSync/RealtimeSync.cbp | 5 | ||||
-rw-r--r-- | RealtimeSync/RealtimeSync.ico | bin | 82726 -> 131100 bytes | |||
-rw-r--r-- | RealtimeSync/RealtimeSync.vcxproj | 1 | ||||
-rw-r--r-- | RealtimeSync/application.cpp | 6 | ||||
-rw-r--r-- | RealtimeSync/main_dlg.cpp | 36 | ||||
-rw-r--r-- | RealtimeSync/main_dlg.h | 2 | ||||
-rw-r--r-- | RealtimeSync/notify.cpp | 20 | ||||
-rw-r--r-- | RealtimeSync/notify.h | 2 | ||||
-rw-r--r-- | RealtimeSync/pch.h | 16 | ||||
-rw-r--r-- | RealtimeSync/resources.cpp | 4 | ||||
-rw-r--r-- | RealtimeSync/tray_menu.cpp | 64 | ||||
-rw-r--r-- | RealtimeSync/watcher.cpp | 69 | ||||
-rw-r--r-- | RealtimeSync/xml_ffs.cpp | 8 |
13 files changed, 156 insertions, 77 deletions
diff --git a/RealtimeSync/RealtimeSync.cbp b/RealtimeSync/RealtimeSync.cbp index 3bf0f88e..cfbdc19e 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_45.a" /> + <Add library="libboost_thread-mgw45-mt-s-1_46_1.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_45.a" /> + <Add library="libboost_thread-mgw45-mt-sd-1_46_1.a" /> <Add directory="C:\Program Files\C++\wxWidgets\lib\gcc_dll" /> </Linker> </Target> @@ -144,6 +144,7 @@ <Unit filename="..\shared\localization.h" /> <Unit filename="..\shared\long_path_prefix.cpp" /> <Unit filename="..\shared\long_path_prefix.h" /> + <Unit filename="..\shared\mouse_move_dlg.cpp" /> <Unit filename="..\shared\privilege.cpp" /> <Unit filename="..\shared\shadow.cpp" /> <Unit filename="..\shared\standard_paths.cpp" /> diff --git a/RealtimeSync/RealtimeSync.ico b/RealtimeSync/RealtimeSync.ico Binary files differindex 8e4e556e..d9fc30ac 100644 --- a/RealtimeSync/RealtimeSync.ico +++ b/RealtimeSync/RealtimeSync.ico diff --git a/RealtimeSync/RealtimeSync.vcxproj b/RealtimeSync/RealtimeSync.vcxproj index e16e892f..c250a421 100644 --- a/RealtimeSync/RealtimeSync.vcxproj +++ b/RealtimeSync/RealtimeSync.vcxproj @@ -238,6 +238,7 @@ <ClCompile Include="..\shared\help_provider.cpp" /> <ClCompile Include="..\shared\localization.cpp" /> <ClCompile Include="..\shared\long_path_prefix.cpp" /> + <ClCompile Include="..\shared\mouse_move_dlg.cpp" /> <ClCompile Include="..\shared\privilege.cpp" /> <ClCompile Include="..\shared\shadow.cpp" /> <ClCompile Include="..\shared\standard_paths.cpp" /> diff --git a/RealtimeSync/application.cpp b/RealtimeSync/application.cpp index 55e46fc6..dffd8970 100644 --- a/RealtimeSync/application.cpp +++ b/RealtimeSync/application.cpp @@ -24,10 +24,10 @@ IMPLEMENT_APP(Application); bool Application::OnInit() { -//do not call wxApp::OnInit() to avoid using default commandline parser + //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 -//for UI update events. This is not the case at the time of OnInit(). + //Note: initialization is done in the FIRST idle event instead of OnInit. Reason: Commandline mode requires the wxApp eventhandler to be established + //for UI update events. This is not the case at the time of OnInit(). Connect(wxEVT_IDLE, wxIdleEventHandler(Application::OnStartApplication), NULL, this); return true; diff --git a/RealtimeSync/main_dlg.cpp b/RealtimeSync/main_dlg.cpp index d832b0aa..a1db4b74 100644 --- a/RealtimeSync/main_dlg.cpp +++ b/RealtimeSync/main_dlg.cpp @@ -22,11 +22,12 @@ #include "../shared/build_info.h" #include "../shared/help_provider.h" #include "../shared/util.h" +#include "../shared/mouse_move_dlg.h" using namespace ffs3; -MainDialog::MainDialog(wxDialog *dlg, const wxString& cfgFileName) +MainDialog::MainDialog(wxDialog* dlg, const wxString& cfgFileName) : MainDlgGenerated(dlg) { wxWindowUpdateLocker dummy(this); //avoid display distortion @@ -44,6 +45,13 @@ MainDialog::MainDialog(wxDialog *dlg, const wxString& cfgFileName) //prepare drag & drop dirNameFirst.reset(new ffs3::DirectoryName(m_panelMainFolder, m_dirPickerMain, m_txtCtrlDirectoryMain)); + +#ifdef FFS_WIN + new MouseMoveWindow(*this, //allow moving main dialog by clicking (nearly) anywhere... + m_panelMain); //ownership passed to "this" +#endif + + //--------------------------- load config values ------------------------------------ xmlAccess::XmlRealConfig newConfig; @@ -99,13 +107,13 @@ MainDialog::~MainDialog() } -void MainDialog::OnClose(wxCloseEvent &event) +void MainDialog::OnClose(wxCloseEvent& event) { Destroy(); } -void MainDialog::OnQuit(wxCommandEvent &event) +void MainDialog::OnQuit(wxCommandEvent& event) { Destroy(); } @@ -172,15 +180,15 @@ void MainDialog::OnStart(wxCommandEvent& event) switch (rts::startDirectoryMonitor(currentCfg, ffs3::extractJobName(currentConfigFileName))) { - case rts::QUIT: - { - Destroy(); - return; - } - break; - - case rts::RESUME: + case rts::QUIT: + { + Destroy(); + return; + } break; + + case rts::RESUME: + break; } Show(); @@ -256,7 +264,7 @@ void MainDialog::setLastUsedConfig(const wxString& filename) } else { - SetTitle(wxString(wxT("RealtimeSync - ")) + filename); + SetTitle(filename); currentConfigFileName = filename; } } @@ -265,8 +273,8 @@ void MainDialog::setLastUsedConfig(const wxString& filename) void MainDialog::OnLoadConfig(wxCommandEvent& event) { wxFileDialog* filePicker = new wxFileDialog(this, wxEmptyString, wxEmptyString, wxEmptyString, - wxString(_("RealtimeSync configuration")) + wxT(" (*.ffs_real;*.ffs_batch)|*.ffs_real;*.ffs_batch"), - wxFD_OPEN); + wxString(_("RealtimeSync configuration")) + wxT(" (*.ffs_real;*.ffs_batch)|*.ffs_real;*.ffs_batch"), + wxFD_OPEN); if (filePicker->ShowModal() == wxID_OK) loadConfig(filePicker->GetPath()); } diff --git a/RealtimeSync/main_dlg.h b/RealtimeSync/main_dlg.h index 7f052e39..a6d2c935 100644 --- a/RealtimeSync/main_dlg.h +++ b/RealtimeSync/main_dlg.h @@ -44,7 +44,7 @@ private: class MainDialog: public MainDlgGenerated { public: - MainDialog(wxDialog *dlg, const wxString& cfgFileName); + MainDialog(wxDialog* dlg, const wxString& cfgFileName); ~MainDialog(); void loadConfig(const wxString& filename); diff --git a/RealtimeSync/notify.cpp b/RealtimeSync/notify.cpp index 182b7cd0..8029da6f 100644 --- a/RealtimeSync/notify.cpp +++ b/RealtimeSync/notify.cpp @@ -199,7 +199,7 @@ public: { const DWORD lastError = ::GetLastError(); 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_SERVICE_SPECIFIC_ERROR) //neither should be fail for "Pogoplug" mapped network drives throw ffs3::FileError(wxString(wxT("Could not register device removal notifications:")) + wxT("\n\n") + ffs3::getLastErrorFormatted(lastError)); } else @@ -243,15 +243,15 @@ private: if (notifications.find(requestNotification) != notifications.end()) //is it for one of our notifications we registered? switch (wParam) { - case DBT_DEVICEQUERYREMOVE: - parent_.onRequestRemoval(body->dbch_handle); - break; - case DBT_DEVICEQUERYREMOVEFAILED: - parent_.onRemovalFinished(body->dbch_handle, false); - break; - case DBT_DEVICEREMOVECOMPLETE: - parent_.onRemovalFinished(body->dbch_handle, true); - break; + case DBT_DEVICEQUERYREMOVE: + parent_.onRequestRemoval(body->dbch_handle); + break; + case DBT_DEVICEQUERYREMOVEFAILED: + parent_.onRemovalFinished(body->dbch_handle, false); + break; + case DBT_DEVICEREMOVECOMPLETE: + parent_.onRemovalFinished(body->dbch_handle, true); + break; } } } diff --git a/RealtimeSync/notify.h b/RealtimeSync/notify.h index 1f7a204a..47f6c3cb 100644 --- a/RealtimeSync/notify.h +++ b/RealtimeSync/notify.h @@ -8,7 +8,7 @@ #define NOTIFY_H_INCLUDED #ifndef FFS_WIN -use in windows build only +#error use in windows build only #endif #include <wx/msw/wrapwin.h> //includes "windows.h" diff --git a/RealtimeSync/pch.h b/RealtimeSync/pch.h index 9894b1c5..b3412782 100644 --- a/RealtimeSync/pch.h +++ b/RealtimeSync/pch.h @@ -12,18 +12,18 @@ do NOT use in release build! #endif -//##################################################### -// basic wxWidgets headers + //##################################################### + // basic wxWidgets headers #ifndef WX_PRECOMP #define WX_PRECOMP #endif #include <wx/wxprec.h> -//##################################################### -// #include other rarely changing headers here + //##################################################### + // #include other rarely changing headers here -//STL headers + //STL headers #include <string> #include <algorithm> #include <vector> @@ -38,7 +38,7 @@ do NOT use in release build! #include <utime.h> #endif //FFS_LINUX -//other wxWidgets headers + //other wxWidgets headers #include <wx/grid.h> #include <wx/animate.h> #include <wx/app.h> @@ -91,13 +91,13 @@ do NOT use in release build! #include <wx/scrolwin.h> #include <wx/notebook.h> -//other + //other #include "../shared/tinyxml/tinyxml.h" #include <sys/stat.h> #ifdef FFS_WIN #include <wx/msw/wrapwin.h> //includes "windows.h" #endif //FFS_WIN -//##################################################### + //##################################################### #endif //RTS_PRECOMPILED_HEADER
\ No newline at end of file diff --git a/RealtimeSync/resources.cpp b/RealtimeSync/resources.cpp index f966d4fa..64de4700 100644 --- a/RealtimeSync/resources.cpp +++ b/RealtimeSync/resources.cpp @@ -80,8 +80,8 @@ void GlobalResources::load() const const wxBitmap& GlobalResources::getImageByName(const wxString& imageName) const { const std::map<wxString, wxBitmap*>::const_iterator bmp = imageName.Find(wxChar('.')) == wxNOT_FOUND ? //assume .png ending if nothing else specified - bitmapResource.find(imageName + wxT(".png")) : - bitmapResource.find(imageName); + bitmapResource.find(imageName + wxT(".png")) : + bitmapResource.find(imageName); if (bmp != bitmapResource.end()) return *bmp->second; diff --git a/RealtimeSync/tray_menu.cpp b/RealtimeSync/tray_menu.cpp index c85df169..4123664c 100644 --- a/RealtimeSync/tray_menu.cpp +++ b/RealtimeSync/tray_menu.cpp @@ -172,36 +172,36 @@ void TrayIconHolder::OnContextMenuSelection(wxCommandEvent& event) const int eventId = event.GetId(); switch (static_cast<Selection>(eventId)) { - case CONTEXT_ABORT: - requestAbort(); - break; - case CONTEXT_RESTORE: - OnRequestResume(event); //just remember: never throw exceptions through a C-Layer (GUI) ;) - break; - case CONTEXT_ABOUT: - { - //build information - wxString build = __TDATE__; + case CONTEXT_ABORT: + requestAbort(); + break; + case CONTEXT_RESTORE: + OnRequestResume(event); //just remember: never throw exceptions through a C-Layer (GUI) ;) + break; + case CONTEXT_ABOUT: + { + //build information + wxString build = __TDATE__; #if wxUSE_UNICODE - build += wxT(" - Unicode"); + build += wxT(" - Unicode"); #else - build += wxT(" - ANSI"); + build += wxT(" - ANSI"); #endif //wxUSE_UNICODE - //compile time info about 32/64-bit build - if (util::is64BitBuild) - build += wxT(" x64"); - else - build += wxT(" x86"); - assert_static(util::is32BitBuild || util::is64BitBuild); + //compile time info about 32/64-bit build + if (util::is64BitBuild) + build += wxT(" x64"); + else + 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(NULL, wxString(wxT("RealtimeSync")) + wxT("\n\n") + buildFormatted, _("About"), wxOK); - aboutDlg.ShowModal(); - } - break; + wxMessageDialog aboutDlg(NULL, wxString(wxT("RealtimeSync")) + wxT("\n\n") + buildFormatted, _("About"), wxOK); + aboutDlg.ShowModal(); + } + break; } } @@ -322,14 +322,14 @@ rts::MonitorResponse rts::startDirectoryMonitor(const xmlAccess::XmlRealConfig& //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; + 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)); diff --git a/RealtimeSync/watcher.cpp b/RealtimeSync/watcher.cpp index 029b2d00..d28c4488 100644 --- a/RealtimeSync/watcher.cpp +++ b/RealtimeSync/watcher.cpp @@ -19,6 +19,8 @@ #include <wx/msw/wrapwin.h> //includes "windows.h" #include "../shared/long_path_prefix.h" #include <boost/shared_ptr.hpp> +#include "../shared/loki/ScopeGuard.h" +#include <boost/scoped_array.hpp> #elif defined FFS_LINUX #include "../shared/inotify/inotify-cxx.h" @@ -110,8 +112,73 @@ private: }; + rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCallback* statusHandler) //throw(FileError) { + /* + #warning cleanup + { + const Zstring formattedDir = ffs3::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(), + 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, + OPEN_EXISTING, + FILE_FLAG_BACKUP_SEMANTICS, + NULL); + if (hDir == INVALID_HANDLE_VALUE) + { + const DWORD lastError = ::GetLastError(); + if ( lastError == ERROR_FILE_NOT_FOUND || //no need to check this condition any earlier! + lastError == ERROR_BAD_NETPATH) // + 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()); + } + + Loki::ScopeGuard dummy = Loki::MakeGuard(::CloseHandle, hDir); + (void)dummy; //silence warning "unused variable" + + + const size_t bufferSize = sizeof(FILE_NOTIFY_INFORMATION); + boost::scoped_array<char> tmp(new char[bufferSize]); + FILE_NOTIFY_INFORMATION& notifyInfo = reinterpret_cast<FILE_NOTIFY_INFORMATION&>(*tmp.get()); + + DWORD bytesWritten = 0; + + if (!::ReadDirectoryChangesW( + hDir, //__in HANDLE hDirectory, + ¬ifyInfo, //__out LPVOID lpBuffer, + bufferSize, //__in DWORD nBufferLength, + true, //__in BOOL bWatchSubtree, + FILE_NOTIFY_CHANGE_FILE_NAME | //__in DWORD dwNotifyFilter, + FILE_NOTIFY_CHANGE_DIR_NAME | + FILE_NOTIFY_CHANGE_SIZE | + FILE_NOTIFY_CHANGE_LAST_WRITE, + &bytesWritten, //__out_opt LPDWORD lpBytesReturned, + NULL, //__inout_opt LPOVERLAPPED lpOverlapped, + 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()); + } + return CHANGE_DETECTED; + } + */ + + + + + + + + + if (dirNames.empty()) //pathological case, but check is needed nevertheless throw ffs3::FileError(_("At least one directory input field is empty.")); @@ -146,7 +213,7 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa lastError == ERROR_BAD_NETPATH) // return CHANGE_DIR_MISSING; - const wxString errorMessage = wxString(_("Could not initialize directory monitoring:")) + wxT("\n\"") + zToWx(*i) + wxT("\""); + const wxString errorMessage = wxString(_("Could not initialize directory monitoring:")) + wxT("\n\"") + zToWx(formattedDir) + wxT("\""); throw ffs3::FileError(errorMessage + wxT("\n\n") + ffs3::getLastErrorFormatted()); } diff --git a/RealtimeSync/xml_ffs.cpp b/RealtimeSync/xml_ffs.cpp index be798efc..1c98cc57 100644 --- a/RealtimeSync/xml_ffs.cpp +++ b/RealtimeSync/xml_ffs.cpp @@ -45,21 +45,23 @@ xmlAccess::XmlRealConfig convertBatchToReal(const xmlAccess::XmlBatchConfig& bat //additional folders for (std::vector<ffs3::FolderPairEnh>::const_iterator i = batchCfg.mainCfg.additionalPairs.begin(); - i != batchCfg.mainCfg.additionalPairs.end(); ++i) + i != batchCfg.mainCfg.additionalPairs.end(); ++i) { uniqueFolders.insert(zToWx(i->leftDirectory)); uniqueFolders.insert(zToWx(i->rightDirectory)); } + uniqueFolders.erase(wxString()); + output.directories.insert(output.directories.end(), uniqueFolders.begin(), uniqueFolders.end()); - output.commandline = ffs3::getBinaryDir() + + output.commandline = wxT("\"") + ffs3::getBinaryDir() + #ifdef FFS_WIN wxT("FreeFileSync.exe") + #elif defined FFS_LINUX wxT("FreeFileSync") + #endif - wxT(" \"") + filename + wxT("\""); + wxT("\" \"") + filename + wxT("\""); return output; } |