mirror of
https://github.com/g4klx/ircDDBGateway.git
synced 2026-04-05 14:25:43 +00:00
Initial commit.
This commit is contained in:
commit
12d55cef37
430 changed files with 72067 additions and 0 deletions
214
RemoteControl/RemoteControl.vcxproj
Normal file
214
RemoteControl/RemoteControl.vcxproj
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
<?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>{F7756875-1F58-4006-AD55-5C963AB682C0}</ProjectGuid>
|
||||
<RootNamespace>RemoteControl</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="RemoteControlApp.cpp" />
|
||||
<ClCompile Include="RemoteControlCallsignData.cpp" />
|
||||
<ClCompile Include="RemoteControlConfig.cpp" />
|
||||
<ClCompile Include="RemoteControlFrame.cpp" />
|
||||
<ClCompile Include="RemoteControlLinkData.cpp" />
|
||||
<ClCompile Include="RemoteControlPreferences.cpp" />
|
||||
<ClCompile Include="RemoteControlRemoteControlHandler.cpp" />
|
||||
<ClCompile Include="RemoteControlRemoteSet.cpp" />
|
||||
<ClCompile Include="RemoteControlRepeaterData.cpp" />
|
||||
<ClCompile Include="RemoteControlRepeaterPanel.cpp" />
|
||||
<ClCompile Include="RemoteControlStarNetGroup.cpp" />
|
||||
<ClCompile Include="RemoteControlStarNetPanel.cpp" />
|
||||
<ClCompile Include="RemoteControlStarNetUser.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="RemoteControlApp.h" />
|
||||
<ClInclude Include="RemoteControlCallsignData.h" />
|
||||
<ClInclude Include="RemoteControlConfig.h" />
|
||||
<ClInclude Include="RemoteControlDefs.h" />
|
||||
<ClInclude Include="RemoteControlFrame.h" />
|
||||
<ClInclude Include="RemoteControlLinkData.h" />
|
||||
<ClInclude Include="RemoteControlPreferences.h" />
|
||||
<ClInclude Include="RemoteControlRemoteControlHandler.h" />
|
||||
<ClInclude Include="RemoteControlRemoteSet.h" />
|
||||
<ClInclude Include="RemoteControlRepeaterData.h" />
|
||||
<ClInclude Include="RemoteControlRepeaterPanel.h" />
|
||||
<ClInclude Include="RemoteControlStarNetGroup.h" />
|
||||
<ClInclude Include="RemoteControlStarNetPanel.h" />
|
||||
<ClInclude Include="RemoteControlStarNetUser.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>
|
||||
98
RemoteControl/RemoteControl.vcxproj.filters
Normal file
98
RemoteControl/RemoteControl.vcxproj.filters
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<?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="RemoteControlApp.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlCallsignData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlConfig.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlFrame.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlLinkData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlPreferences.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlRemoteControlHandler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlRemoteSet.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlRepeaterData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlRepeaterPanel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlStarNetGroup.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlStarNetPanel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="RemoteControlStarNetUser.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="RemoteControlApp.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlCallsignData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlConfig.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlDefs.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlFrame.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlLinkData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlPreferences.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlRemoteControlHandler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlRemoteSet.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlRepeaterData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlRepeaterPanel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlStarNetGroup.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlStarNetPanel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="RemoteControlStarNetUser.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
141
RemoteControl/RemoteControlApp.cpp
Normal file
141
RemoteControl/RemoteControlApp.cpp
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
* Copyright (C) 2011,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 "RemoteControlDefs.h"
|
||||
#include "RemoteControlApp.h"
|
||||
#include "Version.h"
|
||||
|
||||
#include <wx/config.h>
|
||||
#include <wx/cmdline.h>
|
||||
|
||||
IMPLEMENT_APP(CRemoteControlApp)
|
||||
|
||||
const wxChar* NAME_PARAM = wxT("Name");
|
||||
|
||||
CRemoteControlApp::CRemoteControlApp() :
|
||||
wxApp(),
|
||||
m_name(),
|
||||
m_frame(NULL),
|
||||
m_config(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CRemoteControlApp::~CRemoteControlApp()
|
||||
{
|
||||
}
|
||||
|
||||
bool CRemoteControlApp::OnInit()
|
||||
{
|
||||
SetVendorName(VENDOR_NAME);
|
||||
|
||||
if (!wxApp::OnInit())
|
||||
return false;
|
||||
|
||||
m_config = new CRemoteControlConfig(new wxConfig(APPLICATION_NAME), m_name);
|
||||
|
||||
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 CRemoteControlFrame(frameName, position);
|
||||
m_frame->Show();
|
||||
|
||||
SetTopWindow(m_frame);
|
||||
|
||||
return wxApp::OnInit();
|
||||
}
|
||||
|
||||
int CRemoteControlApp::OnExit()
|
||||
{
|
||||
delete m_config;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CRemoteControlApp::OnInitCmdLine(wxCmdLineParser& parser)
|
||||
{
|
||||
parser.AddParam(NAME_PARAM, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
||||
|
||||
wxApp::OnInitCmdLine(parser);
|
||||
}
|
||||
|
||||
bool CRemoteControlApp::OnCmdLineParsed(wxCmdLineParser& parser)
|
||||
{
|
||||
if (!wxApp::OnCmdLineParsed(parser))
|
||||
return false;
|
||||
|
||||
if (parser.GetParamCount() > 0U)
|
||||
m_name = parser.GetParam(0U);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CRemoteControlApp::getConfig(wxString& address, unsigned int& port, wxString& password) const
|
||||
{
|
||||
m_config->getConfig(address, port, password);
|
||||
}
|
||||
|
||||
void CRemoteControlApp::setConfig(const wxString& address, unsigned int port, const wxString& password) const
|
||||
{
|
||||
m_config->setConfig(address, port, password);
|
||||
}
|
||||
|
||||
void CRemoteControlApp::getPosition(int& x, int& y) const
|
||||
{
|
||||
m_config->getPosition(x, y);
|
||||
}
|
||||
|
||||
void CRemoteControlApp::setPosition(int x, int y)
|
||||
{
|
||||
m_config->setPosition(x, y);
|
||||
}
|
||||
|
||||
void CRemoteControlApp::repeaterRefresh(const wxString& callsign)
|
||||
{
|
||||
m_frame->repeaterRefresh(callsign);
|
||||
}
|
||||
|
||||
void CRemoteControlApp::starNetRefresh(const wxString& callsign)
|
||||
{
|
||||
m_frame->starNetRefresh(callsign);
|
||||
}
|
||||
|
||||
void CRemoteControlApp::link(const wxString& callsign, RECONNECT reconnect, const wxString& reflector)
|
||||
{
|
||||
m_frame->link(callsign, reconnect, reflector);
|
||||
}
|
||||
|
||||
void CRemoteControlApp::unlink(const wxString& callsign, PROTOCOL protocol, const wxString& reflector)
|
||||
{
|
||||
m_frame->unlink(callsign, protocol, reflector);
|
||||
}
|
||||
|
||||
void CRemoteControlApp::starNetLogoff(const wxString& callsign, const wxString& user)
|
||||
{
|
||||
m_frame->starNetLogoff(callsign, user);
|
||||
}
|
||||
59
RemoteControl/RemoteControlApp.h
Normal file
59
RemoteControl/RemoteControlApp.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (C) 2011,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 RemoteControlApp_H
|
||||
#define RemoteControlApp_H
|
||||
|
||||
#include "RemoteControlConfig.h"
|
||||
#include "RemoteControlFrame.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
class CRemoteControlApp : public wxApp {
|
||||
|
||||
public:
|
||||
CRemoteControlApp();
|
||||
virtual ~CRemoteControlApp();
|
||||
|
||||
virtual bool OnInit();
|
||||
virtual int OnExit();
|
||||
|
||||
virtual void OnInitCmdLine(wxCmdLineParser& parser);
|
||||
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
|
||||
|
||||
virtual void getConfig(wxString& address, unsigned int& port, wxString& password) const;
|
||||
virtual void setConfig(const wxString& address, unsigned int port, const wxString& password) const;
|
||||
|
||||
virtual void getPosition(int& x, int& y) const;
|
||||
virtual void setPosition(int x, int y);
|
||||
|
||||
virtual void repeaterRefresh(const wxString& callsign);
|
||||
virtual void starNetRefresh(const wxString& callsign);
|
||||
virtual void link(const wxString& callsign, RECONNECT reconnect, const wxString& reflector);
|
||||
virtual void unlink(const wxString& callsign, PROTOCOL protocol, const wxString& reflector);
|
||||
virtual void starNetLogoff(const wxString& callsign, const wxString& user);
|
||||
|
||||
private:
|
||||
wxString m_name;
|
||||
CRemoteControlFrame* m_frame;
|
||||
CRemoteControlConfig* m_config;
|
||||
};
|
||||
|
||||
DECLARE_APP(CRemoteControlApp)
|
||||
|
||||
#endif
|
||||
287
RemoteControl/RemoteControlAppD.cpp
Normal file
287
RemoteControl/RemoteControlAppD.cpp
Normal file
|
|
@ -0,0 +1,287 @@
|
|||
/*
|
||||
* Copyright (C) 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.
|
||||
*/
|
||||
|
||||
#include "RemoteControlRemoteControlHandler.h"
|
||||
#include "RemoteControlConfig.h"
|
||||
#include "RemoteControlDefs.h"
|
||||
#include "DStarDefines.h"
|
||||
#include "SHA256.h"
|
||||
#include "Defs.h"
|
||||
|
||||
#include <wx/cmdline.h>
|
||||
|
||||
const wxChar* NAME_OPTION = wxT("name");
|
||||
const wxChar* REPEATER_PARAM = wxT("Callsign");
|
||||
const wxChar* ACTION_PARAM = wxT("Action");
|
||||
const wxChar* RECONNECT_PARAM = wxT("Param1");
|
||||
const wxChar* REFLECTOR_PARAM = wxT("Param2");
|
||||
|
||||
void sendHash(CRemoteControlRemoteControlHandler* handler, const wxString& password, unsigned int rnd)
|
||||
{
|
||||
wxASSERT(handler != NULL);
|
||||
|
||||
unsigned int len = password.Len() + sizeof(unsigned int);
|
||||
unsigned char* in = new unsigned char[len];
|
||||
unsigned char* out = new unsigned char[32U];
|
||||
|
||||
::memcpy(in, &rnd, sizeof(unsigned int));
|
||||
for (unsigned int i = 0U; i < password.Len(); i++)
|
||||
in[i + sizeof(unsigned int)] = password.GetChar(i);
|
||||
|
||||
CSHA256 sha256;
|
||||
sha256.buffer(in, len, out);
|
||||
|
||||
handler->sendHash(out, 32U);
|
||||
|
||||
delete[] in;
|
||||
delete[] out;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
bool res = ::wxInitialize();
|
||||
if (!res) {
|
||||
::fprintf(stderr, "remotecontrold: failed to initialise the wxWidgets library, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
wxCmdLineParser parser(argc, argv);
|
||||
parser.AddOption(NAME_OPTION, wxEmptyString, wxEmptyString, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
||||
parser.AddParam(REPEATER_PARAM, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
||||
parser.AddParam(ACTION_PARAM, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
||||
parser.AddParam(RECONNECT_PARAM, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
||||
parser.AddParam(REFLECTOR_PARAM, wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL);
|
||||
|
||||
int cmd = parser.Parse();
|
||||
if (cmd != 0) {
|
||||
::wxUninitialize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
wxString name;
|
||||
parser.Found(NAME_OPTION, &name);
|
||||
|
||||
if (parser.GetParamCount() < 2U) {
|
||||
::fprintf(stderr, "remotecontrold: invalid command line usage: remotecontrold [-name <name>] <repeater> link <reconnect> <reflector>\n");
|
||||
::fprintf(stderr, " remotecontrold [-name <name>] <repeater> unlink\n");
|
||||
::fprintf(stderr, " remotecontrold [-name <name>] <starnet> drop <user>\n");
|
||||
::fprintf(stderr, " remotecontrold [-name <name>] <starnet> drop all\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
wxString repeater = parser.GetParam(0U);
|
||||
repeater.Replace(wxT("_"), wxT(" "));
|
||||
repeater.resize(LONG_CALLSIGN_LENGTH, wxT(' '));
|
||||
repeater.MakeUpper();
|
||||
|
||||
wxString actionText = parser.GetParam(1U);
|
||||
|
||||
wxString user; // For STARnet Digital
|
||||
wxString reflector; // For linking
|
||||
RECONNECT reconnect = RECONNECT_NEVER; // For linking
|
||||
|
||||
if (actionText.IsSameAs(wxT("link"), false)) {
|
||||
if (parser.GetParamCount() < 4U) {
|
||||
::fprintf(stderr, "remotecontrold: invalid command line usage: remotecontrold [-name <name>] <repeater> link <reconnect> <reflector>\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
wxString reconnectText = parser.GetParam(2U);
|
||||
|
||||
reflector = parser.GetParam(3U);
|
||||
reflector.Replace(wxT("_"), wxT(" "));
|
||||
reflector.resize(LONG_CALLSIGN_LENGTH, wxT(' '));
|
||||
reflector.MakeUpper();
|
||||
|
||||
if (reconnectText.IsSameAs(wxT("never"), false)) {
|
||||
reconnect = RECONNECT_NEVER;
|
||||
} else if (reconnectText.IsSameAs(wxT("fixed"), false)) {
|
||||
reconnect = RECONNECT_FIXED;
|
||||
} else if (reconnectText.IsSameAs(wxT("5"), false)) {
|
||||
reconnect = RECONNECT_5MINS;
|
||||
} else if (reconnectText.IsSameAs(wxT("10"), false)) {
|
||||
reconnect = RECONNECT_10MINS;
|
||||
} else if (reconnectText.IsSameAs(wxT("15"), false)) {
|
||||
reconnect = RECONNECT_15MINS;
|
||||
} else if (reconnectText.IsSameAs(wxT("20"), false)) {
|
||||
reconnect = RECONNECT_20MINS;
|
||||
} else if (reconnectText.IsSameAs(wxT("25"), false)) {
|
||||
reconnect = RECONNECT_25MINS;
|
||||
} else if (reconnectText.IsSameAs(wxT("30"), false)) {
|
||||
reconnect = RECONNECT_30MINS;
|
||||
} else if (reconnectText.IsSameAs(wxT("60"), false)) {
|
||||
reconnect = RECONNECT_60MINS;
|
||||
} else if (reconnectText.IsSameAs(wxT("90"), false)) {
|
||||
reconnect = RECONNECT_90MINS;
|
||||
} else if (reconnectText.IsSameAs(wxT("120"), false)) {
|
||||
reconnect = RECONNECT_120MINS;
|
||||
} else if (reconnectText.IsSameAs(wxT("180"), false)) {
|
||||
reconnect = RECONNECT_180MINS;
|
||||
} else {
|
||||
::fprintf(stderr, "remotecontrold: invalid reconnect value passed\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
} else if (actionText.IsSameAs(wxT("unlink"), false)) {
|
||||
reconnect = RECONNECT_NEVER;
|
||||
reflector.Clear();
|
||||
} else if (actionText.IsSameAs(wxT("drop"), false)) {
|
||||
if (parser.GetParamCount() < 3U) {
|
||||
::fprintf(stderr, "remotecontrold: invalid command line usage: remotecontrold [-name <name>] <starnet> drop <user>\n");
|
||||
::fprintf(stderr, " remotecontrold [-name <name>] <starnet> drop all\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
user = parser.GetParam(2U);
|
||||
user.Replace(wxT("_"), wxT(" "));
|
||||
user.resize(LONG_CALLSIGN_LENGTH, wxT(' '));
|
||||
user.MakeUpper();
|
||||
} else {
|
||||
::fprintf(stderr, "remotecontrold: invalid action value passed, only drop, link or unlink are allowed\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
CRemoteControlConfig config(new wxConfig(APPLICATION_NAME), name);
|
||||
|
||||
wxString address, password;
|
||||
unsigned int port;
|
||||
config.getConfig(address, port, password);
|
||||
|
||||
if (address.IsEmpty() || port == 0U || password.IsEmpty()) {
|
||||
::fprintf(stderr, "remotecontrold: no address, port, or password is set\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
CRemoteControlRemoteControlHandler handler(address, port);
|
||||
|
||||
bool ret = handler.open();
|
||||
if (!ret) {
|
||||
::fprintf(stderr, "remotecontrold: uanble to open the UDP port\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
ret = handler.login();
|
||||
if (!ret) {
|
||||
handler.close();
|
||||
::fprintf(stderr, "remotecontrold: uanble to login to the gateway/starnetserver\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int count = 0U;
|
||||
while (count < 10U) {
|
||||
::wxMilliSleep(100UL);
|
||||
|
||||
RC_TYPE type = handler.readType();
|
||||
if (type == RCT_RANDOM)
|
||||
break;
|
||||
|
||||
if (type == RCT_NONE)
|
||||
handler.retry();
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count >= 10U) {
|
||||
handler.close();
|
||||
::fprintf(stderr, "remotecontrold: unable to get a response from the gateway/starnetserver\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned int rnd = handler.readRandom();
|
||||
sendHash(&handler, password, rnd);
|
||||
|
||||
count = 0U;
|
||||
while (count < 10U) {
|
||||
::wxMilliSleep(100UL);
|
||||
|
||||
RC_TYPE type = handler.readType();
|
||||
if (type == RCT_ACK)
|
||||
break;
|
||||
|
||||
if (type == RCT_NAK) {
|
||||
handler.close();
|
||||
::fprintf(stderr, "remotecontrold: invalid password sent to the gateway/starnetserver\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (type == RCT_NONE)
|
||||
handler.retry();
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count >= 10U) {
|
||||
handler.close();
|
||||
::fprintf(stderr, "remotecontrold: unable to get a response from the gateway/starnetserver\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
handler.setLoggedIn(true);
|
||||
|
||||
if (actionText.IsSameAs(wxT("drop"), false))
|
||||
handler.logoff(repeater, user);
|
||||
else
|
||||
handler.link(repeater, reconnect, reflector);
|
||||
|
||||
count = 0U;
|
||||
while (count < 10U) {
|
||||
::wxMilliSleep(100UL);
|
||||
|
||||
RC_TYPE type = handler.readType();
|
||||
if (type == RCT_ACK)
|
||||
break;
|
||||
|
||||
if (type == RCT_NAK) {
|
||||
handler.close();
|
||||
::fprintf(stderr, "remotecontrold: drop/link/unlink command rejected by the gateway/starnetserver\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (type == RCT_NONE)
|
||||
handler.retry();
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count >= 10U) {
|
||||
handler.close();
|
||||
::fprintf(stderr, "remotecontrold: unable to get a response from the gateway/starnetserver\n");
|
||||
::wxUninitialize();
|
||||
return 1;
|
||||
}
|
||||
|
||||
::fprintf(stdout, "remotecontrold: command accepted by the gateway/starnetserver\n");
|
||||
|
||||
handler.logout();
|
||||
handler.close();
|
||||
|
||||
::wxUninitialize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
59
RemoteControl/RemoteControlCallsignData.cpp
Normal file
59
RemoteControl/RemoteControlCallsignData.cpp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 "RemoteControlCallsignData.h"
|
||||
|
||||
CRemoteControlCallsignData::CRemoteControlCallsignData() :
|
||||
m_repeaters(),
|
||||
m_starNets()
|
||||
{
|
||||
}
|
||||
|
||||
CRemoteControlCallsignData::~CRemoteControlCallsignData()
|
||||
{
|
||||
}
|
||||
|
||||
void CRemoteControlCallsignData::addRepeater(const wxString& callsign)
|
||||
{
|
||||
m_repeaters.Add(callsign);
|
||||
}
|
||||
|
||||
void CRemoteControlCallsignData::addStarNet(const wxString& callsign)
|
||||
{
|
||||
m_starNets.Add(callsign);
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlCallsignData::getRepeaterCount() const
|
||||
{
|
||||
return m_repeaters.GetCount();
|
||||
}
|
||||
|
||||
wxString CRemoteControlCallsignData::getRepeater(unsigned int n) const
|
||||
{
|
||||
return m_repeaters.Item(n);
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlCallsignData::getStarNetCount() const
|
||||
{
|
||||
return m_starNets.GetCount();
|
||||
}
|
||||
|
||||
wxString CRemoteControlCallsignData::getStarNet(unsigned int n) const
|
||||
{
|
||||
return m_starNets.Item(n);
|
||||
}
|
||||
43
RemoteControl/RemoteControlCallsignData.h
Normal file
43
RemoteControl/RemoteControlCallsignData.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 RemoteControlCallsignData_H
|
||||
#define RemoteControlCallsignData_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
class CRemoteControlCallsignData {
|
||||
public:
|
||||
CRemoteControlCallsignData();
|
||||
~CRemoteControlCallsignData();
|
||||
|
||||
void addRepeater(const wxString& callsign);
|
||||
void addStarNet(const wxString& callsign);
|
||||
|
||||
unsigned int getRepeaterCount() const;
|
||||
unsigned int getStarNetCount() const;
|
||||
|
||||
wxString getRepeater(unsigned int n) const;
|
||||
wxString getStarNet(unsigned int n) const;
|
||||
|
||||
private:
|
||||
wxArrayString m_repeaters;
|
||||
wxArrayString m_starNets;
|
||||
};
|
||||
|
||||
#endif
|
||||
98
RemoteControl/RemoteControlConfig.cpp
Normal file
98
RemoteControl/RemoteControlConfig.cpp
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* Copyright (C) 2011,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 "RemoteControlConfig.h"
|
||||
|
||||
const wxString KEY_ADDRESS = wxT("/address");
|
||||
const wxString KEY_PORT = wxT("/port");
|
||||
const wxString KEY_PASSWORD = wxT("/password");
|
||||
const wxString KEY_WINDOW_X = wxT("/windowX");
|
||||
const wxString KEY_WINDOW_Y = wxT("/windowY");
|
||||
|
||||
const wxString DEFAULT_ADDRESS = wxEmptyString;
|
||||
const long DEFAULT_PORT = 0L;
|
||||
const wxString DEFAULT_PASSWORD = wxEmptyString;
|
||||
const long DEFAULT_WINDOW_X = -1L;
|
||||
const long DEFAULT_WINDOW_Y = -1L;
|
||||
|
||||
|
||||
CRemoteControlConfig::CRemoteControlConfig(wxConfigBase* config, const wxString& name) :
|
||||
m_config(config),
|
||||
m_name()
|
||||
{
|
||||
wxASSERT(config != NULL);
|
||||
|
||||
if (!name.IsEmpty())
|
||||
m_name = wxT("/") + name;
|
||||
}
|
||||
|
||||
CRemoteControlConfig::~CRemoteControlConfig()
|
||||
{
|
||||
delete m_config;
|
||||
}
|
||||
|
||||
void CRemoteControlConfig::getConfig(wxString& address, unsigned int& port, wxString& password) const
|
||||
{
|
||||
wxString addressKey = m_name + KEY_ADDRESS;
|
||||
wxString portKey = m_name + KEY_PORT;
|
||||
wxString passwordKey = m_name + KEY_PASSWORD;
|
||||
|
||||
m_config->Read(addressKey, &address, DEFAULT_ADDRESS);
|
||||
|
||||
long temp;
|
||||
m_config->Read(portKey, &temp, DEFAULT_PORT);
|
||||
port = (unsigned int)temp;
|
||||
|
||||
m_config->Read(passwordKey, &password, DEFAULT_PASSWORD);
|
||||
}
|
||||
|
||||
void CRemoteControlConfig::setConfig(const wxString& address, unsigned int port, const wxString& password) const
|
||||
{
|
||||
wxString addressKey = m_name + KEY_ADDRESS;
|
||||
wxString portKey = m_name + KEY_PORT;
|
||||
wxString passwordKey = m_name + KEY_PASSWORD;
|
||||
|
||||
m_config->Write(addressKey, address);
|
||||
m_config->Write(portKey, long(port));
|
||||
m_config->Write(passwordKey, password);
|
||||
m_config->Flush();
|
||||
}
|
||||
|
||||
|
||||
void CRemoteControlConfig::getPosition(int& x, int& y) const
|
||||
{
|
||||
wxString xKey = m_name + KEY_WINDOW_X;
|
||||
wxString yKey = m_name + KEY_WINDOW_Y;
|
||||
|
||||
long temp;
|
||||
m_config->Read(xKey, &temp, DEFAULT_WINDOW_X);
|
||||
x = (unsigned int)temp;
|
||||
|
||||
m_config->Read(yKey, &temp, DEFAULT_WINDOW_Y);
|
||||
y = (unsigned int)temp;
|
||||
}
|
||||
|
||||
void CRemoteControlConfig::setPosition(int x, int y)
|
||||
{
|
||||
wxString xKey = m_name + KEY_WINDOW_X;
|
||||
wxString yKey = m_name + KEY_WINDOW_Y;
|
||||
|
||||
m_config->Write(xKey, long(x));
|
||||
m_config->Write(yKey, long(y));
|
||||
m_config->Flush();
|
||||
}
|
||||
42
RemoteControl/RemoteControlConfig.h
Normal file
42
RemoteControl/RemoteControlConfig.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (C) 2011,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 RemoteControlConfig_H
|
||||
#define RemoteControlConfig_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/config.h>
|
||||
|
||||
class CRemoteControlConfig {
|
||||
|
||||
public:
|
||||
CRemoteControlConfig(wxConfigBase* config, const wxString& name);
|
||||
~CRemoteControlConfig();
|
||||
|
||||
void getConfig(wxString& address, unsigned int& port, wxString& password) const;
|
||||
void setConfig(const wxString& address, unsigned int port, const wxString& password) const;
|
||||
|
||||
void getPosition(int& x, int& y) const;
|
||||
void setPosition(int x, int y);
|
||||
|
||||
private:
|
||||
wxConfigBase* m_config;
|
||||
wxString m_name;
|
||||
};
|
||||
|
||||
#endif
|
||||
28
RemoteControl/RemoteControlDefs.h
Normal file
28
RemoteControl/RemoteControlDefs.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 RemoteControlDefs_H
|
||||
#define RemoteControlDefs_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
const wxString APPLICATION_NAME = wxT("Remote Control");
|
||||
|
||||
const wxString CONFIG_FILE_NAME = wxT(".Remote Control");
|
||||
|
||||
#endif
|
||||
348
RemoteControl/RemoteControlFrame.cpp
Normal file
348
RemoteControl/RemoteControlFrame.cpp
Normal file
|
|
@ -0,0 +1,348 @@
|
|||
/*
|
||||
* Copyright (C) 2011-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 "RemoteControlPreferences.h"
|
||||
#include "RemoteControlFrame.h"
|
||||
#include "RemoteControlDefs.h"
|
||||
#include "RemoteControlApp.h"
|
||||
#include "Version.h"
|
||||
#include "SHA256.h"
|
||||
|
||||
const unsigned int BORDER_SIZE = 5U;
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
const unsigned int MAIN_HEIGHT = 350U;
|
||||
const unsigned int MAIN_WIDTH = 500U;
|
||||
#else
|
||||
const unsigned int MAIN_HEIGHT = 350U;
|
||||
const unsigned int MAIN_WIDTH = 520U;
|
||||
#endif
|
||||
|
||||
#include <wx/aboutdlg.h>
|
||||
|
||||
enum {
|
||||
Menu_Edit_Preferences = 7000
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(CRemoteControlFrame, wxFrame)
|
||||
EVT_MENU(wxID_EXIT, CRemoteControlFrame::onQuit)
|
||||
EVT_MENU(Menu_Edit_Preferences, CRemoteControlFrame::onPreferences)
|
||||
EVT_MENU(wxID_ABOUT, CRemoteControlFrame::onAbout)
|
||||
|
||||
EVT_TIMER(-1, CRemoteControlFrame::onTimer)
|
||||
|
||||
EVT_CLOSE(CRemoteControlFrame::onClose)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
CRemoteControlFrame::CRemoteControlFrame(const wxString& title, const wxPoint& position) :
|
||||
wxFrame(NULL, -1, title, position),
|
||||
m_state(RCFS_NORMAL),
|
||||
m_timer(this),
|
||||
m_noteBook(NULL),
|
||||
m_handler(NULL),
|
||||
m_password(),
|
||||
m_repeaters(),
|
||||
m_starNets(),
|
||||
m_it1(),
|
||||
m_it2()
|
||||
{
|
||||
SetMenuBar(createMenuBar());
|
||||
|
||||
wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxPanel* panel = new wxPanel(this, -1);
|
||||
|
||||
wxBoxSizer* panelSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_noteBook = new wxNotebook(panel, -1, wxDefaultPosition, wxSize(MAIN_WIDTH, MAIN_HEIGHT));
|
||||
panelSizer->Add(m_noteBook, 0, wxALL | wxGROW, BORDER_SIZE);
|
||||
|
||||
panel->SetSizer(panelSizer);
|
||||
|
||||
panelSizer->SetSizeHints(panel);
|
||||
|
||||
mainSizer->Add(panel);
|
||||
|
||||
SetSizer(mainSizer);
|
||||
mainSizer->SetSizeHints(this);
|
||||
|
||||
wxString address;
|
||||
unsigned int port;
|
||||
::wxGetApp().getConfig(address, port, m_password);
|
||||
|
||||
if (address.IsEmpty() || port == 0U || m_password.IsEmpty())
|
||||
return;
|
||||
|
||||
m_handler = new CRemoteControlRemoteControlHandler(address, port);
|
||||
|
||||
bool ret = m_handler->open();
|
||||
if (!ret) {
|
||||
delete m_handler;
|
||||
m_handler = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
ret = m_handler->login();
|
||||
if (!ret) {
|
||||
m_handler->close();
|
||||
delete m_handler;
|
||||
m_handler = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
m_state = RCFS_LOGIN;
|
||||
|
||||
m_timer.Start(100);
|
||||
}
|
||||
|
||||
CRemoteControlFrame::~CRemoteControlFrame()
|
||||
{
|
||||
}
|
||||
|
||||
wxMenuBar* CRemoteControlFrame::createMenuBar()
|
||||
{
|
||||
wxMenu* fileMenu = new wxMenu();
|
||||
fileMenu->Append(wxID_EXIT, _("Exit"));
|
||||
|
||||
wxMenu* editMenu = new wxMenu();
|
||||
editMenu->Append(Menu_Edit_Preferences, _("Preferences..."));
|
||||
|
||||
wxMenu* helpMenu = new wxMenu();
|
||||
helpMenu->Append(wxID_ABOUT, _("About Remote Control"));
|
||||
|
||||
wxMenuBar* menuBar = new wxMenuBar();
|
||||
menuBar->Append(fileMenu, _("File"));
|
||||
menuBar->Append(editMenu, _("Edit"));
|
||||
menuBar->Append(helpMenu, _("Help"));
|
||||
|
||||
return menuBar;
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::onQuit(wxCommandEvent&)
|
||||
{
|
||||
Close(false);
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::onClose(wxCloseEvent&)
|
||||
{
|
||||
int x, y;
|
||||
GetPosition(&x, &y);
|
||||
if (x >= 0 && y >= 0)
|
||||
::wxGetApp().setPosition(x, y);
|
||||
|
||||
m_timer.Stop();
|
||||
|
||||
if (m_handler != NULL) {
|
||||
m_handler->logout();
|
||||
m_handler->close();
|
||||
}
|
||||
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::onPreferences(wxCommandEvent&)
|
||||
{
|
||||
wxString address, password;
|
||||
unsigned int port;
|
||||
::wxGetApp().getConfig(address, port, password);
|
||||
|
||||
CRemoteControlPreferences dialog1(this, -1, address, port, password);
|
||||
if (dialog1.ShowModal() != wxID_OK)
|
||||
return;
|
||||
|
||||
address = dialog1.getAddress();
|
||||
port = dialog1.getPort();
|
||||
password = dialog1.getPassword();
|
||||
|
||||
::wxGetApp().setConfig(address, port, password);
|
||||
|
||||
wxMessageDialog dialog2(this, _("The changes made will not take effect\nuntil the application is restarted"), _("Remote Control Information"), wxICON_INFORMATION);
|
||||
dialog2.ShowModal();
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::onAbout(wxCommandEvent&)
|
||||
{
|
||||
wxAboutDialogInfo info;
|
||||
info.AddDeveloper(wxT("Jonathan Naylor, G4KLX"));
|
||||
info.SetCopyright(wxT("(C) 2011-2015 using GPL v2 or later"));
|
||||
info.SetName(APPLICATION_NAME);
|
||||
info.SetVersion(VERSION);
|
||||
info.SetDescription(_("This program allows for the controlling of\nircDDB Gateway and STARnet Digital Server."));
|
||||
|
||||
::wxAboutBox(info);
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::onTimer(wxTimerEvent&)
|
||||
{
|
||||
RC_TYPE type = m_handler->readType();
|
||||
|
||||
switch (type) {
|
||||
case RCT_NONE:
|
||||
m_handler->retry();
|
||||
break;
|
||||
|
||||
case RCT_ACK:
|
||||
if (m_state == RCFS_HASH) {
|
||||
m_handler->setLoggedIn(true);
|
||||
m_handler->getCallsigns();
|
||||
m_state = RCFS_NORMAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case RCT_NAK: {
|
||||
if (m_state == RCFS_HASH || m_state == RCFS_LOGIN)
|
||||
m_handler->setLoggedIn(false);
|
||||
|
||||
wxString text = m_handler->readNAK();
|
||||
m_state = RCFS_NORMAL;
|
||||
::wxMessageBox(text);
|
||||
}
|
||||
break;
|
||||
|
||||
case RCT_RANDOM: {
|
||||
unsigned int rnd = m_handler->readRandom();
|
||||
sendHash(rnd);
|
||||
m_state = RCFS_HASH;
|
||||
}
|
||||
break;
|
||||
|
||||
case RCT_CALLSIGNS: {
|
||||
m_noteBook->DeleteAllPages();
|
||||
|
||||
CRemoteControlCallsignData* data = m_handler->readCallsigns();
|
||||
for (unsigned int i = 0U; i < data->getRepeaterCount(); i++)
|
||||
addRepeater(data->getRepeater(i));
|
||||
for (unsigned int i = 0U; i < data->getStarNetCount(); i++)
|
||||
addStarNet(data->getStarNet(i));
|
||||
delete data;
|
||||
|
||||
m_state = RCFS_GET_REPEATERS;
|
||||
m_it1 = m_repeaters.begin();
|
||||
m_it2 = m_starNets.begin();
|
||||
getNextRepeater();
|
||||
}
|
||||
break;
|
||||
|
||||
case RCT_REPEATER: {
|
||||
CRemoteControlRepeaterData* data = m_handler->readRepeater();
|
||||
wxString callsign = data->getCallsign();
|
||||
m_repeaters[callsign]->add(*data);
|
||||
delete data;
|
||||
|
||||
if (m_state == RCFS_GET_REPEATERS || m_state == RCFS_GET_STARNETS)
|
||||
getNextRepeater();
|
||||
}
|
||||
break;
|
||||
|
||||
case RCT_STARNET: {
|
||||
CRemoteControlStarNetGroup* data = m_handler->readStarNetGroup();
|
||||
wxString callsign = data->getCallsign();
|
||||
m_starNets[callsign]->add(*data);
|
||||
delete data;
|
||||
|
||||
if (m_state == RCFS_GET_REPEATERS || m_state == RCFS_GET_STARNETS)
|
||||
getNextStarNet();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::addRepeater(const wxString& callsign)
|
||||
{
|
||||
CRemoteControlRepeaterPanel* repeater = new CRemoteControlRepeaterPanel(m_noteBook, -1, callsign);
|
||||
|
||||
m_noteBook->AddPage(repeater, callsign, false);
|
||||
|
||||
m_repeaters[callsign] = repeater;
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::addStarNet(const wxString& callsign)
|
||||
{
|
||||
CRemoteControlStarNetPanel* starNet = new CRemoteControlStarNetPanel(m_noteBook, -1, callsign);
|
||||
|
||||
m_noteBook->AddPage(starNet, callsign, false);
|
||||
|
||||
m_starNets[callsign] = starNet;
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::repeaterRefresh(const wxString& callsign)
|
||||
{
|
||||
m_handler->getRepeater(callsign);
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::starNetRefresh(const wxString& callsign)
|
||||
{
|
||||
m_handler->getStarNet(callsign);
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::link(const wxString& callsign, RECONNECT reconnect, const wxString& reflector)
|
||||
{
|
||||
m_handler->link(callsign, reconnect, reflector);
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::unlink(const wxString& callsign, PROTOCOL protocol, const wxString& reflector)
|
||||
{
|
||||
m_handler->unlink(callsign, protocol, reflector);
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::starNetLogoff(const wxString& callsign, const wxString& user)
|
||||
{
|
||||
m_handler->logoff(callsign, user);
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::sendHash(unsigned int rnd)
|
||||
{
|
||||
unsigned int len = m_password.Len() + sizeof(unsigned int);
|
||||
unsigned char* in = new unsigned char[len];
|
||||
unsigned char* out = new unsigned char[32U];
|
||||
|
||||
::memcpy(in, &rnd, sizeof(unsigned int));
|
||||
for (unsigned int i = 0U; i < m_password.Len(); i++)
|
||||
in[i + sizeof(unsigned int)] = m_password.GetChar(i);
|
||||
|
||||
CSHA256 sha256;
|
||||
sha256.buffer(in, len, out);
|
||||
|
||||
m_handler->sendHash(out, 32U);
|
||||
|
||||
delete[] in;
|
||||
delete[] out;
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::getNextRepeater()
|
||||
{
|
||||
if (m_it1 == m_repeaters.end()) {
|
||||
m_state = RCFS_GET_STARNETS;
|
||||
getNextStarNet();
|
||||
return;
|
||||
}
|
||||
|
||||
m_handler->getRepeater(m_it1->first);
|
||||
++m_it1;
|
||||
}
|
||||
|
||||
void CRemoteControlFrame::getNextStarNet()
|
||||
{
|
||||
if (m_it2 == m_starNets.end()) {
|
||||
m_state = RCFS_NORMAL;
|
||||
return;
|
||||
}
|
||||
|
||||
m_handler->getStarNet(m_it2->first);
|
||||
++m_it2;
|
||||
}
|
||||
79
RemoteControl/RemoteControlFrame.h
Normal file
79
RemoteControl/RemoteControlFrame.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Copyright (C) 2011,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 RemoteControlFrame_H
|
||||
#define RemoteControlFrame_H
|
||||
|
||||
#include "RemoteControlRemoteControlHandler.h"
|
||||
#include "RemoteControlRepeaterPanel.h"
|
||||
#include "RemoteControlStarNetPanel.h"
|
||||
#include "Defs.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/notebook.h>
|
||||
|
||||
WX_DECLARE_STRING_HASH_MAP(CRemoteControlRepeaterPanel*, CRepeater_t);
|
||||
WX_DECLARE_STRING_HASH_MAP(CRemoteControlStarNetPanel*, CStarNet_t);
|
||||
|
||||
enum RCF_STATE {
|
||||
RCFS_NORMAL,
|
||||
RCFS_LOGIN,
|
||||
RCFS_HASH,
|
||||
RCFS_GET_REPEATERS,
|
||||
RCFS_GET_STARNETS
|
||||
};
|
||||
|
||||
class CRemoteControlFrame : public wxFrame {
|
||||
public:
|
||||
CRemoteControlFrame(const wxString& title, const wxPoint& position);
|
||||
virtual ~CRemoteControlFrame();
|
||||
|
||||
virtual void onQuit(wxCommandEvent& event);
|
||||
virtual void onPreferences(wxCommandEvent& event);
|
||||
virtual void onAbout(wxCommandEvent& event);
|
||||
virtual void onClose(wxCloseEvent& event);
|
||||
virtual void onTimer(wxTimerEvent& event);
|
||||
|
||||
virtual void repeaterRefresh(const wxString& callsign);
|
||||
virtual void starNetRefresh(const wxString& callsign);
|
||||
virtual void link(const wxString& callsign, RECONNECT reconnect, const wxString& reflector);
|
||||
virtual void unlink(const wxString& callsign, PROTOCOL protocol, const wxString& reflector);
|
||||
virtual void starNetLogoff(const wxString& callsign, const wxString& user);
|
||||
|
||||
private:
|
||||
RCF_STATE m_state;
|
||||
wxTimer m_timer;
|
||||
wxNotebook* m_noteBook;
|
||||
CRemoteControlRemoteControlHandler* m_handler;
|
||||
wxString m_password;
|
||||
CRepeater_t m_repeaters;
|
||||
CStarNet_t m_starNets;
|
||||
CRepeater_t::iterator m_it1;
|
||||
CStarNet_t::iterator m_it2;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
wxMenuBar* createMenuBar();
|
||||
void addRepeater(const wxString& callsign);
|
||||
void addStarNet(const wxString& callsign);
|
||||
void sendHash(unsigned int rnd);
|
||||
void getNextRepeater();
|
||||
void getNextStarNet();
|
||||
};
|
||||
|
||||
#endif
|
||||
59
RemoteControl/RemoteControlLinkData.cpp
Normal file
59
RemoteControl/RemoteControlLinkData.cpp
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 "RemoteControlLinkData.h"
|
||||
|
||||
CRemoteControlLinkData::CRemoteControlLinkData(const wxString& callsign, wxInt32 protocol, wxInt32 linked, wxInt32 direction, wxInt32 dongle) :
|
||||
m_callsign(callsign),
|
||||
m_protocol(PROTOCOL(protocol)),
|
||||
m_linked(false),
|
||||
m_direction(DIRECTION(direction)),
|
||||
m_dongle(false)
|
||||
{
|
||||
m_linked = linked == 1;
|
||||
m_dongle = dongle == 1;
|
||||
}
|
||||
|
||||
CRemoteControlLinkData::~CRemoteControlLinkData()
|
||||
{
|
||||
}
|
||||
|
||||
wxString CRemoteControlLinkData::getCallsign() const
|
||||
{
|
||||
return m_callsign;
|
||||
}
|
||||
|
||||
PROTOCOL CRemoteControlLinkData::getProtocol() const
|
||||
{
|
||||
return m_protocol;
|
||||
}
|
||||
|
||||
bool CRemoteControlLinkData::isLinked() const
|
||||
{
|
||||
return m_linked;
|
||||
}
|
||||
|
||||
DIRECTION CRemoteControlLinkData::getDirection() const
|
||||
{
|
||||
return m_direction;
|
||||
}
|
||||
|
||||
bool CRemoteControlLinkData::isDongle() const
|
||||
{
|
||||
return m_dongle;
|
||||
}
|
||||
45
RemoteControl/RemoteControlLinkData.h
Normal file
45
RemoteControl/RemoteControlLinkData.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 RemoteControlLinkData_H
|
||||
#define RemoteControlLinkData_H
|
||||
|
||||
#include "Defs.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
class CRemoteControlLinkData {
|
||||
public:
|
||||
CRemoteControlLinkData(const wxString& callsign, wxInt32 protocol, wxInt32 linked, wxInt32 direction, wxInt32 dongle);
|
||||
~CRemoteControlLinkData();
|
||||
|
||||
wxString getCallsign() const;
|
||||
PROTOCOL getProtocol() const;
|
||||
bool isLinked() const;
|
||||
DIRECTION getDirection() const;
|
||||
bool isDongle() const;
|
||||
|
||||
private:
|
||||
wxString m_callsign;
|
||||
PROTOCOL m_protocol;
|
||||
bool m_linked;
|
||||
DIRECTION m_direction;
|
||||
bool m_dongle;
|
||||
};
|
||||
|
||||
#endif
|
||||
70
RemoteControl/RemoteControlPreferences.cpp
Normal file
70
RemoteControl/RemoteControlPreferences.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 "RemoteControlPreferences.h"
|
||||
#include "RemoteControlDefs.h"
|
||||
|
||||
const unsigned int BORDER_SIZE = 5U;
|
||||
|
||||
CRemoteControlPreferences::CRemoteControlPreferences(wxWindow* parent, int id, const wxString& address, unsigned int port, const wxString& password) :
|
||||
wxDialog(parent, id, wxString(_("Remote Control Preferences"))),
|
||||
m_remote(NULL)
|
||||
{
|
||||
wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxNotebook* noteBook = new wxNotebook(this, -1);
|
||||
|
||||
m_remote = new CRemoteControlRemoteSet(noteBook, -1, APPLICATION_NAME, address, port, password);
|
||||
noteBook->AddPage(m_remote, _("Gateway"), true);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
CRemoteControlPreferences::~CRemoteControlPreferences()
|
||||
{
|
||||
}
|
||||
|
||||
bool CRemoteControlPreferences::Validate()
|
||||
{
|
||||
return m_remote->Validate();
|
||||
}
|
||||
|
||||
wxString CRemoteControlPreferences::getAddress() const
|
||||
{
|
||||
return m_remote->getAddress();
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlPreferences::getPort() const
|
||||
{
|
||||
return m_remote->getPort();
|
||||
}
|
||||
|
||||
wxString CRemoteControlPreferences::getPassword() const
|
||||
{
|
||||
return m_remote->getPassword();
|
||||
}
|
||||
42
RemoteControl/RemoteControlPreferences.h
Normal file
42
RemoteControl/RemoteControlPreferences.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 RemoteControlPreferences_H
|
||||
#define RemoteControlPreferences_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/notebook.h>
|
||||
|
||||
#include "RemoteControlRemoteSet.h"
|
||||
|
||||
class CRemoteControlPreferences : public wxDialog {
|
||||
public:
|
||||
CRemoteControlPreferences(wxWindow* parent, int id, const wxString& address, unsigned int port, const wxString& password);
|
||||
virtual ~CRemoteControlPreferences();
|
||||
|
||||
virtual bool Validate();
|
||||
|
||||
virtual wxString getAddress() const;
|
||||
virtual unsigned int getPort() const;
|
||||
virtual wxString getPassword() const;
|
||||
|
||||
private:
|
||||
CRemoteControlRemoteSet* m_remote;
|
||||
};
|
||||
|
||||
#endif
|
||||
557
RemoteControl/RemoteControlRemoteControlHandler.cpp
Normal file
557
RemoteControl/RemoteControlRemoteControlHandler.cpp
Normal file
|
|
@ -0,0 +1,557 @@
|
|||
/*
|
||||
* Copyright (C) 2011,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 "RemoteControlRemoteControlHandler.h"
|
||||
#include "DStarDefines.h"
|
||||
|
||||
const unsigned int BUFFER_LENGTH = 2000U;
|
||||
|
||||
const unsigned int MAX_RETRIES = 3U;
|
||||
|
||||
CRemoteControlRemoteControlHandler::CRemoteControlRemoteControlHandler(const wxString& address, unsigned int port) :
|
||||
m_socket(wxEmptyString, 0U),
|
||||
m_address(),
|
||||
m_port(port),
|
||||
m_loggedIn(false),
|
||||
m_retryCount(0U),
|
||||
m_type(RCT_NONE),
|
||||
m_inBuffer(NULL),
|
||||
m_inLength(0U),
|
||||
m_outBuffer(NULL),
|
||||
m_outLength(0U)
|
||||
{
|
||||
wxASSERT(!address.IsEmpty());
|
||||
wxASSERT(port > 0U);
|
||||
|
||||
m_address = CUDPReaderWriter::lookup(address);
|
||||
|
||||
m_inBuffer = new unsigned char[BUFFER_LENGTH];
|
||||
m_outBuffer = new unsigned char[BUFFER_LENGTH];
|
||||
}
|
||||
|
||||
CRemoteControlRemoteControlHandler::~CRemoteControlRemoteControlHandler()
|
||||
{
|
||||
delete[] m_inBuffer;
|
||||
delete[] m_outBuffer;
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::open()
|
||||
{
|
||||
return m_socket.open();
|
||||
}
|
||||
|
||||
RC_TYPE CRemoteControlRemoteControlHandler::readType()
|
||||
{
|
||||
m_type = RCT_NONE;
|
||||
|
||||
in_addr address;
|
||||
unsigned int port;
|
||||
|
||||
int length = m_socket.read(m_inBuffer, BUFFER_LENGTH, address, port);
|
||||
if (length <= 0)
|
||||
return m_type;
|
||||
|
||||
m_inLength = length;
|
||||
|
||||
if (::memcmp(m_inBuffer, "ACK", 3U) == 0) {
|
||||
m_retryCount = 0U;
|
||||
m_type = RCT_ACK;
|
||||
return m_type;
|
||||
} else if (::memcmp(m_inBuffer, "NAK", 3U) == 0) {
|
||||
m_retryCount = 0U;
|
||||
m_type = RCT_NAK;
|
||||
return m_type;
|
||||
} else if (::memcmp(m_inBuffer, "RND", 3U) == 0) {
|
||||
m_retryCount = 0U;
|
||||
m_type = RCT_RANDOM;
|
||||
return m_type;
|
||||
} else if (::memcmp(m_inBuffer, "CAL", 3U) == 0) {
|
||||
m_retryCount = 0U;
|
||||
m_type = RCT_CALLSIGNS;
|
||||
return m_type;
|
||||
} else if (::memcmp(m_inBuffer, "RPT", 3U) == 0) {
|
||||
m_retryCount = 0U;
|
||||
m_type = RCT_REPEATER;
|
||||
return m_type;
|
||||
} else if (::memcmp(m_inBuffer, "SNT", 3U) == 0) {
|
||||
m_retryCount = 0U;
|
||||
m_type = RCT_STARNET;
|
||||
return m_type;
|
||||
}
|
||||
|
||||
return m_type;
|
||||
}
|
||||
|
||||
wxString CRemoteControlRemoteControlHandler::readNAK()
|
||||
{
|
||||
if (m_type != RCT_NAK)
|
||||
return wxEmptyString;
|
||||
|
||||
wxString text((char*)(m_inBuffer + 3U), wxConvLocal);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlRemoteControlHandler::readRandom()
|
||||
{
|
||||
if (m_type != RCT_RANDOM)
|
||||
return 0U;
|
||||
|
||||
wxUint32 random;
|
||||
::memcpy(&random, m_inBuffer + 3U, sizeof(wxUint32));
|
||||
|
||||
return wxUINT32_SWAP_ON_BE(random);
|
||||
}
|
||||
|
||||
CRemoteControlCallsignData* CRemoteControlRemoteControlHandler::readCallsigns()
|
||||
{
|
||||
if (m_type != RCT_CALLSIGNS)
|
||||
return NULL;
|
||||
|
||||
CRemoteControlCallsignData* data = new CRemoteControlCallsignData;
|
||||
|
||||
unsigned char* p = m_inBuffer + 3U;
|
||||
unsigned int pos = 3U;
|
||||
|
||||
while (pos < m_inLength) {
|
||||
unsigned char type = *p;
|
||||
pos += 1U;
|
||||
p += 1U;
|
||||
|
||||
wxString callsign((char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
|
||||
pos += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
switch (type) {
|
||||
case 'R':
|
||||
data->addRepeater(callsign);
|
||||
break;
|
||||
case 'S':
|
||||
data->addStarNet(callsign);
|
||||
break;
|
||||
default: // ????
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
CRemoteControlRepeaterData* CRemoteControlRemoteControlHandler::readRepeater()
|
||||
{
|
||||
if (m_type != RCT_REPEATER)
|
||||
return NULL;
|
||||
|
||||
unsigned char* p = m_inBuffer + 3U;
|
||||
unsigned int pos = 3U;
|
||||
|
||||
wxString callsign((char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
|
||||
pos += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
wxInt32 reconnect;
|
||||
::memcpy(&reconnect, p, sizeof(wxInt32));
|
||||
pos += sizeof(wxInt32);
|
||||
p += sizeof(wxInt32);
|
||||
|
||||
wxString reflector((char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
|
||||
pos += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
CRemoteControlRepeaterData* data = new CRemoteControlRepeaterData(callsign, wxINT32_SWAP_ON_BE(reconnect), reflector);
|
||||
|
||||
while (pos < m_inLength) {
|
||||
wxString callsign((char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
|
||||
pos += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
wxInt32 protocol;
|
||||
::memcpy(&protocol, p, sizeof(wxInt32));
|
||||
pos += sizeof(wxInt32);
|
||||
p += sizeof(wxInt32);
|
||||
|
||||
wxInt32 linked;
|
||||
::memcpy(&linked, p, sizeof(wxInt32));
|
||||
pos += sizeof(wxInt32);
|
||||
p += sizeof(wxInt32);
|
||||
|
||||
wxInt32 direction;
|
||||
::memcpy(&direction, p, sizeof(wxInt32));
|
||||
pos += sizeof(wxInt32);
|
||||
p += sizeof(wxInt32);
|
||||
|
||||
wxInt32 dongle;
|
||||
::memcpy(&dongle, p, sizeof(wxInt32));
|
||||
pos += sizeof(wxInt32);
|
||||
p += sizeof(wxInt32);
|
||||
|
||||
data->addLink(callsign, wxINT32_SWAP_ON_BE(protocol), wxINT32_SWAP_ON_BE(linked), wxINT32_SWAP_ON_BE(direction), wxINT32_SWAP_ON_BE(dongle));
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
CRemoteControlStarNetGroup* CRemoteControlRemoteControlHandler::readStarNetGroup()
|
||||
{
|
||||
if (m_type != RCT_STARNET)
|
||||
return NULL;
|
||||
|
||||
unsigned char* p = m_inBuffer + 3U;
|
||||
unsigned int pos = 3U;
|
||||
|
||||
wxString callsign((char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
|
||||
pos += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
wxString logoff((char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
|
||||
pos += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
wxUint32 timer;
|
||||
::memcpy(&timer, p, sizeof(wxUint32));
|
||||
pos += sizeof(wxUint32);
|
||||
p += sizeof(wxUint32);
|
||||
|
||||
wxUint32 timeout;
|
||||
::memcpy(&timeout, p, sizeof(wxUint32));
|
||||
pos += sizeof(wxUint32);
|
||||
p += sizeof(wxUint32);
|
||||
|
||||
CRemoteControlStarNetGroup* group = new CRemoteControlStarNetGroup(callsign, logoff, wxUINT32_SWAP_ON_BE(timer), wxUINT32_SWAP_ON_BE(timeout));
|
||||
|
||||
while (pos < m_inLength) {
|
||||
wxString callsign((char*)p, wxConvLocal, LONG_CALLSIGN_LENGTH);
|
||||
pos += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
::memcpy(&timer, p, sizeof(wxUint32));
|
||||
pos += sizeof(wxUint32);
|
||||
p += sizeof(wxUint32);
|
||||
|
||||
::memcpy(&timeout, p, sizeof(wxUint32));
|
||||
pos += sizeof(wxUint32);
|
||||
p += sizeof(wxUint32);
|
||||
|
||||
group->addUser(callsign, wxUINT32_SWAP_ON_BE(timer), wxUINT32_SWAP_ON_BE(timeout));
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::login()
|
||||
{
|
||||
if (m_loggedIn)
|
||||
return false;
|
||||
|
||||
if (m_address.s_addr == INADDR_NONE)
|
||||
return false;
|
||||
|
||||
::memcpy(m_outBuffer, "LIN", 3U);
|
||||
m_outLength = 3U;
|
||||
|
||||
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
|
||||
if (!ret) {
|
||||
m_retryCount = 0U;
|
||||
return false;
|
||||
} else {
|
||||
m_retryCount = 1U;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void CRemoteControlRemoteControlHandler::setLoggedIn(bool set)
|
||||
{
|
||||
m_loggedIn = set;
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::getCallsigns()
|
||||
{
|
||||
if (!m_loggedIn || m_retryCount > 0U)
|
||||
return false;
|
||||
|
||||
::memcpy(m_outBuffer, "GCS", 3U);
|
||||
m_outLength = 3U;
|
||||
|
||||
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
|
||||
if (!ret) {
|
||||
m_retryCount = 0U;
|
||||
return false;
|
||||
} else {
|
||||
m_retryCount = 1U;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::sendHash(const unsigned char* hash, unsigned int length)
|
||||
{
|
||||
wxASSERT(hash != NULL);
|
||||
wxASSERT(length > 0U);
|
||||
|
||||
if (m_loggedIn || m_retryCount > 0U)
|
||||
return false;
|
||||
|
||||
unsigned char* p = m_outBuffer;
|
||||
m_outLength = 0U;
|
||||
|
||||
::memcpy(p, "SHA", 3U);
|
||||
m_outLength += 3U;
|
||||
p += 3U;
|
||||
|
||||
::memcpy(p, hash, length);
|
||||
m_outLength += length;
|
||||
p += length;
|
||||
|
||||
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
|
||||
if (!ret) {
|
||||
m_retryCount = 0U;
|
||||
return false;
|
||||
} else {
|
||||
m_retryCount = 1U;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::getRepeater(const wxString& callsign)
|
||||
{
|
||||
wxASSERT(!callsign.IsEmpty());
|
||||
|
||||
if (!m_loggedIn || m_retryCount > 0U)
|
||||
return false;
|
||||
|
||||
unsigned char* p = m_outBuffer;
|
||||
m_outLength = 0U;
|
||||
|
||||
::memcpy(p, "GRP", 3U);
|
||||
m_outLength += 3U;
|
||||
p += 3U;
|
||||
|
||||
::memset(p, ' ', LONG_CALLSIGN_LENGTH);
|
||||
for (unsigned int i = 0U; i < callsign.Len(); i++)
|
||||
p[i] = callsign.GetChar(i);
|
||||
|
||||
m_outLength += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
|
||||
if (!ret) {
|
||||
m_retryCount = 0U;
|
||||
return false;
|
||||
} else {
|
||||
m_retryCount = 1U;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::getStarNet(const wxString& callsign)
|
||||
{
|
||||
wxASSERT(!callsign.IsEmpty());
|
||||
|
||||
if (!m_loggedIn || m_retryCount > 0U)
|
||||
return false;
|
||||
|
||||
unsigned char* p = m_outBuffer;
|
||||
m_outLength = 0U;
|
||||
|
||||
::memcpy(p, "GSN", 3U);
|
||||
m_outLength += 3U;
|
||||
p += 3U;
|
||||
|
||||
::memset(p, ' ', LONG_CALLSIGN_LENGTH);
|
||||
for (unsigned int i = 0U; i < callsign.Len(); i++)
|
||||
p[i] = callsign.GetChar(i);
|
||||
|
||||
m_outLength += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
|
||||
if (!ret) {
|
||||
m_retryCount = 0U;
|
||||
return false;
|
||||
} else {
|
||||
m_retryCount = 1U;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::link(const wxString& callsign, RECONNECT reconnect, const wxString& reflector)
|
||||
{
|
||||
wxASSERT(!callsign.IsEmpty());
|
||||
|
||||
if (!m_loggedIn || m_retryCount > 0U)
|
||||
return false;
|
||||
|
||||
unsigned char* p = m_outBuffer;
|
||||
m_outLength = 0U;
|
||||
|
||||
::memcpy(p, "LNK", 3U);
|
||||
m_outLength += 3U;
|
||||
p += 3U;
|
||||
|
||||
::memset(p, ' ', LONG_CALLSIGN_LENGTH);
|
||||
for (unsigned int i = 0U; i < callsign.Len(); i++)
|
||||
p[i] = callsign.GetChar(i);
|
||||
|
||||
m_outLength += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
wxInt32 temp1 = wxInt32(reconnect);
|
||||
wxInt32 temp2 = wxINT32_SWAP_ON_BE(temp1);
|
||||
::memcpy(p, &temp2, sizeof(wxInt32));
|
||||
m_outLength += sizeof(wxInt32);
|
||||
p += sizeof(wxInt32);
|
||||
|
||||
::memset(p, ' ', LONG_CALLSIGN_LENGTH);
|
||||
for (unsigned int i = 0U; i < reflector.Len(); i++)
|
||||
p[i] = reflector.GetChar(i);
|
||||
|
||||
m_outLength += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
|
||||
if (!ret) {
|
||||
m_retryCount = 0U;
|
||||
return false;
|
||||
} else {
|
||||
m_retryCount = 1U;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::unlink(const wxString& callsign, PROTOCOL protocol, const wxString& reflector)
|
||||
{
|
||||
wxASSERT(!callsign.IsEmpty());
|
||||
|
||||
if (!m_loggedIn || m_retryCount > 0U)
|
||||
return false;
|
||||
|
||||
unsigned char* p = m_outBuffer;
|
||||
m_outLength = 0U;
|
||||
|
||||
::memcpy(p, "UNL", 3U);
|
||||
m_outLength += 3U;
|
||||
p += 3U;
|
||||
|
||||
::memset(p, ' ', LONG_CALLSIGN_LENGTH);
|
||||
for (unsigned int i = 0U; i < callsign.Len(); i++)
|
||||
p[i] = callsign.GetChar(i);
|
||||
|
||||
m_outLength += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
wxInt32 temp1 = wxInt32(protocol);
|
||||
wxInt32 temp2 = wxINT32_SWAP_ON_BE(temp1);
|
||||
::memcpy(p, &temp2, sizeof(wxInt32));
|
||||
m_outLength += sizeof(wxInt32);
|
||||
p += sizeof(wxInt32);
|
||||
|
||||
::memset(p, ' ', LONG_CALLSIGN_LENGTH);
|
||||
for (unsigned int i = 0U; i < reflector.Len(); i++)
|
||||
p[i] = reflector.GetChar(i);
|
||||
|
||||
m_outLength += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
|
||||
if (!ret) {
|
||||
m_retryCount = 0U;
|
||||
return false;
|
||||
} else {
|
||||
m_retryCount = 1U;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::logoff(const wxString& callsign, const wxString& user)
|
||||
{
|
||||
wxASSERT(!callsign.IsEmpty());
|
||||
wxASSERT(!user.IsEmpty());
|
||||
|
||||
if (!m_loggedIn || m_retryCount > 0U)
|
||||
return false;
|
||||
|
||||
unsigned char* p = m_outBuffer;
|
||||
m_outLength = 0U;
|
||||
|
||||
::memcpy(p, "LGO", 3U);
|
||||
m_outLength += 3U;
|
||||
p += 3U;
|
||||
|
||||
::memset(p, ' ', LONG_CALLSIGN_LENGTH);
|
||||
for (unsigned int i = 0U; i < callsign.Len(); i++)
|
||||
p[i] = callsign.GetChar(i);
|
||||
|
||||
m_outLength += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
::memset(p, ' ', LONG_CALLSIGN_LENGTH);
|
||||
for (unsigned int i = 0U; i < user.Len(); i++)
|
||||
p[i] = user.GetChar(i);
|
||||
|
||||
m_outLength += LONG_CALLSIGN_LENGTH;
|
||||
p += LONG_CALLSIGN_LENGTH;
|
||||
|
||||
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
|
||||
if (!ret) {
|
||||
m_retryCount = 0U;
|
||||
return false;
|
||||
} else {
|
||||
m_retryCount = 1U;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::logout()
|
||||
{
|
||||
if (!m_loggedIn || m_retryCount > 0U)
|
||||
return false;
|
||||
|
||||
::memcpy(m_outBuffer, "LOG", 3U);
|
||||
m_outLength = 3U;
|
||||
|
||||
for (unsigned int i = 0U; i < 5U; i++) {
|
||||
bool ret = m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
|
||||
if (!ret) {
|
||||
m_retryCount = 0U;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
m_retryCount = 1U;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteControlHandler::retry()
|
||||
{
|
||||
if (m_retryCount > 0U) {
|
||||
m_retryCount++;
|
||||
if (m_retryCount >= MAX_RETRIES) {
|
||||
m_retryCount = 0U;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_socket.write(m_outBuffer, m_outLength, m_address, m_port);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CRemoteControlRemoteControlHandler::close()
|
||||
{
|
||||
m_socket.close();
|
||||
}
|
||||
86
RemoteControl/RemoteControlRemoteControlHandler.h
Normal file
86
RemoteControl/RemoteControlRemoteControlHandler.h
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Copyright (C) 2011,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 RemoteControlRemoteControlHandler_H
|
||||
#define RemoteControlRemoteControlHandler_H
|
||||
|
||||
#include "RemoteControlRepeaterData.h"
|
||||
#include "RemoteControlStarNetGroup.h"
|
||||
#include "RemoteControlCallsignData.h"
|
||||
#include "UDPReaderWriter.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
enum RC_TYPE {
|
||||
RCT_NONE,
|
||||
RCT_ACK,
|
||||
RCT_NAK,
|
||||
RCT_RANDOM,
|
||||
RCT_CALLSIGNS,
|
||||
RCT_REPEATER,
|
||||
RCT_STARNET
|
||||
};
|
||||
|
||||
class CRemoteControlRemoteControlHandler {
|
||||
public:
|
||||
CRemoteControlRemoteControlHandler(const wxString& address, unsigned int port);
|
||||
~CRemoteControlRemoteControlHandler();
|
||||
|
||||
bool open();
|
||||
|
||||
RC_TYPE readType();
|
||||
|
||||
wxString readNAK();
|
||||
unsigned int readRandom();
|
||||
CRemoteControlCallsignData* readCallsigns();
|
||||
CRemoteControlRepeaterData* readRepeater();
|
||||
CRemoteControlStarNetGroup* readStarNetGroup();
|
||||
|
||||
bool login();
|
||||
bool sendHash(const unsigned char* hash, unsigned int length);
|
||||
|
||||
void setLoggedIn(bool set);
|
||||
|
||||
bool getCallsigns();
|
||||
bool getRepeater(const wxString& callsign);
|
||||
bool getStarNet(const wxString& callsign);
|
||||
|
||||
bool link(const wxString& callsign, RECONNECT reconnect, const wxString& reflector);
|
||||
bool unlink(const wxString& callsign, PROTOCOL protocol, const wxString& reflector);
|
||||
bool logoff(const wxString& callsign, const wxString& user);
|
||||
|
||||
bool logout();
|
||||
|
||||
bool retry();
|
||||
|
||||
void close();
|
||||
|
||||
private:
|
||||
CUDPReaderWriter m_socket;
|
||||
in_addr m_address;
|
||||
unsigned int m_port;
|
||||
bool m_loggedIn;
|
||||
unsigned int m_retryCount;
|
||||
RC_TYPE m_type;
|
||||
unsigned char* m_inBuffer;
|
||||
unsigned int m_inLength;
|
||||
unsigned char* m_outBuffer;
|
||||
unsigned int m_outLength;
|
||||
};
|
||||
|
||||
#endif
|
||||
112
RemoteControl/RemoteControlRemoteSet.cpp
Normal file
112
RemoteControl/RemoteControlRemoteSet.cpp
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 "RemoteControlRemoteSet.h"
|
||||
#include "DStarDefines.h"
|
||||
|
||||
const unsigned int PASSWORD_WIDTH = 120U;
|
||||
const unsigned int PORT_WIDTH = 80U;
|
||||
|
||||
const unsigned int PORT_LENGTH = 5U;
|
||||
|
||||
const unsigned int BORDER_SIZE = 5U;
|
||||
|
||||
CRemoteControlRemoteSet::CRemoteControlRemoteSet(wxWindow* parent, int id, const wxString& title, const wxString& address, unsigned int port, const wxString& password) :
|
||||
wxPanel(parent, id),
|
||||
m_title(title),
|
||||
m_address(NULL),
|
||||
m_port(NULL),
|
||||
m_password(NULL)
|
||||
{
|
||||
wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
|
||||
|
||||
wxStaticText* addressLabel = new wxStaticText(this, -1, _("Address"));
|
||||
sizer->Add(addressLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
|
||||
|
||||
m_address = new wxTextCtrl(this, -1, address, wxDefaultPosition, wxSize(PASSWORD_WIDTH, -1));
|
||||
sizer->Add(m_address, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
|
||||
|
||||
wxStaticText* portLabel = new wxStaticText(this, -1, _("Port"));
|
||||
sizer->Add(portLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
|
||||
|
||||
wxString buffer;
|
||||
buffer.Printf(wxT("%u"), port);
|
||||
|
||||
m_port = new CPortTextCtrl(this, -1, buffer, wxDefaultPosition, wxSize(PORT_WIDTH, -1));
|
||||
m_port->SetMaxLength(PORT_LENGTH);
|
||||
sizer->Add(m_port, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
|
||||
|
||||
wxStaticText* passwordLabel = new wxStaticText(this, -1, _("Password"));
|
||||
sizer->Add(passwordLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
|
||||
|
||||
m_password = new wxTextCtrl(this, -1, password, wxDefaultPosition, wxSize(PASSWORD_WIDTH, -1), wxTE_PASSWORD);
|
||||
sizer->Add(m_password, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
|
||||
|
||||
SetAutoLayout(true);
|
||||
|
||||
SetSizer(sizer);
|
||||
}
|
||||
|
||||
|
||||
CRemoteControlRemoteSet::~CRemoteControlRemoteSet()
|
||||
{
|
||||
}
|
||||
|
||||
bool CRemoteControlRemoteSet::Validate()
|
||||
{
|
||||
wxString address = getAddress();
|
||||
if (address.IsEmpty()) {
|
||||
wxMessageDialog dialog(this, _("The Address is empty"), m_title + _(" Error"), wxICON_ERROR);
|
||||
dialog.ShowModal();
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int port = getPort();
|
||||
if (port == 0U || port > 65535U) {
|
||||
wxMessageDialog dialog(this, _("The Port is not valid"), m_title + _(" Error"), wxICON_ERROR);
|
||||
dialog.ShowModal();
|
||||
return false;
|
||||
}
|
||||
|
||||
wxString password = getPassword();
|
||||
if (password.IsEmpty()) {
|
||||
wxMessageDialog dialog(this, _("The Password is empty"), m_title + _(" Error"), wxICON_ERROR);
|
||||
dialog.ShowModal();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
wxString CRemoteControlRemoteSet::getAddress() const
|
||||
{
|
||||
return m_address->GetValue();
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlRemoteSet::getPort() const
|
||||
{
|
||||
unsigned long n;
|
||||
m_port->GetValue().ToULong(&n);
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
wxString CRemoteControlRemoteSet::getPassword() const
|
||||
{
|
||||
return m_password->GetValue();
|
||||
}
|
||||
44
RemoteControl/RemoteControlRemoteSet.h
Normal file
44
RemoteControl/RemoteControlRemoteSet.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 RemoteControlRemoteSet_H
|
||||
#define RemoteControlRemoteSet_H
|
||||
|
||||
#include "PortTextCtrl.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
class CRemoteControlRemoteSet : public wxPanel {
|
||||
public:
|
||||
CRemoteControlRemoteSet(wxWindow* parent, int id, const wxString& title, const wxString& address, unsigned int port, const wxString& password);
|
||||
virtual ~CRemoteControlRemoteSet();
|
||||
|
||||
virtual bool Validate();
|
||||
|
||||
virtual wxString getAddress() const;
|
||||
virtual unsigned int getPort() const;
|
||||
virtual wxString getPassword() const;
|
||||
|
||||
private:
|
||||
wxString m_title;
|
||||
wxTextCtrl* m_address;
|
||||
CPortTextCtrl* m_port;
|
||||
wxTextCtrl* m_password;
|
||||
};
|
||||
|
||||
#endif
|
||||
67
RemoteControl/RemoteControlRepeaterData.cpp
Normal file
67
RemoteControl/RemoteControlRepeaterData.cpp
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 "RemoteControlRepeaterData.h"
|
||||
|
||||
#include <wx/arrimpl.cpp>
|
||||
WX_DEFINE_OBJARRAY(CRemoteLinkData_t);
|
||||
|
||||
CRemoteControlRepeaterData::CRemoteControlRepeaterData(const wxString& callsign, wxInt32 reconnect, const wxString& reflector) :
|
||||
m_callsign(callsign),
|
||||
m_reconnect(RECONNECT(reconnect)),
|
||||
m_reflector(reflector),
|
||||
m_links()
|
||||
{
|
||||
}
|
||||
|
||||
CRemoteControlRepeaterData::~CRemoteControlRepeaterData()
|
||||
{
|
||||
m_links.Clear();
|
||||
}
|
||||
|
||||
void CRemoteControlRepeaterData::addLink(const wxString& callsign, wxInt32 protocol, wxInt32 linked, wxInt32 direction, wxInt32 dongle)
|
||||
{
|
||||
CRemoteControlLinkData data(callsign, protocol, linked, direction, dongle);
|
||||
|
||||
m_links.Add(data);
|
||||
}
|
||||
|
||||
wxString CRemoteControlRepeaterData::getCallsign() const
|
||||
{
|
||||
return m_callsign;
|
||||
}
|
||||
|
||||
RECONNECT CRemoteControlRepeaterData::getReconnect() const
|
||||
{
|
||||
return m_reconnect;
|
||||
}
|
||||
|
||||
wxString CRemoteControlRepeaterData::getReflector() const
|
||||
{
|
||||
return m_reflector;
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlRepeaterData::getLinkCount() const
|
||||
{
|
||||
return m_links.GetCount();
|
||||
}
|
||||
|
||||
CRemoteControlLinkData& CRemoteControlRepeaterData::getLink(unsigned int n) const
|
||||
{
|
||||
return m_links.Item(n);
|
||||
}
|
||||
50
RemoteControl/RemoteControlRepeaterData.h
Normal file
50
RemoteControl/RemoteControlRepeaterData.h
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 RemoteControlRepeaterData_H
|
||||
#define RemoteControlRepeaterData_H
|
||||
|
||||
#include "RemoteControlLinkData.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/dynarray.h>
|
||||
|
||||
WX_DECLARE_OBJARRAY(CRemoteControlLinkData, CRemoteLinkData_t);
|
||||
|
||||
class CRemoteControlRepeaterData {
|
||||
public:
|
||||
CRemoteControlRepeaterData(const wxString& callsign, wxInt32 reconnect, const wxString& reflector);
|
||||
~CRemoteControlRepeaterData();
|
||||
|
||||
void addLink(const wxString& callsign, wxInt32 protocol, wxInt32 linked, wxInt32 direction, wxInt32 dongle);
|
||||
|
||||
wxString getCallsign() const;
|
||||
RECONNECT getReconnect() const;
|
||||
wxString getReflector() const;
|
||||
|
||||
unsigned int getLinkCount() const;
|
||||
CRemoteControlLinkData& getLink(unsigned int n) const;
|
||||
|
||||
private:
|
||||
wxString m_callsign;
|
||||
RECONNECT m_reconnect;
|
||||
wxString m_reflector;
|
||||
CRemoteLinkData_t m_links;
|
||||
};
|
||||
|
||||
#endif
|
||||
397
RemoteControl/RemoteControlRepeaterPanel.cpp
Normal file
397
RemoteControl/RemoteControlRepeaterPanel.cpp
Normal file
|
|
@ -0,0 +1,397 @@
|
|||
/*
|
||||
* Copyright (C) 2011,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 "RemoteControlRepeaterPanel.h"
|
||||
#include "RemoteControlApp.h"
|
||||
#include "DStarDefines.h"
|
||||
#include "HostFile.h"
|
||||
|
||||
#include <wx/filename.h>
|
||||
|
||||
enum {
|
||||
List_Reflectors = 7100,
|
||||
Button_Refresh,
|
||||
Button_Link,
|
||||
Button_Unlink
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(CRemoteControlRepeaterPanel, wxPanel)
|
||||
EVT_LIST_ITEM_SELECTED(List_Reflectors, CRemoteControlRepeaterPanel::onSelect)
|
||||
EVT_BUTTON(Button_Refresh, CRemoteControlRepeaterPanel::onRefresh)
|
||||
EVT_BUTTON(Button_Link, CRemoteControlRepeaterPanel::onLink)
|
||||
EVT_BUTTON(Button_Unlink, CRemoteControlRepeaterPanel::onUnlink)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
const unsigned int LIST_HEIGHT = 350U;
|
||||
const unsigned int LIST_WIDTH = 350U;
|
||||
const unsigned int CALLSIGN_WIDTH = 100U;
|
||||
const unsigned int PROTOCOL_WIDTH = 55U;
|
||||
const unsigned int DIRECTION_WIDTH = 55U;
|
||||
const unsigned int TYPE_WIDTH = 65U;
|
||||
const unsigned int STATE_WIDTH = 55U;
|
||||
const unsigned int BUTTON_WIDTH = 75U;
|
||||
const unsigned int REFLECTOR_WIDTH = 75U;
|
||||
const unsigned int CHANNEL_WIDTH = 40U;
|
||||
const unsigned int RECONNECT_WIDTH = 75U;
|
||||
#else
|
||||
const unsigned int LIST_HEIGHT = 350U;
|
||||
const unsigned int LIST_WIDTH = 350U;
|
||||
const unsigned int CALLSIGN_WIDTH = 100U;
|
||||
const unsigned int PROTOCOL_WIDTH = 55U;
|
||||
const unsigned int DIRECTION_WIDTH = 55U;
|
||||
const unsigned int TYPE_WIDTH = 65U;
|
||||
const unsigned int STATE_WIDTH = 55U;
|
||||
const unsigned int BUTTON_WIDTH = 75U;
|
||||
const unsigned int REFLECTOR_WIDTH = 90U;
|
||||
const unsigned int CHANNEL_WIDTH = 50U;
|
||||
const unsigned int RECONNECT_WIDTH = 100U;
|
||||
#endif
|
||||
|
||||
const unsigned int BORDER_SIZE = 5U;
|
||||
|
||||
CRemoteControlRepeaterPanel::CRemoteControlRepeaterPanel(wxWindow* parent, int id, const wxString& callsign) :
|
||||
wxPanel(parent, id),
|
||||
m_callsign(callsign),
|
||||
m_list(NULL),
|
||||
m_reflector(NULL),
|
||||
m_channel(NULL),
|
||||
m_reconnect(NULL),
|
||||
m_unlink(NULL),
|
||||
m_selected(-1),
|
||||
m_reflectors(),
|
||||
m_protocols()
|
||||
{
|
||||
wxBoxSizer* sizer1 = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_list = new wxListCtrl(this, List_Reflectors, wxDefaultPosition, wxSize(LIST_WIDTH, LIST_HEIGHT), wxLC_REPORT | wxLC_SINGLE_SEL);
|
||||
m_list->InsertColumn(0L, _("Callsign"));
|
||||
m_list->SetColumnWidth(0L, CALLSIGN_WIDTH);
|
||||
m_list->InsertColumn(1L, _("Protocol"));
|
||||
m_list->SetColumnWidth(1L, PROTOCOL_WIDTH);
|
||||
m_list->InsertColumn(2L, _("Direction"));
|
||||
m_list->SetColumnWidth(2L, DIRECTION_WIDTH);
|
||||
m_list->InsertColumn(3L, _("Type"));
|
||||
m_list->SetColumnWidth(3L, TYPE_WIDTH);
|
||||
m_list->InsertColumn(4L, _("State"));
|
||||
m_list->SetColumnWidth(4L, STATE_WIDTH);
|
||||
sizer1->Add(m_list, 0, wxTOP | wxBOTTOM | wxLEFT | wxEXPAND, BORDER_SIZE);
|
||||
|
||||
wxBoxSizer* sizer2 = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxButton* refreshButton = new wxButton(this, Button_Refresh, _("Refresh"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1));
|
||||
sizer2->Add(refreshButton, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
wxStaticText* dummy1Label = new wxStaticText(this, -1, wxEmptyString);
|
||||
sizer2->Add(dummy1Label, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
wxStaticText* dummy2Label = new wxStaticText(this, -1, wxEmptyString);
|
||||
sizer2->Add(dummy2Label, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
wxBoxSizer* sizer3 = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_reflector = new wxChoice(this, -1, wxDefaultPosition, wxSize(REFLECTOR_WIDTH, -1));
|
||||
m_reflector->Append(_("None"));
|
||||
|
||||
wxFileName fileName1(wxFileName::GetHomeDir(), DPLUS_HOSTS_FILE_NAME);
|
||||
if (fileName1.IsFileReadable()) {
|
||||
CHostFile file(fileName1.GetFullPath(), false);
|
||||
|
||||
for (unsigned int i = 0U; i < file.getCount(); i++)
|
||||
m_reflector->Append(file.getName(i).Trim());
|
||||
}
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
wxFileName fileName4(::wxGetCwd(), DPLUS_HOSTS_FILE_NAME);
|
||||
#else
|
||||
wxFileName fileName4(wxT(DATA_DIR), DPLUS_HOSTS_FILE_NAME);
|
||||
#endif
|
||||
if (fileName4.IsFileReadable()) {
|
||||
CHostFile file(fileName4.GetFullPath(), false);
|
||||
|
||||
for (unsigned int i = 0U; i < file.getCount(); i++) {
|
||||
wxString name = file.getName(i).Trim();
|
||||
if (m_reflector->FindString(name) == wxNOT_FOUND)
|
||||
m_reflector->Append(name);
|
||||
}
|
||||
}
|
||||
|
||||
wxFileName fileName2(wxFileName::GetHomeDir(), DEXTRA_HOSTS_FILE_NAME);
|
||||
if (fileName2.IsFileReadable()) {
|
||||
CHostFile file(fileName2.GetFullPath(), false);
|
||||
|
||||
for (unsigned int i = 0U; i < file.getCount(); i++)
|
||||
m_reflector->Append(file.getName(i).Trim());
|
||||
}
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
wxFileName fileName5(::wxGetCwd(), DEXTRA_HOSTS_FILE_NAME);
|
||||
#else
|
||||
wxFileName fileName5(wxT(DATA_DIR), DEXTRA_HOSTS_FILE_NAME);
|
||||
#endif
|
||||
if (fileName5.IsFileReadable()) {
|
||||
CHostFile file(fileName5.GetFullPath(), false);
|
||||
|
||||
for (unsigned int i = 0U; i < file.getCount(); i++) {
|
||||
wxString name = file.getName(i).Trim();
|
||||
if (m_reflector->FindString(name) == wxNOT_FOUND)
|
||||
m_reflector->Append(name);
|
||||
}
|
||||
}
|
||||
|
||||
wxFileName fileName3(wxFileName::GetHomeDir(), DCS_HOSTS_FILE_NAME);
|
||||
if (fileName3.IsFileReadable()) {
|
||||
CHostFile file(fileName3.GetFullPath(), false);
|
||||
|
||||
for (unsigned int i = 0U; i < file.getCount(); i++)
|
||||
m_reflector->Append(file.getName(i).Trim());
|
||||
}
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
wxFileName fileName6(::wxGetCwd(), DCS_HOSTS_FILE_NAME);
|
||||
#else
|
||||
wxFileName fileName6(wxT(DATA_DIR), DCS_HOSTS_FILE_NAME);
|
||||
#endif
|
||||
if (fileName6.IsFileReadable()) {
|
||||
CHostFile file(fileName6.GetFullPath(), false);
|
||||
|
||||
for (unsigned int i = 0U; i < file.getCount(); i++) {
|
||||
wxString name = file.getName(i).Trim();
|
||||
if (m_reflector->FindString(name) == wxNOT_FOUND)
|
||||
m_reflector->Append(name);
|
||||
}
|
||||
}
|
||||
|
||||
sizer3->Add(m_reflector, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
|
||||
m_reflector->SetSelection(0);
|
||||
|
||||
m_channel = new wxChoice(this, -1, wxDefaultPosition, wxSize(CHANNEL_WIDTH, -1));
|
||||
m_channel->Append(wxT("A"));
|
||||
m_channel->Append(wxT("B"));
|
||||
m_channel->Append(wxT("C"));
|
||||
m_channel->Append(wxT("D"));
|
||||
m_channel->Append(wxT("E"));
|
||||
m_channel->Append(wxT("F"));
|
||||
m_channel->Append(wxT("G"));
|
||||
m_channel->Append(wxT("H"));
|
||||
m_channel->Append(wxT("I"));
|
||||
m_channel->Append(wxT("J"));
|
||||
m_channel->Append(wxT("K"));
|
||||
m_channel->Append(wxT("L"));
|
||||
m_channel->Append(wxT("M"));
|
||||
m_channel->Append(wxT("N"));
|
||||
m_channel->Append(wxT("O"));
|
||||
m_channel->Append(wxT("P"));
|
||||
m_channel->Append(wxT("Q"));
|
||||
m_channel->Append(wxT("R"));
|
||||
m_channel->Append(wxT("S"));
|
||||
m_channel->Append(wxT("T"));
|
||||
m_channel->Append(wxT("U"));
|
||||
m_channel->Append(wxT("V"));
|
||||
m_channel->Append(wxT("W"));
|
||||
m_channel->Append(wxT("X"));
|
||||
m_channel->Append(wxT("Y"));
|
||||
m_channel->Append(wxT("Z"));
|
||||
sizer3->Add(m_channel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
|
||||
m_channel->SetSelection(0);
|
||||
|
||||
sizer2->Add(sizer3);
|
||||
|
||||
m_reconnect = new wxChoice(this, -1, wxDefaultPosition, wxSize(RECONNECT_WIDTH, -1));
|
||||
m_reconnect->Append(_("Never"));
|
||||
m_reconnect->Append(_("Fixed"));
|
||||
m_reconnect->Append(_("5 minutes"));
|
||||
m_reconnect->Append(_("10 minutes"));
|
||||
m_reconnect->Append(_("15 minutes"));
|
||||
m_reconnect->Append(_("20 minutes"));
|
||||
m_reconnect->Append(_("25 minutes"));
|
||||
m_reconnect->Append(_("30 minutes"));
|
||||
m_reconnect->Append(_("60 minutes"));
|
||||
m_reconnect->Append(_("90 minutes"));
|
||||
m_reconnect->Append(_("120 minutes"));
|
||||
m_reconnect->Append(_("180 minutes"));
|
||||
sizer2->Add(m_reconnect, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
|
||||
m_reconnect->SetSelection(0);
|
||||
|
||||
wxStaticText* dummy3Label = new wxStaticText(this, -1, wxEmptyString);
|
||||
sizer2->Add(dummy3Label, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
wxButton* linkButton = new wxButton(this, Button_Link, _("Link"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1));
|
||||
sizer2->Add(linkButton, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
m_unlink = new wxButton(this, Button_Unlink, _("Unlink"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1));
|
||||
sizer2->Add(m_unlink, 0, wxALL, BORDER_SIZE);
|
||||
m_unlink->Disable();
|
||||
|
||||
sizer1->Add(sizer2);
|
||||
|
||||
SetAutoLayout(true);
|
||||
|
||||
SetSizer(sizer1);
|
||||
}
|
||||
|
||||
|
||||
CRemoteControlRepeaterPanel::~CRemoteControlRepeaterPanel()
|
||||
{
|
||||
}
|
||||
|
||||
void CRemoteControlRepeaterPanel::add(const CRemoteControlRepeaterData& data)
|
||||
{
|
||||
m_list->DeleteAllItems();
|
||||
m_unlink->Disable();
|
||||
m_reflectors.Clear();
|
||||
m_protocols.Clear();
|
||||
|
||||
RECONNECT reconnect = data.getReconnect();
|
||||
m_reconnect->SetSelection(int(reconnect));
|
||||
|
||||
wxString reflector = data.getReflector();
|
||||
reflector.Append(wxT(" "));
|
||||
reflector.Truncate(LONG_CALLSIGN_LENGTH);
|
||||
|
||||
bool res = m_channel->SetStringSelection(reflector.Right(1));
|
||||
if (!res)
|
||||
m_channel->SetSelection(0);
|
||||
|
||||
reflector.Truncate(LONG_CALLSIGN_LENGTH - 1U);
|
||||
reflector.Append(wxT(" "));
|
||||
|
||||
res = m_reflector->SetStringSelection(reflector);
|
||||
if (!res)
|
||||
m_reflector->SetSelection(0);
|
||||
|
||||
unsigned int count = data.getLinkCount();
|
||||
for (unsigned int i = 0U; i < count; i++) {
|
||||
CRemoteControlLinkData& link = data.getLink(i);
|
||||
|
||||
wxString callsign = link.getCallsign();
|
||||
PROTOCOL protocol = link.getProtocol();
|
||||
bool isLinked = link.isLinked();
|
||||
DIRECTION direction = link.getDirection();
|
||||
bool isDongle = link.isDongle();
|
||||
|
||||
m_reflectors.Add(callsign);
|
||||
m_protocols.Add(protocol);
|
||||
|
||||
m_list->InsertItem(0L, callsign);
|
||||
|
||||
// To allow for sorting
|
||||
m_list->SetItemData(0L, long(protocol));
|
||||
|
||||
switch (protocol) {
|
||||
case PROTO_DEXTRA:
|
||||
m_list->SetItem(0L, 1, wxT("DExtra"));
|
||||
break;
|
||||
case PROTO_DPLUS:
|
||||
m_list->SetItem(0L, 1, wxT("D-Plus"));
|
||||
break;
|
||||
case PROTO_DCS:
|
||||
m_list->SetItem(0L, 1, wxT("DCS"));
|
||||
break;
|
||||
case PROTO_CCS:
|
||||
m_list->SetItem(0L, 1, wxT("CCS"));
|
||||
break;
|
||||
default:
|
||||
m_list->SetItem(0L, 1, wxT("?????"));
|
||||
break;
|
||||
}
|
||||
|
||||
switch (direction){
|
||||
case DIR_INCOMING:
|
||||
m_list->SetItem(0L, 2, _("IN"));
|
||||
break;
|
||||
case DIR_OUTGOING:
|
||||
m_list->SetItem(0L, 2, _("OUT"));
|
||||
break;
|
||||
default:
|
||||
m_list->SetItem(0L, 2, wxT("???"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (isDongle)
|
||||
m_list->SetItem(0L, 3, _("Dongle"));
|
||||
else
|
||||
m_list->SetItem(0L, 3, _("Repeater"));
|
||||
|
||||
if (isLinked)
|
||||
m_list->SetItem(0L, 4, _("Linked"));
|
||||
else
|
||||
m_list->SetItem(0L, 4, _("Linking"));
|
||||
}
|
||||
}
|
||||
|
||||
void CRemoteControlRepeaterPanel::onRefresh(wxCommandEvent&)
|
||||
{
|
||||
::wxGetApp().repeaterRefresh(m_callsign);
|
||||
}
|
||||
|
||||
void CRemoteControlRepeaterPanel::onLink(wxCommandEvent&)
|
||||
{
|
||||
int n = m_reconnect->GetCurrentSelection();
|
||||
if (n == wxNOT_FOUND)
|
||||
return;
|
||||
|
||||
RECONNECT reconnect = RECONNECT(n);
|
||||
|
||||
n = m_reflector->GetCurrentSelection();
|
||||
if (n == wxNOT_FOUND)
|
||||
return;
|
||||
|
||||
wxString reflector = wxEmptyString;
|
||||
|
||||
if (n > 0) {
|
||||
n = m_channel->GetCurrentSelection();
|
||||
if (n == wxNOT_FOUND)
|
||||
return;
|
||||
|
||||
reflector = m_reflector->GetStringSelection();
|
||||
if (reflector.IsEmpty())
|
||||
return;
|
||||
|
||||
wxString channel = m_channel->GetStringSelection();
|
||||
if (channel.IsEmpty())
|
||||
return;
|
||||
|
||||
reflector.Append(wxT(" "));
|
||||
reflector.Truncate(LONG_CALLSIGN_LENGTH - 1U);
|
||||
reflector.Append(channel);
|
||||
}
|
||||
|
||||
::wxGetApp().link(m_callsign, reconnect, reflector);
|
||||
}
|
||||
|
||||
void CRemoteControlRepeaterPanel::onUnlink(wxCommandEvent&)
|
||||
{
|
||||
if (m_selected == -1)
|
||||
return;
|
||||
|
||||
wxString reflector = m_reflectors.Item(m_selected);
|
||||
PROTOCOL protocol = m_protocols.Item(m_selected);
|
||||
|
||||
m_selected = -1;
|
||||
m_unlink->Disable();
|
||||
|
||||
::wxGetApp().unlink(m_callsign, protocol, reflector);
|
||||
}
|
||||
|
||||
void CRemoteControlRepeaterPanel::onSelect(wxListEvent& event)
|
||||
{
|
||||
m_selected = event.GetSelection();
|
||||
|
||||
m_unlink->Enable();
|
||||
}
|
||||
55
RemoteControl/RemoteControlRepeaterPanel.h
Normal file
55
RemoteControl/RemoteControlRepeaterPanel.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (C) 2011,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 RemoteControlRepeaterPanel_H
|
||||
#define RemoteControlRepeaterPanel_H
|
||||
|
||||
#include "RemoteControlRepeaterData.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
WX_DEFINE_ARRAY_INT(PROTOCOL, CArrayProtocol);
|
||||
|
||||
class CRemoteControlRepeaterPanel : public wxPanel {
|
||||
public:
|
||||
CRemoteControlRepeaterPanel(wxWindow* parent, int id, const wxString& callsign);
|
||||
virtual ~CRemoteControlRepeaterPanel();
|
||||
|
||||
virtual void add(const CRemoteControlRepeaterData& data);
|
||||
|
||||
virtual void onRefresh(wxCommandEvent& event);
|
||||
virtual void onLink(wxCommandEvent& event);
|
||||
virtual void onUnlink(wxCommandEvent& event);
|
||||
virtual void onSelect(wxListEvent& event);
|
||||
|
||||
private:
|
||||
wxString m_callsign;
|
||||
wxListCtrl* m_list;
|
||||
wxChoice* m_reflector;
|
||||
wxChoice* m_channel;
|
||||
wxChoice* m_reconnect;
|
||||
wxButton* m_unlink;
|
||||
int m_selected;
|
||||
wxArrayString m_reflectors;
|
||||
CArrayProtocol m_protocols;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
75
RemoteControl/RemoteControlStarNetGroup.cpp
Normal file
75
RemoteControl/RemoteControlStarNetGroup.cpp
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 "RemoteControlStarNetGroup.h"
|
||||
|
||||
#include <wx/arrimpl.cpp>
|
||||
WX_DEFINE_OBJARRAY(CRemoteUserData_t);
|
||||
|
||||
CRemoteControlStarNetGroup::CRemoteControlStarNetGroup(const wxString& callsign, const wxString& logoff, wxUint32 timer, wxUint32 timeout) :
|
||||
m_callsign(callsign),
|
||||
m_logoff(logoff),
|
||||
m_timer((unsigned int)timer),
|
||||
m_timeout((unsigned int)timeout),
|
||||
m_users()
|
||||
{
|
||||
if (m_logoff.IsSameAs(wxT(" ")))
|
||||
m_logoff.Clear();
|
||||
}
|
||||
|
||||
CRemoteControlStarNetGroup::~CRemoteControlStarNetGroup()
|
||||
{
|
||||
m_users.Clear();
|
||||
}
|
||||
|
||||
void CRemoteControlStarNetGroup::addUser(const wxString& callsign, wxUint32 timer, wxUint32 timeout)
|
||||
{
|
||||
CRemoteControlStarNetUser user(callsign, timer, timeout);
|
||||
|
||||
m_users.Add(user);
|
||||
}
|
||||
|
||||
wxString CRemoteControlStarNetGroup::getCallsign() const
|
||||
{
|
||||
return m_callsign;
|
||||
}
|
||||
|
||||
wxString CRemoteControlStarNetGroup::getLogoff() const
|
||||
{
|
||||
return m_logoff;
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlStarNetGroup::getTimer() const
|
||||
{
|
||||
return m_timer;
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlStarNetGroup::getTimeout() const
|
||||
{
|
||||
return m_timeout;
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlStarNetGroup::getUserCount() const
|
||||
{
|
||||
return m_users.GetCount();
|
||||
}
|
||||
|
||||
CRemoteControlStarNetUser& CRemoteControlStarNetGroup::getUser(unsigned int n) const
|
||||
{
|
||||
return m_users.Item(n);
|
||||
}
|
||||
52
RemoteControl/RemoteControlStarNetGroup.h
Normal file
52
RemoteControl/RemoteControlStarNetGroup.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 RemoteControlStarNetGroup_H
|
||||
#define RemoteControlStarNetGroup_H
|
||||
|
||||
#include "RemoteControlStarNetUser.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
#include <wx/dynarray.h>
|
||||
WX_DECLARE_OBJARRAY(CRemoteControlStarNetUser, CRemoteUserData_t);
|
||||
|
||||
class CRemoteControlStarNetGroup {
|
||||
public:
|
||||
CRemoteControlStarNetGroup(const wxString& callsign, const wxString& logoff, wxUint32 timer, wxUint32 timeout);
|
||||
~CRemoteControlStarNetGroup();
|
||||
|
||||
void addUser(const wxString& callsign, wxUint32 timer, wxUint32 timeout);
|
||||
|
||||
wxString getCallsign() const;
|
||||
wxString getLogoff() const;
|
||||
unsigned int getTimer() const;
|
||||
unsigned int getTimeout() const;
|
||||
|
||||
unsigned int getUserCount() const;
|
||||
CRemoteControlStarNetUser& getUser(unsigned int n) const;
|
||||
|
||||
private:
|
||||
wxString m_callsign;
|
||||
wxString m_logoff;
|
||||
unsigned int m_timer;
|
||||
unsigned int m_timeout;
|
||||
CRemoteUserData_t m_users;
|
||||
};
|
||||
|
||||
#endif
|
||||
188
RemoteControl/RemoteControlStarNetPanel.cpp
Normal file
188
RemoteControl/RemoteControlStarNetPanel.cpp
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 "RemoteControlStarNetPanel.h"
|
||||
#include "RemoteControlApp.h"
|
||||
|
||||
enum {
|
||||
Button_Refresh = 7100,
|
||||
Button_LogoffAll,
|
||||
List_StarNets,
|
||||
Menu_Logoff
|
||||
};
|
||||
|
||||
BEGIN_EVENT_TABLE(CRemoteControlStarNetPanel, wxPanel)
|
||||
EVT_BUTTON(Button_Refresh, CRemoteControlStarNetPanel::onRefresh)
|
||||
EVT_BUTTON(Button_LogoffAll, CRemoteControlStarNetPanel::onLogoffAll)
|
||||
EVT_LIST_ITEM_RIGHT_CLICK(List_StarNets, CRemoteControlStarNetPanel::onClick)
|
||||
EVT_MENU(Menu_Logoff, CRemoteControlStarNetPanel::onLogoff)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
const unsigned int LIST_HEIGHT = 350U;
|
||||
const unsigned int LIST_WIDTH = 350U;
|
||||
const unsigned int CALLSIGN_WIDTH = 100U;
|
||||
const unsigned int TIMER_WIDTH = 145U;
|
||||
const unsigned int BUTTON_WIDTH = 75U;
|
||||
#else
|
||||
const unsigned int LIST_HEIGHT = 350U;
|
||||
const unsigned int LIST_WIDTH = 350U;
|
||||
const unsigned int CALLSIGN_WIDTH = 100U;
|
||||
const unsigned int TIMER_WIDTH = 145U;
|
||||
const unsigned int BUTTON_WIDTH = 75U;
|
||||
#endif
|
||||
|
||||
const unsigned int BORDER_SIZE = 5U;
|
||||
|
||||
CRemoteControlStarNetPanel::CRemoteControlStarNetPanel(wxWindow* parent, int id, const wxString& callsign) :
|
||||
wxPanel(parent, id),
|
||||
m_callsign(callsign),
|
||||
m_list(NULL),
|
||||
m_logoff(NULL),
|
||||
m_timer(NULL),
|
||||
m_logoffAll(NULL),
|
||||
m_chosen(),
|
||||
m_menu(NULL)
|
||||
{
|
||||
wxBoxSizer* sizer1 = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_list = new wxListCtrl(this, List_StarNets, wxDefaultPosition, wxSize(LIST_WIDTH, LIST_HEIGHT), wxLC_REPORT | wxLC_SINGLE_SEL);
|
||||
m_list->InsertColumn(0L, _("Callsign"));
|
||||
m_list->SetColumnWidth(0L, CALLSIGN_WIDTH);
|
||||
m_list->InsertColumn(1L, _("User Timer"));
|
||||
m_list->SetColumnWidth(1L, TIMER_WIDTH);
|
||||
sizer1->Add(m_list, 0, wxTOP | wxBOTTOM | wxLEFT | wxEXPAND, BORDER_SIZE);
|
||||
|
||||
wxBoxSizer* sizer2 = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
wxButton* refreshButton = new wxButton(this, Button_Refresh, _("Refresh"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1));
|
||||
sizer2->Add(refreshButton, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
wxStaticText* dummy1Label = new wxStaticText(this, -1, wxEmptyString);
|
||||
sizer2->Add(dummy1Label, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
wxStaticText* logoffLabel = new wxStaticText(this, -1, _("Logoff Callsign"));
|
||||
sizer2->Add(logoffLabel, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
m_logoff = new wxStaticText(this, -1, wxEmptyString);
|
||||
sizer2->Add(m_logoff, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
wxStaticText* dummy3Label = new wxStaticText(this, -1, wxEmptyString);
|
||||
sizer2->Add(dummy3Label, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
wxStaticText* timerLabel = new wxStaticText(this, -1, _("Group Timer"));
|
||||
sizer2->Add(timerLabel, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
m_timer = new wxStaticText(this, -1, wxEmptyString);
|
||||
sizer2->Add(m_timer, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
wxStaticText* dummy5Label = new wxStaticText(this, -1, wxEmptyString);
|
||||
sizer2->Add(dummy5Label, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
m_logoffAll = new wxButton(this, Button_LogoffAll, _("Logoff All"), wxDefaultPosition, wxSize(BUTTON_WIDTH, -1));
|
||||
m_logoffAll->Disable();
|
||||
sizer2->Add(m_logoffAll, 0, wxALL, BORDER_SIZE);
|
||||
|
||||
sizer1->Add(sizer2);
|
||||
|
||||
SetAutoLayout(true);
|
||||
|
||||
SetSizer(sizer1);
|
||||
|
||||
m_menu = new wxMenu;
|
||||
m_menu->Append(Menu_Logoff, _("Logoff"));
|
||||
}
|
||||
|
||||
|
||||
CRemoteControlStarNetPanel::~CRemoteControlStarNetPanel()
|
||||
{
|
||||
}
|
||||
|
||||
void CRemoteControlStarNetPanel::add(const CRemoteControlStarNetGroup& data)
|
||||
{
|
||||
m_list->DeleteAllItems();
|
||||
|
||||
wxString logoff = data.getLogoff();
|
||||
if (logoff.IsEmpty())
|
||||
m_logoff->SetLabel(_("None"));
|
||||
else
|
||||
m_logoff->SetLabel(logoff);
|
||||
|
||||
unsigned int timer = data.getTimer();
|
||||
unsigned int timeout = data.getTimeout();
|
||||
|
||||
if (timeout == 0U) {
|
||||
m_timer->SetLabel(_("None"));
|
||||
} else {
|
||||
wxString text;
|
||||
text.Printf(wxT("%u/%u"), timer, timeout);
|
||||
m_timer->SetLabel(text);
|
||||
}
|
||||
|
||||
unsigned int count = data.getUserCount();
|
||||
for (unsigned int i = 0U; i < count; i++) {
|
||||
CRemoteControlStarNetUser& user = data.getUser(i);
|
||||
|
||||
wxString callsign = user.getCallsign();
|
||||
timer = user.getTimer();
|
||||
timeout = user.getTimeout();
|
||||
|
||||
m_list->InsertItem(0L, callsign);
|
||||
|
||||
if (timeout == 0U) {
|
||||
m_list->SetItem(0L, 1, _("None"));
|
||||
} else {
|
||||
wxString text;
|
||||
text.Printf(wxT("%u/%u"), timer, timeout);
|
||||
m_list->SetItem(0L, 1, text);
|
||||
}
|
||||
}
|
||||
|
||||
if (count > 0U)
|
||||
m_logoffAll->Enable();
|
||||
else
|
||||
m_logoffAll->Disable();
|
||||
}
|
||||
|
||||
void CRemoteControlStarNetPanel::onClick(wxListEvent& event)
|
||||
{
|
||||
long n = event.GetIndex();
|
||||
if (n < 0) {
|
||||
m_chosen.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
m_chosen = m_list->GetItemText(n);
|
||||
|
||||
PopupMenu(m_menu);
|
||||
}
|
||||
|
||||
void CRemoteControlStarNetPanel::onRefresh(wxCommandEvent&)
|
||||
{
|
||||
::wxGetApp().starNetRefresh(m_callsign);
|
||||
}
|
||||
|
||||
void CRemoteControlStarNetPanel::onLogoff(wxCommandEvent&)
|
||||
{
|
||||
::wxGetApp().starNetLogoff(m_callsign, m_chosen);
|
||||
}
|
||||
|
||||
void CRemoteControlStarNetPanel::onLogoffAll(wxCommandEvent&)
|
||||
{
|
||||
::wxGetApp().starNetLogoff(m_callsign, wxT("ALL "));
|
||||
}
|
||||
51
RemoteControl/RemoteControlStarNetPanel.h
Normal file
51
RemoteControl/RemoteControlStarNetPanel.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 RemoteControlStarNetPanel_H
|
||||
#define RemoteControlStarNetPanel_H
|
||||
|
||||
#include "RemoteControlStarNetGroup.h"
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/listctrl.h>
|
||||
|
||||
class CRemoteControlStarNetPanel : public wxPanel {
|
||||
public:
|
||||
CRemoteControlStarNetPanel(wxWindow* parent, int id, const wxString& callsign);
|
||||
virtual ~CRemoteControlStarNetPanel();
|
||||
|
||||
virtual void add(const CRemoteControlStarNetGroup& data);
|
||||
|
||||
virtual void onClick(wxListEvent& event);
|
||||
virtual void onRefresh(wxCommandEvent& event);
|
||||
virtual void onLogoff(wxCommandEvent& event);
|
||||
virtual void onLogoffAll(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
wxString m_callsign;
|
||||
wxListCtrl* m_list;
|
||||
wxStaticText* m_logoff;
|
||||
wxStaticText* m_timer;
|
||||
wxButton* m_logoffAll;
|
||||
wxString m_chosen;
|
||||
wxMenu* m_menu;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
#endif
|
||||
45
RemoteControl/RemoteControlStarNetUser.cpp
Normal file
45
RemoteControl/RemoteControlStarNetUser.cpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 "RemoteControlStarNetUser.h"
|
||||
|
||||
CRemoteControlStarNetUser::CRemoteControlStarNetUser(const wxString& callsign, wxUint32 timer, wxUint32 timeout) :
|
||||
m_callsign(callsign),
|
||||
m_timer((unsigned int)timer),
|
||||
m_timeout((unsigned int)timeout)
|
||||
{
|
||||
}
|
||||
|
||||
CRemoteControlStarNetUser::~CRemoteControlStarNetUser()
|
||||
{
|
||||
}
|
||||
|
||||
wxString CRemoteControlStarNetUser::getCallsign() const
|
||||
{
|
||||
return m_callsign;
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlStarNetUser::getTimer() const
|
||||
{
|
||||
return m_timer;
|
||||
}
|
||||
|
||||
unsigned int CRemoteControlStarNetUser::getTimeout() const
|
||||
{
|
||||
return m_timeout;
|
||||
}
|
||||
39
RemoteControl/RemoteControlStarNetUser.h
Normal file
39
RemoteControl/RemoteControlStarNetUser.h
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (C) 2011 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 RemoteControlStarNetUser_H
|
||||
#define RemoteControlStarNetUser_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
class CRemoteControlStarNetUser {
|
||||
public:
|
||||
CRemoteControlStarNetUser(const wxString& callsign, wxUint32 timer, wxUint32 timeout);
|
||||
~CRemoteControlStarNetUser();
|
||||
|
||||
wxString getCallsign() const;
|
||||
unsigned int getTimer() const;
|
||||
unsigned int getTimeout() const;
|
||||
|
||||
private:
|
||||
wxString m_callsign;
|
||||
unsigned int m_timer;
|
||||
unsigned int m_timeout;
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue