added a first pass dialog for plug in config
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 30 Jan 2016 09:20:27 +0000 (09:20 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sat, 30 Jan 2016 09:20:27 +0000 (09:20 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2671 01035d8c-6547-0410-b346-abe4f91aad63

freedv-dev/src/CMakeLists.txt
freedv-dev/src/dlg_plugin.cpp [new file with mode: 0644]
freedv-dev/src/dlg_plugin.h [new file with mode: 0644]
freedv-dev/src/fdmdv2_main.cpp
freedv-dev/src/fdmdv2_main.h
freedv-dev/src/topFrame.cpp
freedv-dev/src/topFrame.h

index 01f39750a38fc1fa4f0ed54ccc811cbb779043a4..cba792fadf6f9bab81840343c43403f4bbc823a1 100644 (file)
@@ -3,6 +3,7 @@ set(FREEDV_SOURCES
     dlg_filter.cpp
     dlg_options.cpp
     dlg_ptt.cpp
+    dlg_plugin.cpp
     fdmdv2_main.cpp
     fdmdv2_pa_wrapper.cpp
     fdmdv2_plot.cpp
diff --git a/freedv-dev/src/dlg_plugin.cpp b/freedv-dev/src/dlg_plugin.cpp
new file mode 100644 (file)
index 0000000..5ec31ad
--- /dev/null
@@ -0,0 +1,142 @@
+//==========================================================================
+// Name:            dlg_plugin.cpp
+// Purpose:         Subclasses dialog GUI for PlugIn Config. Creates simple 
+//                  wxWidgets dialog GUI to set a few text strings.
+// Date:            Jan 2016
+// Authors:         David Rowe
+// 
+// License:
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License version 2.1,
+//  as published by the Free Software Foundation.  This program is
+//  distributed in the hope that it will be useful, but WITHOUT ANY
+//  WARRANTY; without even the implied warranty of MERCHANTABILITY or
+//  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+//  License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, see <http://www.gnu.org/licenses/>.
+//
+//==========================================================================
+
+#include "dlg_plugin.h"
+#include "fdmdv2_main.h"
+
+#ifdef __WIN32__
+#include <wx/msw/registry.h>
+#endif
+#if defined(__FreeBSD__) || defined(__WXOSX__)
+#include <glob.h>
+#include <string.h>
+#endif
+
+#include <sstream>
+
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
+// Class PlugInDlg
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
+PlugInDlg::PlugInDlg(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style)
+{
+    wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
+    this->SetSizer(mainSizer);
+
+    wxStaticBoxSizer* staticBoxSizer28a = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("Param1")), wxVERTICAL);
+    m_txtCtrlPlugIn1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300,-1), 0);
+    staticBoxSizer28a->Add(m_txtCtrlPlugIn1, 0, 0, 5);
+    mainSizer->Add(staticBoxSizer28a, 0, wxEXPAND, 5);
+
+    wxStaticBoxSizer* staticBoxSizer28b = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY, _("Param2")), wxVERTICAL);
+    m_txtCtrlPlugIn2 = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300,-1), 0);
+    staticBoxSizer28b->Add(m_txtCtrlPlugIn2, 0, 0, 5);
+    mainSizer->Add(staticBoxSizer28b, 0, wxEXPAND, 5);
+
+    //----------------------------------------------------------------------
+    // OK - Cancel - Apply
+    //----------------------------------------------------------------------
+
+    wxBoxSizer* boxSizer12 = new wxBoxSizer(wxHORIZONTAL);
+
+    m_buttonOK = new wxButton(this, wxID_OK, _("OK"), wxDefaultPosition, wxSize(-1,-1), 0);
+    m_buttonOK->SetDefault();
+    boxSizer12->Add(m_buttonOK, 0, wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, 5);
+
+    m_buttonCancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize(-1,-1), 0);
+    boxSizer12->Add(m_buttonCancel, 0, wxLEFT|wxRIGHT|wxTOP|wxBOTTOM, 5);
+
+    mainSizer->Add(boxSizer12, 0, wxLEFT|wxRIGHT|wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL, 5);
+
+    if ( GetSizer() ) 
+    {
+         GetSizer()->Fit(this);
+    }
+    Centre(wxBOTH);
+
+    // Connect events
+    this->Connect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(PlugInDlg::OnInitDialog), NULL, this);
+    m_buttonOK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PlugInDlg::OnOK), NULL, this);
+    m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PlugInDlg::OnCancel), NULL, this);
+
+}
+
+//-------------------------------------------------------------------------
+// ~PlugInDlg()
+//-------------------------------------------------------------------------
+PlugInDlg::~PlugInDlg()
+{
+    // Disconnect Events
+    this->Disconnect(wxEVT_INIT_DIALOG, wxInitDialogEventHandler(PlugInDlg::OnInitDialog), NULL, this);
+    m_buttonOK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PlugInDlg::OnOK), NULL, this);
+    m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PlugInDlg::OnCancel), NULL, this);
+}
+
+//-------------------------------------------------------------------------
+// OnInitDialog()
+//-------------------------------------------------------------------------
+void PlugInDlg::OnInitDialog(wxInitDialogEvent& event)
+{
+    ExchangeData(EXCHANGE_DATA_IN);
+}
+
+
+//-------------------------------------------------------------------------
+// ExchangeData()
+//-------------------------------------------------------------------------
+void PlugInDlg::ExchangeData(int inout)
+{
+    wxConfigBase *pConfig = wxConfigBase::Get();
+    wxString str;
+    
+    if(inout == EXCHANGE_DATA_IN)
+    {
+        m_txtCtrlPlugIn1->SetValue(wxGetApp().m_txtPlugIn1);
+        m_txtCtrlPlugIn2->SetValue(wxGetApp().m_txtPlugIn2);
+    }
+    if(inout == EXCHANGE_DATA_OUT)
+    {
+        wxGetApp().m_txtPlugIn1 = m_txtCtrlPlugIn1->GetValue();
+        pConfig->Write(wxT("/PlugIn/txt1"), wxGetApp().m_txtPlugIn1);
+        wxGetApp().m_txtPlugIn2 = m_txtCtrlPlugIn2->GetValue();
+        pConfig->Write(wxT("/PlugIn/txt2"), wxGetApp().m_txtPlugIn2);
+        pConfig->Flush();
+    }
+    delete wxConfigBase::Set((wxConfigBase *) NULL);
+}
+
+
+//-------------------------------------------------------------------------
+// OnCancel()
+//-------------------------------------------------------------------------
+void PlugInDlg::OnCancel(wxCommandEvent& event)
+{
+    this->EndModal(wxID_CANCEL);
+}
+
+//-------------------------------------------------------------------------
+// OnClose()
+//-------------------------------------------------------------------------
+void PlugInDlg::OnOK(wxCommandEvent& event)
+{
+    ExchangeData(EXCHANGE_DATA_OUT);
+    this->EndModal(wxID_OK);
+}
diff --git a/freedv-dev/src/dlg_plugin.h b/freedv-dev/src/dlg_plugin.h
new file mode 100644 (file)
index 0000000..e9bcb66
--- /dev/null
@@ -0,0 +1,66 @@
+//==========================================================================
+// Name:            dlg_ptt.h
+// Purpose:         Subclasses dialog GUI for PTT Config.
+//                  
+// Created:         May. 11, 2012
+// Authors:         David Rowe, David Witten
+// 
+// License:
+//
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License version 2.1,
+//  as published by the Free Software Foundation.  This program is
+//  distributed in the hope that it will be useful, but WITHOUT ANY
+//  WARRANTY; without even the implied warranty of MERCHANTABILITY or
+//  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+//  License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, see <http://www.gnu.org/licenses/>.
+//
+//==========================================================================
+#ifndef __PLUGIN_DIALOG__
+#define __PLUGIN_DIALOG__
+
+#include "fdmdv2_main.h"
+#include <wx/settings.h>
+#include <wx/xrc/xmlres.h>
+#include <wx/xrc/xh_bmp.h>
+#include <wx/dialog.h>
+#include <wx/sizer.h>
+#include <wx/statbox.h>
+#include <wx/checkbox.h>
+#include <wx/listbox.h>
+#include <wx/radiobut.h>
+#include <wx/button.h>
+#include <wx/spinctrl.h>
+
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
+// Class PlugInDlg
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
+class PlugInDlg : public wxDialog
+{
+     public:
+        PlugInDlg(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Plugin Config"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(450,300), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
+        virtual ~PlugInDlg();
+        void    ExchangeData(int inout);
+
+    protected:
+
+        wxTextCtrl   *m_txtCtrlPlugIn1;
+        wxTextCtrl   *m_txtCtrlPlugIn2;
+        wxTextCtrl   *m_txtCtrlPlugIn3;
+        /* Ok - Cance */
+
+        wxButton* m_buttonOK;
+        wxButton* m_buttonCancel;
+
+
+protected:
+
+        void OnOK(wxCommandEvent& event);
+        void OnCancel(wxCommandEvent& event);
+        virtual void OnInitDialog(wxInitDialogEvent& event);
+};
+
+#endif // __PLUGIN_DIALOG__
index a45414a0e2e2f9725a02d5af927b62f9fa32661b..3f3464a83b2767540046f495ad55d7f552767a8d 100644 (file)
@@ -2161,6 +2161,18 @@ void MainFrame::OnToolsComCfgUI(wxUpdateUIEvent& event)
     event.Enable(!m_RxRunning);
 }
 
