preferences.hh

Go to the documentation of this file.
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   ifstream         prefs_stream;
00037   vector<Filter>   allows;
00038   vector<Filter>   denies;
00039   vector<Score>    scores;
00040   vector<Account>  accnts;
00041   Account          cur_account;
00042   string           prefs_file_name;
00043   string           log_file_name;
00044   string           headers_file_name;
00045   int              icase;
00046   bool             norm;
00047   bool             test;
00048   bool             show_headers;
00049   bool             del_duplicates;
00050   bool             ret_status;
00051   int              high_score;
00052   unsigned         time_out_val;
00053   int              max_size;
00054   Size_score       size_score;
00055   int              max_size_friends;
00056   int              max_line_length;
00057   int              rreg_type;
00058   int              verbosity;
00059   int              conn_type;
00060   int              negative_allows;
00061   int              negative_denies;
00062   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   bool             verbosity_changed;
00067   bool             test_changed;
00068 public:
00069   Preferences                        ();
00070   static Preferences&
00071                    Instance          ();
00072   void             init              (void);
00073   void             kill              (void);
00074   bool             open              (const char*);
00075   bool             load              (void);
00076   void             add_deny_rule     (const char*,
00077                       const char*,
00078                       const char*);
00079   void             add_allow_rule    (const char*,
00080                       const char*,
00081                       const char*);
00082   void             add_score         (const char*,
00083                       int,
00084                       const char*,
00085                       const char*);
00086   int              neg_allows        (void);
00087   int              neg_denies        (void);
00088   void             set_rc_file       (const char*);
00089   string           rc_file           (void);
00090   void             set_log_file      (const char*);
00091   string           log_file          (void);
00092   void             set_verbose_level (int);
00093   int              verbose_level     (void);
00094   void             set_headers_file  (const char*);
00095   string           headers_file      (void);
00096   void             set_default_case  (const char*);
00097   int              default_case      (void);
00098   void             set_reg_type      (const char*);
00099   int              reg_type          (void);
00100   void             set_server        (const char*);
00101   void             set_usr           (const char*);
00102   void             set_passwd        (const char*);
00103   void             set_protocol      (const char*);
00104   void             set_connection    (unsigned int = POSIX_SOCKETS) 
00105                                      __attribute__ ((unused));
00106   void             set_port          (unsigned int);
00107   unsigned int     time_out          (void);
00108   void             set_time_out      (unsigned int);
00109   bool             delete_duplicates (void);
00110   void             set_del_duplicates(const char*);
00111   int              max_size_allow    (void);
00112   void             set_max_size_allow(int);
00113   int              max_size_deny     (void);
00114   void             set_max_size_deny (int);
00115   Size_score       max_size_score    (void);
00116   void             set_max_size_score(int, int);
00117   int              highscore         (void);
00118   void             set_highscore     (int);
00119   bool             normal            (void);
00120   void             set_normal        (const char*);
00121   bool             test_mode         (void);
00122   void             set_test_mode     (const char*);
00123   int              maxlength         (void);
00124   void             set_maxlength     (int);
00125   bool             return_status     (void);
00126   void             set_return_status (bool);
00127   vector<Account>* accounts          (void);
00128   vector<Filter>*  allow_filters     (void);
00129   vector<Filter>*  deny_filters      (void);
00130   vector<Score>*   score_filters     (void);
00131 };
00132 
00133 #endif

Generated on Sat Sep 15 17:50:33 2007 for mailfilter by  doxygen 1.5.3