Fix for attachment count - bug #16076 - reviewer: jefft

This commit is contained in:
rhp%netscape.com 1999-10-14 02:05:20 +00:00
parent dc4835d974
commit 93ccba7139
7 changed files with 96 additions and 115 deletions

View File

@ -426,22 +426,6 @@ MimeExternalBody_parse_eof (MimeObject *obj, PRBool abort_p)
newopt.fancy_headers_p = PR_TRUE;
newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);
{
char p[] = "<P>";
status = MimeObject_write(obj, p, 3, PR_FALSE);
if (status < 0) goto FAIL;
}
status = MimeHeaders_write_attachment_box (hdrs, &newopt, ct, 0,
lname, lurl, body);
if (status < 0) goto FAIL;
{
char p[] = "<P>";
status = MimeObject_write(obj, p, 3, PR_FALSE);
if (status < 0) goto FAIL;
}
FAIL:
if (hdrs)
MimeHeaders_free(hdrs);

View File

@ -175,28 +175,9 @@ MimeExternalObject_parse_begin (MimeObject *obj)
all_headers_p = PR_FALSE;
newopt.fancy_headers_p = PR_TRUE;
newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);
{
char p[] = "<P>";
status = MimeObject_write(obj, p, 3, PR_FALSE);
if (status < 0) goto FAIL;
}
status = MimeHeaders_write_attachment_box (obj->headers, &newopt,
obj->content_type,
obj->encoding,
id_name? id_name : id, id_url, 0);
newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);
PR_FREEIF(id_name);
if (status < 0) goto FAIL;
{
char p[] = "<P>";
status = MimeObject_write(obj, p, 3, PR_FALSE);
if (status < 0) goto FAIL;
}
FAIL:
PR_FREEIF(id);
PR_FREEIF(id_url);
PR_FREEIF(id_name);

View File

@ -995,47 +995,6 @@ MimeHeaders_write_all_headers (MimeHeaders *hdrs, MimeDisplayOptions *opt, PRBoo
return 1;
}
/*
* This routine now drives the emitter by printing all of the
* attachment headers.
*/
int
MimeHeaders_write_attachment_box(MimeHeaders *hdrs,
MimeDisplayOptions *opt,
const char *content_type,
const char *encoding,
const char *lname,
const char *lname_url,
const char *body)
{
int status = 0;
// RICHIE SHERRY
// Writing a header "box" is not needed anymore since we are doing
// attachments a whole new way... I need to clean this up and this
// routine will probably go away for good...but until then, just return
// success
//
nsIPref *pref = GetPrefServiceManager(opt); // Pref service manager
PRBool mimeXULOutput = PR_FALSE;
if (pref)
pref->GetBoolPref("mail.mime_xul_output", &mimeXULOutput);
if (!mimeXULOutput)
{
mimeEmitterStartAttachment(opt, lname, content_type, lname_url);
status = MimeHeaders_write_all_headers (hdrs, opt, PR_TRUE);
mimeEmitterAddAttachmentField(opt, HEADER_X_MOZILLA_PART_URL, lname_url);
mimeEmitterEndAttachment(opt);
}
if (status < 0)
return status;
else
return 0;
}
#ifdef MOZ_SECURITY
HG99401
#endif /* MOZ_SECURITY */

View File

@ -65,16 +65,6 @@ extern int MimeHeaders_write_raw_headers (MimeHeaders *hdrs,
PRBool dont_write_content_type);
/* For drawing the tables that represent objects that can't be displayed
inline. */
extern int MimeHeaders_write_attachment_box(MimeHeaders *hdrs,
MimeDisplayOptions *opt,
const char *content_type,
const char *encoding,
const char *name,
const char *name_url,
const char *body);
#ifdef MOZ_SECURITY
HG77761
#endif

View File

@ -155,21 +155,6 @@ MimeMultipartAppleDouble_parse_begin (MimeObject *obj)
newopt.fancy_headers_p = PR_TRUE;
newopt.headers = (all_headers_p ? MimeHeadersAll : MimeHeadersSome);
{
char p[] = "<P>";
status = MimeObject_write(obj, p, 3, PR_FALSE);
if (status < 0) goto FAIL;
}
status = MimeHeaders_write_attachment_box (obj->headers, &newopt,
obj->content_type,
obj->encoding,
id, id_url, 0);
if (status < 0) goto FAIL;
/* No <P> after the first attachment-box in an AppleDouble, to keep
them closer together. */
FAIL:
PR_FREEIF(id);
PR_FREEIF(id_url);

View File

