JnetCOM.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef NULLSOFT_JNETCOMH
  2. #define NULLSOFT_JNETCOMH
  3. #include <process.h>
  4. #include <ocidl.h>
  5. #include "../../..\Components\wac_network\wac_network_http_receiver_api.h"
  6. #include <objbase.h>
  7. #include "BufferCache.h"
  8. #include <map>
  9. #include <string>
  10. typedef std::map<std::wstring, Buffer_GrowBuf *> BufferMap;
  11. extern BufferMap buffer_map;
  12. #define WORKSIZE 32768
  13. class JnetCOM : public IDispatch
  14. {
  15. public:
  16. JnetCOM() :
  17. refCount(1),
  18. threadexit(0),
  19. active(0),
  20. jnetThread(0),
  21. jnetbuf(NULL),
  22. isBlocking(0),
  23. finalSize(0),
  24. getter(NULL),
  25. callback(NULL),
  26. postData(0),
  27. url(0),
  28. callingThreadId(0),
  29. callingThreadHandle(0)
  30. {
  31. memset(errorstr, 0, sizeof(errorstr));
  32. }
  33. STDMETHOD(QueryInterface)(REFIID riid, PVOID *ppvObject);
  34. STDMETHOD_(ULONG, AddRef)(void);
  35. STDMETHOD_(ULONG, Release)(void);
  36. int refCount;
  37. // *** IDispatch Methods ***
  38. STDMETHOD (GetIDsOfNames)(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid);
  39. STDMETHOD (GetTypeInfo)(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo);
  40. STDMETHOD (GetTypeInfoCount)(unsigned int FAR * pctinfo);
  41. STDMETHOD (Invoke)(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr);
  42. void DownloadURL(DISPPARAMS FAR *pdispparams );
  43. void PostURL(DISPPARAMS FAR *pdispparams);
  44. void callBack();
  45. int threadexit;
  46. int isBlocking;
  47. api_httpreceiver *getter;
  48. Buffer_GrowBuf *jnetbuf;
  49. IDispatch *callback;
  50. BSTR htmldiv;
  51. DWORD callingThreadId;
  52. HANDLE callingThreadHandle;
  53. static DWORD WINAPI JThreadProc(void *param)
  54. {
  55. CoInitialize(NULL);
  56. JnetCOM *th = static_cast<JnetCOM*>(param);
  57. int ret = th->JthreadProc();
  58. _endthread();
  59. return ret;
  60. }
  61. static DWORD WINAPI jnetPostProcedure(void *param)
  62. {
  63. CoInitialize(NULL);
  64. JnetCOM *th = static_cast<JnetCOM*>(param);
  65. int ret = th->PostProcedure();
  66. _endthread();
  67. return ret;
  68. }
  69. size_t finalSize;
  70. wchar_t *url;
  71. char *postData;
  72. int active;
  73. char errorstr[2048];
  74. HANDLE jnetThread;
  75. private:
  76. int JthreadProc();
  77. int PostProcedure();
  78. };
  79. #endif