Skip to content

Commit

Permalink
Merge pull request #3 from ogruetzmann/Development
Browse files Browse the repository at this point in the history
v 1.3.6e32
  • Loading branch information
ogruetzmann committed Jun 8, 2016
2 parents 2169917 + 527c8ef commit d31df39
Show file tree
Hide file tree
Showing 20 changed files with 392 additions and 286 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,6 @@ FakesAssemblies/
*.opt
/ModeS.VC.VC.opendb
/ModeS.VC.db
/ModeS/version.txt
/ModeS/SectorFileProviderDescriptor.txt
/ModeS/euroscope_sector_providers.txt
6 changes: 4 additions & 2 deletions ModeS.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ModeS", "ModeS\ModeS.vcxproj", "{26DEB76D-3967-4550-80CE-5C9DAAFAA1FC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{18F730C8-CD88-4712-992B-1049ADAFE933}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand Down
25 changes: 25 additions & 0 deletions ModeS/Helpers.cpp
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
#include "stdafx.h"
#include "Helpers.h"

std::string LoadUpdateString(PluginData p)
{
const std::string AGENT { "EuroScopeModeS/" + std::string { p.PLUGIN_VERSION } };
HINTERNET connect = InternetOpen(AGENT.c_str(), INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
if (!connect) {
throw error { "Connection Failed. Error: " + std::to_string(GetLastError()) };
}

HINTERNET OpenAddress = InternetOpenUrl(connect, p.UPDATE_URL, NULL, 0, INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0);
if (!OpenAddress) {
InternetCloseHandle(connect);
throw error { "Failed to load URL. Error: " + std::to_string(GetLastError()) };
}

char DataReceived[256];
DWORD NumberOfBytesRead { 0 };
std::string answer;
while (InternetReadFile(OpenAddress, DataReceived, 256, &NumberOfBytesRead) && NumberOfBytesRead)
answer.append(DataReceived, NumberOfBytesRead);

InternetCloseHandle(OpenAddress);
InternetCloseHandle(connect);
return answer;
}
76 changes: 34 additions & 42 deletions ModeS/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,49 @@
#include <vector>
#include <string>
#include <sstream>
#include <iomanip>
#include <EuroScopePlugIn.h>
#include <exception>
#include <WinInet.h>
#include "version.h"

inline bool startsWith(const char *pre, const char *str)
{
size_t lenpre = strlen(pre),
lenstr = strlen(str);
return lenstr < lenpre ? false : strncmp(pre, str, lenpre) == 0;
}
std::string LoadUpdateString(PluginData p);

inline bool isAcModeS(EuroScopePlugIn::CFlightPlan FlightPlan, std::vector<std::string>& EQUIPEMENT_CODES)
inline std::vector<std::string> split(const std::string & s, char delim)
{
std::string transponder_type { FlightPlan.GetFlightPlanData().GetCapibilities() };
for (auto &code : EQUIPEMENT_CODES) {
if (transponder_type == code) {
return true;
}
}
return false;
}
std::istringstream ss(s);
std::string item;
std::vector<std::string> elems;

inline bool isApModeS(std::string icao, std::vector<std::string>& ICAO_MODES)
{
for (auto& zone : ICAO_MODES) {
if (startsWith(zone.c_str(), icao.c_str())) {
return true;
}
}
return false;
while (std::getline(ss, item, delim))
elems.push_back(item);
return elems;
}

inline std::string padWithZeros(int padding, int s)
class modesexception
: public std::exception
{
std::stringstream ss;
ss << std::setfill('0') << std::setw(padding) << s;
return ss.str();
}
public:
explicit modesexception(std::string & what) : std::exception { what.c_str() } {}
virtual inline const long icon() const = 0;
};

inline std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems)
class error
: public modesexception
{
std::stringstream ss(s);
std::string item;
while (std::getline(ss, item, delim)) {
elems.push_back(item);
public:
explicit error(std::string && what) : modesexception { what } {}
inline const long icon() const
{
return MB_ICONERROR;
}
return elems;
}
};

