1 // Copyright 2017 Citra Emulator Project 2 // Licensed under GPLv2 or any later version 3 // Refer to the license.txt file included. 4 // 5 // Based on the original work by Felix Barx 6 // Copyright (c) 2015, Felix Barz 7 // All rights reserved. 8 9 #pragma once 10 11 #include <QtCore/QProcess> 12 #include "citra_qt/updater/updater.h" 13 14 enum class XMLParseResult { 15 Success, 16 NoUpdate, 17 InvalidXML, 18 }; 19 20 class UpdaterPrivate : public QObject { 21 Q_OBJECT; 22 23 public: 24 explicit UpdaterPrivate(Updater* parent_ptr); 25 ~UpdaterPrivate(); 26 27 static QString ToSystemExe(QString base_path); 28 29 bool HasUpdater() const; 30 31 bool StartUpdateCheck(); 32 void StopUpdateCheck(int delay, bool async); 33 34 void LaunchWithArguments(const QStringList& args); 35 void LaunchUI(); 36 void SilentlyUpdate(); 37 38 void LaunchUIOnExit(); 39 40 public slots: 41 void UpdaterReady(int exit_code, QProcess::ExitStatus exit_status); 42 void UpdaterError(QProcess::ProcessError error); 43 44 void AboutToExit(); 45 46 private: 47 XMLParseResult ParseResult(const QByteArray& output, QList<Updater::UpdateInfo>& out); 48 49 Updater* parent; 50 51 QString tool_path{}; 52 QList<Updater::UpdateInfo> update_info{}; 53 bool normal_exit = true; 54 int last_error_code = 0; 55 QByteArray last_error_log = EXIT_SUCCESS; 56 57 bool running = false; 58 QProcess* main_process = nullptr; 59 60 bool launch_ui_on_exit = false; 61 62 QStringList run_arguments{QStringLiteral("--updater")}; 63 QStringList silent_arguments{QStringLiteral("--silentUpdate")}; 64 65 friend class Updater; 66 }; 67