Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make timeout a user setting (bugs #469) #214

Merged
merged 1 commit into from Sep 22, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/optionsdialog.cpp
Expand Up @@ -801,9 +801,28 @@ void mmOptionsDialog::CreateControls()

usageStaticBoxSizer->Add(cbSendData_, g_flags);

networkPanel->SetSizer(networkPanelSizer);
// Communication timeout
networkPanelSizer->AddSpacer(15);

/**********************************************************************************************
wxStaticBox* timeoutStaticBox = new wxStaticBox(networkPanel, wxID_STATIC, _("Timeout"));
timeoutStaticBox->SetFont(staticBoxFontSetting);
wxStaticBoxSizer* timeoutStaticBoxSizer = new wxStaticBoxSizer(timeoutStaticBox, wxVERTICAL);
networkPanelSizer->Add(timeoutStaticBoxSizer, wxSizerFlags(g_flagsExpand).Proportion(0));

int nTimeout = Model_Setting::instance().GetIntSetting("NETWORKTIMEOUT", 10);
scNetworkTimeout_ = new wxSpinCtrl(networkPanel, ID_DIALOG_OPTIONS_NETWORK_TIMEOUT,
wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 150, nTimeout);
scNetworkTimeout_->SetToolTip(_("Specify a network communication timeout value to use."));

wxFlexGridSizer* flex_sizer5 = new wxFlexGridSizer(0, 2, 0, 0);
flex_sizer5->Add(new wxStaticText(networkPanel, wxID_STATIC, _("Seconds")), g_flags);
flex_sizer5->Add(scNetworkTimeout_, g_flags);

timeoutStaticBoxSizer->Add(flex_sizer5, g_flags);

networkPanel->SetSizer(networkPanelSizer);

/**********************************************************************************************
Setting up the notebook with the 5 pages
**********************************************************************************************/
newBook->SetImageList(m_imageList);
Expand Down Expand Up @@ -1166,6 +1185,8 @@ void mmOptionsDialog::SaveNetworkPanelSettings()
Model_Setting::instance().Set("WEBSERVERPORT", scWebServerPort_->GetValue());

Model_Setting::instance().Set("SENDUSAGESTATS", cbSendData_->GetValue());

Model_Setting::instance().Set("NETWORKTIMEOUT", scNetworkTimeout_->GetValue());
}

void mmOptionsDialog::OnOk(wxCommandEvent& /*event*/)
Expand Down
5 changes: 4 additions & 1 deletion src/optionsdialog.h
Expand Up @@ -124,6 +124,8 @@ class mmOptionsDialog: public wxDialog

wxCheckBox* cbSendData_;

wxSpinCtrl *scNetworkTimeout_;

int currencyId_;
wxString dateFormat_;
wxString currentLanguage_;
Expand Down Expand Up @@ -182,7 +184,8 @@ class mmOptionsDialog: public wxDialog
ID_DIALOG_OPTIONS_CHECKBOX_ATTACHMENTSSUBFOLDER,
ID_DIALOG_OPTIONS_ENABLE_WEB_SERVER,
ID_DIALOG_OPTIONS_WEB_SERVER_PORT,
ID_DIALOG_OPTIONS_ALLOW_SEND_USAGE
ID_DIALOG_OPTIONS_ALLOW_SEND_USAGE,
ID_DIALOG_OPTIONS_NETWORK_TIMEOUT
};
};

Expand Down
3 changes: 2 additions & 1 deletion src/util.cpp
Expand Up @@ -187,7 +187,8 @@ int site_content(const wxString& sSite, wxString& sOutput)
int err_code = url.GetError();
if (err_code == wxURL_NOERR)
{
url.GetProtocol().SetTimeout(10); // 10 secs
int networkTimeout = Model_Setting::instance().GetIntSetting("NETWORKTIMEOUT", 10); // default 10 secs
url.GetProtocol().SetTimeout(networkTimeout);
wxInputStream* in_stream = url.GetInputStream();
if (in_stream)
{
Expand Down