void CImportDialog::Run() { wxFileDialog dlg(m_parent, _("Select file to import settings from"), wxString(), _T("FileZilla.xml"), _T("XML files (*.xml)|*.xml"), wxFD_OPEN | wxFD_FILE_MUST_EXIST); dlg.CenterOnParent(); if (dlg.ShowModal() != wxID_OK) return; wxFileName fn(dlg.GetPath()); wxString const path = fn.GetPath(); wxString const settingsDir(COptions::Get()->GetOption(OPTION_DEFAULT_SETTINGSDIR)); if (path == settingsDir) { wxMessageBoxEx(_("You cannot import settings from FileZilla's own settings directory."), _("Error importing"), wxICON_ERROR, m_parent); return; } CXmlFile fz3(dlg.GetPath()); TiXmlElement* fz3Root = fz3.Load(); if (fz3Root) { bool settings = fz3Root->FirstChildElement("Settings") != 0; bool queue = fz3Root->FirstChildElement("Queue") != 0; bool sites = fz3Root->FirstChildElement("Servers") != 0; if (settings || queue || sites) { if (!Load(m_parent, _T("ID_IMPORT"))) { wxBell(); return; } if (!queue) XRCCTRL(*this, "ID_QUEUE", wxCheckBox)->Hide(); if (!sites) XRCCTRL(*this, "ID_SITEMANAGER", wxCheckBox)->Hide(); if (!settings) XRCCTRL(*this, "ID_SETTINGS", wxCheckBox)->Hide(); GetSizer()->Fit(this); if (ShowModal() != wxID_OK) { return; } if (fz3.IsFromFutureVersion()) { wxString msg = wxString::Format(_("The file '%s' has been created by a more recent version of FileZilla.\nLoading files created by newer versions can result in loss of data.\nDo you want to continue?"), fz3.GetFileName()); if (wxMessageBoxEx(msg, _("Detected newer version of FileZilla"), wxICON_QUESTION | wxYES_NO) != wxYES) { return; } } if (queue && XRCCTRL(*this, "ID_QUEUE", wxCheckBox)->IsChecked()) { m_pQueueView->ImportQueue(fz3Root->FirstChildElement("Queue"), true); } if (sites && XRCCTRL(*this, "ID_SITEMANAGER", wxCheckBox)->IsChecked()) { ImportSites(fz3Root->FirstChildElement("Servers")); } if (settings && XRCCTRL(*this, "ID_SETTINGS", wxCheckBox)->IsChecked()) { COptions::Get()->Import(fz3Root->FirstChildElement("Settings")); wxMessageBoxEx(_("The settings have been imported. You have to restart FileZilla for all settings to have effect."), _("Import successful"), wxOK, this); } wxMessageBoxEx(_("The selected categories have been imported."), _("Import successful"), wxOK, this); return; } } CXmlFile fz2(dlg.GetPath(), _T("FileZilla")); TiXmlElement* fz2Root = fz2.Load(); if (fz2Root) { TiXmlElement* sites_fz2 = fz2Root->FirstChildElement("Sites"); if (sites_fz2) { int res = wxMessageBoxEx(_("The file you have selected contains site manager data from a previous version of FileZilla.\nDue to differences in the storage format, only host, port, username and password will be imported.\nContinue with the import?"), _("Import data from older version"), wxICON_QUESTION | wxYES_NO); if (res == wxYES) ImportLegacySites(sites_fz2); return; } } wxMessageBoxEx(_("File does not contain any importable data."), _("Error importing"), wxICON_ERROR, m_parent); }
void CRemoteTreeView::OnBeginDrag(wxTreeEvent& event) { // Drag could result in recursive operation, don't allow at this point if (!m_pState->IsRemoteIdle()) { wxBell(); return; } const wxTreeItemId& item = event.GetItem(); if (!item) return; const CServerPath& path = GetPathFromItem(item); if (path.empty() || !path.HasParent()) return; const CServerPath& parent = path.GetParent(); const wxString& lastSegment = path.GetLastSegment(); if (lastSegment.empty()) return; wxDataObjectComposite object; const CServer* const pServer = m_pState->GetServer(); if (!pServer) return; CRemoteDataObject *pRemoteDataObject = new CRemoteDataObject(*pServer, parent); pRemoteDataObject->AddFile(lastSegment, true, -1, false); pRemoteDataObject->Finalize(); object.Add(pRemoteDataObject, true); #if FZ3_USESHELLEXT CShellExtensionInterface* ext = CShellExtensionInterface::CreateInitialized(); if (ext) { const wxString& file = ext->GetDragDirectory(); wxASSERT(!file.empty()); wxFileDataObject *pFileDataObject = new wxFileDataObject; pFileDataObject->AddFile(file); object.Add(pFileDataObject); } #endif CDragDropManager* pDragDropManager = CDragDropManager::Init(); pDragDropManager->pDragSource = this; pDragDropManager->server = *pServer; pDragDropManager->remoteParent = parent; wxDropSource source(this); source.SetData(object); int res = source.DoDragDrop(); pDragDropManager->Release(); if (res != wxDragCopy) { #if FZ3_USESHELLEXT delete ext; ext = 0; #endif return; } #if FZ3_USESHELLEXT if (ext) { if (!pRemoteDataObject->DidSendData()) { const CServer* const pServer = m_pState->GetServer(); if (!pServer || !m_pState->IsRemoteIdle()) { wxBell(); delete ext; ext = 0; return; } CLocalPath target(ext->GetTarget()); if (target.empty()) { delete ext; ext = 0; wxMessageBoxEx(_("Could not determine the target of the Drag&Drop operation.\nEither the shell extension is not installed properly or you didn't drop the files into an Explorer window.")); return; } m_pState->DownloadDroppedFiles(pRemoteDataObject, target); delete ext; ext = 0; return; } delete ext; ext = 0; } #endif }