summaryrefslogtreecommitdiffstats
path: root/kppp/accounting.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kppp/accounting.cpp')
-rw-r--r--kppp/accounting.cpp94
1 files changed, 47 insertions, 47 deletions
diff --git a/kppp/accounting.cpp b/kppp/accounting.cpp
index e9dcdc4c..76c5f02e 100644
--- a/kppp/accounting.cpp
+++ b/kppp/accounting.cpp
@@ -29,7 +29,7 @@
#include <sys/stat.h>
#include <sys/types.h>
-#include <qdir.h>
+#include <tqdir.h>
#include <kstandarddirs.h>
#include <klocale.h>
@@ -52,8 +52,8 @@ extern PPPData gpppdata;
// Helper functions
//
/////////////////////////////////////////////////////////////////////////////
-static QString timet2qstring(time_t t) {
- QString s;
+static TQString timet2qstring(time_t t) {
+ TQString s;
s.sprintf("%lu", t);
return s;
@@ -67,14 +67,14 @@ static QString timet2qstring(time_t t) {
// accounting is accomplished withing it's derived classes
//
/////////////////////////////////////////////////////////////////////////////
-AccountingBase::AccountingBase(QObject *parent) :
- QObject(parent),
+AccountingBase::AccountingBase(TQObject *parent) :
+ TQObject(parent),
_total(0),
_session(0)
{
- QDate dt = QDate::currentDate();
- LogFileName = QString("%1-%2.log")
- .arg(QDate::shortMonthName(dt.month()))
+ TQDate dt = TQDate::currentDate();
+ LogFileName = TQString("%1-%2.log")
+ .arg(TQDate::shortMonthName(dt.month()))
.arg(dt.year(), 4);
LogFileName = KGlobal::dirs()->saveLocation("appdata", "Log")
@@ -101,8 +101,8 @@ double AccountingBase::session() const {
// set costs back to zero ( typically once per month)
-void AccountingBase::resetCosts(const QString & accountname){
- QString prev_account = gpppdata.accname();
+void AccountingBase::resetCosts(const TQString & accountname){
+ TQString prev_account = gpppdata.accname();
gpppdata.setAccount(accountname);
gpppdata.setTotalCosts("");
@@ -111,8 +111,8 @@ void AccountingBase::resetCosts(const QString & accountname){
}
-void AccountingBase::resetVolume(const QString & accountname){
- QString prev_account = gpppdata.accname();
+void AccountingBase::resetVolume(const TQString & accountname){
+ TQString prev_account = gpppdata.accname();
gpppdata.setAccount(accountname);
gpppdata.setTotalBytes(0);
@@ -121,10 +121,10 @@ void AccountingBase::resetVolume(const QString & accountname){
}
-void AccountingBase::logMessage(QString s, bool newline) {
+void AccountingBase::logMessage(TQString s, bool newline) {
int old_umask = umask(0077);
- QFile f(LogFileName);
+ TQFile f(LogFileName);
bool result = f.open(IO_ReadWrite);
if(result) {
@@ -140,7 +140,7 @@ void AccountingBase::logMessage(QString s, bool newline) {
f.at(f.size());
}
- QCString tmp = s.local8Bit();
+ TQCString tmp = s.local8Bit();
f.writeBlock(tmp, tmp.length());
f.close();
}
@@ -150,13 +150,13 @@ void AccountingBase::logMessage(QString s, bool newline) {
}
-QString AccountingBase::getCosts(const QString & accountname) {
- QString prev_account = gpppdata.accname();
+TQString AccountingBase::getCosts(const TQString & accountname) {
+ TQString prev_account = gpppdata.accname();
gpppdata.setAccount(accountname);
- QString val = gpppdata.totalCosts();
+ TQString val = gpppdata.totalCosts();
// ### currency from rule file
- // QString val = KGlobal::locale()->formatMoney(gpppdata.totalCosts().toDouble(), currency);
+ // TQString val = KGlobal::locale()->formatMoney(gpppdata.totalCosts().toDouble(), currency);
gpppdata.setAccount(prev_account);
@@ -167,7 +167,7 @@ QString AccountingBase::getCosts(const QString & accountname) {
bool AccountingBase::saveCosts() {
if(!_name.isNull() && _name.length() > 0) {
- QString val;
+ TQString val;
val.setNum(total());
gpppdata.setTotalCosts(val);
@@ -180,9 +180,9 @@ bool AccountingBase::saveCosts() {
bool AccountingBase::loadCosts() {
- QString val = gpppdata.totalCosts();
+ TQString val = gpppdata.totalCosts();
- if(val.isNull()) // QString will segfault if isnull and toDouble called
+ if(val.isNull()) // TQString will segfault if isnull and toDouble called
_total = 0.0;
else {
bool ok;
@@ -195,10 +195,10 @@ bool AccountingBase::loadCosts() {
}
-QString AccountingBase::getAccountingFile(const QString &accountname) {
- QString f = "kppp/Rules/";
+TQString AccountingBase::getAccountingFile(const TQString &accountname) {
+ TQString f = "kppp/Rules/";
f += accountname;
- QString d = locate("data", f);
+ TQString d = locate("data", f);
if(d.isNull())
return "";
@@ -212,7 +212,7 @@ QString AccountingBase::getAccountingFile(const QString &accountname) {
// Accounting class for ruleset files
//
/////////////////////////////////////////////////////////////////////////////
-Accounting::Accounting(QObject *parent, PPPStats *st) :
+Accounting::Accounting(TQObject *parent, PPPStats *st) :
AccountingBase(parent),
acct_timer_id(0),
update_timer_id(0),
@@ -226,14 +226,14 @@ bool Accounting::running() const {
}
-void Accounting::timerEvent(QTimerEvent *t) {
+void Accounting::timerEvent(TQTimerEvent *t) {
if(t->timerId() == acct_timer_id) {
double newCosts;
double newLen;
double connect_time = difftime(time(0), start_time);
- rules.getActiveRule(QDateTime::currentDateTime(), connect_time, newCosts, newLen);
+ rules.getActiveRule(TQDateTime::currentDateTime(), connect_time, newCosts, newLen);
if(newLen < 1) { // changed to < 1
slotStop();
return; // no default rule found
@@ -279,13 +279,13 @@ void Accounting::slotStart() {
_lastcosts = 0.0;
_lastlen = 0.0;
_session = rules.perConnectionCosts();
- rules.setStartTime(QDateTime::currentDateTime());
+ rules.setStartTime(TQDateTime::currentDateTime());
acct_timer_id = startTimer(1);
if(UPDATE_TIME > 0)
update_timer_id = startTimer(UPDATE_TIME);
start_time = time(0);
- QString s;
+ TQString s;
s = timet2qstring(start_time);
s += ":";
s += gpppdata.accname();
@@ -305,7 +305,7 @@ void Accounting::slotStop() {
acct_timer_id = 0;
update_timer_id = 0;
- QString s;
+ TQString s;
s.sprintf(":%s:%0.4e:%0.4e:%u:%u\n",
timet2qstring(time(0)).utf8().data(),
session(),
@@ -319,16 +319,16 @@ void Accounting::slotStop() {
}
-bool Accounting::loadRuleSet(const QString & name) {
+bool Accounting::loadRuleSet(const TQString & name) {
if (name.isEmpty()) {
rules.load(""); // delete old rules
return TRUE;
}
- QString d = AccountingBase::getAccountingFile(name);
+ TQString d = AccountingBase::getAccountingFile(name);
- QFileInfo fg(d);
+ TQFileInfo fg(d);
if(fg.exists()) {
int ret = rules.load(d);
_name = rules.name();
@@ -358,7 +358,7 @@ double Accounting::session() const {
-ExecutableAccounting::ExecutableAccounting(PPPStats *st, QObject *parent) :
+ExecutableAccounting::ExecutableAccounting(PPPStats *st, TQObject *parent) :
AccountingBase(parent),
proc(0),
stats(st)
@@ -371,19 +371,19 @@ bool ExecutableAccounting::running() const {
}
-bool ExecutableAccounting::loadRuleSet(const QString &) {
- QString s = AccountingBase::getAccountingFile(gpppdata.accountingFile());
- return (access(QFile::encodeName(s), X_OK) == 0);
+bool ExecutableAccounting::loadRuleSet(const TQString &) {
+ TQString s = AccountingBase::getAccountingFile(gpppdata.accountingFile());
+ return (access(TQFile::encodeName(s), X_OK) == 0);
}
void ExecutableAccounting::gotData(KProcess */*proc*/, char *buffer, int /*buflen*/) {
- QString field[8];
+ TQString field[8];
int nFields = 0;
int pos, last_pos = 0;
// split string
- QString b(buffer);
+ TQString b(buffer);
pos = b.find(':');
while(pos != -1 && nFields < 8) {
field[nFields++] = b.mid(last_pos, pos-last_pos);
@@ -394,8 +394,8 @@ void ExecutableAccounting::gotData(KProcess */*proc*/, char *buffer, int /*bufle
for(int i = 0; i < nFields;i++)
fprintf(stderr, "FIELD[%d] = %s\n", i, field[i].local8Bit().data());
- QString __total, __session;
- QString s(buffer);
+ TQString __total, __session;
+ TQString s(buffer);
int del1, del2, del3;
del1 = s.find(':');
@@ -433,14 +433,14 @@ void ExecutableAccounting::slotStart() {
slotStop(); // just to make sure
loadCosts();
- QString s = AccountingBase::getAccountingFile(gpppdata.accountingFile());
+ TQString s = AccountingBase::getAccountingFile(gpppdata.accountingFile());
proc = new KProcess;
- QString s_total;
+ TQString s_total;
s_total.sprintf("%0.8f", total());
*proc << s << s_total;
- connect(proc, SIGNAL(receivedStdout(KProcess *, char *, int)),
- this, SLOT(gotData(KProcess *, char *, int)));
+ connect(proc, TQT_SIGNAL(receivedStdout(KProcess *, char *, int)),
+ this, TQT_SLOT(gotData(KProcess *, char *, int)));
proc->start();
time_t start_time = time(0);
@@ -460,7 +460,7 @@ void ExecutableAccounting::slotStop() {
delete proc;
proc = 0;
- QString s;
+ TQString s;
s.sprintf(":%s:%0.4e:%0.4e:%u:%u\n",
timet2qstring(time(0)).local8Bit().data(),
session(),