mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
parent
81327ede7b
commit
f10ed4b9bc
17 changed files with 343 additions and 53 deletions
|
@ -982,6 +982,8 @@ PRIVATE
|
||||||
platform/win/windows_dlls.h
|
platform/win/windows_dlls.h
|
||||||
platform/win/windows_event_filter.cpp
|
platform/win/windows_event_filter.cpp
|
||||||
platform/win/windows_event_filter.h
|
platform/win/windows_event_filter.h
|
||||||
|
platform/win/windows_autostart_task.cpp
|
||||||
|
platform/win/windows_autostart_task.h
|
||||||
platform/win/windows_toast_activator.cpp
|
platform/win/windows_toast_activator.cpp
|
||||||
platform/win/windows_toast_activator.h
|
platform/win/windows_toast_activator.h
|
||||||
platform/platform_audio.h
|
platform/platform_audio.h
|
||||||
|
@ -1192,6 +1194,13 @@ PRIVATE
|
||||||
stdafx.h
|
stdafx.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (NOT build_winstore)
|
||||||
|
remove_target_sources(Telegram ${src_loc}
|
||||||
|
platform/win/windows_start_task.cpp
|
||||||
|
platform/win/windows_start_task.h
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
|
if (DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
|
||||||
remove_target_sources(Telegram ${src_loc}
|
remove_target_sources(Telegram ${src_loc}
|
||||||
platform/linux/linux_xdp_file_dialog.cpp
|
platform/linux/linux_xdp_file_dialog.cpp
|
||||||
|
@ -1490,6 +1499,20 @@ if ((NOT DESKTOP_APP_DISABLE_AUTOUPDATE OR APPLE) AND NOT build_macstore AND NOT
|
||||||
|
|
||||||
set_target_properties(Packer PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder})
|
set_target_properties(Packer PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder})
|
||||||
endif()
|
endif()
|
||||||
|
elseif (build_winstore)
|
||||||
|
add_executable(StartupTask WIN32)
|
||||||
|
init_non_host_target(StartupTask)
|
||||||
|
|
||||||
|
add_dependencies(Telegram StartupTask)
|
||||||
|
|
||||||
|
nice_target_sources(StartupTask ${src_loc}
|
||||||
|
PRIVATE
|
||||||
|
_other/startup_task_win.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(StartupTask PROPERTIES
|
||||||
|
RUNTIME_OUTPUT_DIRECTORY ${output_folder}
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (LINUX AND DESKTOP_APP_USE_PACKAGED)
|
if (LINUX AND DESKTOP_APP_USE_PACKAGED)
|
||||||
|
|
|
@ -361,6 +361,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_native_frame" = "Use system window frame";
|
"lng_settings_native_frame" = "Use system window frame";
|
||||||
"lng_settings_auto_start" = "Launch Telegram when system starts";
|
"lng_settings_auto_start" = "Launch Telegram when system starts";
|
||||||
"lng_settings_start_min" = "Launch minimized";
|
"lng_settings_start_min" = "Launch minimized";
|
||||||
|
"lng_settings_auto_start_disabled_uwp" = "Starting with the system was disabled in Windows Settings.\n\nPlease enable Telegram Desktop in the Startup Apps Settings.";
|
||||||
|
"lng_settings_open_system_settings" = "Open Settings";
|
||||||
"lng_settings_add_sendto" = "Place Telegram in \"Send to\" menu";
|
"lng_settings_add_sendto" = "Place Telegram in \"Send to\" menu";
|
||||||
"lng_settings_section_scale" = "Interface Scale";
|
"lng_settings_section_scale" = "Interface Scale";
|
||||||
"lng_settings_scale_auto" = "Auto ({cur})";
|
"lng_settings_scale_auto" = "Auto ({cur})";
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||||
xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2"
|
xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2"
|
||||||
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
|
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
|
||||||
|
xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
|
||||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||||
IgnorableNamespaces="uap uap2 uap3 rescap">
|
IgnorableNamespaces="uap uap2 uap3 desktop rescap">
|
||||||
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
|
<Identity Name="TelegramMessengerLLP.TelegramDesktop"
|
||||||
ProcessorArchitecture="ARCHITECTURE"
|
ProcessorArchitecture="ARCHITECTURE"
|
||||||
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
|
Publisher="CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"
|
||||||
|
@ -37,6 +38,15 @@
|
||||||
<uap3:Extension Category="windows.protocol">
|
<uap3:Extension Category="windows.protocol">
|
||||||
<uap3:Protocol Name="tg" Parameters="-- "%1"" />
|
<uap3:Protocol Name="tg" Parameters="-- "%1"" />
|
||||||
</uap3:Extension>
|
</uap3:Extension>
|
||||||
|
<desktop:Extension
|
||||||
|
Category="windows.startupTask"
|
||||||
|
Executable="StartupTask.exe"
|
||||||
|
EntryPoint="Windows.FullTrustApplication">
|
||||||
|
<desktop:StartupTask
|
||||||
|
TaskId="TelegramStartupTask"
|
||||||
|
Enabled="false"
|
||||||
|
DisplayName="Telegram Desktop" />
|
||||||
|
</desktop:Extension>
|
||||||
</Extensions>
|
</Extensions>
|
||||||
</Application>
|
</Application>
|
||||||
</Applications>
|
</Applications>
|
||||||
|
|
54
Telegram/SourceFiles/_other/startup_task_win.cpp
Normal file
54
Telegram/SourceFiles/_other/startup_task_win.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
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 <windows.h>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
constexpr auto kMaxPathLong = 32767;
|
||||||
|
|
||||||
|
[[nodiscard]] std::wstring ExecutableDirectory() {
|
||||||
|
auto exePath = std::array<WCHAR, kMaxPathLong + 1>{ 0 };
|
||||||
|
const auto exeLength = GetModuleFileName(
|
||||||
|
nullptr,
|
||||||
|
exePath.data(),
|
||||||
|
kMaxPathLong + 1);
|
||||||
|
if (!exeLength || exeLength >= kMaxPathLong + 1) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
const auto exe = std::wstring(exePath.data());
|
||||||
|
const auto last1 = exe.find_last_of('\\');
|
||||||
|
const auto last2 = exe.find_last_of('/');
|
||||||
|
const auto last = std::max(
|
||||||
|
(last1 == std::wstring::npos) ? -1 : int(last1),
|
||||||
|
(last2 == std::wstring::npos) ? -1 : int(last2));
|
||||||
|
if (last < 0) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return exe.substr(0, last);
|
||||||
|
}
|
||||||
|
|
||||||
|
int APIENTRY wWinMain(
|
||||||
|
HINSTANCE instance,
|
||||||
|
HINSTANCE prevInstance,
|
||||||
|
LPWSTR cmdParamarg,
|
||||||
|
int cmdShow) {
|
||||||
|
const auto directory = ExecutableDirectory();
|
||||||
|
if (!directory.empty()) {
|
||||||
|
ShellExecute(
|
||||||
|
nullptr,
|
||||||
|
nullptr,
|
||||||
|
(directory + L"\\Telegram.exe").c_str(),
|
||||||
|
L"-autostart",
|
||||||
|
directory.data(),
|
||||||
|
SW_SHOWNORMAL);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -226,8 +226,8 @@ void Application::run() {
|
||||||
cSetAutoStart(false);
|
cSetAutoStart(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cLaunchMode() == LaunchModeAutoStart && !cAutoStart()) {
|
if (cLaunchMode() == LaunchModeAutoStart && Platform::AutostartSkip()) {
|
||||||
psAutoStart(false, true);
|
Platform::AutostartToggle(false);
|
||||||
App::quit();
|
App::quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -383,11 +383,7 @@ void start(not_null<Core::Launcher*> launcher) {
|
||||||
|
|
||||||
#elif defined OS_WIN_STORE // Q_OS_UNIX || Q_OS_WINRT
|
#elif defined OS_WIN_STORE // Q_OS_UNIX || Q_OS_WINRT
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
cForceWorkingDir(cExeDir());
|
|
||||||
#else // _DEBUG
|
|
||||||
cForceWorkingDir(psAppDataPath());
|
cForceWorkingDir(psAppDataPath());
|
||||||
#endif // !_DEBUG
|
|
||||||
workingDirChosen = true;
|
workingDirChosen = true;
|
||||||
|
|
||||||
#elif defined Q_OS_WIN
|
#elif defined Q_OS_WIN
|
||||||
|
|
|
@ -560,6 +560,41 @@ bool AutostartSupported() {
|
||||||
return !InSnap();
|
return !InSnap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutostartToggle(bool enabled, Fn<void(bool)> done) {
|
||||||
|
const auto guard = gsl::finally([&] {
|
||||||
|
done(enabled);
|
||||||
|
});
|
||||||
|
|
||||||
|
#ifdef __HAIKU__
|
||||||
|
|
||||||
|
HaikuAutostart(enabled);
|
||||||
|
|
||||||
|
#else // __HAIKU__
|
||||||
|
|
||||||
|
const auto silent = !done;
|
||||||
|
if (InFlatpak()) {
|
||||||
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
PortalAutostart(enabled, silent);
|
||||||
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
||||||
|
} else {
|
||||||
|
const auto autostart = QStandardPaths::writableLocation(
|
||||||
|
QStandardPaths::GenericConfigLocation)
|
||||||
|
+ qsl("/autostart/");
|
||||||
|
|
||||||
|
if (enabled) {
|
||||||
|
GenerateDesktopFile(autostart, qsl("-autostart"), silent);
|
||||||
|
} else {
|
||||||
|
QFile::remove(autostart + QGuiApplication::desktopFileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __HAIKU__
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AutostartSkip() {
|
||||||
|
return !cAutoStart();
|
||||||
|
}
|
||||||
|
|
||||||
bool TrayIconSupported() {
|
bool TrayIconSupported() {
|
||||||
return App::wnd()
|
return App::wnd()
|
||||||
? App::wnd()->trayAvailable()
|
? App::wnd()->trayAvailable()
|
||||||
|
@ -637,7 +672,7 @@ QString psAppDataPath() {
|
||||||
|
|
||||||
void psDoCleanup() {
|
void psDoCleanup() {
|
||||||
try {
|
try {
|
||||||
psAutoStart(false, true);
|
Platform::AutostartToggle(false);
|
||||||
psSendToMenu(false, true);
|
psSendToMenu(false, true);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
|
@ -837,29 +872,6 @@ void psNewVersion() {
|
||||||
#endif // __HAIKU__
|
#endif // __HAIKU__
|
||||||
}
|
}
|
||||||
|
|
||||||
void psAutoStart(bool start, bool silent) {
|
|
||||||
#ifdef __HAIKU__
|
|
||||||
HaikuAutostart(start);
|
|
||||||
return;
|
|
||||||
#endif // __HAIKU__
|
|
||||||
|
|
||||||
if (InFlatpak()) {
|
|
||||||
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
PortalAutostart(start, silent);
|
|
||||||
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
|
||||||
} else {
|
|
||||||
const auto autostart = QStandardPaths::writableLocation(
|
|
||||||
QStandardPaths::GenericConfigLocation)
|
|
||||||
+ qsl("/autostart/");
|
|
||||||
|
|
||||||
if (start) {
|
|
||||||
GenerateDesktopFile(autostart, qsl("-autostart"), silent);
|
|
||||||
} else {
|
|
||||||
QFile::remove(autostart + QGuiApplication::desktopFileName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void psSendToMenu(bool send, bool silent) {
|
void psSendToMenu(bool send, bool silent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ inline void IgnoreApplicationActivationRightNow() {
|
||||||
inline void WriteCrashDumpDetails() {
|
inline void WriteCrashDumpDetails() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void AutostartRequestStateFromSystem(Fn<void(bool)> callback) {
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
||||||
inline void psCheckLocalSocket(const QString &serverName) {
|
inline void psCheckLocalSocket(const QString &serverName) {
|
||||||
|
@ -40,7 +43,6 @@ inline void psCheckLocalSocket(const QString &serverName) {
|
||||||
|
|
||||||
void psActivateProcess(uint64 pid = 0);
|
void psActivateProcess(uint64 pid = 0);
|
||||||
QString psAppDataPath();
|
QString psAppDataPath();
|
||||||
void psAutoStart(bool start, bool silent = false);
|
|
||||||
void psSendToMenu(bool send, bool silent = false);
|
void psSendToMenu(bool send, bool silent = false);
|
||||||
|
|
||||||
int psCleanup();
|
int psCleanup();
|
||||||
|
|
|
@ -22,6 +22,9 @@ inline bool AutostartSupported() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void AutostartRequestStateFromSystem(Fn<void(bool)> callback) {
|
||||||
|
}
|
||||||
|
|
||||||
inline bool TrayIconSupported() {
|
inline bool TrayIconSupported() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +53,6 @@ inline void psCheckLocalSocket(const QString &serverName) {
|
||||||
|
|
||||||
void psActivateProcess(uint64 pid = 0);
|
void psActivateProcess(uint64 pid = 0);
|
||||||
QString psAppDataPath();
|
QString psAppDataPath();
|
||||||
void psAutoStart(bool start, bool silent = false);
|
|
||||||
void psSendToMenu(bool send, bool silent = false);
|
void psSendToMenu(bool send, bool silent = false);
|
||||||
|
|
||||||
int psCleanup();
|
int psCleanup();
|
||||||
|
|
|
@ -48,7 +48,7 @@ QString psAppDataPath() {
|
||||||
|
|
||||||
void psDoCleanup() {
|
void psDoCleanup() {
|
||||||
try {
|
try {
|
||||||
psAutoStart(false, true);
|
Platform::AutostartToggle(false);
|
||||||
psSendToMenu(false, true);
|
psSendToMenu(false, true);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
|
@ -181,14 +181,19 @@ void IgnoreApplicationActivationRightNow() {
|
||||||
objc_ignoreApplicationActivationRightNow();
|
objc_ignoreApplicationActivationRightNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AutostartToggle(bool enabled, Fn<void(bool)> done) {
|
||||||
|
done(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AutostartSkip() {
|
||||||
|
return !cAutoStart();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Platform
|
} // namespace Platform
|
||||||
|
|
||||||
void psNewVersion() {
|
void psNewVersion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void psAutoStart(bool start, bool silent) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void psSendToMenu(bool send, bool silent) {
|
void psSendToMenu(bool send, bool silent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,10 @@ void RequestPermission(PermissionType type, Fn<void(PermissionStatus)> resultCal
|
||||||
void OpenSystemSettingsForPermission(PermissionType type);
|
void OpenSystemSettingsForPermission(PermissionType type);
|
||||||
bool OpenSystemSettings(SystemSettingsType type);
|
bool OpenSystemSettings(SystemSettingsType type);
|
||||||
void IgnoreApplicationActivationRightNow();
|
void IgnoreApplicationActivationRightNow();
|
||||||
bool AutostartSupported();
|
[[nodiscard]] bool AutostartSupported();
|
||||||
|
void AutostartRequestStateFromSystem(Fn<void(bool)> callback);
|
||||||
|
void AutostartToggle(bool enabled, Fn<void(bool)> done = nullptr);
|
||||||
|
[[nodiscard]] bool AutostartSkip();
|
||||||
bool TrayIconSupported();
|
bool TrayIconSupported();
|
||||||
bool SkipTaskbarSupported();
|
bool SkipTaskbarSupported();
|
||||||
void WriteCrashDumpDetails();
|
void WriteCrashDumpDetails();
|
||||||
|
|
|
@ -11,10 +11,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "platform/win/notifications_manager_win.h"
|
#include "platform/win/notifications_manager_win.h"
|
||||||
#include "platform/win/windows_app_user_model_id.h"
|
#include "platform/win/windows_app_user_model_id.h"
|
||||||
#include "platform/win/windows_dlls.h"
|
#include "platform/win/windows_dlls.h"
|
||||||
|
#include "platform/win/windows_autostart_task.h"
|
||||||
#include "base/platform/base_platform_info.h"
|
#include "base/platform/base_platform_info.h"
|
||||||
#include "base/platform/win/base_windows_co_task_mem.h"
|
#include "base/platform/win/base_windows_co_task_mem.h"
|
||||||
#include "base/platform/win/base_windows_winrt.h"
|
#include "base/platform/win/base_windows_winrt.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
@ -175,7 +177,7 @@ QString psAppDataPathOld() {
|
||||||
|
|
||||||
void psDoCleanup() {
|
void psDoCleanup() {
|
||||||
try {
|
try {
|
||||||
psAutoStart(false, true);
|
Platform::AutostartToggle(false);
|
||||||
psSendToMenu(false, true);
|
psSendToMenu(false, true);
|
||||||
AppUserModelId::cleanupShortcut();
|
AppUserModelId::cleanupShortcut();
|
||||||
DeleteMyModules();
|
DeleteMyModules();
|
||||||
|
@ -328,7 +330,51 @@ std::optional<bool> IsDarkMode() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutostartSupported() {
|
bool AutostartSupported() {
|
||||||
return !IsWindowsStoreBuild();
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutostartRequestStateFromSystem(Fn<void(bool)> callback) {
|
||||||
|
#ifdef OS_WIN_STORE
|
||||||
|
AutostartTask::RequestState([=](bool enabled) {
|
||||||
|
crl::on_main([=] {
|
||||||
|
callback(enabled);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
#endif // OS_WIN_STORE
|
||||||
|
}
|
||||||
|
|
||||||
|
void AutostartToggle(bool enabled, Fn<void(bool)> done) {
|
||||||
|
#ifdef OS_WIN_STORE
|
||||||
|
const auto requested = enabled;
|
||||||
|
const auto callback = [=](bool enabled) { crl::on_main([=] {
|
||||||
|
if (!Core::IsAppLaunched()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
done(enabled);
|
||||||
|
if (!requested || enabled) {
|
||||||
|
return;
|
||||||
|
} else if (const auto window = Core::App().activeWindow()) {
|
||||||
|
window->show(Box<Ui::ConfirmBox>(
|
||||||
|
tr::lng_settings_auto_start_disabled_uwp(tr::now),
|
||||||
|
tr::lng_settings_open_system_settings(tr::now),
|
||||||
|
[] { AutostartTask::OpenSettings(); Ui::hideLayer(); }));
|
||||||
|
}
|
||||||
|
}); };
|
||||||
|
AutostartTask::Toggle(
|
||||||
|
enabled,
|
||||||
|
done ? Fn<void(bool)>(callback) : nullptr);
|
||||||
|
#else // OS_WIN_STORE
|
||||||
|
_manageAppLnk(start, silent, CSIDL_STARTUP, L"-autostart", L"Telegram autorun link.\nYou can disable autorun in Telegram settings.");
|
||||||
|
done(enabled);
|
||||||
|
#endif // OS_WIN_STORE
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AutostartSkip() {
|
||||||
|
#ifdef OS_WIN_STORE
|
||||||
|
return false;
|
||||||
|
#else // OS_WIN_STORE
|
||||||
|
return !cAutoStart();
|
||||||
|
#endif // OS_WIN_STORE
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteCrashDumpDetails() {
|
void WriteCrashDumpDetails() {
|
||||||
|
@ -534,10 +580,6 @@ void _manageAppLnk(bool create, bool silent, int path_csidl, const wchar_t *args
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void psAutoStart(bool start, bool silent) {
|
|
||||||
_manageAppLnk(start, silent, CSIDL_STARTUP, L"-autostart", L"Telegram autorun link.\nYou can disable autorun in Telegram settings.");
|
|
||||||
}
|
|
||||||
|
|
||||||
void psSendToMenu(bool send, bool silent) {
|
void psSendToMenu(bool send, bool silent) {
|
||||||
_manageAppLnk(send, silent, CSIDL_SENDTO, L"-sendpath", L"Telegram send to link.\nYou can disable send to menu item in Telegram settings.");
|
_manageAppLnk(send, silent, CSIDL_SENDTO, L"-sendpath", L"Telegram send to link.\nYou can disable send to menu item in Telegram settings.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ inline void psCheckLocalSocket(const QString &) {
|
||||||
void psActivateProcess(uint64 pid = 0);
|
void psActivateProcess(uint64 pid = 0);
|
||||||
QString psAppDataPath();
|
QString psAppDataPath();
|
||||||
QString psAppDataPathOld();
|
QString psAppDataPathOld();
|
||||||
void psAutoStart(bool start, bool silent = false);
|
|
||||||
void psSendToMenu(bool send, bool silent = false);
|
void psSendToMenu(bool send, bool silent = false);
|
||||||
|
|
||||||
int psCleanup();
|
int psCleanup();
|
||||||
|
|
111
Telegram/SourceFiles/platform/win/windows_autostart_task.cpp
Normal file
111
Telegram/SourceFiles/platform/win/windows_autostart_task.cpp
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
/*
|
||||||
|
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/win/windows_autostart_task.h"
|
||||||
|
|
||||||
|
#include "base/platform/win/base_windows_winrt.h"
|
||||||
|
|
||||||
|
#include <winrt/Windows.ApplicationModel.h>
|
||||||
|
#include <winrt/Windows.Foundation.h>
|
||||||
|
#include <winrt/Windows.System.h>
|
||||||
|
|
||||||
|
namespace Platform::AutostartTask {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
using namespace winrt::Windows::ApplicationModel;
|
||||||
|
using namespace winrt::Windows::System;
|
||||||
|
using namespace winrt::Windows::Foundation;
|
||||||
|
|
||||||
|
[[nodiscard]] bool IsEnabled(StartupTaskState state) {
|
||||||
|
switch (state) {
|
||||||
|
case StartupTaskState::Enabled:
|
||||||
|
case StartupTaskState::EnabledByPolicy:
|
||||||
|
return true;
|
||||||
|
case StartupTaskState::Disabled:
|
||||||
|
case StartupTaskState::DisabledByPolicy:
|
||||||
|
case StartupTaskState::DisabledByUser:
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void Toggle(bool enabled, Fn<void(bool)> done) {
|
||||||
|
if (!base::WinRT::Supported()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto processEnableResult = [=](StartupTaskState state) {
|
||||||
|
LOG(("Startup Task: Enable finished, state: %1").arg(int(state)));
|
||||||
|
|
||||||
|
done(IsEnabled(state));
|
||||||
|
};
|
||||||
|
const auto processTask = [=](StartupTask task) {
|
||||||
|
LOG(("Startup Task: Got it, state: %1, requested: %2"
|
||||||
|
).arg(int(task.State())
|
||||||
|
).arg(Logs::b(enabled)));
|
||||||
|
|
||||||
|
if (IsEnabled(task.State()) == enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!enabled) {
|
||||||
|
LOG(("Startup Task: Disabling."));
|
||||||
|
task.Disable();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LOG(("Startup Task: Requesting enable."));
|
||||||
|
const auto asyncState = task.RequestEnableAsync();
|
||||||
|
if (!done) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
asyncState.Completed([=](
|
||||||
|
IAsyncOperation<StartupTaskState> operation,
|
||||||
|
AsyncStatus status) {
|
||||||
|
base::WinRT::Try([&] {
|
||||||
|
processEnableResult(operation.GetResults());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
base::WinRT::Try([&] {
|
||||||
|
StartupTask::GetAsync(L"TelegramStartupTask").Completed([=](
|
||||||
|
IAsyncOperation<StartupTask> operation,
|
||||||
|
AsyncStatus status) {
|
||||||
|
base::WinRT::Try([&] {
|
||||||
|
processTask(operation.GetResults());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void RequestState(Fn<void(bool)> callback) {
|
||||||
|
Expects(callback != nullptr);
|
||||||
|
|
||||||
|
if (!base::WinRT::Supported()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto processTask = [=](StartupTask task) {
|
||||||
|
DEBUG_LOG(("Startup Task: Got value, state: %1"
|
||||||
|
).arg(int(task.State())));
|
||||||
|
|
||||||
|
callback(IsEnabled(task.State()));
|
||||||
|
};
|
||||||
|
base::WinRT::Try([&] {
|
||||||
|
StartupTask::GetAsync(L"TelegramStartupTask").Completed([=](
|
||||||
|
IAsyncOperation<StartupTask> operation,
|
||||||
|
AsyncStatus status) {
|
||||||
|
base::WinRT::Try([&] {
|
||||||
|
processTask(operation.GetResults());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenSettings() {
|
||||||
|
Launcher::LaunchUriAsync(Uri(L"ms-settings:startupapps"));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Platform::AutostartTask
|
16
Telegram/SourceFiles/platform/win/windows_autostart_task.h
Normal file
16
Telegram/SourceFiles/platform/win/windows_autostart_task.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Platform::AutostartTask {
|
||||||
|
|
||||||
|
void Toggle(bool enabled, Fn<void(bool)> done);
|
||||||
|
void RequestState(Fn<void(bool)> callback);
|
||||||
|
void OpenSettings();
|
||||||
|
|
||||||
|
} // namespace Platform::AutostartTask
|
|
@ -462,16 +462,21 @@ void SetupSystemIntegrationContent(
|
||||||
return (checked != cAutoStart());
|
return (checked != cAutoStart());
|
||||||
}) | rpl::start_with_next([=](bool checked) {
|
}) | rpl::start_with_next([=](bool checked) {
|
||||||
cSetAutoStart(checked);
|
cSetAutoStart(checked);
|
||||||
psAutoStart(checked);
|
Platform::AutostartToggle(checked, crl::guard(autostart, [=](
|
||||||
if (checked) {
|
bool enabled) {
|
||||||
Local::writeSettings();
|
autostart->setChecked(enabled);
|
||||||
} else if (minimized->entity()->checked()) {
|
if (enabled || !minimized->entity()->checked()) {
|
||||||
minimized->entity()->setChecked(false);
|
Local::writeSettings();
|
||||||
} else {
|
} else {
|
||||||
Local::writeSettings();
|
minimized->entity()->setChecked(false);
|
||||||
}
|
}
|
||||||
|
}));
|
||||||
}, autostart->lifetime());
|
}, autostart->lifetime());
|
||||||
|
|
||||||
|
Platform::AutostartRequestStateFromSystem(crl::guard(
|
||||||
|
controller,
|
||||||
|
[=](bool enabled) { autostart->setChecked(enabled); }));
|
||||||
|
|
||||||
minimized->toggleOn(autostart->checkedValue());
|
minimized->toggleOn(autostart->checkedValue());
|
||||||
minimized->entity()->checkedChanges(
|
minimized->entity()->checkedChanges(
|
||||||
) | rpl::filter([=](bool checked) {
|
) | rpl::filter([=](bool checked) {
|
||||||
|
|
|
@ -223,6 +223,13 @@ if %BuildUWP% equ 0 (
|
||||||
set "UpdateFile=!UpdateFile!_!AlphaSignature!"
|
set "UpdateFile=!UpdateFile!_!AlphaSignature!"
|
||||||
set "PortableFile=talpha!AlphaVersion!_!AlphaSignature!.zip"
|
set "PortableFile=talpha!AlphaVersion!_!AlphaSignature!.zip"
|
||||||
)
|
)
|
||||||
|
) else (
|
||||||
|
:sign2
|
||||||
|
call "%SignPath%" "StartupTask.exe"
|
||||||
|
if %errorlevel% neq 0 (
|
||||||
|
timeout /t 3
|
||||||
|
goto sign2
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
for /f ^"usebackq^ eol^=^
|
for /f ^"usebackq^ eol^=^
|
||||||
|
@ -251,6 +258,7 @@ if %BuildUWP% neq 0 (
|
||||||
if %errorlevel% neq 0 goto error
|
if %errorlevel% neq 0 goto error
|
||||||
|
|
||||||
xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\AppX\"
|
xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\AppX\"
|
||||||
|
xcopy "%ReleasePath%\StartupTask.exe" "%ReleasePath%\AppX\"
|
||||||
xcopy "%ReleasePath%\modules\%Platform%\d3d\d3dcompiler_47.dll" "%ReleasePath%\AppX\modules\%Platform%\d3d\"
|
xcopy "%ReleasePath%\modules\%Platform%\d3d\d3dcompiler_47.dll" "%ReleasePath%\AppX\modules\%Platform%\d3d\"
|
||||||
|
|
||||||
MakeAppx.exe pack /d "%ReleasePath%\AppX" /l /p ..\out\Release\%BinaryName%.%Platform%.appx
|
MakeAppx.exe pack /d "%ReleasePath%\AppX" /l /p ..\out\Release\%BinaryName%.%Platform%.appx
|
||||||
|
|
Loading…
Add table
Reference in a new issue