1
0

main.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #include "api__ssdp.h"
  2. #include "foundation/export.h"
  3. #include "component/ifc_component.h"
  4. #include "nx/nxuri.h"
  5. #include "nswasabi/ReferenceCounted.h"
  6. #include "nswasabi/singleton.h"
  7. #include "SSDPAPI.h"
  8. api_service *WASABI2_API_SVC=0;
  9. api_application *WASABI2_API_APP=0;
  10. api_syscb *WASABI2_API_SYSCB=0;
  11. //api_android *WASABI2_API_ANDROID=0;
  12. SSDPAPI ssdpapi;
  13. static SingletonServiceFactory<SSDPAPI, api_ssdp> ssdp_factory;
  14. // {F47F99AB-F90F-4623-B8BE-454555A8FC79}
  15. static const GUID ssdp_component_guid =
  16. { 0xf47f99ab, 0xf90f, 0x4623, { 0xb8, 0xbe, 0x45, 0x45, 0x55, 0xa8, 0xfc, 0x79 } };
  17. class SSDPComponent : public ifc_component
  18. {
  19. public:
  20. SSDPComponent() : ifc_component(ssdp_component_guid) {}
  21. int WASABICALL Component_Initialize(api_service *service);
  22. int WASABICALL Component_RegisterServices(api_service *service);
  23. void WASABICALL Component_DeregisterServices(api_service *service);
  24. int WASABICALL Component_Quit(api_service *service);
  25. };
  26. int SSDPComponent::Component_Initialize(api_service *service)
  27. {
  28. WASABI2_API_SVC = service;
  29. int ret = jnl_init();
  30. if (ret != NErr_Success)
  31. {
  32. return ret;
  33. }
  34. return NErr_Success;
  35. }
  36. int SSDPComponent::Component_RegisterServices(api_service *service)
  37. {
  38. WASABI2_API_SVC = service;
  39. if (WASABI2_API_SVC)
  40. {
  41. WASABI2_API_SVC->GetService(&WASABI2_API_APP);
  42. WASABI2_API_SVC->GetService(&WASABI2_API_SYSCB);
  43. //WASABI2_API_SVC->GetService(&WASABI2_API_ANDROID);
  44. }
  45. ssdpapi.Initialize();
  46. ssdp_factory.Register(WASABI2_API_SVC, &ssdpapi);
  47. return NErr_Success;
  48. }
  49. void SSDPComponent::Component_DeregisterServices(api_service *service)
  50. {
  51. if (WASABI2_API_SVC)
  52. WASABI2_API_SVC->Release();
  53. if (WASABI2_API_APP)
  54. WASABI2_API_APP->Release();
  55. if (WASABI2_API_SYSCB)
  56. WASABI2_API_SYSCB->Release();
  57. //if (WASABI2_API_ANDROID)
  58. // WASABI2_API_ANDROID->Release();
  59. ssdp_factory.Deregister(WASABI2_API_SVC);
  60. }
  61. int SSDPComponent::Component_Quit(api_service *_service_manager)
  62. {
  63. jnl_quit();
  64. return NErr_Success;
  65. }
  66. static SSDPComponent component;
  67. extern "C" DLLEXPORT ifc_component *GetWasabi2Component()
  68. {
  69. return &component;
  70. }