cddbevnt.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef NULLSOFT_CDDB_EVENT_MANAGER_HEADER
  2. #define NULLSOFT_CDDB_EVENT_MANAGER_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <windows.h>
  7. // callbacks
  8. typedef void (CALLBACK *CDDB_CMDCOMPLETED)(LONG /*lCommandCode*/, HRESULT /*hCommandResult*/, VARIANT* /*pCommandData*/, ULONG_PTR /*user*/);
  9. typedef void (CALLBACK *CDDB_LOGMSG)(BSTR /*bstrMessage*/, ULONG_PTR /*user*/);
  10. typedef void (CALLBACK *CDDB_SRVMSG)(LONG /*lMessageCode*/, LONG /*lMessageAction*/, BSTR /*bstrMessageData*/, ULONG_PTR /*user*/);
  11. typedef void (CALLBACK *CDDB_CMDPROGRESS)(LONG /*lCommandCode*/, LONG /*lProgressCode*/, LONG /*lBytesDone*/, LONG /*lBytesTotal*/, ULONG_PTR /*user*/);
  12. // callback types
  13. #define CDDB_CB_CMDCOMPLETED 0
  14. #define CDDB_CB_CMDPROGRESS 1
  15. #define CDDB_CB_LOGMSG 2
  16. #define CDDB_CB_SRVMSG 3
  17. class CDBBEventManager : public IDispatch
  18. {
  19. public:
  20. CDBBEventManager(void);
  21. virtual ~CDBBEventManager(void);
  22. public:
  23. // *** IUnknown Methods ***
  24. STDMETHOD(QueryInterface)(REFIID riid, PVOID *ppvObject);
  25. STDMETHOD_(ULONG, AddRef)(void);
  26. STDMETHOD_(ULONG, Release)(void);
  27. // *** IDispatch Methods ***
  28. STDMETHOD (GetIDsOfNames)(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid);
  29. STDMETHOD (GetTypeInfo)(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo);
  30. STDMETHOD (GetTypeInfoCount)(unsigned int FAR * pctinfo);
  31. STDMETHOD (Invoke)(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr);
  32. protected:
  33. void OnCommandCompleted(LONG lCommandCode, HRESULT hCommandResult, VARIANT *pCommandData);
  34. void OnLogMessage(BSTR bstrMessage);
  35. void OnServerMessage(LONG lMessageCode, LONG lMessageAction, BSTR bstrMessageData);
  36. void OnCommandProgress(LONG lCommandCode, LONG lProgressCode, LONG lBytesDone, LONG lBytesTotal);
  37. public:
  38. HRESULT Advise(IUnknown *pCDDBCtrl);
  39. HRESULT Unadvise(IUnknown *pCDDBCtrl);
  40. HRESULT RegisterCallback(UINT nType, void *fnCallback);
  41. ULONG_PTR SetUserParam(ULONG_PTR userParam);
  42. protected:
  43. LONG ref;
  44. DWORD cookie;
  45. ULONG_PTR user;
  46. CDDB_CMDCOMPLETED fnCmdCompleted;
  47. CDDB_CMDPROGRESS fnCmdProgress;
  48. CDDB_LOGMSG fnLogMessage;
  49. CDDB_SRVMSG fnServerMessage;
  50. };
  51. #endif //NULLSOFT_CDDB_EVENT_MANAGER_HEADER