зеркало из https://github.com/mozilla/pjs.git
Fix for bug 162440. Add 2 new attributes to nsIMsgAttachmentHandler to allow to set the charset as well an extra parameter for the content-type header. R=varada, SR=bienvenu
This commit is contained in:
Родитель
1424ccf763
Коммит
966b566be8
|
@ -73,16 +73,34 @@ interface nsIMsgAttachment : nsISupports {
|
|||
/**
|
||||
* contentType attribute
|
||||
*
|
||||
* @Specify the content-type of the attachment
|
||||
* @Specify the content-type of the attachment, this not include extra content-type parameters. If
|
||||
* @you need to specify extra information, use contentTypeParam, charset, macType or macCreator.
|
||||
* @If ommitted, it will be determined base on either the name, the url or the content of the file.
|
||||
*/
|
||||
attribute string contentType;
|
||||
|
||||
/**
|
||||
* contentTypeParam attribute
|
||||
*
|
||||
* @Specify the any content-type parameter (other than the content-type itself, charset, macType or macCreator).
|
||||
* @It will be added to the content-type during the send/save operation.
|
||||
*/
|
||||
attribute string contentTypeParam;
|
||||
|
||||
/**
|
||||
* charset attribute
|
||||
*
|
||||
* @Specify the charset of the attachment. It will be added to the content-type during the
|
||||
* @send/save operation
|
||||
* @If omitted, will be determined automatically (if possible).
|
||||
*/
|
||||
attribute string charset;
|
||||
|
||||
/**
|
||||
* macType attribute
|
||||
*
|
||||
* @Specify the Mac file type of the attachment
|
||||
* @Specify the Mac file type of the attachment. It will be added to the content-type during the
|
||||
* @send/save operation
|
||||
* @If omitted, will be determined automatically on Macintosh OS.
|
||||
*/
|
||||
attribute string macType;
|
||||
|
@ -90,7 +108,8 @@ interface nsIMsgAttachment : nsISupports {
|
|||
/**
|
||||
* macCreator attribute
|
||||
*
|
||||
* @Specify the Mac file creator of the attachment
|
||||
* @Specify the Mac file creator of the attachment. It will be added to the content-type during the
|
||||
* @send/save operation
|
||||
* @If omitted, will be determined automatically on Macintosh OS.
|
||||
*/
|
||||
attribute string macCreator;
|
||||
|
|
|
@ -131,6 +131,38 @@ NS_IMETHODIMP nsMsgAttachment::SetContentType(const char * aContentType)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute string contentTypeParam; */
|
||||
NS_IMETHODIMP nsMsgAttachment::GetContentTypeParam(char * *aContentTypeParam)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aContentTypeParam);
|
||||
|
||||
*aContentTypeParam = ToNewCString(mContentTypeParam);
|
||||
return (*aContentTypeParam ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
NS_IMETHODIMP nsMsgAttachment::SetContentTypeParam(const char * aContentTypeParam)
|
||||
{
|
||||
if (aContentTypeParam)
|
||||
while (*aContentTypeParam == ';' || *aContentTypeParam == ' ')
|
||||
aContentTypeParam ++;
|
||||
mContentTypeParam = aContentTypeParam;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute string charset; */
|
||||
NS_IMETHODIMP nsMsgAttachment::GetCharset(char * *aCharset)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aCharset);
|
||||
|
||||
*aCharset = ToNewCString(mCharset);
|
||||
return (*aCharset ? NS_OK : NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
NS_IMETHODIMP nsMsgAttachment::SetCharset(const char * aCharset)
|
||||
{
|
||||
mCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* attribute string macType; */
|
||||
NS_IMETHODIMP nsMsgAttachment::GetMacType(char * *aMacType)
|
||||
{
|
||||
|
|
|
@ -58,6 +58,8 @@ private:
|
|||
PRBool mTemporary;
|
||||
nsCString mContentLocation;
|
||||
nsCString mContentType;
|
||||
nsCString mContentTypeParam;
|
||||
nsCString mCharset;
|
||||
nsCString mMacType;
|
||||
nsCString mMacCreator;
|
||||
};
|
||||
|
|
|
@ -119,6 +119,7 @@ nsMsgAttachmentHandler::nsMsgAttachmentHandler()
|
|||
|
||||
m_done = PR_FALSE;
|
||||
m_type = nsnull;
|
||||
m_type_param = nsnull;
|
||||
m_size = 0;
|
||||
|
||||
mCompFields = nsnull; // Message composition fields for the sender
|
||||
|
@ -153,18 +154,19 @@ nsMsgAttachmentHandler::~nsMsgAttachmentHandler()
|
|||
delete mFileSpec;
|
||||
mFileSpec=nsnull;
|
||||
|
||||
PR_FREEIF(m_charset);
|
||||
PR_FREEIF(m_type);
|
||||
PR_FREEIF(m_content_id);
|
||||
PR_FREEIF(m_desired_type);
|
||||
PR_FREEIF(m_encoding);
|
||||
PR_FREEIF(m_override_type);
|
||||
PR_FREEIF(m_description);
|
||||
PR_FREEIF(m_real_name);
|
||||
PR_FREEIF(m_override_encoding);
|
||||
PR_FREEIF(m_x_mac_type);
|
||||
PR_FREEIF(m_x_mac_creator);
|
||||
PR_FREEIF(m_uri);
|
||||
PR_Free(m_charset);
|
||||
PR_Free(m_type);
|
||||
PR_Free(m_type_param);
|
||||
PR_Free(m_content_id);
|
||||
PR_Free(m_desired_type);
|
||||
PR_Free(m_encoding);
|
||||
PR_Free(m_override_type);
|
||||
PR_Free(m_description);
|
||||
PR_Free(m_real_name);
|
||||
PR_Free(m_override_encoding);
|
||||
PR_Free(m_x_mac_type);
|
||||
PR_Free(m_x_mac_creator);
|
||||
PR_Free(m_uri);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -113,6 +113,7 @@ public:
|
|||
char *m_charset; // charset name
|
||||
char *m_content_id; // This is for mutipart/related Content-ID's
|
||||
char *m_type; // The real type, once we know it.
|
||||
char *m_type_param; // Any addition parameters to add to the content-type (other than charset, macType and maccreator)
|
||||
char *m_override_type; // The type we should assume it to be
|
||||
// or 0, if we should get it from the
|
||||
// server)
|
||||
|
|
|
@ -715,7 +715,9 @@ char
|
|||
}
|
||||
|
||||
char *
|
||||
mime_generate_attachment_headers (const char *type, const char *encoding,
|
||||
mime_generate_attachment_headers (const char *type,
|
||||
const char *type_param,
|
||||
const char *encoding,
|
||||
const char *description,
|
||||
const char *x_mac_type,
|
||||
const char *x_mac_creator,
|
||||
|
@ -784,6 +786,13 @@ mime_generate_attachment_headers (const char *type, const char *encoding,
|
|||
PUSH_STRING ("Content-Type: ");
|
||||
PUSH_STRING (type);
|
||||
|
||||
if (type_param && *type_param)
|
||||
{
|
||||
if (*type_param != ';')
|
||||
PUSH_STRING("; ");
|
||||
PUSH_STRING(type_param);
|
||||
}
|
||||
|
||||
if (mime_type_needs_charset (type))
|
||||
{
|
||||
|
||||
|
|
|
@ -94,7 +94,9 @@ char *mime_generate_headers (nsMsgCompFields *fields,
|
|||
char *mime_make_separator(const char *prefix);
|
||||
char *mime_gen_content_id(PRUint32 aPartNum, const char *aEmailAddress);
|
||||
|
||||
char *mime_generate_attachment_headers (const char *type,
|
||||
char *mime_generate_attachment_headers (
|
||||
const char *type,
|
||||
const char *type_param,
|
||||
const char *encoding,
|
||||
const char *description,
|
||||
const char *x_mac_type,
|
||||
|
|
|
@ -817,6 +817,7 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
|||
m_plaintext->PickEncoding(mCompFields->GetCharacterSet(), this);
|
||||
const char *charset = mCompFields->GetCharacterSet();
|
||||
hdrs = mime_generate_attachment_headers(m_plaintext->m_type,
|
||||
nsnull,
|
||||
m_plaintext->m_encoding,
|
||||
m_plaintext->m_description,
|
||||
m_plaintext->m_x_mac_type,
|
||||
|
@ -985,6 +986,7 @@ nsMsgComposeAndSend::GatherMimeAttachments()
|
|||
{
|
||||
const char *charset = mCompFields->GetCharacterSet();
|
||||
hdrs = mime_generate_attachment_headers (m_attachment1_type,
|
||||
nsnull,
|
||||
m_attachment1_encoding,
|
||||
0, 0, 0, 0, 0,
|
||||
m_digest_p,
|
||||
|
@ -1190,7 +1192,9 @@ nsMsgComposeAndSend::PreProcessPart(nsMsgAttachmentHandler *ma,
|
|||
}
|
||||
else
|
||||
ma->mURL->GetSpec(turl);
|
||||
hdrs = mime_generate_attachment_headers (ma->m_type, ma->m_encoding,
|
||||
hdrs = mime_generate_attachment_headers (ma->m_type,
|
||||
ma->m_type_param,
|
||||
ma->m_encoding,
|
||||
ma->m_description,
|
||||
ma->m_x_mac_type,
|
||||
ma->m_x_mac_creator,
|
||||
|
@ -2228,6 +2232,8 @@ nsMsgComposeAndSend::AddCompFieldLocalAttachments()
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
element->GetContentTypeParam(&m_attachments[newLoc].m_type_param);
|
||||
|
||||
#ifdef XP_MAC
|
||||
//We always need to snarf the file to figure out how to send it, maybe we need to use apple double...
|
||||
|
|
Загрузка…
Ссылка в новой задаче