1
0

minibrowserCOM.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include "precomp__gen_ff.h"
  2. #include "minibrowserCOM.h"
  3. MinibrowserCOM::MinibrowserCOM(BrowserWnd* brw)
  4. {
  5. this->brw = brw;
  6. }
  7. HRESULT __stdcall MinibrowserCOM::GetTypeInfoCount(unsigned int FAR* pctinfo)
  8. {
  9. return E_NOTIMPL;
  10. }
  11. HRESULT __stdcall MinibrowserCOM::GetTypeInfo(unsigned int iTInfo, LCID lcid, ITypeInfo FAR* FAR* ppTInfo)
  12. {
  13. return E_NOTIMPL;
  14. }
  15. HRESULT __stdcall MinibrowserCOM::GetIDsOfNames( REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgDispId)
  16. {
  17. int notFound = false;
  18. for (unsigned int i = 0; i != cNames; i++)
  19. {
  20. if (!_wcsicmp(rgszNames[i], L"messageToMaki"))
  21. {
  22. rgDispId[i] = MINIBROWSERCOM_MAKI_MESSAGETOMAKI;
  23. continue;
  24. }
  25. notFound = true;
  26. }
  27. if (!notFound)
  28. return S_OK;
  29. return DISP_E_UNKNOWNNAME;
  30. }
  31. HRESULT __stdcall MinibrowserCOM::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr)
  32. {
  33. switch (dispid)
  34. {
  35. case MINIBROWSERCOM_MAKI_MESSAGETOMAKI:
  36. /* var ret = window.external.messageToMaki(str1, str2, int1, int2, int3) */
  37. /* keep in mind that the args are passed in reverse order! */
  38. /*if (wFlags != DISPATCH_METHOD)
  39. return DISP_E_MEMBERNOTFOUND;*/
  40. if (pdispparams->cArgs != 5)
  41. return DISP_E_BADPARAMCOUNT;
  42. const wchar_t * ret = this->brw->messageToMaki(pdispparams->rgvarg[4].bstrVal, pdispparams->rgvarg[3].bstrVal, pdispparams->rgvarg[2].iVal, pdispparams->rgvarg[1].iVal, pdispparams->rgvarg[0].iVal);
  43. // (mpdeimos) we need to check this here since in JS one can omit the return value. In this case we would get a NPE here.
  44. if (pvarResult != NULL)
  45. {
  46. BSTR returnValue = SysAllocString(ret);
  47. VariantInit(pvarResult);
  48. V_VT(pvarResult) = VT_BSTR;
  49. V_BSTR(pvarResult) = returnValue;
  50. }
  51. return S_OK;
  52. }
  53. return DISP_E_MEMBERNOTFOUND;
  54. }
  55. STDMETHODIMP MinibrowserCOM::QueryInterface(REFIID riid, PVOID *ppvObject)
  56. {
  57. if (!ppvObject)
  58. return E_POINTER;
  59. else if (IsEqualIID(riid, IID_IDispatch))
  60. *ppvObject = (IDispatch *)this;
  61. else if (IsEqualIID(riid, IID_IUnknown))
  62. *ppvObject = this;
  63. else
  64. {
  65. *ppvObject = NULL;
  66. return E_NOINTERFACE;
  67. }
  68. AddRef();
  69. return S_OK;
  70. }
  71. ULONG MinibrowserCOM::AddRef(void)
  72. {
  73. return 0;
  74. }
  75. ULONG MinibrowserCOM::Release(void)
  76. {
  77. return 0;
  78. }