added subscribe/unsubscribe banner to servlet
authoradam <adam@megacz.com>
Sat, 15 Apr 2006 05:48:51 +0000 (05:48 +0000)
committeradam <adam@megacz.com>
Sat, 15 Apr 2006 05:48:51 +0000 (05:48 +0000)
darcs-hash:20060415054851-5007d-81e3a674227290ea42300e3af4b061206cc4c6c4.gz

src/org/ibex/mail/target/FileBasedMailbox.java

index 0d7250f..e8a3d82 100644 (file)
@@ -131,7 +131,7 @@ public class FileBasedMailbox extends Mailbox.Default {
             if (done()) return null;
             FileInputStream fis = null;
             try {
-                return new Headers(new Stream(new FileInputStream(file())));
+                return new Headers.Original(new Stream(new FileInputStream(file())));
             } catch (IOException e) { throw new MailException.IOException(e);
             } finally { if (fis != null) try { fis.close(); } catch (Exception e) { /* DELIBERATE */ } }
         }
@@ -146,13 +146,14 @@ public class FileBasedMailbox extends Mailbox.Default {
     }
 
     public static class Servlet extends HttpServlet {
-        public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {doGet(request, response);}
+        public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { doGet(request, response); }
         private void frames(HttpServletRequest request, HttpServletResponse response, boolean top) throws IOException {
             String basename = request.getServletPath();
             PrintWriter pw = new PrintWriter(response.getWriter());
             pw.println("<html>");
             if (top) {
-                pw.println("  <frameset rows='30%,*'>");
+                pw.println("  <frameset rows='10%,30%,*'>");
+                pw.println("    <frame src='"+basename+"?frame=banner' marginwidth=0 marginheight=0 name=banner/>");
                 pw.println("    <frame src='"+basename+"?frame=top' marginwidth=0 marginheight=0 name=top/>");
                 pw.println("    <frame src='"+basename+"?frame=bottom' marginwidth=0 marginheight=0 name='bottom'/>");
             } else {
@@ -171,6 +172,7 @@ public class FileBasedMailbox extends Mailbox.Default {
 
             if (frame == null) { frames(request, response, true); return; }
             if (frame.equals("top")) { frames(request, response, false); return; }
+            if (frame.equals("banner")) { banner(request, response); return; }
             if (frame.equals("topleft")) { return; }
 
             if (request.getServletPath().indexOf("..") != -1) throw new IOException(".. not allowed in image paths");
@@ -216,8 +218,17 @@ public class FileBasedMailbox extends Mailbox.Default {
             pw.println("    </pre>");
             pw.println("  </body>");
             pw.println("</html>");
+            pw.flush();
+            pw.close();
         }
         
+        private void banner(HttpServletRequest request, HttpServletResponse response) throws IOException {
+            String basename = request.getServletPath();
+            String realpath = getServletContext().getRealPath(basename);
+            MailingList list = MailingList.getMailingList(realpath);
+            list.banner(request, response);
+        }
+
         private void topright(HttpServletRequest request, HttpServletResponse response, String[][] messages) throws IOException {
             PrintWriter pw = new PrintWriter(response.getWriter());
             String basename = request.getServletPath();
@@ -269,6 +280,8 @@ public class FileBasedMailbox extends Mailbox.Default {
             pw.println("    </table>");
             pw.println("  </body>");
             pw.println("</html>");
+            pw.flush();
+            pw.close();
         }
     }
 }