Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

Preferences.hh

Go to the documentation of this file.
00001 // Preferences.hh - source file for the mailfilter program
00002 // Copyright (c) 2000 - 2003  Andreas Bauer <baueran@in.tum.de>
00003 //
00004 // This program is free software; you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation; either version 2 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00017 // USA.
00018 
00019 #ifndef PREFERENCES_HH
00020 #define PREFERENCES_HH
00021 
00022 #include <string>
00023 #include <vector>
00024 #include <list>
00025 extern "C" {
00026 #include <sys/types.h>
00027 #include <regex.h>
00028 }
00029 #include "RegExp.hh"
00030 #include "mailfilter.hh"
00031 
00032 // Filter modes
00033 #define CASE_DEFAULT       0
00034 #define CASE_SENSITIVE     1
00035 #define CASE_INSENSITIVE   2
00036 
00037 // Verbose levels
00038 #define MIN_VERBOSE        0
00039 #define MAX_VERBOSE        6
00040 
00041 using namespace std;
00042 
00043 namespace pref {
00044   
00045   struct serverInfo {
00046     string name;
00047     string user;
00048     string pass;
00049     int protocol;
00050     int port;
00051   };
00052 
00053 
00054   struct filterInfo {
00055     string filter;        // Filter as ordinary string object
00056     int case_sensitive;   // Values can be { CASE_SENSITIVE | CASE_INSENSITIVE | CASE_DEFAULT }
00057 
00058     // Negative filters
00059     bool negative;        // true if filter is of type 'DENY<>myaddress@something.com', otherwise false
00060 
00061     regex_t cFilter;      // Compiled filter
00062   };
00063   
00064 
00065   struct friendInfo {
00066     string filter;
00067     regex_t cFilter;
00068   };
00069 
00070 
00071   struct scoreInfo {
00072     string filter;
00073     int score;
00074     int case_sensitive;
00075     bool negative;
00076     regex_t cFilter;
00077   };
00078 
00079 
00080   class Preferences {
00081   private:
00082     // Variables
00083     vector<serverInfo> servers;
00084     vector<filterInfo> filters;
00085     vector<friendInfo> friends;
00086     vector<scoreInfo> scores;
00087     serverInfo popServer;
00088     string logfile;
00089     string file;
00090     int highscore;
00091     int maxsize;
00092     int maxsizeFriends;
00093     bool icase;
00094     bool normal;
00095     int regType;
00096     int regNewline;
00097     int verboseLevel;
00098     int timeOut;
00099     bool test;
00100     bool showHeaders;
00101     bool delDuplicates;
00102     bool compiled;
00103     int maxLineLength;
00104     re::RegExp regExp;
00105 
00106     // Private function(s)
00107     int cmpNoCase(const string&, const string&);
00108 
00109   public:
00110     Preferences(const string&);
00111     ~Preferences();
00112 
00113     const vector<serverInfo>& getServers(void);
00114     int getMaxsize(void);
00115     int getMaxsizeFriends(void);
00116     bool getIcase(void);
00117     bool isNormal(void);
00118     int getVerboseLevel(void);
00119     void setVerboseLevel(int);
00120     const string& getLogfile(void);
00121     void setLogfile(const string&);
00122     vector<filterInfo>* getFilters(void);
00123     vector<friendInfo>* getFriends(void);
00124     vector<scoreInfo>* getScores(void);
00125     int getRegType(void);
00126     int getRegNewline(void);
00127     bool getTestMode(void);
00128     void setTestMode(bool);
00129     bool getDelDubs(void);
00130     bool getShowHeaders(void);
00131     int getMaxLineLength(void);
00132     void showErrorDeprecated(const string&);
00133     void showErrorParameter(const string&, const string&, const string&);
00134     void showErrorParameter(const string&, const string&, int);
00135     int getTimeOut(void);
00136     void setTimeOut(int);
00137     int getHighscore(void);
00138     void setHighscore(int);
00139     void keyword(const string, const string, const string);
00140     void keyword(const string, const string, int);
00141     void keyword(const string, int, const string, const string);
00142     int precompileExpressions(void);
00143     void setCompiled(bool);
00144     bool getCompiled(void);
00145   };
00146   
00147   // Exceptions
00148   class MalformedPrefsFile { };
00149   class IOException { };
00150   class RegExException { };
00151 }
00152 
00153 #endif

Generated on Sat Oct 11 13:01:47 2003 for mailfilter by doxygen 1.3.4