00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef DBPSQL_H
00017 #define DBPSQL_H
00018
00019 using namespace std;
00020
00021 #define DLLIMPORT
00022 #define HAVE_CXX_STRING_HEADER
00023 #define HAVE_NAMESPACE_STD
00024 #include <libpq++.h>
00025
00026 #include "Db.h"
00027 #include "Dns.h"
00028 #include "Logger.h"
00029
00030
00034 class DbPsql : public Db
00035 {
00036 public:
00037
00039 ~DbPsql();
00040
00042 DbPsql(Logger *log, const char *dbname, const char *dbuser,
00043 const char *dbpass);
00044
00045
00047
00049
00051 int addUserAccount(UserAccount *account);
00052
00054 void delUserAccount(int id);
00055
00057 bool accountIdExists(int id);
00058
00060 void modUserAccount(int id, char *field, char *value);
00062 void modUserAccount(int id, char *field, int value);
00063
00064
00066 bool fetchAccountInfo(int id, UserAccount *account);
00067
00069 int findUserAccountIdFromFqdn(const char *fqdn);
00070
00072 unsigned long fetchAcctAddr(int id);
00073
00075
00076
00078 void getActiveAccounts();
00079
00080
00081
00083
00085
00087 void addDnsRecord(int id, const char *dname, DnsRecordType type,
00088 const char *data);
00089
00091 void delDnsRecords(int id);
00092
00094 void delDnsRecord(int id, const char *dname, DnsRecordType type,
00095 const char *data);
00096
00098 void listDnsRecords(int id, std::vector<DnsRecord> &dnsRecordList);
00099
00101 int getNbOfDnsRecords(int accountId, DnsRecordType type);
00102
00103
00107 int pruneActiveAccount(void (*func)(int, unsigned long, time_t));
00108
00109 protected:
00111 int allocateUserAccountId();
00112
00114 PgDatabase *pg;
00115
00116 private:
00118 DbPsql();
00119 };
00120
00121 #endif // DBPSQL_H