handler.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "main.h"
  2. #include "service.h"
  3. #include "navigation.h"
  4. #include "handler.h"
  5. #include "../Agave/URIHandler/svc_urihandler.h"
  6. #include <api/service/waservicefactory.h>
  7. #include "api.h"
  8. #include "../ml_online/config.h"
  9. #include "../replicant/nu/Autowide.h"
  10. int NowPlayingURIHandler::ProcessFilename(const wchar_t *filename)
  11. {
  12. if (!_wcsnicmp(filename, L"winamp://Now Playing", 20) || !_wcsnicmp(filename, L"winamp://Now%20Playing", 22))
  13. {
  14. size_t index = 0;
  15. if (filename[12] == L' ')
  16. index = 20;
  17. else
  18. index = 22;
  19. wchar_t fullUrl[1024] = L"http://client.winamp.com/nowplaying";
  20. lstrcpynW(fullUrl, AutoWide(g_config->ReadString("nowplayingurl", "http://client.winamp.com/nowplaying")), ARRAYSIZE(fullUrl));
  21. if (filename[index] != 0)
  22. {
  23. StringCchCatW(fullUrl, 1024, filename + index);
  24. }
  25. Navigation_ShowService(SERVICE_ID, fullUrl, NAVFLAG_FORCEACTIVE | NAVFLAG_ENSUREMLVISIBLE | NAVFLAG_ENSUREITEMVISIBLE);
  26. return HANDLED_EXCLUSIVE;
  27. }
  28. return NOT_HANDLED;
  29. }
  30. int NowPlayingURIHandler::IsMine(const wchar_t *filename)
  31. {
  32. if (!_wcsnicmp(filename, L"winamp://Now Playing", 20 ) || !_wcsnicmp(filename, L"winamp://Now%20Playing", 22))
  33. return HANDLED;
  34. else
  35. return NOT_HANDLED;
  36. }
  37. #define CBCLASS NowPlayingURIHandler
  38. START_DISPATCH;
  39. CB(PROCESSFILENAME, ProcessFilename);
  40. CB(ISMINE, IsMine);
  41. END_DISPATCH;
  42. #undef CBCLASS