/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the Grendel mail/news client. * * The Initial Developer of the Original Code is Netscape Communications * Corporation. Portions created by Netscape are * Copyright (C) 1997 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): * * Created: Jamie Zawinski , 26 Aug 1997. */ package grendel.mime.html; import grendel.mime.IMimeObject; import calypso.util.ByteBuf; import javax.mail.internet.InternetHeaders; import java.io.PrintStream; /** This class converts unknown MIME types to HTML representing an "attachment". @see MimeHTMLOperator */ class MimeExternalObjectOperator extends MimeLeafOperator { String part_id; MimeExternalObjectOperator(IMimeObject object, PrintStream out) { super(object, out); part_id = object.partID(); writeBoxEarly(); } void writeBoxEarly() { String url = "about:jwz"; // #### formatAttachmentBox(headers, content_type, part_id, url, null, false); } void formatAttachmentBox(InternetHeaders headers, String type, String link_name, String link_url, String body, boolean all_headers_p) { String icon = "internal-gopher-binary"; // #### getOut().print("
" + "" + "
"); //#### Temporarily removed because the current renderer doesn't get it --Edwin if (icon != null) { getOut().print("" + "
"); if (link_url != null) getOut().print(""); getOut().print("\"\""); if (link_url != null) getOut().print(""); getOut().print(""); } //#### End of temporarily removed block --Edwin if (link_url != null) getOut().print(""); getOut().print(link_name); if (link_url != null) getOut().print(""); //#### Temporarily removed because the current renderer doesn't get it --Edwin if (icon != null) getOut().print("
"); //#### End of temporarily removed block --Edwin getOut().print("
"); if (all_headers_p) { FullHeaderFormatter formatter = new FullHeaderFormatter(); StringBuffer output = new StringBuffer(200); formatter.formatHeaders(headers, output); getOut().print(output.toString()); } else { String cde[] = headers.getHeader("Content-Description"); String desc = (cde == null || cde.length == 0 ? null : cde[0]); String name = null; ByteBuf buf = new ByteBuf(50); String cdi[] = headers.getHeader("Content-Disposition"); String disp = (cdi == null || cdi.length == 0 ? null : cdi[0]); // #### if (disp != null) name = headers.getHeader("filename", "\n"); if (name == null) if ((type = headers.getHeader("Content-Type", "\n")) != null) name = headers.getHeader("name", "\n"); if (name == null) { String n[] = headers.getHeader("Content-Name"); if (n != null && n.length != 0) name = n[0]; } //#### Temporarily removed because the current renderer doesn't get it --Edwin // getOut().print(""); // // if (name != null) // getOut().print(""); // // if (type != null) // getOut().print(""); // // if (desc != null) // getOut().print(""); // // getOut().print("
" + // "Name" + // #### l10n // ": " + // name + // "
" + // "Type" + // #### l10n // ": " + // type + // "
" + // "Description" + // #### l10n // ": " + // desc + // "
"); //#### End of temporarily removed block --Edwin //#### Temporarily inserted to get rendering working --Edwin if (name != null) getOut().print("Name: " + name + "
"); if (type != null) getOut().print("Type: " + type + "
"); if (desc != null) getOut().print("Description: " + desc + "
"); //#### End of temporarily inserted block --Edwin } if (body != null) { // getOut().print("

");
      // #### quote HTML
      getOut().print(body);
//      getOut().print("
"); } // getOut().print("
"); } public void pushBytes(ByteBuf b) { // Nothing to do with the bytes -- we only use the headers. } public void pushEOF() { } }