WSSerializedMessage.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #ifndef WSSerializedMessage_INCLUDED
  18. #define WSSerializedMessage_INCLUDED
  19. #include <kopano/zcdefs.h>
  20. #include <kopano/ECUnknown.h>
  21. #include <kopano/mapi_ptr.h>
  22. #include <kopano/memory.hpp>
  23. #include "soapStub.h"
  24. #include <string>
  25. /**
  26. * This object represents one exported message stream. It is responsible for requesting the MTOM attachments from soap.
  27. */
  28. class WSSerializedMessage _kc_final : public ECUnknown {
  29. public:
  30. WSSerializedMessage(soap *lpSoap, const std::string strStreamId, ULONG cbProps, LPSPropValue lpProps);
  31. HRESULT GetProps(ULONG *lpcbProps, LPSPropValue *lppProps);
  32. HRESULT CopyData(LPSTREAM lpDestStream);
  33. HRESULT DiscardData();
  34. private:
  35. HRESULT DoCopyData(LPSTREAM lpDestStream);
  36. static void* StaticMTOMWriteOpen(struct soap *soap, void *handle, const char *id, const char *type, const char *description, enum soap_mime_encoding encoding);
  37. static int StaticMTOMWrite(struct soap *soap, void *handle, const char *buf, size_t len);
  38. static void StaticMTOMWriteClose(struct soap *soap, void *handle);
  39. void* MTOMWriteOpen(struct soap *soap, void *handle, const char *id, const char *type, const char *description, enum soap_mime_encoding encoding);
  40. int MTOMWrite(struct soap *soap, void *handle, const char *buf, size_t len);
  41. void MTOMWriteClose(struct soap *soap, void *handle);
  42. soap *m_lpSoap;
  43. const std::string m_strStreamId;
  44. ULONG m_cbProps;
  45. LPSPropValue m_lpProps; // Points to data from parent object.
  46. bool m_bUsed = false;
  47. StreamPtr m_ptrDestStream;
  48. HRESULT m_hr = hrSuccess;
  49. };
  50. typedef KCHL::object_ptr<WSSerializedMessage> WSSerializedMessagePtr;
  51. #endif // ndef WSSerializedMessage_INCLUDED