From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/replicant/http/main.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Src/replicant/http/main.cpp (limited to 'Src/replicant/http/main.cpp') diff --git a/Src/replicant/http/main.cpp b/Src/replicant/http/main.cpp new file mode 100644 index 00000000..3e146df5 --- /dev/null +++ b/Src/replicant/http/main.cpp @@ -0,0 +1,68 @@ +#include "api.h" +#include "jnetlib/jnetlib.h" +#include "component/ifc_component.h" +#include "service/ifc_servicefactory.h" +#include "foundation/export.h" +#include "nswasabi/singleton.h" +#include "HTTPPlaybackService.h" + +static SingletonService playback_factory; + +// {446BFBF6-8CE9-4697-844E-8386B5037685} +static const GUID http_component_guid = +{ 0x446bfbf6, 0x8ce9, 0x4697, { 0x84, 0x4e, 0x83, 0x86, 0xb5, 0x3, 0x76, 0x85 } }; + + +class HTTPComponent : public ifc_component +{ +public: + HTTPComponent() : ifc_component(http_component_guid) {} + int WASABICALL Component_Initialize(api_service *service); + int WASABICALL Component_RegisterServices(api_service *service); + + void WASABICALL Component_DeregisterServices(api_service *service); + int WASABICALL Component_Quit(api_service *_service_manager); +}; + +static HTTPComponent http_component; +api_service *WASABI2_API_SVC=0; +api_application *WASABI2_API_APP=0; + +int HTTPComponent::Component_Initialize(api_service *service) +{ + int ret = jnl_init(); + if (ret != NErr_Success) + return ret; + + return NErr_Success; +} + +int HTTPComponent::Component_RegisterServices(api_service *service) +{ + WASABI2_API_SVC = service; + + // get application API + WASABI2_API_SVC->GetService(&WASABI2_API_APP); + + playback_factory.Register(WASABI2_API_SVC); + return NErr_Success; +} + +void HTTPComponent::Component_DeregisterServices(api_service *service) +{ + playback_factory.Deregister(WASABI2_API_SVC); + + if (WASABI2_API_APP) + WASABI2_API_APP->Release(); +} + +int HTTPComponent::Component_Quit(api_service *_service_manager) +{ + jnl_quit(); + return NErr_Success; +} + +extern "C" DLLEXPORT ifc_component *GetWasabi2Component() +{ + return &http_component; +} -- cgit