1
0

SecurityCOM.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #include "SecurityCOM.h"
  2. #include "JSAPI2_Security.h"
  3. #include "JSAPI.h"
  4. enum
  5. {
  6. DISP_SECURITY_SETACTIONAUTHORIZATION = 777,
  7. };
  8. #define CHECK_ID(str, id)\
  9. if (CSTR_EQUAL == CompareStringW(lcid, NORM_IGNORECASE, rgszNames[i], -1, L##str, -1))\
  10. { rgdispid[i] = id; continue; }
  11. HRESULT SecurityCOM::GetIDsOfNames(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid)
  12. {
  13. bool unknowns = false;
  14. for (unsigned int i = 0;i != cNames;i++)
  15. {
  16. CHECK_ID("SetActionAuthorization", DISP_SECURITY_SETACTIONAUTHORIZATION )
  17. rgdispid[i] = DISPID_UNKNOWN;
  18. unknowns = true;
  19. }
  20. if (unknowns)
  21. return DISP_E_UNKNOWNNAME;
  22. else
  23. return S_OK;
  24. }
  25. HRESULT SecurityCOM::GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo)
  26. {
  27. return E_NOTIMPL;
  28. }
  29. HRESULT SecurityCOM::GetTypeInfoCount(unsigned int FAR * pctinfo)
  30. {
  31. return E_NOTIMPL;
  32. }
  33. HRESULT SecurityCOM::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr)
  34. {
  35. switch (dispid)
  36. {
  37. case DISP_SECURITY_SETACTIONAUTHORIZATION:
  38. {
  39. JSAPI_VERIFY_PARAMCOUNT_OPTIONAL(pdispparams, 2, 4);
  40. JSAPI_VERIFY_PARAMTYPE(pdispparams, 1, VT_BSTR, puArgErr);
  41. const wchar_t *key = JSAPI_PARAM(pdispparams, 1).bstrVal;
  42. switch(JSAPI_NUM_PARAMS(pdispparams))
  43. {
  44. case 2: // key and authorization
  45. JSAPI2::security.SetActionAuthorization(key, 0, 0, JSAPI_PARAM(pdispparams, 2).lVal);
  46. break;
  47. case 3: // key, group and authorization
  48. JSAPI2::security.SetActionAuthorization(key, JSAPI_PARAM(pdispparams, 2).bstrVal, 0, JSAPI_PARAM(pdispparams, 3).lVal);
  49. break;
  50. case 4: // key, group, action and authorization
  51. JSAPI2::security.SetActionAuthorization(key, JSAPI_PARAM(pdispparams, 2).bstrVal, JSAPI_PARAM(pdispparams, 3).bstrVal, JSAPI_PARAM(pdispparams, 4).lVal);
  52. break;
  53. }
  54. return S_OK;
  55. }
  56. break;
  57. }
  58. return DISP_E_MEMBERNOTFOUND;
  59. }
  60. STDMETHODIMP SecurityCOM::QueryInterface(REFIID riid, PVOID *ppvObject)
  61. {
  62. if (!ppvObject)
  63. return E_POINTER;
  64. else if (IsEqualIID(riid, IID_IDispatch))
  65. *ppvObject = (IDispatch *)this;
  66. else if (IsEqualIID(riid, IID_IUnknown))
  67. *ppvObject = this;
  68. else
  69. {
  70. *ppvObject = NULL;
  71. return E_NOINTERFACE;
  72. }
  73. AddRef();
  74. return S_OK;
  75. }
  76. ULONG SecurityCOM::AddRef(void)
  77. {
  78. return 0;
  79. }
  80. ULONG SecurityCOM::Release(void)
  81. {
  82. return 0;
  83. }
  84. void SecurityCOM::SetActionAuthorization(const wchar_t *key, const wchar_t *group, const wchar_t *action, int authorization)
  85. {
  86. }