Back to index

lightning-sunbird  0.9+nobinonly
nsNewsFolder.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 /********************************************************************************************************
00040  
00041    Interface for representing News folders.
00042  
00043 *********************************************************************************************************/
00044 
00045 #ifndef nsMsgNewsFolder_h__
00046 #define nsMsgNewsFolder_h__
00047 
00048 #include "nsMsgDBFolder.h" 
00049 #include "nsFileSpec.h"
00050 #include "nsFileStream.h"
00051 #include "nsINntpIncomingServer.h" // need this for the IID
00052 #include "nsNewsUtils.h"
00053 #include "nsMsgLineBuffer.h"
00054 #include "nsMsgKeySet.h"
00055 #include "nsIMsgNewsFolder.h"
00056 #include "nsCOMPtr.h"
00057 #include "nsIMsgFilterService.h"
00058 
00059 class nsMsgNewsFolder : public nsMsgDBFolder, public nsIMsgNewsFolder, public nsMsgLineBuffer
00060 {
00061 public:
00062   nsMsgNewsFolder(void);
00063   virtual ~nsMsgNewsFolder(void);
00064 
00065   NS_DECL_ISUPPORTS_INHERITED
00066   NS_DECL_NSIMSGNEWSFOLDER
00067   // nsICollection methods:
00068   NS_IMETHOD Enumerate(nsIEnumerator* *result);
00069 
00070   // nsIUrlListener method
00071   NS_IMETHOD OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode);
00072   // nsIMsgFolder methods:
00073   NS_IMETHOD GetSubFolders(nsIEnumerator* *result);
00074 
00075   NS_IMETHOD GetMessages(nsIMsgWindow *aMsgWindow, nsISimpleEnumerator* *result);
00076   NS_IMETHOD UpdateFolder(nsIMsgWindow *aWindow);
00077 
00078   NS_IMETHOD CreateSubfolder(const PRUnichar *folderName,nsIMsgWindow *msgWindow);
00079 
00080   NS_IMETHOD Delete ();
00081   NS_IMETHOD Rename (const PRUnichar *newName, nsIMsgWindow *msgWindow);
00082 
00083   NS_IMETHOD GetAbbreviatedName(PRUnichar * *aAbbreviatedName);
00084 
00085   NS_IMETHOD GetFolderURL(char **url);
00086 
00087   NS_IMETHOD UpdateSummaryTotals(PRBool force) ;
00088 
00089   NS_IMETHOD GetExpungedBytesCount(PRUint32 *count);
00090   NS_IMETHOD GetDeletable (PRBool *deletable); 
00091   NS_IMETHOD GetRequiresCleanup(PRBool *requiresCleanup);
00092 
00093   NS_IMETHOD GetSizeOnDisk(PRUint32 *size);
00094 
00095   NS_IMETHOD GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsIMsgDatabase **db);
00096 
00097   NS_IMETHOD DeleteMessages(nsISupportsArray *messages, 
00098                       nsIMsgWindow *msgWindow, PRBool deleteStorage, PRBool isMove,
00099                       nsIMsgCopyServiceListener* listener, PRBool allowUndo);
00100   NS_IMETHOD GetNewMessages(nsIMsgWindow *aWindow, nsIUrlListener *aListener);
00101 
00102   NS_IMETHOD GetCanSubscribe(PRBool *aResult);
00103   NS_IMETHOD GetCanFileMessages(PRBool *aResult);
00104   NS_IMETHOD GetCanDeleteMessages(PRBool *aCanDeleteMessages);
00105   NS_IMETHOD GetCanCreateSubfolders(PRBool *aResult);
00106   NS_IMETHOD GetCanRename(PRBool *aResult);
00107   NS_IMETHOD GetCanCompact(PRBool *aResult);
00108   NS_IMETHOD OnReadChanged(nsIDBChangeListener * aInstigator);
00109 
00110   NS_IMETHOD DownloadMessagesForOffline(nsISupportsArray *messages, nsIMsgWindow *window);
00111   NS_IMETHOD Compact(nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow);
00112   NS_IMETHOD DownloadAllForOffline(nsIUrlListener *listener, nsIMsgWindow *msgWindow);
00113   NS_IMETHOD GetSortOrder(PRInt32 *order);
00114   NS_IMETHOD SetSortOrder(PRInt32 order);
00115 
00116   NS_IMETHOD GetPersistElided(PRBool *aPersistElided);
00117 
00118   NS_IMETHOD Shutdown(PRBool shutdownChildren);
00119   
00120   NS_IMETHOD GetFilterList(nsIMsgWindow *aMsgWindow, nsIMsgFilterList **aFilterList);
00121   NS_IMETHOD SetFilterList(nsIMsgFilterList *aFilterList);
00122   NS_IMETHOD ApplyRetentionSettings();
00123 
00124   // for nsMsgLineBuffer
00125   virtual PRInt32 HandleLine(char *line, PRUint32 line_size);
00126 
00127 protected:
00128   // helper routine to parse the URI and update member variables
00129   nsresult AbbreviatePrettyName(PRUnichar ** prettyName, PRInt32 fullwords);
00130   nsresult ParseFolder(nsFileSpec& path);
00131   nsresult CreateSubFolders(nsFileSpec &path);
00132   nsresult AddDirectorySeparator(nsFileSpec &path);
00133   nsresult GetDatabase(nsIMsgWindow *aMsgWindow);
00134 
00135   nsresult LoadNewsrcFileAndCreateNewsgroups();
00136   PRInt32 RememberLine(const char *line);
00137   nsresult RememberUnsubscribedGroup(const char *newsgroup, const char *setStr);
00138   nsresult ForgetLine(void);
00139   nsresult GetNewsMessages(nsIMsgWindow *aMsgWindow, PRBool getOld, nsIUrlListener *aListener);
00140 
00141   PRInt32 HandleNewsrcLine(char *line, PRUint32 line_size);
00142   virtual const char *GetIncomingServerType() {return "nntp";}
00143   virtual nsresult CreateBaseMessageURI(const char *aURI);
00144 
00145   nsByteArray        m_newsrcInputStream;
00146 
00147 protected:
00148   PRUint32  mExpungedBytes;
00149   PRPackedBool mGettingNews;
00150   PRPackedBool mInitialized;
00151   PRPackedBool m_downloadMessageForOfflineUse;
00152   PRPackedBool m_downloadingMultipleMessages;
00153 
00154   nsCString mOptionLines;
00155   nsCString mUnsubscribedNewsgroupLines;
00156   nsMsgKeySet *mReadSet; 
00157 
00158   nsCOMPtr<nsIFileSpec> mNewsrcFilePath; 
00159 
00160   // used for auth news
00161   char               *mGroupUsername;
00162   char        *mGroupPassword;
00163 
00164   nsCString mPrevUsername;
00165   nsCString mPrevPassword;
00166 
00167   // the name of the newsgroup.
00168   nsCString   mRawName;
00169   PRInt32 mSortOrder;
00170 
00171 private:
00172     nsresult CreateNewsgroupUsernameUrlForSignon(const char *inUriStr, char **result);
00173     nsresult CreateNewsgroupPasswordUrlForSignon(const char *inUriStr, char **result);
00174     nsresult CreateNewsgroupUrlForSignon(const char *inUriStr, const char *ref, char **result);
00175 
00176     nsCOMPtr <nsIFileSpec> mFilterFile;
00177     nsCOMPtr <nsIMsgFilterList> mFilterList;
00178 };
00179 
00180 #endif // nsMsgNewsFolder_h__