Changeset - r23642:df495c081e7f
[Not reviewed]
master
0 8 0
Niels Martin Hansen - 6 years ago 2019-01-12 21:27:19
nielsm@indvikleren.dk
Add: Warn players that company passwords are not truly secure
8 files changed with 48 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -262,12 +262,13 @@ STR_SHOW_HIDDEN_ENGINES_VEHICLE_SHIP_TOO
 
STR_SHOW_HIDDEN_ENGINES_VEHICLE_AIRCRAFT_TOOLTIP                :{BLACK}By enabling this button, the hidden aircraft are also displayed
 

	
 
# Query window
 
STR_BUTTON_DEFAULT                                              :{BLACK}Default
 
STR_BUTTON_CANCEL                                               :{BLACK}Cancel
 
STR_BUTTON_OK                                                   :{BLACK}OK
 
STR_WARNING_PASSWORD_SECURITY                                   :{YELLOW}Warning: Server administrators may be{}able to read any text entered here.
 

	
 
# On screen keyboard window
 
STR_OSK_KEYBOARD_LAYOUT                                         :`1234567890-=\qwertyuiop[]asdfghjkl;'  zxcvbnm,./ .
 
STR_OSK_KEYBOARD_LAYOUT_CAPS                                    :~!@#$%^&*()_+|QWERTYUIOP{{}}ASDFGHJKL:"  ZXCVBNM<>? .
 

	
 
# Measurement tooltip
src/misc_gui.cpp
Show inline comments
 
@@ -978,12 +978,29 @@ struct QueryStringWindow : public Window
 
		if (widget == WID_QS_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) {
 
			/* We don't want this widget to show! */
 
			fill->width = 0;
 
			resize->width = 0;
 
			size->width = 0;
 
		}
 

	
 
		if (widget == WID_QS_WARNINGBOX && (this->flags & QSF_PASSWORD) == 0) {
 
			/* We don't want this widget to show! */
 
			fill->width = 0;
 
			resize->width = 0;
 
			size->width = 0;
 
		}
 
		if (widget == WID_QS_WARNING) {
 
			*size = GetStringBoundingBox(STR_WARNING_PASSWORD_SECURITY);
 
		}
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != WID_QS_WARNING) return;
 

	
 
		DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
 
	void SetStringParameters(int widget) const override
 
	{
 
		if (widget == WID_QS_CAPTION) SetDParam(0, this->editbox.caption);
 
	}
 
@@ -1034,12 +1051,15 @@ static const NWidgetPart _nested_query_s
 
		NWidget(WWT_CLOSEBOX, COLOUR_GREY),
 
		NWidget(WWT_CAPTION, COLOUR_GREY, WID_QS_CAPTION), SetDataTip(STR_WHITE_STRING, STR_NULL),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY),
 
		NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QS_TEXT), SetMinimalSize(256, 12), SetFill(1, 1), SetPadding(2, 2, 2, 2),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_QS_WARNINGBOX),
 
		NWidget(WWT_LABEL, COLOUR_GREY, WID_QS_WARNING), SetPadding(WD_FRAMETEXT_TOP, WD_FRAMETEXT_RIGHT, WD_FRAMETEXT_BOTTOM, WD_FRAMETEXT_LEFT), SetFill(0, 1),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_DEFAULT), SetMinimalSize(87, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_DEFAULT, STR_NULL),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_CANCEL), SetMinimalSize(86, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_QS_OK), SetMinimalSize(87, 12), SetFill(1, 1), SetDataTip(STR_BUTTON_OK, STR_NULL),
 
	EndContainer(),
 
};
src/network/network_gui.cpp
Show inline comments
 
@@ -2154,13 +2154,13 @@ void ShowNetworkNeedPassword(NetworkPass
 
	StringID caption;
 
	switch (npt) {
 
		default: NOT_REACHED();
 
		case NETWORK_GAME_PASSWORD:    caption = STR_NETWORK_NEED_GAME_PASSWORD_CAPTION; break;
 
		case NETWORK_COMPANY_PASSWORD: caption = STR_NETWORK_NEED_COMPANY_PASSWORD_CAPTION; break;
 
	}
 
	ShowQueryString(STR_EMPTY, caption, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_NONE);
 
	ShowQueryString(STR_EMPTY, caption, NETWORK_PASSWORD_LENGTH, w, CS_ALPHANUMERAL, QSF_PASSWORD);
 
}
 

	
 
struct NetworkCompanyPasswordWindow : public Window {
 
	QueryString password_editbox; ///< Password editbox.
 

	
 
	NetworkCompanyPasswordWindow(WindowDesc *desc, Window *parent) : Window(desc), password_editbox(lengthof(_settings_client.network.default_company_pass))
 
@@ -2171,12 +2171,20 @@ struct NetworkCompanyPasswordWindow : pu
 
		this->querystrings[WID_NCP_PASSWORD] = &this->password_editbox;
 
		this->password_editbox.cancel_button = WID_NCP_CANCEL;
 
		this->password_editbox.ok_button = WID_NCP_OK;
 
		this->SetFocusedWidget(WID_NCP_PASSWORD);
 
	}
 

	
 
	virtual void DrawWidget(const Rect &r, int widget) const
 
	{
 
		if (widget != WID_NCP_WARNING) return;
 

	
 
		DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, r.top + WD_FRAMERECT_TOP, r.bottom - WD_FRAMERECT_BOTTOM,
 
			STR_WARNING_PASSWORD_SECURITY, TC_FROMSTRING, SA_CENTER);
 
	}
 

	
 
	void OnOk()
 
	{
 
		if (this->IsWidgetLowered(WID_NCP_SAVE_AS_DEFAULT_PASSWORD)) {
 
			strecpy(_settings_client.network.default_company_pass, this->password_editbox.text.buf, lastof(_settings_client.network.default_company_pass));
 
		}
 

	
 
@@ -2217,12 +2225,15 @@ static const NWidgetPart _nested_network
 
				NWidget(NWID_SPACER), SetFill(1, 0),
 
				NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_NCP_SAVE_AS_DEFAULT_PASSWORD), SetMinimalSize(194, 12),
 
											SetDataTip(STR_COMPANY_PASSWORD_MAKE_DEFAULT, STR_COMPANY_PASSWORD_MAKE_DEFAULT_TOOLTIP),
 
			EndContainer(),
 
		EndContainer(),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_NCP_WARNING),
 
		NWidget(WWT_LABEL, COLOUR_GREY), SetFill(0, 1), SetPadding(2, 2, 2, 2), SetDataTip(STR_WARNING_PASSWORD_SECURITY, STR_NULL),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_CANCEL), SetFill(1, 0), SetDataTip(STR_BUTTON_CANCEL, STR_COMPANY_PASSWORD_CANCEL),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_NCP_OK), SetFill(1, 0), SetDataTip(STR_BUTTON_OK, STR_COMPANY_PASSWORD_OK),
 
	EndContainer(),
 
};
 

	
src/script/api/game/game_window.hpp.sq
Show inline comments
 
@@ -633,12 +633,14 @@ void SQGSWindow_Register(Squirrel *engin
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_LI_BACKGROUND,                         "WID_LI_BACKGROUND");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_TT_BACKGROUND,                         "WID_TT_BACKGROUND");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_A_SCROLLING_TEXT,                      "WID_A_SCROLLING_TEXT");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_A_WEBSITE,                             "WID_A_WEBSITE");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CAPTION,                            "WID_QS_CAPTION");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_TEXT,                               "WID_QS_TEXT");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_WARNING,                            "WID_QS_WARNING");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_WARNINGBOX,                         "WID_QS_WARNINGBOX");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_DEFAULT,                            "WID_QS_DEFAULT");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_CANCEL,                             "WID_QS_CANCEL");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_QS_OK,                                 "WID_QS_OK");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_Q_CAPTION,                             "WID_Q_CAPTION");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_Q_TEXT,                                "WID_Q_TEXT");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_Q_NO,                                  "WID_Q_NO");
 
@@ -777,12 +779,13 @@ void SQGSWindow_Register(Squirrel *engin
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NJS_BACKGROUND,                        "WID_NJS_BACKGROUND");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NJS_CANCELOK,                          "WID_NJS_CANCELOK");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_BACKGROUND,                        "WID_NCP_BACKGROUND");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_LABEL,                             "WID_NCP_LABEL");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_PASSWORD,                          "WID_NCP_PASSWORD");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_SAVE_AS_DEFAULT_PASSWORD,          "WID_NCP_SAVE_AS_DEFAULT_PASSWORD");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_WARNING,                           "WID_NCP_WARNING");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_CANCEL,                            "WID_NCP_CANCEL");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NCP_OK,                                "WID_NCP_OK");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NGRFI_CAPTION,                         "WID_NGRFI_CAPTION");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NGRFI_PARENT,                          "WID_NGRFI_PARENT");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NGRFI_VEH_PREV,                        "WID_NGRFI_VEH_PREV");
 
	SQGSWindow.DefSQConst(engine, ScriptWindow::WID_NGRFI_VEH_NEXT,                        "WID_NGRFI_VEH_NEXT");
src/script/api/script_window.hpp
Show inline comments
 
@@ -1595,12 +1595,14 @@ public:
 
	};
 

	
 
	/** Widgets of the #QueryStringWindow class. */
 
	enum QueryStringWidgets {
 
		WID_QS_CAPTION                               = ::WID_QS_CAPTION,                               ///< Caption of the window.
 
		WID_QS_TEXT                                  = ::WID_QS_TEXT,                                  ///< Text of the query.
 
		WID_QS_WARNING                               = ::WID_QS_WARNING,                               ///< Warning label about password security
 
		WID_QS_WARNINGBOX                            = ::WID_QS_WARNINGBOX,                            ///< Container for warning label
 
		WID_QS_DEFAULT                               = ::WID_QS_DEFAULT,                               ///< Default button.
 
		WID_QS_CANCEL                                = ::WID_QS_CANCEL,                                ///< Cancel button.
 
		WID_QS_OK                                    = ::WID_QS_OK,                                    ///< OK button.
 
	};
 

	
 
	/** Widgets of the #QueryWindow class. */
 
@@ -1814,12 +1816,13 @@ public:
 
	/** Widgets of the #NetworkCompanyPasswordWindow class. */
 
	enum NetworkCompanyPasswordWidgets {
 
		WID_NCP_BACKGROUND                           = ::WID_NCP_BACKGROUND,                           ///< Background of the window.
 
		WID_NCP_LABEL                                = ::WID_NCP_LABEL,                                ///< Label in front of the password field.
 
		WID_NCP_PASSWORD                             = ::WID_NCP_PASSWORD,                             ///< Input field for the password.
 
		WID_NCP_SAVE_AS_DEFAULT_PASSWORD             = ::WID_NCP_SAVE_AS_DEFAULT_PASSWORD,             ///< Toggle 'button' for saving the current password as default password.
 
		WID_NCP_WARNING                              = ::WID_NCP_WARNING,                              ///< Warning text about password security
 
		WID_NCP_CANCEL                               = ::WID_NCP_CANCEL,                               ///< Close the window without changing anything.
 
		WID_NCP_OK                                   = ::WID_NCP_OK,                                   ///< Safe the password etc.
 
	};
 

	
 
	/* automatically generated from ../../widgets/newgrf_debug_widget.h */
 
	/** Widgets of the #NewGRFInspectWindow class. */
src/textbuf_gui.h
Show inline comments
 
@@ -19,12 +19,13 @@
 
/** Flags used in ShowQueryString() call */
 
enum QueryStringFlags {
 
	QSF_NONE             =    0,
 
	QSF_ACCEPT_UNCHANGED = 0x01, ///< return success even when the text didn't change
 
	QSF_ENABLE_DEFAULT   = 0x02, ///< enable the 'Default' button ("\0" is returned)
 
	QSF_LEN_IN_CHARS     = 0x04, ///< the length of the string is counted in characters
 
	QSF_PASSWORD         = 0x08, ///< password entry box, show warning about password security
 
};
 

	
 
DECLARE_ENUM_AS_BIT_SET(QueryStringFlags)
 

	
 
/** Callback procedure for the ShowQuery method. */
 
typedef void QueryCallbackProc(Window*, bool);
src/widgets/misc_widget.h
Show inline comments
 
@@ -27,17 +27,19 @@ enum AboutWidgets {
 
	WID_A_SCROLLING_TEXT, ///< The actually scrolling text.
 
	WID_A_WEBSITE,        ///< URL of OpenTTD website.
 
};
 

	
 
/** Widgets of the #QueryStringWindow class. */
 
enum QueryStringWidgets {
 
	WID_QS_CAPTION, ///< Caption of the window.
 
	WID_QS_TEXT,    ///< Text of the query.
 
	WID_QS_DEFAULT, ///< Default button.
 
	WID_QS_CANCEL,  ///< Cancel button.
 
	WID_QS_OK,      ///< OK button.
 
	WID_QS_CAPTION,    ///< Caption of the window.
 
	WID_QS_TEXT,       ///< Text of the query.
 
	WID_QS_WARNING,    ///< Warning label about password security
 
	WID_QS_WARNINGBOX, ///< Container for warning label
 
	WID_QS_DEFAULT,    ///< Default button.
 
	WID_QS_CANCEL,     ///< Cancel button.
 
	WID_QS_OK,         ///< OK button.
 
};
 

	
 
/** Widgets of the #QueryWindow class. */
 
enum QueryWidgets {
 
	WID_Q_CAPTION, ///< Caption of the window.
 
	WID_Q_TEXT,    ///< Text of the query.
src/widgets/network_widget.h
Show inline comments
 
@@ -119,11 +119,12 @@ enum NetworkJoinStatusWidgets {
 
/** Widgets of the #NetworkCompanyPasswordWindow class. */
 
enum NetworkCompanyPasswordWidgets {
 
	WID_NCP_BACKGROUND,               ///< Background of the window.
 
	WID_NCP_LABEL,                    ///< Label in front of the password field.
 
	WID_NCP_PASSWORD,                 ///< Input field for the password.
 
	WID_NCP_SAVE_AS_DEFAULT_PASSWORD, ///< Toggle 'button' for saving the current password as default password.
 
	WID_NCP_WARNING,                  ///< Warning text about password security
 
	WID_NCP_CANCEL,                   ///< Close the window without changing anything.
 
	WID_NCP_OK,                       ///< Safe the password etc.
 
};
 

	
 
#endif /* WIDGETS_NETWORK_WIDGET_H */
0 comments (0 inline, 0 general)