@ -253,15 +253,6 @@ NotifyEmittersOfAttachmentList(MimeDisplayOptions *opt,
PRInt32 i = 0;
struct nsMsgAttachmentData *tmp = data;
// RICHIE - this will go away once we cutover...
nsIPref *pref = GetPrefServiceManager(opt); // Pref service manager
PRBool mimeXULOutput = PR_TRUE;
if (pref)
pref->GetBoolPref("mail.mime_xul_output", &mimeXULOutput);
if (!mimeXULOutput)
return;
if ( (!tmp) || (!tmp->real_name) )
return;
@ -1342,7 +1333,7 @@ PRBool
NoEmitterProcessing(nsMimeOutputType format_out)
{
if ( (format_out == nsMimeOutput::nsMimeMessageDraftOrTemplate) ||
(format_out == nsMimeOutput::nsMimeMessageEditorTemplate) )
(format_out == nsMimeOutput::nsMimeMessageEditorTemplate))
return PR_TRUE;
else
return PR_FALSE;

View File

@ -445,13 +445,14 @@ NewChannel(nsIChannel **aInstancePtrResult, nsIURI *aURI)
int
main(int argc, char** argv)
{
nsresult DoFormattingOnly(char *filename);
nsresult DoRFC822toHTMLConversion(char *filename, int numArgs);
nsresult rv;
// Do some sanity checking...
if (argc < 2)
{
fprintf(stderr, "usage: %s <rfc822_disk_file> <any_arg_for_XUL_output>\n", argv[0]);
fprintf(stderr, "usage: %s <rfc822_disk_file> <any_arg_for_XUL_output - 19 for simple processing>\n", argv[0]);
return 1;
}
@ -468,8 +469,11 @@ main(int argc, char** argv)
if (NS_FAILED(rv))
return rv;
// Do the conversion!
DoRFC822toHTMLConversion(argv[1], argc);
// Do the conversion or just process the file!
if ( (argc >= 3) && (atoi(argv[2]) == 19) )
DoFormattingOnly(argv[1]);
else
DoRFC822toHTMLConversion(argv[1], argc);
// Cleanup stuff necessary...
NS_IF_RELEASE(ccMan);
@ -602,3 +606,90 @@ DoRFC822toHTMLConversion(char *filename, int numArgs)
return NS_OK;
}
nsresult
DoFormattingOnly(char *filename)
{
char newURL[1024] = ""; // URL for filename
nsIURI *theURI = nsnull;
nsMimeOutputType outFormat;
char *contentType = nsnull;
outFormat = nsMimeOutput::nsMimeMessageQuoting;
char *opts = PL_strchr(filename, '?');
char save;
if (opts)
{
save = *opts;
*opts = '\0';
}
nsFilePath inFilePath(filename, PR_TRUE); // relative path.
nsFileSpec mySpec(inFilePath);
if (!mySpec.Exists())
{
printf("Unable to open input file %s\n", filename);
return NS_ERROR_FAILURE;
}
if (opts)
*opts = save;
nsCOMPtr<nsIStreamListener> out = nsnull;
ConsoleOutputStreamListener *ptr = nsnull;
// Create the consumer output stream.. this will receive all the HTML from libmime
ptr = new ConsoleOutputStreamListener();
out = do_QueryInterface(ptr);
if (!out)
{
printf("Failed to create nsIOutputStream\n");
return NS_ERROR_FAILURE;
}
// This is the producer stream that will deliver data from the disk file...
FileInputStreamImpl *ptr2 = new FileInputStreamImpl();
nsCOMPtr<FileInputStreamImpl> in = do_QueryInterface(ptr2);
if (!in )
{
printf("Failed to create nsIInputStream\n");
return NS_ERROR_FAILURE;
}
if (NS_FAILED(in->OpenDiskFile(mySpec)))
{
printf("Unable to open input file %s\n", filename);
return NS_ERROR_FAILURE;
}
// Create an nsIURI object needed for stream IO...
PR_snprintf(newURL, sizeof(newURL), "file://%s", filename);
FixURL(newURL);
if (NS_FAILED(NewURI(&theURI, newURL)))
{
printf("Unable to open input file\n");
return NS_ERROR_FAILURE;
}
nsIChannel *tChannel = nsnull;
NewChannel(&tChannel, theURI);
if (ptr)
ptr->SetFormat(outFormat);
// Just pump all of the data from the file into formatter...
while (NS_SUCCEEDED(in->PumpFileStream()))
{
PRUint32 len;
in->GetLength(&len);
if (out->OnDataAvailable(tChannel, nsnull, in, 0, len) != NS_OK)
break;
}
NS_RELEASE(theURI);
return NS_OK;
}