Improved command line autoconnect

Changed how the  command line autoconnect was handled to leverage the existing autoconnect code.
This commit is contained in:
Blake Curry 2018-05-08 13:42:55 -04:00
parent 6ad23a2f3d
commit 5e6474c06e

View file

@ -740,7 +740,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
public boolean autoConnect() {
boolean autoConnectParamValue = Boolean.parseBoolean(PREFS.get("autoConnect", "false"));
boolean autoConnectParamValue = startUser != null || Boolean.parseBoolean(PREFS.get("autoConnect", "false"));
boolean status = false;
if (autoConnectParamValue) {
status = performConnect(false);
@ -1238,26 +1238,20 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
}
instance = new MageFrame();
instance.setVisible(true);
if( startUser != null){
//instance.connectDialog.
Connection startConnection = new Connection();
startConnection.setUsername(startUser);
startConnection.setHost(startServer);
instance.currentConnection = new Connection();
instance.currentConnection.setUsername(startUser);
instance.currentConnection.setHost(startServer);
if (startPort > 0){
startConnection.setPort(startPort);
instance.currentConnection.setPort(startPort);
}else {
startConnection.setPort(MagePreferences.getServerPortWithDefault(Config.port));
}
PreferencesDialog.setProxyInformation(startConnection);
startConnection.setPassword(startPassword);
boolean connectSuccess = connect(startConnection);
if (connectSuccess){
instance.connectDialog.hideDialog();
} else {
instance.currentConnection.setPort(MagePreferences.getServerPortWithDefault(Config.port));
}
PreferencesDialog.setProxyInformation(instance.currentConnection);
instance.currentConnection.setPassword(startPassword);
}
instance.setVisible(true);
});
}