forked from IF-LK-2020/mymail
Finished Project
This commit is contained in:
parent
0f3da85728
commit
53501192bd
70
MyMail.java
70
MyMail.java
|
@ -190,8 +190,7 @@ public class MyMail {
|
|||
|
||||
// Abruf der Mails nach fortlaufender Nummer
|
||||
for( int i = 1; i <= mailCount; i++ ) {
|
||||
|
||||
|
||||
gui.addMailToList(getMail(i));
|
||||
// Mail abrufen (nutze getMail(int))
|
||||
// Mail der GUI hinzufügen (nutze gui.addMailToLost(Mail))
|
||||
}
|
||||
|
@ -250,7 +249,8 @@ public class MyMail {
|
|||
//
|
||||
// Hinweis: Denke daran die Maskierung des Enzeichens "." rückgängig zu machen.
|
||||
// Tipp: Merk dir in einem boolean, ob du im Textkörper oder im Header bist.
|
||||
if( mes.trim().startsWith("Date: ") ) {
|
||||
|
||||
if( mes.startsWith("Date: ") ) {
|
||||
date = mes.substring(6);
|
||||
}
|
||||
else if( mes.startsWith("From: ") ) {
|
||||
|
@ -259,13 +259,17 @@ public class MyMail {
|
|||
else if( mes.startsWith("Subject: ") ) {
|
||||
subject = mes.substring(9);
|
||||
}
|
||||
else if( mes.startsWith("") || header) {
|
||||
text += mes + "/n";
|
||||
else if(header){
|
||||
text += mes + "\n";
|
||||
}
|
||||
else if( mes.equals("")) {
|
||||
header = true;
|
||||
}
|
||||
mes = con.receive();
|
||||
} // end of while
|
||||
|
||||
return new Mail(pNumber, date, sender, subject, text);
|
||||
Mail mail = new Mail(pNumber, date, sender, subject, text);
|
||||
System.out.println(mail);
|
||||
return mail;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -284,8 +288,9 @@ public class MyMail {
|
|||
* @todo Vor Löschen prüfen, ob die Mail auf dem Server dieselbe wie pMail ist.
|
||||
*/
|
||||
public void deleteMail( Mail pMail ) {
|
||||
System.out.println(pMail);
|
||||
// Verbindung erstellen und prüfen
|
||||
|
||||
|
||||
// Anmeldung durchführen und prüfen
|
||||
|
||||
// Prüfen, ob eine Mail mit der Nummer vorhanden ist
|
||||
|
@ -296,6 +301,55 @@ public class MyMail {
|
|||
// Löschung ausführen und Verbindung beenden.
|
||||
|
||||
// Mail aus der GUI entfernen und neu aufbauen.s
|
||||
gui.clearAllMails(); // Gui leeren
|
||||
lastError = null; // Zu Beginn gibt es noch keinen Fehler
|
||||
|
||||
// Verbindung erstellen und prüfen
|
||||
boolean connected = connectToServer();
|
||||
if( !connected ) {
|
||||
// Letzten Fehler anzeigen (wird in connectToServer gesetzt).
|
||||
gui.setError(lastError);
|
||||
return; // Abbrechen
|
||||
}
|
||||
|
||||
// Anmeldung durchführen und prüfen
|
||||
// Hinweis: Nutze die login() Methode
|
||||
if(!login()){
|
||||
gui.setError(lastError);
|
||||
return;
|
||||
}
|
||||
|
||||
con.send("DELE " + pMail.getNumber());
|
||||
if(con.receive().startsWith("-ERR")){
|
||||
lastError = "Zu löschende E-Mail ist nicht vorhanden";
|
||||
gui.setError(lastError);
|
||||
return;
|
||||
}
|
||||
|
||||
int mailCount = getMessageCount();
|
||||
if(mailCount <= 0){
|
||||
gui.setError(lastError);
|
||||
return;
|
||||
}
|
||||
|
||||
// Abruf der Mails nach fortlaufender Nummer, um die aktualisierten Mails einzufügen
|
||||
// Variable bridge um eine fehlende Mail zu überbrücken, da ein Fehler durch die gerade gelöschte Mail erwartet wird
|
||||
// Überbrückt aber nur eine fehlerhafte Anfrage eine Mail
|
||||
boolean bridge = true;
|
||||
for( int i = 1; i <= mailCount; i++ ) {
|
||||
gui.addMailToList(getMail(i));
|
||||
if(lastError != null){
|
||||
if(bridge){
|
||||
mailCount++;
|
||||
lastError = null;
|
||||
bridge = false;
|
||||
}
|
||||
else {
|
||||
gui.setError(lastError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gui.removeMailFromList(pMail);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public class MyMailGUI extends JFrame implements ActionListener, ListSelectionLi
|
|||
if( e.getActionCommand().equals("load") ) {
|
||||
app.getAllMails();
|
||||
} else if( e.getActionCommand().equals("delete") ) {
|
||||
//app.deleteMail(jtMaillist.getSelectedRow()+1);
|
||||
app.deleteMail(mails.get(jtMaillist.getSelectedRow()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,62 +17,62 @@ dependency5.type=UsesDependency
|
|||
dependency6.from=MyMail
|
||||
dependency6.to=Mail
|
||||
dependency6.type=UsesDependency
|
||||
editor.fx.0.height=1017
|
||||
editor.fx.0.width=914
|
||||
editor.fx.0.x=363
|
||||
editor.fx.0.y=14
|
||||
objectbench.height=134
|
||||
objectbench.width=1656
|
||||
editor.fx.0.height=1426
|
||||
editor.fx.0.width=2576
|
||||
editor.fx.0.x=-8
|
||||
editor.fx.0.y=-8
|
||||
objectbench.height=220
|
||||
objectbench.width=2536
|
||||
package.divider.horizontal=0.6
|
||||
package.divider.vertical=0.8297101449275363
|
||||
package.editor.height=680
|
||||
package.editor.width=1545
|
||||
package.divider.vertical=0.8288084464555053
|
||||
package.editor.height=1092
|
||||
package.editor.width=2425
|
||||
package.editor.x=0
|
||||
package.editor.y=98
|
||||
package.frame.height=928
|
||||
package.frame.width=1696
|
||||
package.editor.y=0
|
||||
package.frame.height=1426
|
||||
package.frame.width=2576
|
||||
package.numDependencies=6
|
||||
package.numTargets=5
|
||||
package.showExtends=true
|
||||
package.showUses=true
|
||||
project.charset=UTF-8
|
||||
readme.height=60
|
||||
readme.height=58
|
||||
readme.name=@README
|
||||
readme.width=49
|
||||
readme.width=47
|
||||
readme.x=10
|
||||
readme.y=10
|
||||
target1.height=70
|
||||
target1.height=50
|
||||
target1.name=MyMail
|
||||
target1.showInterface=false
|
||||
target1.type=ClassTarget
|
||||
target1.width=120
|
||||
target1.x=140
|
||||
target1.y=10
|
||||
target2.height=70
|
||||
target1.width=80
|
||||
target1.x=990
|
||||
target1.y=270
|
||||
target2.height=50
|
||||
target2.name=Mail
|
||||
target2.showInterface=false
|
||||
target2.type=ClassTarget
|
||||
target2.width=120
|
||||
target2.x=330
|
||||
target2.y=460
|
||||
target2.width=80
|
||||
target2.x=860
|
||||
target2.y=60
|
||||
target3.height=50
|
||||
target3.name=Connection
|
||||
target3.showInterface=false
|
||||
target3.type=ClassTarget
|
||||
target3.width=100
|
||||
target3.x=520
|
||||
target3.y=150
|
||||
target4.height=70
|
||||
target3.x=1190
|
||||
target3.y=430
|
||||
target4.height=50
|
||||
target4.name=List
|
||||
target4.showInterface=false
|
||||
target4.type=ClassTarget
|
||||
target4.width=150
|
||||
target4.x=490
|
||||
target4.y=270
|
||||
target5.height=70
|
||||
target4.x=440
|
||||
target4.y=60
|
||||
target5.height=50
|
||||
target5.name=MyMailGUI
|
||||
target5.showInterface=false
|
||||
target5.type=ClassTarget
|
||||
target5.width=120
|
||||
target5.x=50
|
||||
target5.y=330
|
||||
target5.width=90
|
||||
target5.x=720
|
||||
target5.y=430
|
||||
|
|
Loading…
Reference in New Issue