From 28f81e8b0e13ef725d2c0993d9bb1c0a5ee3757b Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Wed, 19 Mar 2025 09:32:15 +0100 Subject: [PATCH] tdf#159979 - UI: do not allow Online Update page if the original Online update is not available (not installed) This is only a workaround solution for tdf#159979, with removing MAR update specific files during msi installation if the original Online Update feature is skipped to install, therefor later we can check if the Automatic update UI page should be visible or not. Better/final solution would be if we just skip and not create any MAR update files with /core/external/onlineupdate/Module_onlineupdate.mk if we are not installing the Online Update feature. Change-Id: I7e16c694308f7bb196f9f1121bd7a85e368d35b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183119 Tested-by: Jenkins Reviewed-by: Balazs Varga --- cui/source/options/optupdt.cxx | 10 ++++++- .../onlineupdate/install_updateservice.cxx | 30 +++++++++++++++++++ scp2/source/ooo/windowscustomaction_ooo.scp | 13 ++++++-- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/cui/source/options/optupdt.cxx b/cui/source/options/optupdt.cxx index 21fd59d7f712..fbc32dcf7b94 100644 --- a/cui/source/options/optupdt.cxx +++ b/cui/source/options/optupdt.cxx @@ -18,12 +18,15 @@ */ #include +#include +#include #include #include #include #include #include "optupdt.hxx" #include +#include #include #include #include @@ -524,7 +527,12 @@ bool SvxOnlineUpdateTabPage::isTraditionalOnlineUpdateAvailable() { bool SvxOnlineUpdateTabPage::isMarOnlineUpdateAvailable() { #if HAVE_FEATURE_UPDATE_MAR - return true; + OUString aURL(u"$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/updater.ini"_ustr); + rtl::Bootstrap::expandMacros(aURL); + if (!comphelper::DirectoryHelper::fileExists(aURL)) + return false; + else + return true; #else return false; #endif diff --git a/external/onlineupdate/install_updateservice.cxx b/external/onlineupdate/install_updateservice.cxx index 47c90bc148d6..3d0bbf0e2aaa 100644 --- a/external/onlineupdate/install_updateservice.cxx +++ b/external/onlineupdate/install_updateservice.cxx @@ -195,6 +195,10 @@ extern "C" __declspec(dllexport) UINT __stdcall PrepareUpdateservice(MSIHANDLE h { ok = false; } + if (MsiSetPropertyW(handle, L"remove_updateservice", loc.c_str()) != ERROR_SUCCESS) + { + ok = false; + } if (MsiSetPropertyW(handle, L"uninstall_updateservice", loc.c_str()) != ERROR_SUCCESS) { ok = false; @@ -221,6 +225,32 @@ extern "C" __declspec(dllexport) UINT __stdcall InstallUpdateservice(MSIHANDLE h return ok ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; } +extern "C" __declspec(dllexport) UINT __stdcall RemoveUpdateservice(MSIHANDLE handle) +{ + std::wstring sInstallPath; + if (!getProperty(handle, L"CustomActionData", &sInstallPath)) + { + return ERROR_INSTALL_FAILURE; + } + + const wchar_t* strarray[] = { L"\\program\\mar.exe", L"\\program\\update_service.exe", + L"\\program\\updater.exe", L"\\program\\updater.ini" }; + + for (const wchar_t* file : strarray) + { + std::wstring sFilePath = sInstallPath + file; + WIN32_FIND_DATAW aFindData; + HANDLE hFind = FindFirstFileW(sFilePath.c_str(), &aFindData); + if (INVALID_HANDLE_VALUE != hFind) + { + FindClose(hFind); + SetFileAttributesW(sFilePath.c_str(), FILE_ATTRIBUTE_NORMAL); + DeleteFileW(sFilePath.c_str()); + } + } + return ERROR_SUCCESS; +} + extern "C" __declspec(dllexport) UINT __stdcall UninstallUpdateservice(MSIHANDLE handle) { std::wstring loc; diff --git a/scp2/source/ooo/windowscustomaction_ooo.scp b/scp2/source/ooo/windowscustomaction_ooo.scp index 576daceeaf2a..2b1344b199e6 100644 --- a/scp2/source/ooo/windowscustomaction_ooo.scp +++ b/scp2/source/ooo/windowscustomaction_ooo.scp @@ -263,7 +263,16 @@ WindowsCustomAction gid_Customaction_install_updateservice Source = "install_updateservice.dll"; Target = "InstallUpdateservice"; Inbinarytable = 1; - Assignment1 = ("InstallExecuteSequence", "Not REMOVE=\"ALL\"", "InstallFinalize"); + Assignment1 = ("InstallExecuteSequence", "(\&gm_o_Onlineupdate=3 Or (\!gm_o_Onlineupdate=3 And \&gm_o_Onlineupdate=-1)) And Not REMOVE=\"ALL\"", "InstallFinalize"); +End + +WindowsCustomAction gid_Customaction_remove_updateservice + Name = "remove_updateservice"; + Typ = "3137"; + Source = "install_updateservice.dll"; + Target = "RemoveUpdateservice"; + Inbinarytable = 1; + Assignment1 = ("InstallExecuteSequence", "Not (\&gm_o_Onlineupdate=3 Or (\!gm_o_Onlineupdate=3 And \&gm_o_Onlineupdate=-1)) And Not REMOVE=\"ALL\"", "InstallFinalize"); End WindowsCustomAction gid_Customaction_uninstall_updateservice @@ -272,7 +281,7 @@ WindowsCustomAction gid_Customaction_uninstall_updateservice Source = "install_updateservice.dll"; Target = "UninstallUpdateservice"; Inbinarytable = 1; - Assignment1 = ("InstallExecuteSequence", "REMOVE=\"ALL\"", "UnpublishComponents"); + Assignment1 = ("InstallExecuteSequence", "(\&gm_o_Onlineupdate=3 Or (\!gm_o_Onlineupdate=3 And \&gm_o_Onlineupdate=-1)) And REMOVE=\"ALL\"", "UnpublishComponents"); End #endif