Back to index

lightning-sunbird  0.9+nobinonly
nsMsgCompUtils.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 _nsMsgCompUtils_H_
00039 #define _nsMsgCompUtils_H_
00040 
00041 #include "nscore.h"
00042 #include "nsMsgSend.h"
00043 #include "nsFileSpec.h"
00044 #include "nsMsgCompFields.h"
00045 #include "nsIMsgSend.h"
00046 #include "nsIMsgCompUtils.h"
00047 
00048 class nsIPrompt; 
00049 
00050 #define ANY_SERVER "anyfolder://"
00051 
00052 // these are msg hdr property names for storing the original
00053 // msg uri's and disposition(replied/forwarded) when queuing
00054 // messages to send later.
00055 #define ORIG_URI_PROPERTY "origURIs"
00056 #define QUEUED_DISPOSITION_PROPERTY "queuedDisposition"
00057 
00058 class nsMsgCompUtils : public nsIMsgCompUtils
00059 {
00060 public:
00061   NS_DECL_ISUPPORTS
00062   NS_DECL_NSIMSGCOMPUTILS
00063 
00064   nsMsgCompUtils();
00065   virtual ~nsMsgCompUtils();
00066 };
00067 
00068 PR_BEGIN_EXTERN_C
00069 
00070 //
00071 // Create a file spec or file name using the name passed
00072 // in as a template
00073 //
00074 nsFileSpec  *nsMsgCreateTempFileSpec(const char *tFileName);
00075 char        *nsMsgCreateTempFileName(const char *tFileName);
00076 
00077 
00078 //
00079 // Various utilities for building parts of MIME encoded 
00080 // messages during message composition
00081 //
00082 nsresult    mime_sanity_check_fields (
00083                             const char *from,
00084                             const char *reply_to,
00085                             const char *to,
00086                             const char *cc,
00087                             const char *bcc,
00088                             const char *fcc,
00089                             const char *newsgroups,
00090                             const char *followup_to,
00091                             const char * /*subject*/,
00092                             const char * /*references*/,
00093                             const char * /*organization*/,
00094                             const char * /*other_random_headers*/);
00095 
00096 char        *mime_generate_headers (nsMsgCompFields *fields,
00097                                     const char *charset,
00098                                     nsMsgDeliverMode deliver_mode, nsIPrompt * aPrompt, PRInt32 *status);
00099 
00100 char        *mime_make_separator(const char *prefix);
00101 char        *mime_gen_content_id(PRUint32 aPartNum, const char *aEmailAddress);
00102 
00103 char        *mime_generate_attachment_headers (
00104                            const char *type,
00105                            const char *type_param,
00106                            const char *encoding,
00107                            const char *description,
00108                            const char *x_mac_type,
00109                            const char *x_mac_creator,
00110                            const char *real_name,
00111                            const char *base_url,
00112                            PRBool digest_p,
00113                            nsMsgAttachmentHandler *ma,
00114                            const char *attachmentCharset, // charset of the attachment (can be null)
00115                            const char *bodyCharset,       // charset of the main body
00116                            PRBool bodyIsAsciiOnly,
00117                            const char *content_id,
00118                            PRBool     aBodyDocument);
00119 
00120 char        *msg_generate_message_id (nsIMsgIdentity*);
00121 
00122 PRBool      mime_7bit_data_p (const char *string, PRUint32 size);
00123 
00124 char        *mime_fix_header_1 (const char *string, PRBool addr_p, PRBool news_p);
00125 char        *mime_fix_header (const char *string);
00126 char        *mime_fix_addr_header (const char *string);
00127 char        *mime_fix_news_header (const char *string);
00128 
00129 PRBool      mime_type_requires_b64_p (const char *type);
00130 PRBool      mime_type_needs_charset (const char *type);
00131 
00132 char        *msg_make_filename_qtext(const char *srcText, PRBool stripCRLFs);
00133 
00134 // Rip apart the URL and extract a reasonable value for the `real_name' slot.
00135 void        msg_pick_real_name (nsMsgAttachmentHandler *attachment, const PRUnichar *proposedName, const char *charset);
00136 
00137 //
00138 // Informational calls...
00139 //
00140 void        nsMsgMIMESetConformToStandard (PRBool conform_p);
00141 PRBool      nsMsgMIMEGetConformToStandard (void);
00142 
00143 //
00144 // network service type calls...
00145 //
00146 nsresult    nsMsgNewURL(nsIURI** aInstancePtrResult, const char * aSpec);
00147 PRBool      nsMsgIsLocalFile(const char *url);
00148 char        *nsMsgGetLocalFileFromURL(const char *url);
00149 char        *nsMsgPlatformFileToURL (nsFileSpec aFileSpec);
00150 
00151 char        *nsMsgParseURLHost(const char *url);
00152 
00153 char        *GenerateFileNameFromURI(nsIURI *aURL);
00154 
00155 char        *nsMsgParseSubjectFromFile(nsFileSpec* fileSpec); 
00156 
00157 //
00158 // Folder calls...
00159 //
00160 char        *GetFolderURIFromUserPrefs(nsMsgDeliverMode   aMode,
00161                                        nsIMsgIdentity *identity);
00162                                        
00163 // File calls...
00164 nsresult ConvertBufToPlainText(nsString &aConBuf, PRBool formatflowed = PR_FALSE);
00165 
00166 // Check if we should use format=flowed 
00167 PRBool UseFormatFlowed(const char *charset);
00168 
00169 
00170 PR_END_EXTERN_C
00171 
00172 
00173 #endif /* _nsMsgCompUtils_H_ */
00174