JSAPI2_Creator.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include "api__ml_online.h"
  2. #include "JSAPI2_Creator.h"
  3. #include "jsapi2_omcom.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 (!wcscmp(name, L"OnlineServices"))
  8. return new JSAPI2::OnlineServicesAPI(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 && !wcscmp(group, L"onlineservices"))
  15. {
  16. return JSAPI2::svc_apicreator::AUTHORIZATION_DENY;
  17. }
  18. else
  19. return JSAPI2::svc_apicreator::AUTHORIZATION_UNDEFINED;
  20. }
  21. #define CBCLASS JSAPI2_Creator
  22. START_DISPATCH;
  23. CB(JSAPI2_SVC_APICREATOR_CREATEAPI, CreateAPI);
  24. CB(JSAPI2_SVC_APICREATOR_PROMPTFORAUTHORIZATION, PromptForAuthorization);
  25. END_DISPATCH;
  26. #undef CBCLASS
  27. static JSAPI2_Creator jsapi2_svc;
  28. static const char serviceName[] = "Online Services Javascript Objects";
  29. // {4B0FA456-2B3B-4584-A96C-54765EA46448}
  30. static const GUID jsapi2_factory_guid =
  31. { 0x4b0fa456, 0x2b3b, 0x4584, { 0xa9, 0x6c, 0x54, 0x76, 0x5e, 0xa4, 0x64, 0x48 } };
  32. FOURCC JSAPI2Factory::GetServiceType()
  33. {
  34. return jsapi2_svc.getServiceType();
  35. }
  36. const char *JSAPI2Factory::GetServiceName()
  37. {
  38. return serviceName;
  39. }
  40. GUID JSAPI2Factory::GetGUID()
  41. {
  42. return jsapi2_factory_guid;
  43. }
  44. void *JSAPI2Factory::GetInterface(int global_lock)
  45. {
  46. // if (global_lock)
  47. // WASABI_API_SVC->service_lock(this, (void *)ifc);
  48. return &jsapi2_svc;
  49. }
  50. int JSAPI2Factory::SupportNonLockingInterface()
  51. {
  52. return 1;
  53. }
  54. int JSAPI2Factory::ReleaseInterface(void *ifc)
  55. {
  56. //WASABI_API_SVC->service_unlock(ifc);
  57. return 1;
  58. }
  59. const char *JSAPI2Factory::GetTestString()
  60. {
  61. return 0;
  62. }
  63. int JSAPI2Factory::ServiceNotify(int msg, int param1, int param2)
  64. {
  65. return 1;
  66. }
  67. #define CBCLASS JSAPI2Factory
  68. START_DISPATCH;
  69. CB(WASERVICEFACTORY_GETSERVICETYPE, GetServiceType)
  70. CB(WASERVICEFACTORY_GETSERVICENAME, GetServiceName)
  71. CB(WASERVICEFACTORY_GETGUID, GetGUID)
  72. CB(WASERVICEFACTORY_GETINTERFACE, GetInterface)
  73. CB(WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, SupportNonLockingInterface)
  74. CB(WASERVICEFACTORY_RELEASEINTERFACE, ReleaseInterface)
  75. CB(WASERVICEFACTORY_GETTESTSTRING, GetTestString)
  76. CB(WASERVICEFACTORY_SERVICENOTIFY, ServiceNotify)
  77. END_DISPATCH;
  78. #undef CBCLASS