Working on handshake mechanism with login
This commit is contained in:
@ -12,6 +12,7 @@ import javax.swing.SwingUtilities;
|
||||
|
||||
import envoy.client.*;
|
||||
import envoy.client.util.EnvoyLog;
|
||||
import envoy.data.LoginCredentials;
|
||||
import envoy.data.User;
|
||||
import envoy.exception.EnvoyException;
|
||||
|
||||
@ -75,6 +76,9 @@ public class Startup {
|
||||
logger.severe("User name is not set or empty. Exiting...");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// TODO: create dialog
|
||||
String pass = JOptionPane.showInputDialog("Enter password");
|
||||
|
||||
// Initialize the local database
|
||||
LocalDB localDB;
|
||||
@ -91,10 +95,10 @@ public class Startup {
|
||||
|
||||
// Acquire the client user (with ID) either from the server or from the local
|
||||
// database, which triggers offline mode
|
||||
Client client = new Client(config);
|
||||
Client client = new Client();
|
||||
try {
|
||||
// Try entering online mode first
|
||||
client.onlineInit(userName);
|
||||
client.onlineInit(new LoginCredentials(userName, pass.toCharArray()));
|
||||
} catch (Exception e1) {
|
||||
logger.warning("Could not connect to server. Trying offline mode...");
|
||||
try {
|
||||
@ -120,8 +124,8 @@ public class Startup {
|
||||
// Initialize chats in local database
|
||||
try {
|
||||
localDB.initializeDBFile();
|
||||
localDB.loadChats();
|
||||
} catch (EnvoyException e) {
|
||||
// TODO: localDB.loadChats();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null,
|
||||
"Error while loading local database: " + e.toString() + "\nChats will not be stored locally.",
|
||||
|
Reference in New Issue
Block a user