Back to index

lightning-sunbird  0.9+nobinonly
nsMsgThreadedDBView.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) 2001
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 _nsMsgThreadedDBView_H_
00039 #define _nsMsgThreadedDBView_H_
00040 
00041 #include "nsMsgDBView.h"
00042 
00043 // this class should probably inherit from the class that
00044 // implements the tree. Since I don't know what that is yet,
00045 // I'll just make it inherit from nsMsgDBView for now.
00046 class nsMsgThreadedDBView : public nsMsgDBView
00047 {
00048 public:
00049   nsMsgThreadedDBView();
00050   virtual ~nsMsgThreadedDBView();
00051 
00052   NS_IMETHOD Open(nsIMsgFolder *folder, nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder, nsMsgViewFlagsTypeValue viewFlags, PRInt32 *pCount);
00053   NS_IMETHOD CloneDBView(nsIMessenger *aMessengerInstance, nsIMsgWindow *aMsgWindow, nsIMsgDBViewCommandUpdater *aCommandUpdater, nsIMsgDBView **_retval);
00054   NS_IMETHOD Close();
00055   virtual nsresult AddKeys(nsMsgKey *pKeys, PRInt32 *pFlags, const char *pLevels, nsMsgViewSortTypeValue sortType, PRInt32 numKeysToAdd);
00056   NS_IMETHOD Sort(nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder);
00057   NS_IMETHOD GetViewType(nsMsgViewTypeValue *aViewType);
00058   NS_IMETHOD GetSupportsThreading(PRBool *aResult);
00059 
00060   NS_IMETHOD OnParentChanged (nsMsgKey aKeyChanged, nsMsgKey oldParent, nsMsgKey newParent, nsIDBChangeListener *aInstigator);
00061 
00062 protected:
00063   virtual const char * GetViewName(void) {return "ThreadedDBView"; }
00064   nsresult InitThreadedView(PRInt32 *pCount);
00065   virtual nsresult OnNewHeader(nsIMsgDBHdr *newHdr, nsMsgKey aParentKey, PRBool ensureListed);
00066   virtual nsresult AddMsgToThreadNotInView(nsIMsgThread *threadHdr, nsIMsgDBHdr *msgHdr, PRBool ensureListed);
00067   nsresult ListThreadIds(nsMsgKey *startMsg, PRBool unreadOnly, nsMsgKey *pOutput, PRInt32 *pFlags, char *pLevels, 
00068                         PRInt32 numToList, PRInt32 *pNumListed, PRInt32 *pTotalHeaders);
00069   nsresult InitSort(nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder);
00070   virtual nsresult SortThreads(nsMsgViewSortTypeValue sortType, nsMsgViewSortOrderValue sortOrder);
00071   virtual void  OnExtraFlagChanged(nsMsgViewIndex index, PRUint32 extraFlag);
00072   virtual void OnHeaderAddedOrDeleted();
00073   void    ClearPrevIdArray();
00074   virtual nsresult RemoveByIndex(nsMsgViewIndex index);
00075   nsMsgViewIndex GetInsertInfoForNewHdr(nsIMsgDBHdr *newHdr, nsMsgViewIndex threadIndex, PRInt32 targetLevel);
00076 
00077   // these are used to save off the previous view so that bopping back and forth
00078   // between two views is quick (e.g., threaded and flat sorted by date).
00079   PRBool          m_havePrevView;
00080   nsMsgKeyArray   m_prevKeys;   //this is used for caching non-threaded view.
00081   nsUInt32Array   m_prevFlags;
00082   nsUint8Array    m_prevLevels;
00083   nsCOMPtr <nsISimpleEnumerator> m_threadEnumerator;
00084 };
00085 
00086 #endif