RMS SDK for C++  0.2.1
A client library for using Microsoft RMS from Linux.
CustomProtectedStream.h
1 /*
2  * ======================================================================
3  * Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
4  * Licensed under the MIT License.
5  * See LICENSE.md in the project root for license information.
6  * ======================================================================
7  */
8 
9 #ifndef _RMS_LIB_CUSTOMPROTECTEDSTREAM_H_
10 #define _RMS_LIB_CUSTOMPROTECTEDSTREAM_H_
11 
12 #include "UserPolicy.h"
13 #include "IStream.h"
14 #include "ModernAPIExport.h"
15 
16 namespace rmscore {
17 namespace modernapi {
18 
27 class DLL_PUBLIC_RMS CustomProtectedStream : public rmscrypto::api::IStream {
28 public:
29 
75  static std::shared_ptr<CustomProtectedStream> Create(
76  std::shared_ptr<UserPolicy> policy,
77  rmscrypto::api::SharedStream stream,
78  uint64_t contentStartPosition,
79  uint64_t contentSize);
80 
88  static uint64_t GetEncryptedContentLength(
89  std::shared_ptr<UserPolicy>policy,
90  uint64_t contentLength);
91 
107  virtual std::shared_future<int64_t>ReadAsync(uint8_t *pbBuffer,
108  int64_t cbBuffer,
109  int64_t cbOffset,
110  std::launch launchType)
111  override;
112 
128  virtual std::shared_future<int64_t>WriteAsync(const uint8_t *cpbBuffer,
129  int64_t cbBuffer,
130  int64_t cbOffset,
131  std::launch launchType)
132  override;
133 
145  virtual std::future<bool> FlushAsync(std::launch launchType)
146  override;
147 
155  virtual int64_t Read(uint8_t *pbBuffer,
156  int64_t cbBuffer) override;
157 
165  virtual int64_t Write(const uint8_t *cpbBuffer,
166  int64_t cbBuffer) override;
167 
173  virtual bool Flush() override;
174 
180  virtual rmscrypto::api::SharedStream Clone() override;
181 
186  virtual void Seek(uint64_t u64Position) override;
187 
192  virtual bool CanRead() const override;
193 
198  virtual bool CanWrite() const override;
199 
204  virtual uint64_t Position() override;
205 
210  virtual uint64_t Size() override;
211 
216  virtual void Size(uint64_t u64Value) override;
217 
218  virtual ~CustomProtectedStream();
219 
220 protected:
221 
222  CustomProtectedStream(std::shared_ptr<IStream>pImpl);
223  std::shared_ptr<IStream>GetImpl();
224 
225 private:
226 
227  std::shared_ptr<IStream> m_pImpl;
228 };
229 } // namespace modernapi
230 } // namespace rmscore
231 #endif // _RMS_LIB_CUSTOMPROTECTEDSTREAM_H_
Base interface for protected streams.
Definition: IStream.h:34
Definition: AuthenticationCallbackImpl.h:16
Used to access files that use a custom protection format.
Definition: CustomProtectedStream.h:27