yacreader/compressed_archive/open_callbacks.h
Luis Ángel San Martín 1903b6753f Update compressed_archive to support the latest version of 7zip 18.05
p7zip has been abandoned and the latest version available is 16.02.
2019-02-18 17:00:30 +01:00

55 lines
1.2 KiB
C++

#ifndef OPEN_CALLBACKS_H
#define OPEN_CALLBACKS_H
#include "7z_includes.h"
#include <QDebug>
//////////////////////////////////////////////////////////////
// Archive Open callback class
class YCArchiveOpenCallback:
public IArchiveOpenCallback,
public ICryptoGetTextPassword,
public CMyUnknownImp
{
public:
MY_UNKNOWN_IMP1(ICryptoGetTextPassword)
STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes);
STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes);
STDMETHOD(CryptoGetTextPassword)(BSTR *password);
bool PasswordIsDefined;
UString Password;
YCArchiveOpenCallback() : PasswordIsDefined(false) {}
};
STDMETHODIMP YCArchiveOpenCallback::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */)
{
return S_OK;
}
STDMETHODIMP YCArchiveOpenCallback::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */)
{
return S_OK;
}
STDMETHODIMP YCArchiveOpenCallback::CryptoGetTextPassword(BSTR *password)
{
if (!PasswordIsDefined)
{
// You can ask real password here from user
// Password = GetPassword(OutStream);
// PasswordIsDefined = true;
qDebug() << "Password is not defined" << endl;
return E_ABORT;
}
return StringToBstr(Password, password);
}
#endif