1
0

JSAPI2_svc_apicreator.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #pragma once
  2. #include <bfc/dispatch.h>
  3. #include <bfc/std_mkncc.h>
  4. #include <ocidl.h>
  5. #include "jsapi2_api_security.h"
  6. #include "JSAPI_Info.h"
  7. namespace JSAPI2
  8. {
  9. class svc_apicreator : public Dispatchable
  10. {
  11. public:
  12. enum
  13. {
  14. AUTHORIZATION_UNDEFINED = 0x0,
  15. AUTHORIZATION_ALLOW = 0x1,
  16. AUTHORIZATION_DENY = 0x2,
  17. AUTHORIZATION_MASK = 0xFFF,
  18. AUTHORIZATION_FLAG_ALWAYS = 0x1000,
  19. AUTHORIZATION_FLAG_ALWAYS_FOR_SERVICE = 0x2000,
  20. AUTHORIZATION_FLAG_GROUP_ONLY = 0x4000,
  21. };
  22. public:
  23. static FOURCC getServiceType() { return MK4CC('j','s','a','c'); }
  24. // this key is guaranteed to out-live your object, so you can just save the pointer
  25. // also, DO NOT add a reference to the info object or else you will create a circular reference
  26. IDispatch *CreateAPI(const wchar_t *name, const wchar_t *key, JSAPI::ifc_info *info);
  27. // returns new AUTHORIZATION_* enum to save to settings, or AUTHORIZATION_UNDEFINED if this isn't our API
  28. int PromptForAuthorization(HWND parent, const wchar_t *group, const wchar_t *action, const wchar_t *authorization_key, JSAPI2::api_security::AuthorizationData *data);
  29. enum
  30. {
  31. JSAPI2_SVC_APICREATOR_CREATEAPI = 0,
  32. JSAPI2_SVC_APICREATOR_PROMPTFORAUTHORIZATION = 1,
  33. };
  34. };
  35. }
  36. inline IDispatch *JSAPI2::svc_apicreator::CreateAPI(const wchar_t *name, const wchar_t *key, JSAPI::ifc_info *info)
  37. {
  38. return _call(JSAPI2_SVC_APICREATOR_CREATEAPI , (IDispatch *)0, name, key, info);
  39. }
  40. inline int JSAPI2::svc_apicreator::PromptForAuthorization(HWND parent, const wchar_t *group, const wchar_t *action, const wchar_t *authorization_key, JSAPI2::api_security::AuthorizationData *data)
  41. {
  42. return _call(JSAPI2_SVC_APICREATOR_PROMPTFORAUTHORIZATION, (int)AUTHORIZATION_UNDEFINED, parent, group, action, authorization_key, data);
  43. }