Kaydet (Commit) 25ac5330 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

updater: call the updater executable on windows

Change-Id: Ibbcfea2e42bc55cf5c018bfb1856be7f1981f57d
Reviewed-on: https://gerrit.libreoffice.org/40922Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarkus Mohrhard <markus.mohrhard@googlemail.com>
üst 596f866e
......@@ -80,6 +80,13 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
vcl \
))
ifeq ($(OS),WNT)
$(eval $(call gb_Library_use_static_libraries,sofficeapp,\
$(if $(ENABLE_ONLINE_UPDATE_MAR),\
windows_process )\
))
endif
ifeq ($(OS),MACOSX)
$(eval $(call gb_Library_add_cxxflags,sofficeapp,\
......
......@@ -1442,7 +1442,9 @@ int Desktop::Main()
xFlushable->flush();
// avoid the old oosplash staying around
CloseSplashScreen();
update();
bool bSuccess = update();
if (bSuccess)
return EXIT_SUCCESS;
}
else if (isTimeForUpdateCheck())
{
......
......@@ -15,6 +15,10 @@
#endif
#ifdef _WIN32
#include <comphelper/windowsStart.hxx>
#endif
#include <fstream>
#include <config_folders.h>
#include <rtl/bootstrap.hxx>
......@@ -116,33 +120,41 @@ void CopyUpdaterToTempDir(const OUString& rInstallDirURL, const OUString& rTempD
CopyFileToDir(rTempDirURL, aUpdaterName, rInstallDirURL);
}
void createStr(const char* pSrc, char** pArgs, size_t i)
{
size_t nLength = std::strlen(pSrc);
char* pFinalStr = new char[nLength + 1];
std::strncpy(pFinalStr, pSrc, nLength);
pFinalStr[nLength] = '\0';
pArgs[i] = pFinalStr;
}
#ifdef UNX
typedef char CharT;
#define tstrncpy std::strncpy
#elif _WIN32
typedef wchar_t CharT;
#define tstrncpy std::wcsncpy
#else
#error "Need an implementation"
#endif
void createStr(const OUString& rStr, char** pArgs, size_t i)
void createStr(const OUString& rStr, CharT** pArgs, size_t i)
{
#ifdef UNX
OString aStr = OUStringToOString(rStr, RTL_TEXTENCODING_UTF8);
char* pStr = new char[aStr.getLength() + 1];
std::strncpy(pStr, aStr.getStr(), aStr.getLength());
#elif _WIN32
OUString aStr = rStr;
#else
#error "Need an implementation"
#endif
CharT* pStr = new CharT[aStr.getLength() + 1];
tstrncpy(pStr, (CharT*)aStr.getStr(), aStr.getLength());
pStr[aStr.getLength()] = '\0';
pArgs[i] = pStr;
}
char** createCommandLine()
CharT** createCommandLine()
{
OUString aInstallDir = Updater::getInstallationPath();
size_t nCommandLineArgs = rtl_getAppCommandArgCount();
size_t nArgs = 8 + nCommandLineArgs;
char** pArgs = new char*[nArgs];
CharT** pArgs = new CharT*[nArgs];
{
createStr(pUpdaterName, pArgs, 0);
OUString aUpdaterName = OUString::fromUtf8(pUpdaterName);
createStr(aUpdaterName, pArgs, 0);
}
{
// directory with the patch log
......@@ -163,8 +175,17 @@ char** createCommandLine()
createStr(aInstallDir, pArgs, 3);
}
{
const char* pPID = "0";
createStr(pPID, pArgs, 4);
#ifdef UNX
OUString aPID("0");
#elif _WIN32
oslProcessInfo aInfo;
aInfo.Size = sizeof(oslProcessInfo);
osl_getProcessInfo(nullptr, osl_Process_IDENTIFIER, &aInfo);
OUString aPID = OUString::number(aInfo.Ident);
#else
#error "Need an implementation"
#endif
createStr(aPID, pArgs, 4);
}
{
OUString aExeDir = Updater::getExecutableDirURL();
......@@ -247,7 +268,7 @@ bool isUserWritable(const OUString& rFileURL)
}
void update()
bool update()
{
utl::TempFile aTempDir(nullptr, true);
OUString aTempDirURL = aTempDir.GetURL();
......@@ -257,9 +278,9 @@ void update()
OString aPath = OUStringToOString(aTempDirPath + "/" + OUString::fromUtf8(pUpdaterName), RTL_TEXTENCODING_UTF8);
Updater::log("Calling the updater with parameters: ");
char** pArgs = createCommandLine();
CharT** pArgs = createCommandLine();
bool bSuccess = true;
#if UNX
const char* pUpdaterTestReplace = std::getenv("LIBO_UPDATER_TEST_REPLACE");
if (!pUpdaterTestReplace)
......@@ -267,6 +288,7 @@ void update()
if (execv(aPath.getStr(), pArgs))
{
printf("execv failed with error %d %s\n",errno,strerror(errno));
bSuccess = false;
}
}
else
......@@ -275,7 +297,10 @@ void update()
{
SAL_WARN("desktop.updater", pArgs[i]);
}
bSuccess = false;
}
#elif _WIN32
bSuccess = WinLaunchChild(nullptr, 8, pArgs);
#endif
for (size_t i = 0; i < 8 + rtl_getAppCommandArgCount(); ++i)
......@@ -283,6 +308,8 @@ void update()
delete[] pArgs[i];
}
delete[] pArgs;
return bSuccess;
}
namespace {
......
......@@ -12,7 +12,7 @@
#include <rtl/ustring.hxx>
void update();
bool update();
void update_checker();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment