SettingsWithTimePeriodDlg.cpp

Go to the documentation of this file.
00001 
00009 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) && defined(PKIFRESOURCES_ALLOW_GCC_PRAGMA)
00010     #pragma implementation "SettingsWithTimePeriodDlg.cpp"
00011 #endif
00012 
00013 //Pick up PKIF windows SDK configuration macros instead of WX's 
00014 #include "PKIFdll.h"
00015 // For compilers that support precompilation, includes "wx/wx.h".
00016 #include "wx/wxprec.h"
00017 
00018 #ifdef __BORLANDC__
00019     #pragma hdrstop
00020 #endif
00021 
00022 #include "SettingsWithTimePeriodDlg.h"
00023 #include "TMDDateTimePicker.h"
00024 #include "pkif.h"
00025 #include "PathSettingsNotebook.h"
00026 #include "PkiEnvironmentDefinitionNotebook.h"
00027 
00028 //implemented in ScvpResponderEntryDlg.cpp
00029 const char* MakeTimePurty(CPKIFTimePtr& t, std::string& s);
00030 
00031 struct SettingsWithTimePeriodDlgImpl
00032 {
00033     #ifdef __INCLUDE_SCVP_SUPPORT__
00034     CPKIFExMediatorPtr m_exMed;
00035     CPKIFExPathSettingsPtr m_exPs;
00036     #endif
00037     IPKIFMediatorPtr m_med;
00038     CPKIFPathSettingsPtr m_ps;
00039     CPKIFTimePtr m_medNA, m_medNB, m_psNA, m_psNB;
00040 };
00041 
00042 // WDR: class implementations
00043 
00044 //----------------------------------------------------------------------------
00045 // CSettingsWithTimePeriodDlg
00046 //----------------------------------------------------------------------------
00047 
00048 // WDR: event table for CSettingsWithTimePeriodDlg
00049 
00050 BEGIN_EVENT_TABLE(CSettingsWithTimePeriodDlg,wxDialog)
00051     EVT_BUTTON( wxID_OK, CSettingsWithTimePeriodDlg::OnOk )
00052     EVT_BUTTON( wxID_CANCEL, CSettingsWithTimePeriodDlg::OnCancel )
00053     EVT_BUTTON( ID_BUTTON_MEDS, CSettingsWithTimePeriodDlg::OnClickMeds )
00054     EVT_BUTTON( ID_BUTTON_PP, CSettingsWithTimePeriodDlg::OnClickPathSettings )
00055     EVT_BUTTON( ID_BUTTON_MEDS_NOT_BEFORE, CSettingsWithTimePeriodDlg::OnClickMedsNotBefore )
00056     EVT_BUTTON( ID_BUTTON_MEDS_NOT_AFTER, CSettingsWithTimePeriodDlg::OnClickMedsNotAfter )
00057     EVT_BUTTON( ID_BUTTON_PP_NOT_BEFORE, CSettingsWithTimePeriodDlg::OnClickPathNotBefore )
00058     EVT_BUTTON( ID_BUTTON_PP_NOT_AFTER, CSettingsWithTimePeriodDlg::OnClickPathNotAfter )
00059 END_EVENT_TABLE()
00067 CSettingsWithTimePeriodDlg::CSettingsWithTimePeriodDlg( wxWindow *parent, wxWindowID id, const wxString &title,
00068     const wxPoint &position, const wxSize& size, long style ) :
00069     wxDialog( parent, id, title, position, size, style ), m_impl(new SettingsWithTimePeriodDlgImpl)
00070 {
00071     m_whatToDisplay = DISPLAY_BOTH;
00072 
00073     // WDR: dialog function SettingsWithTimePeriodDlg for CSettingsWithTimePeriodDlg
00074     SettingsWithTimePeriodDlg( this, TRUE ); 
00075 }
00083 CSettingsWithTimePeriodDlg::~CSettingsWithTimePeriodDlg()
00084 {
00085 }
00093 bool CSettingsWithTimePeriodDlg::Validate()
00094 {
00095     return TRUE;
00096 }
00104 bool CSettingsWithTimePeriodDlg::TransferDataToWindow()
00105 {
00106     #ifdef __INCLUDE_SCVP_SUPPORT__
00107     if(DISPLAY_MEDS == m_whatToDisplay)
00108     {
00109         wxSizer* sz = GetSizer();
00110         sz->Hide(gPathSettingsGroupBox, true);
00111     }
00112     if(DISPLAY_PP == m_whatToDisplay)
00113     {
00114         wxSizer* sz = GetSizer();
00115         sz->Hide(gMediatorGroupBox, true);
00116     }
00117 
00118     if(m_impl->m_exMed)
00119     {
00120         m_impl->m_med = m_impl->m_exMed->second;
00121         m_impl->m_medNA = m_impl->m_exMed->first->notAfter();
00122         if(m_impl->m_medNA)
00123         {
00124             std::string aString;
00125             GetTextctrlMedsNotAfter()->SetValue(wxString(MakeTimePurty(m_impl->m_medNA, aString),wxConvUTF8));
00126         }
00127         m_impl->m_medNB = m_impl->m_exMed->first->notBefore();
00128         if(m_impl->m_medNB)
00129         {
00130             std::string aString;
00131             GetTextctrlMedsNotBefore()->SetValue(wxString(MakeTimePurty(m_impl->m_medNB, aString),wxConvUTF8));
00132         }
00133     }
00134 
00135     if(m_impl->m_exPs)
00136     {
00137         m_impl->m_ps = m_impl->m_exPs->second;
00138         m_impl->m_psNA = m_impl->m_exPs->first->notAfter();
00139         if(m_impl->m_psNA)
00140         {
00141             std::string aString;
00142             GetTextctrlPpNotAfter()->SetValue(wxString(MakeTimePurty(m_impl->m_psNA, aString),wxConvUTF8));
00143         }
00144         m_impl->m_psNB = m_impl->m_exPs->first->notBefore();
00145         if(m_impl->m_psNB)
00146         {
00147             std::string aString;
00148             GetTextctrlPpNotBefore()->SetValue(wxString(MakeTimePurty(m_impl->m_psNB, aString),wxConvUTF8));
00149         }
00150     }
00151     #endif
00152     return TRUE;
00153 }
00161 bool CSettingsWithTimePeriodDlg::TransferDataFromWindow()
00162 {
00163     return TRUE;
00164 }
00165 
00166 // WDR: handler implementations for CSettingsWithTimePeriodDlg
00174 void CSettingsWithTimePeriodDlg::OnClickPathNotAfter( wxCommandEvent &event )
00175 {
00176     TMDDateTimePicker dlg(0,wxID_ANY,wxT("Select a date"));
00177     dlg.SetMorningOrNight(false);
00178     if(m_impl->m_psNA)
00179     {
00180         CPKIFTimePtr notAfter = m_impl->m_psNA;
00181         dlg.SetDate(notAfter);
00182     }
00183     dlg.CentreOnParent();
00184     if(wxID_OK == dlg.ShowModal()) 
00185     {
00186         GetTextctrlPpNotAfter()->SetValue(dlg.GetDate());
00187         m_impl->m_psNA = dlg.GetDateAsPKIFTime();
00188     }
00189 }
00197 void CSettingsWithTimePeriodDlg::OnClickPathNotBefore( wxCommandEvent &event )
00198 {
00199     TMDDateTimePicker dlg(0,wxID_ANY,wxT("Select a date"));
00200     dlg.SetMorningOrNight(true);
00201     if(m_impl->m_psNB)
00202     {
00203         CPKIFTimePtr notBefore = m_impl->m_psNB;
00204         dlg.SetDate(notBefore);
00205     }
00206     dlg.CentreOnParent();
00207     if(wxID_OK == dlg.ShowModal()) 
00208     {
00209         GetTextctrlPpNotBefore()->SetValue(dlg.GetDate());
00210         m_impl->m_psNB = dlg.GetDateAsPKIFTime();
00211     }
00212 }
00220 void CSettingsWithTimePeriodDlg::OnClickPathSettings( wxCommandEvent &event )
00221 {
00222     CPKIFPathSettingsNotebook psn(NULL,-1,wxT("Path Validation Settings"),wxDefaultPosition,wxDefaultSize,
00223         wxDEFAULT_DIALOG_STYLE);
00224     psn.SetInitialPathSettings(m_impl->m_ps);
00225     psn.Center();
00226     wxButton * okButton = (wxButton *)psn.FindWindow(wxID_OK);
00227     if(okButton) okButton->SetLabel(wxT("Save"));
00228     if(wxID_OK == psn.ShowModal())
00229     {
00230         m_impl->m_ps = psn.GetPathSettings();
00231     }
00232 }
00240 void CSettingsWithTimePeriodDlg::OnClickMedsNotAfter( wxCommandEvent &event )
00241 {
00242     TMDDateTimePicker dlg(0,wxID_ANY,wxT("Select a date"));
00243     dlg.SetMorningOrNight(false);
00244     if(m_impl->m_medNA)
00245     {
00246         CPKIFTimePtr notAfter = m_impl->m_medNA;
00247         dlg.SetDate(notAfter);
00248     }
00249     dlg.CentreOnParent();
00250     if(wxID_OK == dlg.ShowModal()) 
00251     {
00252         GetTextctrlMedsNotAfter()->SetValue(dlg.GetDate());
00253         m_impl->m_medNA = dlg.GetDateAsPKIFTime();
00254     }
00255 }
00263 void CSettingsWithTimePeriodDlg::OnClickMedsNotBefore( wxCommandEvent &event )
00264 {
00265     TMDDateTimePicker dlg(0,wxID_ANY,wxT("Select a date"));
00266     dlg.SetMorningOrNight(true);
00267     if(m_impl->m_medNB)
00268     {
00269         CPKIFTimePtr notBefore = m_impl->m_medNB;
00270         dlg.SetDate(notBefore);
00271     }
00272     dlg.CentreOnParent();
00273     if(wxID_OK == dlg.ShowModal()) 
00274     {
00275         GetTextctrlMedsNotBefore()->SetValue(dlg.GetDate());
00276         m_impl->m_medNB = dlg.GetDateAsPKIFTime();
00277     }
00278 }
00286 void CSettingsWithTimePeriodDlg::OnClickMeds( wxCommandEvent &event )
00287 {
00288     CPKIFPkiEnvironmentDefinitionNotebook pedn(NULL,-1,wxT("PKI Environment Definition for SCVP Response Processing"),
00289         wxDefaultPosition,wxDefaultSize, wxDEFAULT_DIALOG_STYLE);
00290     pedn.SetInitialMediator(m_impl->m_med);
00291     pedn.Center();
00292     wxButton * okButton = (wxButton *)pedn.FindWindow(wxID_OK);
00293     if(okButton) okButton->SetLabel(wxT("Save"));
00294     if(wxID_OK == pedn.ShowModal())
00295     {
00296         m_impl->m_med = pedn.GetMediator();
00297     }
00298 }
00306 void CSettingsWithTimePeriodDlg::OnOk(wxCommandEvent &event)
00307 {
00308     #ifdef __INCLUDE_SCVP_SUPPORT__
00309     if(DISPLAY_MEDS == m_whatToDisplay || DISPLAY_BOTH == m_whatToDisplay)
00310     {
00311         if(m_impl->m_medNB == (CPKIFTime*)NULL)
00312         {
00313             wxString msg =  wxT("\"Do not use before\" time is not specified");
00314             wxMessageBox(msg);
00315             return;
00316         }
00317         if(m_impl->m_medNA == (CPKIFTime*)NULL)
00318         {
00319             wxString msg =  wxT("\"Do not use after\" time is not specified");
00320             wxMessageBox(msg);
00321             return;
00322         }
00323         if(m_impl->m_med == (IPKIFMediator*)NULL)
00324         {
00325             wxString msg =  wxT("PKI Environment Settings are is not specified");
00326             wxMessageBox(msg);
00327             return;
00328         }
00329         if(*m_impl->m_medNB > *m_impl->m_medNA)
00330         {
00331             wxString msg =  wxT("\"Do not use before\" time is after \"Do not use after\" time");
00332             wxMessageBox(msg);
00333             return;
00334         }
00335 
00336         CPKIFExMediatorPtr newEx(new CPKIFExMediator);
00337 
00338         CPKIFValidityPtr newV(new CPKIFValidity(m_impl->m_medNB, m_impl->m_medNA));
00339         newEx->first = newV;
00340 
00341         newEx->second = m_impl->m_med;
00342         m_impl->m_exMed = newEx;
00343 
00344     }
00345     else
00346     {
00347         CPKIFExMediatorPtr empty;
00348         m_impl->m_exMed = empty;
00349     }
00350 
00351     if(DISPLAY_PP == m_whatToDisplay || DISPLAY_BOTH == m_whatToDisplay)
00352     {
00353         if(m_impl->m_psNB == (CPKIFTime*)NULL)
00354         {
00355             wxString msg =  wxT("\"Do not use before\" time is not specified");
00356             wxMessageBox(msg);
00357             return;
00358         }
00359         
00360         if(m_impl->m_psNA == (CPKIFTime*)NULL)
00361         {
00362             wxString msg =  wxT("\"Do not use after\" time is not specified");
00363             wxMessageBox(msg);
00364             return;
00365         }
00366         if(m_impl->m_ps == (CPKIFPathSettings*)NULL)
00367         {
00368             wxString msg =  wxT("PKI Environment Settings are not specified");
00369             wxMessageBox(msg);
00370             return;
00371         }
00372         
00373         if(*m_impl->m_psNB > *m_impl->m_psNA)
00374         {
00375             wxString msg =  wxT("\"Do not use before\" time is after \"Do not use after\" time");
00376             wxMessageBox(msg);
00377             return;
00378         }
00379 
00380         CPKIFExPathSettingsPtr newEx(new CPKIFExPathSettings);
00381 
00382         CPKIFValidityPtr newV(new CPKIFValidity(m_impl->m_psNB, m_impl->m_psNA));
00383         newEx->first = newV;
00384 
00385         newEx->second = m_impl->m_ps;
00386         m_impl->m_exPs = newEx;
00387     }
00388     else
00389     {
00390         CPKIFExPathSettingsPtr empty;
00391         m_impl->m_exPs = empty;
00392     }
00393 
00394     #endif
00395     event.Skip();
00396 }
00404 void CSettingsWithTimePeriodDlg::OnCancel(wxCommandEvent &event)
00405 {
00406     event.Skip();
00407 }
00408 #ifdef __INCLUDE_SCVP_SUPPORT__
00409 
00416 CPKIFExMediatorPtr CSettingsWithTimePeriodDlg::GetMediator()
00417 {
00418     return m_impl->m_exMed;
00419 }
00427 CPKIFExPathSettingsPtr CSettingsWithTimePeriodDlg::GetPathSettings()
00428 {
00429     return m_impl->m_exPs;
00430 }
00438 void CSettingsWithTimePeriodDlg::SetMediator(CPKIFExMediatorPtr& med)
00439 {
00440     m_impl->m_exMed = med;
00441 }
00449 void CSettingsWithTimePeriodDlg::SetPathSettings(CPKIFExPathSettingsPtr& ps)
00450 {
00451     m_impl->m_exPs = ps;
00452 }
00453 #endif

Generated on Mon Nov 15 11:15:56 2010 for PublicKeyInfrastructureFramework(PKIF) by  doxygen 1.5.6