bool CState::Connect(const CServer& server, const CServerPath& path /*=CServerPath()*/) { if (!m_pEngine) return false; if (m_pEngine->IsConnected() || m_pEngine->IsBusy() || !m_pCommandQueue->Idle()) m_pCommandQueue->Cancel(); m_pRecursiveOperation->StopRecursiveOperation(); SetSyncBrowse(false); m_pCommandQueue->ProcessCommand(new CConnectCommand(server)); m_pCommandQueue->ProcessCommand(new CListCommand(path, _T(""), LIST_FLAG_FALLBACK_CURRENT)); SetServer(&server); return true; }
bool CState::ChangeRemoteDir(const CServerPath& path, const wxString& subdir /*=_T("")*/, int flags /*=0*/, bool ignore_busy /*=false*/) { if (!m_pServer || !m_pCommandQueue) return false; if (!m_sync_browse.local_root.empty()) { CServerPath p(path); if (!subdir.empty() && !p.ChangePath(subdir)) { wxString msg = wxString::Format(_("Could not get full remote path.")); wxMessageBoxEx(msg, _("Synchronized browsing")); return false; } if (p != m_sync_browse.remote_root && !p.IsSubdirOf(m_sync_browse.remote_root, false)) { wxString msg = wxString::Format(_("The remote directory '%s' is not below the synchronization root (%s).\nDisable synchronized browsing and continue changing the remote directory?"), p.GetPath(), m_sync_browse.remote_root.GetPath()); if (wxMessageBoxEx(msg, _("Synchronized browsing"), wxICON_QUESTION | wxYES_NO) != wxYES) return false; SetSyncBrowse(false); } else if (!IsRemoteIdle() && !ignore_busy) { wxString msg(_("Another remote operation is already in progress, cannot change directory now.")); wxMessageBoxEx(msg, _("Synchronized browsing"), wxICON_EXCLAMATION); return false; } else { wxString error; CLocalPath local_path = GetSynchronizedDirectory(p); if (local_path.empty()) { wxString msg = wxString::Format(_("Could not obtain corresponding local directory for the remote directory '%s'.\nDisable synchronized browsing and continue changing the remote directory?"), p.GetPath()); if (wxMessageBoxEx(msg, _("Synchronized browsing"), wxICON_QUESTION | wxYES_NO) != wxYES) return false; SetSyncBrowse(false); } else if (!local_path.Exists(&error)) { wxString msg = error + _T("\n") + _("Disable synchronized browsing and continue changing the remote directory?"); if (wxMessageBoxEx(msg, _("Synchronized browsing"), wxICON_QUESTION | wxYES_NO) != wxYES) return false; SetSyncBrowse(false); } else { m_sync_browse.is_changing = true; m_sync_browse.compare = m_pComparisonManager->IsComparing(); } } } CListCommand *pCommand = new CListCommand(path, subdir, flags); m_pCommandQueue->ProcessCommand(pCommand); return true; }
bool CState::SetLocalDir(CLocalPath const& dir, wxString *error, bool rememberPreviousSubdir) { if (m_sync_browse.is_changing) { wxMessageBoxEx(_T("Cannot change directory, there already is a synchronized browsing operation in progress."), _("Synchronized browsing")); return false; } if (!dir.Exists(error)) return false; if (!m_sync_browse.local_root.empty()) { wxASSERT(m_pServer); if (dir != m_sync_browse.local_root && !dir.IsSubdirOf(m_sync_browse.local_root)) { wxString msg = wxString::Format(_("The local directory '%s' is not below the synchronization root (%s).\nDisable synchronized browsing and continue changing the local directory?"), dir.GetPath(), m_sync_browse.local_root.GetPath()); if (wxMessageBoxEx(msg, _("Synchronized browsing"), wxICON_QUESTION | wxYES_NO) != wxYES) return false; SetSyncBrowse(false); } else if (!IsRemoteIdle()) { wxString msg(_("A remote operation is in progress and synchronized browsing is enabled.\nDisable synchronized browsing and continue changing the local directory?")); if (wxMessageBoxEx(msg, _("Synchronized browsing"), wxICON_QUESTION | wxYES_NO) != wxYES) return false; SetSyncBrowse(false); } else { CServerPath remote_path = GetSynchronizedDirectory(dir); if (remote_path.empty()) { SetSyncBrowse(false); wxString msg = wxString::Format(_("Could not obtain corresponding remote directory for the local directory '%s'.\nSynchronized browsing has been disabled."), dir.GetPath()); wxMessageBoxEx(msg, _("Synchronized browsing")); return false; } m_sync_browse.is_changing = true; m_sync_browse.compare = m_pComparisonManager->IsComparing(); CListCommand *pCommand = new CListCommand(remote_path); m_pCommandQueue->ProcessCommand(pCommand); return true; } } if (dir == m_localDir.GetParent() && rememberPreviousSubdir) { #ifdef __WXMSW__ if (dir.GetPath() == _T("\\")) { m_previouslyVisitedLocalSubdir = m_localDir.GetPath(); m_previouslyVisitedLocalSubdir.RemoveLast(); } else #endif m_previouslyVisitedLocalSubdir = m_localDir.GetLastSegment(); } else m_previouslyVisitedLocalSubdir = _T(""); m_localDir = dir; COptions::Get()->SetOption(OPTION_LASTLOCALDIR, m_localDir.GetPath()); NotifyHandlers(STATECHANGE_LOCAL_DIR); return true; }
bool CState::SetRemoteDir(std::shared_ptr<CDirectoryListing> const& pDirectoryListing, bool modified) { if (!pDirectoryListing) { SetSyncBrowse(false); if (modified) return false; if (m_pDirectoryListing) { m_pDirectoryListing = 0; NotifyHandlers(STATECHANGE_REMOTE_DIR); } m_previouslyVisitedRemoteSubdir = _T(""); return true; } wxASSERT(pDirectoryListing->m_firstListTime.IsValid()); if (pDirectoryListing && m_pDirectoryListing && pDirectoryListing->path == m_pDirectoryListing->path.GetParent()) m_previouslyVisitedRemoteSubdir = m_pDirectoryListing->path.GetLastSegment(); else m_previouslyVisitedRemoteSubdir = _T(""); if (modified) { if (!m_pDirectoryListing || m_pDirectoryListing->path != pDirectoryListing->path) { // We aren't interested in these listings return true; } } else m_last_path = pDirectoryListing->path; if (m_pDirectoryListing && m_pDirectoryListing->path == pDirectoryListing->path && pDirectoryListing->failed()) { // We still got an old listing, no need to display the new one return true; } m_pDirectoryListing = pDirectoryListing; if (!modified) NotifyHandlers(STATECHANGE_REMOTE_DIR); else NotifyHandlers(STATECHANGE_REMOTE_DIR_MODIFIED); if (m_sync_browse.is_changing && !modified) { m_sync_browse.is_changing = false; if (m_pDirectoryListing->path != m_sync_browse.remote_root && !m_pDirectoryListing->path.IsSubdirOf(m_sync_browse.remote_root, false)) { SetSyncBrowse(false); wxString msg = wxString::Format(_("Current remote directory (%s) is not below the synchronization root (%s).\nSynchronized browsing has been disabled."), m_pDirectoryListing->path.GetPath(), m_sync_browse.remote_root.GetPath()); wxMessageBoxEx(msg, _("Synchronized browsing")); } else { CLocalPath local_path = GetSynchronizedDirectory(m_pDirectoryListing->path); if (local_path.empty()) { SetSyncBrowse(false); wxString msg = wxString::Format(_("Could not obtain corresponding local directory for the remote directory '%s'.\nSynchronized browsing has been disabled."), m_pDirectoryListing->path.GetPath()); wxMessageBoxEx(msg, _("Synchronized browsing")); return true; } wxString error; if (!local_path.Exists(&error)) { SetSyncBrowse(false); wxString msg = error + _T("\n") + _("Synchronized browsing has been disabled."); wxMessageBoxEx(msg, _("Synchronized browsing")); return true; } m_localDir = local_path; COptions::Get()->SetOption(OPTION_LASTLOCALDIR, m_localDir.GetPath()); NotifyHandlers(STATECHANGE_LOCAL_DIR); if (m_sync_browse.compare) m_pComparisonManager->CompareListings(); } } return true; }
bool CState::SetLocalDir(const wxString& dir, wxString *error /*=0*/) { if (m_sync_browse.is_changing) { wxMessageBox(_T("Cannot change directory, there already is a synchronized browsing operation in progress."), _("Synchronized browsing")); return false; } CLocalPath p(m_localDir); #ifdef __WXMSW__ if (dir == _T("..") && !p.HasParent() && p.HasLogicalParent()) { // Parent of C:\ is drive list if (!p.MakeParent()) return false; } else #endif if (!p.ChangePath(dir)) return false; if (!p.Exists(error)) return false; if (!m_sync_browse.local_root.empty()) { wxASSERT(m_pServer); if (p != m_sync_browse.local_root && !p.IsSubdirOf(m_sync_browse.local_root)) { wxString msg = wxString::Format(_("The local directory '%s' is not below the synchronization root (%s).\nDisable synchronized browsing and continue changing the local directory?"), p.GetPath().c_str(), m_sync_browse.local_root.GetPath().c_str()); if (wxMessageBox(msg, _("Synchronized browsing"), wxICON_QUESTION | wxYES_NO) != wxYES) return false; SetSyncBrowse(false); } else if (!IsRemoteIdle()) { wxString msg(_("A remote operation is in progress and synchronized browsing is enabled.\nDisable synchronized browsing and continue changing the local directory?")); if (wxMessageBox(msg, _("Synchronized browsing"), wxICON_QUESTION | wxYES_NO) != wxYES) return false; SetSyncBrowse(false); } else { CServerPath remote_path = GetSynchronizedDirectory(p); if (remote_path.IsEmpty()) { SetSyncBrowse(false); wxString msg = wxString::Format(_("Could not obtain corresponding remote directory for the local directory '%s'.\nSynchronized browsing has been disabled."), p.GetPath().c_str()); wxMessageBox(msg, _("Synchronized browsing")); return false; } m_sync_browse.is_changing = true; m_sync_browse.compare = m_pComparisonManager->IsComparing(); CListCommand *pCommand = new CListCommand(remote_path); m_pCommandQueue->ProcessCommand(pCommand); return true; } } m_localDir = p; COptions::Get()->SetOption(OPTION_LASTLOCALDIR, m_localDir.GetPath()); NotifyHandlers(STATECHANGE_LOCAL_DIR); return true; }