Back to index

lightning-sunbird  0.9+nobinonly
nsNntpService.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; 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  *
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 nsNntpService_h___
00039 #define nsNntpService_h___
00040 
00041 #include "nsINntpService.h"
00042 #include "nsIProtocolHandler.h"
00043 #include "nsIMsgMessageService.h"
00044 #include "nsINntpIncomingServer.h"
00045 #include "nsIMsgIncomingServer.h"
00046 #include "nsIFileSpec.h"
00047 #include "MailNewsTypes.h"
00048 #include "nsIMsgProtocolInfo.h"
00049 #include "nsIMsgWindow.h"
00050 #include "nsINntpUrl.h"
00051 #include "nsCOMPtr.h"
00052 #include "nsIContentHandler.h"
00053 #include "nsICacheSession.h"
00054 
00055 #ifdef MOZ_XUL_APP
00056 #include "nsICommandLineHandler.h"
00057 #define ICOMMANDLINEHANDLER nsICommandLineHandler
00058 #else
00059 #include "nsICmdLineHandler.h"
00060 #define ICOMMANDLINEHANDLER nsICmdLineHandler
00061 #endif
00062 
00063 class nsIURI;
00064 class nsIUrlListener;
00065 
00066 class nsNntpService : public nsINntpService,
00067                       public nsIMsgMessageService,
00068                       public nsIMsgMessageFetchPartService,
00069                       public nsIProtocolHandler,
00070                       public nsIMsgProtocolInfo,
00071                       public ICOMMANDLINEHANDLER,
00072                       public nsIContentHandler
00073 {
00074 public:
00075 
00076   NS_DECL_ISUPPORTS
00077   NS_DECL_NSINNTPSERVICE
00078   NS_DECL_NSIMSGMESSAGESERVICE
00079   NS_DECL_NSIPROTOCOLHANDLER
00080   NS_DECL_NSIMSGPROTOCOLINFO
00081   NS_DECL_NSICONTENTHANDLER
00082   NS_DECL_NSIMSGMESSAGEFETCHPARTSERVICE
00083   
00084 #ifdef MOZ_XUL_APP
00085   NS_DECL_NSICOMMANDLINEHANDLER
00086 #else
00087   NS_DECL_NSICMDLINEHANDLER
00088   CMDLINEHANDLER_REGISTERPROC_DECLS
00089 #endif
00090 
00091   // nsNntpService
00092   nsNntpService();
00093   virtual ~nsNntpService();
00094 
00095 protected:
00096   PRBool WeAreOffline();
00097 
00098   nsresult GetNntpServerByAccount(const char *aAccountKey, nsIMsgIncomingServer **aNntpServer);
00099   nsresult SetUpNntpUrlForPosting(const char *aAccountKey, char **newsUrlSpec);
00100   nsresult FindHostFromGroup(nsCString &host, nsCString &groupName);
00101   nsresult FindServerWithNewsgroup(nsCString &host, nsCString &groupName);
00102   
00103   nsresult CreateMessageIDURL(nsIMsgFolder *folder, nsMsgKey key, char **url);
00104   // a convience routine used to put together news urls
00105   nsresult ConstructNntpUrl(const char * urlString, nsIUrlListener *aUrlListener,  nsIMsgWindow * aMsgWindow, const char *originalMessageUri, PRInt32 action, nsIURI ** aUrl);
00106   nsresult CreateNewsAccount(const char *aHostname, PRBool aIsSecure, PRInt32 aPort, nsIMsgIncomingServer **aServer);
00107   nsresult GetProtocolForUri(nsIURI *aUri, nsIMsgWindow *aMsgWindow, nsINNTPProtocol **aProtocol);
00108   // a convience routine to run news urls
00109   nsresult RunNewsUrl (nsIURI * aUrl, nsIMsgWindow *aMsgWindow, nsISupports * aConsumer);
00110   // a convience routine to go from folder uri to msg folder
00111   nsresult GetFolderFromUri(const char *uri, nsIMsgFolder **folder);
00112   static PRBool findNewsServerWithGroup(nsISupports *aElement, void *data);
00113   nsresult DecomposeNewsMessageURI(const char * aMessageURI, nsIMsgFolder ** aFolder, nsMsgKey *aMsgKey);
00114 
00115   PRBool            mPrintingOperation; // Flag for printing operations
00116   PRBool                    mOpenAttachmentOperation; // Flag for opening attachments
00117 
00118   nsCOMPtr<nsICacheSession> mCacheSession; // the cache session used by news
00119 };
00120 
00121 #endif /* nsNntpService_h___ */