Compare commits

..

No commits in common. "9412bb899d561829fd457987e2f13c3fae7d5a9d" and "a6097ca49a19f8c81e32fcb1cc94d3ba6209d631" have entirely different histories.

5 changed files with 23 additions and 91 deletions

View file

@ -13,7 +13,6 @@ import standard.VueStandard;
public class ControleurConnexion implements ActionListener{
//Controller state : either DEBUT at initialization or ID_OK if the user has signed in
private enum Etat {DEBUT, ID_OK};
private VueConnexion vue;
@ -24,14 +23,6 @@ public class ControleurConnexion implements ActionListener{
private SQLiteManager sqlManager;
private VueStandard vueStd;
/**
* Create and initialize the object in charge of monitoring all actions depending on what the user do.
*
* @param vue : associated instance of VueConnexion
* @param numtest : on local mode, allows you to choose which port to use. Integer between 0 and 3
*
*/
public ControleurConnexion(VueConnexion vue, int numtest) {
this.vue = vue;
this.etat = Etat.DEBUT;
@ -64,10 +55,10 @@ public class ControleurConnexion implements ActionListener{
}
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void actionPerformed(ActionEvent e) {
String pseudo;
@ -82,6 +73,7 @@ public class ControleurConnexion implements ActionListener{
inputOK = (res == 1);
} catch (SQLException e2) {
e2.printStackTrace();
}
@ -125,13 +117,17 @@ public class ControleurConnexion implements ActionListener{
try {
Utilisateur.setSelf(this.username, pseudo, "localhost", this.portTCP);
} catch (UnknownHostException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
//broadcast new pseudo
try {
this.comUDP.sendMessageInfoPseudo();
} catch (UnknownHostException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
try {
@ -139,6 +135,7 @@ public class ControleurConnexion implements ActionListener{
this.vue.setVisible(false);
this.setVueStandard();
} catch (IOException e1) {
e1.printStackTrace();
}
}
else this.vue.setConnexionInfo("Ce nom est déjà utilisé, veuillez en choisir un autre");
@ -146,12 +143,6 @@ public class ControleurConnexion implements ActionListener{
}
// ----- SETTING & RESETTING VIEW ----- //
/**
* Create a new VueStandard instance and give it the hand.
*
*/
private void setVueStandard() throws IOException {
if(this.vueStd == null) {
this.vueStd = new VueStandard("Standard", this.comUDP, this.portTCP, this.sqlManager, this.vue);
@ -163,10 +154,6 @@ public class ControleurConnexion implements ActionListener{
}
}
/**
* Restore the associated instance of VueConnexion to its initial state
*
*/
private void resetView() {
this.etat = Etat.DEBUT;
this.vue.addPasswordPanel();

View file

@ -1,11 +1,12 @@
package connexion;
//Import librairies
//Importe les librairies
import java.awt.*;
import javax.swing.*;
import database.SQLiteManager;
import main.Vue;
import messages.MauvaisTypeMessageException;
public class VueConnexion extends Vue {

View file

@ -4,7 +4,9 @@ import java.net.*;
public class Utilisateur implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String id;
@ -12,103 +14,48 @@ public class Utilisateur implements Serializable{
private InetAddress ip;
private int port;
//Represents the user that is currently using the application
private static Utilisateur self;
/**
* Create and initialize an object representing an user
*
* @param id : user id as String
* @param pseudo : name under which other users can see this user as String
* @param ip : ip of the device this user is currently using as InetAddress
* @param port : on local mode, port used for the TCP listen socket as int
*
*/
public Utilisateur(String id, String pseudo, InetAddress ip, int port) throws UnknownHostException {
this.id = id;
this.pseudo = pseudo;
this.ip = ip;
this.port = port;
}
// ----- GETTERS ----- //
/**
* Returns user id as String
*
* @return user id as String
*/
public String getId() {
return id;
}
/**
* Returns user pseudo as String
*
* @return user pseudo as String
*/
public String getPseudo() {
return pseudo;
}
/**
* Returns user device's ip as String
*
* @return user device's ip as String
*/
public InetAddress getIp() {
return ip;
}
/**
* Returns the port the user uses for their TCP listen socket as int
*
* @return TCP listen socket port as int
*/
public int getPort() {
return port;
}
/**
* Returns the user currently using this instance of the application as Utilisateur
*
* @return current user as Utilisateur
*/
public static Utilisateur getSelf() {
return Utilisateur.self;
}
// ----- SETTERS ----- //
/**
* Change the pseudo used by an user
*
* @param pseudo : new pseudo as String
*/
public void setPseudo(String pseudo) {
this.pseudo = pseudo;
}
/**
* Sets the self static attribute with a new Utilisateur
*
* @param id : user id as String
* @param pseudo : name under which other users can see this user as String
* @param ip : ip of the device this user is currently using as InetAddress
* @param port : on local mode, port used for the TCP listen socket as int
*/
public InetAddress getIp() {
return ip;
}
public int getPort() {
return port;
}
public static void setSelf(String id, String pseudo, String host, int port) throws UnknownHostException {
if(Utilisateur.self == null) {
Utilisateur.self = new Utilisateur(id, pseudo, InetAddress.getByName(host), port);
}
}
/**
* Sets the self static attribute with null
*/
public static Utilisateur getSelf() {
return Utilisateur.self;
}
public static void resetSelf() {
Utilisateur.self = null;
}

View file

@ -2,9 +2,6 @@ package main;
import javax.swing.JFrame;
// General class from which all VueX class derivate
public class Vue extends JFrame{
private static final long serialVersionUID = 1L;

0
modelisation/dossmod.txt Normal file
View file