Add option to quit Apollo from webpage w/ hide tray menu controls
This commit is contained in:
@@ -439,6 +439,7 @@ namespace config {
|
||||
};
|
||||
|
||||
sunshine_t sunshine {
|
||||
false, // hide_tray_controls
|
||||
"en", // locale
|
||||
2, // min_log_level
|
||||
0, // flags
|
||||
@@ -1102,6 +1103,7 @@ namespace config {
|
||||
bool_f(vars, "high_resolution_scrolling", input.high_resolution_scrolling);
|
||||
bool_f(vars, "native_pen_touch", input.native_pen_touch);
|
||||
|
||||
bool_f(vars, "hide_tray_controls", sunshine.hide_tray_controls);
|
||||
bool_f(vars, "notify_pre_releases", sunshine.notify_pre_releases);
|
||||
|
||||
int port = sunshine.port;
|
||||
|
||||
@@ -163,6 +163,7 @@ namespace config {
|
||||
bool elevated;
|
||||
};
|
||||
struct sunshine_t {
|
||||
bool hide_tray_controls;
|
||||
std::string locale;
|
||||
int min_log_level;
|
||||
std::bitset<flag::FLAG_SIZE> flags;
|
||||
|
||||
@@ -621,6 +621,32 @@ namespace confighttp {
|
||||
platf::restart();
|
||||
}
|
||||
|
||||
void
|
||||
quit(resp_https_t response, req_https_t request) {
|
||||
if (!authenticate(response, request)) return;
|
||||
|
||||
print_req(request);
|
||||
|
||||
// We do want to return here
|
||||
std::thread quit_thread([]{
|
||||
sleep(1000);
|
||||
#ifdef _WIN32
|
||||
// If we're running in a service, return a special status to
|
||||
// tell it to terminate too, otherwise it will just respawn us.
|
||||
if (GetConsoleWindow() == NULL) {
|
||||
lifetime::exit_sunshine(ERROR_SHUTDOWN_IN_PROGRESS, true);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
lifetime::exit_sunshine(0, true);
|
||||
});
|
||||
|
||||
quit_thread.detach();
|
||||
|
||||
response->write();
|
||||
}
|
||||
|
||||
void
|
||||
savePassword(resp_https_t response, req_https_t request) {
|
||||
if (!config::sunshine.username.empty() && !authenticate(response, request)) return;
|
||||
@@ -825,6 +851,7 @@ namespace confighttp {
|
||||
server.resource["^/api/config$"]["POST"] = saveConfig;
|
||||
server.resource["^/api/configLocale$"]["GET"] = getLocale;
|
||||
server.resource["^/api/restart$"]["POST"] = restart;
|
||||
server.resource["^/api/quit$"]["POST"] = quit;
|
||||
server.resource["^/api/password$"]["POST"] = savePassword;
|
||||
server.resource["^/api/apps/([0-9]+)$"]["DELETE"] = deleteApp;
|
||||
server.resource["^/api/clients/unpair-all$"]["POST"] = unpairAll;
|
||||
|
||||
@@ -289,7 +289,7 @@ main(int argc, char *argv[]) {
|
||||
BOOST_LOG(fatal) << "HTTP interface failed to initialize"sv;
|
||||
|
||||
#ifdef _WIN32
|
||||
BOOST_LOG(fatal) << "To relaunch Sunshine successfully, use the shortcut in the Start Menu. Do not run Sunshine.exe manually."sv;
|
||||
BOOST_LOG(fatal) << "To relaunch Apollo successfully, use the shortcut in the Start Menu. Do not run Sunshine.exe manually."sv;
|
||||
std::this_thread::sleep_for(10s);
|
||||
#endif
|
||||
|
||||
@@ -317,8 +317,8 @@ main(int argc, char *argv[]) {
|
||||
#ifdef _WIN32
|
||||
// If we're using the default port and GameStream is enabled, warn the user
|
||||
if (config::sunshine.port == 47989 && is_gamestream_enabled()) {
|
||||
BOOST_LOG(fatal) << "GameStream is still enabled in GeForce Experience! This *will* cause streaming problems with Sunshine!"sv;
|
||||
BOOST_LOG(fatal) << "Disable GameStream on the SHIELD tab in GeForce Experience or change the Port setting on the Advanced tab in the Sunshine Web UI."sv;
|
||||
BOOST_LOG(fatal) << "GameStream is still enabled in GeForce Experience! This *will* cause streaming problems with Apollo!"sv;
|
||||
BOOST_LOG(fatal) << "Disable GameStream on the SHIELD tab in GeForce Experience or change the Port setting on the Advanced tab in the Apollo Web UI."sv;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -97,6 +97,7 @@ namespace system_tray {
|
||||
(struct tray_menu[]) {
|
||||
// todo - use boost/locale to translate menu strings
|
||||
{ .text = "Open Apollo", .cb = tray_open_ui_cb },
|
||||
{ .text = "-" },
|
||||
// { .text = "-" },
|
||||
// { .text = "Donate",
|
||||
// .submenu =
|
||||
@@ -231,6 +232,10 @@ namespace system_tray {
|
||||
#endif
|
||||
tray.menu[0].text = title_str.c_str();
|
||||
|
||||
if (config::sunshine.hide_tray_controls) {
|
||||
tray.menu[1].text = nullptr;
|
||||
}
|
||||
|
||||
std::thread tray_thread(system_tray);
|
||||
tray_thread.detach();
|
||||
#endif
|
||||
@@ -269,7 +274,7 @@ namespace system_tray {
|
||||
tray.notification_text = msg;
|
||||
tray.tooltip = msg;
|
||||
tray.notification_icon = TRAY_ICON_PLAYING;
|
||||
tray.menu[1].text = force_close_msg;
|
||||
tray.menu[2].text = force_close_msg;
|
||||
tray_update(&tray);
|
||||
}
|
||||
|
||||
@@ -320,7 +325,7 @@ namespace system_tray {
|
||||
tray.notification_title = "Application Stopped";
|
||||
tray.notification_text = msg;
|
||||
tray.tooltip = PROJECT_NAME;
|
||||
tray.menu[1].text = TRAY_MSG_NO_APP_RUNNING;
|
||||
tray.menu[2].text = TRAY_MSG_NO_APP_RUNNING;
|
||||
tray_update(&tray);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user