added GMail support
authoradam <adam@megacz.com>
Fri, 3 Sep 2004 04:21:27 +0000 (04:21 +0000)
committeradam <adam@megacz.com>
Fri, 3 Sep 2004 04:21:27 +0000 (04:21 +0000)
darcs-hash:20040903042127-5007d-882924241ef2424a59d0b07748538d5baba1835b.gz

src/org/ibex/mail/Main.java
src/org/ibex/mail/protocol/GMail.java

index adcc0eb..531850d 100644 (file)
@@ -13,9 +13,10 @@ public class Main implements Listener {
 
     public void accept(Connection conn) {
         try {
-            if (conn.getLocalPort() == 25)       new SMTP.Server().handleRequest(conn);
-            else if (conn.getLocalPort() == 143) new IMAP.Listener(auth).handleRequest(conn);
-            else if (conn.getLocalPort() == 119) new NNTP.Listener(auth).handleRequest(conn);
+            if      (conn.getLocalPort() == 143)  new IMAP.Listener(auth).handleRequest(conn);
+            else if (conn.getLocalPort() == 25)   new SMTP.Server().handleRequest(conn);
+            else if (conn.getLocalPort() == 119)  new NNTP.Listener(auth).handleRequest(conn);
+            else if (conn.getLocalPort() == 8099) GMail.handleRequest(conn);
         } finally {
             conn.close();
         }
@@ -25,8 +26,7 @@ public class Main implements Listener {
     private static class Auth implements Login {
         public Account anonymous() { return null; }
         public Account login(String user, String pass) {
-            if (user.indexOf("@gmail.com") != -1)
-                return new GMail(user.substring(0, user.indexOf("@gmail.com")), pass);
+            if (user.indexOf("@gmail.com") != -1) return GMail.getGMail(user, pass);
             if (!EtcPasswd.verify(user, pass)) return null;
             final Mailbox root = FileBasedMailbox.getFileBasedMailbox(Mailbox.STORAGE_ROOT, true).slash("user", true);
             return new Account(user, null, root.slash(user, true)){
index 8b277f5..a476ed6 100644 (file)
@@ -115,7 +115,7 @@ public class GMail extends Account {
                                                    "Hi there.  Google is lame; please type in the word you see below and " +
                                                    "click submit.  You might have to click 'get mail' again after that.<br>  " +
                                                    "<img src=\"https://www.google.com/accounts/"+image+"\">\r\n" +
-                                                   "<form method=get action=http://testing.megacz.com:8099/Captcha>\r\n"+
+                                                   "<form method=get action=http://gmail.megacz.com:8099/Captcha>\r\n"+
                                                    "  <input type=text name=captcha>\r\n"+
                                                    "  <input type=hidden name=email value=\""+email+"\">\r\n"+
                                                    "  <input type=hidden name=pass value="+password+">\r\n"+
@@ -201,12 +201,6 @@ public class GMail extends Account {
             e.printStackTrace();
         }
         success = true;
-        for(int i=0; i<connections.size(); i++)
-            try {
-                ((Connection)connections.elementAt(i)).close();
-            } catch (Exception e) {
-                Log.error(this, e);
-            }
         return messages;
     }