Skip to content

Commit

Permalink
Add an option to update silently
Browse files Browse the repository at this point in the history
A "Yes (Silent)" button is added in the update propt dialog, beside of button "Yes" which will trigger the classic update with GUI.
Choose "Yes (Silent)" will download the package, close your Notepad++, then install new version of Notepad++ silently (without NEXT, NEXT...). After the installation, new version of Notepad++ will be launched.

Fix notepad-plus-plus/notepad-plus-plus#8514, close #8514
  • Loading branch information
donho committed Jun 13, 2024
1 parent e1620d1 commit 069edc2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 23 deletions.
9 changes: 5 additions & 4 deletions src/gup.rc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ EXSTYLE WS_EX_TOOLWINDOW | WS_EX_WINDOWEDGE
CAPTION "Notepad++ Update Available"
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
LTEXT "An update package is available, do you want to download it?",IDC_YESNONEVERMSG,15,15,250,64
PUSHBUTTON "Yes",IDYES,50,70,50,14
PUSHBUTTON "No",IDNO,110,70,50,14
PUSHBUTTON "Never",IDCANCEL,170,70,50,14
LTEXT "An update package is available, do you want to download and install it?",IDC_YESNONEVERMSG,15,15,250,50
PUSHBUTTON "Yes",IDYES,27,70,50,14
PUSHBUTTON "Yes (Silent)",IDOK,82,70,50,14
PUSHBUTTON "No",IDNO,136,70,50,14
PUSHBUTTON "Never",IDCANCEL,190,70,50,14
END

IDD_UPDATE_DLG DIALOGEX 0, 0, 200, 110
Expand Down
2 changes: 1 addition & 1 deletion src/translations/english.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<GUP_NativeLangue name="English" version="5.1.3">
<PopupMessages>
<MSGID_UPDATEAVAILABLE content="An update package is available, do you want to download it?" />
<MSGID_UPDATEAVAILABLE content="An update package is available, do you want to download and install it?" />
<MSGID_VERSIONCURRENT content="Current version is :" />
<MSGID_VERSIONNEW content="Available version is :" />

Expand Down
2 changes: 1 addition & 1 deletion src/translations/french.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<GUP_NativeLangue name="français" version="5.1.3">
<PopupMessages>
<MSGID_UPDATEAVAILABLE content="Une mise à jour est disponible, voulez-vous le télécharger?"/>
<MSGID_UPDATEAVAILABLE content="Une mise à jour est disponible, voulez-vous la télécharger et l'installer?"/>

<MSGID_DOWNLOADPAGE content="Aller à la page de téléchargement" />
<MSGID_MOREINFO content="plus d'info" />
Expand Down
2 changes: 1 addition & 1 deletion src/translations/taiwaneseMandarin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<GUP_NativeLangue name="台灣繁體" version="5.1.3">
<PopupMessages>
<MSGID_UPDATEAVAILABLE content="有可更新的新版本,您要下載嗎" />
<MSGID_UPDATEAVAILABLE content="有可更新的新版本,您要下載並安裝它嗎" />

<MSGID_DOWNLOADPAGE content="進入官方網站下載頁面" />
<MSGID_MOREINFO content="更多相關資訊" />
Expand Down
43 changes: 27 additions & 16 deletions src/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ static long proxyPort = 0;
static wstring winGupUserAgent = L"WinGup/";
static wstring dlFileName = L"";
static wstring appIconFile = L"";
static wstring nsisSilentInstallParam = L"";

const wchar_t FLAG_NSIS_SILENT_INSALL_PARAM[] = L"/closeRunningNpp /S /runNppAfterSilentInstall";


const wchar_t FLAG_OPTIONS[] = L"-options";
const wchar_t FLAG_VERBOSE[] = L"-verbose";
const wchar_t FLAG_HELP[] = L"--help";
const wchar_t FLAG_UUZIP[] = L"-unzipTo";
const wchar_t FLAG_CLEANUP[] = L"-clean";

const wchar_t MSGID_UPDATEAVAILABLE[] = L"An update package is available, do you want to download it?";
const wchar_t MSGID_UPDATEAVAILABLE[] = L"An update package is available, do you want to download and install it?";
const wchar_t MSGID_VERSIONCURRENT[] = L"Current version is :";
const wchar_t MSGID_VERSIONNEW[] = L"Available version is :";
const wchar_t MSGID_DOWNLOADSTOPPED[] = L"Download is stopped by user. Update is aborted.";
Expand Down Expand Up @@ -577,21 +581,21 @@ LRESULT CALLBACK progressBarDlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARA
case WM_COMMAND:
switch(wParam)
{
case IDOK:
EndDialog(hWndDlg, 0);
return TRUE;
case IDCANCEL:
stopDL = true;
if (abortOrNot == L"")
abortOrNot = MSGID_ABORTORNOT;
int abortAnswer = ::MessageBox(hWndDlg, abortOrNot.c_str(), msgBoxTitle.c_str(), MB_YESNO);
if (abortAnswer == IDYES)
{
doAbort = true;
case IDOK:
EndDialog(hWndDlg, 0);
}
stopDL = false;
return TRUE;
return TRUE;
case IDCANCEL:
stopDL = true;
if (abortOrNot == L"")
abortOrNot = MSGID_ABORTORNOT;
int abortAnswer = ::MessageBox(hWndDlg, abortOrNot.c_str(), msgBoxTitle.c_str(), MB_YESNO);
if (abortAnswer == IDYES)
{
doAbort = true;
EndDialog(hWndDlg, 0);
}
stopDL = false;
return TRUE;
}
break;
}
Expand Down Expand Up @@ -622,6 +626,7 @@ LRESULT CALLBACK yesNoNeverDlgProc(HWND hWndDlg, UINT message, WPARAM wParam, LP
{
switch (wParam)
{
case IDOK:
case IDYES:
case IDNO:
case IDCANCEL:
Expand Down Expand Up @@ -978,8 +983,9 @@ bool runInstaller(const wstring& app2runPath, const wstring& binWindowsClassName
}
}


// execute the installer
HINSTANCE result = ::ShellExecute(NULL, L"open", app2runPath.c_str(), L"", L".", SW_SHOW);
HINSTANCE result = ::ShellExecute(NULL, L"open", app2runPath.c_str(), nsisSilentInstallParam.c_str(), L".", SW_SHOW);

if (result <= (HINSTANCE)32) // There's a problem (Don't ask me why, ask Microsoft)
{
Expand Down Expand Up @@ -1405,6 +1411,11 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR lpszCmdLine, int)
}
return 0;
}
else if (dlAnswer == IDOK)
{
nsisSilentInstallParam = FLAG_NSIS_SILENT_INSALL_PARAM;
}
// else IDYES: do nothing

//
// Download executable bin
Expand Down

0 comments on commit 069edc2

Please sign in to comment.