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