Back to index

lightning-sunbird  0.9+nobinonly
nsNNTPNewsgroupList.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) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Seth Spitzer <sspitzer@netscape.com>
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  * formerly listngst.h
00040  * This class should ultimately be part of a news group listing
00041  * state machine - either by inheritance or delegation.
00042  * Currently, a folder pane owns one and libnet news group listing
00043  * related messages get passed to this object.
00044  */
00045 #ifndef nsNNTPNewsgroupListState_h___
00046 #define nsNNTPNewsgroupListState_h___
00047 
00048 #include "nsINNTPNewsgroupList.h"
00049 #include "nsIMsgNewsFolder.h"
00050 #include "nsIMsgDatabase.h"
00051 #include "nsMsgKeySet.h"
00052 #include "nsINntpUrl.h"
00053 #include "nsIMsgFilterList.h"
00054 #include "nsIMsgHdr.h"
00055 #include "nsIMsgWindow.h"
00056 
00057 /* The below is all stuff that we remember for netlib about which
00058    articles we've already seen in the current newsgroup. */
00059 
00060 typedef struct MSG_NewsKnown {
00061   nsMsgKeySet* set; /* Set of articles we've already gotten
00062                        from the newsserver (if it's marked
00063                        "read", then we've already gotten it).
00064                        If an article is marked "read", it
00065                        doesn't mean we're actually displaying
00066                        it; it may be an article that no longer
00067                        exists, or it may be one that we've
00068                        marked read and we're only viewing
00069                        unread messages. */
00070 
00071   PRInt32 first_possible; /* The oldest article in this group. */
00072   PRInt32 last_possible; /* The newest article in this group. */
00073 
00074   PRBool shouldGetOldest;
00075 } MSG_NewsKnown;
00076 
00077 // This class should ultimately be part of a news group listing
00078 // state machine - either by inheritance or delegation.
00079 // Currently, a folder pane owns one and libnet news group listing
00080 // related messages get passed to this object.
00081 class nsNNTPNewsgroupList : public nsINNTPNewsgroupList, public nsIMsgFilterHitNotify
00082 #ifdef HAVE_CHANGELISTENER
00083 /* ,public ChangeListener */
00084 #endif
00085 {
00086 public:
00087   nsNNTPNewsgroupList();
00088   virtual  ~nsNNTPNewsgroupList();
00089   NS_DECL_ISUPPORTS
00090   NS_DECL_NSINNTPNEWSGROUPLIST
00091   NS_DECL_NSIMSGFILTERHITNOTIFY
00092 
00093 private:
00094   NS_METHOD CleanUp();
00095      
00096   PRBool  m_finishingXover;
00097 
00098 #ifdef HAVE_CHANGELISTENER
00099   virtual void OnAnnouncerGoingAway (ChangeAnnouncer *instigator);
00100 #endif
00101   nsresult ParseLine(char *line, PRUint32 *message_number);
00102   nsresult GetDatabase(const char *uri, nsIMsgDatabase **db);
00103   void SetProgressBarPercent(PRInt32 percent);
00104   void SetProgressStatus(const PRUnichar *message);
00105 
00106 protected:
00107   PRBool m_getOldMessages;
00108   PRBool m_promptedAlready;
00109   PRBool m_downloadAll;
00110   PRInt32 m_maxArticles;
00111   PRInt32 m_lastPercent;
00112   PRTime m_lastStatusUpdate;
00113 
00114   nsCOMPtr <nsIMsgNewsFolder> m_newsFolder;
00115   nsCOMPtr <nsIMsgDatabase> m_newsDB;
00116   nsCOMPtr <nsINntpUrl> m_runningURL;
00117   
00118   nsMsgKey m_lastProcessedNumber;
00119   nsMsgKey m_firstMsgNumber;
00120   nsMsgKey m_lastMsgNumber;
00121   PRInt32 m_firstMsgToDownload;
00122   PRInt32 m_lastMsgToDownload;
00123   
00124   struct MSG_NewsKnown m_knownArts;
00125   nsMsgKeySet *m_set;
00126 
00127 private:
00128   nsCOMPtr <nsIMsgWindow> m_msgWindow;
00129   nsCOMPtr <nsIMsgFilterList> m_filterList;
00130   nsCOMPtr <nsIMsgFilterList> m_serverFilterList;
00131   nsCOMPtr <nsIMsgDBHdr> m_newMsgHdr; /* current message header we're building */
00132   PRBool m_addHdrToDB;
00133 };
00134     
00135 #endif /* nsNNTPNewsgroupListState_h___ */
00136