ECMessageStreamImporterIStreamAdapter.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 ECMessageStreamImporterIStreamAdapter_INCLUDED
  18. #define ECMessageStreamImporterIStreamAdapter_INCLUDED
  19. #include <kopano/zcdefs.h>
  20. #include <kopano/memory.hpp>
  21. #include <kopano/ECUnknown.h>
  22. #include "WSMessageStreamImporter.h"
  23. /**
  24. * This class wraps a WSMessageStreamImporter object and exposes it as an IStream.
  25. * The actual import callto the server will be initiated by the first write to the
  26. * IStream.
  27. * On commit, the call thread will block until the asynchronous call has completed, and
  28. * the return value will be returned.
  29. */
  30. class ECMessageStreamImporterIStreamAdapter _kc_final : public ECUnknown {
  31. public:
  32. static HRESULT Create(WSMessageStreamImporter *lpStreamImporter, IStream **lppStream);
  33. // IUnknown
  34. virtual HRESULT QueryInterface(REFIID refiid, void **lppInterface) _kc_override;
  35. // ISequentialStream
  36. virtual HRESULT Read(void *pv, ULONG cb, ULONG *pcbRead);
  37. virtual HRESULT Write(const void *pv, ULONG cb, ULONG *pcbWritten);
  38. // IStream
  39. virtual HRESULT Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition);
  40. virtual HRESULT SetSize(ULARGE_INTEGER libNewSize);
  41. virtual HRESULT CopyTo(IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten);
  42. virtual HRESULT Commit(DWORD grfCommitFlags);
  43. virtual HRESULT Revert(void);
  44. virtual HRESULT LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
  45. virtual HRESULT UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
  46. virtual HRESULT Stat(STATSTG *pstatstg, DWORD grfStatFlag);
  47. virtual HRESULT Clone(IStream **ppstm);
  48. private:
  49. ECMessageStreamImporterIStreamAdapter(WSMessageStreamImporter *lpStreamImporter);
  50. ~ECMessageStreamImporterIStreamAdapter();
  51. class xSequentialStream _kc_final : public ISequentialStream {
  52. #include <kopano/xclsfrag/IUnknown.hpp>
  53. #include <kopano/xclsfrag/ISequentialStream.hpp>
  54. } m_xSequentialStream;
  55. class xStream _kc_final : public IStream {
  56. #include <kopano/xclsfrag/IUnknown.hpp>
  57. #include <kopano/xclsfrag/ISequentialStream.hpp>
  58. #include <kopano/xclsfrag/IStream.hpp>
  59. } m_xStream;
  60. WSMessageStreamImporterPtr m_ptrStreamImporter;
  61. WSMessageStreamSinkPtr m_ptrSink;
  62. };
  63. typedef KCHL::object_ptr<ECMessageStreamImporterIStreamAdapter> ECMessageStreamImporterIStreamAdapterPtr;
  64. #endif // ndef ECMessageStreamImporterIStreamAdapter_INCLUDED