Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

db::Mailinst Class Reference

#include <Mailinst.h>

Inheritance diagram for db::Mailinst:

Inheritance graph
[legend]
Collaboration diagram for db::Mailinst:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Mailinst (Database &)
 Mailinst (Database &, long)
 Mailinst (Database &, const std::string &)
 Mailinst (Database &, const std::string &host, const std::string &mail, const std::string &rcpt, const std::string &h_from, const std::string &h_to, const std::string &h_subject)
 ~Mailinst ()
void save ()

Public Attributes

long m_id
std::string m_host
std::string m_mail
std::string m_rcpt
std::string m_h_from
std::string m_h_to
std::string m_h_subject
bool m_host_spam
bool m_mail_spam
bool m_from_spam
bool m_subject_spam

Private Member Functions

void Spawn (const std::string &)

Constructor & Destructor Documentation

db::Mailinst::Mailinst Database &   ) 
 

Definition at line 28 of file Mailinst.cpp.

References m_from_spam, m_host_spam, m_mail_spam, and m_subject_spam.

00028 : Table(db) 00029 { 00030 m_new = true; 00031 m_host_spam = false; 00032 m_mail_spam = false; 00033 m_from_spam = false; 00034 m_subject_spam = false; 00035 }

db::Mailinst::Mailinst Database &  ,
long 
 

Definition at line 38 of file Mailinst.cpp.

References Spawn().

00038 : Table(db) 00039 { 00040 std::string sql; 00041 sql = "select * from mailinst where id=" + Utility::l2string(id); 00042 Spawn(sql); 00043 }

db::Mailinst::Mailinst Database &  ,
const std::string & 
 

Definition at line 46 of file Mailinst.cpp.

References Spawn().

00046 : Table(db) 00047 { 00048 Spawn(sql); 00049 }

db::Mailinst::Mailinst Database &  ,
const std::string &  host,
const std::string &  mail,
const std::string &  rcpt,
const std::string &  h_from,
const std::string &  h_to,
const std::string &  h_subject
 

Definition at line 52 of file Mailinst.cpp.

References m_h_from, m_h_subject, m_h_to, m_host, m_mail, m_rcpt, and Spawn().

00057 : Table(db) 00058 { 00059 std::string sql; 00060 sql = "select * from mailinst where host='" + sqlsafe(host) + "' and "; 00061 sql += "mail='" + sqlsafe(mail) + "' and "; 00062 sql += "rcpt='" + sqlsafe(rcpt) + "' and "; 00063 sql += "h_from='" + sqlsafe(h_from) + "' and "; 00064 sql += "h_to='" + sqlsafe(h_to) + "' and "; 00065 sql += "h_subject='" + sqlsafe(h_subject) + "'"; 00066 Spawn(sql); 00067 m_host = host; 00068 m_mail = mail; 00069 m_rcpt = rcpt; 00070 m_h_from = h_from; 00071 m_h_to = h_to; 00072 m_h_subject = h_subject; 00073 }

db::Mailinst::~Mailinst  ) 
 

Definition at line 76 of file Mailinst.cpp.

00077 { 00078 }


Member Function Documentation

void db::Mailinst::save  )  [virtual]
 

Implements db::Table.

Definition at line 123 of file Mailinst.cpp.

References db::Table::GetDatabase(), m_from_spam, m_h_from, m_h_subject, m_h_to, m_host, m_host_spam, m_id, m_mail, m_mail_spam, m_rcpt, and m_subject_spam.

Referenced by SMTPSocket::OnLine().

