Initial commit.

This commit is contained in:
Jonathan Naylor 2018-05-09 19:23:17 +01:00
commit 12d55cef37
430 changed files with 72067 additions and 0 deletions

View file

@ -0,0 +1,206 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{99F336A5-6E33-4919-BF75-D6D8BA26345E}</ProjectGuid>
<RootNamespace>TimeServer</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>14.0.24720.0</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(WXWIN)\include;$(WXWIN)\lib\vc_dll\mswud;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(WXWIN)\include;$(WXWIN)\lib\vc_x64_dll\mswud;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(WXWIN)\include\msvc;$(WXWIN)\include;../Common;../GUICommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0400;__WXMSW__;WXUSINGDLL;wxUSE_GUI=1;__WXDEBUG__;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader />
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(WXWIN)\lib\vc_dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(WXWIN)\include\msvc;$(WXWIN)\include;../Common;../GUICommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;WINVER=0x0400;__WXMSW__;WXUSINGDLL;wxUSE_GUI=1;__WXDEBUG__;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(WXWIN)\lib\vc_x64_dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(WXWIN)\include\msvc;$(WXWIN)\include;../Common;../GUICommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0400;__WXMSW__;WXUSINGDLL;wxUSE_GUI=1;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(WXWIN)\lib\vc_dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(WXWIN)\include\msvc;$(WXWIN)\include;../Common;../GUICommon;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;WINVER=0x0400;__WXMSW__;WXUSINGDLL;wxUSE_GUI=1;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(WXWIN)\lib\vc_x64_dll;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="TimeServerAnnouncementsSet.cpp" />
<ClCompile Include="TimeServerApp.cpp" />
<ClCompile Include="TimeServerConfig.cpp" />
<ClCompile Include="TimeServerFrame.cpp" />
<ClCompile Include="TimeServerGatewaySet.cpp" />
<ClCompile Include="TimeServerLogRedirect.cpp" />
<ClCompile Include="TimeServerPreferences.cpp" />
<ClCompile Include="TimeServerThread.cpp" />
<ClCompile Include="TimeServerThreadHelper.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="TimeServerAnnouncementsSet.h" />
<ClInclude Include="TimeServerApp.h" />
<ClInclude Include="TimeServerConfig.h" />
<ClInclude Include="TimeServerDefs.h" />
<ClInclude Include="TimeServerFrame.h" />
<ClInclude Include="TimeServerGatewaySet.h" />
<ClInclude Include="TimeServerLogRedirect.h" />
<ClInclude Include="TimeServerPreferences.h" />
<ClInclude Include="TimeServerThread.h" />
<ClInclude Include="TimeServerThreadHelper.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.vcxproj">
<Project>{e793cb8e-2ac9-431a-bbfc-3f52537bb3cf}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="..\GUICommon\GUICommon.vcxproj">
<Project>{02d03515-0bbe-4553-8c40-566a597478f8}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="TimeServerAnnouncementsSet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TimeServerApp.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TimeServerConfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TimeServerFrame.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TimeServerGatewaySet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TimeServerLogRedirect.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TimeServerPreferences.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TimeServerThread.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TimeServerThreadHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="TimeServerAnnouncementsSet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimeServerApp.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimeServerConfig.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimeServerDefs.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimeServerFrame.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimeServerGatewaySet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimeServerLogRedirect.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimeServerPreferences.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimeServerThread.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TimeServerThreadHelper.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View file

