Back to index

lightning-sunbird  0.9+nobinonly
nsEudoraMailbox.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is mozilla.org Code.
00017  *
00018  * The Initial Developer of the Original Code is
00019  * Netscape Communications Corporation.
00020  * Portions created by the Initial Developer are Copyright (C) 1998
00021  * the Initial Developer. All Rights Reserved.
00022  *
00023  * Contributor(s):
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either of the GNU General Public License Version 2 or later (the "GPL"),
00027  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #ifndef nsEudoraMailbox_h__
00040 #define nsEudoraMailbox_h__
00041 
00042 #include "nscore.h"
00043 #include "nsString.h"
00044 #include "nsVoidArray.h"
00045 #include "nsIFileSpec.h"
00046 #include "nsISupportsArray.h"
00047 #include "nsEudoraCompose.h"
00048 
00049 
00053 
00054 class nsEudoraMailbox {
00055 public:
00056        nsEudoraMailbox();
00057        virtual ~nsEudoraMailbox();
00058 
00059        // Things that must be overridden because they are platform specific.
00060               // retrieve the mail folder
00061        virtual PRBool              FindMailFolder( nsIFileSpec *pFolder) { return( PR_FALSE);}
00062               // get the list of mailboxes
00063        virtual nsresult     FindMailboxes( nsIFileSpec *pRoot, nsISupportsArray **ppArray) { return( NS_ERROR_FAILURE);}
00064               // get the toc file corresponding to this mailbox
00065        virtual nsresult     FindTOCFile( nsIFileSpec *pMailFile, nsIFileSpec **pTOCFile, PRBool *pDeleteToc) { return( NS_ERROR_FAILURE);}
00066               // interpret the attachment line and return the attached file
00067        virtual nsresult     GetAttachmentInfo( const char *pFileName, nsIFileSpec *pSpec, nsCString& mimeType, nsCString& aAttachment) { return( NS_ERROR_FAILURE);}
00068               
00069        // Non-platform specific common stuff
00070               // import a mailbox
00071        nsresult ImportMailbox( PRUint32 *pBytes, PRBool *pAbort, const PRUnichar *pName, nsIFileSpec *pSrc, nsIFileSpec *pDst, PRInt32 *pMsgCount);
00072 
00073        static PRInt32              IsEudoraFromSeparator( const char *pData, PRInt32 maxLen, nsCString& defaultDate);
00074        static PRBool        IsEudoraTag( const char *pChar, PRInt32 maxLen, PRBool &insideEudoraTags, nsCString &bodyType, PRInt32& tagLength);
00075 
00076 protected:
00077        nsresult      CreateTempFile( nsIFileSpec **ppSpec);
00078        nsresult      DeleteFile( nsIFileSpec *pSpec);
00079 
00080 
00081 private:
00082        nsresult      CompactMailbox( PRUint32 *pBytes, PRBool *pAbort, nsIFileSpec *pMail, nsIFileSpec *pToc, nsIFileSpec *pDst);
00083        nsresult      ReadNextMessage( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& copy, SimpleBufferTonyRCopiedOnce& header, SimpleBufferTonyRCopiedOnce& body, nsCString& defaultDate, nsCString &defBodyType);
00084        PRInt32              FindStartLine( SimpleBufferTonyRCopiedOnce& data);
00085        PRInt32              FindNextEndLine( SimpleBufferTonyRCopiedOnce& data);
00086        PRInt32              IsEndHeaders( SimpleBufferTonyRCopiedOnce& data);
00087        nsresult      WriteFromSep( nsIFileSpec *pDst);
00088        nsresult      FillMailBuffer( ReadFileState *pState, SimpleBufferTonyRCopiedOnce& read);
00089        
00090        void          EmptyAttachments( void);
00091        nsresult      ExamineAttachment( SimpleBufferTonyRCopiedOnce& data);
00092        PRBool        AddAttachment( nsCString& fileName);
00093 
00094        static PRInt32              AsciiToLong( const char *pChar, PRInt32 len);
00095        static int                  IsWeekDayStr( const char *pStr);
00096        static int                  IsMonthStr( const char *pStr);
00097 
00098 private:
00099        PRUint32             m_mailSize;
00100        PRInt32                     m_fromLen;
00101        nsVoidArray          m_attachments;
00102 };
00103 
00104 
00105 
00106 #endif /* nsEudoraMailbox_h__ */
00107