Back to index

lightning-sunbird  0.9+nobinonly
nsEudoraWin32.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 nsEudoraWin32_h__
00040 #define nsEudoraWin32_h__
00041 
00042 #include "nscore.h"
00043 #include "nsString.h"
00044 #include "nsIFileSpec.h"
00045 #include "nsISupportsArray.h"
00046 #include "nsEudoraMailbox.h"
00047 #include "nsEudoraAddress.h"
00048 
00049 #include <windows.h>
00050 
00051 class nsIImportService;
00052 class nsIMsgAccountManager;
00053 class nsIMsgAccount;
00054 
00055 
00056 class nsEudoraWin32 : public nsEudoraMailbox, public nsEudoraAddress {
00057 public:
00058        nsEudoraWin32();
00059        ~nsEudoraWin32();
00060 
00061               // retrieve the mail folder
00062        virtual PRBool              FindMailFolder( nsIFileSpec *pFolder);
00063               // get the list of mailboxes
00064        virtual nsresult     FindMailboxes( nsIFileSpec *pRoot, nsISupportsArray **ppArray);
00065               // get a TOC file from a mailbox file
00066        virtual nsresult     FindTOCFile( nsIFileSpec *pMailFile, nsIFileSpec **pTOCFile, PRBool *pDeleteToc);
00067 
00068        virtual nsresult     GetAttachmentInfo( const char *pFileName, nsIFileSpec *pSpec, nsCString& mimeType, nsCString& aAttachment);
00069 
00070        // Things that must be overridden because they are platform specific.
00071               // retrieve the address book folder
00072        virtual PRBool              FindAddressFolder( nsIFileSpec *pFolder);
00073               // get the list of address books
00074        virtual nsresult     FindAddressBooks( nsIFileSpec *pRoot, nsISupportsArray **ppArray);
00075 
00076               // import settings from Win32 ini file
00077        static PRBool ImportSettings( nsIFileSpec *pIniFile, nsIMsgAccount **localMailAccount);
00078        static PRBool FindSettingsFile( nsIFileSpec *pIniFile) { return( FindEudoraLocation( pIniFile, PR_TRUE));}
00079 
00080 private:
00081        nsresult      ScanMailDir( nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport);
00082        nsresult      IterateMailDir( nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport);
00083        nsresult      ScanDescmap( nsIFileSpec *pFolder, nsISupportsArray *pArray, nsIImportService *pImport, const char *pData, PRInt32 len);
00084        nsresult      FoundMailFolder( nsIFileSpec *mailFolder, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport);
00085        nsresult      FoundMailbox( nsIFileSpec *mailFile, const char *pName, nsISupportsArray *pArray, nsIImportService *pImport);
00086        PRBool        FindMimeIniFile( nsIFileSpec *pSpec);
00087        void          GetMimeTypeFromExtension( nsCString& ext, nsCString& mimeType);
00088        nsresult      FoundAddressBook( nsIFileSpec *spec, const PRUnichar *pName, nsISupportsArray *pArray, nsIImportService *impSvc);
00089        nsresult      ScanAddressDir( nsIFileSpec *pDir, nsISupportsArray *pArray, nsIImportService *impSvc);
00090 
00091 
00092        static PRBool        FindEudoraLocation( nsIFileSpec *pFolder, PRBool findIni = PR_FALSE);
00093 
00094               // Settings support
00095        static PRBool BuildPOPAccount( nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount);
00096        static PRBool BuildIMAPAccount( nsIMsgAccountManager *accMgr, const char *pSection, const char *pIni, nsIMsgAccount **ppAccount);
00097        static void          GetServerAndUserName( const char *pSection, const char *pIni, nsCString& serverName, nsCString& userName, char *pBuff);
00098        static void          GetAccountName( const char *pSection, nsString& str);
00099        static void          SetIdentities( nsIMsgAccountManager *accMgr, nsIMsgAccount *acc, const char *pSection, const char *pIniFile, const char *userName, const char *serverName, char *pBuff);
00100        static void          SetSmtpServer( nsIMsgAccountManager *pMgr, nsIMsgAccount *pAcc, const char *pServer, const char *pUser);
00101 
00102 
00103 
00104        static BYTE * GetValueBytes( HKEY hKey, const char *pValueName);
00105        static void          ConvertPath( nsCString& str);
00106 
00107 private:
00108        PRUint32             m_depth;
00109        nsIFileSpec * m_mailImportLocation;
00110        nsIFileSpec * m_addressImportFolder;
00111        char *               m_pMimeSection;
00112 };
00113 
00114 
00115 #endif /* nsEudoraWin32_h__ */
00116