inline std::vector<std::string> split(const std::string &s, char delim)
class warning
: public modesexception
{
std::vector<std::string> elems;
split(s, delim, elems);
return elems;
}
public:
explicit warning(std::string && what) : modesexception { what } {}
inline const long icon() const
{
return MB_ICONWARNING;
}
};
28 changes: 0 additions & 28 deletions ModeS/HttpHelper.cpp

This file was deleted.

7 changes: 0 additions & 7 deletions ModeS/HttpHelper.h

This file was deleted.

21 changes: 7 additions & 14 deletions ModeS/ModeS.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
#include "stdafx.h"
#include "ModeS.h"
#include "ModeS2.h"
#include "EuroScopePlugIn.h"


CModeS * gpMyPlugin = NULL;
CModeS * gpMyPlugin = NULL;

//---EuroScopePlugInInit-----------------------------------------------

void __declspec (dllexport) EuroScopePlugInInit(EuroScopePlugIn::CPlugIn ** ppPlugInInstance)
void __declspec (dllexport) EuroScopePlugInInit(EuroScopePlugIn::CPlugIn ** ppPlugInInstance)
{
//AFX_MANAGE_STATE(AfxGetStaticModuleState())

// create the instance
* ppPlugInInstance = gpMyPlugin = new CModeS();
// create the instance
*ppPlugInInstance = gpMyPlugin = new CModeS();
}


//---EuroScopePlugInExit-----------------------------------------------

void __declspec (dllexport) EuroScopePlugInExit(void)
void __declspec (dllexport) EuroScopePlugInExit()
{
//AFX_MANAGE_STATE(AfxGetStaticModuleState())

// delete the instance
delete gpMyPlugin;
// delete the instance
delete gpMyPlugin;
}
2 changes: 2 additions & 0 deletions ModeS/ModeS.h
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#pragma once
#include "EuroScopePlugIn.h"
#include "ModeS2.h"
11 changes: 7 additions & 4 deletions ModeS/ModeS.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<CodeAnalysisRuleSet>MixedRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
Expand All @@ -54,7 +55,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_USRDLL;CURL_STATICLIB;CURL_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>C:\Users\Olli\Documents\GitHub\ModeS\lib\include;C:\Users\Olli\Documents\GitHub\ModeS\lib\include\curl</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>C:\Users\Olli\Documents\GitHub\ModeS\lib\include</AdditionalIncludeDirectories>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
</ClCompile>
<Link>
Expand Down Expand Up @@ -84,7 +85,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;_USRDLL;CURL_STATICLIB;CURL_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
<AdditionalIncludeDirectories>C:\Users\Olli\Documents\GitHub\ModeS\lib\include;C:\Users\Olli\Documents\GitHub\ModeS\lib\include\curl</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>C:\Users\Olli\Documents\GitHub\ModeS\lib\include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -95,6 +96,7 @@
</ModuleDefinitionFile>
<AdditionalDependencies>EuroScopePlugInDll.lib;WinInet.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>C:\Users\Olli\Documents\GitHub\ModeS\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<Profile>true</Profile>
</Link>
<Midl>
<MkTypLibCompatible>false</MkTypLibCompatible>
Expand All @@ -108,20 +110,21 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Helpers.cpp" />
<ClCompile Include="HttpHelper.cpp" />
<ClCompile Include="ModeS.cpp" />
<ClCompile Include="ModeS2.cpp" />
<ClCompile Include="ModeSCodes.cpp" />
<ClCompile Include="ModeSDisplay.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="version.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Helpers.h" />
<ClInclude Include="HttpHelper.h" />
<ClInclude Include="ModeS.h" />
<ClInclude Include="ModeS2.h" />
<ClInclude Include="ModeSCodes.h" />
<ClInclude Include="ModeSDisplay.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
Expand Down
11 changes: 7 additions & 4 deletions ModeS/ModeS.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@
<ClCompile Include="ModeS2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="HttpHelper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ModeSDisplay.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Helpers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ModeSCodes.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="version.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ModeS.h">
Expand All @@ -56,7 +59,7 @@
<ClInclude Include="version.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="HttpHelper.h">
<ClInclude Include="ModeSCodes.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
Expand Down
Loading

0 comments on commit d31df39

Please sign in to comment.