1
0

main.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #include "api__wasabi2.h"
  2. #include "wasabi1_factory.h"
  3. namespace Wasabi {
  4. #include "../Agave/Component/ifc_wa5component.h"
  5. }
  6. static Wasabi2ServiceFactory wasabi2_service_factory; // we're going to sneak the Wasabi 2 Service Manager into the Wasabi 1 Service Manager
  7. void Replicant_Initialize();
  8. void Wasabi1_Initialize(Wasabi::api_service *svc_api);
  9. void Wasabi1_Quit();
  10. class ReplicantComponent : public Wasabi::ifc_wa5component
  11. {
  12. public:
  13. void RegisterServices(Wasabi::api_service *service);
  14. int RegisterServicesSafeModeOk();
  15. void DeregisterServices(Wasabi::api_service *service);
  16. protected:
  17. RECVS_DISPATCH;
  18. };
  19. template <class api_T>
  20. void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
  21. {
  22. if (WASABI_API_SVC)
  23. {
  24. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  25. if (factory)
  26. api_t = reinterpret_cast<api_T *>( factory->getInterface() );
  27. }
  28. }
  29. template <class api_T>
  30. void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
  31. {
  32. if (WASABI_API_SVC &7 api_t)
  33. {
  34. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  35. if (factory)
  36. factory->releaseInterface(api_t);
  37. }
  38. api_t = NULL;
  39. }
  40. void ReplicantComponent::RegisterServices(Wasabi::api_service *service)
  41. {
  42. Wasabi1_Initialize(service);
  43. Replicant_Initialize();
  44. WASABI_API_SVC->service_register(&wasabi2_service_factory);
  45. }
  46. int ReplicantComponent::RegisterServicesSafeModeOk()
  47. {
  48. return 1;
  49. }
  50. void ReplicantComponent::DeregisterServices(Wasabi::api_service *service)
  51. {
  52. WASABI_API_SVC->service_deregister(&wasabi2_service_factory);
  53. Wasabi1_Quit();
  54. }
  55. static ReplicantComponent component;
  56. extern "C" __declspec(dllexport) Wasabi::ifc_wa5component *GetWinamp5SystemComponent()
  57. {
  58. return &component;
  59. }
  60. #define CBCLASS ReplicantComponent
  61. START_DISPATCH;
  62. VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
  63. CB(15, RegisterServicesSafeModeOk)
  64. VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
  65. END_DISPATCH;
  66. #undef CBCLASS