init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
90
Telegram/SourceFiles/platform/mac/launcher_mac.mm
Normal file
90
Telegram/SourceFiles/platform/mac/launcher_mac.mm
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#include "platform/mac/launcher_mac.h"
|
||||
|
||||
#include "core/crash_reports.h"
|
||||
#include "core/update_checker.h"
|
||||
#include "base/base_file_utilities.h"
|
||||
#include "base/platform/base_platform_file_utilities.h"
|
||||
#include "base/platform/mac/base_utilities_mac.h"
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <CoreFoundation/CFURL.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
namespace Platform {
|
||||
|
||||
Launcher::Launcher(int argc, char *argv[])
|
||||
: Core::Launcher(argc, argv) {
|
||||
}
|
||||
|
||||
void Launcher::initHook() {
|
||||
base::RegisterBundledResources(u"Telegram.rcc"_q);
|
||||
}
|
||||
|
||||
bool Launcher::launchUpdater(UpdaterLaunch action) {
|
||||
if (cExeName().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
@autoreleasepool {
|
||||
|
||||
#ifdef OS_MAC_STORE
|
||||
// In AppStore version we don't have Updater.
|
||||
// We just relaunch our app.
|
||||
if (action == UpdaterLaunch::JustRelaunch) {
|
||||
NSDictionary *conf = [NSDictionary dictionaryWithObject:[NSArray array] forKey:NSWorkspaceLaunchConfigurationArguments];
|
||||
[[NSWorkspace sharedWorkspace] launchApplicationAtURL:[NSURL fileURLWithPath:Q2NSString(cExeDir() + cExeName())] options:NSWorkspaceLaunchAsync | NSWorkspaceLaunchNewInstance configuration:conf error:0];
|
||||
return true;
|
||||
}
|
||||
#endif // OS_MAC_STORE
|
||||
|
||||
NSString *path = @"", *args = @"";
|
||||
@try {
|
||||
path = [[NSBundle mainBundle] bundlePath];
|
||||
if (!path) {
|
||||
LOG(("Could not get bundle path!!"));
|
||||
return false;
|
||||
}
|
||||
path = [path stringByAppendingString:@"/Contents/Frameworks/Updater"];
|
||||
base::Platform::RemoveQuarantine(QFile::decodeName([path fileSystemRepresentation]));
|
||||
|
||||
NSMutableArray *args = [[NSMutableArray alloc] initWithObjects:@"-workpath", Q2NSString(cWorkingDir()), @"-procid", nil];
|
||||
[args addObject:[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]]];
|
||||
if (cRestartingToSettings()) [args addObject:@"-tosettings"];
|
||||
if (action == UpdaterLaunch::JustRelaunch) [args addObject:@"-noupdate"];
|
||||
if (cLaunchMode() == LaunchModeAutoStart) [args addObject:@"-autostart"];
|
||||
if (Logs::DebugEnabled()) [args addObject:@"-debug"];
|
||||
if (cStartInTray()) [args addObject:@"-startintray"];
|
||||
if (cDataFile() != u"data"_q) {
|
||||
[args addObject:@"-key"];
|
||||
[args addObject:Q2NSString(cDataFile())];
|
||||
}
|
||||
if (customWorkingDir()) {
|
||||
[args addObject:@"-workdir_custom"];
|
||||
}
|
||||
|
||||
DEBUG_LOG(("Application Info: executing %1 %2").arg(NS2QString(path)).arg(NS2QString([args componentsJoinedByString:@" "])));
|
||||
Logs::closeMain();
|
||||
CrashReports::Finish();
|
||||
if (![NSTask launchedTaskWithLaunchPath:path arguments:args]) {
|
||||
DEBUG_LOG(("Task not launched while executing %1 %2").arg(NS2QString(path)).arg(NS2QString([args componentsJoinedByString:@" "])));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@catch (NSException *exception) {
|
||||
LOG(("Exception caught while executing %1 %2").arg(NS2QString(path)).arg(NS2QString(args)));
|
||||
return false;
|
||||
}
|
||||
@finally {
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
Reference in New Issue
Block a user