1 /* 2 This file is part of Telegram Desktop, 3 the official desktop application for the Telegram messaging service. 4 5 For license and copyright information please follow this link: 6 https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL 7 */ 8 #pragma once 9 10 #include "core/base_integration.h" 11 12 namespace Core { 13 14 class Launcher { 15 public: 16 Launcher(int argc, char *argv[]); 17 18 static std::unique_ptr<Launcher> Create(int argc, char *argv[]); 19 20 virtual int exec(); 21 22 QString argumentsString() const; 23 bool customWorkingDir() const; 24 25 uint64 installationTag() const; 26 27 bool checkPortableVersionFolder(); 28 void workingFolderReady(); 29 void writeDebugModeSetting(); 30 void writeInstallBetaVersionsSetting(); 31 32 virtual ~Launcher() = default; 33 34 protected: 35 enum class UpdaterLaunch { 36 PerformUpdate, 37 JustRelaunch, 38 }; 39 40 private: 41 void prepareSettings(); 42 void initQtMessageLogging(); 43 void processArguments(); 44 45 QStringList readArguments(int argc, char *argv[]) const; readArgumentsHook(int argc,char * argv[])46 virtual std::optional<QStringList> readArgumentsHook( 47 int argc, 48 char *argv[]) const { 49 return std::nullopt; 50 } 51 52 void init(); initHook()53 virtual void initHook() { 54 } 55 56 virtual bool launchUpdater(UpdaterLaunch action) = 0; 57 58 int executeApplication(); 59 60 int _argc; 61 char **_argv; 62 QStringList _arguments; 63 BaseIntegration _baseIntegration; 64 65 bool _customWorkingDir = false; 66 67 }; 68 69 } // namespace Core 70