Skip to content

Commit

Permalink
Fixes and updates:
Browse files Browse the repository at this point in the history
  - Added plain vanilla "accept license to continue" style license dialog
  - Fixed memory leak in package build
  - Fixed behavior when clicking close on progress dlg after install
  • Loading branch information
keelanstuart committed Sep 26, 2020
1 parent e7faa2c commit 121211c
Show file tree
Hide file tree
Showing 16 changed files with 240 additions and 48 deletions.
19 changes: 12 additions & 7 deletions Archiver/Source/Archiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

IArchiver::CREATE_RESULT IArchiver::CreateArchiver(IArchiver **ppia, IArchiveHandle *pah, COMPRESSOR_TYPE ct)
{

if (ppia)
{
DWORD bw;
Expand Down Expand Up @@ -63,8 +62,11 @@ void IArchiver::DestroyArchiver(IArchiver **ppia)
{
if (ppia && *ppia)
{
delete *ppia;
*ppia = NULL;
CFastLZArchiver *pflza = dynamic_cast<CFastLZArchiver *>(*ppia);
if (pflza)
delete pflza;

*ppia = nullptr;
}
}

Expand All @@ -75,14 +77,14 @@ IExtractor::CREATE_RESULT IExtractor::CreateExtractor(IExtractor **ppie, IArchiv
{
DWORD br;
uint32_t magic;
ReadFile(pah->GetHandle(), &magic, sizeof(uint32_t), &br, NULL);
ReadFile(pah->GetHandle(), &magic, sizeof(uint32_t), &br, nullptr);

if (magic != IArchiver::MAGIC)
return CR_BADMAGIC;

*ppie = NULL;

ReadFile(pah->GetHandle(), &magic, sizeof(uint32_t), &br, NULL);
ReadFile(pah->GetHandle(), &magic, sizeof(uint32_t), &br, nullptr);

UINT64 flags;
ReadFile(pah->GetHandle(), &flags, sizeof(uint64_t), &br, NULL);
Expand All @@ -109,7 +111,10 @@ void IExtractor::DestroyExtractor(IExtractor **ppie)
{
if (ppie && *ppie)
{
delete *ppie;
*ppie = NULL;
CFastLZExtractor *pflze = dynamic_cast<CFastLZExtractor *>(*ppie);
if (pflze)
delete pflze;

*ppie = nullptr;
}
}
1 change: 1 addition & 0 deletions Archiver/Source/FastLZArchiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ CFastLZArchiver::CFastLZArchiver(IArchiveHandle *pah)

CFastLZArchiver::~CFastLZArchiver()
{
m_FileTable.clear();
}


Expand Down
84 changes: 84 additions & 0 deletions sfx/sfx/LicenseAcceptanceDlg.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
Copyright © 2013-2020, Keelan Stuart (hereafter referenced as AUTHOR). All Rights Reserved.
Permission to use, copy, modify, and distribute this software is hereby granted, without fee and without a signed licensing agreement,
provided that the above copyright notice appears in all copies, modifications, and distributions.
Furthermore, AUTHOR assumes no responsibility for any damages caused either directly or indirectly by the use of this software, nor vouches for
any fitness of purpose of this software.
All other copyrighted material contained herein is noted and rights attributed to individual copyright holders.
For inquiries, contact: [email protected]
*/


#include "stdafx.h"
#include "sfx.h"
#include "LicenseAcceptanceDlg.h"
#include "afxdialogex.h"


// CLicenseAcceptanceDlg dialog

IMPLEMENT_DYNAMIC(CLicenseAcceptanceDlg, CDialog)

CLicenseAcceptanceDlg::CLicenseAcceptanceDlg(const TCHAR *description, CWnd *pParent)
: CDialog(IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(_T("ICON"));

m_Desc = description;
}

CLicenseAcceptanceDlg::~CLicenseAcceptanceDlg()
{
}

void CLicenseAcceptanceDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CLicenseAcceptanceDlg, CDialog)
ON_BN_CLICKED(IDC_CHECK_ACCEPTLICENSE, &CLicenseAcceptanceDlg::OnBnClickedCheckAcceptlicense)
END_MESSAGE_MAP()


// CLicenseAcceptanceDlg message handlers


void CLicenseAcceptanceDlg::OnCancel()
{
CDialog::OnCancel();
}


BOOL CLicenseAcceptanceDlg::OnInitDialog()
{
CDialog::OnInitDialog();

SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

m_CtlOk.SubclassDlgItem(IDOK, this);

if (m_CtlDesc.CreateFromStatic(IDC_BROWSER, this))
{
m_CtlDesc.LoadFromResource(_T("license"));
}

if (m_CtlAcceptCB.SubclassDlgItem(IDC_CHECK_ACCEPTLICENSE, this))
{
m_CtlOk.EnableWindow(false);
}

ShowWindow(SW_SHOWNORMAL);

return FALSE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}


void CLicenseAcceptanceDlg::OnBnClickedCheckAcceptlicense()
{
m_CtlOk.EnableWindow((m_CtlAcceptCB.GetCheck() > 0) ? TRUE : FALSE);
}
46 changes: 46 additions & 0 deletions sfx/sfx/LicenseAcceptanceDlg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Copyright © 2013-2020, Keelan Stuart (hereafter referenced as AUTHOR). All Rights Reserved.
Permission to use, copy, modify, and distribute this software is hereby granted, without fee and without a signed licensing agreement,
provided that the above copyright notice appears in all copies, modifications, and distributions.
Furthermore, AUTHOR assumes no responsibility for any damages caused either directly or indirectly by the use of this software, nor vouches for
any fitness of purpose of this software.
All other copyrighted material contained herein is noted and rights attributed to individual copyright holders.
For inquiries, contact: [email protected]
*/

#pragma once


#include "HtmlCtrl.h"

// CLicenseKeyEntryDlg dialog

class CLicenseAcceptanceDlg : public CDialog
{
DECLARE_DYNAMIC(CLicenseAcceptanceDlg)

public:
CLicenseAcceptanceDlg(const TCHAR *description, CWnd *pParent = nullptr); // standard constructor
virtual ~CLicenseAcceptanceDlg();

// Dialog Data
enum { IDD = IDD_LICENSE_DIALOG };

protected:
virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support

HICON m_hIcon;
CHtmlCtrl m_CtlDesc;
CButton m_CtlAcceptCB;
CButton m_CtlOk;

CString m_Desc;


DECLARE_MESSAGE_MAP()
virtual void OnCancel();
public:
virtual BOOL OnInitDialog();
afx_msg void OnBnClickedCheckAcceptlicense();
};
4 changes: 2 additions & 2 deletions sfx/sfx/ProgressDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,9 +736,9 @@ UINT CProgressDlg::InstallThreadProc(LPVOID param)

void CProgressDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if (m_Thread && (nID == SC_CLOSE))
if (nID == SC_CLOSE)
{
if (MessageBox(_T("Do you really want to cancel this installation process and exit?"), _T("Confirm Exit"), MB_YESNO) == IDYES)
if (!m_Thread || (MessageBox(_T("Do you really want to cancel this installation process and exit?"), _T("Confirm Exit"), MB_YESNO) == IDYES))
ExitProcess(0);

return;
Expand Down
16 changes: 16 additions & 0 deletions sfx/sfx/TinyJS_SfxFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,22 @@ void scAbortInstall(CScriptVar* c, void* userdata)
}


void scShowLicenseAcceptanceDlg(CScriptVar *c, void *userdata)
{
if (!theApp.m_LicenseAcceptanceDlg)
{
theApp.m_LicenseAcceptanceDlg = new CLicenseAcceptanceDlg(_T(""));
}

INT_PTR dlg_ret = theApp.m_LicenseAcceptanceDlg->DoModal();

if (dlg_ret == IDCANCEL)
{
exit(-1);
}
}


void scShowLicenseDlg(CScriptVar *c, void *userdata)
{
if (!theApp.m_LicenseDlg)
Expand Down
1 change: 1 addition & 0 deletions sfx/sfx/TinyJS_SfxFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern void scSpawnProcess(CScriptVar *c, void *userdata);
extern void scGetExeVersion(CScriptVar* c, void* userdata);
extern void scCompareStrings(CScriptVar* c, void* userdata);
extern void scAbortInstall(CScriptVar* c, void* userdata);
extern void scShowLicenseAcceptanceDlg(CScriptVar *c, void *userdata);
extern void scShowLicenseDlg(CScriptVar *c, void *userdata);
extern void scGetLicenseKey(CScriptVar *c, void *userdata);
extern void scGetLicenseUser(CScriptVar *c, void *userdata);
Expand Down
Binary file modified sfx/sfx/resource.h
Binary file not shown.
20 changes: 18 additions & 2 deletions sfx/sfx/sfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CSfxApp::CSfxApp()
{
m_Flags = 0;
m_LicenseDlg = nullptr;
m_LicenseAcceptanceDlg = nullptr;
}


Expand Down Expand Up @@ -168,6 +169,7 @@ BOOL CSfxApp::InitInstance()
theApp.m_js.addNative(_T("function SetGlobalInt(name, val)"), scSetGlobalInt, (void *)this);
theApp.m_js.addNative(_T("function SetProperty(name, type, aspect, value)"), scSetProperty, (void *)this);
theApp.m_js.addNative(_T("function SetRegistryKeyValue(root, key, name, val)"), scSetRegistryKeyValue, (void *)this);
theApp.m_js.addNative(_T("function ShowLicenseAcceptanceDlg()"), scShowLicenseAcceptanceDlg, (void *)this);
theApp.m_js.addNative(_T("function ShowLicenseDlg()"), scShowLicenseDlg, (void *)this);
theApp.m_js.addNative(_T("function SpawnProcess(cmd, params, rundir, block)"), scSpawnProcess, (void *)this);
theApp.m_js.addNative(_T("function TextFileOpen(filename, mode)"), scTextFileOpen, (void *)this);
Expand Down Expand Up @@ -309,9 +311,10 @@ BOOL CSfxApp::InitInstance()

UINT dt = runnow ? DT_PROGRESS : DT_FIRST;

CDialog *dlg = nullptr;
while (dt != DT_QUIT)
{
CDialog *dlg = CreateSfxDialog((ESfxDlgType)dt);
dlg = CreateSfxDialog((ESfxDlgType)dt);
if (!dlg)
break;

Expand Down Expand Up @@ -356,8 +359,15 @@ BOOL CSfxApp::InitInstance()
#endif

m_pMainWnd = nullptr;

delete dlg;
dlg = nullptr;
}

if (dlg)
{
delete dlg;
dlg = NULL;
dlg = nullptr;
}

// Delete the shell manager created above.
Expand Down Expand Up @@ -385,6 +395,12 @@ BOOL CSfxApp::ExitInstance()
m_LicenseDlg = nullptr;
}

if (m_LicenseAcceptanceDlg)
{
delete m_LicenseAcceptanceDlg;
m_LicenseAcceptanceDlg = nullptr;
}

return TRUE;
}

Expand Down
2 changes: 2 additions & 0 deletions sfx/sfx/sfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "resource.h" // main symbols
#include "TinyJS.h"
#include "LicenseEntryDlg.h"
#include "LicenseAcceptanceDlg.h"


// CSfxApp:
Expand Down Expand Up @@ -49,6 +50,7 @@ class CSfxApp : public CWinApp
CTinyJS m_js;

CLicenseKeyEntryDlg *m_LicenseDlg;
CLicenseAcceptanceDlg *m_LicenseAcceptanceDlg;

enum EScriptType
{
Expand Down
Binary file modified sfx/sfx/sfx.rc
Binary file not shown.
2 changes: 2 additions & 0 deletions sfx/sfx/sfx.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
<ClInclude Include="..\sfxPackager\wtfpropertygridtooltipctrl.h" />
<ClInclude Include="..\sfxPackager\wtfvslistbox.h" />
<ClInclude Include="HttpDownload.h" />
<ClInclude Include="LicenseAcceptanceDlg.h" />
<ClInclude Include="LicenseEntryDlg.h" />
<ClInclude Include="FinishDlg.h" />
<ClInclude Include="HtmlCtrl.h" />
Expand All @@ -250,6 +251,7 @@
<ClCompile Include="..\sfxPackager\wtfpropertygridtooltipctrl.cpp" />
<ClCompile Include="..\sfxPackager\wtfvslistbox.cpp" />
<ClCompile Include="HttpDownload.cpp" />
<ClCompile Include="LicenseAcceptanceDlg.cpp" />
<ClCompile Include="LicenseEntryDlg.cpp" />
<ClCompile Include="FinishDlg.cpp" />
<ClCompile Include="HtmlCtrl.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions sfx/sfx/sfx.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
<ClInclude Include="TinyJS_SfxFunctions.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="LicenseAcceptanceDlg.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="sfx.cpp">
Expand Down Expand Up @@ -196,6 +199,9 @@
<ClCompile Include="TinyJS_SfxFunctions.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="LicenseAcceptanceDlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="sfx.rc">
Expand Down
13 changes: 8 additions & 5 deletions sfx/sfxPackager/OutputWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,14 @@ void COutputList::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
CMFCPopupMenu* pPopupMenu = new CMFCPopupMenu;

if (!pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE))
return;

((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu);
UpdateDialogControls(this, FALSE);
if (pPopupMenu)
{
if (pPopupMenu->Create(this, point.x, point.y, (HMENU)pSumMenu->m_hMenu, FALSE, TRUE))
{
((CMDIFrameWndEx*)AfxGetMainWnd())->OnShowPopupMenu(pPopupMenu);
UpdateDialogControls(this, FALSE);
}
}
}

SetFocus();
Expand Down
Binary file modified sfx/sfxPackager/sfxPackager.rc
Binary file not shown.
Loading

0 comments on commit 121211c

Please sign in to comment.