diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java index 9039216c..3e64123a 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupFrameModel.java @@ -52,13 +52,20 @@ public class StartupFrameModel { @Override public void onUserAccountConnectedEvent(String username) { - firerer.fireStartupValidated(); } @Override public void onUserAccountDisconnectedEvent(String username) { } + + @Override + public void onStartupProcedureFinishedEvent(boolean success) { + if(success) + firerer.fireStartupValidated(); + + startupProcessBegan = false; + } }) .handle(); } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupProcedureHandler.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupProcedureHandler.java index 453481bb..120e1030 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupProcedureHandler.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/StartupProcedureHandler.java @@ -79,6 +79,7 @@ class StartupProcedureHandler { System.out.println(" --> Compte inconnu"); //Compte spécifié inconnu firerer.fireUserAccountUnknownEvent(username); + firerer.fireStartupProcedureFinishedEvent(false); }else{ //TODO remove sysout System.out.println(" --> Compte connu"); @@ -88,6 +89,7 @@ class StartupProcedureHandler { } }catch(Throwable e){ e.printStackTrace(); + firerer.fireStartupProcedureFinishedEvent(false); } } @@ -106,6 +108,7 @@ class StartupProcedureHandler { @Override public void onPQTPingFailureEvent(String host, Integer port, Throwable cause) { StartupProcedureHandler.this.removePingListener(); + firerer.fireStartupProcedureFinishedEvent(false); } @Override @@ -153,16 +156,25 @@ class StartupProcedureHandler { //Compte connecté //TODO remove sysout System.out.println("Connecté en tant que '"+username+"'"); + StartupProcedureHandler.this.removeConnectAccountListener(); firerer.fireUserAccountConnectedEvent(username); + firerer.fireStartupProcedureFinishedEvent(true); }else{ //Compte non-connecté //TODO remove sysout System.out.println("Non-connecté en tant que '"+username+"'"); - StartupProcedureHandler.this.removeConnectAccountListener(); + firerer.fireUserAccountDisconnectedEvent(username); + firerer.fireStartupProcedureFinishedEvent(false); } } + + @Override + public void onAccountStatusNotChangedEvent(Throwable cause) { + StartupProcedureHandler.this.removeConnectAccountListener(); + firerer.fireStartupProcedureFinishedEvent(false); + } }; } return connectAccountListener; diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureEventFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureEventFirerer.java index 93c9b061..9fa2ba3c 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureEventFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureEventFirerer.java @@ -6,6 +6,7 @@ public interface IStartupProcedureEventFirerer { void fireUserAccountUnknownEvent(String username); void fireUserAccountConnectedEvent(String username); void fireUserAccountDisconnectedEvent(String username); + void fireStartupProcedureFinishedEvent(boolean success); void addListener(IStartupProcedureListener l ); void removeListener(IStartupProcedureListener l ); diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureListener.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureListener.java index 6f0968e4..17d95820 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureListener.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/IStartupProcedureListener.java @@ -8,4 +8,5 @@ public interface IStartupProcedureListener extends EventListener{ void onUserAccountUnknownEvent(String username); void onUserAccountConnectedEvent(String username); void onUserAccountDisconnectedEvent(String username); + void onStartupProcedureFinishedEvent(boolean success); } diff --git a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/SimpleStartupProcedureEventFirerer.java b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/SimpleStartupProcedureEventFirerer.java index 97a0693e..aa2f6fa2 100644 --- a/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/SimpleStartupProcedureEventFirerer.java +++ b/Workspace/client/src/main/java/com/pqt/client/gui/frames/startup_frame/listeners/procedure/SimpleStartupProcedureEventFirerer.java @@ -35,6 +35,12 @@ public class SimpleStartupProcedureEventFirerer implements IStartupProcedureEven .forEach(l->l.onUserAccountDisconnectedEvent(username)); } + @Override + public void fireStartupProcedureFinishedEvent(boolean success) { + Arrays.stream(listenerList.getListeners(IStartupProcedureListener.class)) + .forEach(l->l.onStartupProcedureFinishedEvent(success)); + } + @Override public void addListener(IStartupProcedureListener l) { listenerList.add(IStartupProcedureListener.class, l);