00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef DDTMANAGER_H
00021 #define DDTMANAGER_H
00022
00023
00024
00025
00026 #include "global.h"
00027
00028 #include "Logger.h"
00029 #include "Dns.h"
00030 #include "Db.h"
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 class DdtManager
00041 {
00042 public:
00049 DdtManager(Logger *log, Db *db, Dns *dns);
00050
00054 ~DdtManager();
00055
00056
00057
00058
00064 int addUserAccount(UserAccount *account);
00065
00070 void delUserAccount(int id);
00071
00076 void logonUserAccount(int id);
00077
00082 void logoffUserAccount(int id);
00083
00089 void updateIPAddress(int id, unsigned long ip);
00090
00095 void updateTimeStamp(int id);
00096
00101 void modifyUserAccount(UserAccount *account);
00102
00103
00104
00105
00106
00114 void addDnsRecord(int id, const char *dname, DnsRecordType type,
00115 const char *data);
00116
00124 void delDnsRecord(int id, const char *dname, DnsRecordType type,
00125 const char *data);
00126
00132 void delDnsRecords(int id);
00133
00134
00139 void listDnsRecords(int id, std::vector<DnsRecord> &dnsRecordList);
00140
00141
00142
00143 int markOnline(int id, unsigned int ip)
00144 { updateIPAddress(id, ip); return 0; }
00145
00146 int markOffline(int id) { logoffUserAccount(id); return 0; }
00147
00148 int markAlive(int id) { updateTimeStamp(id); return 0; }
00149
00150 bool getAcctInfo (int id, userAccount *account)
00151 {
00152 db->fetchAccountInfo(id, account);
00153 return 0;
00154 }
00155
00156 bool fetchAccountInfo(int id, char *field, char *dest, int length)
00157 {
00158 UserAccount a;
00159 db->fetchAccountInfo(id, &a);
00160
00161 if (strcasecmp(field, "adminPassword") == 0)
00162 strncpy(dest, a.adminPassword, length);
00163 else if (strcasecmp(field, "updatePassword") == 0)
00164 strncpy(dest, a.updatePassword, length);
00165 else if (strcasecmp(field, "contactName") == 0)
00166 strncpy(dest, a.contactName, length);
00167 else if (strcasecmp(field, "contactEmail") == 0)
00168 strncpy(dest, a.contactEmail, length);
00169 else if (strcasecmp(field, "arch") == 0)
00170 strncpy(dest, a.arch, length);
00171 else if (strcasecmp(field, "os") == 0)
00172 strncpy(dest, a.os, length);
00173 else if (strcasecmp(field, "fqdn") == 0)
00174 strncpy(dest, a.fqdn, length);
00175 else if (strcasecmp(field, "ipAddress") == 0)
00176 strncpy(dest, a.ipAddress, length);
00177 else
00178 return false;
00179
00180 return true;
00181 }
00182
00183 int findUserAccountIdFromFqdn(char *fqdn)
00184 {
00185 return db->findUserAccountIdFromFqdn(fqdn);
00186 }
00187
00188 int modUserAccount(int id, char *field, char *value)
00189 {
00190 db->modUserAccount(id, field, value);
00191 return 0;
00192 }
00193
00194 int pruneActiveAccount(void (*func)(int, unsigned long, time_t))
00195 { return db->pruneActiveAccount(func); }
00196
00197 unsigned long fetchAcctAddr(int uid) { return db->fetchAcctAddr(uid); }
00198
00199
00200 protected:
00201 Logger *log;
00202 Db *db;
00203 Dns *dns;
00204
00205
00206 };
00207
00208 #endif // DDTMANAGER_H