JSAPI_Info.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include <bfc/dispatch.h>
  3. namespace JSAPI
  4. {
  5. class ifc_info_callback : public Dispatchable
  6. {
  7. public:
  8. /* this is called when an action is denied by the user */
  9. void OnSecurity(const wchar_t *group, const wchar_t *action, int authorization);
  10. };
  11. /*
  12. JSAPI and JSAPI2's IDispatch object will also have this interface
  13. (retrieve via IWasabiDispatchable)
  14. It includes information about the API
  15. Allows you to associate an HWND with the API (for dialog parenting, etc)
  16. And register for callbacks to get notifications about things like security denial
  17. */
  18. // this GUID is an interface GUID, NOT a service GUID
  19. // {64DE905A-8C95-4427-AACE-72A42EB2DE73}
  20. static const GUID IID_JSAPI_ifc_info =
  21. { 0x64de905a, 0x8c95, 0x4427, { 0xaa, 0xce, 0x72, 0xa4, 0x2e, 0xb2, 0xde, 0x73 } };
  22. class ifc_info : public Dispatchable
  23. {
  24. public:
  25. static GUID GetIID() { return IID_JSAPI_ifc_info; }
  26. const wchar_t *GetUserAgent();
  27. /* associates an HWND with this object
  28. mainly used for parenting dialog boxes */
  29. void SetHWND(HWND hwnd);
  30. HWND GetHWND();
  31. /* registers for callbacks */
  32. void RegisterCallback(ifc_info_callback *callback);
  33. void UnregisterCallback(ifc_info_callback *callback);
  34. /* associates a name with this object */
  35. void SetName(const wchar_t *name);
  36. const wchar_t *GetName();
  37. /* adds to the API (for this object only for JSAPI2, globally for JSAPI1 because it's a singleton */
  38. int AddAPI(const wchar_t *name, IDispatch *dispatch);
  39. enum
  40. {
  41. JSAPI_IFC_INFO_GETUSERAGENT = 0,
  42. JSAPI_IFC_INFO_SETHWND = 1,
  43. JSAPI_IFC_INFO_GETHWND = 2,
  44. JSAPI_IFC_INFO_REGISTERCALLBACK = 3,
  45. JSAPI_IFC_INFO_UNREGISTERCALLBACK = 4,
  46. JSAPI_IFC_INFO_SETNAME = 5,
  47. JSAPI_IFC_INFO_GETNAME = 6,
  48. JSAPI_IFC_INFO_ADDAPI = 7,
  49. };
  50. };
  51. }
  52. inline const wchar_t *JSAPI::ifc_info::GetUserAgent()
  53. {
  54. return _call(JSAPI_IFC_INFO_GETUSERAGENT, (const wchar_t *)0);
  55. }
  56. inline void JSAPI::ifc_info::SetHWND(HWND hwnd)
  57. {
  58. _voidcall(JSAPI_IFC_INFO_SETHWND, hwnd);
  59. }
  60. inline HWND JSAPI::ifc_info::GetHWND()
  61. {
  62. return _call(JSAPI_IFC_INFO_GETHWND, (HWND)0);
  63. }
  64. inline void JSAPI::ifc_info::RegisterCallback(ifc_info_callback *callback)
  65. {
  66. _voidcall(JSAPI_IFC_INFO_REGISTERCALLBACK, callback);
  67. }
  68. inline void JSAPI::ifc_info::UnregisterCallback(ifc_info_callback *callback)
  69. {
  70. _voidcall(JSAPI_IFC_INFO_UNREGISTERCALLBACK, callback);
  71. }
  72. inline void JSAPI::ifc_info::SetName(const wchar_t *name)
  73. {
  74. _voidcall(JSAPI_IFC_INFO_SETNAME, name);
  75. }
  76. inline const wchar_t *JSAPI::ifc_info::GetName()
  77. {
  78. return _call(JSAPI_IFC_INFO_GETNAME, (const wchar_t *)0);
  79. }
  80. inline int JSAPI::ifc_info::AddAPI(const wchar_t *name, IDispatch *dispatch)
  81. {
  82. return _call(JSAPI_IFC_INFO_ADDAPI, (int)1, name, dispatch);
  83. }