Back to index

lightning-sunbird  0.9+nobinonly
nsEudoraAddress.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 nsEudoraAddress_h__
00040 #define nsEudoraAddress_h__
00041 
00042 #include "nscore.h"
00043 #include "nsString.h"
00044 #include "nsVoidArray.h"
00045 #include "nsIFileSpec.h"
00046 #include "nsISupportsArray.h"
00047 #include "nsCOMPtr.h"
00048 #include "nsIImportService.h"
00049 
00050 
00051 class nsIAddrDatabase;
00052 class CAliasEntry;
00053 class CAliasData;
00054 
00055 
00059 
00060 class nsEudoraAddress {
00061 public:
00062        nsEudoraAddress();
00063        virtual ~nsEudoraAddress();
00064 
00065        // Things that must be overridden because they are platform specific.
00066               // retrieve the mail folder
00067        virtual PRBool              FindAddressFolder( nsIFileSpec *pFolder) { return( PR_FALSE);}
00068               // get the list of mailboxes
00069        virtual nsresult     FindAddressBooks( nsIFileSpec *pRoot, nsISupportsArray **ppArray) { return( NS_ERROR_FAILURE);}
00070               
00071        // Non-platform specific common stuff
00072               // import a mailbox
00073        nsresult ImportAddresses( PRUint32 *pBytes, PRBool *pAbort, const PRUnichar *pName, nsIFileSpec *pSrc, nsIAddrDatabase *pDb, nsString& errors);
00074 
00075 
00076 private:
00077        void                 EmptyAliases( void);
00078        void                 ProcessLine( const char *pLine, PRInt32 len, nsString& errors);
00079        PRInt32              CountWhiteSpace( const char *pLine, PRInt32 len);
00080        CAliasEntry   *      ProcessAlias( const char *pLine, PRInt32 len, nsString& errors);
00081        void                 ProcessNote( const char *pLine, PRInt32 len, nsString& errors);
00082        PRInt32                     GetAliasName( const char *pLine, PRInt32 len, nsCString& name);
00083        CAliasEntry * ResolveAlias( nsCString& name);
00084        void                 ResolveEntries( nsCString& name, nsVoidArray& list, nsVoidArray& result);
00085        void                 BuildABCards( PRUint32 *pBytes, nsIAddrDatabase *pDb);
00086        void                 AddSingleCard( CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb);
00087   nsresult  AddSingleList( CAliasEntry *pEntry, nsVoidArray &emailList, nsIAddrDatabase *pDb);
00088   nsresult  AddGroupMembersAsCards(nsVoidArray &membersArray, nsIAddrDatabase *pDb);
00089   void      RememberGroupMembers(nsVoidArray &membersArray, nsVoidArray &emailList);
00090        PRInt32                     FindAlias( nsCString& name);
00091        void                 ExtractNoteField( nsCString& note, nsCString& field, const char *pFieldName);
00092        void                 SanitizeValue( nsCString& val);
00093        void                 SplitString( nsCString& val1, nsCString& val2);
00094 
00095 public:
00096        static PRInt32              CountQuote( const char *pLine, PRInt32 len);
00097        static PRInt32              CountComment( const char *pLine, PRInt32 len);
00098        static PRInt32              CountAngle( const char *pLine, PRInt32 len);
00099 
00100 private:
00101        nsVoidArray          m_alias;
00102 };
00103 
00104 
00105 
00106 #endif /* nsEudoraAddress_h__ */
00107