1
0

JSAPI2_Creator.cpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #include "api__ml_history.h"
  2. #include "JSAPI2_Creator.h"
  3. #include "JSAPI2_HistoryAPI.h"
  4. #include "resource.h"
  5. IDispatch *JSAPI2_Creator::CreateAPI(const wchar_t *name, const wchar_t *key, JSAPI::ifc_info *info)
  6. {
  7. if (!_wcsicmp(name, L"History"))
  8. return new JSAPI2::HistoryAPI(key, info);
  9. else
  10. return 0;
  11. }
  12. int JSAPI2_Creator::PromptForAuthorization(HWND parent, const wchar_t *group, const wchar_t *action, const wchar_t *authorization_key, JSAPI2::api_security::AuthorizationData *data)
  13. {
  14. if (group && !_wcsicmp(group, L"history"))
  15. {
  16. const wchar_t *title_str = AGAVE_API_JSAPI2_SECURITY->GetAssociatedName(authorization_key);
  17. return AGAVE_API_JSAPI2_SECURITY->SecurityPrompt(parent, title_str, L"This service is requesting access to your playback history.", JSAPI2::svc_apicreator::AUTHORIZATION_FLAG_GROUP_ONLY);
  18. }
  19. else
  20. return JSAPI2::svc_apicreator::AUTHORIZATION_UNDEFINED;
  21. }
  22. #define CBCLASS JSAPI2_Creator
  23. START_DISPATCH;
  24. CB(JSAPI2_SVC_APICREATOR_CREATEAPI, CreateAPI);
  25. CB(JSAPI2_SVC_APICREATOR_PROMPTFORAUTHORIZATION, PromptForAuthorization);
  26. END_DISPATCH;
  27. #undef CBCLASS
  28. static JSAPI2_Creator jsapi2_svc;
  29. static const char serviceName[] = "History Javascript Objects";
  30. // {D9F59F89-82F3-446d-8CD8-6D4445094D50}
  31. static const GUID jsapi2_factory_guid =
  32. { 0xd9f59f89, 0x82f3, 0x446d, { 0x8c, 0xd8, 0x6d, 0x44, 0x45, 0x9, 0x4d, 0x50 } };
  33. FOURCC JSAPI2Factory::GetServiceType()
  34. {
  35. return jsapi2_svc.getServiceType();
  36. }
  37. const char *JSAPI2Factory::GetServiceName()
  38. {
  39. return serviceName;
  40. }
  41. GUID JSAPI2Factory::GetGUID()
  42. {
  43. return jsapi2_factory_guid;
  44. }
  45. void *JSAPI2Factory::GetInterface(int global_lock)
  46. {
  47. // if (global_lock)
  48. // plugin.service->service_lock(this, (void *)ifc);
  49. return &jsapi2_svc;
  50. }
  51. int JSAPI2Factory::SupportNonLockingInterface()
  52. {
  53. return 1;
  54. }
  55. int JSAPI2Factory::ReleaseInterface(void *ifc)
  56. {
  57. //plugin.service->service_unlock(ifc);
  58. return 1;
  59. }
  60. const char *JSAPI2Factory::GetTestString()
  61. {
  62. return 0;
  63. }
  64. int JSAPI2Factory::ServiceNotify(int msg, int param1, int param2)
  65. {
  66. return 1;
  67. }
  68. #define CBCLASS JSAPI2Factory
  69. START_DISPATCH;
  70. CB(WASERVICEFACTORY_GETSERVICETYPE, GetServiceType)
  71. CB(WASERVICEFACTORY_GETSERVICENAME, GetServiceName)
  72. CB(WASERVICEFACTORY_GETGUID, GetGUID)
  73. CB(WASERVICEFACTORY_GETINTERFACE, GetInterface)
  74. CB(WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, SupportNonLockingInterface)
  75. CB(WASERVICEFACTORY_RELEASEINTERFACE, ReleaseInterface)
  76. CB(WASERVICEFACTORY_GETTESTSTRING, GetTestString)
  77. CB(WASERVICEFACTORY_SERVICENOTIFY, ServiceNotify)
  78. END_DISPATCH;
  79. #undef CBCLASS