From 18538bce7c4d3c8a56a2439989a2374d7ac6f756 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 7 Apr 2015 00:33:09 -0700 Subject: [PATCH] MGR: Don't allow user to enter start time = end time for time-of-day or day-of-week preferences --- clientgui/DlgAdvPreferences.cpp | 30 ++++++++++++++++++++++++++++-- clientgui/sg_DlgPreferences.cpp | 14 ++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index 1e25c07d0f..557df79cc6 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -396,7 +396,7 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { //special day times for(int i=0; i< 7;i++) { TIME_SPAN& cpu = prefs.cpu_times.week.days[i]; - if(cpu.present) { + if(cpu.present && (cpu.start_hour != cpu.end_hour)) { procDayChks[i]->SetValue(true); procDayStartTxts[i]->ChangeValue(DoubleToTimeString(cpu.start_hour)); procDayStopTxts[i]->ChangeValue(DoubleToTimeString(cpu.end_hour)); @@ -413,7 +413,7 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { //special net times for(int i=0; i< 7;i++) { TIME_SPAN& net = prefs.net_times.week.days[i]; - if(net.present) { + if(net.present && (net.start_hour != net.end_hour)) { netDayChks[i]->SetValue(true); netDayStartTxts[i]->ChangeValue(DoubleToTimeString(net.start_hour)); netDayStopTxts[i]->ChangeValue(DoubleToTimeString(net.end_hour)); @@ -668,9 +668,11 @@ void CDlgAdvPreferences::UpdateControlStates() { bool CDlgAdvPreferences::ValidateInput() { wxString invMsgFloat = _("Invalid number"); wxString invMsgTime = _("Invalid time, value must be between 0:00 and 24:00, format is HH:MM"); + wxString invMsgTimeSpan = _("Start time must be different from end time"); wxString invMsgLimit10 = _("Number must be between 0 and 10"); wxString invMsgLimit100 = _("Number must be between 0 and 100"); wxString buffer; + double startTime, endTime; // ######### proc usage page buffer = m_txtProcUseProcessors->GetValue(); @@ -819,6 +821,12 @@ bool CDlgAdvPreferences::ValidateInput() { ShowErrorMessage(invMsgTime,m_txtProcEveryDayStop); return false; } + startTime = TimeStringToDouble(m_txtProcEveryDayStart->GetValue()); + endTime = TimeStringToDouble(m_txtProcEveryDayStop->GetValue()); + if (startTime == endTime) { + ShowErrorMessage(invMsgTimeSpan,m_txtProcEveryDayStop); + return false; + } } //all text ctrls in proc special time textBox @@ -834,6 +842,12 @@ bool CDlgAdvPreferences::ValidateInput() { ShowErrorMessage(invMsgTime,procDayStopTxts[i]); return false; } + startTime = TimeStringToDouble(procDayStartTxts[i]->GetValue()); + endTime = TimeStringToDouble(procDayStopTxts[i]->GetValue()); + if (startTime == endTime) { + ShowErrorMessage(invMsgTimeSpan,procDayStopTxts[i]); + return false; + } } } @@ -848,6 +862,12 @@ bool CDlgAdvPreferences::ValidateInput() { ShowErrorMessage(invMsgTime,m_txtNetEveryDayStop); return false; } + startTime = TimeStringToDouble(m_txtNetEveryDayStart->GetValue()); + endTime = TimeStringToDouble(m_txtNetEveryDayStop->GetValue()); + if (startTime == endTime) { + ShowErrorMessage(invMsgTimeSpan,m_txtNetEveryDayStop); + return false; + } } //all text ctrls in net special time textBox @@ -863,6 +883,12 @@ bool CDlgAdvPreferences::ValidateInput() { ShowErrorMessage(invMsgTime,netDayStopTxts[i]); return false; } + startTime = TimeStringToDouble(netDayStartTxts[i]->GetValue()); + endTime = TimeStringToDouble(netDayStopTxts[i]->GetValue()); + if (startTime == endTime) { + ShowErrorMessage(invMsgTimeSpan,netDayStopTxts[i]); + return false; + } } } return true; diff --git a/clientgui/sg_DlgPreferences.cpp b/clientgui/sg_DlgPreferences.cpp index bfea64be57..61e53118cd 100644 --- a/clientgui/sg_DlgPreferences.cpp +++ b/clientgui/sg_DlgPreferences.cpp @@ -750,7 +750,9 @@ bool CPanelPreferences::SavePreferenceSettings() { bool CPanelPreferences::ValidateInput() { wxString invMsgFloat = _("Invalid number"); wxString invMsgTime = _("Invalid time, value must be between 0:00 and 24:00, format is HH:MM"); + wxString invMsgTimeSpan = _("Start time must be different from end time"); wxString invMsgLimit100 = _("Number must be between 0 and 100"); + double startTime, endTime; wxString buffer; if(m_txtProcIdleFor->IsEnabled()) { @@ -772,6 +774,12 @@ bool CPanelPreferences::ValidateInput() { ShowErrorMessage(invMsgTime,m_txtProcEveryDayStop); return false; } + startTime = TimeStringToDouble(m_txtProcEveryDayStart->GetValue()); + endTime = TimeStringToDouble(m_txtProcEveryDayStop->GetValue()); + if (startTime == endTime) { + ShowErrorMessage(invMsgTimeSpan,m_txtProcEveryDayStop); + return false; + } } buffer = m_txtProcUseCPUTime->GetValue(); @@ -791,6 +799,12 @@ bool CPanelPreferences::ValidateInput() { ShowErrorMessage(invMsgTime,m_txtNetEveryDayStop); return false; } + startTime = TimeStringToDouble(m_txtNetEveryDayStart->GetValue()); + endTime = TimeStringToDouble(m_txtNetEveryDayStop->GetValue()); + if (startTime == endTime) { + ShowErrorMessage(invMsgTimeSpan,m_txtNetEveryDayStop); + return false; + } } if (m_chkDiskMaxSpace->IsChecked()) {