Back to index

lightning-sunbird  0.9+nobinonly
nsImapUrl.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 nsImapUrl_h___
00039 #define nsImapUrl_h___
00040 
00041 #include "nsIImapUrl.h"
00042 #include "nsIImapMockChannel.h"
00043 #include "nsCOMPtr.h"
00044 #include "nsMsgMailNewsUrl.h"
00045 #include "nsIMsgIncomingServer.h"
00046 #include "nsIImapMailFolderSink.h"
00047 #include "nsIImapServerSink.h"
00048 #include "nsIImapMessageSink.h"
00049 
00050 #include "nsWeakPtr.h"
00051 #include "nsXPIDLString.h"
00052 #include "nsIFileSpec.h"
00053 
00054 class nsImapUrl : public nsIImapUrl, public nsMsgMailNewsUrl, public nsIMsgMessageUrl, public nsIMsgI18NUrl
00055 {
00056 public:
00057 
00058   NS_DECL_ISUPPORTS_INHERITED
00059 
00060   // nsIURI override
00061   NS_IMETHOD SetSpec(const nsACString &aSpec);
00062   NS_IMETHOD SetQuery(const nsACString &aQuery);
00063 
00065   // we support the nsIImapUrl interface
00067   NS_DECL_NSIIMAPURL
00068 
00069   // nsIMsgMailNewsUrl overrides
00070   NS_IMETHOD IsUrlType(PRUint32 type, PRBool *isType);
00071   NS_IMETHOD SetMsgWindow(nsIMsgWindow *aMsgWindow);
00072   NS_IMETHOD GetFolder(nsIMsgFolder **aFolder);
00073   NS_IMETHOD SetFolder(nsIMsgFolder *aFolder);
00074   // nsIMsgMessageUrl
00075   NS_DECL_NSIMSGMESSAGEURL
00076   NS_DECL_NSIMSGI18NURL
00077   
00078   // nsImapUrl
00079   nsImapUrl();
00080   virtual ~nsImapUrl();
00081   
00082   static nsresult ConvertToCanonicalFormat(const char *folderName, char onlineDelimiter, char **resultingCanonicalPath);
00083   static nsresult EscapeSlashes(const char *sourcePath, char **resultPath);
00084   static nsresult UnescapeSlashes(char *path);
00085   static char *      ReplaceCharsInCopiedString(const char *stringToCopy, char oldChar, char newChar);
00086   
00087 protected:
00088   virtual nsresult ParseUrl();
00089   virtual const char * GetUserName() { return m_userName;}
00090   
00091   char        *m_listOfMessageIds;
00092   
00093   // handle the imap specific parsing
00094   void        ParseImapPart(char *imapPartOfUrl);
00095   
00096   void        ParseFolderPath(char **resultingCanonicalPath);
00097   void        ParseSearchCriteriaString();
00098   void        ParseUidChoice();
00099   void        ParseMsgFlags();
00100   void        ParseListOfMessageIds();
00101   void          ParseCustomMsgFetchAttribute();
00102   void          ParseNumBytes();
00103 
00104   nsresult GetMsgFolder(nsIMsgFolder **msgFolder);
00105   
00106   char        *m_sourceCanonicalFolderPathSubString;
00107   char        *m_destinationCanonicalFolderPathSubString;
00108   char        *m_tokenPlaceHolder;
00109   char        *m_urlidSubString;
00110   char        m_onlineSubDirSeparator;
00111   char        *m_searchCriteriaString;    // should we use m_search, or is this special?
00112   nsCString     m_command;       // for custom commands
00113   nsCString     m_msgFetchAttribute; // for fetching custom msg attributes
00114   nsCString     m_customAttributeResult; // for fetching custom msg attributes
00115   nsCString     m_customCommandResult; // custom command response
00116   nsCString     m_customAddFlags;       // these two are for setting and clearing custom flags
00117   nsCString     m_customSubtractFlags;
00118   PRInt32       m_numBytesToFetch; // when doing a msg body preview, how many bytes to read
00119   PRPackedBool m_validUrl;
00120   PRPackedBool m_runningUrl;
00121   PRPackedBool m_idsAreUids;
00122   PRPackedBool m_mimePartSelectorDetected;
00123   PRPackedBool m_allowContentChange;      // if PR_FALSE, we can't use Mime parts on demand
00124   PRPackedBool m_fetchPartsOnDemand; // if PR_TRUE, we should fetch leave parts on server.
00125   PRPackedBool m_msgLoadingFromCache; // if PR_TRUE, we might need to mark read on server
00126   PRPackedBool m_externalLinkUrl; // if PR_TRUE, we're running this url because the user
00127   PRPackedBool m_shouldStoreMsgOffline;
00128   PRPackedBool m_rerunningUrl; // first attempt running this failed with connection error; retrying
00129   nsImapContentModifiedType m_contentModified;
00130 
00131   nsXPIDLCString  m_userName;
00132   nsXPIDLCString  m_serverKey;
00133   // event sinks
00134   imapMessageFlagsType      m_flags;
00135   nsImapAction       m_imapAction;
00136 
00137   nsWeakPtr m_imapFolder;
00138   nsWeakPtr m_imapMailFolderSink;
00139   nsWeakPtr m_imapMessageSink;
00140 
00141   nsWeakPtr m_imapServerSink;
00142 
00143   // online message copy support; i don't have a better solution yet
00144   nsCOMPtr <nsISupports> m_copyState;   // now, refcounted.
00145   nsIFileSpec* m_fileSpec;
00146   nsCOMPtr<nsIImapMockChannel> m_mockChannel;
00147 
00148     // used by save message to disk
00149   nsCOMPtr<nsIFileSpec> m_messageFileSpec;
00150   PRBool                m_addDummyEnvelope;
00151   PRBool                m_canonicalLineEnding; // CRLF
00152   
00153   nsCString mURI; // the RDF URI associated with this url.
00154   nsCString mCharsetOverride; // used by nsIMsgI18NUrl...
00155 };
00156 
00157 #endif /* nsImapUrl_h___ */