Author: dbkr
Date: 2006-05-05 01:57:31 +0000 (Fri, 05 May 2006)
New Revision: 8605

Modified:
   trunk/apps/fnmail/src/fnmail/fcp/FCPConnection.java
   trunk/apps/fnmail/src/fnmail/fcp/FCPMessage.java
   trunk/apps/fnmail/src/fnmail/fcp/HighLevelFCPClient.java
   trunk/apps/fnmail/src/fnmail/smtp/SMTPHandler.java
   trunk/apps/fnmail/src/fnmail/utils/EmailAddress.java
Log:
Fix some bugs with losing connection to the node. Whinge at the email client
if it tries to send to a non-fnmail address.


Modified: trunk/apps/fnmail/src/fnmail/fcp/FCPConnection.java
===================================================================
--- trunk/apps/fnmail/src/fnmail/fcp/FCPConnection.java 2006-05-04 23:27:32 UTC 
(rev 8604)
+++ trunk/apps/fnmail/src/fnmail/fcp/FCPConnection.java 2006-05-05 01:57:31 UTC 
(rev 8605)
@@ -32,6 +32,7 @@
                        if (reply.getType() == null) {
                                System.out.println("Connection closed");
                                this.conn = null;
+                               return;
                        }
                        if (!reply.getType().equals("NodeHello")) {
                                System.out.println("Warning - got 
'"+reply.getType()+"' from node, expecting 'NodeHello'");
@@ -61,7 +62,7 @@
                                }

                                FCPMessage msg = this.getMessage();
-                               if (msg == null) throw new IOException();
+                               if (msg.getType() == null) throw new 
IOException("Connection closed");
                                this.dispatch(msg);
                        } catch (IOException ioe) {
                                System.out.println("Warning - error 
communicating with node - "+ioe.getMessage());
@@ -70,7 +71,7 @@
                                Iterator i = this.clients.values().iterator();
                                while (i.hasNext()) {
                                        FCPClient cli = (FCPClient)i.next();
-                                       cli.requestFinished(null);
+                                       cli.requestFinished(new FCPMessage(1, 
"ConnectionClosed"));
                                }
                                this.clients.clear();
                                // wait a bit

Modified: trunk/apps/fnmail/src/fnmail/fcp/FCPMessage.java
===================================================================
--- trunk/apps/fnmail/src/fnmail/fcp/FCPMessage.java    2006-05-04 23:27:32 UTC 
(rev 8604)
+++ trunk/apps/fnmail/src/fnmail/fcp/FCPMessage.java    2006-05-05 01:57:31 UTC 
(rev 8605)
@@ -39,7 +39,7 @@
                while ( (line = r.readLine(200, 200)) != null) {
                        //System.out.println(line);
                        if (this.messagetype == null) {
-                               messagetype = this.messagetype = line;
+                               this.messagetype = line;
                        } else if (line.startsWith("End")) {
                                return;
                        } else if (line.equals("Data")) {

Modified: trunk/apps/fnmail/src/fnmail/fcp/HighLevelFCPClient.java
===================================================================
--- trunk/apps/fnmail/src/fnmail/fcp/HighLevelFCPClient.java    2006-05-04 
23:27:32 UTC (rev 8604)
+++ trunk/apps/fnmail/src/fnmail/fcp/HighLevelFCPClient.java    2006-05-05 
01:57:31 UTC (rev 8605)
@@ -61,11 +61,8 @@
                                break;
                        } catch (NoNodeConnectionException nnce) {
                                try {
-                                       System.out.println("sleeping");
                                        Thread.sleep(5000);
-                                       System.out.println("wake");
                                } catch (InterruptedException ie) {
-                                       System.out.println("inerrupted");
                                }
                        }
                }

Modified: trunk/apps/fnmail/src/fnmail/smtp/SMTPHandler.java
===================================================================
--- trunk/apps/fnmail/src/fnmail/smtp/SMTPHandler.java  2006-05-04 23:27:32 UTC 
(rev 8604)
+++ trunk/apps/fnmail/src/fnmail/smtp/SMTPHandler.java  2006-05-05 01:57:31 UTC 
(rev 8605)
@@ -208,6 +208,12 @@
                        return;
                }

+               if (!addr.is_fnmail_address()) {
+                       this.ps.print("553 Not a fnmail address\r\n");
+                       return;
+               }
+               
+               
                this.to.add(addr);

                this.ps.print("250 OK\r\n");

Modified: trunk/apps/fnmail/src/fnmail/utils/EmailAddress.java
===================================================================
--- trunk/apps/fnmail/src/fnmail/utils/EmailAddress.java        2006-05-04 
23:27:32 UTC (rev 8604)
+++ trunk/apps/fnmail/src/fnmail/utils/EmailAddress.java        2006-05-05 
01:57:31 UTC (rev 8605)
@@ -44,4 +44,9 @@
                        this.domain = bank.toString();
                }
        }
+       
+       public boolean is_fnmail_address() {
+               if (this.domain == null) return false;
+               return this.domain.equalsIgnoreCase("nim.fnmail");
+       }
 }


Reply via email to