@ -0,0 +1,116 @@
/*
* Copyright (C) 2012,2013 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TimeServerAnnouncementsSet.h"
#include "DStarDefines.h"
const unsigned int BORDER_SIZE = 5U;
const unsigned int CONTROL_WIDTH = 150U;
CTimeServerAnnouncementsSet::CTimeServerAnnouncementsSet(wxWindow* parent, int id, const wxString& title, LANGUAGE language, FORMAT format, INTERVAL interval) :
wxPanel(parent, id),
m_title(title),
m_language(NULL),
m_format(NULL),
m_interval(NULL)
{
wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
wxStaticText* languageLabel = new wxStaticText(this, -1, _("Language"));
sizer->Add(languageLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
m_language = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_language->Append(wxT("English 1 (UK)"));
m_language->Append(wxT("English 2 (UK)"));
m_language->Append(wxT("English 1 (US)"));
m_language->Append(wxT("English 2 (US)"));
m_language->Append(wxT("Deutsch 1"));
m_language->Append(wxT("Deutsch 2"));
m_language->Append(wxT("Francais"));
m_language->Append(wxT("Nederlands"));
m_language->Append(wxT("Svenska"));
m_language->Append(wxT("Espanol"));
m_language->Append(wxT("Norsk"));
m_language->Append(wxT("Portugues"));
sizer->Add(m_language, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_language->SetSelection(int(language));
wxStaticText* formatLabel = new wxStaticText(this, -1, _("Format"));
sizer->Add(formatLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_format = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_format->Append(_("Voice, time only"));
m_format->Append(_("Voice, callsign + time"));
m_format->Append(_("Text, time only"));
sizer->Add(m_format, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_format->SetSelection(int(format));
wxStaticText* intervalLabel = new wxStaticText(this, -1, _("Interval"));
sizer->Add(intervalLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_interval = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_interval->Append(_("Every 15 minutes"));
m_interval->Append(_("Every 30 minutes"));
m_interval->Append(_("Every hour"));
sizer->Add(m_interval, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_interval->SetSelection(int(interval));
SetAutoLayout(true);
SetSizer(sizer);
}
CTimeServerAnnouncementsSet::~CTimeServerAnnouncementsSet()
{
}
bool CTimeServerAnnouncementsSet::Validate()
{
if (m_language->GetCurrentSelection() == wxNOT_FOUND)
return false;
return m_interval->GetCurrentSelection() != wxNOT_FOUND;
}
LANGUAGE CTimeServerAnnouncementsSet::getLanguage() const
{
int n = m_language->GetCurrentSelection();
if (n == wxNOT_FOUND)
return LANG_ENGLISH_UK_1;
return LANGUAGE(n);
}
FORMAT CTimeServerAnnouncementsSet::getFormat() const
{
int n = m_format->GetCurrentSelection();
if (n == wxNOT_FOUND)
return FORMAT_VOICE_TIME;
return FORMAT(n);
}
INTERVAL CTimeServerAnnouncementsSet::getInterval() const
{
int n = m_interval->GetCurrentSelection();
if (n == wxNOT_FOUND)
return INTERVAL_15MINS;
return INTERVAL(n);
}

View file

@ -0,0 +1,46 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerAnnouncementsSet_H
#define TimeServerAnnouncementsSet_H
#include "TimeServerDefs.h"
#include <wx/wx.h>
class CTimeServerAnnouncementsSet : public wxPanel {
public:
CTimeServerAnnouncementsSet(wxWindow* parent, int id, const wxString& title, LANGUAGE language, FORMAT format, INTERVAL interval);
virtual ~CTimeServerAnnouncementsSet();
virtual bool Validate();
virtual LANGUAGE getLanguage() const;
virtual FORMAT getFormat() const;
virtual INTERVAL getInterval() const;
private:
wxString m_title;
wxChoice* m_language;
wxChoice* m_format;
wxChoice* m_interval;
};
#endif

View file

@ -0,0 +1,241 @@
/*
* Copyright (C) 2012,2014,2015 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TimeServerLogRedirect.h"
#include "TimeServerThread.h"
#include "TimeServerApp.h"
#include "Version.h"
#include "Logger.h"
#include <wx/config.h>
#include <wx/cmdline.h>
#include <wx/filename.h>
IMPLEMENT_APP(CTimeServerApp)
const wxChar* NAME_PARAM = wxT("Name");
const wxChar* NOLOGGING_SWITCH = wxT("nolog");
const wxChar* GUI_SWITCH = wxT("gui");
const wxChar* LOGDIR_OPTION = wxT("logdir");
const wxChar* CONFDIR_OPTION = wxT("confdir");
static const wxString LOG_BASE_NAME ="timeserver";
CTimeServerApp::CTimeServerApp() :
wxApp(),
m_name(),
m_nolog(false),
m_gui(false),
m_logDir(),
m_confDir(),
m_frame(NULL),
m_thread(NULL),
m_config(NULL),
m_logChain(NULL)
{
}
CTimeServerApp::~CTimeServerApp()
{
}
bool CTimeServerApp::OnInit()
{
SetVendorName(VENDOR_NAME);
if (!wxApp::OnInit())
return false;
if (!m_nolog) {
wxString logBaseName = LOG_BASE_NAME;
if (!m_name.IsEmpty()) {
logBaseName.Append(wxT("_"));
logBaseName.Append(m_name);
}
#if defined(__WINDOWS__)
if (m_logDir.IsEmpty())
m_logDir = wxFileName::GetHomeDir();
#else
if (m_logDir.IsEmpty())
m_logDir = wxT(LOG_DIR);
#endif
wxLog* log = new CLogger(m_logDir, logBaseName);
wxLog::SetActiveTarget(log);
} else {
new wxLogNull;
}
m_logChain = new wxLogChain(new CTimeServerLogRedirect);
#if defined(__WINDOWS__)
m_config = new CTimeServerConfig(new wxConfig(APPLICATION_NAME), m_name);
#else
if (m_confDir.IsEmpty())
m_confDir = wxT(CONF_DIR);
m_config = new CTimeServerConfig(m_confDir, m_name);
#endif
wxString frameName = APPLICATION_NAME + wxT(" - ");
if (!m_name.IsEmpty()) {
frameName.Append(m_name);
frameName.Append(wxT(" - "));
}
frameName.Append(VERSION);
wxPoint position = wxDefaultPosition;
int x, y;
getPosition(x, y);
if (x >= 0 && y >= 0)
position = wxPoint(x, y);
m_frame = new CTimeServerFrame(frameName, position, m_gui);
m_frame->Show();
SetTopWindow(m_frame);
wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" - ") + VERSION);
// Log the version of wxWidgets and the Operating System
wxLogInfo(wxT("Using wxWidgets %d.%d.%d on %s"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, ::wxGetOsDescription().c_str());
createThread();
return true;
}
int CTimeServerApp::OnExit()
{
m_logChain->SetLog(NULL);
wxLogInfo(APPLICATION_NAME + wxT(" is exiting"));
m_thread->kill();
delete m_config;
return 0;
}
void CTimeServerApp::OnInitCmdLine(wxCmdLineParser& parser)
{
parser.AddSwitch(NOLOGGING_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddSwitch(GUI_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddOption(LOGDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddOption(CONFDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddParam(NAME_PARAM, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
wxApp::OnInitCmdLine(parser);
}
bool CTimeServerApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
if (!wxApp::OnCmdLineParsed(parser))
return false;
m_nolog = parser.Found(NOLOGGING_SWITCH);
m_gui = parser.Found(GUI_SWITCH);
wxString logDir;
bool found = parser.Found(LOGDIR_OPTION, &logDir);
if (found)
m_logDir = logDir;
wxString confDir;
found = parser.Found(CONFDIR_OPTION, &confDir);
if (found)
m_confDir = confDir;
if (parser.GetParamCount() > 0U)
m_name = parser.GetParam(0U);
return true;
}
#if defined(__WXDEBUG__)
void CTimeServerApp::OnAssertFailure(const wxChar* file, int line, const wxChar* func, const wxChar* cond, const wxChar* msg)
{
wxLogFatalError(wxT("Assertion failed on line %d in file %s and function %s: %s %s"), line, file, func, cond, msg);
}
#endif
void CTimeServerApp::showLog(const wxString& text)
{
m_frame->showLog(text);
}
void CTimeServerApp::getGateway(wxString& callsign, bool& sendA, bool& sendB, bool& sendC, bool& sendD, bool& sendE, wxString& address) const
{
m_config->getGateway(callsign, sendA, sendB, sendC, sendD, sendE, address);
}
void CTimeServerApp::setGateway(const wxString& callsign, bool sendA, bool sendB, bool sendC, bool sendD, bool sendE, const wxString& address)
{
m_config->setGateway(callsign, sendA, sendB, sendC, sendD, sendE, address);
}
void CTimeServerApp::getAnnouncements(LANGUAGE& language, FORMAT& format, INTERVAL& interval) const
{
m_config->getAnnouncements(language, format, interval);
}
void CTimeServerApp::setAnnouncements(LANGUAGE language, FORMAT format, INTERVAL interval)
{
m_config->setAnnouncements(language, format, interval);
}
void CTimeServerApp::getPosition(int& x, int& y) const
{
m_config->getPosition(x, y);
}
void CTimeServerApp::setPosition(int x, int y)
{
m_config->setPosition(x, y);
}
bool CTimeServerApp::writeConfig()
{
return m_config->write();
}
void CTimeServerApp::createThread()
{
CTimeServerThread* thread = new CTimeServerThread;
wxString callsign, address;
bool sendA, sendB, sendC, sendD, sendE;
getGateway(callsign, sendA, sendB, sendC, sendD, sendE, address);
callsign.MakeUpper();
thread->setGateway(callsign, sendA, sendB, sendC, sendD, sendE, address);
wxLogInfo(wxT("Callsign set to %s, module %s%s%s%s, address: %s"), callsign.c_str(), sendA ? wxT("A") : wxT(""), sendB ? wxT("B") : wxT(""), sendC ? wxT("C") : wxT(""), sendD ? wxT("D") : wxT(""), sendE ? wxT("E") : wxT(""), address.c_str());
LANGUAGE language;
FORMAT format;
INTERVAL interval;
getAnnouncements(language, format, interval);
thread->setAnnouncements(language, format, interval);
wxLogInfo(wxT("Language: %d, format: %d, interval: %d"), int(language), int(format), int(interval));
// Convert the worker class into a thread
m_thread = new CTimeServerThreadHelper(thread);
m_thread->start();
}

View file

@ -0,0 +1,75 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerApp_H
#define TimeServerApp_H
#include "TimeServerThreadHelper.h"
#include "TimeServerConfig.h"
#include "TimeServerFrame.h"
#include "TimeServerDefs.h"
#include <wx/wx.h>
class CTimeServerApp : public wxApp {
public:
CTimeServerApp();
virtual ~CTimeServerApp();
virtual bool OnInit();
virtual int OnExit();
virtual void OnInitCmdLine(wxCmdLineParser& parser);
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
// This is overridden because dialog boxes from threads are bad news
#if defined(__WXDEBUG__)
virtual void OnAssertFailure(const wxChar* file, int line, const wxChar* func, const wxChar* cond, const wxChar* msg);
#endif
virtual void showLog(const wxString& text);
virtual void getGateway(wxString& callsign, bool& sendA, bool& sendB, bool& sendC, bool& sendD, bool& sendE, wxString& address) const;
virtual void setGateway(const wxString& callsign, bool sendA, bool sendB, bool sendC, bool sendD, bool sendE, const wxString& address);
virtual void getAnnouncements(LANGUAGE& language, FORMAT& format, INTERVAL& interval) const;
virtual void setAnnouncements(LANGUAGE language, FORMAT format, INTERVAL interval);
virtual void getPosition(int& x, int& y) const;
virtual void setPosition(int x, int y);
virtual bool writeConfig();
private:
wxString m_name;
bool m_nolog;
bool m_gui;
wxString m_logDir;
wxString m_confDir;
CTimeServerFrame* m_frame;
CTimeServerThreadHelper* m_thread;
CTimeServerConfig* m_config;
wxLogChain* m_logChain;
void createThread();
};
DECLARE_APP(CTimeServerApp)
#endif

View file

@ -0,0 +1,331 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TimeServerConfig.h"
const wxString KEY_CALLSIGN = wxT("callsign");
const wxString KEY_SENDA = wxT("sendA");
const wxString KEY_SENDB = wxT("sendB");
const wxString KEY_SENDC = wxT("sendC");
const wxString KEY_SENDD = wxT("sendD");
const wxString KEY_SENDE = wxT("sendE");
const wxString KEY_ADDRESS = wxT("address");
const wxString KEY_LANGUAGE = wxT("language");
const wxString KEY_FORMAT = wxT("format");
const wxString KEY_INTERVAL = wxT("interval");
const wxString KEY_WINDOW_X = wxT("windowX");
const wxString KEY_WINDOW_Y = wxT("windowY");
const wxString DEFAULT_CALLSIGN = wxEmptyString;
const bool DEFAULT_SENDA = false;
const bool DEFAULT_SENDB = false;
const bool DEFAULT_SENDC = false;
const bool DEFAULT_SENDD = false;
const bool DEFAULT_SENDE = false;
const wxString DEFAULT_ADDRESS = wxT("127.0.0.1");
const LANGUAGE DEFAULT_LANGUAGE = LANG_ENGLISH_UK_1;
const FORMAT DEFAULT_FORMAT = FORMAT_VOICE_TIME;
const INTERVAL DEFAULT_INTERVAL = INTERVAL_15MINS;
const int DEFAULT_WINDOW_X = -1;
const int DEFAULT_WINDOW_Y = -1;
#if defined(__WINDOWS__)
CTimeServerConfig::CTimeServerConfig(wxConfigBase* config, const wxString& name) :
m_config(config),
m_name(wxT("/")),
m_callsign(DEFAULT_CALLSIGN),
m_sendA(DEFAULT_SENDA),
m_sendB(DEFAULT_SENDB),
m_sendC(DEFAULT_SENDC),
m_sendD(DEFAULT_SENDD),
m_sendE(DEFAULT_SENDE),
m_address(DEFAULT_ADDRESS),
m_language(DEFAULT_LANGUAGE),
m_format(DEFAULT_FORMAT),
m_interval(DEFAULT_INTERVAL),
m_x(DEFAULT_WINDOW_X),
m_y(DEFAULT_WINDOW_Y)
{
wxASSERT(config != NULL);
if (!name.IsEmpty())
m_name = wxT("/") + name + wxT("/");
m_config->Read(m_name + KEY_CALLSIGN, &m_callsign, DEFAULT_CALLSIGN);
m_config->Read(m_name + KEY_SENDA, &m_sendA, DEFAULT_SENDA);
m_config->Read(m_name + KEY_SENDB, &m_sendB, DEFAULT_SENDB);
m_config->Read(m_name + KEY_SENDC, &m_sendC, DEFAULT_SENDC);
m_config->Read(m_name + KEY_SENDD, &m_sendD, DEFAULT_SENDD);
m_config->Read(m_name + KEY_SENDE, &m_sendE, DEFAULT_SENDE);
m_config->Read(m_name + KEY_ADDRESS, &m_address, DEFAULT_ADDRESS);
long temp;
m_config->Read(m_name + KEY_LANGUAGE, &temp, long(DEFAULT_LANGUAGE));
m_language = LANGUAGE(temp);
m_config->Read(m_name + KEY_FORMAT, &temp, long(DEFAULT_FORMAT));
m_format = FORMAT(temp);
m_config->Read(m_name + KEY_INTERVAL, &temp, long(DEFAULT_INTERVAL));
m_interval = INTERVAL(temp);
m_config->Read(m_name + KEY_WINDOW_X, &temp, long(DEFAULT_WINDOW_X));
m_x = int(temp);
m_config->Read(m_name + KEY_WINDOW_Y, &temp, long(DEFAULT_WINDOW_Y));
m_y = int(temp);
}
CTimeServerConfig::~CTimeServerConfig()
{
delete m_config;
}
#else
CTimeServerConfig::CTimeServerConfig(const wxString& dir, const wxString& name) :
m_fileName(),
m_callsign(DEFAULT_CALLSIGN),
m_sendA(DEFAULT_SENDA),
m_sendB(DEFAULT_SENDB),
m_sendC(DEFAULT_SENDC),
m_sendD(DEFAULT_SENDD),
m_sendE(DEFAULT_SENDE),
m_address(DEFAULT_ADDRESS),
m_language(DEFAULT_LANGUAGE),
m_format(DEFAULT_FORMAT),
m_interval(DEFAULT_INTERVAL),
m_x(DEFAULT_WINDOW_X),
m_y(DEFAULT_WINDOW_Y)
{
wxASSERT(!dir.IsEmpty());
wxString fileName = CONFIG_FILE_NAME;
if (!name.IsEmpty())
fileName = CONFIG_FILE_NAME + wxT("_") + name;
m_fileName.Assign(dir, fileName);
wxTextFile file(m_fileName.GetFullPath());
bool exists = file.Exists();
if (!exists)
return;
bool ret = file.Open();
if (!ret) {
wxLogError(wxT("Cannot open the config file - %s"), m_fileName.GetFullPath().c_str());
return;
}
long temp;
wxString str = file.GetFirstLine();
while (!file.Eof()) {
if (str.GetChar(0U) == wxT('#')) {
str = file.GetNextLine();
continue;
}
int n = str.Find(wxT('='));
if (n == wxNOT_FOUND) {
str = file.GetNextLine();
continue;
}
wxString key = str.Left(n);
wxString val = str.Mid(n + 1U);
if (key.IsSameAs(KEY_CALLSIGN)) {
m_callsign = val;
} else if (key.IsSameAs(KEY_SENDA)) {
val.ToLong(&temp);
m_sendA = temp == 1L;
} else if (key.IsSameAs(KEY_SENDB)) {
val.ToLong(&temp);
m_sendB = temp == 1L;
} else if (key.IsSameAs(KEY_SENDC)) {
val.ToLong(&temp);
m_sendC = temp == 1L;
} else if (key.IsSameAs(KEY_SENDD)) {
val.ToLong(&temp);
m_sendD = temp == 1L;
} else if (key.IsSameAs(KEY_SENDE)) {
val.ToLong(&temp);
m_sendE = temp == 1L;
} else if (key.IsSameAs(KEY_ADDRESS)) {
m_address = val;
} else if (key.IsSameAs(KEY_LANGUAGE)) {
val.ToLong(&temp);
m_language = LANGUAGE(temp);
} else if (key.IsSameAs(KEY_FORMAT)) {
val.ToLong(&temp);
m_format = FORMAT(temp);
} else if (key.IsSameAs(KEY_INTERVAL)) {
val.ToLong(&temp);
m_interval = INTERVAL(temp);
} else if (key.IsSameAs(KEY_WINDOW_X)) {
val.ToLong(&temp);
m_x = int(temp);
} else if (key.IsSameAs(KEY_WINDOW_Y)) {
val.ToLong(&temp);
m_y = int(temp);
}
str = file.GetNextLine();
}
file.Close();
}
CTimeServerConfig::~CTimeServerConfig()
{
}
#endif
void CTimeServerConfig::getGateway(wxString& callsign, bool& sendA, bool& sendB, bool& sendC, bool& sendD, bool& sendE, wxString& address) const
{
callsign = m_callsign;
sendA = m_sendA;
sendB = m_sendB;
sendC = m_sendC;
sendD = m_sendD;
sendE = m_sendE;
address = m_address;
}
void CTimeServerConfig::setGateway(const wxString& callsign, bool sendA, bool sendB, bool sendC, bool sendD, bool sendE, const wxString& address)
{
m_callsign = callsign;
m_sendA = sendA;
m_sendB = sendB;
m_sendC = sendC;
m_sendD = sendD;
m_sendE = sendE;
m_address = address;
}
void CTimeServerConfig::getAnnouncements(LANGUAGE& language, FORMAT& format, INTERVAL& interval) const
{
language = m_language;
format = m_format;
interval = m_interval;
}
void CTimeServerConfig::setAnnouncements(LANGUAGE language, FORMAT format, INTERVAL interval)
{
m_language = language;
m_format = format;
m_interval = interval;
}
void CTimeServerConfig::getPosition(int& x, int& y) const
{
x = m_x;
y = m_y;
}
void CTimeServerConfig::setPosition(int x, int y)
{
m_x = x;
m_y = y;
}
#if defined(__WINDOWS__)
bool CTimeServerConfig::write()
{
m_config->Write(m_name + KEY_CALLSIGN, m_callsign);
m_config->Write(m_name + KEY_SENDA, m_sendA);
m_config->Write(m_name + KEY_SENDB, m_sendB);
m_config->Write(m_name + KEY_SENDC, m_sendC);
m_config->Write(m_name + KEY_SENDD, m_sendD);
m_config->Write(m_name + KEY_SENDE, m_sendE);
m_config->Write(m_name + KEY_ADDRESS, m_address);
m_config->Write(m_name + KEY_LANGUAGE, long(m_language));
m_config->Write(m_name + KEY_FORMAT, long(m_format));
m_config->Write(m_name + KEY_INTERVAL, long(m_interval));
m_config->Write(m_name + KEY_WINDOW_X, long(m_x));
m_config->Write(m_name + KEY_WINDOW_Y, long(m_y));
m_config->Flush();
return true;
}
#else
bool CTimeServerConfig::write()
{
wxTextFile file(m_fileName.GetFullPath());
bool exists = file.Exists();
if (exists) {
bool ret = file.Open();
if (!ret) {
wxLogError(wxT("Cannot open the config file - %s"), m_fileName.GetFullPath().c_str());
return false;
}
// Remove the existing file entries
file.Clear();
} else {
bool ret = file.Create();
if (!ret) {
wxLogError(wxT("Cannot create the config file - %s"), m_fileName.GetFullPath().c_str());
return false;
}
}
wxString buffer;
buffer.Printf(wxT("%s=%s"), KEY_CALLSIGN.c_str(), m_callsign.c_str()); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_SENDA.c_str(), m_sendA ? 1 : 0); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_SENDB.c_str(), m_sendB ? 1 : 0); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_SENDC.c_str(), m_sendC ? 1 : 0); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_SENDD.c_str(), m_sendD ? 1 : 0); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_SENDE.c_str(), m_sendE ? 1 : 0); file.AddLine(buffer);
buffer.Printf(wxT("%s=%s"), KEY_ADDRESS.c_str(), m_address.c_str()); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_LANGUAGE.c_str(), int(m_language)); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_FORMAT.c_str(), int(m_format)); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_INTERVAL.c_str(), int(m_interval)); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_WINDOW_X.c_str(), m_x); file.AddLine(buffer);
buffer.Printf(wxT("%s=%d"), KEY_WINDOW_Y.c_str(), m_y); file.AddLine(buffer);
bool ret = file.Write();
if (!ret) {
file.Close();
wxLogError(wxT("Cannot write the config file - %s"), m_fileName.GetFullPath().c_str());
return false;
}
file.Close();
return true;
}
#endif

View file

@ -0,0 +1,69 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerConfig_H
#define TimeServerConfig_H
#include "TimeServerDefs.h"
#include <wx/wx.h>
#include <wx/config.h>
#include <wx/filename.h>
class CTimeServerConfig {
public:
#if defined(__WINDOWS__)
CTimeServerConfig(wxConfigBase* config, const wxString& name);
#else
CTimeServerConfig(const wxString& dir, const wxString& name);
#endif
~CTimeServerConfig();
void getGateway(wxString& callsign, bool& sendA, bool& sendB, bool& sendC, bool& sendD, bool& sendE, wxString& address) const;
void setGateway(const wxString& callsign, bool sendA, bool sendB, bool sendC, bool sendD, bool sendE, const wxString& address);
void getAnnouncements(LANGUAGE& language, FORMAT& format, INTERVAL& interval) const;
void setAnnouncements(LANGUAGE language, FORMAT format, INTERVAL interval);
void getPosition(int& x, int& y) const;
void setPosition(int x, int y);
bool write();
private:
#if defined(__WINDOWS__)
wxConfigBase* m_config;
wxString m_name;
#else
wxFileName m_fileName;
#endif
wxString m_callsign;
bool m_sendA;
bool m_sendB;
bool m_sendC;
bool m_sendD;
bool m_sendE;
wxString m_address;
LANGUAGE m_language;
FORMAT m_format;
INTERVAL m_interval;
int m_x;
int m_y;
};
#endif

180
TimeServer/TimeServerD.cpp Normal file
View file

@ -0,0 +1,180 @@
/*
* Copyright (C) 2012-2015 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TimeServerConfig.h"
#include "TimeServerD.h"
#include "Version.h"
#include "Logger.h"
#include <wx/cmdline.h>
#include <wx/wfstream.h>
#include <wx/fileconf.h>
#include <wx/filename.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
const wxChar* NAME_PARAM = wxT("Name");
const wxChar* NOLOGGING_SWITCH = wxT("nolog");
const wxChar* LOGDIR_OPTION = wxT("logdir");
const wxChar* CONFDIR_OPTION = wxT("confdir");
const wxChar* DAEMON_SWITCH = wxT("daemon");
static const wxString LOG_BASE_NAME = "timeserverd";
int main(int argc, char** argv)
{
bool res = ::wxInitialize();
if (!res) {
::fprintf(stderr, "timeserverd: failed to initialise the wxWidgets library, exiting\n");
return -1;
}
wxCmdLineParser parser(argc, argv);
parser.AddSwitch(NOLOGGING_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddSwitch(DAEMON_SWITCH, wxEmptyString, wxEmptyString, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddOption(LOGDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddOption(CONFDIR_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
parser.AddParam(NAME_PARAM, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
int cmd = parser.Parse();
if (cmd != 0) {
::wxUninitialize();
return 0;
}
bool nolog = parser.Found(NOLOGGING_SWITCH);
bool daemon = parser.Found(DAEMON_SWITCH);
wxString logDir;
bool found = parser.Found(LOGDIR_OPTION, &logDir);
if (!found)
logDir.Clear();
wxString confDir;
found = parser.Found(CONFDIR_OPTION, &confDir);
if (!found)
confDir = wxT(CONF_DIR);
wxString name;
if (parser.GetParamCount() > 0U)
name = parser.GetParam(0U);
if (daemon) {
pid_t pid = ::fork();
if (pid < 0) {
::fprintf(stderr, "timeserverd: error in fork(), exiting\n");
::wxUninitialize();
return 1;
}
// If this is the parent, exit
if (pid > 0)
return 0;
// We are the child from here onwards
::setsid();
::chdir("/");
::umask(0);
}
CTimeServerD gateway(nolog, logDir, confDir, name);
if (!gateway.init()) {
::wxUninitialize();
return 1;
}
gateway.run();
::wxUninitialize();
return 0;
}
CTimeServerD::CTimeServerD(bool nolog, const wxString& logDir, const wxString& confDir, const wxString& name) :
m_name(name),
m_nolog(nolog),
m_logDir(logDir),
m_confDir(confDir),
m_thread(NULL)
{
}
CTimeServerD::~CTimeServerD()
{
}
bool CTimeServerD::init()
{
if (!m_nolog) {
wxString logBaseName = LOG_BASE_NAME;
if (!m_name.IsEmpty()) {
logBaseName.Append(wxT("_"));
logBaseName.Append(m_name);
}
if (m_logDir.IsEmpty())
m_logDir = wxT(LOG_DIR);
wxLog* log = new CLogger(m_logDir, logBaseName);
wxLog::SetActiveTarget(log);
} else {
new wxLogNull;
}
wxLogInfo(wxT("Starting ") + APPLICATION_NAME + wxT(" daemon - ") + VERSION);
// Log the version of wxWidgets and the Operating System
wxLogInfo(wxT("Using wxWidgets %d.%d.%d on %s"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, ::wxGetOsDescription().c_str());
return createThread();
}
void CTimeServerD::run()
{
m_thread->run();
wxLogInfo(APPLICATION_NAME + wxT(" is exiting"));
}
bool CTimeServerD::createThread()
{
CTimeServerConfig config(m_confDir, m_name);
m_thread = new CTimeServerThread;
wxString callsign, address;
bool sendA, sendB, sendC, sendD, sendE;
config.getGateway(callsign, sendA, sendB, sendC, sendD, sendE, address);
callsign.MakeUpper();
m_thread->setGateway(callsign, sendA, sendB, sendC, sendD, sendE, address);
wxLogInfo(wxT("Callsign set to %s, module %s%s%s%s, address: %s"), callsign.c_str(), sendA ? wxT("A") : wxT(""), sendB ? wxT("B") : wxT(""), sendC ? wxT("C") : wxT(""), sendD ? wxT("D") : wxT(""), sendE ? wxT("E") : wxT(""), address.c_str());
LANGUAGE language;
FORMAT format;
INTERVAL interval;
config.getAnnouncements(language, format, interval);
m_thread->setAnnouncements(language, format, interval);
wxLogInfo(wxT("Language: %d, format: %d, interval: %d"), int(language), int(format), int(interval));
return true;
}

48
TimeServer/TimeServerD.h Normal file
View file

@ -0,0 +1,48 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerD_H
#define TimeServerD_H
#include "TimeServerThread.h"
#include "TimeServerDefs.h"
#include <wx/wx.h>
#include <wx/config.h>
class CTimeServerD {
public:
CTimeServerD(bool nolog, const wxString& logDir, const wxString& confDir, const wxString& name);
~CTimeServerD();
bool init();
void run();
private:
wxString m_name;
bool m_nolog;
wxString m_logDir;
wxString m_confDir;
CTimeServerThread* m_thread;
bool createThread();
};
#endif

View file

@ -0,0 +1,57 @@
/*
* Copyright (C) 2012,2013,2014 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerDefs_H
#define TimeServerDefs_H
#include <wx/wx.h>
const wxString APPLICATION_NAME = wxT("Time Server");
#if !defined(__WINDOWS__)
const wxString CONFIG_FILE_NAME = wxT("timeserver");
#endif
enum LANGUAGE {
LANG_ENGLISH_UK_1,
LANG_ENGLISH_UK_2,
LANG_ENGLISH_US_1,
LANG_ENGLISH_US_2,
LANG_DEUTSCH_1,
LANG_DEUTSCH_2,
LANG_FRANCAIS,
LANG_NEDERLANDS,
LANG_SVENSKA,
LANG_ESPANOL,
LANG_NORSK,
LANG_PORTUGUES
};
enum INTERVAL {
INTERVAL_15MINS,
INTERVAL_30MINS,
INTERVAL_60MINS
};
enum FORMAT {
FORMAT_VOICE_TIME,
FORMAT_VOICE_ALL,
FORMAT_TEXT_TIME
};
#endif

View file

@ -0,0 +1,232 @@
/*
* Copyright (C) 2012-2015 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TimeServerPreferences.h"
#include "TimeServerFrame.h"
#include "TimeServerApp.h"
#include "LogEvent.h"
#include "Version.h"
#if defined(__WINDOWS__)
const unsigned int LOGTEXT_WIDTH = 560U;
#else
const unsigned int LOGTEXT_WIDTH = 700U;
#endif
const unsigned int BORDER_SIZE = 5U;
#include <wx/gbsizer.h>
#include <wx/aboutdlg.h>
DEFINE_EVENT_TYPE(LOG_EVENT)
enum {
Menu_Edit_Preferences = 6000,
Menu_View_Updates
};
BEGIN_EVENT_TABLE(CTimeServerFrame, wxFrame)
EVT_MENU(wxID_EXIT, CTimeServerFrame::onQuit)
EVT_MENU(Menu_Edit_Preferences, CTimeServerFrame::onPreferences)
EVT_MENU(Menu_View_Updates, CTimeServerFrame::onUpdates)
EVT_MENU(wxID_ABOUT, CTimeServerFrame::onAbout)
EVT_CLOSE(CTimeServerFrame::onClose)
EVT_CUSTOM(LOG_EVENT, wxID_ANY, CTimeServerFrame::onLog)
END_EVENT_TABLE()
CTimeServerFrame::CTimeServerFrame(const wxString& title, const wxPoint& position, bool gui) :
wxFrame(NULL, -1, title, position),
#if defined(__WXDEBUG__)
m_updates(true)
#else
m_updates(gui)
#endif
{
SetMenuBar(createMenuBar());
wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
wxPanel* panel = new wxPanel(this);
wxBoxSizer* panelSizer = new wxBoxSizer(wxVERTICAL);
wxStaticBoxSizer* log1Sizer = new wxStaticBoxSizer(new wxStaticBox(panel, -1, _("Log")), wxVERTICAL);
wxBoxSizer* log2Sizer = new wxBoxSizer(wxVERTICAL);
for (unsigned int i = 0U; i < 10U; i++) {
m_logLine[i] = new wxStaticText(panel, -1, wxEmptyString, wxDefaultPosition, wxSize(LOGTEXT_WIDTH, -1));
m_logLine[i]->Wrap(LOGTEXT_WIDTH);
log2Sizer->Add(m_logLine[i], 0, wxTOP | wxLEFT | wxRIGHT, BORDER_SIZE);
}
log1Sizer->Add(log2Sizer);
panelSizer->Add(log1Sizer, 0, wxALL, BORDER_SIZE);
panel->SetSizer(panelSizer);
panelSizer->SetSizeHints(panel);
mainSizer->Add(panel);
SetSizer(mainSizer);
mainSizer->SetSizeHints(this);
}
CTimeServerFrame::~CTimeServerFrame()
{
}
wxMenuBar* CTimeServerFrame::createMenuBar()
{
wxMenu* fileMenu = new wxMenu();
fileMenu->Append(wxID_EXIT, _("Exit"));
wxMenu* editMenu = new wxMenu();
editMenu->Append(Menu_Edit_Preferences, _("Preferences..."));
wxMenu* viewMenu = new wxMenu();
viewMenu->AppendCheckItem(Menu_View_Updates, _("GUI Updates"));
viewMenu->Check(Menu_View_Updates, m_updates);
wxMenu* helpMenu = new wxMenu();
helpMenu->Append(wxID_ABOUT, _("About Time Server"));
wxMenuBar* menuBar = new wxMenuBar();
menuBar->Append(fileMenu, _("File"));
menuBar->Append(editMenu, _("Edit"));
menuBar->Append(viewMenu, _("View"));
menuBar->Append(helpMenu, _("Help"));
return menuBar;
}
void CTimeServerFrame::onQuit(wxCommandEvent&)
{
Close(false);
}
void CTimeServerFrame::onClose(wxCloseEvent&)
{
int x, y;
GetPosition(&x, &y);
if (x >= 0 && y >= 0) {
::wxGetApp().setPosition(x, y);
::wxGetApp().writeConfig();
}
Destroy();
}
void CTimeServerFrame::onPreferences(wxCommandEvent&)
{
wxString callsign, address;
bool sendA, sendB, sendC, sendD, sendE;
::wxGetApp().getGateway(callsign, sendA, sendB, sendC, sendD, sendE, address);
LANGUAGE language;
FORMAT format;
INTERVAL interval;
::wxGetApp().getAnnouncements(language, format, interval);
CTimeServerPreferences dialog1(this, -1, callsign, sendA, sendB, sendC, sendD, sendE, address, language, format, interval);
if (dialog1.ShowModal() != wxID_OK)
return;
callsign = dialog1.getCallsign();
sendA = dialog1.getSendA();
sendB = dialog1.getSendB();
sendC = dialog1.getSendC();
sendD = dialog1.getSendD();
sendE = dialog1.getSendE();
address = dialog1.getAddress();
language = dialog1.getLanguage();
format = dialog1.getFormat();
interval = dialog1.getInterval();
::wxGetApp().setGateway(callsign, sendA, sendB, sendC, sendD, sendE, address);
::wxGetApp().setAnnouncements(language, format, interval);
::wxGetApp().writeConfig();
wxMessageDialog dialog2(this, _("The changes made will not take effect\nuntil the application is restarted"), _("DCS Gateway Information"), wxICON_INFORMATION);
dialog2.ShowModal();
}
void CTimeServerFrame::onUpdates(wxCommandEvent& event)
{
m_updates = event.IsChecked();
}
void CTimeServerFrame::onAbout(wxCommandEvent&)
{
wxAboutDialogInfo info;
info.AddDeveloper(wxT("Jonathan Naylor, G4KLX"));
info.SetCopyright(wxT("(C) 2012-2015 using GPL v2 or later"));
info.SetName(APPLICATION_NAME);
info.SetVersion(VERSION);
info.SetDescription(_("This program allows a computer running a gateway\nto have the time announced."));
::wxAboutBox(info);
}
void CTimeServerFrame::onLog(wxEvent& event)
{
CLogEvent& logEvent = dynamic_cast<CLogEvent&>(event);
wxString text;
text = m_logLine[1U]->GetLabel();
m_logLine[0U]->SetLabel(text);
text = m_logLine[2U]->GetLabel();
m_logLine[1U]->SetLabel(text);
text = m_logLine[3U]->GetLabel();
m_logLine[2U]->SetLabel(text);
text = m_logLine[4U]->GetLabel();
m_logLine[3U]->SetLabel(text);
text = m_logLine[5U]->GetLabel();
m_logLine[4U]->SetLabel(text);
text = m_logLine[6U]->GetLabel();
m_logLine[5U]->SetLabel(text);
text = m_logLine[7U]->GetLabel();
m_logLine[6U]->SetLabel(text);
text = m_logLine[8U]->GetLabel();
m_logLine[7U]->SetLabel(text);
text = m_logLine[9U]->GetLabel();
m_logLine[8U]->SetLabel(text);
text = logEvent.getText();
m_logLine[9U]->SetLabel(text);
}
void CTimeServerFrame::showLog(const wxString& text)
{
if (!m_updates)
return;
CLogEvent event(text, LOG_EVENT);
AddPendingEvent(event);
}

View file

@ -0,0 +1,50 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerFrame_H
#define TimeServerFrame_H
#include "TimeServerDefs.h"
#include <wx/wx.h>
#include <wx/tglbtn.h>
class CTimeServerFrame : public wxFrame {
public:
CTimeServerFrame(const wxString& title, const wxPoint& position, bool gui);
virtual ~CTimeServerFrame();
virtual void onQuit(wxCommandEvent& event);
virtual void onPreferences(wxCommandEvent& event);
virtual void onUpdates(wxCommandEvent& event);
virtual void onAbout(wxCommandEvent& event);
virtual void onClose(wxCloseEvent& event);
virtual void onLog(wxEvent& event);
virtual void showLog(const wxString& text);
private:
wxStaticText* m_logLine[10];
bool m_updates;
DECLARE_EVENT_TABLE()
wxMenuBar* createMenuBar();
};
#endif

View file

@ -0,0 +1,184 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TimeServerGatewaySet.h"
#include "DStarDefines.h"
const unsigned int BORDER_SIZE = 5U;
const unsigned int CONTROL_WIDTH = 150U;
CTimeServerGatewaySet::CTimeServerGatewaySet(wxWindow* parent, int id, const wxString& title, const wxString& callsign, bool sendA, bool sendB, bool sendC, bool sendD, bool sendE, const wxString& address) :
wxPanel(parent, id),
m_title(title),
m_callsign(NULL),
m_address(NULL),
m_sendA(NULL),
m_sendB(NULL),
m_sendC(NULL),
m_sendD(NULL),
m_sendE(NULL)
{
wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
wxStaticText* callsignLabel = new wxStaticText(this, -1, _("Callsign"));
sizer->Add(callsignLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_callsign = new CCallsignTextCtrl(this, -1, callsign, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_callsign->SetMaxLength(LONG_CALLSIGN_LENGTH - 1U);
sizer->Add(m_callsign, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
wxStaticText* addressLabel = new wxStaticText(this, -1, _("Address"));
sizer->Add(addressLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_address = new CAddressTextCtrl(this, -1, address, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
sizer->Add(m_address, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
wxStaticText* sendALabel = new wxStaticText(this, -1, _("Module A"));
sizer->Add(sendALabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_sendA = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_sendA->Append(_("No"));
m_sendA->Append(_("Yes"));
sizer->Add(m_sendA, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_sendA->SetSelection(sendA ? 1 : 0);
wxStaticText* sendBLabel = new wxStaticText(this, -1, _("Module B"));
sizer->Add(sendBLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_sendB = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_sendB->Append(_("No"));
m_sendB->Append(_("Yes"));
sizer->Add(m_sendB, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_sendB->SetSelection(sendB ? 1 : 0);
wxStaticText* sendCLabel = new wxStaticText(this, -1, _("Module C"));
sizer->Add(sendCLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_sendC = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_sendC->Append(_("No"));
m_sendC->Append(_("Yes"));
sizer->Add(m_sendC, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_sendC->SetSelection(sendC ? 1 : 0);
wxStaticText* sendDLabel = new wxStaticText(this, -1, _("Module D"));
sizer->Add(sendDLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_sendD = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_sendD->Append(_("No"));
m_sendD->Append(_("Yes"));
sizer->Add(m_sendD, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_sendD->SetSelection(sendD ? 1 : 0);
wxStaticText* sendELabel = new wxStaticText(this, -1, _("Module E"));
sizer->Add(sendELabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_sendE = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1));
m_sendE->Append(_("No"));
m_sendE->Append(_("Yes"));
sizer->Add(m_sendE, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
m_sendE->SetSelection(sendE ? 1 : 0);
SetAutoLayout(true);
SetSizer(sizer);
}
CTimeServerGatewaySet::~CTimeServerGatewaySet()
{
}
bool CTimeServerGatewaySet::Validate()
{
bool res = getCallsign().IsEmpty();
if (res) {
wxMessageDialog dialog(this, _("The Callsign may not be empty"), _("Time Server Error"), wxICON_ERROR);
dialog.ShowModal();
return false;
}
res = getAddress().IsEmpty();
if (res) {
wxMessageDialog dialog(this, _("The Address may not be empty"), _("Time Server Error"), wxICON_ERROR);
dialog.ShowModal();
return false;
}
if (m_sendA->GetCurrentSelection() == wxNOT_FOUND)
return false;
if (m_sendB->GetCurrentSelection() == wxNOT_FOUND)
return false;
if (m_sendC->GetCurrentSelection() == wxNOT_FOUND)
return false;
if (m_sendD->GetCurrentSelection() == wxNOT_FOUND)
return false;
return m_sendE->GetCurrentSelection() != wxNOT_FOUND;
}
wxString CTimeServerGatewaySet::getCallsign() const
{
wxString callsign = m_callsign->GetValue();
callsign.MakeUpper();
return callsign;
}
wxString CTimeServerGatewaySet::getAddress() const
{
return m_address->GetValue();
}
bool CTimeServerGatewaySet::getSendA() const
{
int n = m_sendA->GetCurrentSelection();
return n == 1;
}
bool CTimeServerGatewaySet::getSendB() const
{
int n = m_sendB->GetCurrentSelection();
return n == 1;
}
bool CTimeServerGatewaySet::getSendC() const
{
int n = m_sendC->GetCurrentSelection();
return n == 1;
}
bool CTimeServerGatewaySet::getSendD() const
{
int n = m_sendD->GetCurrentSelection();
return n == 1;
}
bool CTimeServerGatewaySet::getSendE() const
{
int n = m_sendE->GetCurrentSelection();
return n == 1;
}

View file

@ -0,0 +1,56 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerGatewaySet_H
#define TimeServerGatewaySet_H
#include "CallsignTextCtrl.h"
#include "AddressTextCtrl.h"
#include <wx/wx.h>
class CTimeServerGatewaySet : public wxPanel {
public:
CTimeServerGatewaySet(wxWindow* parent, int id, const wxString& title, const wxString& callsign, bool sendA, bool sendB,
bool sendC, bool sendD, bool sendE, const wxString& address);
virtual ~CTimeServerGatewaySet();
virtual bool Validate();
virtual wxString getCallsign() const;
virtual wxString getAddress() const;
virtual bool getSendA() const;
virtual bool getSendB() const;
virtual bool getSendC() const;
virtual bool getSendD() const;
virtual bool getSendE() const;
private:
wxString m_title;
CCallsignTextCtrl* m_callsign;
CAddressTextCtrl* m_address;
wxChoice* m_sendA;
wxChoice* m_sendB;
wxChoice* m_sendC;
wxChoice* m_sendD;
wxChoice* m_sendE;
};
#endif

View file

@ -0,0 +1,56 @@
/*
* Copyright (C) 2002,2003,2009-2013,2018 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TimeServerLogRedirect.h"
#include "TimeServerApp.h"
CTimeServerLogRedirect::CTimeServerLogRedirect() :
wxLog()
{
}
CTimeServerLogRedirect::~CTimeServerLogRedirect()
{
}
void CTimeServerLogRedirect::DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info)
{
wxString letter;
switch (level) {
case wxLOG_FatalError: letter = wxT("F"); break;
case wxLOG_Error: letter = wxT("E"); break;
case wxLOG_Warning: letter = wxT("W"); break;
case wxLOG_Info: letter = wxT("I"); break;
case wxLOG_Message: letter = wxT("M"); break;
case wxLOG_Status: letter = wxT("M"); break;
case wxLOG_Trace: letter = wxT("T"); break;
case wxLOG_Debug: letter = wxT("D"); break;
default: letter = wxT("U"); break;
}
struct tm* tm = ::gmtime(&info.timestamp);
wxString message;
message.Printf(wxT("%s: %04d-%02d-%02d %02d:%02d:%02d: %s\n"), letter.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, msg.c_str());
::wxGetApp().showLog(message);
if (level == wxLOG_FatalError)
::abort();
}

View file

@ -0,0 +1,35 @@
/*
* Copyright (C) 2002,2003,2009-2011,2018 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerLogRedirect_H
#define TimeServerLogRedirect_H
#include <wx/wx.h>
#include <wx/log.h>
class CTimeServerLogRedirect : public wxLog {
public:
CTimeServerLogRedirect();
virtual ~CTimeServerLogRedirect();
virtual void DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info);
private:
};
#endif

View file

@ -0,0 +1,114 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TimeServerPreferences.h"
#include "DStarDefines.h"
const unsigned int BORDER_SIZE = 5U;
const unsigned int CONTROL_WIDTH = 150U;
CTimeServerPreferences::CTimeServerPreferences(wxWindow* parent, int id, const wxString& callsign, bool sendA, bool sendB, bool sendC, bool sendD, bool sendE, const wxString& address, LANGUAGE language, FORMAT format, INTERVAL interval) :
wxDialog(parent, id, wxString(_("Time Server Preferences"))),
m_gateway(NULL),
m_announcements(NULL)
{
wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
wxNotebook* noteBook = new wxNotebook(this, -1);
m_gateway = new CTimeServerGatewaySet(noteBook, -1, APPLICATION_NAME, callsign, sendA, sendB, sendC, sendD, sendE, address);
noteBook->AddPage(m_gateway, _("Gateway"), true);
m_announcements = new CTimeServerAnnouncementsSet(noteBook, -1, APPLICATION_NAME, language, format, interval);
noteBook->AddPage(m_announcements, _("Announcements"), false);
mainSizer->Add(noteBook, 1, wxALL | wxGROW, BORDER_SIZE);
mainSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
SetAutoLayout(true);
Layout();
mainSizer->Fit(this);
mainSizer->SetSizeHints(this);
SetSizer(mainSizer);
}
CTimeServerPreferences::~CTimeServerPreferences()
{
}
bool CTimeServerPreferences::Validate()
{
if (!m_gateway->Validate())
return false;
return m_announcements->Validate();
}
wxString CTimeServerPreferences::getCallsign() const
{
return m_gateway->getCallsign();
}
wxString CTimeServerPreferences::getAddress() const
{
return m_gateway->getAddress();
}
bool CTimeServerPreferences::getSendA() const
{
return m_gateway->getSendA();
}
bool CTimeServerPreferences::getSendB() const
{
return m_gateway->getSendB();
}
bool CTimeServerPreferences::getSendC() const
{
return m_gateway->getSendC();
}
bool CTimeServerPreferences::getSendD() const
{
return m_gateway->getSendD();
}
bool CTimeServerPreferences::getSendE() const
{
return m_gateway->getSendE();
}
LANGUAGE CTimeServerPreferences::getLanguage() const
{
return m_announcements->getLanguage();
}
FORMAT CTimeServerPreferences::getFormat() const
{
return m_announcements->getFormat();
}
INTERVAL CTimeServerPreferences::getInterval() const
{
return m_announcements->getInterval();
}

View file

@ -0,0 +1,54 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerPreferences_H
#define TimeServerPreferences_H
#include "TimeServerAnnouncementsSet.h"
#include "TimeServerGatewaySet.h"
#include "TimeServerDefs.h"
#include <wx/wx.h>
#include <wx/notebook.h>
class CTimeServerPreferences : public wxDialog {
public:
CTimeServerPreferences(wxWindow* parent, int id, const wxString& callsign, bool sendA, bool sendB,
bool sendC, bool sendD, bool sendE, const wxString& address, LANGUAGE language, FORMAT format, INTERVAL interval);
virtual ~CTimeServerPreferences();
virtual bool Validate();
virtual wxString getCallsign() const;
virtual wxString getAddress() const;
virtual bool getSendA() const;
virtual bool getSendB() const;
virtual bool getSendC() const;
virtual bool getSendD() const;
virtual bool getSendE() const;
virtual LANGUAGE getLanguage() const;
virtual FORMAT getFormat() const;
virtual INTERVAL getInterval() const;
private:
CTimeServerGatewaySet* m_gateway;
CTimeServerAnnouncementsSet* m_announcements;
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,122 @@
/*
* Copyright (C) 2012,2013 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerThread_H
#define TimeServerThread_H
#include "SlowDataEncoder.h"
#include "UDPReaderWriter.h"
#include "TimeServerDefs.h"
#include "HeaderData.h"
#include "AMBEData.h"
#include <wx/wx.h>
class CIndexRecord {
public:
CIndexRecord(const wxString& name, unsigned int start, unsigned int length) :
m_name(name),
m_start(start),
m_length(length)
{
}
wxString getName() const
{
return m_name;
}
unsigned int getStart() const
{
return m_start;
}
unsigned int getLength() const
{
return m_length;
}
private:
wxString m_name;
unsigned int m_start;
unsigned int m_length;
};
WX_DECLARE_STRING_HASH_MAP(CIndexRecord*, CIndexList_t);
class CTimeServerThread {
public:
CTimeServerThread();
virtual ~CTimeServerThread();
virtual bool setGateway(const wxString& callsign, bool sendA, bool sendB, bool sendC, bool sendD, bool sendE, const wxString& address);
virtual void setAnnouncements(LANGUAGE language, FORMAT format, INTERVAL interval);
virtual void run();
virtual void kill();
private:
CUDPReaderWriter m_socket;
wxString m_callsign;
wxString m_callsignA;
wxString m_callsignB;
wxString m_callsignC;
wxString m_callsignD;
wxString m_callsignE;
wxString m_callsignG;
in_addr m_address;
LANGUAGE m_language;
FORMAT m_format;
INTERVAL m_interval;
unsigned char* m_ambe;
unsigned int m_ambeLength;
CIndexList_t m_index;
unsigned int m_seqNo;
unsigned int m_in;
CSlowDataEncoder m_encoder;
CAMBEData** m_data;
bool m_killed;
void sendTime(unsigned int hour, unsigned int min);
wxArrayString sendTimeEnGB1(unsigned int hour, unsigned int min);
wxArrayString sendTimeEnGB2(unsigned int hour, unsigned int min);
wxArrayString sendTimeEnUS1(unsigned int hour, unsigned int min);
wxArrayString sendTimeEnUS2(unsigned int hour, unsigned int min);
wxArrayString sendTimeDeDE1(unsigned int hour, unsigned int min);
wxArrayString sendTimeDeDE2(unsigned int hour, unsigned int min);
wxArrayString sendTimeFrFR(unsigned int hour, unsigned int min);
wxArrayString sendTimeNlNL(unsigned int hour, unsigned int min);
wxArrayString sendTimeSeSE(unsigned int hour, unsigned int min);
wxArrayString sendTimeEsES(unsigned int hour, unsigned int min);
wxArrayString sendTimeNoNO(unsigned int hour, unsigned int min);
wxArrayString sendTimePtPT(unsigned int hour, unsigned int min);
bool send(const wxArrayString& words, unsigned int hour, unsigned int min);
bool sendHeader(const CHeaderData& header);
bool sendData(const CAMBEData& data);
bool loadAMBE();
bool readAMBE(const wxString& name);
bool readIndex(const wxString& name);
bool lookup(const wxString& id);
void end();
};
#endif

View file

@ -0,0 +1,58 @@
/*
* Copyright (C) 2012 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "TimeServerThreadHelper.h"
CTimeServerThreadHelper::CTimeServerThreadHelper(CTimeServerThread* thread) :
wxThread(wxTHREAD_JOINABLE),
m_thread(thread)
{
wxASSERT(thread != NULL);
}
CTimeServerThreadHelper::~CTimeServerThreadHelper()
{
delete m_thread;
}
void CTimeServerThreadHelper::start()
{
Create();
SetPriority(100U);
Run();
}
void* CTimeServerThreadHelper::Entry()
{
wxASSERT(m_thread != NULL);
m_thread->run();
return NULL;
}
void CTimeServerThreadHelper::kill()
{
wxASSERT(m_thread != NULL);
m_thread->kill();
Wait();
}

View file

@ -0,0 +1,42 @@
/*
* Copyright (C) 2012,2013 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef TimeServerThreadHelper_H
#define TimeServerThreadHelper_H
#include "TimeServerThread.h"
#include <wx/wx.h>
class CTimeServerThreadHelper : public wxThread {
public:
CTimeServerThreadHelper(CTimeServerThread* thread);
virtual ~CTimeServerThreadHelper();
virtual void start();
virtual void* Entry();
virtual void kill();
private:
CTimeServerThread* m_thread;
};
#endif