59
58
{ "FTP Proxy password", string, _T("") },
60
59
{ "FTP Proxy login sequence", string, _T("") },
61
60
{ "SFTP keyfiles", string, _T("") },
61
{ "Proxy type", number, _T("0") },
62
{ "Proxy host", string, _T("") },
63
{ "Proxy port", number, _T("0") },
64
{ "Proxy user", string, _T("") },
65
{ "Proxy password", string, _T("") },
66
{ "Logging file", string, _T("") },
67
{ "Logging filesize limit", number, _T("10") },
63
69
// Interface settings
64
70
{ "Number of Transfers", number, _T("2") },
93
99
{ "Local filelist colwidths", string, _T("") },
94
100
{ "Remote filelist colwidths", string, _T("") },
95
101
{ "Window position and size", string, _T("") },
96
{ "Splitter positions", string, _T("") },
102
{ "Splitter positions (v2)", string, _T("") },
97
103
{ "Local filelist sortorder", string, _T("") },
98
104
{ "Remote filelist sortorder", string, _T("") },
99
105
{ "Time Format", string, _T("") },
116
122
{ "Remote filelist shown columns", string, _T("") },
117
123
{ "Local filelist column order", string, _T("") },
118
124
{ "Remote filelist column order", string, _T("") },
119
{ "Filelist status bar", number, _T("1") }
125
{ "Filelist status bar", number, _T("1") },
126
{ "Filter toggle state", number, _T("0") },
127
{ "Size decimal places", number, _T("0") },
128
{ "Show quickconnect bar", number, _T("1") },
129
{ "Messagelog position", number, _T("0") },
130
{ "Last connected site", string, _T("") },
131
{ "File doubleclock action", number, _T("0") },
132
{ "Dir doubleclock action", number, _T("0") }
135
struct t_default_option
137
const wxChar name[30];
143
static t_default_option default_options[DEFAULTS_NUM] =
145
{ _T("Config Location"), string, _T(""), 0 },
146
{ _T("Kiosk mode"), number, _T(""), 0 },
147
{ _T("Disable update check"), number, _T(""), 0 }
150
BEGIN_EVENT_TABLE(COptions, wxEvtHandler)
151
EVT_TIMER(wxID_ANY, COptions::OnTimer)
122
154
COptions::COptions()
128
160
for (unsigned int i = 0; i < OPTIONS_NUM; i++)
129
161
m_optionsCache[i].cached = false;
163
m_save_timer.SetOwner(this);
131
165
CInterProcessMutex mutex(MUTEX_OPTIONS);
132
166
m_pXmlFile = new CXmlFile(_T("filezilla"));
133
167
if (!m_pXmlFile->Load())
135
wxString msg = wxString::Format(_("Could not load \"%s\", make sure the file is valid.\nFor this session, default settings will be used and any changes to the settings are not persistent."), m_pXmlFile->GetFileName().GetFullPath().c_str());
169
wxString msg = m_pXmlFile->GetError() + _T("\n\n") + _("For this session the default settings will be used. Any changes to the settings will not be saved.");
136
170
wxMessageBox(msg, _("Error loading xml file"), wxICON_ERROR);
137
171
delete m_pXmlFile;
141
175
CreateSettingsXmlElement();
177
LoadGlobalDefaultOptions();
144
180
COptions::~COptions()
200
236
bool COptions::SetOption(unsigned int nID, int value)
202
if (!SetOptionNoSave(nID, value))
207
CInterProcessMutex mutex(MUTEX_OPTIONS);
214
bool COptions::SetOptionNoSave(unsigned int nID, int value)
216
238
if (nID >= OPTIONS_NUM)
225
247
m_optionsCache[nID].numValue = value;
228
251
SetXmlValue(nID, wxString::Format(_T("%d"), value));
253
if (!m_save_timer.IsRunning())
254
m_save_timer.Start(15000, true);
233
260
bool COptions::SetOption(unsigned int nID, wxString value)
235
if (!SetOptionNoSave(nID, value))
240
CInterProcessMutex mutex(MUTEX_OPTIONS);
247
bool COptions::SetOptionNoSave(unsigned int nID, wxString value)
249
262
if (nID >= OPTIONS_NUM)
457
475
if (value < 0 || value > 1440)
478
case OPTION_SIZE_DECIMALPLACES:
479
if (value < 0 || value > 3)
482
case OPTION_MESSAGELOG_POSITION:
483
if (value < 0 || value > 2)
486
case OPTION_DOUBLECLICK_ACTION_FILE:
487
case OPTION_DOUBLECLICK_ACTION_DIRECTORY:
488
if (value < 0 || value > 3)
609
640
if (!GetXmlValue(i, value, pElement))
612
SetOptionNoSave(i, value);
647
void COptions::LoadGlobalDefaultOptions()
649
const wxString& defaultsDir = wxGetApp().GetDefaultsDir();
650
if (defaultsDir == _T(""))
653
wxFileName name(defaultsDir, _T("fzdefaults.xml"));
658
TiXmlElement* pElement = file.GetElement();
662
pElement = pElement->FirstChildElement("Settings");
666
for (TiXmlElement* pSetting = pElement->FirstChildElement("Setting"); pSetting; pSetting = pSetting->NextSiblingElement("Setting"))
617
CInterProcessMutex mutex(MUTEX_OPTIONS);
668
wxString name = GetTextAttribute(pSetting, "name");
669
for (int i = 0; i < DEFAULTS_NUM; i++)
671
if (name != default_options[i].name)
674
wxString value = GetTextElement(pSetting);
675
if (default_options[i].type == string)
676
default_options[i].value_str = value;
680
if (!value.ToLong(&v))
682
default_options[i].value_number = v;
689
int COptions::GetDefaultVal(unsigned int nID) const
691
if (nID >= DEFAULTS_NUM)
694
return default_options[nID].value_number;
697
wxString COptions::GetDefault(unsigned int nID) const
699
if (nID >= DEFAULTS_NUM)
702
return default_options[nID].value_str;
705
void COptions::OnTimer(wxTimerEvent& event)
710
void COptions::Save()
715
CInterProcessMutex mutex(MUTEX_OPTIONS);
719
void COptions::SaveIfNeeded()
721
if (!m_save_timer.IsRunning())