forked from IF-LK-2020/mymail
Compare commits
1 Commits
c035137020
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc2fa40bcd |
@@ -34,6 +34,7 @@ public class LoginGUI extends JDialog implements ActionListener {
|
|||||||
setBounds(100, 100, 251, 220);
|
setBounds(100, 100, 251, 220);
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
getContentPane().setLayout(new BorderLayout());
|
getContentPane().setLayout(new BorderLayout());
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
||||||
contentPanel.setLayout(null);
|
contentPanel.setLayout(null);
|
||||||
@@ -90,9 +91,8 @@ public class LoginGUI extends JDialog implements ActionListener {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (e.getActionCommand().equals("OK")) {
|
if (e.getActionCommand().equals("OK")) {
|
||||||
app.start(address.getText(), 110, user.getText(), new String(pw.getPassword()));
|
app.start(address.getText(), 110, user.getText(), new String(pw.getPassword()));
|
||||||
dispose();
|
|
||||||
} else if (e.getActionCommand().equals("Cancel")) {
|
} else if (e.getActionCommand().equals("Cancel")) {
|
||||||
System.out.println("Cancel");
|
dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
MyMail.java
26
MyMail.java
@@ -1,3 +1,4 @@
|
|||||||
|
import javax.swing.JOptionPane;
|
||||||
|
|
||||||
public class MyMail {
|
public class MyMail {
|
||||||
|
|
||||||
@@ -27,20 +28,33 @@ public class MyMail {
|
|||||||
|
|
||||||
private String lastError;
|
private String lastError;
|
||||||
|
|
||||||
private LoginGUI loginGUI;
|
private LoginGUI login;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verbindet zu einem lokalen POP3-Server.
|
* Verbindet zu einem lokalen POP3-Server.
|
||||||
*/
|
*/
|
||||||
public MyMail() {
|
public MyMail() {
|
||||||
loginGUI = new LoginGUI(this);
|
login = new LoginGUI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(String pIP, int pPort, String pUser, String pPassword) {
|
public void start(String pIP, int pPort, String pUser, String pPassword) {
|
||||||
|
|
||||||
ip = pIP;
|
ip = pIP;
|
||||||
port = pPort;
|
port = pPort;
|
||||||
user = pUser;
|
user = pUser;
|
||||||
password = pPassword;
|
password = pPassword;
|
||||||
|
|
||||||
|
if (!connectToServer()) {
|
||||||
|
JOptionPane.showMessageDialog(null, lastError, "Fehler", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!login()) {
|
||||||
|
JOptionPane.showMessageDialog(null, lastError, "Fehler", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
con.send("QUIT");
|
||||||
|
con.close();
|
||||||
|
login.dispose();
|
||||||
|
|
||||||
// GUI erstellen und Status setzen.
|
// GUI erstellen und Status setzen.
|
||||||
gui = new MyMailGUI(this);
|
gui = new MyMailGUI(this);
|
||||||
@@ -108,14 +122,14 @@ public class MyMail {
|
|||||||
con.send("USER " + user);
|
con.send("USER " + user);
|
||||||
mes = con.receive();
|
mes = con.receive();
|
||||||
if (mes == null || mes.startsWith("-ERR")) {
|
if (mes == null || mes.startsWith("-ERR")) {
|
||||||
lastError = "Ungueltiger Benutzername!";
|
lastError = "Ungültiger Benutzername!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// PASS Kommando senden und Antwort prüfen
|
// PASS Kommando senden und Antwort prüfen
|
||||||
con.send("PASS " + password);
|
con.send("PASS " + password);
|
||||||
mes = con.receive();
|
mes = con.receive();
|
||||||
if (mes == null || mes.startsWith("-ERR")) {
|
if (mes == null || mes.startsWith("-ERR")) {
|
||||||
lastError = "Ungueltiges Passwort!";
|
lastError = "Ungültiges Passwort!";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Anmeldung war erfolgreich
|
// Anmeldung war erfolgreich
|
||||||
@@ -326,4 +340,8 @@ public class MyMail {
|
|||||||
gui.removeMailFromList(pMail);
|
gui.removeMailFromList(pMail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void switchUser() {
|
||||||
|
login = new LoginGUI(this);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class MyMailGUI extends JFrame implements ActionListener, ListSelectionLi
|
|||||||
|
|
||||||
private JLabel jlStatusText;
|
private JLabel jlStatusText;
|
||||||
|
|
||||||
private JButton jbReload, jbDelete, jbNew, jbReply, jbSettings;
|
private JButton jbReload, jbDelete, jbNew, jbReply, jbSettings, jbSwitchUser;
|
||||||
|
|
||||||
private JTable jtMaillist;
|
private JTable jtMaillist;
|
||||||
|
|
||||||
@@ -100,6 +100,9 @@ public class MyMailGUI extends JFrame implements ActionListener, ListSelectionLi
|
|||||||
app.getAllMails();
|
app.getAllMails();
|
||||||
} else if( e.getActionCommand().equals("delete") ) {
|
} else if( e.getActionCommand().equals("delete") ) {
|
||||||
app.deleteMail(mails.get(jtMaillist.getSelectedRow()));
|
app.deleteMail(mails.get(jtMaillist.getSelectedRow()));
|
||||||
|
} else if (e.getActionCommand().equals("switchUser")) {
|
||||||
|
app.switchUser();
|
||||||
|
dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,6 +147,11 @@ public class MyMailGUI extends JFrame implements ActionListener, ListSelectionLi
|
|||||||
jbDelete.addActionListener(this);
|
jbDelete.addActionListener(this);
|
||||||
jbDelete.setIcon(loadImageIcon("email_delete.png"));
|
jbDelete.setIcon(loadImageIcon("email_delete.png"));
|
||||||
jpSidebar.add(jbDelete);
|
jpSidebar.add(jbDelete);
|
||||||
|
|
||||||
|
jbSwitchUser = new JButton("Abmelden");
|
||||||
|
jbSwitchUser.setActionCommand("switchUser");
|
||||||
|
jbSwitchUser.addActionListener(this);
|
||||||
|
jpSidebar.add(jbSwitchUser);
|
||||||
|
|
||||||
jbSettings = new JButton("Einstellungen");
|
jbSettings = new JButton("Einstellungen");
|
||||||
jbSettings.setActionCommand("settings");
|
jbSettings.setActionCommand("settings");
|
||||||
|
|||||||
Reference in New Issue
Block a user