Skip to content

Commit

Permalink
Convert DisconnectAction to EnumParameter
Browse files Browse the repository at this point in the history
  • Loading branch information
CendioOssman committed Feb 12, 2025
1 parent 0d14e5b commit 5d2043c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
9 changes: 5 additions & 4 deletions win/rfb_win32/SDisplay.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ IntParameter rfb::win32::SDisplay::updateMethod("UpdateMethod",
0, 0, 2);
BoolParameter rfb::win32::SDisplay::disableLocalInputs("DisableLocalInputs",
"Disable local keyboard and pointer input while the server is in use", false);
StringParameter rfb::win32::SDisplay::disconnectAction("DisconnectAction",
"Action to perform when all clients have disconnected. (None, Lock, Logoff)", "None");
EnumParameter rfb::win32::SDisplay::disconnectAction("DisconnectAction",
"Action to perform when all clients have disconnected. (None, Lock, Logoff)",
{"None", "Lock", "Logoff"}, "None");
StringParameter displayDevice("DisplayDevice",
"Display device name of the monitor to be remoted, or empty to export the whole desktop.", "");
BoolParameter rfb::win32::SDisplay::removeWallpaper("RemoveWallpaper",
Expand Down Expand Up @@ -124,12 +125,12 @@ void SDisplay::stop()
// If we successfully start()ed then perform the DisconnectAction
if (core) {
CurrentUserToken cut;
if (stricmp(disconnectAction, "Logoff") == 0) {
if (disconnectAction == "Logoff") {
if (!cut.h)
vlog.info("Ignoring DisconnectAction=Logoff - no current user");
else
ExitWindowsEx(EWX_LOGOFF, 0);
} else if (stricmp(disconnectAction, "Lock") == 0) {
} else if (disconnectAction == "Lock") {
if (!cut.h) {
vlog.info("Ignoring DisconnectAction=Lock - no current user");
} else {
Expand Down
2 changes: 1 addition & 1 deletion win/rfb_win32/SDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace rfb {

static IntParameter updateMethod;
static BoolParameter disableLocalInputs;
static StringParameter disconnectAction;
static EnumParameter disconnectAction;
static BoolParameter removeWallpaper;
static BoolParameter disableEffects;

Expand Down
10 changes: 4 additions & 6 deletions win/vncconfig/Desktop.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ namespace rfb {
DesktopPage(const RegKey& rk)
: PropSheetPage(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_DESKTOP)), regKey(rk) {}
void initDialog() override {
const char *action(rfb::win32::SDisplay::disconnectAction);
bool disconnectLock = stricmp(action, "Lock") == 0;
bool disconnectLogoff = stricmp(action, "Logoff") == 0;
bool disconnectLock = rfb::win32::SDisplay::disconnectAction == "Lock";
bool disconnectLogoff = rfb::win32::SDisplay::disconnectAction == "Logoff";
setItemChecked(IDC_DISCONNECT_LOGOFF, disconnectLogoff);
setItemChecked(IDC_DISCONNECT_LOCK, disconnectLock);
setItemChecked(IDC_DISCONNECT_NONE, !disconnectLock && !disconnectLogoff);
Expand All @@ -47,9 +46,8 @@ namespace rfb {
case IDC_DISCONNECT_NONE:
case IDC_REMOVE_WALLPAPER:
case IDC_DISABLE_EFFECTS:
const char *action(rfb::win32::SDisplay::disconnectAction);
bool disconnectLock = stricmp(action, "Lock") == 0;
bool disconnectLogoff = stricmp(action, "Logoff") == 0;
bool disconnectLock = rfb::win32::SDisplay::disconnectAction == "Lock";
bool disconnectLogoff = rfb::win32::SDisplay::disconnectAction == "Logoff";
setChanged((disconnectLogoff != isItemChecked(IDC_DISCONNECT_LOGOFF)) ||
(disconnectLock != isItemChecked(IDC_DISCONNECT_LOCK)) ||
(isItemChecked(IDC_REMOVE_WALLPAPER) != rfb::win32::SDisplay::removeWallpaper) ||
Expand Down

0 comments on commit 5d2043c

Please sign in to comment.