+//-------------------------------------------------------------------------
+// OnToolsPlugInCfg()
+//-------------------------------------------------------------------------
+void MainFrame::OnToolsPlugInCfg(wxCommandEvent& event)
+{
+    wxUnusedVar(event);
+    PlugInDlg *dlg = new PlugInDlg(NULL);
+    dlg->ShowModal();
+    delete dlg;
+}
+
+
 //-------------------------------------------------------------------------
 // OnHelpCheckUpdates()
 //-------------------------------------------------------------------------
@@ -2184,67 +2196,16 @@ void MainFrame::OnHelpCheckUpdatesUI(wxUpdateUIEvent& event)
 void MainFrame::OnHelpAbout(wxCommandEvent& event)
 {
     wxUnusedVar(event);
-#ifdef _USE_ABOUT_DIALOG
-    int rv = 0;
-    AboutDlg *dlg = new AboutDlg(NULL);
-    rv = dlg->ShowModal();
-    if(rv == wxID_OK)
-    {
-        dlg->ExchangeData(EXCHANGE_DATA_OUT);
-    }
-    delete dlg;
-#else
-    wxString svnLatestRev("Can't determine latest SVN revision.");
-
-    // Try to determine current SVN revision from the Internet
-    wxURL url(wxT("http://svn.code.sf.net/p/freetel/code/freedv-dev/"));
-
-    if(url.GetError() == wxURL_NOERR)
-    {
-        wxString htmldata;
-        wxInputStream *in = url.GetInputStream();
-
-        if(in && in->IsOk())
-        {
-            //printf("In OK\n");
-            wxStringOutputStream html_stream(&htmldata);
-            in->Read(html_stream);
-            //wxLogDebug(htmldata);
-
-            wxString s("<h2>p/freetel/code - Revision ");
-            int startIndex = htmldata.find(s) + s.Length();
-            int endIndex = htmldata.find(wxT(": /fdmdv2</h2>"));
-            svnLatestRev = wxT("Latest svn revision: ") + htmldata.SubString(startIndex, endIndex-1);
-            //printf("startIndex: %d endIndex: %d\n", startIndex, endIndex);
-       }
-       delete in;
-    }
-
     wxString msg;
     msg.Printf( wxT("FreeDV %s\n\n")
-                wxT("Open Source Narrow Band Digital Voice over Radio\n\n")
+                wxT("Open Source Digital Voice\n\n")
                 wxT("For Help and Support visit: http://freedv.org\n\n")
 
-                wxT("How much have you spent on Ham gear this year?  How did it compare to FreeDV? ")
-                wxT("FreeDV repesents an open and free future for digital voice over Ham Radio. ")
-                wxT("Please help by donating just $10 here: http://freedv.org\n\n")
-
                 wxT("GNU Public License V2.1\n\n")
                 wxT("Copyright (c) David Witten KD0EAG and David Rowe VK5DGR\n\n")
-                wxT("svn revision: %s\n") + svnLatestRev, FREEDV_VERSION, SVN_REVISION);
+                wxT("svn revision: %s\n"), FREEDV_VERSION, SVN_REVISION);
 
     wxMessageBox(msg, wxT("About"), wxOK | wxICON_INFORMATION, this);
