main.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "api.h"
  2. #include "jnetlib/jnetlib.h"
  3. #include "component/ifc_component.h"
  4. #include "service/ifc_servicefactory.h"
  5. #include "foundation/export.h"
  6. #include "nswasabi/singleton.h"
  7. #include "HTTPPlaybackService.h"
  8. static SingletonService<HTTPPlaybackService, svc_playback> playback_factory;
  9. // {446BFBF6-8CE9-4697-844E-8386B5037685}
  10. static const GUID http_component_guid =
  11. { 0x446bfbf6, 0x8ce9, 0x4697, { 0x84, 0x4e, 0x83, 0x86, 0xb5, 0x3, 0x76, 0x85 } };
  12. class HTTPComponent : public ifc_component
  13. {
  14. public:
  15. HTTPComponent() : ifc_component(http_component_guid) {}
  16. int WASABICALL Component_Initialize(api_service *service);
  17. int WASABICALL Component_RegisterServices(api_service *service);
  18. void WASABICALL Component_DeregisterServices(api_service *service);
  19. int WASABICALL Component_Quit(api_service *_service_manager);
  20. };
  21. static HTTPComponent http_component;
  22. api_service *WASABI2_API_SVC=0;
  23. api_application *WASABI2_API_APP=0;
  24. int HTTPComponent::Component_Initialize(api_service *service)
  25. {
  26. int ret = jnl_init();
  27. if (ret != NErr_Success)
  28. return ret;
  29. return NErr_Success;
  30. }
  31. int HTTPComponent::Component_RegisterServices(api_service *service)
  32. {
  33. WASABI2_API_SVC = service;
  34. // get application API
  35. WASABI2_API_SVC->GetService(&WASABI2_API_APP);
  36. playback_factory.Register(WASABI2_API_SVC);
  37. return NErr_Success;
  38. }
  39. void HTTPComponent::Component_DeregisterServices(api_service *service)
  40. {
  41. playback_factory.Deregister(WASABI2_API_SVC);
  42. if (WASABI2_API_APP)
  43. WASABI2_API_APP->Release();
  44. }
  45. int HTTPComponent::Component_Quit(api_service *_service_manager)
  46. {
  47. jnl_quit();
  48. return NErr_Success;
  49. }
  50. extern "C" DLLEXPORT ifc_component *GetWasabi2Component()
  51. {
  52. return &http_component;
  53. }