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 - 2004 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 struct Size_score{ 00081 int score; 00082 int size; 00083 }; 00084 00085 00086 class Preferences { 00087 private: 00088 // Variables 00089 vector<serverInfo> servers; 00090 vector<filterInfo> filters; 00091 vector<friendInfo> friends; 00092 vector<scoreInfo> scores; 00093 serverInfo popServer; 00094 Size_score size_score; 00095 string logfile; 00096 string file; 00097 int highscore; 00098 int maxsize; 00099 int maxsizeFriends; 00100 bool icase; 00101 bool normal; 00102 int regType; 00103 int regNewline; 00104 int verboseLevel; 00105 int timeOut; 00106 bool test; 00107 bool showHeaders; 00108 bool delDuplicates; 00109 bool compiled; 00110 int maxLineLength; 00111 re::RegExp regExp; 00112 00113 // Private function(s) 00114 int cmpNoCase(const string&, const string&); 00115 00116 public: 00117 Preferences(const string&); 00118 ~Preferences(); 00119 00120 const vector<serverInfo>& getServers(void); 00121 int getMaxsize(void); 00122 int getMaxsizeFriends(void); 00123 bool getIcase(void); 00124 bool isNormal(void); 00125 int getVerboseLevel(void); 00126 void setVerboseLevel(int); 00127 const string& getLogfile(void); 00128 void setLogfile(const string&); 00129 vector<filterInfo>* getFilters(void); 00130 vector<friendInfo>* getFriends(void); 00131 vector<scoreInfo>* getScores(void); 00132 int getRegType(void); 00133 int getRegNewline(void); 00134 bool getTestMode(void); 00135 void setTestMode(bool); 00136 bool getDelDubs(void); 00137 bool getShowHeaders(void); 00138 int getMaxLineLength(void); 00139 void showErrorDeprecated(const string&); 00140 void showErrorParameter(const string&, const string&, const string&); 00141 void showErrorParameter(const string&, const string&, int); 00142 int getTimeOut(void); 00143 void setTimeOut(int); 00144 int getHighscore(void); 00145 void setHighscore(int); 00146 void keyword(const string, const string, const string); 00147 void keyword(const string, const string, int); 00148 void keyword(const string, int, const string, const string); 00149 int precompileExpressions(void); 00150 void setCompiled(bool); 00151 bool getCompiled(void); 00152 Size_score getMaxSizeScore(void); 00153 }; 00154 00155 // Exceptions 00156 class MalformedPrefsFile { }; 00157 class IOException { }; 00158 class RegExException { }; 00159 } 00160 00161 #endif

Generated on Sun Aug 8 15:22:26 2004 for mailfilter by doxygen 1.3.8