From d955b29585010b324dc6c7a6959d968cc4f399be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Sat, 3 Oct 2015 18:55:37 +0200 Subject: [PATCH] Allow to disable 'register custom scheme' functions using a macro. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adding "DEFINES += TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME" to Telegram.pro would disable these functions. This can be useful when the application is distributed using an installer or a package manager that can apply these settings system-globaly. Signed-off-by: Eduardo Sánchez Muñoz (github: eduardosm) --- Telegram/SourceFiles/pspecific_linux.cpp | 2 ++ Telegram/SourceFiles/pspecific_mac_p.mm | 2 ++ Telegram/SourceFiles/pspecific_wnd.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/Telegram/SourceFiles/pspecific_linux.cpp b/Telegram/SourceFiles/pspecific_linux.cpp index 2859c9067..dde085ab8 100644 --- a/Telegram/SourceFiles/pspecific_linux.cpp +++ b/Telegram/SourceFiles/pspecific_linux.cpp @@ -1165,6 +1165,7 @@ namespace { } void psRegisterCustomScheme() { + #ifndef TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME QString home(_psHomeDir()); if (home.isEmpty()) return; @@ -1249,6 +1250,7 @@ void psRegisterCustomScheme() { LOG(("App Error: Could not open '%1' for write").arg(file)); } } + #endif } void psNewVersion() { diff --git a/Telegram/SourceFiles/pspecific_mac_p.mm b/Telegram/SourceFiles/pspecific_mac_p.mm index 845ca5e2a..270f5fb2e 100644 --- a/Telegram/SourceFiles/pspecific_mac_p.mm +++ b/Telegram/SourceFiles/pspecific_mac_p.mm @@ -932,8 +932,10 @@ void objc_finish() { } void objc_registerCustomScheme() { + #ifndef TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME OSStatus result = LSSetDefaultHandlerForURLScheme(CFSTR("tg"), (CFStringRef)[[NSBundle mainBundle] bundleIdentifier]); DEBUG_LOG(("App Info: set default handler for 'tg' scheme result: %1").arg(result)); + #endif } BOOL _execUpdater(BOOL update = YES) { diff --git a/Telegram/SourceFiles/pspecific_wnd.cpp b/Telegram/SourceFiles/pspecific_wnd.cpp index 3cba849fe..54e05d56f 100644 --- a/Telegram/SourceFiles/pspecific_wnd.cpp +++ b/Telegram/SourceFiles/pspecific_wnd.cpp @@ -2211,6 +2211,7 @@ namespace { } void RegisterCustomScheme() { + #ifndef TDESKTOP_DISABLE_REGISTER_CUSTOM_SCHEME DEBUG_LOG(("App Info: Checking custom scheme 'tg'..")); HKEY rkey; @@ -2227,6 +2228,7 @@ void RegisterCustomScheme() { if (!_psOpenRegKey(L"Software\\Classes\\tg\\shell\\open", &rkey)) return; if (!_psOpenRegKey(L"Software\\Classes\\tg\\shell\\open\\command", &rkey)) return; if (!_psSetKeyValue(rkey, 0, '"' + exe + qsl("\" -workdir \"") + cWorkingDir() + qsl("\" -- \"%1\""))) return; + #endif } void psNewVersion() {