-
-#endif // _USE_ABOUT_DIALOG
-#ifdef USE_SIMPLE_ABOUT_DIALOG
-    wxUnusedVar(event);
-    wxAboutDialogInfo info;
-    info.SetCopyright(_("HAMLib Test"));
-    info.SetLicence(_("GPL v2 or later"));
-    info.SetDescription(_("Short description goes here"));
-    ::wxAboutBox(info);
-#endif // USE_SIMPLE_ABOUT_DIALOG
-
 }
 
 
@@ -2983,9 +2944,9 @@ void MainFrame::processTxtEvent(char event[]) {
             // if we found a match, lets run the replace regexp and issue the system command
 
             wxString event_str_rep = event_str;
-
+           
             if (re.Replace(&event_str_rep, regexp_replace) != 0) {
-                //printf("  found match!\n");
+                fprintf(stderr, "  found match! event_str: %s\n", (const char *)event_str.c_str());
                 found_match = true;
 
                 bool enableSystem = false;
@@ -2996,7 +2957,7 @@ void MainFrame::processTxtEvent(char event[]) {
 
                 if (spamTimer[rule].IsRunning()) {
                     enableSystem = false;
-                    //printf("  spam timer running\n");
+                    fprintf(stderr, "  spam timer running\n");
                 }
 
                 const char *event_out = event_str_rep.ToUTF8();
index 42a0b2bda51c9ff80a48ee35ee07cbbfccefd213..94e127ec1fd4b17de0e48ea4b1eb127920cb315c 100644 (file)
@@ -85,6 +85,7 @@
 #include "varicode.h"
 #include "sox_biquad.h"
 #include "comp_prim.h"
+#include "dlg_plugin.h"
 
 #define _USE_TIMER              1
 #define _USE_ONIDLE             1
@@ -268,6 +269,11 @@ class MainApp : public wxApp
         bool                loadConfig();
         bool                saveConfig();
 
+        // Plugins -----------------------------------
+
+        wxString            m_txtPlugIn1;
+        wxString            m_txtPlugIn2;
+
         // misc
 
         bool       m_testFrames;
@@ -495,6 +501,8 @@ class MainFrame : public TopFrame
         void OnToolsOptions(wxCommandEvent& event);
         void OnToolsOptionsUI(wxUpdateUIEvent& event);
 
+        void OnToolsPlugInCfg( wxCommandEvent& event );
+
         void OnPlayFileToMicIn( wxCommandEvent& event );
         void StopPlayFileToMicIn(void);
         void OnRecFileFromRadio( wxCommandEvent& event );
index 1bd7d4e814e61ff71473891aee2527e465429b91..514d8949c4be85249152a0ce51f23d45c7a9c0ef 100644 (file)
@@ -68,6 +68,10 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const
     m_menuItemFilter = new wxMenuItem(tools, wxID_ANY, wxString(_("&Filter")) , wxEmptyString, wxITEM_NORMAL);
     tools->Append(m_menuItemFilter);
 
+    wxMenuItem* m_menuItemPlugIn;
+    m_menuItemPlugIn = new wxMenuItem(tools, wxID_ANY, wxString(_("PlugIn Config")) , wxEmptyString, wxITEM_NORMAL);
+    tools->Append(m_menuItemPlugIn);
+
     wxMenuItem* m_menuItemPlayFileToMicIn;
     m_menuItemPlayFileToMicIn = new wxMenuItem(tools, wxID_ANY, wxString(_("Start/Stop Play File - Mic In")) , wxEmptyString, wxITEM_NORMAL);
     g_playFileToMicInEventId = m_menuItemPlayFileToMicIn->GetId();
@@ -471,6 +475,8 @@ TopFrame::TopFrame(wxWindow* parent, wxWindowID id, const wxString& title, const
     this->Connect(m_menuItemOptions->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnToolsOptions));
     this->Connect(m_menuItemOptions->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler(TopFrame::OnToolsOptionsUI));
 
+    this->Connect(m_menuItemPlugIn->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnToolsPlugInCfg));
+
     this->Connect(m_menuItemPlayFileToMicIn->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnPlayFileToMicIn));
     this->Connect(m_menuItemRecFileFromRadio->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnRecFileFromRadio));
     this->Connect(m_menuItemPlayFileFromRadio->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnPlayFileFromRadio));
