JSAPI2_TransportAPI.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. #include "JSAPI2_TransportAPI.h"
  2. #include "JSAPI2_Security.h"
  3. #include "JSAPI2_CallbackManager.h"
  4. #include "main.h"
  5. #include "JSAPI.h"
  6. #include "JSAPI_CallbackParameters.h"
  7. #define SCRIPT_E_REPORTED 0x80020101
  8. JSAPI2::TransportAPI::TransportAPI(const wchar_t *_key, JSAPI::ifc_info *info)
  9. {
  10. this->info = info;
  11. key = _key;
  12. refCount = 1;
  13. }
  14. JSAPI2::TransportAPI::~TransportAPI()
  15. {
  16. // just in case someone forgot
  17. JSAPI2::callbackManager.Deregister(this);
  18. size_t index = events.size();
  19. while(index--)
  20. {
  21. IDispatch *pEvent = events[index];
  22. if (NULL != pEvent)
  23. pEvent->Release();
  24. }
  25. }
  26. #define DISP_TABLE \
  27. CHECK_ID(Prev)\
  28. CHECK_ID(Play)\
  29. CHECK_ID(Pause)\
  30. CHECK_ID(Stop)\
  31. CHECK_ID(Next)\
  32. CHECK_ID(shuffle)\
  33. CHECK_ID(repeat)\
  34. CHECK_ID(position)\
  35. CHECK_ID(length)\
  36. CHECK_ID(url)\
  37. CHECK_ID(title)\
  38. CHECK_ID(playing)\
  39. CHECK_ID(paused)\
  40. CHECK_ID(GetMetadata)\
  41. CHECK_ID(RegisterForEvents)\
  42. CHECK_ID(UnregisterFromEvents)\
  43. #define CHECK_ID(str) JSAPI_DISP_ENUMIFY(str),
  44. enum {
  45. DISP_TABLE
  46. };
  47. #undef CHECK_ID
  48. #define CHECK_ID(str)\
  49. if (CSTR_EQUAL == CompareStringW(lcid, NORM_IGNORECASE, rgszNames[i], -1, L## #str, -1))\
  50. { rgdispid[i] = JSAPI_DISP_ENUMIFY(str); continue; }
  51. HRESULT JSAPI2::TransportAPI::GetIDsOfNames(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid)
  52. {
  53. bool unknowns = false;
  54. for (unsigned int i = 0;i != cNames;i++)
  55. {
  56. DISP_TABLE
  57. rgdispid[i] = DISPID_UNKNOWN;
  58. unknowns = true;
  59. }
  60. if (unknowns)
  61. return DISP_E_UNKNOWNNAME;
  62. else
  63. return S_OK;
  64. }
  65. HRESULT JSAPI2::TransportAPI::GetTypeInfo(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo)
  66. {
  67. return E_NOTIMPL;
  68. }
  69. HRESULT JSAPI2::TransportAPI::GetTypeInfoCount(unsigned int FAR * pctinfo)
  70. {
  71. return E_NOTIMPL;
  72. }
  73. HRESULT JSAPI2::TransportAPI::ButtonPress(WPARAM button, const wchar_t *action, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  74. {
  75. JSAPI_VERIFY_METHOD(wFlags);
  76. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 0);
  77. JSAPI_INIT_RESULT(pvarResult, VT_BOOL);
  78. switch (security.GetActionAuthorization(L"transport", action, key, info, JSAPI2::api_security::ACTION_PROMPT))
  79. {
  80. case JSAPI2::api_security::ACTION_DISALLOWED:
  81. JSAPI_SET_RESULT(pvarResult, boolVal, VARIANT_FALSE);
  82. break;
  83. case JSAPI2::api_security::ACTION_ALLOWED:
  84. JSAPI_SET_RESULT(pvarResult, boolVal, VARIANT_TRUE);
  85. SendMessageW(hMainWindow, WM_COMMAND, button, 0);
  86. break;
  87. }
  88. return S_OK;
  89. }
  90. HRESULT JSAPI2::TransportAPI::Prev(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  91. {
  92. return ButtonPress(WINAMP_BUTTON1, L"controls", wFlags, pdispparams, pvarResult, puArgErr);
  93. }
  94. HRESULT JSAPI2::TransportAPI::Play(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  95. {
  96. return ButtonPress(WINAMP_BUTTON2, L"controls", wFlags, pdispparams, pvarResult, puArgErr);
  97. }
  98. HRESULT JSAPI2::TransportAPI::Pause(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  99. {
  100. return ButtonPress(WINAMP_BUTTON3, L"controls", wFlags, pdispparams, pvarResult, puArgErr);
  101. }
  102. HRESULT JSAPI2::TransportAPI::Stop(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  103. {
  104. return ButtonPress(WINAMP_BUTTON4, L"controls", wFlags, pdispparams, pvarResult, puArgErr);
  105. }
  106. HRESULT JSAPI2::TransportAPI::Next(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  107. {
  108. return ButtonPress(WINAMP_BUTTON5, L"controls", wFlags, pdispparams, pvarResult, puArgErr);
  109. }
  110. HRESULT JSAPI2::TransportAPI::shuffle(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  111. {
  112. if (wFlags & DISPATCH_PROPERTYPUT)
  113. {
  114. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 1);
  115. JSAPI_VERIFY_PARAMTYPE(pdispparams, 1, VT_BOOL, puArgErr);
  116. switch (security.GetActionAuthorization(L"transport", L"controls", key, info, JSAPI2::api_security::ACTION_PROMPT))
  117. {
  118. case JSAPI2::api_security::ACTION_DISALLOWED:
  119. return S_OK;
  120. case JSAPI2::api_security::ACTION_ALLOWED:
  121. if (!!config_shuffle != JSAPI_PARAM(pdispparams, 1).lVal)
  122. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_FILE_SHUFFLE, 0);
  123. return S_OK;
  124. }
  125. }
  126. else if (wFlags & DISPATCH_PROPERTYGET)
  127. {
  128. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 0);
  129. VariantInit(pvarResult);
  130. V_VT(pvarResult) = VT_BOOL;
  131. V_BOOL(pvarResult) = (0 != config_shuffle) ? VARIANT_TRUE : VARIANT_FALSE;//(LONG)SendMessageW(hMainWindow, WM_WA_IPC, 0, IPC_GET_SHUFFLE);
  132. return S_OK;
  133. }
  134. else
  135. return DISP_E_MEMBERNOTFOUND;
  136. return E_FAIL;
  137. }
  138. HRESULT JSAPI2::TransportAPI::repeat(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  139. {
  140. if (wFlags & DISPATCH_PROPERTYPUT)
  141. {
  142. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 1);
  143. JSAPI_VERIFY_PARAMTYPE(pdispparams, 1, VT_BOOL, puArgErr);
  144. switch (security.GetActionAuthorization(L"transport", L"controls", key, info, JSAPI2::api_security::ACTION_PROMPT))
  145. {
  146. case JSAPI2::api_security::ACTION_DISALLOWED:
  147. return S_OK;
  148. case JSAPI2::api_security::ACTION_ALLOWED:
  149. if (!!config_repeat != !!JSAPI_PARAM(pdispparams, 1).boolVal)
  150. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_FILE_REPEAT, 0);
  151. return S_OK;
  152. }
  153. }
  154. else if (wFlags & DISPATCH_PROPERTYGET)
  155. {
  156. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 0);
  157. VariantInit(pvarResult);
  158. V_VT(pvarResult) = VT_BOOL;
  159. V_BOOL(pvarResult) = (0 != config_repeat) ? VARIANT_TRUE : VARIANT_FALSE;
  160. return S_OK;
  161. }
  162. else
  163. return DISP_E_MEMBERNOTFOUND;
  164. return E_FAIL;
  165. }
  166. HRESULT JSAPI2::TransportAPI::position(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  167. {
  168. if (wFlags & DISPATCH_PROPERTYPUT)
  169. {
  170. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 1);
  171. JSAPI_VERIFY_PARAMTYPE(pdispparams, 1, VT_I4, puArgErr);
  172. if (security.GetActionAuthorization(L"transport", L"controls", key, info, JSAPI2::api_security::ACTION_PROMPT) == JSAPI2::api_security::ACTION_ALLOWED)
  173. {
  174. SendMessageW(hMainWindow, WM_WA_IPC, JSAPI_PARAM(pdispparams, 1).lVal, IPC_JUMPTOTIME);
  175. }
  176. return S_OK;
  177. }
  178. else if (wFlags & DISPATCH_PROPERTYGET)
  179. {
  180. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 0);
  181. VariantInit(pvarResult);
  182. V_VT(pvarResult) = VT_I4;
  183. V_I4(pvarResult) = (LONG)SendMessageW(hMainWindow, WM_WA_IPC, 0, IPC_GETOUTPUTTIME);
  184. return S_OK;
  185. }
  186. return DISP_E_MEMBERNOTFOUND;
  187. }
  188. HRESULT JSAPI2::TransportAPI::length(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  189. {
  190. if (wFlags & DISPATCH_PROPERTYGET)
  191. {
  192. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 0);
  193. VariantInit(pvarResult);
  194. V_VT(pvarResult) = VT_I4;
  195. V_I4(pvarResult) = (LONG)SendMessageW(hMainWindow, WM_WA_IPC, 2, IPC_GETOUTPUTTIME);
  196. return S_OK;
  197. }
  198. else
  199. return DISP_E_MEMBERNOTFOUND;
  200. }
  201. HRESULT JSAPI2::TransportAPI::url(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  202. {
  203. if (wFlags & DISPATCH_PROPERTYGET)
  204. {
  205. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 0);
  206. JSAPI_INIT_RESULT(pvarResult, VT_BSTR);
  207. if (security.GetActionAuthorization(L"transport", L"metadata", key, info, JSAPI2::api_security::ACTION_PROMPT) == JSAPI2::api_security::ACTION_ALLOWED)
  208. {
  209. JSAPI_SET_RESULT(pvarResult, bstrVal, SysAllocString(FileName));
  210. }
  211. else
  212. {
  213. JSAPI_EMPTY_RESULT(pvarResult);
  214. }
  215. return S_OK;
  216. }
  217. else
  218. return DISP_E_MEMBERNOTFOUND;
  219. }
  220. HRESULT JSAPI2::TransportAPI::title(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  221. {
  222. if (wFlags & DISPATCH_PROPERTYGET)
  223. {
  224. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 0);
  225. JSAPI_INIT_RESULT(pvarResult, VT_BSTR);
  226. if (security.GetActionAuthorization(L"transport", L"metadata", key, info, JSAPI2::api_security::ACTION_PROMPT) == JSAPI2::api_security::ACTION_ALLOWED)
  227. {
  228. JSAPI_SET_RESULT(pvarResult, bstrVal, SysAllocString(FileTitle));
  229. }
  230. else
  231. {
  232. JSAPI_EMPTY_RESULT(pvarResult);
  233. }
  234. return S_OK;
  235. }
  236. else
  237. return DISP_E_MEMBERNOTFOUND;
  238. }
  239. HRESULT JSAPI2::TransportAPI::playing(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  240. {
  241. if (wFlags & DISPATCH_PROPERTYGET)
  242. {
  243. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 0);
  244. VariantInit(pvarResult);
  245. V_VT(pvarResult) = VT_BOOL;
  246. switch (security.GetActionAuthorization(L"transport", L"controls", key, info, JSAPI2::api_security::ACTION_PROMPT))
  247. {
  248. case JSAPI2::api_security::ACTION_DISALLOWED:
  249. V_BOOL(pvarResult) = VARIANT_FALSE;
  250. break;
  251. case JSAPI2::api_security::ACTION_ALLOWED:
  252. V_BOOL(pvarResult) = ::playing?VARIANT_TRUE:VARIANT_FALSE;
  253. break;
  254. }
  255. return S_OK;
  256. }
  257. else
  258. return DISP_E_MEMBERNOTFOUND;
  259. }
  260. HRESULT JSAPI2::TransportAPI::paused(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  261. {
  262. if (wFlags & DISPATCH_PROPERTYGET)
  263. {
  264. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 0);
  265. VariantInit(pvarResult);
  266. V_VT(pvarResult) = VT_BOOL;
  267. switch (security.GetActionAuthorization(L"transport", L"controls", key, info, JSAPI2::api_security::ACTION_PROMPT))
  268. {
  269. case JSAPI2::api_security::ACTION_DISALLOWED:
  270. V_BOOL(pvarResult) = VARIANT_FALSE;
  271. break;
  272. case JSAPI2::api_security::ACTION_ALLOWED:
  273. V_BOOL(pvarResult) = ::paused?VARIANT_TRUE:VARIANT_FALSE;
  274. break;
  275. }
  276. return S_OK;
  277. }
  278. else
  279. return DISP_E_MEMBERNOTFOUND;
  280. }
  281. HRESULT JSAPI2::TransportAPI::GetMetadata(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  282. {
  283. JSAPI_VERIFY_METHOD(wFlags);
  284. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 1);
  285. JSAPI_VERIFY_PARAMTYPE(pdispparams, 1, VT_BSTR, puArgErr);
  286. JSAPI_INIT_RESULT(pvarResult, VT_BSTR);
  287. if (security.GetActionAuthorization(L"transport", L"metadata", key, info, JSAPI2::api_security::ACTION_PROMPT) == JSAPI2::api_security::ACTION_ALLOWED)
  288. {
  289. wchar_t buffer[4096] = {0};
  290. extendedFileInfoStructW info;
  291. info.filename = FileName;
  292. info.metadata = JSAPI_PARAM(pdispparams, 1).bstrVal;
  293. info.ret = buffer;
  294. info.retlen = sizeof(buffer)/sizeof(*buffer);
  295. if (NULL != info.filename &&
  296. NULL != info.metadata)
  297. {
  298. if (0 == SendMessageW(hMainWindow, WM_WA_IPC, (WPARAM)&info, IPC_GET_EXTENDED_FILE_INFOW_HOOKABLE))
  299. info.ret = NULL;
  300. JSAPI_SET_RESULT(pvarResult, bstrVal, SysAllocString(info.ret));
  301. }
  302. else
  303. JSAPI_EMPTY_RESULT(pvarResult);
  304. }
  305. else
  306. {
  307. JSAPI_EMPTY_RESULT(pvarResult);
  308. }
  309. return S_OK;
  310. }
  311. HRESULT JSAPI2::TransportAPI::RegisterForEvents(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  312. {
  313. JSAPI_VERIFY_METHOD(wFlags);
  314. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 1);
  315. JSAPI_VERIFY_PARAMTYPE(pdispparams, 1, VT_DISPATCH, puArgErr);
  316. JSAPI_INIT_RESULT(pvarResult, VT_BOOL);
  317. switch (security.GetActionAuthorization(L"transport", L"events", key, info, JSAPI2::api_security::ACTION_PROMPT))
  318. {
  319. case JSAPI2::api_security::ACTION_DISALLOWED:
  320. JSAPI_SET_RESULT(pvarResult, boolVal, VARIANT_FALSE);
  321. break;
  322. case JSAPI2::api_security::ACTION_ALLOWED:
  323. {
  324. /** if this is the first time someone is registering an event
  325. ** add ourselves to the callback manager
  326. */
  327. if (events.empty())
  328. JSAPI2::callbackManager.Register(this);
  329. IDispatch *event = JSAPI_PARAM(pdispparams, 1).pdispVal;
  330. event->AddRef();
  331. // TODO: benski> not sure, but we might need to: event->AddRef();
  332. events.push_back(event);
  333. JSAPI_SET_RESULT(pvarResult, boolVal, VARIANT_TRUE);
  334. }
  335. break;
  336. }
  337. return S_OK;
  338. }
  339. HRESULT JSAPI2::TransportAPI::UnregisterFromEvents(WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, unsigned int FAR *puArgErr)
  340. {
  341. JSAPI_VERIFY_METHOD(wFlags);
  342. JSAPI_VERIFY_PARAMCOUNT(pdispparams, 1);
  343. JSAPI_VERIFY_PARAMTYPE(pdispparams, 1, VT_DISPATCH, puArgErr);
  344. IDispatch *event = JSAPI_PARAM(pdispparams, 1).pdispVal;
  345. // TODO: benski> not sure, but we might need to: event->Release();
  346. size_t index = events.size();
  347. while(index--)
  348. {
  349. if (events[index] == event)
  350. {
  351. events.erase(events.begin() + index);
  352. event->Release();
  353. }
  354. }
  355. /** if we don't have any more event listeners
  356. ** remove ourselves from the callback manager
  357. */
  358. if (events.empty())
  359. JSAPI2::callbackManager.Deregister(this);
  360. return S_OK;
  361. }
  362. #undef CHECK_ID
  363. #define CHECK_ID(str) case JSAPI_DISP_ENUMIFY(str): return str(wFlags, pdispparams, pvarResult, puArgErr);
  364. HRESULT JSAPI2::TransportAPI::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr)
  365. {
  366. switch (dispid)
  367. {
  368. DISP_TABLE
  369. }
  370. return DISP_E_MEMBERNOTFOUND;
  371. }
  372. STDMETHODIMP JSAPI2::TransportAPI::QueryInterface(REFIID riid, PVOID *ppvObject)
  373. {
  374. if (!ppvObject)
  375. return E_POINTER;
  376. else if (IsEqualIID(riid, IID_IDispatch))
  377. *ppvObject = (IDispatch *)this;
  378. else if (IsEqualIID(riid, IID_IUnknown))
  379. *ppvObject = this;
  380. else
  381. {
  382. *ppvObject = NULL;
  383. return E_NOINTERFACE;
  384. }
  385. AddRef();
  386. return S_OK;
  387. }
  388. ULONG JSAPI2::TransportAPI::AddRef(void)
  389. {
  390. return InterlockedIncrement(&refCount);
  391. }
  392. ULONG JSAPI2::TransportAPI::Release(void)
  393. {
  394. LONG lRef = InterlockedDecrement(&refCount);
  395. if (lRef == 0) delete this;
  396. return lRef;
  397. }
  398. void JSAPI2::TransportAPI::InvokeEvent(const wchar_t *eventName, JSAPI::CallbackParameters::PropertyTemplate *parameters, size_t parametersCount)
  399. {
  400. size_t index = events.size();
  401. if (0 == index)
  402. {
  403. JSAPI2::callbackManager.Deregister(this);
  404. return;
  405. }
  406. JSAPI::CallbackParameters *eventData= new JSAPI::CallbackParameters;
  407. if (NULL == eventData) return;
  408. eventData->AddString(L"event", eventName);
  409. if (NULL != parameters && 0 != parametersCount)
  410. eventData->AddPropertyIndirect(parameters, parametersCount);
  411. HRESULT hr;
  412. while (index--)
  413. {
  414. IDispatch *pEvent = events[index];
  415. if (NULL != pEvent)
  416. {
  417. hr = JSAPI::InvokeEvent(eventData, pEvent);
  418. if (FAILED(hr) && SCRIPT_E_REPORTED != hr)
  419. {
  420. events.erase(events.begin() + index);
  421. pEvent->Release();
  422. }
  423. }
  424. }
  425. if (events.empty())
  426. JSAPI2::callbackManager.Deregister(this);
  427. eventData->Release();
  428. }
  429. void JSAPI2::TransportAPI::OnStop(int position, int is_full_stop)
  430. {
  431. if (!is_full_stop)
  432. {
  433. JSAPI::CallbackParameters::PropertyTemplate parameter =
  434. {JSAPI::CallbackParameters::typeLong, L"position", (ULONG_PTR)position};
  435. InvokeEvent(L"OnStop", &parameter, 1);
  436. }
  437. else
  438. {
  439. InvokeEvent(L"OnEndOfFile", NULL, 0);
  440. }
  441. }
  442. void JSAPI2::TransportAPI::OnPlay(const wchar_t *filename)
  443. {
  444. JSAPI::CallbackParameters::PropertyTemplate parameter =
  445. {JSAPI::CallbackParameters::typeString, L"filename", (ULONG_PTR)filename};
  446. InvokeEvent(L"OnPlay", &parameter, 1);
  447. }
  448. void JSAPI2::TransportAPI::OnPause(bool pause_state)
  449. {
  450. JSAPI::CallbackParameters::PropertyTemplate parameter =
  451. {JSAPI::CallbackParameters::typeBool, L"paused", (ULONG_PTR)pause_state};
  452. InvokeEvent(L"OnPause", &parameter, 1);
  453. }