Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(holds): Hold timer is triggered by entry time
Resolve #416
- Loading branch information
Showing
164 changed files
with
4,872 additions
and
932 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
[submodule "third_party/googletest"] | ||
path = third_party/googletest | ||
url = git@github.com:google/googletest.git | ||
[submodule "third_party/continuable"] | ||
path = third_party/continuable | ||
url = git@github.com:Naios/continuable.git | ||
[submodule "third_party/function2"] | ||
path = third_party/function2 | ||
url = https://github.com/Naios/function2.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "ApiConfigurationMenuItem.h" | ||
#include "BootstrapApi.h" | ||
#include "api/ApiBootstrap.h" | ||
#include "api/ApiFactory.h" | ||
#include "bootstrap/PersistenceContainer.h" | ||
#include "euroscope/CallbackFunction.h" | ||
#include "plugin/FunctionCallEventHandler.h" | ||
#include "radarscreen/ConfigurableDisplayCollection.h" | ||
|
||
using UKControllerPlugin::Bootstrap::PersistenceContainer; | ||
using UKControllerPlugin::Euroscope::CallbackFunction; | ||
|
||
namespace UKControllerPlugin::Api { | ||
void BootstrapApi(PersistenceContainer& container) | ||
{ | ||
container.apiFactory = | ||
UKControllerPluginUtils::Api::Bootstrap(*container.settingsRepository, *container.windows); | ||
container.api = UKControllerPluginUtils::Api::BootstrapLegacy(*container.apiFactory, *container.curl); | ||
} | ||
|
||
void BootstrapConfigurationMenuItem( | ||
const PersistenceContainer& container, RadarScreen::ConfigurableDisplayCollection& configurableDisplays) | ||
{ | ||
unsigned int callbackId = container.pluginFunctionHandlers->ReserveNextDynamicFunctionId(); | ||
std::shared_ptr<ApiConfigurationMenuItem> menuItem = std::make_shared<ApiConfigurationMenuItem>( | ||
*container.apiFactory->SettingsProvider(), *container.windows, callbackId); | ||
|
||
CallbackFunction menuItemSelectedCallback( | ||
callbackId, // NOLINT | ||
"API Configuration Menu Item Selected", | ||
[menuItem](int functionId, std::string subject, RECT screenObjectArea) { | ||
menuItem->Configure(functionId, std::move(subject), screenObjectArea); | ||
}); | ||
|
||
container.pluginFunctionHandlers->RegisterFunctionCall(menuItemSelectedCallback); | ||
configurableDisplays.RegisterDisplay(menuItem); | ||
} | ||
} // namespace UKControllerPlugin::Api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
namespace UKControllerPlugin { | ||
namespace Bootstrap { | ||
struct PersistenceContainer; | ||
} // namespace Bootstrap | ||
namespace RadarScreen { | ||
class ConfigurableDisplayCollection; | ||
} // namespace RadarScreen | ||
} // namespace UKControllerPlugin | ||
|
||
namespace UKControllerPlugin::Api { | ||
void BootstrapApi(Bootstrap::PersistenceContainer& container); | ||
void BootstrapConfigurationMenuItem( | ||
const Bootstrap::PersistenceContainer& container, | ||
RadarScreen::ConfigurableDisplayCollection& configurableDisplays); | ||
} // namespace UKControllerPlugin::Api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#include "FirstTimeApiAuthorisationChecker.h" | ||
#include "api/ApiRequestFactory.h" | ||
#include "api/ApiRequestException.h" | ||
#include "api/ApiSettingsProviderInterface.h" | ||
#include "windows/WinApiInterface.h" | ||
|
||
using UKControllerPluginUtils::Api::ApiRequestException; | ||
|
||
namespace UKControllerPlugin::Api { | ||
|
||
void FirstTimeApiAuthorisationCheck( | ||
UKControllerPluginUtils::Api::ApiSettingsProviderInterface& settingsProviderInterface, | ||
Windows::WinApiInterface& windows) | ||
{ | ||
ApiRequest() | ||
.Get("authorise") | ||
.Then([]() { LogInfo("Api authorisation check was successful."); }) | ||
.Catch([&windows, &settingsProviderInterface](const ApiRequestException& exception) { | ||
LogWarning( | ||
"Api authorisation check failed, status code was " + | ||
std::to_string(static_cast<uint64_t>(exception.StatusCode()))); | ||
|
||
if (UKControllerPluginUtils::Http::IsServerError(exception.StatusCode())) { | ||
windows.OpenMessageBox( | ||
L"Server error whilst checking API authentication, some functionality may not work as " | ||
"expected. If your configuration is otherwise correct, functionality will resume when the " | ||
"service is online again.", | ||
L"UKCP API Server Error", | ||
MB_OK | MB_ICONWARNING); | ||
return; | ||
} | ||
|
||
auto messageResponse = windows.OpenMessageBox( | ||
L"API authentication failed. Please re-download your credentails from the VATSIM UK website " | ||
"and click OK to try again. If this problem persists, please contact the Web Services Department.", | ||
L"UKCP API Config Invalid", | ||
MB_OKCANCEL | MB_ICONWARNING); | ||
|
||
if (messageResponse == IDCANCEL || !settingsProviderInterface.Reload()) { | ||
LogInfo("User elected not to set API key after authentication failure"); | ||
windows.OpenMessageBox( | ||
L"You have elected not to complete API setup at this time. Some functionality of the plugin " | ||
"may not work as expected.", | ||
L"UKCP API Config Not Updated", | ||
MB_OK | MB_ICONWARNING); | ||
return; | ||
} | ||
|
||
FirstTimeApiAuthorisationCheck(settingsProviderInterface, windows); | ||
}) | ||
.Await(); | ||
} | ||
} // namespace UKControllerPlugin::Api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
|
||
namespace UKControllerPluginUtils::Api { | ||
class ApiSettingsProviderInterface; | ||
} // namespace UKControllerPluginUtils::Api | ||
|
||
namespace UKControllerPlugin::Windows { | ||
class WinApiInterface; | ||
} // namespace UKControllerPlugin::Windows | ||
namespace UKControllerPlugin::Api { | ||
void FirstTimeApiAuthorisationCheck( | ||
UKControllerPluginUtils::Api::ApiSettingsProviderInterface& settingsProviderInterface, | ||
Windows::WinApiInterface& windows); | ||
} // namespace UKControllerPlugin::Api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "FirstTimeApiConfigLoader.h" | ||
#include "api/ApiSettingsProviderInterface.h" | ||
|
||
namespace UKControllerPlugin::Api { | ||
|
||
auto LocateConfig(UKControllerPluginUtils::Api::ApiSettingsProviderInterface& settingsProvider) -> bool | ||
{ | ||
if (settingsProvider.Has()) { | ||
LogInfo("Api configuration successfully loaded"); | ||
return true; | ||
} | ||
|
||
if (!settingsProvider.Reload()) { | ||
LogInfo("First time api config load, user elected not to load config"); | ||
return false; | ||
} | ||
|
||
LogInfo("First time api config load completed"); | ||
return true; | ||
} | ||
} // namespace UKControllerPlugin::Api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
namespace UKControllerPluginUtils::Api { | ||
class ApiSettingsProviderInterface; | ||
} // namespace UKControllerPluginUtils::Api | ||
|
||
namespace UKControllerPlugin::Api { | ||
auto LocateConfig(UKControllerPluginUtils::Api::ApiSettingsProviderInterface& settingsProvider) -> bool; | ||
} // namespace UKControllerPlugin::Api |
Oops, something went wrong.