From c8b131a073149a4f2b4470ecdb904495bb4cc52b Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sat, 31 May 2014 02:00:05 +0000 Subject: [PATCH] first draft of event processing GUI, still plenty of work to do to wire it up git-svn-id: https://svn.code.sf.net/p/freetel/code@1620 01035d8c-6547-0410-b346-abe4f91aad63 --- fdmdv2/src/dlg_options.cpp | 79 +++++++++++++++++++++++++------------- fdmdv2/src/dlg_options.h | 13 ++++--- fdmdv2/src/fdmdv2_main.cpp | 11 +++--- fdmdv2/src/fdmdv2_main.h | 7 ++-- 4 files changed, 69 insertions(+), 41 deletions(-) diff --git a/fdmdv2/src/dlg_options.cpp b/fdmdv2/src/dlg_options.cpp index 2fc010f7..32ae43c4 100644 --- a/fdmdv2/src/dlg_options.cpp +++ b/fdmdv2/src/dlg_options.cpp @@ -33,14 +33,14 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c bSizer30 = new wxBoxSizer(wxVERTICAL); //------------------------------ - // Call Sign Text Box + // Txt Msg Text Box //------------------------------ wxStaticBoxSizer* sbSizer_callSign; - sbSizer_callSign = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Call Sign")), wxVERTICAL); + sbSizer_callSign = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Txt Msg")), wxVERTICAL); m_txtCtrlCallSign = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); - m_txtCtrlCallSign->SetToolTip(_("Call Sign of your station")); + m_txtCtrlCallSign->SetToolTip(_("Txt Msg you can send along with Voice")); sbSizer_callSign->Add(m_txtCtrlCallSign, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 3); bSizer30->Add(sbSizer_callSign,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3); @@ -58,21 +58,49 @@ OptionsDlg::OptionsDlg(wxWindow* parent, wxWindowID id, const wxString& title, c bSizer30->Add(sbSizer_testFrames,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3); //------------------------------ - // Web Integration + // Event processing //------------------------------ - wxStaticBoxSizer* sbSizer_web; - sbSizer_web = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Web Integration")), wxVERTICAL); + wxStaticBoxSizer* sbSizer_events; + sbSizer_events = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Event Processing")), wxVERTICAL); - m_txt_webURL = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); - m_txt_webURL->SetToolTip(_("Hit this URL on action below")); - sbSizer_web->Add(m_txt_webURL, 1, wxEXPAND, 5); - m_ckbox_webOnStart = new wxCheckBox(this, wxID_ANY, _("Start Button"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); - sbSizer_web->Add(m_ckbox_webOnStart, 1, wxEXPAND, 5); - m_ckbox_webOnPTT = new wxCheckBox(this, wxID_ANY, _("PTT Button"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); - sbSizer_web->Add(m_ckbox_webOnPTT, 1, wxEXPAND, 5); + // event processing enable - bSizer30->Add(sbSizer_web,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3); + m_ckbox_events = new wxCheckBox(this, wxID_ANY, _("Enable"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE); + sbSizer_events->Add(m_ckbox_events, 0, 0, 5); + + // list of regexps + + wxStaticBoxSizer* sbSizer_regexp = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Regular Expressions to Process Events")), wxVERTICAL); + m_txt_events_regexp = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(400,100), wxTE_MULTILINE); + m_txt_events_regexp->SetToolTip(_("Enter regular expressions to process events")); + sbSizer_regexp->Add(m_txt_events_regexp, 1, wxEXPAND, 5); + sbSizer_events->Add(sbSizer_regexp, 1, wxEXPAND, 5); + + // log of events and responses + + wxStaticBoxSizer* sbSizer_event_log = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Events and Responses")), wxVERTICAL); + wxBoxSizer* bSizer33 = new wxBoxSizer(wxHORIZONTAL); + m_txt_events_in = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200,50), wxTE_MULTILINE | wxTE_READONLY); + bSizer33->Add(m_txt_events_in, 1, wxEXPAND, 5); + m_txt_events_out = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200,50), wxTE_MULTILINE | wxTE_READONLY); + bSizer33->Add(m_txt_events_out, 1, wxEXPAND, 5); + sbSizer_event_log->Add(bSizer33, 1, wxEXPAND, 5); + sbSizer_events->Add(sbSizer_event_log, 1, wxEXPAND, 5); + + // test event + + wxStaticBoxSizer* sbSizer_event_test = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Test your Regular Expression")), wxVERTICAL); + wxBoxSizer* bSizer34 = new wxBoxSizer(wxHORIZONTAL); + m_txt_event_test = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); + m_txt_event_test->SetToolTip(_("Enter event text to test a regular expression")); + bSizer34->Add(m_txt_event_test, 1, wxEXPAND|wxALL, 5); + m_btn_event_test = new wxButton(this, wxID_ANY, _("Test"), wxDefaultPosition, wxDefaultSize, 0); + bSizer34->Add(m_btn_event_test, 0, wxEXPAND|wxALL, 5); + sbSizer_event_test->Add(bSizer34, 0, wxEXPAND, 5); + sbSizer_events->Add(sbSizer_event_test, 0, wxEXPAND, 5); + + bSizer30->Add(sbSizer_events,0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND, 3); //------------------------------ // Cancel - OK Buttons @@ -125,26 +153,23 @@ void OptionsDlg::ExchangeData(int inout, bool storePersistent) m_txtCtrlCallSign->SetValue(wxGetApp().m_callSign); m_ckboxTestFrame->SetValue(wxGetApp().m_testFrames); - m_ckbox_webOnStart->SetValue(wxGetApp().m_webOnStart); - m_ckbox_webOnPTT->SetValue(wxGetApp().m_webOnPTT); - m_txt_webURL->SetValue(wxGetApp().m_webURL); + m_ckbox_events->SetValue(wxGetApp().m_events); + m_txt_events_regexp->SetValue(wxGetApp().m_events_regexp); } if(inout == EXCHANGE_DATA_OUT) { - wxGetApp().m_callSign = m_txtCtrlCallSign->GetValue(); - wxGetApp().m_testFrames = m_ckboxTestFrame->GetValue(); - - wxGetApp().m_webOnStart = m_ckbox_webOnStart->GetValue(); - wxGetApp().m_webOnPTT = m_ckbox_webOnPTT->GetValue(); - wxGetApp().m_webURL = m_txt_webURL->GetValue(); + wxGetApp().m_callSign = m_txtCtrlCallSign->GetValue(); + wxGetApp().m_testFrames = m_ckboxTestFrame->GetValue(); + wxGetApp().m_events = m_ckbox_events->GetValue(); + wxGetApp().m_events_regexp = m_txt_events_regexp->GetValue(); + if (storePersistent) { pConfig->Write(wxT("/Data/CallSign"), wxGetApp().m_callSign); - pConfig->Write(wxT("/Web/OnStart"), wxGetApp().m_webOnStart); - pConfig->Write(wxT("/Web/OnPTT"), wxGetApp().m_webOnPTT); - pConfig->Write(wxT("/Web/URL"), wxGetApp().m_webURL); - pConfig->Flush(); + pConfig->Write(wxT("/Events/enable"), wxGetApp().m_events); + pConfig->Write(wxT("/Events/regexp"), wxGetApp().m_events_regexp); + pConfig->Flush(); } } delete wxConfigBase::Set((wxConfigBase *) NULL); diff --git a/fdmdv2/src/dlg_options.h b/fdmdv2/src/dlg_options.h index 533f88ce..cfa7eaea 100644 --- a/fdmdv2/src/dlg_options.h +++ b/fdmdv2/src/dlg_options.h @@ -32,7 +32,7 @@ class OptionsDlg : public wxDialog public: OptionsDlg( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Options"), - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(450,290), + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(600,530), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); ~OptionsDlg(); @@ -45,12 +45,15 @@ class OptionsDlg : public wxDialog void OnClose(wxCloseEvent& event); void OnInitDialog(wxInitDialogEvent& event); - wxTextCtrl *m_txtCtrlCallSign; + wxTextCtrl *m_txtCtrlCallSign; // TODO: this should be renamed to tx_txtmsg, and rename all related incl persis strge wxCheckBox *m_ckboxTestFrame; - wxCheckBox *m_ckbox_webOnStart; - wxCheckBox *m_ckbox_webOnPTT; - wxTextCtrl *m_txt_webURL; + wxCheckBox *m_ckbox_events; + wxTextCtrl *m_txt_events_regexp; + wxTextCtrl *m_txt_events_in; + wxTextCtrl *m_txt_events_out; + wxTextCtrl *m_txt_event_test; + wxButton *m_btn_event_test; wxButton* m_sdbSizer5OK; wxButton* m_sdbSizer5Cancel; diff --git a/fdmdv2/src/fdmdv2_main.cpp b/fdmdv2/src/fdmdv2_main.cpp index 906352f7..e85ba276 100644 --- a/fdmdv2/src/fdmdv2_main.cpp +++ b/fdmdv2/src/fdmdv2_main.cpp @@ -370,9 +370,9 @@ MainFrame::MainFrame(wxWindow *parent) : TopFrame(parent) wxGetApp().m_SpkOutEQEnable = (float)pConfig->Read(wxT("/Filter/SpkOutEQEnable"), f); wxGetApp().m_callSign = pConfig->Read("/Data/CallSign", wxT("")); - wxGetApp().m_webOnStart = pConfig->Read("/Web/OnStart", f); - wxGetApp().m_webOnPTT = pConfig->Read("/Web/OnPTT", f); - wxGetApp().m_webURL = pConfig->Read("/Web/URL", wxT("http://qso.freedv.org/cgi-bin/")); + wxGetApp().m_events = pConfig->Read("/Events/enable", f); + wxGetApp().m_events_regexp = pConfig->Read("/Events/regexp", + wxT("s|onstart,mycallsign=(.*),|curl http://qso.freedv.org/cgi-bin/onstart.cgi?callsign=$1|")); pConfig->SetPath(wxT("/")); @@ -529,9 +529,8 @@ MainFrame::~MainFrame() pConfig->Write(wxT("/Audio/snrSlow"), wxGetApp().m_snrSlow); pConfig->Write(wxT("/Data/CallSign"), wxGetApp().m_callSign); - pConfig->Write(wxT("/Web/OnStart"), wxGetApp().m_webOnStart); - pConfig->Write(wxT("/Web/OnPTT"), wxGetApp().m_webOnPTT); - pConfig->Write(wxT("/Web/URL"), wxGetApp().m_webURL); + pConfig->Write(wxT("/Events/enable"), wxGetApp().m_events); + pConfig->Write(wxT("/Events/regexp"), wxGetApp().m_events_regexp); pConfig->Write(wxT("/Filter/MicInEQEnable"), wxGetApp().m_MicInEQEnable); pConfig->Write(wxT("/Filter/SpkOutEQEnable"), wxGetApp().m_SpkOutEQEnable); diff --git a/fdmdv2/src/fdmdv2_main.h b/fdmdv2/src/fdmdv2_main.h index 1ed2d44d..0a513bff 100644 --- a/fdmdv2/src/fdmdv2_main.h +++ b/fdmdv2/src/fdmdv2_main.h @@ -169,10 +169,11 @@ class MainApp : public wxApp unsigned int m_recFileFromRadioSecs; wxString m_playFileFromRadioPath; + // Options dialog + wxString m_callSign; - bool m_webOnStart; - bool m_webOnPTT; - wxString m_webURL; + bool m_events; + wxString m_events_regexp; bool m_snrSlow; -- 2.25.1