diff --git a/cmd/launcher/launcher.cpp b/cmd/launcher/launcher.cpp index 7a4f4894..4b28794a 100644 --- a/cmd/launcher/launcher.cpp +++ b/cmd/launcher/launcher.cpp @@ -33,8 +33,9 @@ typedef std::vector CStringList; class CScreenInfo { public: - CString m_screen; - CStringList m_aliases; + CString m_screen; + CStringList m_aliases; + CConfig::CScreenOptions m_options; }; class CChildWaitInfo { @@ -266,6 +267,14 @@ addScreen(HWND hwnd) ARG->m_config.addAlias(info.m_screen, *index); } + // set options + ARG->m_config.removeOptions(info.m_screen); + for (CConfig::CScreenOptions::const_iterator + index = info.m_options.begin(); + index != info.m_options.end(); ++index) { + ARG->m_config.addOption(info.m_screen, index->first, index->second); + } + // update neighbors updateNeighbors(hwnd); enableScreensControls(hwnd); @@ -295,6 +304,11 @@ editScreen(HWND hwnd) info.m_aliases.push_back(index->first); } } + const CConfig::CScreenOptions* options = + ARG->m_config.getOptions(info.m_screen); + if (options != NULL) { + info.m_options = *options; + } // save current info CScreenInfo oldInfo = info; @@ -320,6 +334,14 @@ editScreen(HWND hwnd) ARG->m_config.addAlias(info.m_screen, *index); } + // set options + ARG->m_config.removeOptions(info.m_screen); + for (CConfig::CScreenOptions::const_iterator + index = info.m_options.begin(); + index != info.m_options.end(); ++index) { + ARG->m_config.addOption(info.m_screen, index->first, index->second); + } + // update list CString item = CStringUtil::print("%d. %s", index + 1, info.m_screen.c_str()); @@ -740,6 +762,18 @@ addDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_INITDIALOG: { info = (CScreenInfo*)lParam; + // set title + CString title; + if (info->m_screen.empty()) { + title = getString(IDS_ADD_SCREEN); + } + else { + title = CStringUtil::format( + getString(IDS_EDIT_SCREEN).c_str(), + info->m_screen.c_str()); + } + SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)title.c_str()); + // fill in screen name HWND child = getItem(hwnd, IDC_ADD_SCREEN_NAME_EDIT); SendMessage(child, WM_SETTEXT, 0, (LPARAM)info->m_screen.c_str()); @@ -756,6 +790,25 @@ addDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) child = getItem(hwnd, IDC_ADD_ALIASES_EDIT); SendMessage(child, WM_SETTEXT, 0, (LPARAM)aliases.c_str()); + // set options + CConfig::CScreenOptions::const_iterator index; + child = getItem(hwnd, IDC_ADD_HD_CAPS_CHECK); + index = info->m_options.find(kOptionHalfDuplexCapsLock); + if (index != info->m_options.end() && index->second != 0) { + SendMessage(child, BM_SETCHECK, BST_CHECKED, 0); + } + else { + SendMessage(child, BM_SETCHECK, BST_UNCHECKED, 0); + } + child = getItem(hwnd, IDC_ADD_HD_NUM_CHECK); + index = info->m_options.find(kOptionHalfDuplexNumLock); + if (index != info->m_options.end() && index->second != 0) { + SendMessage(child, BM_SETCHECK, BST_CHECKED, 0); + } + else { + SendMessage(child, BM_SETCHECK, BST_UNCHECKED, 0); + } + return TRUE; } @@ -824,10 +877,26 @@ addDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } } - // save data + // save name data info->m_screen = newName; info->m_aliases = newAliases; + // save options + child = getItem(hwnd, IDC_ADD_HD_CAPS_CHECK); + if (SendMessage(child, BM_GETCHECK, 0, 0) == BST_CHECKED) { + info->m_options[kOptionHalfDuplexCapsLock] = 1; + } + else { + info->m_options.erase(kOptionHalfDuplexCapsLock); + } + child = getItem(hwnd, IDC_ADD_HD_NUM_CHECK); + if (SendMessage(child, BM_GETCHECK, 0, 0) == BST_CHECKED) { + info->m_options[kOptionHalfDuplexNumLock] = 1; + } + else { + info->m_options.erase(kOptionHalfDuplexNumLock); + } + // success EndDialog(hwnd, 1); info = NULL; diff --git a/cmd/launcher/launcher.rc b/cmd/launcher/launcher.rc index 35974cc1..b9840a49 100644 --- a/cmd/launcher/launcher.rc +++ b/cmd/launcher/launcher.rc @@ -106,18 +106,25 @@ BEGIN PUSHBUTTON "Quit",IDCANCEL,243,241,50,14 END -IDD_ADD DIALOG DISCARDABLE 0, 0, 172, 95 +IDD_ADD DIALOG DISCARDABLE 0, 0, 192, 170 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION CAPTION "Add Screen" FONT 8, "MS Sans Serif" BEGIN - LTEXT "Screen Name:",IDC_STATIC,7,9,46,8 - EDITTEXT IDC_ADD_SCREEN_NAME_EDIT,59,7,106,12,ES_AUTOHSCROLL - LTEXT "Aliases:",IDC_STATIC,7,25,25,8 - EDITTEXT IDC_ADD_ALIASES_EDIT,59,26,106,40,ES_MULTILINE | + LTEXT "&Screen Name:",IDC_STATIC,7,9,46,8 + EDITTEXT IDC_ADD_SCREEN_NAME_EDIT,79,7,106,12,ES_AUTOHSCROLL + LTEXT "&Aliases:",IDC_STATIC,7,25,25,8 + EDITTEXT IDC_ADD_ALIASES_EDIT,79,26,106,40,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN - DEFPUSHBUTTON "OK",IDOK,59,74,50,14 - PUSHBUTTON "Cancel",IDCANCEL,115,74,50,14 + LTEXT "If your Caps Lock or Num Lock keys behave strangely on this client screen then try turning the half-duplex options on and reconnect the client.", + IDC_STATIC,13,82,165,25 + CONTROL "Half-duplex &Caps Lock",IDC_ADD_HD_CAPS_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,13,110,165,10 + CONTROL "Half-duplex &Num Lock",IDC_ADD_HD_NUM_CHECK,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,13,122,165,10 + DEFPUSHBUTTON "OK",IDOK,79,149,50,14 + PUSHBUTTON "Cancel",IDCANCEL,135,149,50,14 + GROUPBOX "Options",IDC_STATIC,7,72,178,64 END IDD_WAIT DIALOG DISCARDABLE 0, 0, 186, 54 @@ -170,9 +177,9 @@ BEGIN IDD_ADD, DIALOG BEGIN LEFTMARGIN, 7 - RIGHTMARGIN, 165 + RIGHTMARGIN, 185 TOPMARGIN, 7 - BOTTOMMARGIN, 88 + BOTTOMMARGIN, 163 END IDD_WAIT, DIALOG @@ -255,6 +262,8 @@ BEGIN IDS_INVALID_SERVER_NAME "Server name `%{1}' is invalid." IDS_TITLE "Synergy - Version %{1}" IDS_SERVER_IS_CLIENT "Please enter the computer name of the synergy server, not\nthe name of this computer, in the Server Host Name field." + IDS_ADD_SCREEN "Add Screen" + IDS_EDIT_SCREEN "Edit Screen %{1}" END #endif // English (U.S.) resources diff --git a/cmd/launcher/resource.h b/cmd/launcher/resource.h index b5c78218..9b7acf49 100644 --- a/cmd/launcher/resource.h +++ b/cmd/launcher/resource.h @@ -38,6 +38,8 @@ #define IDS_INVALID_SERVER_NAME 34 #define IDS_TITLE 35 #define IDS_SERVER_IS_CLIENT 36 +#define IDS_ADD_SCREEN 37 +#define IDS_EDIT_SCREEN 38 #define IDD_MAIN 101 #define IDD_ADD 102 #define IDD_WAIT 103 @@ -59,6 +61,7 @@ #define IDC_ADD_SCREEN_NAME_EDIT 1020 #define IDC_MAIN_SERVER_REMOVE_BUTTON 1020 #define IDC_ADD_ALIASES_EDIT 1021 +#define IDC_MAIN_SERVER_OPTIONS_BUTTON 1021 #define IDC_MAIN_SERVER_LEFT_COMBO 1022 #define IDC_MAIN_SERVER_RIGHT_COMBO 1023 #define IDC_MAIN_SERVER_TOP_COMBO 1024 @@ -74,6 +77,8 @@ #define IDC_AUTOSTART_INSTALL_SYSTEM 1034 #define IDC_MAIN_AUTOSTART 1035 #define IDC_MAIN_DEBUG 1036 +#define IDC_ADD_HD_CAPS_CHECK 1037 +#define IDC_ADD_HD_NUM_CHECK 1038 // Next default values for new objects // @@ -82,7 +87,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 106 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1037 +#define _APS_NEXT_CONTROL_VALUE 1038 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/lib/server/CConfig.cpp b/lib/server/CConfig.cpp index 66a5e94a..9ed619db 100644 --- a/lib/server/CConfig.cpp +++ b/lib/server/CConfig.cpp @@ -241,7 +241,7 @@ CConfig::setHTTPAddress(const CNetworkAddress& addr) } bool -CConfig::addOption(const CString& name, UInt32 option, SInt32 value) +CConfig::addOption(const CString& name, OptionID option, OptionValue value) { // find cell CCellMap::iterator index = m_map.find(name); @@ -255,7 +255,7 @@ CConfig::addOption(const CString& name, UInt32 option, SInt32 value) } bool -CConfig::removeOption(const CString& name, UInt32 option) +CConfig::removeOption(const CString& name, OptionID option) { // find cell CCellMap::iterator index = m_map.find(name); @@ -268,6 +268,20 @@ CConfig::removeOption(const CString& name, UInt32 option) return true; } +bool +CConfig::removeOptions(const CString& name) +{ + // find cell + CCellMap::iterator index = m_map.find(name); + if (index == m_map.end()) { + return false; + } + + // remove option + index->second.m_options.clear(); + return true; +} + bool CConfig::isValidScreenName(const CString& name) const { @@ -421,6 +435,17 @@ CConfig::operator==(const CConfig& x) const for (CCellMap::const_iterator index1 = m_map.begin(), index2 = x.m_map.begin(); index1 != m_map.end(); ++index1, ++index2) { + // compare names + if (!CStringUtil::CaselessCmp::equal(index1->first, index2->first)) { + return false; + } + + // compare options + if (index1->second.m_options != index2->second.m_options) { + return false; + } + + // compare neighbors for (UInt32 i = 0; i <= kLastDirection - kFirstDirection; ++i) { if (!CStringUtil::CaselessCmp::equal(index1->second.m_neighbor[i], index2->second.m_neighbor[i])) { diff --git a/lib/server/CConfig.h b/lib/server/CConfig.h index 1e29b8a7..a60b3abc 100644 --- a/lib/server/CConfig.h +++ b/lib/server/CConfig.h @@ -188,7 +188,7 @@ public: is a known screen. */ bool addOption(const CString& name, - UInt32 option, SInt32 value); + OptionID option, OptionValue value); //! Remove a screen option /*! @@ -196,7 +196,14 @@ public: nothing if the option doesn't exist on the screen. Returns true iff \c name is a known screen. */ - bool removeOption(const CString& name, UInt32 option); + bool removeOption(const CString& name, OptionID option); + + //! Remove a screen options + /*! + Removes all options and values from the named screen. Returns true + iff \c name is a known screen. + */ + bool removeOptions(const CString& name); //@} //! @name accessors