Back to index

lightning-sunbird  0.9+nobinonly
nsDBFolderInfo.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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) 1999
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 /* This class encapsulates the global information about a folder stored in the
00039        summary file.
00040 */
00041 #ifndef _nsDBFolderInfo_H
00042 #define _nsDBFolderInfo_H
00043 
00044 #include "nsString.h"
00045 #include "MailNewsTypes.h"
00046 #include "mdb.h"
00047 #include "nsMsgKeyArray.h"
00048 #include "nsIDBFolderInfo.h"
00049 #include <time.h>
00050 
00051 class nsMsgDatabase;
00052 
00053 // again, this could inherit from nsISupports, but I don't see the need as of yet.
00054 // I'm not sure it needs to be ref-counted (but I think it does).
00055 
00056 // I think these getters and setters really need to go through mdb and not rely on the object
00057 // caching the values. If this somehow turns out to be prohibitively expensive, we can invent
00058 // some sort of dirty mechanism, but I think it turns out that these values will be cached by 
00059 // the MSG_FolderInfo's anyway.
00060 class nsDBFolderInfo : public nsIDBFolderInfo
00061 {
00062 public:
00063   friend class nsMsgDatabase;
00064   
00065   nsDBFolderInfo(nsMsgDatabase *mdb);
00066   virtual ~nsDBFolderInfo();
00067   
00068   NS_DECL_ISUPPORTS
00069     // interface methods.
00070     NS_DECL_NSIDBFOLDERINFO
00071     // create the appropriate table and row in a new db.
00072     nsresult                AddToNewMDB();
00073   // accessor methods.
00074   
00075   PRBool    TestFlag(PRInt32 flags);
00076   PRInt16   GetIMAPHierarchySeparator() ;
00077   void      SetIMAPHierarchySeparator(PRInt16 hierarchySeparator) ;
00078   void      ChangeImapTotalPendingMessages(PRInt32 delta);
00079   void      ChangeImapUnreadPendingMessages(PRInt32 delta) ;
00080   
00081   nsresult      InitFromExistingDB();
00082   // get and set arbitrary property, aka row cell value.
00083   nsresult    SetPropertyWithToken(mdb_token aProperty, const nsAString &propertyStr);
00084   nsresult    SetUint32PropertyWithToken(mdb_token aProperty, PRUint32 propertyValue);
00085   nsresult    SetInt32PropertyWithToken(mdb_token aProperty, PRInt32 propertyValue);
00086   nsresult    GetPropertyWithToken(mdb_token aProperty, nsAString &resultProperty);
00087   nsresult    GetUint32PropertyWithToken(mdb_token aProperty, PRUint32 &propertyValue, PRUint32 defaultValue = 0);
00088   nsresult    GetInt32PropertyWithToken(mdb_token aProperty, PRInt32 &propertyValue, PRInt32 defaultValue = 0);
00089   nsresult      GetConstCharPtrCharacterSet(const char**result);
00090   
00091   
00092   nsMsgKeyArray m_lateredKeys;            // list of latered messages
00093   
00094 protected:
00095   
00096   // initialize from appropriate table and row in existing db.
00097   nsresult InitMDBInfo();
00098   nsresult LoadMemberVariables();
00099   
00100   void ReleaseExternalReferences(); // let go of any references to other objects.
00101   
00102   PRInt32   m_folderSize;
00103   PRInt32   m_expungedBytes;       // sum of size of deleted messages in folder
00104   PRUint32  m_folderDate;
00105   nsMsgKey  m_highWaterMessageKey; // largest news article number or imap uid whose header we've seen
00106   
00107   //  m_numUnreadMessages and m_numMessages can never be negative. 0 means 'no msgs'.
00108   PRInt32   m_numUnreadMessages;
00109   PRInt32   m_numMessages;    // includes expunged and ignored messages
00110   
00111   PRInt32   m_flags;  // folder specific flags. This holds things like re-use thread pane,
00112   // configured for off-line use, use default retrieval, purge article/header options
00113   
00114   PRUint16    m_version;                // for upgrading...
00115   PRInt16     m_IMAPHierarchySeparator;   // imap path separator
00116   
00117   // mail only (for now)
00118   
00119   // IMAP only
00120   PRInt32     m_ImapUidValidity;
00121   PRInt32     m_totalPendingMessages;
00122   PRInt32     m_unreadPendingMessages;
00123   
00124   // news only (for now)
00125   nsMsgKey    m_expiredMark;              // Highest invalid article number in group - for expiring
00126   // the db folder info will have to know what db and row it belongs to, since it is really
00127   // just a wrapper around the singleton folder info row in the mdb. 
00128   nsMsgDatabase *m_mdb;
00129   nsIMdbTable   *m_mdbTable;       // singleton table in db
00130   nsIMdbRow     *m_mdbRow;  // singleton row in table;
00131   
00132   nsCString     m_charSet;
00133   PRBool        m_charSetOverride;
00134   PRBool        m_mdbTokensInitialized;
00135   
00136   mdb_token     m_rowScopeToken;
00137   mdb_token     m_tableKindToken;
00138   // tokens for the pre-set columns - we cache these for speed, which may be silly
00139   mdb_token     m_mailboxNameColumnToken;
00140   mdb_token     m_numMessagesColumnToken;
00141   mdb_token     m_numUnreadMessagesColumnToken;
00142   mdb_token     m_flagsColumnToken;
00143   mdb_token     m_folderSizeColumnToken;
00144   mdb_token     m_expungedBytesColumnToken;
00145   mdb_token     m_folderDateColumnToken;
00146   mdb_token     m_highWaterMessageKeyColumnToken;
00147   
00148   mdb_token     m_imapUidValidityColumnToken;
00149   mdb_token     m_totalPendingMessagesColumnToken;
00150   mdb_token     m_unreadPendingMessagesColumnToken;
00151   mdb_token     m_expiredMarkColumnToken;
00152   mdb_token     m_versionColumnToken;
00153 };
00154 
00155 #endif