diff --git a/src/ibcalpha/ibc/IbcTws.java b/src/ibcalpha/ibc/IbcTws.java index 6f46bf2..6c56337 100644 --- a/src/ibcalpha/ibc/IbcTws.java +++ b/src/ibcalpha/ibc/IbcTws.java @@ -332,6 +332,7 @@ private static List createWindowHandlers() { windowHandlers.add(new ExitConfirmationDialogHandler()); windowHandlers.add(new TradingLoginHandoffDialogHandler()); windowHandlers.add(new LoginFailedDialogHandler()); + windowHandlers.add(new UnrecognizedUsernameOrPasswordDialogHandler()); windowHandlers.add(new TooManyFailedLoginAttemptsDialogHandler()); windowHandlers.add(new ShutdownProgressDialogHandler()); windowHandlers.add(new BidAskLastSizeDisplayUpdateDialogHandler()); diff --git a/src/ibcalpha/ibc/UnrecognizedUsernameOrPasswordDialogHandler.java b/src/ibcalpha/ibc/UnrecognizedUsernameOrPasswordDialogHandler.java new file mode 100644 index 0000000..5d941d3 --- /dev/null +++ b/src/ibcalpha/ibc/UnrecognizedUsernameOrPasswordDialogHandler.java @@ -0,0 +1,55 @@ +// This file is part of IBC. +// Copyright (C) 2004 Steven M. Kearns (skearns23@yahoo.com ) +// Copyright (C) 2004 - 2020 Richard L King (rlking@aultan.com) +// For conditions of distribution and use, see copyright notice in COPYING.txt + +// IBC is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// IBC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with IBC. If not, see . + +package ibcalpha.ibc; + +import java.awt.Window; +import java.awt.event.WindowEvent; +import javax.swing.JDialog; + +public class UnrecognizedUsernameOrPasswordDialogHandler implements WindowHandler { + final String DIALOG_TITLE = "Unrecognized Username or Password"; + + @Override + public boolean filterEvent(Window window, int eventId) { + switch (eventId) { + case WindowEvent.WINDOW_OPENED: + return true; + default: + return false; + } + } + + @Override + public void handleWindow(Window window, int eventID) { + Utils.logToConsole("Unrecognized Username or Password"); + Utils.logToConsole("Cold restart in progress"); + MyCachedThreadPool.getInstance().execute(new StopTask(null, true, "Cold restart after Unrecognized Username or Password dialog encountered")); + + if (! SwingUtils.clickButton(window, "OK")) { + Utils.logError("could not dismiss Unrecognized Username or Password dialog because we could not find the OK button"); + } + } + + @Override + public boolean recogniseWindow(Window window) { + if (! (window instanceof JDialog)) return false; + + return (SwingUtils.titleContains(window, DIALOG_TITLE)); + } +}