svc_urihandler.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #pragma once
  2. #include <bfc/dispatch.h>
  3. #include <bfc/platform/types.h>
  4. #include <bfc/std_mkncc.h> // for MKnCC()
  5. class svc_urihandler : public Dispatchable
  6. {
  7. protected:
  8. svc_urihandler() {}
  9. ~svc_urihandler() {}
  10. public:
  11. static FOURCC getServiceType() { return svc_urihandler::SERVICETYPE; }
  12. enum
  13. {
  14. NOT_HANDLED = -1, // return if it's not yours
  15. HANDLED = 0, // return if it's yours, but other services might want to handle also
  16. HANDLED_EXCLUSIVE = 1, // if it's yours AND NO ONE ELSES
  17. };
  18. int ProcessFilename(const wchar_t *filename);
  19. int IsMine(const wchar_t *filename); // just like ProcessFilename but don't actually process
  20. int EnumProtocols(size_t n, wchar_t *protocol, size_t protocolCch, wchar_t *description, size_t descriptionCch); // return 0 on success
  21. int RegisterProtocol(const wchar_t *protocol, const wchar_t *winampexe);
  22. int UnregisterProtocol(const wchar_t *protocol);
  23. enum
  24. {
  25. PROCESSFILENAME=0,
  26. ISMINE=1,
  27. ENUMPROTOCOLS=2,
  28. REGISTERPROTOCOL=3,
  29. UNREGISTERPROTOCOL=4,
  30. };
  31. enum
  32. {
  33. SERVICETYPE = MK4CC('u','r','i', 'h')
  34. };
  35. };
  36. inline int svc_urihandler::ProcessFilename(const wchar_t *filename)
  37. {
  38. return _call(PROCESSFILENAME, (int)NOT_HANDLED, filename);
  39. }
  40. inline int svc_urihandler::IsMine(const wchar_t *filename)
  41. {
  42. return _call(ISMINE, (int)NOT_HANDLED, filename);
  43. }
  44. inline int svc_urihandler::EnumProtocols(size_t n, wchar_t *protocol, size_t protocolCch, wchar_t *description, size_t descriptionCch)
  45. {
  46. return _call(ENUMPROTOCOLS, (int)1, n, protocol, protocolCch, description, descriptionCch);
  47. }
  48. inline int svc_urihandler::RegisterProtocol(const wchar_t *protocol, const wchar_t *winampexe)
  49. {
  50. return _call(REGISTERPROTOCOL, (int)1, protocol, winampexe);
  51. }
  52. inline int svc_urihandler::UnregisterProtocol(const wchar_t *protocol)
  53. {
  54. return _call(UNREGISTERPROTOCOL, (int)1, protocol);
  55. }