Back to index

lightning-sunbird  0.9+nobinonly
nsNntpIncomingServer.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  *
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 __nsNntpIncomingServer_h
00039 #define __nsNntpIncomingServer_h
00040 
00041 #include "nsINntpIncomingServer.h"
00042 #include "nsIUrlListener.h"
00043 #include "nscore.h"
00044 
00045 #include "nsMsgIncomingServer.h"
00046 
00047 #include "prmem.h"
00048 #include "plstr.h"
00049 #include "prprf.h"
00050 
00051 #include "nsAdapterEnumerator.h" 
00052 #include "nsIMsgWindow.h"
00053 #include "nsISubscribableServer.h"
00054 #include "nsMsgLineBuffer.h"
00055 #include "nsVoidArray.h"
00056 #include "nsITimer.h"
00057 #include "nsFileStream.h"
00058 
00059 #include "nsITreeView.h"
00060 #include "nsITreeSelection.h"
00061 #include "nsIAtom.h"
00062 
00063 class nsINntpUrl;
00064 class nsIMsgMailNewsUrl;
00065 
00066 /* get some implementation from nsMsgIncomingServer */
00067 class nsNntpIncomingServer : public nsMsgIncomingServer,
00068                              public nsINntpIncomingServer,
00069                              public nsIUrlListener,
00070                              public nsISubscribableServer,
00071                              public nsMsgLineBuffer,
00072                              public nsITreeView
00073                              
00074 {
00075 public:
00076     NS_DECL_ISUPPORTS_INHERITED
00077     NS_DECL_NSINNTPINCOMINGSERVER
00078     NS_DECL_NSIURLLISTENER
00079     NS_DECL_NSISUBSCRIBABLESERVER
00080     NS_DECL_NSITREEVIEW
00081 
00082     nsNntpIncomingServer();
00083     virtual ~nsNntpIncomingServer();
00084     
00085     NS_IMETHOD GetLocalStoreType(char * *type);
00086     NS_IMETHOD CloseCachedConnections();
00087     NS_IMETHOD PerformBiff(nsIMsgWindow *aMsgWindow);
00088     NS_IMETHOD PerformExpand(nsIMsgWindow *aMsgWindow);
00089     NS_IMETHOD OnUserOrHostNameChanged(const char *oldName, const char *newName);
00090 
00091     // for nsMsgLineBuffer
00092     virtual PRInt32 HandleLine(char *line, PRUint32 line_size);
00093 
00094     // override to clear all passwords associated with server
00095     NS_IMETHODIMP ForgetPassword();
00096     NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages);
00097     NS_IMETHOD GetOfflineSupportLevel(PRInt32 *aSupportLevel);
00098     NS_IMETHOD GetDefaultCopiesAndFoldersPrefsToServer(PRBool *aCopiesAndFoldersOnServer);
00099     NS_IMETHOD GetCanCreateFoldersOnServer(PRBool *aCanCreateFoldersOnServer);
00100     NS_IMETHOD GetCanFileMessagesOnServer(PRBool *aCanFileMessagesOnServer);
00101     NS_IMETHOD GetFilterScope(nsMsgSearchScopeValue *filterScope);
00102     NS_IMETHOD GetSearchScope(nsMsgSearchScopeValue *searchScope);
00103 
00104     nsresult AppendIfSearchMatch(nsCString& newsgroupName);
00105 
00106 protected:
00107     nsresult CreateProtocolInstance(nsINNTPProtocol ** aNntpConnection, nsIURI *url,
00108                                              nsIMsgWindow *window);
00109     PRBool ConnectionTimeOut(nsINNTPProtocol* aNntpConnection);
00110     nsCOMPtr<nsISupportsArray> m_connectionCache;
00111     NS_IMETHOD GetServerRequiresPasswordForBiff(PRBool *aServerRequiresPasswordForBiff);
00112     nsByteArray        mHostInfoInputStream;    
00113     nsresult SetupNewsrcSaveTimer();
00114     static void OnNewsrcSaveTimer(nsITimer *timer, void *voidIncomingServer);
00115 
00116 private:
00117     nsCStringArray mSubscribedNewsgroups;
00118     nsCStringArray mGroupsOnServer;
00119     nsCStringArray mSubscribeSearchResult;
00120     PRBool mSearchResultSortDescending;
00121     // the list of of subscribed newsgroups within a given
00122     // subscribed dialog session.  
00123     // we need to keep track of them so we know what to show as "checked"
00124     // in the search view
00125     nsCStringArray mTempSubscribed;
00126     nsCOMPtr<nsIAtom> mSubscribedAtom;
00127     nsCOMPtr<nsIAtom> mNntpAtom;
00128 
00129     nsString mSearchValue;
00130     nsCOMPtr<nsITreeBoxObject> mTree;
00131     nsCOMPtr<nsITreeSelection> mTreeSelection;
00132 
00133     PRBool   mHasSeenBeginGroups;
00134     nsresult WriteHostInfoFile();
00135     nsresult LoadHostInfoFile();
00136     nsresult AddGroupOnServer(const nsACString &name);
00137 
00138     PRBool mNewsrcHasChanged;
00139     nsAdapterEnumerator *mGroupsEnumerator;
00140     PRBool mHostInfoLoaded;
00141     PRBool mHostInfoHasChanged;
00142     nsCOMPtr <nsIFileSpec> mHostInfoFile;
00143     
00144     PRUint32 mLastGroupDate;
00145     PRTime mFirstNewDate;
00146     PRInt32 mUniqueId;    
00147     PRUint32 mLastUpdatedTime;
00148     PRInt32 mVersion;
00149     PRBool mPostingAllowed;
00150     PRBool m_userAuthenticated;
00151 
00152     nsCOMPtr<nsITimer> mNewsrcSaveTimer;
00153     nsCOMPtr <nsIMsgWindow> mMsgWindow;
00154 
00155     nsCOMPtr <nsISubscribableServer> mInner;
00156     nsresult EnsureInner();
00157     nsresult ClearInner();
00158     nsresult IsValidRow(PRInt32 row);
00159 
00160     nsIOFileStream *mHostInfoStream;
00161     nsCOMPtr<nsIFileSpec> mNewsrcFilePath;
00162 };
00163 
00164 #endif