| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | /*
 | 
					
						
							|  |  |  | This file is part of Telegram Desktop, | 
					
						
							| 
									
										
										
										
											2018-01-03 13:23:14 +03:00
										 |  |  | the official desktop application for the Telegram messaging service. | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-03 13:23:14 +03:00
										 |  |  | For license and copyright information please follow this link: | 
					
						
							|  |  |  | https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | */ | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-02 20:06:47 +03:00
										 |  |  | #include "core/base_integration.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | namespace Core { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-12 13:18:28 +04:00
										 |  |  | extern const char kOptionFractionalScalingEnabled[]; | 
					
						
							| 
									
										
										
										
											2023-02-22 11:44:59 +04:00
										 |  |  | extern const char kOptionFreeType[]; | 
					
						
							| 
									
										
										
										
											2023-01-12 13:18:28 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | class Launcher { | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2021-08-24 17:43:31 +03:00
										 |  |  | 	Launcher(int argc, char *argv[]); | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	static std::unique_ptr<Launcher> Create(int argc, char *argv[]); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-13 04:34:27 +04:00
										 |  |  | 	static Launcher &Instance() { | 
					
						
							|  |  |  | 		Expects(InstanceSetter::Instance != nullptr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return *InstanceSetter::Instance; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-23 03:20:40 +04:00
										 |  |  | 	virtual int exec(); | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-13 06:03:19 +04:00
										 |  |  | 	const QStringList &arguments() const; | 
					
						
							| 
									
										
										
										
											2023-08-14 09:26:39 +04:00
										 |  |  | 	QString initialWorkingDir() const; | 
					
						
							| 
									
										
										
										
											2018-06-03 22:52:23 +03:00
										 |  |  | 	bool customWorkingDir() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-21 17:42:21 +04:00
										 |  |  | 	uint64 installationTag() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	bool checkPortableVersionFolder(); | 
					
						
							| 
									
										
										
										
											2023-07-22 01:07:22 +04:00
										 |  |  | 	bool validateCustomWorkingDir(); | 
					
						
							| 
									
										
										
										
											2019-01-21 17:42:21 +04:00
										 |  |  | 	void workingFolderReady(); | 
					
						
							|  |  |  | 	void writeDebugModeSetting(); | 
					
						
							|  |  |  | 	void writeInstallBetaVersionsSetting(); | 
					
						
							| 
									
										
										
										
											2017-12-12 11:52:53 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-13 04:34:27 +04:00
										 |  |  | 	virtual ~Launcher(); | 
					
						
							| 
									
										
										
										
											2018-04-08 21:32:48 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-12 11:52:53 +04:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	enum class UpdaterLaunch { | 
					
						
							|  |  |  | 		PerformUpdate, | 
					
						
							|  |  |  | 		JustRelaunch, | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2017-12-12 11:52:53 +04:00
										 |  |  | 	void prepareSettings(); | 
					
						
							| 
									
										
										
										
											2021-04-20 16:40:54 +04:00
										 |  |  | 	void initQtMessageLogging(); | 
					
						
							| 
									
										
										
										
											2017-12-12 11:52:53 +04:00
										 |  |  | 	void processArguments(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-12 12:15:33 +04:00
										 |  |  | 	QStringList readArguments(int argc, char *argv[]) const; | 
					
						
							| 
									
										
										
										
											2018-09-21 19:28:46 +03:00
										 |  |  | 	virtual std::optional<QStringList> readArgumentsHook( | 
					
						
							| 
									
										
										
										
											2017-12-12 12:15:33 +04:00
										 |  |  | 			int argc, | 
					
						
							|  |  |  | 			char *argv[]) const { | 
					
						
							| 
									
										
										
										
											2018-09-21 19:28:46 +03:00
										 |  |  | 		return std::nullopt; | 
					
						
							| 
									
										
										
										
											2017-12-12 12:15:33 +04:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | 	void init(); | 
					
						
							| 
									
										
										
										
											2017-12-12 11:52:53 +04:00
										 |  |  | 	virtual void initHook() { | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2023-01-12 13:18:28 +04:00
										 |  |  | 	virtual void initHighDpi(); | 
					
						
							| 
									
										
										
										
											2017-12-12 11:52:53 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	virtual bool launchUpdater(UpdaterLaunch action) = 0; | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 22:41:34 +04:00
										 |  |  | 	int executeApplication(); | 
					
						
							| 
									
										
										
										
											2017-12-12 12:15:33 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-13 04:34:27 +04:00
										 |  |  | 	struct InstanceSetter { | 
					
						
							|  |  |  | 		InstanceSetter(not_null<Launcher*> instance) { | 
					
						
							|  |  |  | 			Expects(Instance == nullptr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			Instance = instance; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		static Launcher *Instance; | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 	InstanceSetter _setter = { this }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | 	int _argc; | 
					
						
							|  |  |  | 	char **_argv; | 
					
						
							|  |  |  | 	QStringList _arguments; | 
					
						
							| 
									
										
										
										
											2019-11-02 20:06:47 +03:00
										 |  |  | 	BaseIntegration _baseIntegration; | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-14 09:26:39 +04:00
										 |  |  | 	QString _initialWorkingDir; | 
					
						
							| 
									
										
										
										
											2023-07-22 01:07:22 +04:00
										 |  |  | 	QString _customWorkingDir; | 
					
						
							| 
									
										
										
										
											2017-12-12 11:52:53 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-11 18:45:29 +04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace Core
 |