summaryrefslogtreecommitdiff
path: root/desktop
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-08-09 15:36:03 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-08-13 17:55:25 +0200
commit25ac5330e84b5e8c55cd81c7fd0c84c8aa889d47 (patch)
tree7898f8d38db899542a4cf18c3dc5d042c479aa47 /desktop
parent596f866ee9e3acee114d3b4638df3f9000d93cc7 (diff)
updater: call the updater executable on windows
Change-Id: Ibbcfea2e42bc55cf5c018bfb1856be7f1981f57d Reviewed-on: https://gerrit.libreoffice.org/40922 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'desktop')
-rw-r--r--desktop/Library_sofficeapp.mk7
-rw-r--r--desktop/source/app/app.cxx4
-rw-r--r--desktop/source/app/updater.cxx65
-rw-r--r--desktop/source/app/updater.hxx2
4 files changed, 57 insertions, 21 deletions
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 1c88d4e1a421..53496f2c1544 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -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,\
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index fe89eeb3b628..cc5e59dcda9b 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -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())
{
diff --git a/desktop/source/app/updater.cxx b/desktop/source/app/updater.cxx
index f855a15672a0..1ee55fcf3944 100644
--- a/desktop/source/app/updater.cxx
+++ b/desktop/source/app/updater.cxx
@@ -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 {
diff --git a/desktop/source/app/updater.hxx b/desktop/source/app/updater.hxx
index 4c01129f9697..937728dd70bc 100644
--- a/desktop/source/app/updater.hxx
+++ b/desktop/source/app/updater.hxx
@@ -12,7 +12,7 @@
#include <rtl/ustring.hxx>
-void update();
+bool update();
void update_checker();