@@ -528,6 +534,8 @@ TopFrame::~TopFrame()
     this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnToolsOptions));
     this->Disconnect(wxID_ANY, wxEVT_UPDATE_UI, wxUpdateUIEventHandler(TopFrame::OnToolsOptionsUI));
 
+    this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnToolsPlugInCfg));
+
     this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnPlayFileToMicIn));
     this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnRecFileFromRadio));
     this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(TopFrame::OnPlayFileFromRadio));
index 9d29053c37014bb75ec27fff14038124e01fd395..2cfe7291f8df31ac1675ae617eff8e1c3b240576 100644 (file)
@@ -125,6 +125,9 @@ class TopFrame : public wxFrame
         virtual void OnToolsFilter( wxCommandEvent& event ) { event.Skip(); }
         virtual void OnToolsFilterUI( wxUpdateUIEvent& event ) { event.Skip(); }
         virtual void OnToolsOptions( wxCommandEvent& event ) { event.Skip(); }
+
+        virtual void OnToolsPlugInCfg( wxCommandEvent& event ) { event.Skip(); }
+
         virtual void OnToolsUDP( wxCommandEvent& event ) { event.Skip(); }
         virtual void OnToolsOptionsUI( wxUpdateUIEvent& event ) { event.Skip(); }
         virtual void OnToolsComCfg( wxCommandEvent& event ) { event.Skip(); }