Back to index

lightning-sunbird  0.9+nobinonly
nsMsgCompFields.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 
00038 #ifndef _MsgCompFields_H_
00039 #define _MsgCompFields_H_
00040 
00041 #include "nsIMsgCompFields.h"
00042 #include "msgCore.h"
00043 
00044 
00045 /* Note that all the "Get" methods never return NULL (except in case of serious
00046    error, like an illegal parameter); rather, they return "" if things were set
00047    to NULL.  This makes it real handy for the callers. */
00048 
00049 class nsMsgCompFields : public nsIMsgCompFields {
00050 public:
00051   nsMsgCompFields();
00052   virtual ~nsMsgCompFields();
00053 
00054   /* this macro defines QueryInterface, AddRef and Release for this class */
00055   NS_DECL_ISUPPORTS
00056   NS_DECL_NSIMSGCOMPFIELDS
00057 
00058   typedef enum MsgHeaderID
00059   {
00060     MSG_FROM_HEADER_ID        = 0,
00061     MSG_REPLY_TO_HEADER_ID,
00062     MSG_TO_HEADER_ID,
00063     MSG_CC_HEADER_ID,
00064     MSG_BCC_HEADER_ID,
00065     MSG_FCC_HEADER_ID,
00066     MSG_FCC2_HEADER_ID,
00067     MSG_NEWSGROUPS_HEADER_ID,
00068     MSG_FOLLOWUP_TO_HEADER_ID,
00069     MSG_SUBJECT_HEADER_ID,
00070     MSG_ATTACHMENTS_HEADER_ID,
00071     MSG_ORGANIZATION_HEADER_ID,
00072     MSG_REFERENCES_HEADER_ID,
00073     MSG_OTHERRANDOMHEADERS_HEADER_ID,
00074     MSG_NEWSPOSTURL_HEADER_ID,
00075     MSG_PRIORITY_HEADER_ID,
00076     MSG_CHARACTER_SET_HEADER_ID,
00077     MSG_MESSAGE_ID_HEADER_ID,
00078     MSG_X_TEMPLATE_HEADER_ID,
00079     MSG_DRAFT_ID_HEADER_ID,
00080   MSG_TEMPORARY_FILES_HEADER_ID,
00081     
00082     MSG_MAX_HEADERS   //Must be the last one.
00083   } MsgHeaderID;
00084 
00085   nsresult SetAsciiHeader(MsgHeaderID header, const char *value);
00086   const char* GetAsciiHeader(MsgHeaderID header); //just return the address of the internal header variable, don't dispose it
00087 
00088   nsresult SetUnicodeHeader(MsgHeaderID header, const nsAString &value);
00089   nsresult GetUnicodeHeader(MsgHeaderID header, nsAString &_retval); 
00090 
00091   /* Convenience routines to get and set header's value...
00092   
00093     IMPORTANT:
00094     all routines const char* GetXxx(void) will return a pointer to the header, please don't free it.
00095   */
00096 
00097   nsresult SetFrom(const char *value) {return SetAsciiHeader(MSG_FROM_HEADER_ID, value);}
00098   const char* GetFrom(void) {return GetAsciiHeader(MSG_FROM_HEADER_ID);}
00099 
00100   nsresult SetReplyTo(const char *value) {return SetAsciiHeader(MSG_REPLY_TO_HEADER_ID, value);}
00101   const char* GetReplyTo() {return GetAsciiHeader(MSG_REPLY_TO_HEADER_ID);}
00102 
00103   nsresult SetTo(const char *value) {return SetAsciiHeader(MSG_TO_HEADER_ID, value);}
00104   const char* GetTo() {return GetAsciiHeader(MSG_TO_HEADER_ID);}
00105 
00106   nsresult SetCc(const char *value) {return SetAsciiHeader(MSG_CC_HEADER_ID, value);}
00107   const char* GetCc() {return GetAsciiHeader(MSG_CC_HEADER_ID);}
00108 
00109   nsresult SetBcc(const char *value) {return SetAsciiHeader(MSG_BCC_HEADER_ID, value);}
00110   const char* GetBcc() {return GetAsciiHeader(MSG_BCC_HEADER_ID);}
00111 
00112   nsresult SetFcc(const char *value) {return SetAsciiHeader(MSG_FCC_HEADER_ID, value);}
00113   const char* GetFcc() {return GetAsciiHeader(MSG_FCC_HEADER_ID);}
00114 
00115   nsresult SetFcc2(const char *value) {return SetAsciiHeader(MSG_FCC2_HEADER_ID, value);}
00116   const char* GetFcc2() {return GetAsciiHeader(MSG_FCC2_HEADER_ID);}
00117 
00118   nsresult SetNewsgroups(const char *aValue) {return SetAsciiHeader(MSG_NEWSGROUPS_HEADER_ID, aValue);}
00119   const char* GetNewsgroups() {return GetAsciiHeader(MSG_NEWSGROUPS_HEADER_ID);}
00120 
00121   const char* GetNewshost() {return GetAsciiHeader(MSG_NEWSPOSTURL_HEADER_ID);}
00122 
00123   const char* GetFollowupTo() {return GetAsciiHeader(MSG_FOLLOWUP_TO_HEADER_ID);}
00124 
00125   nsresult SetSubject(const char *value) {return SetAsciiHeader(MSG_SUBJECT_HEADER_ID, value);}
00126   const char* GetSubject() {return GetAsciiHeader(MSG_SUBJECT_HEADER_ID);}
00127 
00128   const char* GetAttachments() {
00129     NS_ASSERTION(0, "nsMsgCompFields::GetAttachments is not supported anymore, please use nsMsgCompFields::GetAttachmentsArray");
00130     return GetAsciiHeader(MSG_ATTACHMENTS_HEADER_ID);
00131     }
00132 
00133   const char* GetTemporaryFiles() {
00134     NS_ASSERTION(0, "nsMsgCompFields::GetTemporaryFiles is not supported anymore, please use nsMsgCompFields::GetAttachmentsArray");
00135     return GetAsciiHeader(MSG_TEMPORARY_FILES_HEADER_ID);
00136     }
00137 
00138   nsresult SetOrganization(const char *value) {return SetAsciiHeader(MSG_ORGANIZATION_HEADER_ID, value);}
00139   const char* GetOrganization() {return GetAsciiHeader(MSG_ORGANIZATION_HEADER_ID);}
00140 
00141   const char* GetReferences() {return GetAsciiHeader(MSG_REFERENCES_HEADER_ID);}
00142 
00143   nsresult SetOtherRandomHeaders(const char *value) {return SetAsciiHeader(MSG_OTHERRANDOMHEADERS_HEADER_ID, value);}
00144   const char* GetOtherRandomHeaders() {return GetAsciiHeader(MSG_OTHERRANDOMHEADERS_HEADER_ID);}
00145 
00146   const char* GetNewspostUrl() {return GetAsciiHeader(MSG_NEWSPOSTURL_HEADER_ID);}
00147 
00148   const char* GetPriority() {return GetAsciiHeader(MSG_PRIORITY_HEADER_ID);}
00149 
00150   const char* GetCharacterSet() {return GetAsciiHeader(MSG_CHARACTER_SET_HEADER_ID);}
00151 
00152   const char* GetMessageId() {return GetAsciiHeader(MSG_MESSAGE_ID_HEADER_ID);}
00153 
00154   nsresult SetTemplateName(const char *value) {return SetAsciiHeader(MSG_X_TEMPLATE_HEADER_ID, value);}
00155   const char* GetTemplateName() {return GetAsciiHeader(MSG_X_TEMPLATE_HEADER_ID);}
00156 
00157   const char* GetDraftId() {return GetAsciiHeader(MSG_DRAFT_ID_HEADER_ID);}
00158 
00159   PRBool GetReturnReceipt() {return m_returnReceipt;}
00160   PRBool GetAttachVCard() {return m_attachVCard;}
00161   PRBool GetForcePlainText() {return m_forcePlainText;}
00162   PRBool GetUseMultipartAlternative() {return m_useMultipartAlternative;}
00163   PRBool GetUuEncodeAttachments() {return m_uuEncodeAttachments;}
00164   PRBool GetBodyIsAsciiOnly() {return m_bodyIsAsciiOnly;}
00165   PRBool GetForceMsgEncoding() {return m_forceMsgEncoding;}
00166 
00167   nsresult SetBody(const char *value);
00168   const char* GetBody();
00169 
00170   nsresult SplitRecipientsEx(const PRUnichar *recipients, nsIMsgRecipientArray ** fullAddrsArray, nsIMsgRecipientArray ** emailsArray); 
00171 
00172 protected:
00173   char*       m_headers[MSG_MAX_HEADERS];
00174   nsCString   m_body;
00175   nsCOMPtr<nsISupportsArray>  m_attachments;
00176   PRBool      m_attachVCard;
00177   PRBool      m_forcePlainText;
00178   PRBool      m_useMultipartAlternative;
00179   PRBool      m_uuEncodeAttachments;
00180   PRBool      m_returnReceipt;
00181   PRBool      m_bodyIsAsciiOnly;
00182   PRBool      m_forceMsgEncoding;
00183   PRInt32     m_receiptHeaderType;        /* receipt header type */
00184   nsCString   m_DefaultCharacterSet;
00185   PRBool      m_needToCheckCharset;
00186 
00187   nsCOMPtr<nsISupports> mSecureCompFields;
00188 };
00189 
00190 
00191 #endif /* _MsgCompFields_H_ */