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

DbPsql.h

00001 /* -*- Mode: C++; c-file-style: "stroustrup"; indent-tabs-mode: nil -*- */
00002 /*
00003  * DbPsql.h
00004  *
00005  * $Id: DbPsql.h,v 1.14 2003/04/24 04:44:56 benoit Exp $
00006  *
00007  * Copyright (c) 2000, 2001 Remi Lefebvre <remi@debian.org>
00008  * Copyright (c) 2000 Benoit Joly <benoit@dhis.net>
00009  *
00010  * DDT comes with ABSOLUTELY NO WARRANTY and is licenced under the
00011  * GNU General Public License (version 2 or later). This license
00012  * can be retrieved from http://www.gnu.org/copyleft/gnu.html.
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     // operations on user accounts
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 //    void updateLastAccess(int id);
00076 
00078     void getActiveAccounts();
00079     
00080 
00081 
00083     // dns db opperations //
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

Generated on Tue Sep 13 01:32:46 2005 for DDT Project by  doxygen 1.4.4