1
0

JSAPI2_Creator.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #include "JSAPI2_Creator.h"
  2. #include "JSAPI2_Playlists.h"
  3. #include "api__playlist.h"
  4. #include "main.h"
  5. #include "resource.h"
  6. IDispatch *JSAPI2_Creator::CreateAPI(const wchar_t *name, const wchar_t *key, JSAPI::ifc_info *info)
  7. {
  8. if (!wcscmp(name, L"Playlists"))
  9. return new JSAPI2::PlaylistsAPI(key, info);
  10. else
  11. return 0;
  12. }
  13. int JSAPI2_Creator::PromptForAuthorization(HWND parent, const wchar_t *group, const wchar_t *action, const wchar_t *authorization_key, JSAPI2::api_security::AuthorizationData *data)
  14. {
  15. if (group && !wcscmp(group, L"playlists"))
  16. {
  17. const wchar_t *title_str = AGAVE_API_JSAPI2_SECURITY->GetAssociatedName(authorization_key);
  18. if (action && !wcscmp(action, L"read"))
  19. {
  20. return AGAVE_API_JSAPI2_SECURITY->SecurityPrompt(parent, title_str, L"This service is requesting access to the playlists in your Library.", 0);
  21. }
  22. else if (action && !wcscmp(action, L"write"))
  23. {
  24. return AGAVE_API_JSAPI2_SECURITY->SecurityPrompt(parent, title_str, L"This service is trying modify one of the playlists in your Library.", 0);
  25. }
  26. }
  27. return JSAPI2::svc_apicreator::AUTHORIZATION_UNDEFINED;
  28. }
  29. #define CBCLASS JSAPI2_Creator
  30. START_DISPATCH;
  31. CB(JSAPI2_SVC_APICREATOR_CREATEAPI, CreateAPI);
  32. CB(JSAPI2_SVC_APICREATOR_PROMPTFORAUTHORIZATION, PromptForAuthorization);
  33. END_DISPATCH;
  34. #undef CBCLASS
  35. static JSAPI2_Creator jsapi2_svc;
  36. static const char serviceName[] = "Playlist Javascript Objects";
  37. // {CF057176-A819-4bc5-8723-6C072BB28BAA}
  38. static const GUID jsapi2_factory_guid =
  39. { 0xcf057176, 0xa819, 0x4bc5, { 0x87, 0x23, 0x6c, 0x7, 0x2b, 0xb2, 0x8b, 0xaa } };
  40. FOURCC JSAPI2Factory::GetServiceType()
  41. {
  42. return jsapi2_svc.getServiceType();
  43. }
  44. const char *JSAPI2Factory::GetServiceName()
  45. {
  46. return serviceName;
  47. }
  48. GUID JSAPI2Factory::GetGUID()
  49. {
  50. return jsapi2_factory_guid;
  51. }
  52. void *JSAPI2Factory::GetInterface(int global_lock)
  53. {
  54. // if (global_lock)
  55. // WASABI_API_SVC->service_lock(this, (void *)ifc);
  56. return &jsapi2_svc;
  57. }
  58. int JSAPI2Factory::SupportNonLockingInterface()
  59. {
  60. return 1;
  61. }
  62. int JSAPI2Factory::ReleaseInterface(void *ifc)
  63. {
  64. //WASABI_API_SVC->service_unlock(ifc);
  65. return 1;
  66. }
  67. const char *JSAPI2Factory::GetTestString()
  68. {
  69. return 0;
  70. }
  71. int JSAPI2Factory::ServiceNotify(int msg, int param1, int param2)
  72. {
  73. return 1;
  74. }
  75. #define CBCLASS JSAPI2Factory
  76. START_DISPATCH;
  77. CB(WASERVICEFACTORY_GETSERVICETYPE, GetServiceType)
  78. CB(WASERVICEFACTORY_GETSERVICENAME, GetServiceName)
  79. CB(WASERVICEFACTORY_GETGUID, GetGUID)
  80. CB(WASERVICEFACTORY_GETINTERFACE, GetInterface)
  81. CB(WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, SupportNonLockingInterface)
  82. CB(WASERVICEFACTORY_RELEASEINTERFACE, ReleaseInterface)
  83. CB(WASERVICEFACTORY_GETTESTSTRING, GetTestString)
  84. CB(WASERVICEFACTORY_SERVICENOTIFY, ServiceNotify)
  85. END_DISPATCH;
  86. #undef CBCLASS