OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / user / gnugk / sqlacct.h
1 /*
2  * sqlacct.h
3  *
4  * SQL accounting module for GNU Gatekeeper
5  *
6  * Copyright (c) 2004, Michal Zygmuntowicz
7  *
8  * This work is published under the GNU Public License (GPL)
9  * see file COPYING for details.
10  * We also explicitely grant the right to link this code
11  * with the OpenH323 library.
12  *
13  * $Log: sqlacct.h,v $
14  * Revision 1.7  2006/04/14 13:56:19  willamowius
15  * call failover code merged
16  *
17  * Revision 1.1.1.1  2005/11/21 20:19:58  willamowius
18  *
19  *
20  * Revision 1.4  2005/11/15 19:52:56  jan
21  * Michal v1 (works, but on in routed, not proxy mode)
22  *
23  * Revision 1.6  2005/03/08 14:31:13  zvision
24  * Support for Connect event added
25  *
26  * Revision 1.5  2005/01/12 17:55:07  willamowius
27  * fix gkip accounting parameter
28  *
29  * Revision 1.4  2005/01/05 15:42:41  willamowius
30  * new accounting event 'connect', parameter substitution unified in parent class
31  *
32  * Revision 1.3  2004/11/10 18:30:41  zvision
33  * Ability to customize timestamp strings
34  *
35  * Revision 1.2  2004/07/09 22:11:36  zvision
36  * SQLAcct module ported from 2.0 branch
37  *
38  * Revision 1.1.2.1  2004/04/23 16:01:16  zvision
39  * New direct SQL accounting module (SQLAcct)
40  *
41  */
42 #ifndef SQLACCT_H
43 #define SQLACCT_H "@(#) $Id: sqlacct.h,v 1.7 2006/04/14 13:56:19 willamowius Exp $"
44
45 #include "gkacct.h"
46
47 /** This accounting module stores call information directly to an SQL database.
48     It uses generic SQL interface, so different SQL backends are supported.
49     Queries to store accounting information are parametrized using named 
50     parameters.
51 */
52 class GkSQLConnection;
53 class SQLAcct : public GkAcctLogger
54 {
55 public:
56         enum Constants {
57                 /// events recognized by this module
58                 SQLAcctEvents = AcctStart | AcctUpdate | AcctStop | AcctConnect
59         };
60         
61         /// Create a logger that sends accounting to an SQL database
62         SQLAcct( 
63                 /// name from Gatekeeper::Acct section
64                 const char* moduleName,
65                 /// name for a config section with logger settings
66                 /// pass NULL to use the moduleName as the section name
67                 const char* cfgSecName = NULL
68                 );
69                 
70         /// Destroy the accounting logger
71         virtual ~SQLAcct();
72
73         /** Log accounting event.
74         
75                 @return
76                 Status of this logging operation (see #Status enum#)
77         */
78         virtual Status Log( 
79                 AcctEvent evt, /// accounting event to log
80                 const callptr& call /// additional data for the event
81                 );
82
83 private:
84         /* No copy constructor allowed */
85         SQLAcct(const SQLAcct&);
86         /* No operator= allowed */
87         SQLAcct& operator=(const SQLAcct&);
88
89 private:
90         /// connection to the SQL database
91         GkSQLConnection* m_sqlConn;
92         /// parametrized query string for the call start event
93         PString m_startQuery;
94         /// parametrized alternative query string for the call start event
95         PString m_startQueryAlt;
96         /// parametrized query string for the call update event
97         PString m_updateQuery;
98         /// parametrized query string for the call stop event
99         PString m_stopQuery;
100         /// parametrized alternative query string for the call stop event
101         PString m_stopQueryAlt;
102         /// timestamp formatting string
103         PString m_timestampFormat;
104 };
105
106 #endif /* SQLACCT_H */