"Fossies" - the Fresh Open Source Software Archive

Member "filezilla-3.48.1/src/interface/settings/optionspage_connection_ftp.cpp" (8 May 2020, 2919 Bytes) of package /linux/misc/FileZilla_3.48.1_src.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "optionspage_connection_ftp.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 3.48.0_vs_3.48.1.

    1 #include <filezilla.h>
    2 #include "../Options.h"
    3 #include "settingsdialog.h"
    4 #include "optionspage.h"
    5 #include "optionspage_connection_ftp.h"
    6 #include "../netconfwizard.h"
    7 
    8 #include <wx/statbox.h>
    9 
   10 struct COptionsPageConnectionFTP::impl final
   11 {
   12     wxRadioButton* passive_{};
   13     wxRadioButton* active_{};
   14     wxCheckBox* fallback_{};
   15     wxCheckBox* keepalive_{};
   16 };
   17 
   18 COptionsPageConnectionFTP::COptionsPageConnectionFTP()
   19     : impl_(std::make_unique<impl>())
   20 {
   21 }
   22 
   23 COptionsPageConnectionFTP::~COptionsPageConnectionFTP()
   24 {
   25 }
   26 
   27 bool COptionsPageConnectionFTP::CreateControls(wxWindow* parent)
   28 {
   29     auto const& lay = m_pOwner->layout();
   30 
   31     Create(parent);
   32     auto main = lay.createFlex(1);
   33     main->AddGrowableCol(0);
   34     SetSizer(main);
   35 
   36     {
   37         auto [box, inner] = lay.createStatBox(main, _("Overview"), 1);
   38         inner->Add(new wxStaticText(box, -1, _("For more detailed information about what these options do, please run the network configuration wizard.")));
   39         auto run = new wxButton(box, -1, _("&Run configuration wizard now..."));
   40         inner->Add(run);
   41         run->Bind(wxEVT_BUTTON, [this](wxCommandEvent const&) {
   42             CNetConfWizard wizard(GetParent(), m_pOptions, m_pOwner->GetEngineContext());
   43             if (!wizard.Load()) {
   44                 return;
   45             }
   46             if (wizard.Run()) {
   47                 ReloadSettings();
   48             }
   49         });
   50     }
   51     {
   52         auto [box, inner] = lay.createStatBox(main, _("Transfer Mode"), 1);
   53         impl_->passive_ = new wxRadioButton(box, -1, _("Pa&ssive (recommended)"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
   54         inner->Add(impl_->passive_);
   55         impl_->active_ = new wxRadioButton(box, -1, _("&Active"));
   56         inner->Add(impl_->active_);
   57         impl_->fallback_ = new wxCheckBox(box, -1, _("Allow &fall back to other transfer mode on failure"));
   58         inner->Add(impl_->fallback_);
   59         inner->Add(new wxStaticText(box, -1, _("If you have problems to retrieve directory listings or to transfer files, try to change the default transfer mode.")));
   60     }
   61     {
   62         auto [box, inner] = lay.createStatBox(main, _("FTP Keep-alive"), 1);
   63         impl_->keepalive_ = new wxCheckBox(box, -1, _("Send FTP &keep-alive commands"));
   64         inner->Add(impl_->keepalive_);
   65         inner->Add(new wxStaticText(box, -1, _("A proper server does not require this. Contact the server administrator if you need this.")));
   66     }
   67     return true;
   68 }
   69 
   70 bool COptionsPageConnectionFTP::LoadPage()
   71 {
   72     const bool use_pasv = m_pOptions->GetOptionVal(OPTION_USEPASV) != 0;
   73     impl_->passive_->SetValue(use_pasv);
   74     impl_->active_->SetValue(!use_pasv);
   75     impl_->fallback_->SetValue(m_pOptions->GetOptionVal(OPTION_ALLOW_TRANSFERMODEFALLBACK) != 0);
   76     impl_->keepalive_->SetValue(m_pOptions->GetOptionVal(OPTION_FTP_SENDKEEPALIVE) != 0);
   77     return true;
   78 }
   79 
   80 bool COptionsPageConnectionFTP::SavePage()
   81 {
   82     m_pOptions->SetOption(OPTION_USEPASV, impl_->passive_->GetValue() ? 1 : 0);
   83     m_pOptions->SetOption(OPTION_ALLOW_TRANSFERMODEFALLBACK, impl_->fallback_ ? 1 : 0);
   84     m_pOptions->SetOption(OPTION_FTP_SENDKEEPALIVE, impl_->keepalive_ ? 1 : 0);
   85     return true;
   86 }