mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-13 18:27:35 +00:00
Initial check in
This commit is contained in:
parent
30df698861
commit
0c2f8a656b
729
mailnews/compose/src/nsMsgCompFields.cpp
Normal file
729
mailnews/compose/src/nsMsgCompFields.cpp
Normal file
@ -0,0 +1,729 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Netscape Public License
|
||||||
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||||
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||||
|
* http://www.mozilla.org/NPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* NPL.
|
||||||
|
*
|
||||||
|
* The Initial Developer of this code under the NPL is Netscape
|
||||||
|
* Communications Corporation. Portions created by Netscape are
|
||||||
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||||
|
* Reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rosetta_mailnews.h"
|
||||||
|
#include "nsCRT.h"
|
||||||
|
#include "nsMsgCompFields.h"
|
||||||
|
#include "nsMsgCompFieldsFact.h"
|
||||||
|
|
||||||
|
/*JFD
|
||||||
|
#include "msg.h"
|
||||||
|
#include "errcode.h"
|
||||||
|
#include "dberror.h"
|
||||||
|
|
||||||
|
#include "msgcflds.h"
|
||||||
|
#include "prefapi.h"
|
||||||
|
#include "ptrarray.h"
|
||||||
|
#include "msgpane.h"
|
||||||
|
JFD*/
|
||||||
|
|
||||||
|
/* use these macros to define a class IID for our component. Our object currently supports two interfaces
|
||||||
|
(nsISupports and nsIMsgCompose) so we want to define constants for these two interfaces */
|
||||||
|
static NS_DEFINE_IID(kIMsgCompFields, NS_IMSGCOMPFIELDS_IID);
|
||||||
|
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
extern int MK_OUT_OF_MEMORY;
|
||||||
|
extern int MK_MSG_INVALID_NEWS_HEADER;
|
||||||
|
extern int MK_MSG_CANT_POST_TO_MULTIPLE_NEWS_HOSTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* this function will be used by the factory to generate an Message Compose Fields Object....*/
|
||||||
|
nsresult NS_NewMsgCompFields(nsIMsgCompFields** aInstancePtrResult)
|
||||||
|
{
|
||||||
|
/* note this new macro for assertions...they can take a string describing the assertion */
|
||||||
|
nsresult result = NS_OK;
|
||||||
|
NS_PRECONDITION(nsnull != aInstancePtrResult, "nsnull ptr");
|
||||||
|
if (nsnull != aInstancePtrResult)
|
||||||
|
{
|
||||||
|
nsMsgCompFields* pCompFields = new nsMsgCompFields();
|
||||||
|
if (pCompFields)
|
||||||
|
return pCompFields->QueryInterface(kIMsgCompFields, (void**) aInstancePtrResult);
|
||||||
|
else
|
||||||
|
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NS_ERROR_NULL_POINTER; /* aInstancePtrResult was NULL....*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* the following macro actually implement addref, release and query interface for our component. */
|
||||||
|
NS_IMPL_ISUPPORTS(nsMsgCompFields, NS_IMSGCOMPFIELDS_IID);
|
||||||
|
|
||||||
|
nsMsgCompFields::nsMsgCompFields()
|
||||||
|
{
|
||||||
|
PRInt16 i;
|
||||||
|
PRBool bReturnReceiptOn = FALSE;
|
||||||
|
|
||||||
|
m_owner = NULL;
|
||||||
|
for (i = 0; i < MAX_HEADERS; i ++)
|
||||||
|
m_headers[i] = NULL;
|
||||||
|
m_body = NULL;
|
||||||
|
m_forwardurl = NULL;
|
||||||
|
m_numforward = 0;
|
||||||
|
m_maxforward = 0;
|
||||||
|
for (i = 0; i < MSG_LAST_BOOL_HEADER_MASK; i ++)
|
||||||
|
m_boolHeaders[i] = PR_FALSE;
|
||||||
|
m_force_plain_text = PR_FALSE;
|
||||||
|
m_multipart_alt = PR_FALSE;
|
||||||
|
m_receiptType = 0;
|
||||||
|
|
||||||
|
PREF_GetBoolPref("mail.request.return_receipt_on", &bReturnReceiptOn);
|
||||||
|
PREF_GetIntPref("mail.request.return_receipt", &m_receiptType);
|
||||||
|
SetReturnReceipt (bReturnReceiptOn, NULL);
|
||||||
|
|
||||||
|
NS_INIT_REFCNT();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nsMsgCompFields::~nsMsgCompFields()
|
||||||
|
{
|
||||||
|
PRInt16 i;
|
||||||
|
for (i = 0; i < MAX_HEADERS; i ++)
|
||||||
|
PR_FREEIF(m_headers[i]);
|
||||||
|
|
||||||
|
PR_FREEIF(m_body);
|
||||||
|
|
||||||
|
for (i = 0; i < m_numforward; i++)
|
||||||
|
delete [] m_forwardurl[i];
|
||||||
|
|
||||||
|
delete [] m_forwardurl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::Copy(const nsIMsgCompFields* pMsgCompFields)
|
||||||
|
{
|
||||||
|
nsMsgCompFields * pFields = (nsMsgCompFields*)pMsgCompFields;
|
||||||
|
|
||||||
|
PRInt16 i;
|
||||||
|
for (i = 0; i < MAX_HEADERS; i ++) {
|
||||||
|
if (pFields->m_headers[i])
|
||||||
|
m_headers[i] = nsCRT::strdup(pFields->m_headers[i]);
|
||||||
|
}
|
||||||
|
if (pFields->m_body)
|
||||||
|
m_body = nsCRT::strdup(pFields->m_body);
|
||||||
|
|
||||||
|
for (i = 0; i < pFields->m_numforward; i++)
|
||||||
|
AddForwardURL(pFields->m_forwardurl[i]);
|
||||||
|
|
||||||
|
for (i = 0; i < MSG_LAST_BOOL_HEADER_MASK; i ++)
|
||||||
|
m_boolHeaders[i] = pFields->m_boolHeaders[i];
|
||||||
|
|
||||||
|
m_receiptType = pFields->m_receiptType;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetHeader(PRInt32 header, const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
|
/* Since colon is not a legal character in a newsgroup name under son-of-1036
|
||||||
|
we're assuming that such a header contains a URL, and we should parse it out
|
||||||
|
to infer the news server. */
|
||||||
|
if (value && MSG_NEWSGROUPS_HEADER_MASK == header && PL_strchr(value, ':'))
|
||||||
|
{
|
||||||
|
status = ParseNewsgroupsForUrls (value);
|
||||||
|
if (status == 0)
|
||||||
|
return status; /* it was a news URL, and we snarfed it up */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (status == MK_MSG_CANT_POST_TO_MULTIPLE_NEWS_HOSTS)
|
||||||
|
{
|
||||||
|
MSG_Pane *owner = GetOwner();
|
||||||
|
if (owner)
|
||||||
|
FE_Alert (owner->GetContext(), XP_GetString(status));
|
||||||
|
}
|
||||||
|
|
||||||
|
status = 0; /* It isn't a valid news URL, so treat it like a newsgroup
|
||||||
|
MSG_CompositionPane::SanityCheck will decide if it's a legal newsgroup name */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int i = DecodeHeader(header);
|
||||||
|
if (i >= 0)
|
||||||
|
{
|
||||||
|
char* old = m_headers[i]; /* Done with careful paranoia, in case the
|
||||||
|
value given is the old value (or worse,
|
||||||
|
a substring of the old value, as does
|
||||||
|
happen here and there.) */
|
||||||
|
if (value != old)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
m_headers[i] = nsCRT::strdup(value);
|
||||||
|
if (!m_headers[i])
|
||||||
|
status = MK_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_headers[i] = NULL;
|
||||||
|
PR_FREEIF(old);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_retval)
|
||||||
|
*_retval = status;
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetHeader(PRInt32 header, char **_retval)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(nsnull != _retval, "nsnull ptr");
|
||||||
|
|
||||||
|
int i = DecodeHeader(header);
|
||||||
|
if (i >= 0) {
|
||||||
|
if (m_headers[i])
|
||||||
|
*_retval = m_headers[i];
|
||||||
|
else
|
||||||
|
*_retval = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*_retval = NULL;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetBoolHeader(PRInt32 header, PRBool bValue, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
int status = 0;
|
||||||
|
/*JFD
|
||||||
|
NS_ASSERTION ((int) header >= (int) MSG_RETURN_RECEIPT_BOOL_HEADER_MASK &&
|
||||||
|
(int) header < (int) MSG_LAST_BOOL_HEADER_MASK, "invalid header index");
|
||||||
|
|
||||||
|
if ( (int) header < (int) MSG_RETURN_RECEIPT_BOOL_HEADER_MASK ||
|
||||||
|
(int) header >= (int) MSG_LAST_BOOL_HEADER_MASK )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
m_boolHeaders[header] = bValue;
|
||||||
|
*/
|
||||||
|
if (_retval)
|
||||||
|
*_retval = status;
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetBoolHeader(PRInt32 header, PRBool *_retval)
|
||||||
|
{
|
||||||
|
NS_PRECONDITION(nsnull != _retval, "nsnull ptr");
|
||||||
|
/*JFD
|
||||||
|
NS_ASSERTION ((int) header >= (int) MSG_RETURN_RECEIPT_BOOL_HEADER_MASK &&
|
||||||
|
(int) header < (int) MSG_LAST_BOOL_HEADER_MASK, "invalid header index");
|
||||||
|
|
||||||
|
if ( (int) header < (int) MSG_RETURN_RECEIPT_BOOL_HEADER_MASK ||
|
||||||
|
(int) header >= (int) MSG_LAST_BOOL_HEADER_MASK )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return m_boolHeaders[header];
|
||||||
|
*/
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetFrom(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_FROM_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetFrom(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_FROM_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetReplyTo(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_REPLY_TO_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetReplyTo(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_REPLY_TO_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetTo(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_TO_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetTo(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_TO_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetCc(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_CC_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetCc(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_CC_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetBcc(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_BCC_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetBcc(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_BCC_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetFcc(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_NEWS_FCC_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetFcc(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_NEWS_FCC_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetNewsFcc(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_NEWS_FCC_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetNewsFcc(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_NEWS_FCC_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetNewsBcc(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_NEWS_BCC_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetNewsBcc(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_NEWS_BCC_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetNewsgroups(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_NEWSGROUPS_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetNewsgroups(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_NEWSGROUPS_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetFollowupTo(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_FOLLOWUP_TO_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetFollowupTo(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_FOLLOWUP_TO_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetSubject(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_SUBJECT_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetSubject(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_SUBJECT_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetAttachments(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_ATTACHMENTS_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetAttachments(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_ATTACHMENTS_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetOrganization(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_ORGANIZATION_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetOrganization(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_ORGANIZATION_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetReferences(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_REFERENCES_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetReferences(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_REFERENCES_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetOtherRandomHeaders(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_OTHERRANDOMHEADERS_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetOtherRandomHeaders(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_OTHERRANDOMHEADERS_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetNewspostUrl(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_NEWSPOSTURL_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetNewspostUrl(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_NEWSPOSTURL_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetDefaultBody(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_DEFAULTBODY_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetDefaultBody(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_DEFAULTBODY_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetPriority(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_PRIORITY_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetPriority(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_PRIORITY_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetMessageEncoding(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_MESSAGE_ENCODING_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetMessageEncoding(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_MESSAGE_ENCODING_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetCharacterSet(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_CHARACTER_SET_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetCharacterSet(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_CHARACTER_SET_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetMessageId(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_MESSAGE_ID_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetMessageId(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_MESSAGE_ID_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetHTMLPart(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_HTML_PART_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetHTMLPart(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_HTML_PART_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetTemplateName(const char *value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetHeader(MSG_X_TEMPLATE_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetTemplateName(char **_retval)
|
||||||
|
{
|
||||||
|
return GetHeader(MSG_X_TEMPLATE_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetReturnReceipt(PRBool value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetReturnReceipt(PRBool *_retval)
|
||||||
|
{
|
||||||
|
return GetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::SetAttachVCard(PRBool value, PRInt32 *_retval)
|
||||||
|
{
|
||||||
|
return SetBoolHeader(MSG_ATTACH_VCARD_BOOL_HEADER_MASK, value, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult nsMsgCompFields::GetAttachVCard(PRBool *_retval)
|
||||||
|
{
|
||||||
|
return GetBoolHeader(MSG_ATTACH_VCARD_BOOL_HEADER_MASK, _retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
HJ36954
|
||||||
|
{
|
||||||
|
/* Here's where we allow URLs in the newsgroups: header */
|
||||||
|
|
||||||
|
int status = -1;
|
||||||
|
if (hostPort && group) /* must have a group */
|
||||||
|
{
|
||||||
|
char *newsPostUrl = HJ57077
|
||||||
|
if (newsPostUrl)
|
||||||
|
{
|
||||||
|
const char *existingHeader;
|
||||||
|
GetHeader (MSG_NEWSPOSTURL_HEADER_MASK, (char **)&existingHeader);
|
||||||
|
if (existingHeader && *existingHeader && nsCRT::strcasecmp(newsPostUrl,existingHeader))
|
||||||
|
status = MK_MSG_CANT_POST_TO_MULTIPLE_NEWS_HOSTS; /* can only send to one news host at a time */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetHeader (MSG_NEWSPOSTURL_HEADER_MASK, newsPostUrl, NULL);
|
||||||
|
status = 0; /* we succeeded, no need to keep looking at this header */
|
||||||
|
}
|
||||||
|
PR_Free(newsPostUrl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = MK_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PRInt16 nsMsgCompFields::ParseNewsgroupsForUrls (const char *value)
|
||||||
|
{
|
||||||
|
int status = 0;
|
||||||
|
|
||||||
|
/* Here we pull apart the comma-separated header value and look for news
|
||||||
|
URLs. We'll use the URL to set the newspost URL to determine the host */
|
||||||
|
#if 0 //JFD
|
||||||
|
msg_StringArray values (TRUE /*owns memory for strings*/);
|
||||||
|
values.ImportTokenList (value);
|
||||||
|
|
||||||
|
for (int i = 0; i < values.GetSize() && status == 0; i++)
|
||||||
|
{
|
||||||
|
const char *singleValue = values.GetAt(i);
|
||||||
|
if (NEWS_TYPE_URL == NET_URL_Type (singleValue))
|
||||||
|
{
|
||||||
|
char *hostPort, *group, *id, *data;
|
||||||
|
HJ81279
|
||||||
|
if (status == 0)
|
||||||
|
{
|
||||||
|
HJ78808
|
||||||
|
if (status == 0)
|
||||||
|
{
|
||||||
|
values.RemoveAt(i); /* Remove the URL spec for this group */
|
||||||
|
values.InsertAt (i, group); /* Add in the plain old group name */
|
||||||
|
}
|
||||||
|
PR_FREEIF (hostPort);
|
||||||
|
PR_FREEIF (group);
|
||||||
|
PR_FREEIF (id);
|
||||||
|
PR_FREEIF (data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
status = MK_MSG_INVALID_NEWS_HEADER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == 0)
|
||||||
|
{
|
||||||
|
char *newValue = values.ExportTokenList ();
|
||||||
|
if (newValue)
|
||||||
|
{
|
||||||
|
status = SetHeader (MSG_NEWSGROUPS_HEADER_MASK, newValue);
|
||||||
|
PR_Free(newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif //JFD
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*JFD
|
||||||
|
extern "C" const char* MSG_GetCompFieldsHeader(MSG_CompositionFields *fields,
|
||||||
|
MSG_HEADER_SET header)
|
||||||
|
{
|
||||||
|
return (fields) ? fields->GetHeader(header) : 0;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
nsMsgCompFields::SetBody(const char* value)
|
||||||
|
{
|
||||||
|
PR_FREEIF(m_body);
|
||||||
|
if (value) {
|
||||||
|
m_body = nsCRT::strdup(value);
|
||||||
|
if (!m_body) return MK_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
nsMsgCompFields::GetBody()
|
||||||
|
{
|
||||||
|
return m_body ? m_body : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
nsMsgCompFields::AppendBody(const char* value)
|
||||||
|
{
|
||||||
|
if (!value || !*value) return 0;
|
||||||
|
if (!m_body) {
|
||||||
|
return SetBody(value);
|
||||||
|
} else {
|
||||||
|
char* tmp = (char*) PR_MALLOC(nsCRT::strlen(m_body) + nsCRT::strlen(value) + 1);
|
||||||
|
if (tmp) {
|
||||||
|
tmp = nsCRT::strdup(m_body);
|
||||||
|
PL_strcat(tmp, value);
|
||||||
|
PR_Free(m_body);
|
||||||
|
m_body = tmp;
|
||||||
|
} else {
|
||||||
|
return MK_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRInt16 nsMsgCompFields::DecodeHeader(MSG_HEADER_SET header)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
switch(header) {
|
||||||
|
case MSG_FROM_HEADER_MASK:
|
||||||
|
result = 0;
|
||||||
|
break;
|
||||||
|
case MSG_REPLY_TO_HEADER_MASK:
|
||||||
|
result = 1;
|
||||||
|
break;
|
||||||
|
case MSG_TO_HEADER_MASK:
|
||||||
|
result = 2;
|
||||||
|
break;
|
||||||
|
case MSG_CC_HEADER_MASK:
|
||||||
|
result = 3;
|
||||||
|
break;
|
||||||
|
case MSG_BCC_HEADER_MASK:
|
||||||
|
result = 4;
|
||||||
|
break;
|
||||||
|
case MSG_FCC_HEADER_MASK:
|
||||||
|
result = 5;
|
||||||
|
break;
|
||||||
|
case MSG_NEWSGROUPS_HEADER_MASK:
|
||||||
|
result = 6;
|
||||||
|
break;
|
||||||
|
case MSG_FOLLOWUP_TO_HEADER_MASK:
|
||||||
|
result = 7;
|
||||||
|
break;
|
||||||
|
case MSG_SUBJECT_HEADER_MASK:
|
||||||
|
result = 8;
|
||||||
|
break;
|
||||||
|
case MSG_ATTACHMENTS_HEADER_MASK:
|
||||||
|
result = 9;
|
||||||
|
break;
|
||||||
|
case MSG_ORGANIZATION_HEADER_MASK:
|
||||||
|
result = 10;
|
||||||
|
break;
|
||||||
|
case MSG_REFERENCES_HEADER_MASK:
|
||||||
|
result = 11;
|
||||||
|
break;
|
||||||
|
case MSG_OTHERRANDOMHEADERS_HEADER_MASK:
|
||||||
|
result = 12;
|
||||||
|
break;
|
||||||
|
case MSG_NEWSPOSTURL_HEADER_MASK:
|
||||||
|
result = 13;
|
||||||
|
break;
|
||||||
|
case MSG_PRIORITY_HEADER_MASK:
|
||||||
|
result = 14;
|
||||||
|
break;
|
||||||
|
case MSG_NEWS_FCC_HEADER_MASK:
|
||||||
|
result = 15;
|
||||||
|
break;
|
||||||
|
case MSG_MESSAGE_ENCODING_HEADER_MASK:
|
||||||
|
result = 16;
|
||||||
|
break;
|
||||||
|
case MSG_CHARACTER_SET_HEADER_MASK:
|
||||||
|
result = 17;
|
||||||
|
break;
|
||||||
|
case MSG_MESSAGE_ID_HEADER_MASK:
|
||||||
|
result = 18;
|
||||||
|
break;
|
||||||
|
case MSG_NEWS_BCC_HEADER_MASK:
|
||||||
|
result = 19;
|
||||||
|
break;
|
||||||
|
case MSG_HTML_PART_HEADER_MASK:
|
||||||
|
result = 20;
|
||||||
|
break;
|
||||||
|
case MSG_DEFAULTBODY_HEADER_MASK:
|
||||||
|
result = 21;
|
||||||
|
break;
|
||||||
|
case MSG_X_TEMPLATE_HEADER_MASK:
|
||||||
|
result = 22;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
NS_ASSERTION(0, "invalid header index");
|
||||||
|
result = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
NS_ASSERTION(result < sizeof(m_headers) / sizeof(char*), "wrong result, review the code!");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRInt16 nsMsgCompFields::AddForwardURL(const char* url)
|
||||||
|
{
|
||||||
|
NS_ASSERTION(url && *url, "empty url");
|
||||||
|
if (!url || !*url) return -1;
|
||||||
|
if (m_numforward >= m_maxforward) {
|
||||||
|
m_maxforward += 10;
|
||||||
|
char** tmp = new char* [m_maxforward];
|
||||||
|
if (!tmp) return MK_OUT_OF_MEMORY;
|
||||||
|
for (PRInt32 i=0 ; i<m_numforward ; i++) {
|
||||||
|
tmp[i] = m_forwardurl[i];
|
||||||
|
}
|
||||||
|
delete [] m_forwardurl;
|
||||||
|
m_forwardurl = tmp;
|
||||||
|
}
|
||||||
|
m_forwardurl[m_numforward] = new char[nsCRT::strlen(url) + 1];
|
||||||
|
if (!m_forwardurl[m_numforward]) return MK_OUT_OF_MEMORY;
|
||||||
|
m_forwardurl[m_numforward] = nsCRT::strdup(url);
|
||||||
|
m_numforward++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PRInt32 nsMsgCompFields::GetNumForwardURL()
|
||||||
|
{
|
||||||
|
return m_numforward;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* nsMsgCompFields::GetForwardURL(PRInt32 which)
|
||||||
|
{
|
||||||
|
NS_ASSERTION(which >= 0 && which < m_numforward, "parameter out of range");
|
||||||
|
if (which >= 0 && which < m_numforward) {
|
||||||
|
return m_forwardurl[which];
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
184
mailnews/compose/src/nsMsgCompFields.h
Normal file
184
mailnews/compose/src/nsMsgCompFields.h
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Netscape Public License
|
||||||
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||||
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||||
|
* http://www.mozilla.org/NPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* NPL.
|
||||||
|
*
|
||||||
|
* The Initial Developer of this code under the NPL is Netscape
|
||||||
|
* Communications Corporation. Portions created by Netscape are
|
||||||
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||||
|
* Reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MsgCompFields_H_
|
||||||
|
#define _MsgCompFields_H_
|
||||||
|
|
||||||
|
/*JFD #include "msgzap.h" */
|
||||||
|
#include "msgCore.h"
|
||||||
|
#include "prprf.h" /* should be defined into msgCore.h? */
|
||||||
|
#include "net.h" /* should be defined into msgCore.h? */
|
||||||
|
#include "intl_csi.h"
|
||||||
|
#include "msgcom.h"
|
||||||
|
#include "nsMsgHeaderMasks.h"
|
||||||
|
|
||||||
|
#include "MsgCompGlue.h"
|
||||||
|
|
||||||
|
#include "nsIMsgCompFields.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Note that all the "Get" methods never return NULL (except in case of serious
|
||||||
|
error, like an illegal parameter); rather, they return "" if things were set
|
||||||
|
to NULL. This makes it real handy for the callers. */
|
||||||
|
|
||||||
|
class nsMsgCompFields : public nsIMsgCompFields, public MSG_ZapIt {
|
||||||
|
public:
|
||||||
|
nsMsgCompFields();
|
||||||
|
virtual ~nsMsgCompFields();
|
||||||
|
|
||||||
|
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
|
/* this is just for testing purpose, must be removed before shipping */
|
||||||
|
NS_IMETHOD Test() {printf("nsMsgCompField: Test Succesfull\n"); return NS_OK;}
|
||||||
|
|
||||||
|
NS_IMETHOD Copy(const nsIMsgCompFields* pMsgCompFields);
|
||||||
|
|
||||||
|
NS_IMETHOD SetHeader(PRInt32 header, const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetHeader(PRInt32 header, char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetBoolHeader(PRInt32 header, PRBool bValue, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetBoolHeader(PRInt32 header, PRBool *_retval);
|
||||||
|
|
||||||
|
|
||||||
|
/* Convenience routines to get and set header's value... */
|
||||||
|
NS_IMETHOD SetFrom(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetFrom(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetReplyTo(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetReplyTo(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetTo(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetTo(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetCc(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetCc(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetBcc(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetBcc(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetFcc(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetFcc(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetNewsFcc(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetNewsFcc(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetNewsBcc(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetNewsBcc(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetNewsgroups(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetNewsgroups(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetFollowupTo(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetFollowupTo(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetSubject(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetSubject(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetAttachments(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetAttachments(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetOrganization(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetOrganization(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetReferences(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetReferences(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetOtherRandomHeaders(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetOtherRandomHeaders(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetNewspostUrl(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetNewspostUrl(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetDefaultBody(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetDefaultBody(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetPriority(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetPriority(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetMessageEncoding(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetMessageEncoding(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetCharacterSet(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetCharacterSet(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetMessageId(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetMessageId(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetHTMLPart(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetHTMLPart(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetTemplateName(const char *value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetTemplateName(char **_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetReturnReceipt(PRBool value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetReturnReceipt(PRBool *_retval);
|
||||||
|
|
||||||
|
NS_IMETHOD SetAttachVCard(PRBool value, PRInt32 *_retval);
|
||||||
|
NS_IMETHOD GetAttachVCard(PRBool *_retval);
|
||||||
|
|
||||||
|
int SetBody(const char*);
|
||||||
|
const char* GetBody();
|
||||||
|
|
||||||
|
int AppendBody(const char*);
|
||||||
|
|
||||||
|
// When forwarding a bunch of messages, we can have a bunch of
|
||||||
|
// "forward url's" instead of an attachment.
|
||||||
|
|
||||||
|
PRInt16 AddForwardURL(const char*);
|
||||||
|
|
||||||
|
PRInt32 GetNumForwardURL();
|
||||||
|
const char* GetForwardURL(PRInt32 which);
|
||||||
|
|
||||||
|
PRInt32 GetReturnReceiptType() { return m_receiptType; };
|
||||||
|
void SetReturnReceiptType(PRInt32 type) {m_receiptType = type;};
|
||||||
|
|
||||||
|
void SetOwner(MSG_Pane *pane) {
|
||||||
|
m_owner = pane;
|
||||||
|
}
|
||||||
|
|
||||||
|
MSG_Pane * GetOwner() { return m_owner; }
|
||||||
|
|
||||||
|
|
||||||
|
void SetForcePlainText(PRBool value) {m_force_plain_text = value;}
|
||||||
|
PRBool GetForcePlainText() {return m_force_plain_text;}
|
||||||
|
void SetUseMultipartAlternative(PRBool value) {m_multipart_alt = value;}
|
||||||
|
PRBool GetUseMultipartAlternative() {return m_multipart_alt;}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
PRInt16 DecodeHeader(MSG_HEADER_SET header);
|
||||||
|
|
||||||
|
// These methods allow news URLs in the newsgroups header
|
||||||
|
HJ30181
|
||||||
|
PRInt16 ParseNewsgroupsForUrls (const char *value);
|
||||||
|
|
||||||
|
#define MAX_HEADERS 32
|
||||||
|
MSG_Pane* m_owner;
|
||||||
|
char* m_headers[MAX_HEADERS];
|
||||||
|
char* m_body;
|
||||||
|
char** m_forwardurl;
|
||||||
|
PRInt32 m_numforward;
|
||||||
|
PRInt32 m_maxforward;
|
||||||
|
PRBool m_boolHeaders[MSG_LAST_BOOL_HEADER_MASK];
|
||||||
|
PRBool m_force_plain_text;
|
||||||
|
PRBool m_multipart_alt;
|
||||||
|
PRInt32 m_receiptType; /* 0:None 1:DSN 2:MDN 3:BOTH */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _MsgCompFields_H_ */
|
4153
mailnews/compose/src/nsMsgCompose.cpp
Normal file
4153
mailnews/compose/src/nsMsgCompose.cpp
Normal file
File diff suppressed because it is too large
Load Diff
322
mailnews/compose/src/nsMsgCompose.h
Normal file
322
mailnews/compose/src/nsMsgCompose.h
Normal file
@ -0,0 +1,322 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Netscape Public License
|
||||||
|
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||||
|
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||||
|
* http://www.mozilla.org/NPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* NPL.
|
||||||
|
*
|
||||||
|
* The Initial Developer of this code under the NPL is Netscape
|
||||||
|
* Communications Corporation. Portions created by Netscape are
|
||||||
|
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||||
|
* Reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _MsgCompose_H_
|
||||||
|
#define _MsgCompose_H_
|
||||||
|
|
||||||
|
|
||||||
|
#include "msgCore.h"
|
||||||
|
#include "prprf.h" /* should be defined into msgCore.h? */
|
||||||
|
#include "net.h" /* should be defined into msgCore.h? */
|
||||||
|
#include "intl_csi.h"
|
||||||
|
#include "msgcom.h"
|
||||||
|
|
||||||
|
#include "MsgCompGlue.h"
|
||||||
|
|
||||||
|
//#include "nsMsgPtrArray.h"
|
||||||
|
#include "nsMsgHeaderMasks.h"
|
||||||
|
#include "nsMsgFolderFlags.h"
|
||||||
|
|
||||||
|
#include "nsIMsgCompFields.h"
|
||||||
|
#include "nsIMsgCompose.h"
|
||||||
|
|
||||||
|
/*JFD
|
||||||
|
#include "msg.h"
|
||||||
|
#include "msgpane.h"
|
||||||
|
#include "xlate.h"
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* The MSG_REPLY_TYPE shares the same space as MSG_CommandType, to avoid
|
||||||
|
possible weird errors, but is restricted to the `composition' commands
|
||||||
|
(MSG_ReplyToSender through MSG_ForwardMessage.)
|
||||||
|
*/
|
||||||
|
typedef MSG_CommandType MSG_REPLY_TYPE;
|
||||||
|
|
||||||
|
|
||||||
|
struct MSG_AttachedFile;
|
||||||
|
typedef struct PrintSetup_ PrintSetup;
|
||||||
|
typedef struct _XPDialogState XPDialogState;
|
||||||
|
|
||||||
|
HJ08142
|
||||||
|
class MSG_NewsHost;
|
||||||
|
class MSG_HTMLRecipients;
|
||||||
|
|
||||||
|
class nsMsgCompose : public nsIMsgCompose, public MSG_Pane {
|
||||||
|
public:
|
||||||
|
|
||||||
|
nsMsgCompose();
|
||||||
|
virtual ~nsMsgCompose();
|
||||||
|
|
||||||
|
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||||
|
NS_DECL_ISUPPORTS
|
||||||
|
|
||||||
|
/* this is just for testing purpose, must be removed before shipping */
|
||||||
|
NS_IMETHOD Test() {printf("nsMsgCompose: Test Succesfull\n"); return NS_OK;}
|
||||||
|
|
||||||
|
#if 0 //JFD
|
||||||
|
NS_IMETHOD CreateAndInit(/*MWContext* */PRInt32 a_context, /* MWContext* */PRInt32 old_context,
|
||||||
|
/* MSG_Prefs* */PRInt32 prefs, const nsIMsgCompFields* initfields,
|
||||||
|
/* MSG_Master* */PRInt32 master);
|
||||||
|
|
||||||
|
// Or, if you prefer, construct using below constructor and be sure to
|
||||||
|
// soon call the Initialize() method:
|
||||||
|
|
||||||
|
NS_IMETHOD Create(/* MWContext* */PRInt32 a_context, /* MSG_Prefs* */PRInt32 prefs,
|
||||||
|
/* MSG_Master* */PRInt32 master);
|
||||||
|
NS_IMETHOD Initialize(/* MWContext* */PRInt32 old_context, const nsIMsgCompFields* initfields);
|
||||||
|
|
||||||
|
NS_IMETHOD Dispose();
|
||||||
|
|
||||||
|
virtual MSG_PaneType GetPaneType();
|
||||||
|
|
||||||
|
virtual void NotifyPrefsChange(NotifyCode code);
|
||||||
|
|
||||||
|
MSG_CommandType PreviousSaveCommand();
|
||||||
|
|
||||||
|
virtual MsgERR GetCommandStatus(MSG_CommandType command,
|
||||||
|
const MSG_ViewIndex* indices,
|
||||||
|
int32 numindices,
|
||||||
|
XP_Bool *selectable_p,
|
||||||
|
MSG_COMMAND_CHECK_STATE *selected_p,
|
||||||
|
const char **display_string,
|
||||||
|
XP_Bool * plural_p);
|
||||||
|
virtual MsgERR DoCommand(MSG_CommandType command,
|
||||||
|
MSG_ViewIndex* indices, int32 numindices);
|
||||||
|
|
||||||
|
const char* GetDefaultURL();
|
||||||
|
virtual void SetDefaultURL(const char *defaultUrl = NULL,
|
||||||
|
const char *htmlPart = NULL);
|
||||||
|
|
||||||
|
|
||||||
|
int SetCallbacks(MSG_CompositionPaneCallbacks* callbacks, void* closure);
|
||||||
|
|
||||||
|
MSG_CompositionFields* GetInitialFields();
|
||||||
|
|
||||||
|
|
||||||
|
MSG_HEADER_SET GetInterestingHeaders();
|
||||||
|
int SetAttachmentList(struct MSG_AttachmentData*);
|
||||||
|
XP_Bool NoPendingAttachments() const;
|
||||||
|
char* GetAttachmentString();
|
||||||
|
XP_Bool ShouldAutoQuote();
|
||||||
|
const char* GetCompHeader(MSG_HEADER_SET);
|
||||||
|
int SetCompHeader(MSG_HEADER_SET, const char*);
|
||||||
|
XP_Bool GetCompBoolHeader(MSG_BOOL_HEADER_SET);
|
||||||
|
int SetCompBoolHeader(MSG_BOOL_HEADER_SET, XP_Bool);
|
||||||
|
const char* GetCompBody();
|
||||||
|
int SetCompBody(const char*);
|
||||||
|
void ToggleCompositionHeader(uint32 header);
|
||||||
|
XP_Bool ShowingAllCompositionHeaders();
|
||||||
|
XP_Bool ShowingCompositionHeader(uint32 mask);
|
||||||
|
XP_Bool GetHTMLMarkup(void);
|
||||||
|
void SetHTMLMarkup(XP_Bool flag);
|
||||||
|
MsgERR QuoteMessage(int (*func)(void* closure, const char* data),
|
||||||
|
void* closure);
|
||||||
|
int PastePlaintextQuotation(const char* str);
|
||||||
|
const struct MSG_AttachmentData *GetAttachmentList();
|
||||||
|
int DownloadAttachments();
|
||||||
|
char* UpdateHeaderContents(MSG_HEADER_SET which_header, const char* value);
|
||||||
|
const char* GetWindowTitle();
|
||||||
|
void SetBodyEdited(XP_Bool value);
|
||||||
|
void MailCompositionAllConnectionsComplete();
|
||||||
|
void CheckExpansion(MSG_HEADER_SET header);
|
||||||
|
XP_Bool DeliveryInProgress();
|
||||||
|
|
||||||
|
int SendMessageNow();
|
||||||
|
int QueueMessageForLater();
|
||||||
|
int SaveMessage();
|
||||||
|
int SaveMessageAsDraft();
|
||||||
|
int SaveMessageAsTemplate();
|
||||||
|
|
||||||
|
XP_Bool IsDuplicatePost();
|
||||||
|
const char* GetCompositionMessageID();
|
||||||
|
void ClearCompositionMessageID();
|
||||||
|
HJ13591
|
||||||
|
HJ86782
|
||||||
|
HJ02278
|
||||||
|
HJ95534
|
||||||
|
|
||||||
|
int RemoveNoCertRecipients();
|
||||||
|
|
||||||
|
XP_Bool SanityCheckNewsgroups (const char *newsgroups);
|
||||||
|
int SanityCheck(int skippast);
|
||||||
|
|
||||||
|
HJ42055
|
||||||
|
|
||||||
|
/* draft */
|
||||||
|
int SetPreloadedAttachments ( MWContext *context,
|
||||||
|
struct MSG_AttachmentData *attachmentData,
|
||||||
|
struct MSG_AttachedFile *attachments,
|
||||||
|
int attachments_count );
|
||||||
|
|
||||||
|
virtual void SetIMAPMessageUID (MessageKey key);
|
||||||
|
|
||||||
|
int RetrieveStandardHeaders(MSG_HeaderEntry ** return_list);
|
||||||
|
int SetHeaderEntries(MSG_HeaderEntry * in_list,int count);
|
||||||
|
void ClearComposeHeaders();
|
||||||
|
|
||||||
|
HJ37212
|
||||||
|
HJ42256
|
||||||
|
|
||||||
|
int SetHTMLAction(MSG_HTMLComposeAction action) {
|
||||||
|
m_htmlaction = action;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
MSG_HTMLComposeAction GetHTMLAction() {return m_htmlaction;}
|
||||||
|
|
||||||
|
int PutUpRecipientsDialog(void *pWnd = NULL);
|
||||||
|
|
||||||
|
int ResultsRecipients(XP_Bool cancelled, int32* nohtml, int32* htmlok);
|
||||||
|
|
||||||
|
XP_Bool m_confirmed_uuencode_p; // Have we confirmed sending uuencoded data?
|
||||||
|
|
||||||
|
// For qutoing plain text to html then convert back to plain text
|
||||||
|
void SetLineWidth(int width) { m_lineWidth = width; }
|
||||||
|
int GetLineWidth() { return m_lineWidth; }
|
||||||
|
// #$@%&*
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void QuoteHTMLDone_S(URL_Struct* url,
|
||||||
|
int status, MWContext* context);
|
||||||
|
|
||||||
|
void InitializeHeaders(MWContext* old_context,
|
||||||
|
MSG_CompositionFields* fields);
|
||||||
|
|
||||||
|
char* FigureBcc(XP_Bool newsBcc);
|
||||||
|
const char* CheckForLosingFcc(const char* fcc);
|
||||||
|
|
||||||
|
static void GetUrlDone_S(PrintSetup*);
|
||||||
|
void GetUrlDone(PrintSetup*);
|
||||||
|
|
||||||
|
static void DownloadAttachmentsDone_S(MWContext *context,
|
||||||
|
void *fe_data,
|
||||||
|
int status,
|
||||||
|
const char *error_message,
|
||||||
|
struct MSG_AttachedFile *attachmnts);
|
||||||
|
|
||||||
|
void DownloadAttachmentsDone(MWContext* context, int status,
|
||||||
|
const char* error_message,
|
||||||
|
struct MSG_AttachedFile *attachments);
|
||||||
|
|
||||||
|
int DoneComposeMessage(MSG_Deliver_Mode deliver_mode);
|
||||||
|
|
||||||
|
static void DeliveryDoneCB_s(MWContext *context, void *fe_data, int status,
|
||||||
|
const char *error_message);
|
||||||
|
void DeliveryDoneCB(MWContext* context, int status,
|
||||||
|
const char* error_message);
|
||||||
|
|
||||||
|
int RemoveNoCertRecipientsFromList(MSG_HEADER_SET header);
|
||||||
|
|
||||||
|
XP_Bool HasNoMarkup();
|
||||||
|
MSG_HTMLComposeAction DetermineHTMLAction();
|
||||||
|
int MungeThroughRecipients(XP_Bool* someNonHTML, XP_Bool* groupNonHTML);
|
||||||
|
|
||||||
|
static PRBool AskDialogDone_s(XPDialogState *state, char **argv, int argc,
|
||||||
|
unsigned int button);
|
||||||
|
PRBool AskDialogDone(XPDialogState *state, char **argv, int argc,
|
||||||
|
unsigned int button);
|
||||||
|
static PRBool RecipientDialogDone_s(XPDialogState *state, char **argv,
|
||||||
|
int argc, unsigned int button);
|
||||||
|
PRBool RecipientDialogDone(XPDialogState *state, char **argv, int argc,
|
||||||
|
unsigned int button);
|
||||||
|
|
||||||
|
int CreateVcardAttachment ();
|
||||||
|
|
||||||
|
MSG_NewsHost *InferNewsHost (const char *groups);
|
||||||
|
|
||||||
|
MSG_REPLY_TYPE m_replyType; /* The kind of message composition in
|
||||||
|
progress (reply, forward, etc.) */
|
||||||
|
|
||||||
|
XP_Bool m_markup; /* Whether we should generate messages
|
||||||
|
whose first part is text/html rather
|
||||||
|
than text/plain. */
|
||||||
|
|
||||||
|
MSG_AttachmentData *m_attachData; /* null-terminated list of the URLs and
|
||||||
|
desired types currently scheduled
|
||||||
|
for attachment. */
|
||||||
|
MSG_AttachedFile *m_attachedFiles; /* The attachments which have already
|
||||||
|
been downloaded, and some info about
|
||||||
|
them. */
|
||||||
|
|
||||||
|
char *m_defaultUrl; /* Default URL for attaching, etc. */
|
||||||
|
|
||||||
|
MSG_CompositionFields* m_initfields; // What all the fields were,
|
||||||
|
// initially.
|
||||||
|
MSG_CompositionFields* m_fields; // Current value of all the fields.
|
||||||
|
|
||||||
|
char* m_messageId; // Message-Id to use for composition.
|
||||||
|
|
||||||
|
char* m_attachmentString; // Storage for string to display in UI for
|
||||||
|
// the list of attachments.
|
||||||
|
char* m_quotedText; // The results of quoting the original text.
|
||||||
|
|
||||||
|
/* Stuff used while quoting a message. */
|
||||||
|
PrintSetup* m_print;
|
||||||
|
MWContext *m_textContext;
|
||||||
|
MWContext *m_oldContext;
|
||||||
|
char* m_quoteUrl;
|
||||||
|
URL_Struct *m_dummyUrl;
|
||||||
|
Net_GetUrlExitFunc *m_exitQuoting;
|
||||||
|
int (*m_quotefunc)(void* closure, const char* data);
|
||||||
|
void* m_quoteclosure;
|
||||||
|
XP_Bool m_deliveryInProgress; /* True while mail is being sent. */
|
||||||
|
XP_Bool m_attachmentInProgress; /* True while attachments being
|
||||||
|
saved. */
|
||||||
|
int m_pendingAttachmentsCount;
|
||||||
|
|
||||||
|
MSG_Deliver_Mode m_deliver_mode; /* MSG_DelverNow, MSG_QueueForLater,
|
||||||
|
* MSG_SaveAs,
|
||||||
|
* MSG_SaveAsDraft, MSG_SaveAsTemplate
|
||||||
|
*/
|
||||||
|
|
||||||
|
HJ21695
|
||||||
|
|
||||||
|
XP_Bool m_cited;
|
||||||
|
|
||||||
|
XP_Bool m_duplicatePost; /* Whether we seem to be trying for a
|
||||||
|
second time to post the same message.
|
||||||
|
(If this is true, then we know to ignore
|
||||||
|
435 errors from the newsserver.) */
|
||||||
|
|
||||||
|
HJ92535
|
||||||
|
|
||||||
|
MSG_HTMLComposeAction m_htmlaction;
|
||||||
|
MSG_HTMLRecipients* m_htmlrecip;
|
||||||
|
|
||||||
|
int m_status;
|
||||||
|
// I'm sure this isn't what Terry had in mind... // ### dmb
|
||||||
|
MSG_HEADER_SET m_visible_headers;
|
||||||
|
|
||||||
|
MSG_NewsHost* m_host; // Which newshost we're posting to. This is
|
||||||
|
// lazily evaluated, so a NULL does necessarily
|
||||||
|
// mean we have no news host specified.
|
||||||
|
|
||||||
|
XP_Bool m_closeAfterSave;
|
||||||
|
|
||||||
|
XP_Bool m_haveQuoted;
|
||||||
|
XP_Bool m_haveAttachedVcard;
|
||||||
|
|
||||||
|
MSG_CompositionPaneCallbacks m_callbacks;
|
||||||
|
void* m_callbackclosure;
|
||||||
|
int m_lineWidth; // for quoting plain text to html then convert back
|
||||||
|
// to plain text
|
||||||
|
#endif 0 //JFD
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* _MsgCompose_H_ */
|
Loading…
Reference in New Issue
Block a user