2
* kPPP: A pppd front end for the KDE project
6
* Copyright (C) 1997 Bernd Johannes Wuebben
7
* wuebben@math.cornell.edu
8
* This file contributed by: Mario Weilguni, <mweilguni@sime.com>
11
* This program is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Library General Public
13
* License as published by the Free Software Foundation; either
14
* version 2 of the License, or (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* Library General Public License for more details.
21
* You should have received a copy of the GNU Library General Public
22
* License along with this program; if not, write to the Free
23
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
#ifndef __ACCOUNTING__H__
27
#define __ACCOUNTING__H__
31
#include <QTimerEvent>
32
#include <k3process.h>
37
/////////////////////////////////////////////////////////////////////////////
39
// Accounting base class
41
/////////////////////////////////////////////////////////////////////////////
42
class AccountingBase : public QObject {
45
AccountingBase(QObject *parent);
46
virtual ~AccountingBase();
48
virtual double total() const;
49
virtual double session() const;
51
virtual bool running() const { return false; }
52
virtual bool loadRuleSet(const QString & name) = 0;
55
virtual void slotStart() {}
56
virtual void slotStop() {}
59
void changed(QString total, QString session);
62
void logMessage(const QString &, bool = false);
67
double _total, _session;
72
static void resetCosts(const QString & accountname);
73
static void resetVolume(const QString & accountname);
74
static QString getCosts(const QString & accountname);
75
static QString getAccountingFile(const QString &accountname);
79
/////////////////////////////////////////////////////////////////////////////
81
// Accounting based on ruleset files
83
/////////////////////////////////////////////////////////////////////////////
84
class Accounting : public AccountingBase {
87
Accounting(QObject *parent, PPPStats *st);
89
virtual double total() const;
90
virtual double session() const;
92
virtual bool loadRuleSet(const QString & name);
93
virtual bool running() const;
96
virtual void timerEvent(QTimerEvent *t);
99
virtual void slotStart();
100
virtual void slotStop();
103
void changed(QString total, QString session);
116
/////////////////////////////////////////////////////////////////////////////
118
// Accounting based on executable files
120
/////////////////////////////////////////////////////////////////////////////
121
class ExecutableAccounting : public AccountingBase {
124
explicit ExecutableAccounting(PPPStats *st, QObject *parent = 0);
126
virtual bool loadRuleSet(const QString & );
127
virtual bool running() const;
130
virtual void slotStart();
131
virtual void slotStop();
134
void gotData(K3Process *proc, char *buffer, int buflen);
137
void changed(QString total, QString session);