1
0

jnetcom.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #include <ocidl.h>
  3. #include "..\Components\wac_network\wac_network_http_receiver_api.h"
  4. #include "api.h"
  5. class JNetCOM : public IDispatch, public ifc_downloadManagerCallback
  6. {
  7. public:
  8. JNetCOM(IDispatch *_dispatch);
  9. ~JNetCOM();
  10. STDMETHOD(QueryInterface)(REFIID riid, PVOID *ppvObject);
  11. STDMETHOD_(ULONG, AddRef)(void);
  12. STDMETHOD_(ULONG, Release)(void);
  13. // *** IDispatch Methods ***
  14. STDMETHOD (GetIDsOfNames)(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid);
  15. STDMETHOD (GetTypeInfo)(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo);
  16. STDMETHOD (GetTypeInfoCount)(unsigned int FAR * pctinfo);
  17. STDMETHOD (Invoke)(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr);
  18. STDMETHOD (Abort)();
  19. STDMETHOD (AddHeader)(LPCWSTR header);
  20. STDMETHOD (Connect)(LPCWSTR url, LPCWSTR requestMethod);
  21. STDMETHOD (GetContent)(VARIANT *variant);
  22. STDMETHOD (GetContentAsString)(VARIANT *variant);
  23. STDMETHOD (GetErrorString)(VARIANT *variant);
  24. STDMETHOD (GetHeader)(LPCWSTR header, VARIANT *variant);
  25. STDMETHOD (GetReply)(VARIANT *variant);
  26. STDMETHOD (GetReplyCode)(VARIANT *variant);
  27. STDMETHOD (GetUrl)(VARIANT *variant);
  28. /* Dispatchable */
  29. size_t Dispatchable_AddRef();
  30. size_t Dispatchable_Release();
  31. void OnFinish(DownloadToken token);
  32. void OnTick(DownloadToken token);
  33. void OnError(DownloadToken token, int error);
  34. void OnCancel(DownloadToken token);
  35. void OnConnect(DownloadToken token);
  36. void OnInit(DownloadToken token);
  37. void Call(PAPCFUNC func);
  38. /*
  39. methods:
  40. Abort
  41. AddHeader (only call this during OnInit)
  42. Connect (here is where you specify the URL)
  43. GetContent
  44. GetContentAsString
  45. GetErrorString
  46. GetHeader
  47. GetReply
  48. GetReplyCode
  49. GetUrl (may not be the same as what you originally connected because of redirection)
  50. SetPostString (only call this during OnInit)
  51. callback methods in YOUR object:
  52. OnCancel
  53. OnConnect
  54. OnError
  55. OnFinish
  56. OnTick (called every once in a while)
  57. OnInit (called immediately after Connect(), you can add headers and shit here
  58. */
  59. private:
  60. LONG refCount;
  61. DWORD threadId;
  62. HANDLE threadHandle;
  63. IDispatch *dispatch;
  64. DownloadToken token;
  65. bool retained;
  66. protected:
  67. RECVS_DISPATCH;
  68. };