1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
/*
* sqlacct.h
*
* SQL accounting module for GNU Gatekeeper
*
* Copyright (c) 2004, Michal Zygmuntowicz
* Copyright (c) 2005-2010, Jan Willamowius
*
* This work is published under the GNU Public License version 2 (GPLv2)
* see file COPYING for details.
* We also explicitly grant the right to link this code
* with the OpenH323/H323Plus and OpenSSL library.
*
*/
#ifndef SQLACCT_H
#define SQLACCT_H "@(#) $Id: sqlacct.h,v 1.11 2010/10/25 15:01:51 willamowius Exp $"
#include "gkacct.h"
/** This accounting module stores call information directly to an SQL database.
It uses generic SQL interface, so different SQL backends are supported.
Queries to store accounting information are parametrized using named
parameters.
*/
class GkSQLConnection;
class SQLAcct : public GkAcctLogger
{
public:
enum Constants {
/// events recognized by this module
SQLAcctEvents = AcctStart | AcctUpdate | AcctStop | AcctConnect | AcctAlert | AcctRegister | AcctUnregister
};
/// Create a logger that sends accounting to an SQL database
SQLAcct(
/// name from Gatekeeper::Acct section
const char* moduleName,
/// name for a config section with logger settings
/// pass NULL to use the moduleName as the section name
const char* cfgSecName = NULL
);
/// Destroy the accounting logger
virtual ~SQLAcct();
/** Log call accounting event.
@return
Status of this logging operation (see #Status enum#)
*/
virtual Status Log(
AcctEvent evt, /// accounting event to log
const callptr& call /// additional data for the event
);
/** Log endpoint accounting event.
@return
Status of this logging operation (see #Status enum#)
*/
virtual Status Log(
AcctEvent evt, /// accounting event to log
const endptr& ep /// additional data for the event
);
virtual PString GetInfo();
private:
/* No copy constructor allowed */
SQLAcct(const SQLAcct&);
/* No operator= allowed */
SQLAcct& operator=(const SQLAcct&);
private:
/// connection to the SQL database
GkSQLConnection* m_sqlConn;
/// parametrized query string for the call start event
PString m_startQuery;
/// parametrized alternative query string for the call start event
PString m_startQueryAlt;
/// parametrized query string for the call update event
PString m_updateQuery;
/// parametrized query string for the call stop event
PString m_stopQuery;
/// parametrized alternative query string for the call stop event
PString m_stopQueryAlt;
/// parametrized query string for call alerting
PString m_alertQuery;
/// parametrized query string for endpoint registration
PString m_registerQuery;
/// parametrized query string for endpoint un-registration
PString m_unregisterQuery;
/// timestamp formatting string
PString m_timestampFormat;
};
#endif /* SQLACCT_H */
|