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 <balazs.varga.extern@allotropia.de>
This commit is contained in:
Balazs Varga 2025-03-19 09:32:15 +01:00
parent 08ef545000
commit 28f81e8b0e
3 changed files with 50 additions and 3 deletions

View File

@ -18,12 +18,15 @@
*/ */
#include <config_features.h> #include <config_features.h>
#include <config_folders.h>
#include <rtl/bootstrap.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <svl/numformat.hxx> #include <svl/numformat.hxx>
#include <svl/zforlist.hxx> #include <svl/zforlist.hxx>
#include "optupdt.hxx" #include "optupdt.hxx"
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <comphelper/DirectoryHelper.hxx>
#include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/configuration/theDefaultProvider.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp> #include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
@ -524,6 +527,11 @@ bool SvxOnlineUpdateTabPage::isTraditionalOnlineUpdateAvailable() {
bool SvxOnlineUpdateTabPage::isMarOnlineUpdateAvailable() { bool SvxOnlineUpdateTabPage::isMarOnlineUpdateAvailable() {
#if HAVE_FEATURE_UPDATE_MAR #if HAVE_FEATURE_UPDATE_MAR
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; return true;
#else #else
return false; return false;

View File

@ -195,6 +195,10 @@ extern "C" __declspec(dllexport) UINT __stdcall PrepareUpdateservice(MSIHANDLE h
{ {
ok = false; 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) if (MsiSetPropertyW(handle, L"uninstall_updateservice", loc.c_str()) != ERROR_SUCCESS)
{ {
ok = false; ok = false;
@ -221,6 +225,32 @@ extern "C" __declspec(dllexport) UINT __stdcall InstallUpdateservice(MSIHANDLE h
return ok ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; 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) extern "C" __declspec(dllexport) UINT __stdcall UninstallUpdateservice(MSIHANDLE handle)
{ {
std::wstring loc; std::wstring loc;

View File

@ -263,7 +263,16 @@ WindowsCustomAction gid_Customaction_install_updateservice
Source = "install_updateservice.dll"; Source = "install_updateservice.dll";
Target = "InstallUpdateservice"; Target = "InstallUpdateservice";
Inbinarytable = 1; 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 End
WindowsCustomAction gid_Customaction_uninstall_updateservice WindowsCustomAction gid_Customaction_uninstall_updateservice
@ -272,7 +281,7 @@ WindowsCustomAction gid_Customaction_uninstall_updateservice
Source = "install_updateservice.dll"; Source = "install_updateservice.dll";
Target = "UninstallUpdateservice"; Target = "UninstallUpdateservice";
Inbinarytable = 1; 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 End
#endif #endif