You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
1.6 KiB
85 lines
1.6 KiB
10 months ago
|
#include "ArchiveOpenCallback.h"
|
||
|
#include "../CPP/Common/MyCom.h"
|
||
|
|
||
|
namespace SevenZip
|
||
|
{
|
||
|
namespace intl
|
||
|
{
|
||
|
|
||
|
ArchiveOpenCallback::ArchiveOpenCallback()
|
||
|
: m_refCount(0), PasswordIsDefined(false)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
ArchiveOpenCallback::~ArchiveOpenCallback()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
STDMETHODIMP ArchiveOpenCallback::QueryInterface( REFIID iid, void** ppvObject )
|
||
|
{
|
||
|
if ( iid == __uuidof( IUnknown ) )
|
||
|
{
|
||
|
*ppvObject = reinterpret_cast< IUnknown* >( this );
|
||
|
AddRef();
|
||
|
return S_OK;
|
||
|
}
|
||
|
|
||
|
if ( iid == IID_IArchiveOpenCallback )
|
||
|
{
|
||
|
*ppvObject = static_cast< IArchiveOpenCallback* >( this );
|
||
|
AddRef();
|
||
|
return S_OK;
|
||
|
}
|
||
|
|
||
|
if ( iid == IID_ICryptoGetTextPassword )
|
||
|
{
|
||
|
*ppvObject = static_cast< ICryptoGetTextPassword* >( this );
|
||
|
AddRef();
|
||
|
return S_OK;
|
||
|
}
|
||
|
|
||
|
return E_NOINTERFACE;
|
||
|
}
|
||
|
|
||
|
STDMETHODIMP_(ULONG) ArchiveOpenCallback::AddRef()
|
||
|
{
|
||
|
return static_cast< ULONG >( InterlockedIncrement( &m_refCount ) );
|
||
|
}
|
||
|
|
||
|
STDMETHODIMP_(ULONG) ArchiveOpenCallback::Release()
|
||
|
{
|
||
|
ULONG res = static_cast< ULONG >( InterlockedDecrement( &m_refCount ) );
|
||
|
if ( res == 0 )
|
||
|
{
|
||
|
delete this;
|
||
|
}
|
||
|
return res;
|
||
|
}
|
||
|
|
||
|
STDMETHODIMP ArchiveOpenCallback::SetTotal( const UInt64* /*files*/, const UInt64* /*bytes*/ )
|
||
|
{
|
||
|
return S_OK;
|
||
|
}
|
||
|
|
||
|
STDMETHODIMP ArchiveOpenCallback::SetCompleted( const UInt64* /*files*/, const UInt64* /*bytes*/ )
|
||
|
{
|
||
|
return S_OK;
|
||
|
}
|
||
|
|
||
|
STDMETHODIMP ArchiveOpenCallback::CryptoGetTextPassword( BSTR* password)
|
||
|
{
|
||
|
if (!PasswordIsDefined)
|
||
|
{
|
||
|
// You can ask real password here from user
|
||
|
// Password = GetPassword(OutStream);
|
||
|
// PasswordIsDefined = true;
|
||
|
//printf("Password is not defined");
|
||
|
return E_ABORT;
|
||
|
}
|
||
|
|
||
|
return StringToBstr(Password, password);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|