00124 { 00125 Query q(GetDatabase()); 00126 std::string sql; 00127 if (m_new) 00128 { 00129 sql = "insert into mailinst values(NULL" 00130 ",'" + sqlsafe(m_host) + "'" 00131 ",'" + sqlsafe(m_mail) + "'" 00132 ",'" + sqlsafe(m_rcpt) + "'" 00133 ",'" + sqlsafe(m_h_from) + "'" 00134 ",'" + sqlsafe(m_h_to) + "'" 00135 ",'" + sqlsafe(m_h_subject) + "'"; 00136 sql += m_host_spam ? ",1" : ",0"; 00137 sql += m_mail_spam ? ",1" : ",0"; 00138 sql += m_from_spam ? ",1" : ",0"; 00139 sql += m_subject_spam ? ",1" : ",0"; 00140 sql += ")"; 00141 printf("SQL: '%s'\n",sql.c_str()); 00142 q.execute(sql); 00143 m_id = q.insert_id(); 00144 } 00145 else 00146 { 00147 sql = "update mailinst set " 00148 "host='" + sqlsafe(m_host) + "'," 00149 "mail='" + sqlsafe(m_mail) + "'," 00150 "rcpt='" + sqlsafe(m_rcpt) + "'," 00151 "h_from='" + sqlsafe(m_h_from) + "'," 00152 "h_to='" + sqlsafe(m_h_to) + "'," 00153 "h_subject='" + sqlsafe(m_h_subject) + "',"; 00154 sql += m_host_spam ? "host_spam=1," : "host_spam=0,"; 00155 sql += m_mail_spam ? "mail_spam=1," : "mail_spam=0,"; 00156 sql += m_from_spam ? "from_spam=1," : "from_spam=0,"; 00157 sql += m_subject_spam ? "subject_spam=1 " : "subject_spam=0 "; 00158 sql = sql + "where id=" + Utility::l2string(m_id); 00159 printf("SQL: '%s'\n",sql.c_str()); 00160 q.execute(sql); 00161 } 00162 }

void db::Mailinst::Spawn const std::string &   )  [private, virtual]
 

Implements db::Table.

Definition at line 95 of file Mailinst.cpp.

References db::Table::GetDatabase(), m_from_spam, m_h_from, m_h_subject, m_h_to, m_host, m_host_spam, m_id, m_mail, m_mail_spam, m_rcpt, and m_subject_spam.

Referenced by Mailinst().

00096 { 00097 Query q(GetDatabase()); 00098 m_new = true; 00099 m_host_spam = false; 00100 m_mail_spam = false; 00101 m_from_spam = false; 00102 m_subject_spam = false; 00103 q.get_result(sql); 00104 if (q.fetch_row()) 00105 { 00106 m_id = q.getval(); 00107 m_host = q.getstr(); 00108 m_mail = q.getstr(); 00109 m_rcpt = q.getstr(); 00110 m_h_from = q.getstr(); 00111 m_h_to = q.getstr(); 00112 m_h_subject = q.getstr(); 00113 m_host_spam = q.getval() ? true : false; 00114 m_mail_spam = q.getval() ? true : false; 00115 m_from_spam = q.getval() ? true : false; 00116 m_subject_spam = q.getval() ? true : false; 00117 m_new = false; 00118 } 00119 q.free_result(); 00120 }


Member Data Documentation

bool db::Mailinst::m_from_spam
 

Definition at line 53 of file Mailinst.h.

Referenced by Mailinst(), save(), and Spawn().

std::string db::Mailinst::m_h_from
 

Definition at line 48 of file Mailinst.h.

Referenced by Mailinst(), save(), and Spawn().

std::string db::Mailinst::m_h_subject
 

Definition at line 50 of file Mailinst.h.

Referenced by Mailinst(), save(), and Spawn().

std::string db::Mailinst::m_h_to
 

Definition at line 49 of file Mailinst.h.

Referenced by Mailinst(), save(), and Spawn().

std::string db::Mailinst::m_host
 

Definition at line 45 of file Mailinst.h.

Referenced by Mailinst(), save(), and Spawn().

bool db::Mailinst::m_host_spam
 

Definition at line 51 of file Mailinst.h.

Referenced by Mailinst(), save(), and Spawn().

long db::Mailinst::m_id
 

Definition at line 44 of file Mailinst.h.

Referenced by save(), and Spawn().

std::string db::Mailinst::m_mail
 

Definition at line 46 of file Mailinst.h.

Referenced by Mailinst(), save(), and Spawn().

bool db::Mailinst::m_mail_spam
 

Definition at line 52 of file Mailinst.h.

Referenced by Mailinst(), save(), and Spawn().

std::string db::Mailinst::m_rcpt
 

Definition at line 47 of file Mailinst.h.

Referenced by Mailinst(), save(), and Spawn().

bool db::Mailinst::m_subject_spam
 

Definition at line 54 of file Mailinst.h.

Referenced by Mailinst(), save(), and Spawn().


The documentation for this class was generated from the following files:
Generated for C++ Sockets library example: SMTP Proxy by doxygen 1.3.6

www.TV-friendship.com
The matchmaking service with an all new twist.

Quantum 'Teleportation'
Some thoughts
Page, code, and content Copyright (C) 2004 by Anders Hedström