bool CBookmarksDialog::Verify() { wxTreeItemId item = m_pTree->GetSelection(); if (!item) return true; CBookmarkItemData *data = (CBookmarkItemData *)m_pTree->GetItemData(item); if (!data) return true; const CServer *server; if (m_pTree->GetItemParent(item) == m_bookmarks_site) server = m_server; else server = 0; const wxString remotePathRaw = XRCCTRL(*this, "ID_BOOKMARK_REMOTEDIR", wxTextCtrl)->GetValue(); if (!remotePathRaw.empty()) { CServerPath remotePath; if (server) remotePath.SetType(server->GetType()); if (!remotePath.SetPath(remotePathRaw)) { XRCCTRL(*this, "ID_BOOKMARK_REMOTEDIR", wxTextCtrl)->SetFocus(); if (server) { wxString msg; if (server->GetType() != DEFAULT) msg = wxString::Format(_("Remote path cannot be parsed. Make sure it is a valid absolute path and is supported by the current site's servertype (%s)."), server->GetNameFromServerType(server->GetType())); else msg = _("Remote path cannot be parsed. Make sure it is a valid absolute path."); wxMessageBoxEx(msg); } else wxMessageBoxEx(_("Remote path cannot be parsed. Make sure it is a valid absolute path.")); return false; } } const wxString localPath = XRCCTRL(*this, "ID_BOOKMARK_LOCALDIR", wxTextCtrl)->GetValue(); if (remotePathRaw.empty() && localPath.empty()) { XRCCTRL(*this, "ID_BOOKMARK_LOCALDIR", wxTextCtrl)->SetFocus(); wxMessageBoxEx(_("You need to enter at least one path, empty bookmarks are not supported.")); return false; } bool sync = XRCCTRL(*this, "ID_BOOKMARK_SYNC", wxCheckBox)->GetValue(); if (sync && (localPath.empty() || remotePathRaw.empty())) { wxMessageBoxEx(_("You need to enter both a local and a remote path to enable synchronized browsing for this bookmark."), _("New bookmark"), wxICON_EXCLAMATION, this); return false; } return true; }
void CSearchDialog::OnSearch(wxCommandEvent& event) { if (!m_pState->IsRemoteIdle()) { wxBell(); return; } CServerPath path; const CServer* pServer = m_pState->GetServer(); if (!pServer) { wxMessageBox(_("Connection to server lost."), _("Remote file search"), wxICON_EXCLAMATION); return; } path.SetType(pServer->GetType()); if (!path.SetPath(XRCCTRL(*this, "ID_PATH", wxTextCtrl)->GetValue()) || path.IsEmpty()) { wxMessageBox(_("Need to enter valid remote path"), _("Remote file search"), wxICON_EXCLAMATION); return; } m_search_root = path; // Prepare filter wxString error; if (!ValidateFilter(error, true)) { wxMessageBox(wxString::Format(_("Invalid search conditions: %s"), error.c_str()), _("Remote file search"), wxICON_EXCLAMATION); return; } m_search_filter = GetFilter(); if (!CFilterManager::CompileRegexes(m_search_filter)) { wxMessageBox(_("Invalid regular expression in search conditions."), _("Remote file search"), wxICON_EXCLAMATION); return; } m_search_filter.matchCase = XRCCTRL(*this, "ID_CASE", wxCheckBox)->GetValue(); // Delete old results m_results->ClearSelection(); m_results->m_indexMapping.clear(); m_results->m_fileData.clear(); m_results->SetItemCount(0); m_visited.clear(); m_results->RefreshListOnly(true); m_results->GetFilelistStatusBar()->Clear(); // Start m_searching = true; m_pState->GetRecursiveOperationHandler()->AddDirectoryToVisitRestricted(path, _T(""), true); std::list<CFilter> filters; // Empty, recurse into everything m_pState->GetRecursiveOperationHandler()->StartRecursiveOperation(CRecursiveOperation::recursive_list, path, filters, true); }
int CUpdateWizard::SendTransferCommand() { m_inTransfer = true; CFileTransferCommand::t_transferSettings transferSettings; CServerPath path; wxString file = m_urlFile; path.SetPath(file, true); CFileTransferCommand cmd(m_localFile, path, file, true, transferSettings); return m_pEngine->Command(cmd); }
void CRemoteViewHeader::OnSelectionChanged(wxCommandEvent& event) { const wxString& dir = event.GetString(); if (dir == _T("")) return; CServerPath path = m_path; if (!path.SetPath(dir)) { wxBell(); return; } if (!m_pState->m_pCommandQueue->Idle()) { wxBell(); return; } m_pState->ChangeRemoteDir(path); }
BOOL CServerPath::ChangePath(CString &subdir, BOOL bIsFile /*=FALSE*/) { CServerPath newpath = *this; CString dir = subdir; if (!(newpath.m_nServerType&FZ_SERVERTYPE_HIGHMASK)) newpath.m_nServerType = FZ_SERVERTYPE_FTP; dir.TrimLeft(_T(" ")); dir.TrimRight(_T(" ")); if ( dir==_T("") ) { if (newpath.IsEmpty() || bIsFile) return FALSE; else { *this=newpath; return TRUE; } } switch (newpath.m_nServerType&FZ_SERVERTYPE_HIGHMASK) { case FZ_SERVERTYPE_FTP: switch(newpath.m_nServerType&FZ_SERVERTYPE_SUBMASK) { case FZ_SERVERTYPE_SUB_FTP_MVS: case FZ_SERVERTYPE_SUB_FTP_BS2000: subdir.TrimLeft(FTP_MVS_DOUBLE_QUOTA); subdir.TrimRight(FTP_MVS_DOUBLE_QUOTA); if (subdir.Left(1) == _MPT("'")) { if (subdir.Right(1) != _MPT("'")) return FALSE; if (!newpath.SetPath(subdir, bIsFile)) return FALSE; } else if (subdir.Right(1) == _MPT("'")) return FALSE; else if (!newpath.IsEmpty()) { if (m_Prefix != _T(".")) return FALSE; subdir.TrimLeft(_MPT('.')); while (subdir.Replace(_T(".."), _T("."))); int pos = subdir.Find(_MPT('.')); while (pos != -1) { newpath.m_Segments.push_back(subdir.Left(pos)); subdir = subdir.Mid(pos + 1); } if (subdir != _T("")) { newpath.m_Segments.push_back(subdir); newpath.m_Prefix = _T(""); } else newpath.m_Prefix = _T("."); if (bIsFile) { if (newpath.m_Prefix == _T(".")) return false; if (newpath.m_Segments.empty()) return false; subdir = newpath.m_Segments.back(); newpath.m_Segments.pop_back(); int pos = subdir.Find(_MPT('(')); int pos2 = subdir.Find(_MPT(')')); if (pos != -1) { if (!pos || pos2 != subdir.GetLength() - 2) return false; newpath.m_Segments.push_back(subdir.Left(pos)); subdir = subdir.Mid(pos + 1, pos2 - pos - 1); } else if (pos2 != -1) return false; else newpath.m_Prefix = _T("."); } } else if (!newpath.SetPath(subdir, bIsFile)) return FALSE; break; case FZ_SERVERTYPE_SUB_FTP_VMS: { int pos1=dir.Find( _T("[") ); if (pos1==-1) { int pos2=dir.ReverseFind(_MPT(']')); if (pos2!=-1) return FALSE; if (bIsFile) { if (newpath.IsEmpty()) return FALSE; subdir=dir; *this=newpath; return TRUE; } while ( dir.Replace( _T(".."), _T(".") ) ); } else { int pos2=dir.ReverseFind(_MPT(']')); if (pos2==-1) return FALSE; if (bIsFile && pos2==(dir.GetLength()-1)) return FALSE; if (!bIsFile && pos2!=(dir.GetLength()-1)) return FALSE; if (pos2<=pos1) return FALSE; if (bIsFile) subdir=dir.Mid(pos2+2); dir=dir.Left(pos2); if (pos1) newpath.m_Prefix=dir.Left(pos1); else newpath.m_Prefix=_MPT(""); newpath.m_Segments.clear(); dir=dir.Mid(pos1+1); pos1=dir.Find( _T("[") ); pos2=dir.Find( _T("]") ); if (pos1!=-1 || pos2!=-1) return FALSE; } int pos=dir.Find( _T(".") ); while(pos!=-1) { newpath.m_Segments.push_back(dir.Left(pos)); dir=dir.Mid(pos+1); pos=dir.Find( _T(".") ); } if (dir!=_MPT("")) newpath.m_Segments.push_back(dir); } break; case FZ_SERVERTYPE_SUB_FTP_WINDOWS: { dir.Replace( _T("\\"), _T("/") ); while(dir.Replace( _T("//"), _T("/") )); if (dir.GetLength() >= 2 && dir[1] == _MPT(':')) newpath.m_Segments.clear(); else if (dir[0]==_MPT('/')) { CString firstSegment; if (newpath.m_Segments.empty()) firstSegment = _MPT("C:"); else firstSegment = newpath.m_Segments.front(); newpath.m_Segments.clear(); newpath.m_Segments.push_back(firstSegment); dir.TrimLeft( _T("/") ); } if (newpath.IsEmpty()) return FALSE; if (dir.Right(1)==_T("/") && bIsFile) return FALSE; dir.TrimRight( _T("/") ); int pos=dir.ReverseFind(_MPT('/')); if (bIsFile) if (pos==-1) { subdir=dir; newpath.m_bEmpty=FALSE; *this=newpath; return TRUE; } else { subdir=dir.Mid(pos+1); dir=dir.Left(pos); dir.TrimRight( _T("/") ); } pos=dir.Find( _T("/") ); while(pos!=-1) { newpath.m_Segments.push_back(dir.Left(pos)); dir=dir.Mid(pos+1); pos=dir.Find( _T("/") ); } if (dir!=_MPT("")) newpath.m_Segments.push_back(dir); break; } case FZ_SERVERTYPE_SUB_FTP_UNKNOWN: dir.Replace(_MPT('.'), _MPT('/')); dir = _T("/") + dir; default: dir.Replace( _T("\\"), _T("/") ); while(dir.Replace( _T("//"), _T("/") )); if (dir[0]==_MPT('/')) { newpath.m_Segments.clear(); if (dir!="/") dir.TrimLeft( _T("/") ); } else if (newpath.IsEmpty()) return FALSE; if (dir.Right(1)==_T("/") && bIsFile) return FALSE; dir.TrimRight( _T("/") ); int pos=dir.ReverseFind(_MPT('/')); if (bIsFile) if (pos==-1) { subdir=dir; newpath.m_bEmpty=FALSE; *this=newpath; return TRUE; } else { subdir=dir.Mid(pos+1); dir=dir.Left(pos); dir.TrimRight( _T("/") ); } pos=dir.Find( _T("/") ); while(pos!=-1) { newpath.m_Segments.push_back(dir.Left(pos)); dir=dir.Mid(pos+1); pos=dir.Find( _T("/") ); } if (dir!=_MPT("")) newpath.m_Segments.push_back(dir); break; } break; case FZ_SERVERTYPE_LOCAL: { if (dir.Right(1)==_T("\\") && bIsFile) return FALSE; dir.TrimRight( _T("\\") ); while (dir.Replace( _T("\\\\"), _T("\\") )); if ( dir.Left(1) == _T("\\") ) newpath.m_Segments.clear(); else if (newpath.IsEmpty()) return FALSE; dir.TrimLeft( _T("\\") ); if (bIsFile) { int pos=dir.ReverseFind(_MPT('\\')); if (pos==-1) { if (dir.Find( _T(":") )!=-1) return FALSE; subdir=dir; newpath.m_bEmpty=FALSE; *this=newpath; return TRUE; } else { if (dir.Find( _T(":"), pos+1)!=-1) return FALSE; subdir=dir.Mid(pos+1); dir=dir.Left(pos); } } int pos=dir.Find( _T(":") ); if (pos==1) //dir is absolute path { newpath.m_Segments.clear(); newpath.m_Prefix=dir.Left(pos+1); dir=dir.Mid(pos+1); dir.TrimLeft( _T("\\") ); if (dir.Find( _T(":") )!=-1) return FALSE; } if (pos==-1 || pos==1) { pos=dir.Find( _T("\\") ); while (pos!=-1) { newpath.m_Segments.push_back(dir.Left(pos)); dir=dir.Mid(pos+1); pos=dir.Find( _T("\\") ); } if (dir!=_MPT("")) newpath.m_Segments.push_back(dir); } else return FALSE; } break; default: return FALSE; } newpath.m_bEmpty=FALSE; *this=newpath; return TRUE; }