00001 // preferences.hh - source file for the mailfilter program 00002 // Copyright (c) 2000 - 2005 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 <fstream> 00025 #include "defines.hh" 00026 #include "socket.hh" 00027 #include "filter.hh" 00028 #include "score.hh" 00029 #include "account.hh" 00030 00031 using namespace std; 00032 00033 class Preferences 00034 { 00035 protected: 00036 static ifstream prefs_stream; 00037 static vector<Filter> allows; 00038 static vector<Filter> denies; 00039 static vector<Score> scores; 00040 static vector<Account> accnts; 00041 static Account cur_account; 00042 static string prefs_file_name; 00043 static string log_file_name; 00044 static string headers_file_name; 00045 static int icase; 00046 static bool norm; 00047 static bool test; 00048 static bool show_headers; 00049 static bool del_duplicates; 00050 static bool ret_status; 00051 static int high_score; 00052 static unsigned time_out_val; 00053 static int max_size; 00054 static Size_score size_score; 00055 static int max_size_friends; 00056 static int max_line_length; 00057 static int rreg_type; 00058 static int verbosity; 00059 static int conn_type; 00060 static int negative_allows; 00061 static int negative_denies; 00062 static int negative_scores; 00063 // These flags indicate whether a value was already set, or 00064 // whether it's still set to the default values defined by the 00065 // constructor. 00066 static bool verbosity_changed; 00067 static bool test_changed; 00068 public: 00069 static void init (void); 00070 static void kill (void); 00071 static bool open (const char*); 00072 static bool load (void); 00073 static void add_deny_rule (const char*, 00074 const char*, 00075 const char*); 00076 static void add_allow_rule (const char*, 00077 const char*, 00078 const char*); 00079 static void add_score (const char*, 00080 int, 00081 const char*, 00082 const char*); 00083 static int neg_allows (void); 00084 static int neg_denies (void); 00085 static void set_rc_file (const char*); 00086 static string rc_file (void); 00087 static void set_log_file (const char*); 00088 static string log_file (void); 00089 static void set_verbose_level (int); 00090 static int verbose_level (void); 00091 static void set_headers_file (const char*); 00092 static string headers_file (void); 00093 static void set_default_case (const char*); 00094 static int default_case (void); 00095 static void set_reg_type (const char*); 00096 static int reg_type (void); 00097 static void set_server (const char*); 00098 static void set_usr (const char*); 00099 static void set_passwd (const char*); 00100 static void set_protocol (const char*); 00101 static void set_connection (unsigned int = POSIX_SOCKETS) 00102 __attribute__ ((unused)); 00103 static void set_port (unsigned int); 00104 static unsigned int time_out (void); 00105 static void set_time_out (unsigned int); 00106 static bool delete_duplicates (void); 00107 static void set_del_duplicates(const char*); 00108 static int max_size_allow (void); 00109 static void set_max_size_allow(int); 00110 static int max_size_deny (void); 00111 static void set_max_size_deny (int); 00112 static Size_score max_size_score (void); 00113 static void set_max_size_score(int, 00114 int); 00115 static int highscore (void); 00116 static void set_highscore (int); 00117 static bool normal (void); 00118 static void set_normal (const char*); 00119 static bool test_mode (void); 00120 static void set_test_mode (const char*); 00121 static int maxlength (void); 00122 static void set_maxlength (int); 00123 static bool return_status (void); 00124 static void set_return_status (bool); 00125 static vector<Account>* accounts (void); 00126 static vector<Filter>* allow_filters (void); 00127 static vector<Filter>* deny_filters (void); 00128 static vector<Score>* score_filters (void); 00129 }; 00130 00131 #endif