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";

This comment has been minimized.

Copy link
@CennoxX

CennoxX Jun 14, 2024

Should be …_INSTALL_… instead of …_INSALL_…

This comment has been minimized.

Copy link
@donho

donho Jun 14, 2024

Author Member

@CennoxX
Fixed: 3beed29
Thank you for the heads up.



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

10 comments on commit 069edc2

@xomx
Copy link

@xomx xomx commented on 069edc2 Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donho

Perfect!

I'd like to test but this will also need the new N++ installer with the previously added '/closeRunningNpp' & '/runNppAfterSilentInstall' option available for download.

And it also seems that the downloaded GH Actions build of the GUP.exe cannot simply replace my installed N++ one (is there a security reason, probably unsigned GUP.exe ?)

So how one can properly test this feature?

@donho
Copy link
Member Author

@donho donho commented on 069edc2 Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xomx
You are welcome to test it.

Just download the new installer here:
http://download.notepad-plus-plus.org/repository/MISC/npp.8.6.8.Installer.x64.exe

Install it firstly so it will put the modified 'gup.xml' and new 'GUP.exe' into the installation destination.
Once it's installed, replace notepad++.exe of version 8.6.8 by any previous version's one.

Then launch notepad++.exe -> update Notepad++. The new package will be download from the same location:
http://download.notepad-plus-plus.org/repository/MISC/npp.8.6.8.Installer.x64.exe

Please let me know if it does work to you.

@donho
Copy link
Member Author

@donho donho commented on 069edc2 Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xomx

And it also seems that the downloaded GH Actions build of the GUP.exe cannot simply replace my installed N++ one (is there a security reason, probably unsigned GUP.exe ?)

Notepad++ will check GUP.exe's certificate before launching it. So if GUP.exe is not signed, nothing will happen.

@xomx
Copy link

@xomx xomx commented on 069edc2 Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donho
Tested & works ok.

One minor glitch to fix:

  • after a successful download, the progres-bar incorrectly stays opened at 100% and covers the next N++ dlg (Notepad++ is opened. Updater will close...):
    npp-GUP-progressbar-not-autoclosed
  • because of the GUP.exe cert-security I cannot patch & try so I only guess here what to do - I would add (at the end) autoclosing of the hProgressBar if the dl-percentage reaches 100%:
    static size_t setProgress(HWND, double dlTotal, double dlSoFar, double, double)

@donho
Copy link
Member Author

@donho donho commented on 069edc2 Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xomx
Sorry but I don't get the glitch you mentioned. Mind to collaborate it?

@donho
Copy link
Member Author

@donho donho commented on 069edc2 Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xomx
OK, I see. You're right.
I'll see what I can do about it.

@xomx
Copy link

@xomx xomx commented on 069edc2 Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got this sequence while updating:
npp-GUP-1
npp-GUP-2
npp-GUP-3-covered
npp-GUP-3-uncovered

@donho
Copy link
Member Author

@donho donho commented on 069edc2 Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xomx
You can try 069edc2#commitcomment-143117163 again.
The glitch is fixed.

@xomx
Copy link

@xomx xomx commented on 069edc2 Jun 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donho
I can confirm, now it is ok.
I see this Yes (Silent) as a major improvement for the users using the installed N++!

@donho
Copy link
Member Author

@donho donho commented on 069edc2 Jun 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xomx

I see this Yes (Silent) as a major improvement for the users using the installed N++!

It's thanks to your "/closeRunningNppAutomatically" feature!

Please sign in to comment.