text: //=========================================================================
  // Copyright (C) 2012 The Elastos Open Source Project
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //      http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  //=========================================================================
  
  #ifndef __ORG_CONSCRYPT_OPENSSLBIOSOURCE_H__
  #define __ORG_CONSCRYPT_OPENSSLBIOSOURCE_H__
  
  #include "elastos/coredef.h"
  #include <Elastos.CoreLibrary.IO.h>
  #include "elastos/core/Object.h"
  #include "elastos/io/InputStream.h"
  #include "_Org.Conscrypt.h"
  
  using Elastos::IO::IByteBuffer;
  using Elastos::IO::InputStream;
  
  namespace Org {
  namespace Conscrypt {
  
  class OpenSSLBIOSource
      : public IOpenSSLBIOSource
      , public Object
  {
  private:
      class ByteBufferInputStream
          : public InputStream
      {
      public:
          ByteBufferInputStream(
              /* [in] */ IByteBuffer* source);
  
          // @Override
          CARAPI Read(
              /* [out] */ Int32* result);
  
          // @Override
          CARAPI Available(
              /* [out] */ Int32* result);
  
          // @Override
          CARAPI Read(
              /* [in] */ ArrayOf<Byte>* buffer,
              /* [out] */ Int32* result);
  
          // @Override
          CARAPI Read(
              /* [in] */ ArrayOf<Byte>* buffer,
              /* [in] */ Int32 byteOffset,
              /* [in] */ Int32 byteCount,
              /* [out] */ Int32* result);
  
          // @Override
          CARAPI Reset();
  
          // @Override
          CARAPI Skip(
              /* [in] */ Int64 byteCount,
              /* [out] */ Int64* result);
  
      private:
          AutoPtr<IByteBuffer> mSource;
      };
  
  public:
      CAR_INTERFACE_DECL()
  
      OpenSSLBIOSource();
  
      ~OpenSSLBIOSource();
  
      CARAPI constructor(
          /* [in] */ IOpenSSLBIOInputStream* source);
  
      CARAPI GetContext(
          /* [out] */  Int64* result);
  
      CARAPI ReleaseResources();
  
      static CARAPI Wrap(
          /* [in] */ IByteBuffer* buffer,
          /* [out] */ IOpenSSLBIOSource** result);
  
  private:
      AutoPtr<IOpenSSLBIOInputStream> mSource;
  };
  
  } // namespace Conscrypt
  } // namespace Org
  
  #endif //__ORG_CONSCRYPT_OPENSSLBIOSOURCE_H__
  