00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00033 #define CASE_DEFAULT 0
00034 #define CASE_SENSITIVE 1
00035 #define CASE_INSENSITIVE 2
00036
00037
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;
00056 int case_sensitive;
00057
00058
00059 bool negative;
00060
00061 regex_t
cFilter;
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
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
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
00156 class MalformedPrefsFile { };
00157 class IOException { };
00158 class RegExException { };
00159 }
00160
00161
#endif