api__wasabi2.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "Winamp5ArtworkManager.h"
  2. #include "main.h"
  3. #include "api__wasabi2.h"
  4. #include "application.h"
  5. #include <Wasabi/Wasabi.h>
  6. #include <nswasabi/singleton.h>
  7. #include <component/win/ComponentManager.h>
  8. #include <Replicant/metadata/metadata.h>
  9. #include <Shlwapi.h>
  10. Application application;
  11. static ComponentManager component_manager;
  12. static SingletonServiceFactory<Application, api_application> application_factory;
  13. static SingletonService<Winamp5ArtworkManager, api_artwork> artwork_factory;
  14. static void AddComponents(const wchar_t *directory)
  15. {
  16. nx_uri_t uri_directory;
  17. if (NXURICreateWithUTF16(&uri_directory, directory) == NErr_Success)
  18. {
  19. component_manager.AddDirectory(uri_directory);
  20. NXURIRelease(uri_directory);
  21. }
  22. }
  23. void Replicant_Initialize()
  24. {
  25. application.Init();
  26. if (Wasabi_Init() == NErr_Success)
  27. {
  28. application_factory.Register(WASABI2_API_SVC, WASABI2_API_APP);
  29. artwork_factory.Register(WASABI2_API_SVC);
  30. component_manager.SetServiceAPI(WASABI2_API_SVC);
  31. Replicant_Metadata_Initialize(WASABI2_API_SVC);
  32. wchar_t PROG_DIR[MAX_PATH] = {0};
  33. GetModuleFileName(0, PROG_DIR, MAX_PATH);
  34. PathRemoveFileSpec(PROG_DIR);
  35. PathAppend(PROG_DIR, L"Components");
  36. AddComponents(PROG_DIR);
  37. component_manager.Load();
  38. }
  39. }