Browse Source

Switch auto-update method with the new windows installer

Tobias Hieta 9 years ago
parent
commit
e494bb2abb

+ 2 - 1
CMakeModules/WindowsInstaller.cmake

@@ -85,6 +85,7 @@ function(wix_light)
   if(NOT _WL_TARGET)
     set(_WL_TARGET wix_${_WL_OUTPUT})
   endif()
+  
     
   add_custom_command(OUTPUT ${_WL_OUTPUT}
                      DEPENDS ${_WL_OBJS} ${_WL_DEPENDS}
@@ -150,4 +151,4 @@ wix_create_installer(PlexMediaPlayer-${VERSION_STRING}-windows-x64.exe
                      BASEDIR "${PROJECT_SOURCE_DIR}/bundle/win"
 )
 
-add_custom_target(windows_package DEPENDS PlexMediaPlayerInstaller)
+add_custom_target(windows_package DEPENDS PlexMediaPlayerInstaller)

+ 11 - 5
src/system/UpdateManager.cpp

@@ -9,10 +9,14 @@
 #include "utils/HelperLauncher.h"
 #include "system/SystemComponent.h"
 
-#if KONVERGO_OPENELEC
+#ifdef KONVERGO_OPENELEC
 #include "OEUpdateManager.h"
 #endif
 
+#ifdef Q_OS_WIN
+#include "UpdateManagerWin32.h"
+#endif
+
 UpdateManager* g_updateManager;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -20,10 +24,12 @@ UpdateManager* UpdateManager::Get()
 {
   if (!g_updateManager)
   {
-#if KONVERGO_OPENELEC
-    g_updateManager = new OEUpdateManager(NULL);
+#if defined(KONVERGO_OPENELEC)
+    g_updateManager = new OEUpdateManager(nullptr);
+#elif defined(Q_OS_WIN)
+    g_updateManager = new UpdateManagerWin32(nullptr);
 #else
-    g_updateManager = new UpdateManager(NULL);
+    g_updateManager = new UpdateManager(nullptr);
 #endif
   }
 
@@ -181,4 +187,4 @@ bool UpdateManager::CheckForUpdates()
       return true;
   }
   return false;
-}
+}

+ 36 - 0
src/system/UpdateManagerWin32.cpp

@@ -0,0 +1,36 @@
+//
+// Created by msn on 2016-02-16.
+//
+
+#include "UpdateManagerWin32.h"
+#include "Paths.h"
+
+#include "QsLog.h"
+
+#include <QFile>
+#include <QDir>
+#include <QProcess>
+
+/////////////////////////////////////////////////////////////////////////////////////////
+bool UpdateManagerWin32::applyUpdate(const QString& version)
+{
+  QString updateExe = GetPath("PlexMediaPlayer-" + version + "-windows-x64.exe", version, true);
+  if(QFile::exists(updateExe))
+  {
+    QStringList args;
+    args << "/passive" << "/norestart" << "/log" << Paths::logDir("Plex Media Player Installer.log");
+
+    QFile::remove(GetPath("_readyToApply", version, false));
+    if (QProcess::startDetached(updateExe, args, QDir::temp().absolutePath()))
+    {
+      QLOG_DEBUG() << "Running update...";
+      return true;
+    }
+  }
+  else
+  {
+    QLOG_WARN() << "Failed to find update file:" << updateExe;
+  }
+
+  return false;
+}

+ 19 - 0
src/system/UpdateManagerWin32.h

@@ -0,0 +1,19 @@
+//
+// Created by Tobias Hieta on 2016-02-16.
+//
+
+#ifndef PLEXMEDIAPLAYER_UPDATEMANAGERWIN32_H
+#define PLEXMEDIAPLAYER_UPDATEMANAGERWIN32_H
+
+#include "UpdateManager.h"
+
+class UpdateManagerWin32 : public UpdateManager
+{
+public:
+  UpdateManagerWin32(QObject *parent = 0) {};
+  ~UpdateManagerWin32() {};
+
+  virtual bool applyUpdate(const QString& version) override;
+};
+
+#endif //PLEXMEDIAPLAYER_UPDATEMANAGERWIN32_H