Back to index

lightning-sunbird  0.9+nobinonly
nsImapCore.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) 1999
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Lorenzo Colitti <lorenzo@colitti.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 #ifndef _nsImapCore_H_
00040 #define _nsImapCore_H_
00041 
00042 #include "MailNewsTypes.h"
00043 #include "nsString.h"
00044 #include "nsIMailboxSpec.h"
00045 #include "nsIImapFlagAndUidState.h"
00046 
00047 class nsIMAPNamespace;
00048 class nsImapProtocol;
00049 class nsImapFlagAndUidState;
00050 
00051 /* imap message flags */
00052 typedef PRUint16 imapMessageFlagsType;
00053 
00054 /* used for communication between imap thread and event sinks */
00055 #define kNoFlags     0x00   /* RFC flags */
00056 #define kMarked      0x01
00057 #define kUnmarked    0x02
00058 #define kNoinferiors 0x04
00059 #define kNoselect    0x08
00060 #define kImapTrash   0x10   /* Navigator flag */
00061 #define kJustExpunged 0x20  /* This update is a post expunge url update. */
00062 #define kPersonalMailbox    0x40   /* this mailbox is in the personal namespace */
00063 #define kPublicMailbox             0x80   /* this mailbox is in the public namespace */
00064 #define kOtherUsersMailbox  0x100  /* this mailbox is in the other users' namespace */
00065 #define kNameSpace                 0x200  /* this mailbox IS a namespace */
00066 #define kNewlyCreatedFolder     0x400 /* this folder was just created */
00067 
00068 /* flags for individual messages */
00069 /* currently the ui only offers \Seen and \Flagged */
00070 #define kNoImapMsgFlag                0x0000
00071 #define kImapMsgSeenFlag              0x0001
00072 #define kImapMsgAnsweredFlag          0x0002
00073 #define kImapMsgFlaggedFlag           0x0004
00074 #define kImapMsgDeletedFlag           0x0008
00075 #define kImapMsgDraftFlag             0x0010
00076 #define kImapMsgRecentFlag            0x0020
00077 #define       kImapMsgForwardedFlag         0x0040             /* Not always supported, check mailbox folder */
00078 #define kImapMsgMDNSentFlag           0x0080            /* Not always supported. check mailbox folder */
00079 #define kImapMsgCustomKeywordFlag     0x0100            /* this msg has a custom keyword */
00080 #define kImapMsgLabelFlags            0x0E00            /* supports 5 labels only supported if the folder supports keywords */
00081 #define kImapMsgSupportMDNSentFlag    0x2000
00082 #define kImapMsgSupportForwardedFlag  0x4000
00083 #define kImapMsgSupportUserFlag       0x8000            
00084 /* This seems to be the most cost effective way of
00085 * piggying back the server support user flag info.
00086 */
00087 
00088 /* if a url creator does not know the hierarchySeparator, use this */
00089 #define kOnlineHierarchySeparatorUnknown '^'
00090 #define kOnlineHierarchySeparatorNil '|'
00091 
00092 #define IMAP_URL_TOKEN_SEPARATOR ">"
00093 #define kUidUnknown -1
00094 
00095 // this has to do with Mime Parts on Demand. It used to live in net.h
00096 // I'm not sure where this will live, but here is OK temporarily
00097 typedef enum {
00098        IMAP_CONTENT_NOT_MODIFIED = 0,
00099        IMAP_CONTENT_MODIFIED_VIEW_INLINE,
00100        IMAP_CONTENT_MODIFIED_VIEW_AS_LINKS,
00101        IMAP_CONTENT_FORCE_CONTENT_NOT_MODIFIED
00102 } IMAP_ContentModifiedType;
00103 
00104 
00105 
00106 // I think this should really go in an imap.h equivalent file
00107 typedef enum {
00108     kPersonalNamespace = 0,
00109     kOtherUsersNamespace,
00110     kPublicNamespace,
00111     kDefaultNamespace,
00112     kUnknownNamespace
00113 } EIMAPNamespaceType;
00114 
00115 
00116 typedef enum {
00117     kCapabilityUndefined = 0x00000000,
00118     kCapabilityDefined = 0x00000001,
00119     kHasAuthLoginCapability = 0x00000002,
00120     kHasXNetscapeCapability = 0x00000004,
00121     kHasXSenderCapability = 0x00000008,
00122     kIMAP4Capability = 0x00000010,          /* RFC1734 */
00123     kIMAP4rev1Capability = 0x00000020,      /* RFC2060 */
00124     kIMAP4other = 0x00000040,                       /* future rev?? */
00125     kNoHierarchyRename = 0x00000080,                        /* no hierarchy rename */
00126     kACLCapability = 0x00000100,          /* ACL extension */
00127     kNamespaceCapability = 0x00000200,    /* IMAP4 Namespace Extension */
00128     kMailboxDataCapability = 0x00000400,  /* MAILBOXDATA SMTP posting extension */
00129     kXServerInfoCapability = 0x00000800,  /* XSERVERINFO extension for admin urls */
00130     kHasAuthPlainCapability = 0x00001000, /* new form of auth plain base64 login */
00131     kUidplusCapability = 0x00002000,         /* RFC 2359 UIDPLUS extension */
00132     kLiteralPlusCapability = 0x00004000, /* RFC 2088 LITERAL+ extension */
00133     kAOLImapCapability = 0x00008000,     /* aol imap extensions */
00134     kHasLanguageCapability = 0x00010000, /* language extensions */
00135     kHasCRAMCapability     = 0x00020000, /* CRAM auth extension */
00136     kQuotaCapability       = 0x00040000, /* RFC 2087 quota extension */
00137     kHasIdleCapability       = 0x00080000,  /* RFC 2177 idle extension */
00138     kHasAuthNTLMCapability = 0x00100000,  /* AUTH NTLM extension */
00139     kHasAuthMSNCapability = 0x00200000,   /* AUTH MSN extension */
00140     kHasStartTLSCapability = 0x00400000,   /* STARTTLS support */
00141     kLoginDisabled = 0x00800000,        /* login disabled */
00142     kHasAuthGssApiCapability = 0x01000000
00143 } eIMAPCapabilityFlag;
00144 
00145 // this used to be part of the connection object class - maybe we should move it into 
00146 // something similar
00147 typedef enum {
00148     kEveryThingRFC822,
00149     kEveryThingRFC822Peek,
00150     kHeadersRFC822andUid,
00151     kUid,
00152     kFlags,
00153     kRFC822Size,
00154     kRFC822HeadersOnly,
00155     kMIMEPart,
00156     kMIMEHeader,
00157     kBodyStart
00158 } nsIMAPeFetchFields;
00159     
00160 // This class is currently only used for the one-time upgrade
00161 // process from a LIST view to the subscribe model.
00162 // It basically contains the name of a mailbox and whether or not
00163 // its children have been listed.
00164 class nsIMAPMailboxInfo
00165 {
00166 public:
00167   nsIMAPMailboxInfo(const char *name, char delimiter);
00168   virtual ~nsIMAPMailboxInfo();
00169   void SetChildrenListed(PRBool childrenListed) { m_childrenListed = childrenListed; }
00170   PRBool GetChildrenListed() { return m_childrenListed; }
00171   const char *GetMailboxName() { return m_mailboxName.get(); }
00172   char GetDelimiter() { return m_delimiter; }
00173   
00174 protected:
00175   PRBool m_childrenListed;
00176   nsCString m_mailboxName;
00177   char m_delimiter;
00178 };
00179 
00180 class nsImapMailboxSpec : public nsIMailboxSpec
00181 {
00182 public:
00183   NS_DECL_ISUPPORTS
00184     
00185   nsImapMailboxSpec();
00186   virtual ~nsImapMailboxSpec();
00187 
00188   NS_DECL_NSIMAILBOXSPEC
00189     
00190   nsImapMailboxSpec& operator=(const nsImapMailboxSpec& aCopy);
00191   PRInt32 folder_UIDVALIDITY;
00192   PRInt32 number_of_messages;
00193   PRInt32 number_of_unseen_messages;
00194   PRInt32 number_of_recent_messages;
00195   
00196   PRUint32  box_flags;
00197   PRUint32  supportedUserFlags;
00198   
00199   char          *allocatedPathName;
00200   PRUnichar *unicharPathName;
00201   char      hierarchySeparator;
00202   char     *hostName;
00203   
00204   nsImapProtocol *connection;      // do we need this? It seems evil.
00205   nsCOMPtr <nsIImapFlagAndUidState>     flagState;
00206   
00207   PRBool    folderSelected;
00208   PRBool    discoveredFromLsub;
00209   
00210   PRBool    onlineVerified;
00211   
00212   nsIMAPNamespace *namespaceForFolder;
00213 };
00214 
00215 typedef struct _utf_name_struct {
00216        PRBool toUtf7Imap;
00217        unsigned char *sourceString;
00218        unsigned char *convertedString;
00219 } utf_name_struct;
00220 
00221 
00222 typedef struct _ProgressInfo {
00223   PRUnichar *message;
00224   PRInt32 currentProgress;
00225   PRInt32 maxProgress;
00226 } ProgressInfo;
00227 
00228 
00229 
00230 typedef enum 
00231 {
00232     eContinue,
00233     eContinueNew,
00234     eListMyChildren,
00235     eNewServerDirectory,
00236     eCancelled 
00237 } EMailboxDiscoverStatus;
00238 
00239 
00240 
00241 // This class is only used for passing data
00242 // between the IMAP and mozilla threads 
00243 class nsIMAPACLRightsInfo
00244 { 
00245 public:
00246   char *hostName, *mailboxName, *userName, *rights;
00247 };
00248 
00249 
00250 #endif