1
0

w5s.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "api.h"
  2. #include "w5s.h"
  3. #include "GracenoteFactory.h"
  4. #include <bfc/platform/export.h>
  5. #include <api/service/waservicefactory.h>
  6. #include "GracenoteApi.h"
  7. template <class api_T>
  8. void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
  9. {
  10. if (WASABI_API_SVC)
  11. {
  12. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  13. if (factory)
  14. api_t = reinterpret_cast<api_T *>( factory->getInterface() );
  15. }
  16. }
  17. template <class api_T>
  18. void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
  19. {
  20. if (WASABI_API_SVC && api_t)
  21. {
  22. waServiceFactory *factory = WASABI_API_SVC->service_getServiceByGuid(factoryGUID_t);
  23. if (factory)
  24. factory->releaseInterface(api_t);
  25. }
  26. api_t = NULL;
  27. }
  28. api_application *WASABI_API_APP = 0;
  29. api_service *WASABI_API_SVC = 0;
  30. api_config *AGAVE_API_CONFIG=0;
  31. api_language *WASABI_API_LNG = 0;
  32. GracenoteFactory gracenoteFactory;
  33. void WA5_Gracenote::RegisterServices(api_service *service)
  34. {
  35. WASABI_API_SVC = service;
  36. ServiceBuild(AGAVE_API_CONFIG, AgaveConfigGUID);
  37. ServiceBuild(WASABI_API_APP, applicationApiServiceGuid);
  38. ServiceBuild(WASABI_API_LNG, languageApiGUID);
  39. WASABI_API_SVC->service_register(&gracenoteFactory);
  40. }
  41. int WA5_Gracenote::RegisterServicesSafeModeOk()
  42. {
  43. return 1;
  44. }
  45. void WA5_Gracenote::DeregisterServices(api_service *service)
  46. {
  47. gracenoteApi.Close();
  48. WASABI_API_SVC->service_deregister(&gracenoteFactory);
  49. ServiceRelease(AGAVE_API_CONFIG, AgaveConfigGUID);
  50. ServiceRelease(WASABI_API_APP, applicationApiServiceGuid);
  51. ServiceRelease(WASABI_API_LNG, languageApiGUID);
  52. }
  53. static WA5_Gracenote wa5_gracenote;
  54. extern "C" DLLEXPORT ifc_wa5component *GetWinamp5SystemComponent()
  55. {
  56. return &wa5_gracenote;
  57. }
  58. #define CBCLASS WA5_Gracenote
  59. START_DISPATCH;
  60. VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
  61. CB(15, RegisterServicesSafeModeOk)
  62. VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
  63. END_DISPATCH;
  64. #undef CBCLASS