Back to index

lightning-sunbird  0.9+nobinonly
nsMsgFilter.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  *   David Bienvenu (bienvenu@nventure.com)
00024  *   Howard Chu <hyc@symas.com>
00025  *
00026  * Alternatively, the contents of this file may be used under the terms of
00027  * either of the GNU General Public License Version 2 or later (the "GPL"),
00028  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00029  * in which case the provisions of the GPL or the LGPL are applicable instead
00030  * of those above. If you wish to allow use of your version of this file only
00031  * under the terms of either the GPL or the LGPL, and not to allow others to
00032  * use your version of this file under the terms of the MPL, indicate your
00033  * decision by deleting the provisions above and replace them with the notice
00034  * and other provisions required by the GPL or the LGPL. If you do not delete
00035  * the provisions above, a recipient may use your version of this file under
00036  * the terms of any one of the MPL, the GPL or the LGPL.
00037  *
00038  * ***** END LICENSE BLOCK ***** */
00039 
00040 #ifndef _nsMsgFilter_H_
00041 #define _nsMsgFilter_H_
00042 
00043 #include "nscore.h"
00044 #include "nsISupports.h"
00045 #include "nsIMsgFilter.h"
00046 #include "nsMsgSearchArray.h"
00047 #include "nsIMsgSearchScopeTerm.h"
00048 #include "nsMsgSearchBoolExpression.h"
00049 #include "nsIDateTimeFormat.h"
00050 
00051 class nsMsgRuleAction : public nsIMsgRuleAction
00052 {
00053 public:
00054   NS_DECL_ISUPPORTS
00055 
00056   nsMsgRuleAction();
00057   virtual ~nsMsgRuleAction();
00058 
00059   NS_DECL_NSIMSGRULEACTION
00060 
00061 private:
00062     nsMsgRuleActionType      m_type;
00063               // this used to be a union - why bother?
00064     nsMsgPriorityValue      m_priority;  /* priority to set rule to */
00065     nsMsgLabelValue         m_label;  /* label to set rule to */
00066     nsCString        m_folderUri; 
00067     PRInt32             m_junkScore;  /* junk score (or arbitrary int value?) */
00068     // arbitrary string value. Currently, email address to forward to
00069     nsCString           m_strValue; 
00070 } ;
00071 
00072 
00073 class nsMsgFilter : public nsIMsgFilter
00074 {
00075 public:
00076   NS_DECL_ISUPPORTS
00077     NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMSGFILTER_IID)
00078 
00079   nsMsgFilter();
00080   virtual ~nsMsgFilter ();
00081 
00082   NS_DECL_NSIMSGFILTER
00083 
00084   nsMsgFilterTypeType       GetType() {return m_type;}
00085   void   SetType(nsMsgFilterTypeType      type) {m_type = type;}
00086   PRBool  GetEnabled() {return m_enabled;}
00087   void    SetFilterScript(nsCString *filterName) ;
00088   void    SetFilterList(nsIMsgFilterList* filterList);
00089   PRBool  IsRule() {return (m_type & (nsMsgFilterType::InboxRule |
00090                                nsMsgFilterType::NewsRule)) != 0;}
00091 
00092   PRBool  IsScript() {return (m_type &
00093                                   (nsMsgFilterType::InboxJavaScript |
00094                                    nsMsgFilterType::NewsJavaScript)) != 0;}
00095 
00096   // filing routines.
00097   nsresult  SaveToTextFile(nsIOFileStream *aStream);
00098   nsresult  SaveRule(nsIOFileStream *aStream);
00099 
00100   PRInt16   GetVersion();
00101 #ifdef DEBUG
00102   void     Dump();
00103 #endif
00104 
00105   nsresult  ConvertMoveOrCopyToFolderValue(nsIMsgRuleAction *filterAction, nsCString &relativePath);
00106   static const char *GetActionStr(nsMsgRuleActionType action);
00107   static nsresult GetActionFilingStr(nsMsgRuleActionType action, nsCString &actionStr);
00108   static nsMsgRuleActionType GetActionForFilingStr(nsCString &actionStr);
00109   nsMsgRuleAction      m_action;
00110 protected:
00111   nsMsgFilterTypeType m_type;
00112   nsString    m_filterName;
00113   nsCString   m_scriptFileName;    // iff this filter is a script.
00114   nsCString   m_description;
00115   nsCString   m_unparsedBuffer;
00116 
00117   PRPackedBool m_enabled;
00118   PRPackedBool m_temporary;
00119   PRPackedBool m_unparseable;
00120   nsIMsgFilterList *m_filterList;  /* owning filter list */
00121   nsCOMPtr<nsISupportsArray> m_termList;       /* linked list of criteria terms */
00122   nsCOMPtr<nsIMsgSearchScopeTerm> m_scope;         /* default for mail rules is inbox, but news rules could
00123                                                   have a newsgroup - LDAP would be invalid */
00124   nsCOMPtr<nsISupportsArray> m_actionList;
00125   nsMsgSearchBoolExpression *m_expressionTree;
00126   nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
00127 };
00128 
00129 #endif