Fix for bad wrapping on quoting and IMAP Parts on demand - Bugs #: 32100 17794

git-svn-id: svn://10.0.0.236/trunk@64049 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rhp%netscape.com
2000-03-24 21:22:53 +00:00
parent 450a22a4e5
commit 2bd7ccb0bc
14 changed files with 51 additions and 19 deletions

View File

@@ -164,11 +164,16 @@ var messageHeaderSink = {
}
},
handleAttachment: function(url, displayName, uri)
handleAttachment: function(url, displayName, uri, notDownloaded)
{
// be sure to escape the display name before we insert it into the
// method
var commandString = "OpenAttachURL('" + url + "', '" + escape(displayName) + "', '" + uri + "')";
if (notDownloaded)
{
displayName += " " + Bundle.GetStringFromName("notDownloaded");
}
AddAttachmentToMenu(displayName, commandString);
}
};

View File

@@ -51,3 +51,4 @@ PrintingMessage=Printing message...
PrintingComplete=Printing complete.
saveAttachmentFailed=Unable to save the attachment. Please check your file name and try again later.
saveMessageFailed=Unable to save the message. Please check your file name and try again later.
notDownloaded=(Not Downloaded)

View File

@@ -77,7 +77,7 @@ typedef nsresult (*nsMsgSendUnsentMessagesCallback) (nsresult aExitCode, PRUint3
// Attachment file/URL structures
struct nsMsgAttachmentData
{
nsIURI *url; // The URL to attach. This should be 0 to signify "end of list".
nsIURI *url; // The URL to attach. This should be 0 to signify "end of list".
char *desired_type; // The type to which this document should be
// converted. Legal values are NULL, TEXT_PLAIN
@@ -100,6 +100,7 @@ struct nsMsgAttachmentData
char *x_mac_type, *x_mac_creator; // Mac-specific data that should show up as optional parameters
// to the content-type header.
PRBool notDownloaded; // Flag for IMAP parts on demand status
};

View File

@@ -311,7 +311,8 @@ nsMimeBaseEmitter::SetOutputListener(nsIStreamListener *listener)
// Attachment handling routines
nsresult
nsMimeBaseEmitter::StartAttachment(const char *name, const char *contentType, const char *url)
nsMimeBaseEmitter::StartAttachment(const char *name, const char *contentType, const char *url,
PRBool aNotDownloaded)
{
// Ok, now we will setup the attachment info
mCurrentAttachment = (attachmentInfoType *) PR_NEWZAP(attachmentInfoType);
@@ -322,6 +323,7 @@ nsMimeBaseEmitter::StartAttachment(const char *name, const char *contentType, co
mCurrentAttachment->displayName = nsCRT::strdup(name);
mCurrentAttachment->urlSpec = nsCRT::strdup(url);
mCurrentAttachment->contentType = nsCRT::strdup(contentType);
mCurrentAttachment->notDownloaded = aNotDownloaded;
}
return NS_OK;

View File

@@ -55,6 +55,7 @@ typedef struct {
char *displayName;
char *urlSpec;
char *contentType;
PRBool notDownloaded;
} attachmentInfoType;
//

View File

@@ -215,7 +215,8 @@ nsMimeHtmlDisplayEmitter::EndHeader()
}
nsresult
nsMimeHtmlDisplayEmitter::StartAttachment(const char *name, const char *contentType, const char *url)
nsMimeHtmlDisplayEmitter::StartAttachment(const char *name, const char *contentType, const char *url,
PRBool aNotDownloaded)
{
nsresult rv = NS_OK;
@@ -246,7 +247,7 @@ nsMimeHtmlDisplayEmitter::StartAttachment(const char *name, const char *contentT
}
if (NS_SUCCEEDED(rv))
headerSink->HandleAttachment(escapedUrl, unicodeHeaderValue, uriString);
headerSink->HandleAttachment(escapedUrl, unicodeHeaderValue, uriString, aNotDownloaded);
nsCRT::free(escapedUrl);
mSkipAttachment = PR_TRUE;
}

View File

@@ -45,7 +45,8 @@ public:
NS_IMETHOD EndHeader();
// Attachment handling routines
NS_IMETHOD StartAttachment(const char *name, const char *contentType, const char *url);
NS_IMETHOD StartAttachment(const char *name, const char *contentType, const char *url,
PRBool aNotDownloaded);
NS_IMETHOD AddAttachmentField(const char *field, const char *value);
NS_IMETHOD EndAttachment();

View File

@@ -177,7 +177,8 @@ nsMimeXmlEmitter::EndHeader()
// Attachment handling routines
nsresult
nsMimeXmlEmitter::StartAttachment(const char *name, const char *contentType, const char *url)
nsMimeXmlEmitter::StartAttachment(const char *name, const char *contentType, const char *url,
PRBool aNotDownloaded)
{
char buf[128];

View File

@@ -45,7 +45,8 @@ public:
NS_IMETHOD EndHeader();
// Attachment handling routines
NS_IMETHOD StartAttachment(const char *name, const char *contentType, const char *url);
NS_IMETHOD StartAttachment(const char *name, const char *contentType, const char *url,
PRBool aNotDownloaded);
NS_IMETHOD AddAttachmentField(const char *field, const char *value);
NS_IMETHOD EndAttachment();

View File

@@ -61,7 +61,7 @@ interface nsIMimeEmitter : nsISupports{
// Attachment handling routines
void StartAttachment([const] in string name, [const] in string contentType,
[const] in string url);
[const] in string url, in PRBool aNotDownloaded);
void AddAttachmentField([const] in string field, [const] in string value);
void EndAttachment();

View File

@@ -51,5 +51,5 @@ interface nsIMsgHeaderSink : nsISupports{
// make a sandwhich around header processing.....
void onStartHeaders();
void onEndHeaders();
void handleAttachment(in string url, in wstring displayName, in string uri);
void handleAttachment(in string url, in wstring displayName, in string uri, in boolean aNotDownloaded);
};

View File

@@ -163,8 +163,12 @@ ProcessBodyAsAttachment(MimeObject *obj, nsMsgAttachmentData **data)
tmpURL = mime_set_url_imap_part(url, id_imap, id);
rv = nsMimeNewURI(&(tmp->url), tmpURL, nsnull);
tmp->notDownloaded = PR_TRUE;
// RICHIE RICHIE
// If we get here, we should really add some type of string
// onto the name to show its not downloaded
/********************
nsString tName(tmp->real_name);
char *msgString = MimeGetStringByID(MIME_MSG_NOT_DOWNLOADED);
@@ -172,6 +176,7 @@ ProcessBodyAsAttachment(MimeObject *obj, nsMsgAttachmentData **data)
tName.Append(msgString);
PR_FREEIF(tmp->real_name);
tmp->real_name = tName.ToNewCString();
*********************/
}
else
{
@@ -380,15 +385,22 @@ BuildAttachmentList(MimeObject *aChild, nsMsgAttachmentData *aAttachData,
if (isIMAPPart)
{
// If we get here, we should mark this attachment as not being
// downloaded.
tmp->notDownloaded = PR_TRUE;
// RICHIE RICHIE RICHIE
//
// If we get here, we should really add some type of string
// onto the name to show its not downloaded
/**
nsString tName(tmp->real_name);
char *msgString = MimeGetStringByID(MIME_MSG_NOT_DOWNLOADED);
tName.Append(" ");
tName.Append(msgString);
PR_FREEIF(tmp->real_name);
tmp->real_name = tName.ToNewCString();
***/
}
}
@@ -486,7 +498,7 @@ NotifyEmittersOfAttachmentList(MimeDisplayOptions *opt,
if ( tmp->url )
tmp->url->GetSpec(&spec);
mimeEmitterStartAttachment(opt, tmp->real_name, tmp->real_type, spec);
mimeEmitterStartAttachment(opt, tmp->real_name, tmp->real_type, spec, tmp->notDownloaded);
mimeEmitterAddAttachmentField(opt, HEADER_X_MOZILLA_PART_URL, spec);
if (spec)
@@ -711,7 +723,6 @@ mime_display_stream_write (nsMIMESession *stream,
PRInt32 size)
{
struct mime_stream_data *msd = (struct mime_stream_data *) ((nsMIMESession *)stream)->data_object;
static PRBool firstCheck = PR_TRUE;
MimeObject *obj = (msd ? msd->obj : 0);
if (!obj) return -1;
@@ -720,7 +731,7 @@ mime_display_stream_write (nsMIMESession *stream,
// Ok, now check to see if this is a display operation for a MIME Parts on Demand
// enabled call.
//
if (firstCheck)
if (msd->firstCheck)
{
if (msd->channel)
{
@@ -740,7 +751,7 @@ mime_display_stream_write (nsMIMESession *stream,
}
}
firstCheck = PR_FALSE;
msd->firstCheck = PR_FALSE;
}
return obj->clazz->parse_buffer((char *) buf, size, obj);
@@ -1196,6 +1207,7 @@ mime_bridge_create_display_stream(
// Assign the new mime emitter - will handle output operations
msd->output_emitter = newEmitter;
msd->firstCheck = PR_TRUE;
// Store the URL string for this decode operation
char *urlString;
@@ -1483,7 +1495,8 @@ mimeEmitterAddHeaderField(MimeDisplayOptions *opt, const char *field, const char
}
extern "C" nsresult
mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char *contentType, const char *url)
mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char *contentType, const char *url,
PRBool aNotDownloaded)
{
// Check for draft processing...
if (NoEmitterProcessing(opt->format_out))
@@ -1496,7 +1509,7 @@ mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char
if (msd->output_emitter)
{
nsIMimeEmitter *emitter = (nsIMimeEmitter *)msd->output_emitter;
return emitter->StartAttachment(name, contentType, url);
return emitter->StartAttachment(name, contentType, url, aNotDownloaded);
}
return NS_ERROR_FAILURE;

View File

@@ -115,6 +115,7 @@ struct mime_stream_data { /* This struct is the state we pass around
MimeHeaders *headers; /* Copy of outer most mime header */
nsIMimeEmitter *output_emitter; /* Output emitter engine for libmime */
PRBool firstCheck; /* Is this the first look at the stream data */
};
////////////////////////////////////////////////////////////////
@@ -137,7 +138,8 @@ extern "C" nsIMimeEmitter *GetMimeEmitter(MimeDisplayOptions *opt);
extern "C" nsresult mimeSetNewURL(nsMIMESession *stream, char *url);
extern "C" nsresult mimeEmitterAddAttachmentField(MimeDisplayOptions *opt, const char *field, const char *value);
extern "C" nsresult mimeEmitterAddHeaderField(MimeDisplayOptions *opt, const char *field, const char *value);
extern "C" nsresult mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char *contentType, const char *url);
extern "C" nsresult mimeEmitterStartAttachment(MimeDisplayOptions *opt, const char *name, const char *contentType, const char *url,
PRBool aNotDownloaded);
extern "C" nsresult mimeEmitterEndAttachment(MimeDisplayOptions *opt);
extern "C" nsresult mimeEmitterStartBody(MimeDisplayOptions *opt, PRBool bodyOnly, const char *msgID, const char *outCharset);
extern "C" nsresult mimeEmitterEndBody(MimeDisplayOptions *opt);

View File

@@ -149,7 +149,10 @@ MimeInlineTextPlain_parse_begin (MimeObject *obj)
if ( (obj->options->format_out == nsMimeOutput::nsMimeMessageQuoting) ||
(obj->options->format_out == nsMimeOutput::nsMimeMessageBodyQuoting) )
{
s = nsCRT::strdup(strs[0]);
if (obj->options->wrap_long_lines_p)
s = nsCRT::strdup(strs[2]);
else
s = nsCRT::strdup(strs[0]);
}
else
{