"Fossies" - the Fresh Open Source Software Archive

Member "filezilla-3.48.1/src/interface/Options.h" (12 May 2020, 5811 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 "Options.h" 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 #ifndef FILEZILLA_INTERFACE_OPTIONS_HEADER
    2 #define FILEZILLA_INTERFACE_OPTIONS_HEADER
    3 
    4 #include "local_path.h"
    5 
    6 #include <option_change_event_handler.h>
    7 
    8 #include <libfilezilla/mutex.hpp>
    9 
   10 #include <wx/timer.h>
   11 
   12 #include "xmlfunctions.h"
   13 
   14 enum interfaceOptions
   15 {
   16     OPTION_NUMTRANSFERS = OPTIONS_ENGINE_NUM,
   17     OPTION_ASCIIBINARY,
   18     OPTION_ASCIIFILES,
   19     OPTION_ASCIINOEXT,
   20     OPTION_ASCIIDOTFILE,
   21     OPTION_LANGUAGE,
   22     OPTION_CONCURRENTDOWNLOADLIMIT,
   23     OPTION_CONCURRENTUPLOADLIMIT,
   24     OPTION_UPDATECHECK,
   25     OPTION_UPDATECHECK_INTERVAL,
   26     OPTION_UPDATECHECK_LASTDATE,
   27     OPTION_UPDATECHECK_LASTVERSION,
   28     OPTION_UPDATECHECK_NEWVERSION,
   29     OPTION_UPDATECHECK_CHECKBETA,
   30     OPTION_DEBUG_MENU,
   31     OPTION_FILEEXISTS_DOWNLOAD,
   32     OPTION_FILEEXISTS_UPLOAD,
   33     OPTION_ASCIIRESUME,
   34     OPTION_GREETINGVERSION,
   35     OPTION_GREETINGRESOURCES,
   36     OPTION_ONETIME_DIALOGS,
   37     OPTION_SHOW_TREE_LOCAL,
   38     OPTION_SHOW_TREE_REMOTE,
   39     OPTION_FILEPANE_LAYOUT,
   40     OPTION_FILEPANE_SWAP,
   41     OPTION_FILELIST_DIRSORT,
   42     OPTION_FILELIST_NAMESORT,
   43     OPTION_QUEUE_SUCCESSFUL_AUTOCLEAR,
   44     OPTION_QUEUE_COLUMN_WIDTHS,
   45     OPTION_LOCALFILELIST_COLUMN_WIDTHS,
   46     OPTION_REMOTEFILELIST_COLUMN_WIDTHS,
   47     OPTION_MAINWINDOW_POSITION,
   48     OPTION_MAINWINDOW_SPLITTER_POSITION,
   49     OPTION_LOCALFILELIST_SORTORDER,
   50     OPTION_REMOTEFILELIST_SORTORDER,
   51     OPTION_TIME_FORMAT,
   52     OPTION_DATE_FORMAT,
   53     OPTION_SHOW_MESSAGELOG,
   54     OPTION_SHOW_QUEUE,
   55     OPTION_EDIT_DEFAULTEDITOR,
   56     OPTION_EDIT_ALWAYSDEFAULT,
   57     OPTION_EDIT_CUSTOMASSOCIATIONS,
   58     OPTION_COMPARISONMODE,
   59     OPTION_COMPARISON_THRESHOLD,
   60     OPTION_SITEMANAGER_POSITION,
   61     OPTION_ICONS_THEME,
   62     OPTION_ICONS_SCALE,
   63     OPTION_MESSAGELOG_TIMESTAMP,
   64     OPTION_SITEMANAGER_LASTSELECTED,
   65     OPTION_LOCALFILELIST_COLUMN_SHOWN,
   66     OPTION_REMOTEFILELIST_COLUMN_SHOWN,
   67     OPTION_LOCALFILELIST_COLUMN_ORDER,
   68     OPTION_REMOTEFILELIST_COLUMN_ORDER,
   69     OPTION_FILELIST_STATUSBAR,
   70     OPTION_FILTERTOGGLESTATE,
   71     OPTION_SHOW_QUICKCONNECT,
   72     OPTION_MESSAGELOG_POSITION,
   73     OPTION_DOUBLECLICK_ACTION_FILE,
   74     OPTION_DOUBLECLICK_ACTION_DIRECTORY,
   75     OPTION_MINIMIZE_TRAY,
   76     OPTION_SEARCH_COLUMN_WIDTHS,
   77     OPTION_SEARCH_COLUMN_SHOWN,
   78     OPTION_SEARCH_COLUMN_ORDER,
   79     OPTION_SEARCH_SIZE,
   80     OPTION_COMPARE_HIDEIDENTICAL,
   81     OPTION_SEARCH_SORTORDER,
   82     OPTION_EDIT_TRACK_LOCAL,
   83     OPTION_PREVENT_IDLESLEEP,
   84     OPTION_FILTEREDIT_SIZE,
   85     OPTION_INVALID_CHAR_REPLACE_ENABLE,
   86     OPTION_INVALID_CHAR_REPLACE,
   87     OPTION_ALREADYCONNECTED_CHOICE,
   88     OPTION_EDITSTATUSDIALOG_SIZE,
   89     OPTION_SPEED_DISPLAY,
   90     OPTION_TOOLBAR_HIDDEN,
   91     OPTION_STRIP_VMS_REVISION,
   92     OPTION_STARTUP_ACTION,
   93     OPTION_PROMPTPASSWORDSAVE,
   94     OPTION_PERSISTENT_CHOICES,
   95     OPTION_QUEUE_COMPLETION_ACTION,
   96     OPTION_QUEUE_COMPLETION_COMMAND,
   97     OPTION_DND_DISABLED,
   98     OPTION_DISABLE_UPDATE_FOOTER,
   99     OPTION_MASTERPASSWORDENCRYPTOR,
  100     OPTION_TAB_DATA,
  101 
  102     // Default/internal options
  103     OPTION_DEFAULT_SETTINGSDIR, // guaranteed to be (back)slash-terminated
  104     OPTION_DEFAULT_KIOSKMODE,
  105     OPTION_DEFAULT_DISABLEUPDATECHECK,
  106     OPTION_DEFAULT_CACHE_DIR,
  107 
  108     // Has to be last element
  109     OPTIONS_NUM
  110 };
  111 
  112 struct t_OptionsCache
  113 {
  114     bool operator==(std::wstring_view const& v) const { return strValue == v; }
  115     bool operator==(int v) const { return numValue == v; }
  116     bool operator==(pugi::xml_document const& v) const { return xmlValue == v; }
  117     t_OptionsCache& operator=(std::wstring_view const& v);
  118     t_OptionsCache& operator=(std::wstring && v);
  119     t_OptionsCache& operator=(int v);
  120     t_OptionsCache& operator=(pugi::xml_document const& v);
  121     t_OptionsCache& operator=(pugi::xml_document && v);
  122 
  123     bool from_default;
  124     int numValue;
  125     std::wstring strValue;
  126     pugi::xml_document xmlValue;
  127 };
  128 
  129 std::wstring GetEnv(char const* name);
  130 
  131 class CXmlFile;
  132 class COptions final : public wxEvtHandler, public COptionsBase
  133 {
  134 public:
  135     virtual int GetOptionVal(unsigned int nID);
  136     virtual std::wstring GetOption(unsigned int nID);
  137     virtual pugi::xml_document GetOptionXml(unsigned int nID);
  138 
  139     virtual bool SetOption(unsigned int nID, int value);
  140     virtual bool SetOption(unsigned int nID, std::wstring_view const& value);
  141     virtual bool SetOptionXml(unsigned int nID, pugi::xml_node const& value);
  142 
  143     bool OptionFromFzDefaultsXml(unsigned int nID);
  144 
  145     static COptions* Get();
  146     static void Init();
  147     static void Destroy();
  148 
  149     void Import(pugi::xml_node element);
  150 
  151     void RequireCleanup();
  152     void SaveIfNeeded();
  153 
  154     static CLocalPath GetUnadjustedSettingsDir();
  155     CLocalPath GetCacheDirectory();
  156 
  157 protected:
  158     COptions();
  159     virtual ~COptions();
  160 
  161     int Validate(unsigned int nID, int value);
  162     std::wstring Validate(unsigned int nID, std::wstring_view const& value);
  163     pugi::xml_document Validate(unsigned int nID, pugi::xml_document const& value);
  164 
  165     template<typename T> void ContinueSetOption(unsigned int nID, T const& value);
  166     void SetXmlValue(unsigned int nID, pugi::xml_node settings, int value);
  167     void SetXmlValue(unsigned int nID, pugi::xml_node settings, std::wstring_view const& value);
  168     void SetXmlValue(unsigned int nID, pugi::xml_node settings, pugi::xml_document const& value);
  169 
  170     pugi::xml_node CreateSettingsXmlElement();
  171 
  172     std::map<std::string, unsigned int> GetNameOptionMap() const;
  173     void LoadOptions(std::map<std::string, unsigned int> const& nameOptionMap, pugi::xml_node settings = pugi::xml_node());
  174     void LoadGlobalDefaultOptions(std::map<std::string, unsigned int> const& nameOptionMap);
  175     void LoadOptionFromElement(pugi::xml_node option, std::map<std::string, unsigned int> const& nameOptionMap, bool allowDefault);
  176     CLocalPath InitSettingsDir();
  177     void SetDefaultValues();
  178     void WriteCacheToXml(pugi::xml_node settings);
  179 
  180     bool Cleanup(); // Removes all unknown elements from the XML
  181     void Save();
  182 
  183     void NotifyChangedOptions();
  184 
  185     std::unique_ptr<CXmlFile> xmlFile_;
  186 
  187     t_OptionsCache m_optionsCache[OPTIONS_NUM];
  188 
  189     static COptions* m_theOptions;
  190 
  191     wxTimer m_save_timer;
  192     bool needsCleanup_{};
  193 
  194     DECLARE_EVENT_TABLE()
  195     void OnTimer(wxTimerEvent& event);
  196 
  197     fz::mutex m_sync_{false};
  198 
  199     changed_options_t changedOptions_;
  200 };
  201 
  202 #endif