1
0

service.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #ifndef NULLSOFT_WINAMP_OMSERVICE_IMPLEMENTATION_HEADER
  2. #define NULLSOFT_WINAMP_OMSERVICE_IMPLEMENTATION_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include "./ifc_omservice.h"
  7. #include "./ifc_omservicedetails.h"
  8. #include "./ifc_omserviceeditor.h"
  9. #include "./ifc_omservicecopier.h"
  10. #include "./ifc_omservicecommand.h"
  11. #include "./ifc_omservicehostext.h"
  12. #include "./ifc_omserviceeventmngr.h"
  13. #include "./flagTracker.h"
  14. #include <vector>
  15. #include <bfc/multipatch.h>
  16. #define MPIID_OMSVC 10
  17. #define MPIID_OMSVCDETAILS 20
  18. #define MPIID_OMSVCEDITOR 30
  19. #define MPIID_OMSVCCOPIER 40
  20. #define MPIID_OMSVCCOMMAND 50
  21. #define MPIID_OMSVCEVENTMNGR 60
  22. #define MPIID_OMSVCHOSTEXT 70
  23. class OmService : public MultiPatch<MPIID_OMSVC, ifc_omservice>,
  24. public MultiPatch<MPIID_OMSVCDETAILS, ifc_omservicedetails>,
  25. public MultiPatch<MPIID_OMSVCEDITOR, ifc_omserviceeditor>,
  26. public MultiPatch<MPIID_OMSVCCOPIER, ifc_omservicecopier>,
  27. public MultiPatch<MPIID_OMSVCCOMMAND, ifc_omservicecommand>,
  28. public MultiPatch<MPIID_OMSVCEVENTMNGR, ifc_omserviceeventmngr>,
  29. public MultiPatch<MPIID_OMSVCHOSTEXT, ifc_omservicehostext>
  30. {
  31. protected:
  32. OmService(UINT serviceId, ifc_omservicehost *serviceHost);
  33. ~OmService();
  34. public:
  35. static HRESULT CreateInstance(UINT serviceId, ifc_omservicehost *serviceHost, OmService **serviceOut);
  36. public:
  37. /* Dispatchable */
  38. size_t AddRef();
  39. size_t Release();
  40. int QueryInterface(GUID interface_guid, void **object);
  41. /* ifc_omservice */
  42. unsigned int GetId();
  43. HRESULT GetName(LPWSTR pszBuffer, UINT cchBufferMax);
  44. HRESULT GetUrl(LPWSTR pszBuffer, UINT cchBufferMax);
  45. HRESULT GetUrlDirect(LPWSTR pszBuffer, UINT cchBufferMax);
  46. HRESULT GetIcon(LPWSTR pszBuffer, UINT cchBufferMax);
  47. HRESULT GetExternal(IDispatch **ppDispatch);
  48. HRESULT GetRating(UINT *rating);
  49. HRESULT GetVersion(UINT *version);
  50. HRESULT GetFlags(UINT *flags);
  51. HRESULT SetAddress(LPCWSTR pszAddress);
  52. HRESULT GetAddress(LPWSTR pszBuffer, UINT cchBufferMax);
  53. HRESULT GetGeneration(UINT *generation);
  54. HRESULT UpdateFlags(UINT flags);
  55. /* ifc_omservicedetails */
  56. HRESULT GetDescription(LPWSTR pszBuffer, UINT cchBufferMax);
  57. HRESULT GetAuthorFirst(LPWSTR pszBuffer, UINT cchBufferMax);
  58. HRESULT GetAuthorLast(LPWSTR pszBuffer, UINT cchBufferMax);
  59. HRESULT GetUpdated(LPWSTR pszBuffer, UINT cchBufferMax);
  60. HRESULT GetPublished(LPWSTR pszBuffer, UINT cchBufferMax);
  61. HRESULT GetThumbnail(LPWSTR pszBuffer, UINT cchBufferMax);
  62. HRESULT GetScreenshot(LPWSTR pszBuffer, UINT cchBufferMax);
  63. /* ifc_omserviceeditor */
  64. HRESULT SetName(LPCWSTR pszName, BOOL utf8);
  65. HRESULT SetUrl(LPCWSTR pszUrl, BOOL utf8);
  66. HRESULT SetIcon(LPCWSTR pszPath, BOOL utf8);
  67. HRESULT SetRating(UINT nRating);
  68. HRESULT SetVersion(UINT nVersion);
  69. HRESULT SetGeneration(UINT nGeneration);
  70. HRESULT SetFlags(UINT nFlags, UINT nMask);
  71. HRESULT SetDescription(LPCWSTR pszDescription, BOOL utf8);
  72. HRESULT SetAuthorFirst(LPCWSTR pszName, BOOL utf8);
  73. HRESULT SetAuthorLast(LPCWSTR pszName, BOOL utf8);
  74. HRESULT SetUpdated(LPCWSTR pszDate, BOOL utf8);
  75. HRESULT SetPublished(LPCWSTR pszDate, BOOL utf8);
  76. HRESULT SetThumbnail(LPCWSTR pszPath, BOOL utf8);
  77. HRESULT SetScreenshot(LPCWSTR pszPath, BOOL utf8);
  78. HRESULT SetModified(UINT nFlags, UINT nMask);
  79. HRESULT GetModified(UINT *pFlags);
  80. HRESULT BeginUpdate();
  81. HRESULT EndUpdate();
  82. /* ifc_omservicecopier */
  83. HRESULT CopyTo(ifc_omservice *service, UINT *modifiedFlags);
  84. /* ifc_omservicecommand */
  85. HRESULT QueryState(HWND hBrowser, const GUID *commandGroup, UINT commandId);
  86. HRESULT Exec(HWND hBrowser, const GUID *commandGroup, UINT commandId, ULONG_PTR commandArg);
  87. /* ifc_omserviceeventmngr */
  88. HRESULT RegisterEventHandler(ifc_omserviceevent *handler);
  89. HRESULT UnregisterEventHandler(ifc_omserviceevent *handler);
  90. HRESULT Signal_ServiceChange(UINT modifiedFlags);
  91. HRESULT Signal_CommandStateChange(const GUID *commandGroup, UINT commandId);
  92. /* ifc_omservicehostext */
  93. HRESULT GetHost(ifc_omservicehost **ppHost);
  94. HRESULT SetHost(ifc_omservicehost *serviceHost);
  95. public:
  96. HRESULT SetId(UINT serviceId);
  97. private:
  98. static void CALLBACK ModifiedEvent(UINT nMark, FlagTracker *instance, ULONG_PTR user);
  99. void UnregisterAllEventHandlers();
  100. HRESULT StringCchCopyExMT(LPTSTR pszDest, size_t cchDest, LPCTSTR pszSrc, LPTSTR *ppszDestEnd, size_t *pcchRemaining, DWORD dwFlags);
  101. protected:
  102. typedef std::vector<ifc_omserviceevent*> EventList;
  103. protected:
  104. ULONG ref;
  105. UINT id;
  106. LPWSTR name;
  107. LPWSTR url;
  108. LPWSTR icon;
  109. UINT rating;
  110. UINT version;
  111. UINT flags;
  112. UINT generation;
  113. LPWSTR description;
  114. LPWSTR authorFirst;
  115. LPWSTR authorLast;
  116. LPWSTR published;
  117. LPWSTR updated;
  118. LPWSTR thumbnail;
  119. LPWSTR screenshot;
  120. FlagTracker modified;
  121. LPWSTR address;
  122. ifc_omservicehost *host;
  123. CRITICAL_SECTION lock;
  124. EventList eventList;
  125. CRITICAL_SECTION eventLock;
  126. protected:
  127. RECVS_MULTIPATCH;
  128. };
  129. #endif //NULLSOFT_WINAMP_OMSERVICE_IMPLEMENTATION_HEADER