Reformat whole project
This commit is contained in:
parent
547c94110e
commit
b281b4b530
37 changed files with 159 additions and 161 deletions
|
@ -7,10 +7,10 @@ import org.json.JSONObject;
|
|||
@SuppressWarnings("FieldCanBeLocal")
|
||||
public class Config {
|
||||
|
||||
private ServerConfig serverConfig;
|
||||
private LocalConfig localConfig;
|
||||
private final String SERVER_KEY = "serveur";
|
||||
private final String LOCAL_KEY = "local";
|
||||
private ServerConfig serverConfig;
|
||||
private LocalConfig localConfig;
|
||||
|
||||
public Config() {
|
||||
serverConfig = new ServerConfig();
|
||||
|
@ -30,6 +30,7 @@ public class Config {
|
|||
public ServerConfig getServerConfig() {
|
||||
return serverConfig;
|
||||
}
|
||||
|
||||
public LocalConfig getLocalConfig() {
|
||||
return localConfig;
|
||||
}
|
||||
|
@ -38,21 +39,18 @@ public class Config {
|
|||
public static class ServerConfig {
|
||||
public static final int DEFAULT_PRESENCE_PORT = 35650;
|
||||
public static final int DEFAULT_PROXY_PORT = 35750;
|
||||
|
||||
private JSONObject obj;
|
||||
|
||||
private boolean enabled;
|
||||
private String uri;
|
||||
private ServerType type;
|
||||
private int presencePort;
|
||||
private int proxyPort;
|
||||
|
||||
private final String ENABLED_KEY = "actif";
|
||||
private final String URI_KEY = "uri";
|
||||
private final String TYPE_KEY = "type";
|
||||
private final String PORTS_KEY = "ports";
|
||||
private final String PORT_PRESENCE_KEY = "presence";
|
||||
private final String PORT_PROXY_KEY = "proxy";
|
||||
private JSONObject obj;
|
||||
private boolean enabled;
|
||||
private String uri;
|
||||
private ServerType type;
|
||||
private int presencePort;
|
||||
private int proxyPort;
|
||||
|
||||
/**
|
||||
* Basic constructor setting the default server configuration
|
||||
|
@ -160,14 +158,11 @@ public class Config {
|
|||
@SuppressWarnings("FieldCanBeLocal")
|
||||
public static class LocalConfig {
|
||||
public static final int DEFAULT_TCP_PORT = 31598;
|
||||
|
||||
private JSONObject obj;
|
||||
|
||||
private boolean enabled;
|
||||
private int port;
|
||||
|
||||
private final String ENABLED_KEY = "actif";
|
||||
private final String PORT_KEY = "port";
|
||||
private JSONObject obj;
|
||||
private boolean enabled;
|
||||
private int port;
|
||||
|
||||
/**
|
||||
* Basic constructor setting the default local configuration
|
||||
|
|
|
@ -89,6 +89,14 @@ public class NetDiscoverer {
|
|||
}
|
||||
|
||||
|
||||
private interface BroadcastReceivedCallback {
|
||||
void onBroadcastReceived(InetAddress ipAddr, String data);
|
||||
}
|
||||
|
||||
public interface ResponseReceivedCallback {
|
||||
void onResponseReceived(InetAddress ipAddr, String data);
|
||||
}
|
||||
|
||||
private static class BroadcastSender extends Thread {
|
||||
private final String broadcastMessage;
|
||||
private final ErrorCallback errorCallback;
|
||||
|
@ -246,13 +254,4 @@ public class NetDiscoverer {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private interface BroadcastReceivedCallback {
|
||||
void onBroadcastReceived(InetAddress ipAddr, String data);
|
||||
}
|
||||
|
||||
public interface ResponseReceivedCallback {
|
||||
void onResponseReceived(InetAddress ipAddr, String data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ public class InsaPresence implements Presence {
|
|||
|
||||
private final String path;
|
||||
private final int presencePort;
|
||||
private TcpConnection presenceConnection;
|
||||
private final Proxy proxy;
|
||||
private TcpConnection presenceConnection;
|
||||
|
||||
public InsaPresence(String path, int presencePort, int proxyPort) {
|
||||
this.path = path;
|
||||
|
|
|
@ -39,7 +39,7 @@ public interface Presence {
|
|||
* Notifies the presence server of any changes to the current user
|
||||
*
|
||||
* @param newInformation The new information to send
|
||||
* @param callback Called when notify completes
|
||||
* @param callback Called when notify completes
|
||||
*/
|
||||
void notify(UserInformation newInformation, @Nullable SimpleCallback callback, @Nullable ErrorCallback errorCallback);
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ public class LoadingScreenController implements Initializable {
|
|||
|
||||
/**
|
||||
* Instantly shows the loading screen
|
||||
*
|
||||
* @param label The text to display bellow the loading indicator
|
||||
*/
|
||||
public void show(String label) {
|
||||
|
@ -51,6 +52,7 @@ public class LoadingScreenController implements Initializable {
|
|||
|
||||
/**
|
||||
* Sets the text to display bellow the loading indicator
|
||||
*
|
||||
* @param label The text to use
|
||||
*/
|
||||
public void setLabel(@Nullable String label) {
|
||||
|
@ -62,6 +64,7 @@ public class LoadingScreenController implements Initializable {
|
|||
|
||||
/**
|
||||
* Gets the main container styles to apply custom styling
|
||||
*
|
||||
* @return The style list
|
||||
*/
|
||||
public ObservableList<String> getRootStyle() {
|
||||
|
|
|
@ -4,9 +4,9 @@ import com.jfoenix.controls.JFXSnackbar;
|
|||
import fr.insa.clavardator.client.config.Config;
|
||||
import fr.insa.clavardator.client.config.ConfigLoader;
|
||||
import fr.insa.clavardator.client.db.DatabaseController;
|
||||
import fr.insa.clavardator.client.server.ServerType;
|
||||
import fr.insa.clavardator.client.server.presence.Presence;
|
||||
import fr.insa.clavardator.client.server.presence.PresenceFactory;
|
||||
import fr.insa.clavardator.client.server.ServerType;
|
||||
import fr.insa.clavardator.client.server.presence.UnknownPresenceException;
|
||||
import fr.insa.clavardator.client.ui.chat.ChatController;
|
||||
import fr.insa.clavardator.client.ui.dialogs.AboutDialogController;
|
||||
|
@ -32,6 +32,7 @@ import java.util.TimerTask;
|
|||
public class MainController implements Initializable {
|
||||
|
||||
private final CurrentUser currentUser;
|
||||
private final int DEFAULT_PORT = 31598;
|
||||
@FXML
|
||||
private StackPane root;
|
||||
@FXML
|
||||
|
@ -50,14 +51,10 @@ public class MainController implements Initializable {
|
|||
private LoadingScreenController loadingController;
|
||||
@FXML
|
||||
private ErrorScreenController errorController;
|
||||
|
||||
private JFXSnackbar snackbar;
|
||||
private UserList userList;
|
||||
private Presence presenceServer;
|
||||
private boolean online;
|
||||
|
||||
private final int DEFAULT_PORT = 31598;
|
||||
|
||||
private int port = DEFAULT_PORT;
|
||||
private boolean localEnabled = true;
|
||||
|
||||
|
@ -177,9 +174,9 @@ public class MainController implements Initializable {
|
|||
userList.discoverActiveUsers(
|
||||
port,
|
||||
(e) -> {
|
||||
Log.e(this.getClass().getSimpleName(), "Error discovering users", e);
|
||||
CurrentUser.getInstance().setState(CurrentUser.State.INVALID);
|
||||
});
|
||||
Log.e(this.getClass().getSimpleName(), "Error discovering users", e);
|
||||
CurrentUser.getInstance().setState(CurrentUser.State.INVALID);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,9 +190,9 @@ public class MainController implements Initializable {
|
|||
userList.startUserListening(
|
||||
port,
|
||||
(e) -> {
|
||||
Log.e(this.getClass().getSimpleName(), "Error listening to users", e);
|
||||
CurrentUser.getInstance().setState(CurrentUser.State.INVALID);
|
||||
});
|
||||
Log.e(this.getClass().getSimpleName(), "Error listening to users", e);
|
||||
CurrentUser.getInstance().setState(CurrentUser.State.INVALID);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ public class ToolbarController implements Initializable {
|
|||
public void setEditListener(ButtonPressEvent listener) {
|
||||
editListeners = listener;
|
||||
}
|
||||
|
||||
public void setAboutListener(ButtonPressEvent listener) {
|
||||
aboutListeners = listener;
|
||||
}
|
||||
|
@ -32,6 +33,7 @@ public class ToolbarController implements Initializable {
|
|||
editListeners.onPress();
|
||||
}
|
||||
}
|
||||
|
||||
public void onAboutPress() {
|
||||
if (aboutListeners != null) {
|
||||
aboutListeners.onPress();
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package fr.insa.clavardator.client.ui.chat;
|
||||
|
||||
import fr.insa.clavardator.client.chat.ChatHistory;
|
||||
import fr.insa.clavardator.lib.message.Message;
|
||||
import fr.insa.clavardator.client.ui.LoadingScreenController;
|
||||
import fr.insa.clavardator.client.ui.NoSelectionModel;
|
||||
import fr.insa.clavardator.client.users.PeerUser;
|
||||
import fr.insa.clavardator.lib.message.Message;
|
||||
import fr.insa.clavardator.lib.util.ErrorCallback;
|
||||
import fr.insa.clavardator.lib.util.Log;
|
||||
import javafx.application.Platform;
|
||||
|
@ -36,18 +36,19 @@ public class ChatController implements Initializable {
|
|||
private VBox emptyContainer;
|
||||
private PeerUser remoteUser;
|
||||
|
||||
// public void setAttachmentListener(ButtonPressEvent listener) {
|
||||
// public void setAttachmentListener(ButtonPressEvent listener) {
|
||||
// chatFooterController.setAttachmentListener(listener);
|
||||
// }
|
||||
public void setSendErrorListener(ErrorCallback listener) {
|
||||
chatFooterController.setSendErrorListener(listener);
|
||||
}
|
||||
public void setSendErrorListener(ErrorCallback listener) {
|
||||
chatFooterController.setSendErrorListener(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the user that finished loading is the right one then set the chat state to done
|
||||
*
|
||||
* @param user The user that finished loading
|
||||
*/
|
||||
private void onHistoryLoaded (PeerUser user) {
|
||||
private void onHistoryLoaded(PeerUser user) {
|
||||
if (user.equals(remoteUser)) {
|
||||
setState(State.DONE);
|
||||
scrollToEnd();
|
||||
|
|
|
@ -24,6 +24,8 @@ import java.util.ResourceBundle;
|
|||
* Controller for the chat input field and associated buttons
|
||||
*/
|
||||
public class ChatFooterController implements Initializable {
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
File attachedFile;
|
||||
@FXML
|
||||
private HBox container;
|
||||
@FXML
|
||||
|
@ -32,15 +34,10 @@ public class ChatFooterController implements Initializable {
|
|||
private JFXButton sendButton;
|
||||
@FXML
|
||||
private JFXButton attachButton;
|
||||
|
||||
private ErrorCallback sendErrorListeners;
|
||||
|
||||
private PeerUser remoteUser;
|
||||
private HashMap<PeerUser, String> savedText;
|
||||
|
||||
FileChooser fileChooser = new FileChooser();
|
||||
File attachedFile;
|
||||
|
||||
public void setSendErrorListener(ErrorCallback listener) {
|
||||
sendErrorListeners = listener;
|
||||
}
|
||||
|
|
|
@ -52,5 +52,6 @@ public class ChatHeaderController implements Initializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {}
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package fr.insa.clavardator.client.ui.chat;
|
||||
|
||||
import com.jfoenix.controls.JFXButton;
|
||||
import fr.insa.clavardator.client.users.CurrentUser;
|
||||
import fr.insa.clavardator.lib.message.FileMessage;
|
||||
import fr.insa.clavardator.lib.message.Message;
|
||||
import fr.insa.clavardator.client.users.CurrentUser;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Pos;
|
||||
|
@ -30,6 +30,7 @@ public class MessageListItemController implements Initializable {
|
|||
private Label timestamp;
|
||||
@FXML
|
||||
private FontIcon attachmentIcon;
|
||||
|
||||
/**
|
||||
* Sets the message to display
|
||||
*
|
||||
|
@ -108,5 +109,6 @@ public class MessageListItemController implements Initializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {}
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
}
|
||||
}
|
|
@ -7,8 +7,6 @@ import com.jfoenix.validation.base.ValidatorBase;
|
|||
import fr.insa.clavardator.client.ui.ButtonPressEvent;
|
||||
import fr.insa.clavardator.client.users.CurrentUser;
|
||||
import fr.insa.clavardator.client.users.UserList;
|
||||
import fr.insa.clavardator.lib.util.ParametrizedCallback;
|
||||
import fr.insa.clavardator.lib.util.SimpleCallback;
|
||||
import javafx.beans.property.ReadOnlyBooleanWrapper;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
|
@ -69,6 +67,7 @@ public class EditUsernameDialogController implements Initializable {
|
|||
public void setOnSuccessListener(ButtonPressEvent listener) {
|
||||
this.successListener = listener;
|
||||
}
|
||||
|
||||
public void setOnCancelListener(ButtonPressEvent listener) {
|
||||
this.cancelListener = listener;
|
||||
}
|
||||
|
@ -76,12 +75,11 @@ public class EditUsernameDialogController implements Initializable {
|
|||
/**
|
||||
* Plays the dialog show animation
|
||||
*
|
||||
* @param root The dialog's root component
|
||||
* @param mode The dialog display mode
|
||||
* @implNote WARNING: Do not try to open the dialog instantly after closing it.
|
||||
* Due to JFoenix animations, the dialog will not reopen.
|
||||
* If you must, wait at least 500ms before reopening.
|
||||
*
|
||||
* @param root The dialog's root component
|
||||
* @param mode The dialog display mode
|
||||
*/
|
||||
public void show(StackPane root, Mode mode) {
|
||||
setLocked(false);
|
||||
|
@ -202,7 +200,7 @@ public class EditUsernameDialogController implements Initializable {
|
|||
textField.setOnKeyPressed(event -> {
|
||||
if (event.getCode() == KeyCode.ENTER) {
|
||||
event.consume();
|
||||
if(!textField.getText().isEmpty()){
|
||||
if (!textField.getText().isEmpty()) {
|
||||
onConfirm();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ public class UserActiveIndicatorController implements Initializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {}
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ import com.jfoenix.controls.JFXButton;
|
|||
import fr.insa.clavardator.client.ui.ButtonPressEvent;
|
||||
import fr.insa.clavardator.client.ui.UserSelectedEvent;
|
||||
import fr.insa.clavardator.client.users.PeerUser;
|
||||
import fr.insa.clavardator.lib.users.User;
|
||||
import fr.insa.clavardator.client.users.UserList;
|
||||
import fr.insa.clavardator.lib.users.User;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.ListView;
|
||||
|
@ -22,14 +22,17 @@ public class UserListController implements Initializable {
|
|||
private ButtonPressEvent refreshUserListener;
|
||||
private UserSelectedEvent userSelectedListener;
|
||||
|
||||
public UserListController() {}
|
||||
public UserListController() {
|
||||
}
|
||||
|
||||
public void setRefreshUserListener(ButtonPressEvent listener) {
|
||||
refreshUserListener = listener;
|
||||
}
|
||||
|
||||
public void setUserSelectedListener(UserSelectedEvent listener) {
|
||||
userSelectedListener = listener;
|
||||
}
|
||||
|
||||
public void onRefreshUserListPress() {
|
||||
if (refreshUserListener != null) {
|
||||
refreshUserListener.onPress();
|
||||
|
@ -38,6 +41,7 @@ public class UserListController implements Initializable {
|
|||
|
||||
/**
|
||||
* Enables or disables the refresh button
|
||||
*
|
||||
* @param enabled True to enable, false otherwise
|
||||
*/
|
||||
public void setRefreshButtonEnabled(boolean enabled) {
|
||||
|
@ -63,6 +67,7 @@ public class UserListController implements Initializable {
|
|||
|
||||
/**
|
||||
* Sets the user list to subscribe to
|
||||
*
|
||||
* @param userList The user list to use
|
||||
*/
|
||||
public void setUserList(UserList userList) {
|
||||
|
|
|
@ -111,5 +111,6 @@ public class UserListItemController implements Initializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {}
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--suppress JavaFxUnresolvedFxIdReference -->
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<!--suppress JavaFxUnresolvedFxIdReference -->
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import com.jfoenix.controls.JFXSpinner?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/11.0.1"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.client.ui.chat.ChatController"
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1"
|
||||
xmlns="http://javafx.com/javafx/11.0.1" fx:controller="fr.insa.clavardator.client.ui.chat.ChatController"
|
||||
stylesheets="@../styles.css" styleClass="container">
|
||||
<StackPane AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<HBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
<HBox xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns="http://javafx.com/javafx"
|
||||
fx:controller="fr.insa.clavardator.client.ui.chat.ChatFooterController"
|
||||
stylesheets="@../styles.css" styleClass="container" alignment="CENTER" spacing="10.0" fx:id="container">
|
||||
<padding>
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<VBox xmlns="http://javafx.com/javafx/11.0.1"
|
||||
xmlns:fx="http://javafx.com/fxml/1"
|
||||
<VBox xmlns:fx="http://javafx.com/fxml/1"
|
||||
xmlns="http://javafx.com/javafx/11.0.1"
|
||||
fx:controller="fr.insa.clavardator.client.ui.chat.MessageListItemController"
|
||||
stylesheets="@../styles.css"
|
||||
styleClass="inner"
|
||||
fx:id="container"
|
||||
spacing="10">
|
||||
<padding>
|
||||
<Insets left="50" right="50" top="10" bottom="10"/>
|
||||
</padding>
|
||||
<JFXButton fx:id="button"
|
||||
mnemonicParsing="false"
|
||||
text="Message"
|
||||
textAlignment="CENTER">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-paperclip" iconSize="24" fx:id="attachmentIcon"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
<Label fx:id="timestamp"
|
||||
text="Timestamp"
|
||||
styleClass="timestamp"/>
|
||||
<padding>
|
||||
<Insets left="50" right="50" top="10" bottom="10"/>
|
||||
</padding>
|
||||
<JFXButton fx:id="button"
|
||||
mnemonicParsing="false"
|
||||
text="Message"
|
||||
textAlignment="CENTER">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-paperclip" iconSize="24" fx:id="attachmentIcon"/>
|
||||
</graphic>
|
||||
</JFXButton>
|
||||
<Label fx:id="timestamp"
|
||||
text="Timestamp"
|
||||
styleClass="timestamp"/>
|
||||
</VBox>
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import com.jfoenix.controls.JFXDialog?>
|
||||
<?import com.jfoenix.controls.JFXTextField?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
@ -22,7 +21,7 @@
|
|||
<padding>
|
||||
<Insets bottom="10"/>
|
||||
</padding>
|
||||
<Label styleClass="dialog-title" >À Propos</Label>
|
||||
<Label styleClass="dialog-title">À Propos</Label>
|
||||
<VBox VBox.vgrow="ALWAYS" alignment="CENTER" spacing="30">
|
||||
<Label VBox.vgrow="ALWAYS">Application réalisée par Yohan SIMARD et Arnaud VERGNET</Label>
|
||||
<Label VBox.vgrow="ALWAYS">INSA Toulouse 2020-2021</Label>
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns="http://javafx.com/javafx"
|
||||
fx:controller="fr.insa.clavardator.client.ui.dialogs.SnackbarController"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<VBox xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns="http://javafx.com/javafx"
|
||||
|
@ -14,9 +14,9 @@
|
|||
fx:id="container">
|
||||
<Label>Une erreur est survenue et Clavardator ne peut pas démarrer</Label>
|
||||
<JFXButton styleClass="background-danger" onAction="#onPress">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-times"/>
|
||||
</graphic>
|
||||
Quitter
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-times"/>
|
||||
</graphic>
|
||||
Quitter
|
||||
</JFXButton>
|
||||
</VBox>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--suppress JavaFxUnresolvedFxIdReference -->
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<StackPane xmlns:fx="http://javafx.com/fxml/1"
|
||||
xmlns="http://javafx.com/javafx/11.0.1"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/********************************************************
|
||||
THEME
|
||||
*********************************************************/
|
||||
|
@ -17,7 +16,6 @@
|
|||
}
|
||||
|
||||
|
||||
|
||||
/********************************************************
|
||||
STYLE
|
||||
*********************************************************/
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<VBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
<VBox xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns="http://javafx.com/javafx"
|
||||
fx:controller="fr.insa.clavardator.client.ui.ToolbarController"
|
||||
stylesheets="@styles.css" styleClass="container">
|
||||
<HBox alignment="CENTER_LEFT" prefHeight="64.0" spacing="10">
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<HBox xmlns="http://javafx.com/javafx"
|
||||
xmlns:fx="http://javafx.com/fxml"
|
||||
<HBox xmlns:fx="http://javafx.com/fxml"
|
||||
xmlns="http://javafx.com/javafx"
|
||||
fx:controller="fr.insa.clavardator.client.ui.users.UserActiveIndicatorController"
|
||||
stylesheets="@../styles.css" alignment="CENTER">
|
||||
<Circle fx:id="circle" radius="5.0" styleClass="active-user-dot"/>
|
||||
|
|
|
@ -4,13 +4,14 @@
|
|||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import org.kordamp.ikonli.javafx.FontIcon?>
|
||||
<AnchorPane xmlns="http://javafx.com/javafx/11.0.1"
|
||||
xmlns:fx="http://javafx.com/fxml/1" fx:controller="fr.insa.clavardator.client.ui.users.UserListController"
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1"
|
||||
xmlns="http://javafx.com/javafx/11.0.1" fx:controller="fr.insa.clavardator.client.ui.users.UserListController"
|
||||
stylesheets="@../styles.css" styleClass="container">
|
||||
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<HBox alignment="CENTER" prefHeight="64.0" spacing="10.0">
|
||||
<JFXButton mnemonicParsing="false" text="Utilisateurs" onMouseClicked="#onRefreshUserListPress" fx:id="refreshButton">
|
||||
<JFXButton mnemonicParsing="false" text="Utilisateurs" onMouseClicked="#onRefreshUserListPress"
|
||||
fx:id="refreshButton">
|
||||
<graphic>
|
||||
<FontIcon iconLiteral="fas-sync-alt" iconSize="24"/>
|
||||
</graphic>
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--suppress JavaFxUnresolvedFxIdReference -->
|
||||
<?import com.jfoenix.controls.JFXButton?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<!--suppress JavaFxUnresolvedFxIdReference -->
|
||||
<AnchorPane prefHeight="40.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"
|
||||
<AnchorPane xmlns:fx="http://javafx.com/fxml/1" prefHeight="40.0" xmlns="http://javafx.com/javafx/11.0.1"
|
||||
fx:controller="fr.insa.clavardator.client.ui.users.UserListItemController" stylesheets="@../styles.css"
|
||||
styleClass="inner">
|
||||
<!--suppress JavaFxRedundantPropertyValue -->
|
||||
<JFXButton fx:id="button" alignment="CENTER_LEFT" AnchorPane.bottomAnchor="0" AnchorPane.leftAnchor="0"
|
||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0" onAction="#onPress">
|
||||
<graphic>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package fr.insa.clavardator;
|
||||
|
||||
import fr.insa.clavardator.lib.message.Message;
|
||||
import fr.insa.clavardator.client.db.DatabaseController;
|
||||
import fr.insa.clavardator.lib.message.Message;
|
||||
import fr.insa.clavardator.lib.users.UserInformation;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -30,9 +30,9 @@ public class DatabaseTest {
|
|||
|
||||
db.getChatHistory(new UserInformation("1", "Yohan"),
|
||||
new UserInformation("0", "Arnaud"), new Date(0), new Date(), history -> {
|
||||
assertEquals(history.size(), 0);
|
||||
latch2.countDown();
|
||||
}, Assertions::fail);
|
||||
assertEquals(history.size(), 0);
|
||||
latch2.countDown();
|
||||
}, Assertions::fail);
|
||||
latch2.await();
|
||||
|
||||
CountDownLatch latch8 = new CountDownLatch(1);
|
||||
|
@ -67,8 +67,8 @@ public class DatabaseTest {
|
|||
|
||||
db.getChatHistory(new UserInformation("1", "Yohan"),
|
||||
new UserInformation("2", "Arnaud"), new Date(0), new Date(), history -> {
|
||||
assertEquals(5, history.size());
|
||||
assertEquals("Coucou Arnaud !", history.get(0).getText());
|
||||
assertEquals(5, history.size());
|
||||
assertEquals("Coucou Arnaud !", history.get(0).getText());
|
||||
assertEquals("1", history.get(0).getSender().id);
|
||||
assertEquals("2", history.get(0).getRecipient().id);
|
||||
assertEquals("Yohan", history.get(0).getSender().getUsername());
|
||||
|
|
|
@ -14,8 +14,8 @@ public class FileMessage extends Message {
|
|||
public static final String STORED_FILES_FOLDER = "clavardator_stored_files";
|
||||
|
||||
private final String fileName;
|
||||
private String path;
|
||||
byte[] rawFile = null;
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* Constructs a FileMessage
|
||||
|
|
|
@ -17,7 +17,7 @@ public class Message implements Serializable, SenderInfo, RecipientInfo {
|
|||
}
|
||||
|
||||
public Message(User sender, User recipient, Date date) {
|
||||
this(sender, recipient, date,"");
|
||||
this(sender, recipient, date, "");
|
||||
}
|
||||
|
||||
public Message(UserInformation sender, UserInformation recipient, Date date, String text) {
|
||||
|
|
|
@ -14,12 +14,12 @@ import java.net.Socket;
|
|||
|
||||
public class TcpConnection {
|
||||
|
||||
private final int port;
|
||||
private final Object outputStreamGuard = new Object();
|
||||
private Socket socket;
|
||||
private ObjectOutputStream outputStream;
|
||||
private ObjectInputStream inputStream;
|
||||
private boolean shouldStop = false;
|
||||
private final int port;
|
||||
private final Object outputStreamGuard = new Object();
|
||||
|
||||
/**
|
||||
* Creates a new connection, and connects to the peer
|
||||
|
@ -103,6 +103,15 @@ public class TcpConnection {
|
|||
return socket != null && socket.isConnected() && !socket.isClosed();
|
||||
}
|
||||
|
||||
public interface SocketConnectedCallback {
|
||||
void onSocketConnected(TcpConnection connection);
|
||||
}
|
||||
|
||||
|
||||
public interface MessageReceivedCallback {
|
||||
void onMessageReceived(Object msg) throws IOException;
|
||||
}
|
||||
|
||||
private class Connector extends Thread {
|
||||
private final InetAddress ipAddr;
|
||||
private final SocketConnectedCallback callback;
|
||||
|
@ -129,7 +138,6 @@ public class TcpConnection {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private class Sender extends Thread {
|
||||
private final Serializable message;
|
||||
private final SimpleCallback callback;
|
||||
|
@ -198,13 +206,4 @@ public class TcpConnection {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface SocketConnectedCallback {
|
||||
void onSocketConnected(TcpConnection connection);
|
||||
}
|
||||
|
||||
public interface MessageReceivedCallback {
|
||||
void onMessageReceived(Object msg) throws IOException;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,12 +30,16 @@ public class TcpListener {
|
|||
}
|
||||
|
||||
|
||||
public interface NewConnectionCallback {
|
||||
void onNewConnection(Socket clientSocket);
|
||||
}
|
||||
|
||||
private static class Acceptor extends Thread {
|
||||
private boolean shouldStop = false;
|
||||
private final NewConnectionCallback callback;
|
||||
private final ErrorCallback errorCallback;
|
||||
private ServerSocket server;
|
||||
private final int port;
|
||||
private boolean shouldStop = false;
|
||||
private ServerSocket server;
|
||||
|
||||
public Acceptor(int port, NewConnectionCallback callback, ErrorCallback errorCallback) {
|
||||
this.port = port;
|
||||
|
@ -66,9 +70,4 @@ public class TcpListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface NewConnectionCallback {
|
||||
void onNewConnection(Socket clientSocket);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,17 +5,10 @@ import java.beans.PropertyChangeSupport;
|
|||
import java.io.Serializable;
|
||||
|
||||
public class User implements Serializable {
|
||||
private String username;
|
||||
private String id;
|
||||
|
||||
// Make this class observable
|
||||
private final transient PropertyChangeSupport pcs = new PropertyChangeSupport(this);
|
||||
public void addObserver(PropertyChangeListener listener) {
|
||||
pcs.addPropertyChangeListener(listener);
|
||||
}
|
||||
public void removeObserver(PropertyChangeListener listener) {
|
||||
pcs.removePropertyChangeListener(listener);
|
||||
}
|
||||
private String username;
|
||||
private String id;
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
@ -29,6 +22,14 @@ public class User implements Serializable {
|
|||
this.username = username;
|
||||
}
|
||||
|
||||
public void addObserver(PropertyChangeListener listener) {
|
||||
pcs.addPropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
public void removeObserver(PropertyChangeListener listener) {
|
||||
pcs.removePropertyChangeListener(listener);
|
||||
}
|
||||
|
||||
public PropertyChangeSupport getPcs() {
|
||||
return pcs;
|
||||
}
|
||||
|
|
|
@ -16,13 +16,13 @@ public class Log {
|
|||
public static int verboseLevel = 4;
|
||||
|
||||
private static void print(String prefix, String message, String mode, int requiredLevel, @Nullable Exception e) {
|
||||
if (verboseLevel >= requiredLevel) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
|
||||
System.out.println(sdf.format(date) + " | " + mode + " | " + prefix + ": " + message);
|
||||
if (e != null)
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (verboseLevel >= requiredLevel) {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSS");
|
||||
System.out.println(sdf.format(date) + " | " + mode + " | " + prefix + ": " + message);
|
||||
if (e != null)
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void v(String prefix, String message) {
|
||||
|
|
|
@ -21,6 +21,6 @@ shadowJar {
|
|||
mergeServiceFiles()
|
||||
}
|
||||
|
||||
run{
|
||||
run {
|
||||
standardInput = System.in
|
||||
}
|
|
@ -51,7 +51,7 @@ public class Main {
|
|||
printVersion();
|
||||
System.exit(0);
|
||||
}
|
||||
for (int i = 0; i < args.length -1; i++) {
|
||||
for (int i = 0; i < args.length - 1; i++) {
|
||||
if (PROXY_ARGS.contains(args[i])) {
|
||||
proxyPort = getPort(args[i + 1], PROXY_PORT);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class Presence {
|
|||
public void publish(UserInformation info) {
|
||||
ArrayList<UserInformation> msg = new ArrayList<>(1);
|
||||
msg.add(info);
|
||||
for (Map.Entry<String,TcpConnection> entry : subscribers.entrySet()) {
|
||||
for (Map.Entry<String, TcpConnection> entry : subscribers.entrySet()) {
|
||||
// Do not send update to self
|
||||
if (!entry.getKey().equals(info.id)) {
|
||||
entry.getValue().send(msg, null,
|
||||
|
|
Loading…
Reference in a new issue