cui/source/options/optupdt.cxx                  |   10 +++++++-
 external/onlineupdate/install_updateservice.cxx |   30 ++++++++++++++++++++++++
 scp2/source/ooo/windowscustomaction_ooo.scp     |   13 ++++++++--
 3 files changed, 50 insertions(+), 3 deletions(-)

New commits:
commit 28f81e8b0e13ef725d2c0993d9bb1c0a5ee3757b
Author:     Balazs Varga <[email protected]>
AuthorDate: Wed Mar 19 09:32:15 2025 +0100
Commit:     Balazs Varga <[email protected]>
CommitDate: Mon Mar 24 18:22:12 2025 +0100

    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 <[email protected]>

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 <config_features.h>
+#include <config_folders.h>
+#include <rtl/bootstrap.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
 #include <svl/numformat.hxx>
 #include <svl/zforlist.hxx>
 #include "optupdt.hxx"
 #include <comphelper/processfactory.hxx>
+#include <comphelper/DirectoryHelper.hxx>
 #include <com/sun/star/configuration/theDefaultProvider.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
@@ -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

Reply via email to