1
0

browserEvent.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "main.h"
  2. #include "./browserEvent.h"
  3. #include "./serviceHost.h"
  4. #include "./serviceHelper.h"
  5. #include <ifc_omservice.h>
  6. #include <ifc_omserviceeventmngr.h>
  7. #include <ifc_omservicecommand.h>
  8. #include <browserView.h>
  9. #include <browserPopup.h>
  10. BrowserEvent::BrowserEvent()
  11. : ref(1)
  12. {
  13. }
  14. BrowserEvent::~BrowserEvent()
  15. {
  16. }
  17. HRESULT BrowserEvent::CreateInstance(BrowserEvent **instance)
  18. {
  19. if (NULL == instance) return E_POINTER;
  20. *instance = new BrowserEvent();
  21. if (NULL == *instance) return E_OUTOFMEMORY;
  22. return S_OK;
  23. }
  24. size_t BrowserEvent::AddRef()
  25. {
  26. return InterlockedIncrement((LONG*)&ref);
  27. }
  28. size_t BrowserEvent::Release()
  29. {
  30. if (0 == ref)
  31. return ref;
  32. LONG r = InterlockedDecrement((LONG*)&ref);
  33. if (0 == r)
  34. delete(this);
  35. return r;
  36. }
  37. int BrowserEvent::QueryInterface(GUID interface_guid, void **object)
  38. {
  39. if (NULL == object) return E_POINTER;
  40. if (IsEqualIID(interface_guid, IFC_OmBrowserEvent))
  41. *object = static_cast<ifc_ombrowserevent*>(this);
  42. else
  43. {
  44. *object = NULL;
  45. return E_NOINTERFACE;
  46. }
  47. if (NULL == *object)
  48. return E_UNEXPECTED;
  49. AddRef();
  50. return S_OK;
  51. }
  52. void BrowserEvent::WindowCreate(HWND hwnd, const GUID *windowType)
  53. {
  54. if (NULL != windowType)
  55. {
  56. if (IsEqualGUID(*windowType, WTID_BrowserView) ||
  57. IsEqualGUID(*windowType, WTID_BrowserPopup))
  58. {
  59. ifc_omservice *service;
  60. if (FALSE != BrowserControl_GetService(hwnd, &service))
  61. {
  62. UINT flags;
  63. if (SUCCEEDED(service->GetFlags(&flags)) &&
  64. 0 == ((SVCF_SPECIAL | SVCF_VALIDATED | SVCF_VERSIONCHECK) & flags))
  65. {
  66. ServiceHelper_BeginVersionCheck(service);
  67. }
  68. service->Release();
  69. }
  70. }
  71. }
  72. }
  73. void BrowserEvent::WindowClose(HWND hwnd, const GUID *windowType)
  74. {
  75. }
  76. #define CBCLASS BrowserEvent
  77. START_DISPATCH;
  78. CB(ADDREF, AddRef)
  79. CB(RELEASE, Release)
  80. CB(QUERYINTERFACE, QueryInterface)
  81. VCB(API_WINDOWCREATE, WindowCreate)
  82. VCB(API_WINDOWCLOSE, WindowClose)
  83. END_DISPATCH;
  84. #undef CBCLASS