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

DnsblManager.h

Go to the documentation of this file.
00001 // DnsblManager.h: interface for the DnsblManager class.
00002 //
00004 
00005 #if !defined(AFX_DNSBLMANAGER_H__FEAA2C18_5349_4DAF_93D5_6CB5A30C6FA4__INCLUDED_)
00006 #define AFX_DNSBLMANAGER_H__FEAA2C18_5349_4DAF_93D5_6CB5A30C6FA4__INCLUDED_
00007 
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011 
00012 #include <abuse/abuse.h>
00013 #include <abuse/DnsblCache.h>
00014 #include <abuse/Dnsbl.h>
00015 #include <abuse/Url.h>
00016 #include <abuse/SysError.h>
00017 #include <map>
00018 #include <list>
00019 #include <abuse/RegKey.h>
00020 
00021 class DnsblManager  
00022 {
00023 public:
00024         struct DnsblData //should I inherit (and partially masquerade) Dnsbl?
00025         {
00026                 bool bDirty;
00027                 bool bActive;
00028                 Dnsbl *dnsbl;
00029                 void setCache(DnsblCache* c)
00030                 {
00031                         dnsbl->setCache(c);
00032                 }
00033                 bool hasCache()const
00034                 {
00035                         return (dnsbl->getCache()!=NULL);
00036                 }
00037                 const DnsblCache* getCache()const
00038                 {
00039                         return dnsbl->getCache();
00040                 }
00041                 DnsblData():dnsbl(NULL){}
00042                 DnsblData(const Dnsbl& other):dnsbl(new Dnsbl(other)){}
00043                 ~DnsblData(){delete dnsbl;}
00044         private:
00045                 DnsblData(const DnsblData& other);//not impl
00046         };
00047         
00048         static DnsblCache* createDnsblCache(const std::string& name,int validity);
00049 
00050         virtual ~DnsblManager()throw(SysError);
00051         DnsblManager(RegKey& regkey)throw(std::runtime_error);
00052         void add(const std::string& name,Result iflisted,const std::string& description="")throw(std::runtime_error);
00053         void add(const std::string& name,const std::map<Url,Result>& resmap,const std::string& description="")throw(std::runtime_error);
00054         void add(const Dnsbl& dnsbl)throw(std::runtime_error);
00055         void edit(const std::string& name,Result iflisted,const std::string& description="")throw(std::runtime_error);
00056         void edit(const std::string& name,const std::map<Url,Result>& resmap,const std::string& desc)throw(std::runtime_error);
00057         void edit(const Dnsbl& dnsbl)throw(std::runtime_error);
00058         void setActive(const std::string& name,bool bActive)throw(std::runtime_error);
00059         bool isActive(const std::string& name)const throw(std::runtime_error);
00060         void addCache(const std::string& name,int hoursofvalidity);
00061         const DnsblCache* getCache(const std::string& name)const throw (std::runtime_error);
00062         void removeCache(const std::string& name);
00063         void remove(const std::string& name)throw(std::runtime_error);
00064         const DnsblData* get(const std::string& name)const;
00065         const std::list<const DnsblData*> getAll()const;
00066         std::list<std::string> getNames()const;
00067         void saveToFile(const std::string& filename)throw(SysError);
00068         void loadFromFile(const std::string& filename)throw(std::runtime_error);
00069 private:
00070         void init()throw(std::runtime_error);
00071         void dnsblDataFromReg(const std::string& name)throw(std::runtime_error);
00072         void save()throw(SysError);
00073         typedef std::map<std::string,DnsblData*> DnsblMap;
00074         DnsblMap m_map;
00075         RegKey m_reg;
00076 };
00077 
00078 #endif // !defined(AFX_DNSBLMANAGER_H__FEAA2C18_5349_4DAF_93D5_6CB5A30C6FA4__INCLUDED_)

Generated on Thu Jun 16 00:13:24 2005 for Abuse! by  doxygen 1.4.3