summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/conwindow.cpp110
-rw-r--r--noncore/settings/networksettings/ppp/ppp.pro4
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp27
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.h4
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp54
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h16
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp24
7 files changed, 130 insertions, 109 deletions
diff --git a/noncore/settings/networksettings/ppp/conwindow.cpp b/noncore/settings/networksettings/ppp/conwindow.cpp
index ad89005..20d705d 100644
--- a/noncore/settings/networksettings/ppp/conwindow.cpp
+++ b/noncore/settings/networksettings/ppp/conwindow.cpp
@@ -169,173 +169,173 @@ void ConWindow::accounting(bool on) {
l1->addWidget(timelabel1, 1, 0);
l1->addWidget(timelabel2, 1, 1);
if(accountingEnabled) {
session_bill_l->show();
session_bill->show();
total_bill_l->show();
total_bill->show();
l1->addWidget(session_bill_l, 2, 0);
l1->addWidget(session_bill, 2, 1);
l1->addWidget(total_bill_l, 3, 0);
l1->addWidget(total_bill, 3, 1);
if(volumeAccountingEnabled) {
vollabel->show();
volinfo->show();
l1->addWidget(vollabel, 4, 0);
l1->addWidget(volinfo, 4, 1);
} else {
vollabel->hide();
volinfo->hide();
}
} else {
session_bill_l->hide();
session_bill->hide();
total_bill_l->hide();
total_bill->hide();
if(volumeAccountingEnabled) {
vollabel->show();
volinfo->show();
l1->addWidget(vollabel, 2, 0);
l1->addWidget(volinfo, 2, 1);
} else {
vollabel->hide();
volinfo->hide();
}
}
tl->addSpacing(10);
QVBoxLayout *l2 = new QVBoxLayout(5);
tl->addLayout(l2);
l2->addStretch(1);
// l2->addWidget(statsbutton);
l2->addWidget(cancelbutton);
l2->addStretch(1);
tl1->addSpacing(5);
setFixedSize(sizeHint());
/*
do not overwrite position read from config
setGeometry((QApplication::desktop()->width() - width()) / 2,
(QApplication::desktop()->height() - height())/2,
width(),
height());
*/
}
void ConWindow::dock() {
// DockWidget::dock_widget->show();
this->hide();
}
void ConWindow::startClock() {
minutes = 0;
seconds = 0;
hours = 0;
QString title ;
title = PPPData::data()->accname();
if(PPPData::data()->get_show_clock_on_caption()){
title += " 00:00" ;
}
this->setCaption(title);
timelabel2->setText("00:00:00");
clocktimer->start(1000);
}
void ConWindow::setConnectionSpeed(const QString &speed) {
info2->setText(speed);
}
void ConWindow::stopClock() {
clocktimer->stop();
}
void ConWindow::timeclick() {
- QString tooltip = i18n("Connection: %1\n"
- "Connected at: %2\n"
- "Time connected: %3")
- .arg(PPPData::data()->accname()).arg(info2->text())
- .arg(time_string2);
-
- if(accountingEnabled)
- tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2")
- .arg(session_bill->text()).arg(total_bill->text());
- // volume accounting
- if(volumeAccountingEnabled) {
-
- volinfo->setEnabled(TRUE);
- int bytes = PPPData::data()->totalBytes();
- volinfo->setText(prettyPrintVolume(bytes));
- }
-
- seconds++;
-
- if(seconds >= 60 ) {
- minutes ++;
- seconds = 0;
- }
-
- if (minutes >= 60){
- minutes = 0;
- hours ++;
- }
-
- if( hours >= 24){
- days ++;
- hours = 0;
- }
-
- time_string.sprintf("%02d:%02d",hours,minutes);
- time_string2 = "";
- if (days)
- time_string2.sprintf("%d d %02d:%02d:%02d",
- days,hours,minutes,seconds);
-
- else
- time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds);
-
- caption_string = PPPData::data()->accname();
- caption_string += " ";
- caption_string += time_string;
-
-
- timelabel2->setText(time_string2);
-
- if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){
- // we update the Caption only once per minute not every second
- // otherwise I get a flickering icon
- this->setCaption(caption_string);
- }
+// QString tooltip = i18n("Connection: %1\n"
+// "Connected at: %2\n"
+// "Time connected: %3")
+// .arg(PPPData::data()->accname()).arg(info2->text())
+// .arg(time_string2);
+
+// if(accountingEnabled)
+// tooltip += i18n("\nSession Bill: %1\nTotal Bill: %2")
+// .arg(session_bill->text()).arg(total_bill->text());
+// // volume accounting
+// if(volumeAccountingEnabled) {
+
+// volinfo->setEnabled(TRUE);
+// int bytes = PPPData::data()->totalBytes();
+// volinfo->setText(prettyPrintVolume(bytes));
+// }
+
+// seconds++;
+
+// if(seconds >= 60 ) {
+// minutes ++;
+// seconds = 0;
+// }
+
+// if (minutes >= 60){
+// minutes = 0;
+// hours ++;
+// }
+
+// if( hours >= 24){
+// days ++;
+// hours = 0;
+// }
+
+// time_string.sprintf("%02d:%02d",hours,minutes);
+// time_string2 = "";
+// if (days)
+// time_string2.sprintf("%d d %02d:%02d:%02d",
+// days,hours,minutes,seconds);
+
+// else
+// time_string2.sprintf("%02d:%02d:%02d",hours,minutes,seconds);
+
+// caption_string = PPPData::data()->accname();
+// caption_string += " ";
+// caption_string += time_string;
+
+
+// timelabel2->setText(time_string2);
+
+// if(PPPData::data()->get_show_clock_on_caption() && (seconds == 1)){
+// // we update the Caption only once per minute not every second
+// // otherwise I get a flickering icon
+// this->setCaption(caption_string);
+// }
// QToolTip::add(DockWidget::dock_widget, tooltip);
}
void ConWindow::closeEvent( QCloseEvent *e ){
// we don't want to lose the
// conwindow since this is our last connection kppp.
// if we lost it we could only kill the program by hand to get on with life.
e->ignore();
if(PPPData::data()->get_dock_into_panel())
dock();
}
void ConWindow::slotAccounting(QString total, QString session) {
total_bill->setText(total);
session_bill->setText(session);
}
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro
index e3c58d6..ac438dd 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -1,20 +1,20 @@
#TEMPLATE = app
#
TEMPLATE = lib
#CONFIG += qt warn_on release
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/plugins/networksettings
HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h kpppwidget.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h
-# knuminput.h knumvalidator.h
+#
SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp kpppwidget.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp
-#knuminput.cpp knumvalidator.cpp
+#
INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -L../interfaces/ -linterfaces
INTERFACES =
TARGET = pppplugin
VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp
index c0f1fef..e2521a6 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.cpp
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -1,62 +1,69 @@
#include <qlayout.h>
#include <qmessagebox.h>
#include <qtabwidget.h>
#include "accounts.h"
#include "general.h"
+#include "interface.h"
+#include "modem.h"
#include "pppconfig.h"
#include "pppdata.h"
#include "runtests.h"
-#include "modem.h"
-PPPConfigWidget::PPPConfigWidget( QWidget *parent, const char *name,
+PPPConfigWidget::PPPConfigWidget( Interface* iface, QWidget *parent,
+ const char *name,
bool modal, WFlags fl )
: QDialog(parent, name, modal, fl)
{
setCaption(tr("Configure Modem"));
- int result = runTests();
- if(result == TEST_CRITICAL){
- QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") );
- return;
- }
-
-// setFixedSize(sizeHint());
+ int result = runTests();
+ if(result == TEST_CRITICAL){
+ QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") );
+ return;
+ }
- (void)new Modem;
+ interface = iface;
+ if (!PPPData::data()->setModemDevice( interface->getInterfaceName() ))
+ PPPData::data()->setModemDevice("/dev/modem");
+ if (!PPPData::data()->setAccount( interface->getHardwareName() ))
+ PPPData::data()->setAccount( 0 );
+ (void)new Modem;
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 0 );
layout->setMargin( 1 );
tabWindow = new QTabWidget( this, "tabWidget" );
layout->addWidget( tabWindow );
accounts = new AccountWidget( tabWindow, "accounts" );
tabWindow->addTab( accounts, tr("&Accounts") );
modem1 = new ModemWidget( tabWindow, "modem1" );
tabWindow->addTab( modem1, tr("&Device") );
modem2 = new ModemWidget2( tabWindow, "modem2" );
tabWindow->addTab( modem2, tr("&Modem") );
// graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) );
// general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) );
}
PPPConfigWidget::~PPPConfigWidget()
{
}
void PPPConfigWidget::accept()
{
+ interface->setInterfaceName( PPPData::data()->modemDevice() );
+ interface->setHardwareName( PPPData::data()->accname() );
PPPData::data()->save();
QDialog::accept();
}
void PPPConfigWidget::reject()
{
PPPData::data()->cancel();
QDialog::reject();
}
diff --git a/noncore/settings/networksettings/ppp/pppconfig.h b/noncore/settings/networksettings/ppp/pppconfig.h
index ec64878..b324b6d 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.h
+++ b/noncore/settings/networksettings/ppp/pppconfig.h
@@ -1,34 +1,36 @@
#ifndef _PPPCONFIG_H_
#define _PPPCONFIG_H_
#include <qdialog.h>
class QTabWidget;
+class Interface;
class AccountWidget;
class GeneralWidget;
class ModemWidget;
class ModemWidget2;
class PPPConfigWidget : public QDialog {
Q_OBJECT
public:
- PPPConfigWidget( QWidget *parent=0, const char *name=0,
+ PPPConfigWidget( Interface*, QWidget *parent=0, const char *name=0,
bool modal = false, WFlags fl = 0 );
~PPPConfigWidget();
protected slots:
virtual void accept();
virtual void reject();
private:
+ Interface *interface;
QTabWidget *tabWindow;
AccountWidget *accounts;
GeneralWidget *general;
ModemWidget *modem1;
ModemWidget2 *modem2;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index bb1c8ed..109e3b7 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -1,159 +1,160 @@
/*
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "pppdata.h"
#include "runtests.h"
#include "devices.h"
//#include <klocale.h>
#define i18n QObject::tr
#include <qpe/config.h>
#include <qmessagebox.h>
#include <qapplication.h>
// #include <klocale.h>
// #include <kconfig.h>
// #include <kmessagebox.h>
// #include <kapplication.h>
#include <assert.h>
PPPData *PPPData::_data = 0;
Config *PPPData::config = 0;
PPPData* PPPData::data()
{
if (!_data){
qDebug("PPPData::data() creates new Instance");
_data = new PPPData();
}
if (!_data->config){
qDebug("PPPData::data() opens conffile");
_data->open();
}
return _data;
}
PPPData::PPPData()
: //config(0L),
highcount(-1), // start out with no entries
caccount(-1), // set the current account index also
suidprocessid(-1), // process ID of setuid child
pppdisrunning(false),
- pppderror(0)
+ pppderror(0),
+ modemDeviceGroup(-1)
{
}
//
// open configuration file
//
bool PPPData::open() {
qDebug("opening configfile NetworkSetupPPP");
if (config) return true;
config = new Config("NetworkSetupPPP");
highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
if (highcount > MAX_ACCOUNTS)
highcount = MAX_ACCOUNTS;
if(highcount >= 0 && defaultAccount().isEmpty()) {
setAccountbyIndex(0);
setDefaultAccount(accname());
} else if(!setAccount(defaultAccount()))
setDefaultAccount(accname());
// start out with internal debugging disabled
// the user is still free to specify `debug' on his own
setPPPDebug(false);
::pppdVersion(&pppdVer, &pppdMod, &pppdPatch);
return true;
}
//
// save configuration
//
void PPPData::save() {
if (config) {
writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
delete config;
config = 0;
qDebug("worte confi NetworkSetupPPP");
}
if (_data){
delete _data;
_data = 0;
}
}
//
// cancel changes
//
void PPPData::cancel() {
// if (config) {
// config->rollback();
// config->reparseConfiguration();
// }
}
// // currently differentiates between READWRITE and NONE only
// int PPPData::access() const {
// return 1;//config->getConfigState();
// }
// functions to read/write date to configuration file
QString PPPData::readConfig(const QString &group, const QString &key,
const QString &defvalue = "")
{
// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
if (config) {
config->setGroup(group);
return config->readEntry(key, defvalue);
} else
return defvalue;
}
int PPPData::readNumConfig(const QString &group, const QString &key,
int defvalue) {
if (config) {
config->setGroup(group);
return config->readNumEntry(key, defvalue);
} else
return defvalue;
}
@@ -234,194 +235,202 @@ void PPPData::set_show_clock_on_caption(bool set) {
bool PPPData::get_xserver_exit_disconnect() {
return (bool) readNumConfig(GENERAL_GRP, DISCONNECT_KEY, true);
}
void PPPData::setPPPDebug(bool set) {
writeConfig(GENERAL_GRP, PPP_DEBUG_OPTION, (int)set);
}
bool PPPData::getPPPDebug() {
return (bool)readNumConfig(GENERAL_GRP, PPP_DEBUG_OPTION, false);
}
void PPPData::set_xserver_exit_disconnect(bool set) {
writeConfig(GENERAL_GRP, DISCONNECT_KEY, (int) set);
}
bool PPPData::quit_on_disconnect() {
return (bool) readNumConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, false);
}
void PPPData::set_quit_on_disconnect(bool set) {
writeConfig(GENERAL_GRP, QUITONDISCONNECT_KEY, (int) set);
}
bool PPPData::get_show_log_window() {
return (bool) readNumConfig (GENERAL_GRP, SHOWLOGWIN_KEY, false);
}
void PPPData::set_show_log_window(bool set) {
writeConfig(GENERAL_GRP, SHOWLOGWIN_KEY, (int) set);
}
bool PPPData::automatic_redial() {
return (bool) readNumConfig(GENERAL_GRP, AUTOREDIAL_KEY, FALSE);
}
void PPPData::set_automatic_redial(bool set) {
writeConfig(GENERAL_GRP, AUTOREDIAL_KEY, (int) set);
}
bool PPPData::get_iconify_on_connect() {
return (bool) readNumConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, TRUE);
}
void PPPData::set_iconify_on_connect(bool set) {
writeConfig(GENERAL_GRP, ICONIFY_ON_CONNECT_KEY, (int) set);
}
bool PPPData::get_dock_into_panel() {
return (bool) readNumConfig(GENERAL_GRP, DOCKING_KEY, false);
}
void PPPData::set_dock_into_panel(bool set) {
writeConfig(GENERAL_GRP, DOCKING_KEY, (int) set);
}
QString PPPData::pppdVersion() {
return QString("%1.%2.%3").arg(pppdVer).arg(pppdMod).arg(pppdPatch);
}
bool PPPData::pppdVersionMin(int ver, int mod, int patch) {
// check if pppd version fulfills minimum requirement
return (pppdVer > ver
|| (pppdVer == ver && pppdMod > mod)
|| (pppdVer == ver && pppdMod == mod && pppdPatch >= patch));
}
int PPPData::pppdTimeout() {
return readNumConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, PPPD_TIMEOUT);
}
void PPPData::setpppdTimeout(int n) {
writeConfig(GENERAL_GRP, PPPDTIMEOUT_KEY, n);
}
const QString PPPData::modemDevice() {
return readConfig (modemGroup(), MODEMDEV_KEY, devices[DEV_DEFAULT]);
}
-void PPPData::setModemDevice(const QString &n) {
- writeConfig(modemGroup(), MODEMDEV_KEY, n);
+bool PPPData::setModemDevice(const QString &n) {
+ //FIXME: change modem group
+ bool ret = false;
+ for (int i = 0; devices[i]; i++)
+ if (devices[i] == n){
+ modemDeviceGroup = i;
+ writeConfig(modemGroup(), MODEMDEV_KEY, n);
+ ret = true;
+ }
+ return ret;
}
const QString PPPData::flowcontrol() {
return readConfig(modemGroup(), FLOWCONTROL_KEY, "CRTSCTS");
}
void PPPData::setFlowcontrol(const QString &n) {
writeConfig(modemGroup(), FLOWCONTROL_KEY, n);
}
const QString PPPData::speed() {
QString s = readConfig(modemGroup(), SPEED_KEY, "57600");
// undo the damage of a bug in former versions. It left an empty Speed=
// entry in kppprc. kppp did set the serial port to 57600 as default but
// pppd wouldn't receive the speed via the command line.
if(s.toUInt() == 0)
s = "57600";
return s;
}
void PPPData::setSpeed(const QString &n) {
writeConfig(modemGroup(), SPEED_KEY, n);
}
#if 0
void PPPData::setUseCDLine(const int n) {
writeConfig(modemGroup(),USECDLINE_KEY,n);
}
int PPPData::UseCDLine() {
return readNumConfig(modemGroup(),USECDLINE_KEY,0);
}
#endif
const QString PPPData::modemEscapeStr() {
return readConfig(modemGroup(),ESCAPESTR_KEY,"+++");
}
void PPPData::setModemEscapeStr(const QString &n) {
writeConfig(modemGroup(),ESCAPESTR_KEY,n);
}
const QString PPPData::modemEscapeResp() {
return readConfig(modemGroup(),ESCAPERESP_KEY,"OK");
}
void PPPData::setModemEscapeResp(const QString &n) {
writeConfig(modemGroup(),ESCAPERESP_KEY,n);
}
int PPPData::modemEscapeGuardTime() {
return readNumConfig(modemGroup(),ESCAPEGUARDTIME_KEY,50);
}
void PPPData::setModemEscapeGuardTime(int n) {
writeConfig(modemGroup(),ESCAPEGUARDTIME_KEY,n);
}
bool PPPData::modemLockFile() {
return readNumConfig(modemGroup(), LOCKFILE_KEY, 1);
}
void PPPData::setModemLockFile(bool set) {
writeConfig(modemGroup(), LOCKFILE_KEY, set);
}
int PPPData::modemTimeout() {
return readNumConfig(modemGroup(), TIMEOUT_KEY, MODEM_TIMEOUT);
}
void PPPData::setModemTimeout(int n) {
writeConfig(modemGroup(), TIMEOUT_KEY, n);
}
int PPPData::modemToneDuration() {
return readNumConfig(modemGroup(), TONEDURATION_KEY,MODEM_TONEDURATION);
}
void PPPData::setModemToneDuration(int n) {
@@ -1000,239 +1009,240 @@ const QString PPPData::gateway() {
void PPPData::setGateway(const QString &n ) {
writeConfig(cgroup, GATEWAY_KEY, n);
}
bool PPPData::defaultroute() {
// default route is by default 'on'.
return (bool) readNumConfig(cgroup, DEFAULTROUTE_KEY, true);
}
void PPPData::setDefaultroute(bool set) {
writeConfig(cgroup, DEFAULTROUTE_KEY, (int) set);
}
bool PPPData::autoDNS() {
bool set = (bool) readNumConfig(cgroup, AUTODNS_KEY, true);
return (set && PPPData::data()->pppdVersionMin(2, 3, 7));
}
void PPPData::setAutoDNS(bool set) {
writeConfig(cgroup, AUTODNS_KEY, (int) set);
}
void PPPData::setExDNSDisabled(bool set) {
writeConfig(cgroup, EXDNSDISABLED_KEY, (int) set);
}
bool PPPData::exDNSDisabled() {
return (bool) readNumConfig(cgroup, EXDNSDISABLED_KEY,0);
}
QStringList &PPPData::dns() {
static QStringList dnslist;
readListConfig(cgroup, DNS_KEY, dnslist);
while(dnslist.count() > MAX_DNS_ENTRIES)
dnslist.remove(dnslist.last());
return dnslist;
}
void PPPData::setDns(QStringList &list) {
writeListConfig(cgroup, DNS_KEY, list);
}
const QString PPPData::domain() {
return readConfig(cgroup, DOMAIN_KEY);
}
void PPPData::setDomain(const QString &n ) {
writeConfig(cgroup, DOMAIN_KEY, n);
}
QStringList &PPPData::scriptType() {
static QStringList typelist;
readListConfig(cgroup, SCRIPTCOM_KEY, typelist);
while(typelist.count() > MAX_SCRIPT_ENTRIES)
typelist.remove(typelist.last());
return typelist;
}
void PPPData::setScriptType(QStringList &list) {
writeListConfig(cgroup, SCRIPTCOM_KEY, list);
}
QStringList &PPPData::script() {
static QStringList scriptlist;
readListConfig(cgroup, SCRIPTARG_KEY, scriptlist);
while(scriptlist.count() > MAX_SCRIPT_ENTRIES)
scriptlist.remove(scriptlist.last());
return scriptlist;
}
void PPPData::setScript(QStringList &list) {
writeListConfig(cgroup, SCRIPTARG_KEY, list);
}
-const QString PPPData::accountingFile() {
- return readConfig(cgroup, ACCTFILE_KEY);
-}
+// const QString PPPData::accountingFile() {
+// return readConfig(cgroup, ACCTFILE_KEY);
+// }
-void PPPData::setAccountingFile(const QString &n) {
- writeConfig(cgroup, ACCTFILE_KEY, n);
-}
+// void PPPData::setAccountingFile(const QString &n) {
+// writeConfig(cgroup, ACCTFILE_KEY, n);
+// }
-const QString PPPData::totalCosts() {
- return readConfig(cgroup, TOTALCOSTS_KEY);
-}
+// const QString PPPData::totalCosts() {
+// return readConfig(cgroup, TOTALCOSTS_KEY);
+// }
-void PPPData::setTotalCosts(const QString &n) {
- writeConfig(cgroup, TOTALCOSTS_KEY, n);
-}
+// void PPPData::setTotalCosts(const QString &n) {
+// writeConfig(cgroup, TOTALCOSTS_KEY, n);
+// }
-int PPPData::totalBytes() {
- return readNumConfig(cgroup, TOTALBYTES_KEY, 0);
-}
+// int PPPData::totalBytes() {
+// return readNumConfig(cgroup, TOTALBYTES_KEY, 0);
+// }
-void PPPData::setTotalBytes(int n) {
- writeConfig(cgroup, TOTALBYTES_KEY, n);
-}
+// void PPPData::setTotalBytes(int n) {
+// writeConfig(cgroup, TOTALBYTES_KEY, n);
+// }
QStringList &PPPData::pppdArgument() {
static QStringList arglist;
while(arglist.count() > MAX_PPPD_ARGUMENTS)
arglist.remove(arglist.last());
readListConfig(cgroup, PPPDARG_KEY, arglist);
return arglist;
}
void PPPData::setpppdArgument(QStringList &args) {
writeListConfig(cgroup, PPPDARG_KEY, args);
}
void PPPData::setpppdArgumentDefaults() {
QStringList arg;
setpppdArgument(arg);
}
// // graphing widget
// void PPPData::setGraphingOptions(bool enable,
// QColor bg,
// QColor text,
// QColor in,
// QColor out)
// {
// if(config) {
// config->setGroup(GRAPH_GRP);
// config->writeEntry(GENABLED, enable);
// // config->writeEntry(GCOLOR_BG, bg);
// // config->writeEntry(GCOLOR_TEXT, text);
// // config->writeEntry(GCOLOR_IN, in);
// // config->writeEntry(GCOLOR_OUT, out);
// }
// }
// void PPPData::graphingOptions(bool &enable,
// QColor &bg,
// QColor &text,
// QColor &in,
// QColor &out)
// {
// QColor c;
// if(config) {
// config->setGroup(GRAPH_GRP);
// enable = config->readBoolEntry(GENABLED, true);
// bg = Qt::white;
// //bg = config->readColorEntry(GCOLOR_BG, &c);
// text = Qt::black;
// //text = config->readColorEntry(GCOLOR_TEXT, &c);
// in = Qt::blue;
// //in = config->readColorEntry(GCOLOR_IN, &c);
// out = Qt::red;
// //out = config->readColorEntry(GCOLOR_OUT, &c);
// }
// }
// bool PPPData::graphingEnabled() {
// return (bool) readNumConfig(GRAPH_GRP, GENABLED, true);
// }
//
//functions to change/set the child pppd process info
//
bool PPPData::pppdRunning() const {
return pppdisrunning;
}
void PPPData::setpppdRunning(bool set) {
pppdisrunning = set;
}
int PPPData::pppdError() const {
return pppderror;
}
void PPPData::setpppdError(int err) {
pppderror = err;
}
QString PPPData::modemGroup()
{
- return MODEM_GRP;
+ if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup);
+ return QString("MODEM_GRP_%1").arg(modemDeviceGroup);
}
// //
// // window position
// //
// void PPPData::winPosConWin(int& p_x, int& p_y) {
// p_x = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_X, QApplication::desktop()->width()/2-160);
// p_y = readNumConfig(WINPOS_GRP, WINPOS_CONWIN_Y, QApplication::desktop()->height()/2-55);
// }
// void PPPData::setWinPosConWin(int p_x, int p_y) {
// writeConfig(WINPOS_GRP, WINPOS_CONWIN_X, p_x);
// writeConfig(WINPOS_GRP, WINPOS_CONWIN_Y, p_y);
// }
// void PPPData::winPosStatWin(int& p_x, int& p_y) {
// p_x = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_X, QApplication::desktop()->width()/2-160);
// p_y = readNumConfig(WINPOS_GRP, WINPOS_STATWIN_Y, QApplication::desktop()->height()/2-55);
// }
// void PPPData::setWinPosStatWin(int p_x, int p_y) {
// writeConfig(WINPOS_GRP, WINPOS_STATWIN_X, p_x);
// writeConfig(WINPOS_GRP, WINPOS_STATWIN_Y, p_y);
// }
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index c4d7bc3..41dfbd8 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -148,321 +148,321 @@ class Config;
#define GCOLOR_OUT "OutBytes"
// pppd errors
#define E_IF_TIMEOUT 1
#define E_PPPD_DIED 2
// window position
#define WINPOS_CONWIN_X "WindowPositionConWinX"
#define WINPOS_CONWIN_Y "WindowPositionConWinY"
#define WINPOS_STATWIN_X "WindowPositionStatWinX"
#define WINPOS_STATWIN_Y "WindowPositionStatWinY"
class PPPData {
public:
PPPData();
~PPPData() {};
static PPPData* data();
enum { NumInitStrings = 2 };
// general functions
bool open();
void save();
void cancel();
// function to read/write date to configuration file
QString readConfig(const QString &, const QString &, const QString &);
int readNumConfig(const QString &, const QString &, int);
bool readListConfig(const QString &, const QString &,
QStringList &, char sep = ',');
void writeConfig(const QString &, const QString &, const QString &);
void writeConfig(const QString &, const QString &, int);
void writeListConfig(const QString &, const QString &,
QStringList &, char sep = ',');
// return the current account group
QString currentGroup() { return cgroup; }
QString modemGroup();
// functions to set/get general kppp info
QString password() const;
void setPassword(const QString &);
const QString defaultAccount();
void setDefaultAccount(const QString &);
void set_xserver_exit_disconnect(bool set);
bool get_xserver_exit_disconnect();
void setPPPDebug(bool set);
bool getPPPDebug();
void set_quit_on_disconnect(bool);
bool quit_on_disconnect();
void set_show_clock_on_caption(bool set);
bool get_show_clock_on_caption();
void set_show_log_window(bool set);
bool get_show_log_window();
void set_automatic_redial(bool set);
bool automatic_redial();
void set_iconify_on_connect(bool set);
bool get_iconify_on_connect();
void set_dock_into_panel(bool set);
bool get_dock_into_panel();
const QString enter();
void setEnter(const QString &);
QString pppdVersion();
bool pppdVersionMin(int ver, int mod, int patch);
int pppdTimeout();
void setpppdTimeout(int);
int busyWait();
void setbusyWait(int);
bool modemLockFile();
void setModemLockFile(bool set);
int modemEscapeGuardTime();
void setModemEscapeGuardTime(int i);
void setModemEscapeStr(const QString &);
const QString modemEscapeStr();
void setModemEscapeResp(const QString &);
const QString modemEscapeResp();
const QString modemDevice();
- void setModemDevice(const QString &);
+ bool setModemDevice(const QString &);
const QString flowcontrol();
void setFlowcontrol(const QString &);
int modemTimeout();
void setModemTimeout(int);
int modemToneDuration();
void setModemToneDuration(int);
QString volumeInitString();
int volume();
void setVolume(int);
int waitForDialTone();
void setWaitForDialTone(int i);
// modem command strings/responses
const QString modemInitStr(int i);
void setModemInitStr(int i, const QString &);
const QString modemInitResp();
void setModemInitResp(const QString &);
int modemPreInitDelay();
void setModemPreInitDelay(int);
int modemInitDelay();
void setModemInitDelay(int);
QString modemNoDialToneDetectionStr();
void setModemNoDialToneDetectionStr(const QString &);
const QString modemDialStr();
void setModemDialStr(const QString &);
const QString modemConnectResp();
void setModemConnectResp(const QString &);
const QString modemBusyResp();
void setModemBusyResp(const QString &);
const QString modemNoCarrierResp();
void setModemNoCarrierResp(const QString &);
const QString modemNoDialtoneResp();
void setModemNoDialtoneResp(const QString &);
const QString modemHangupStr();
void setModemHangupStr(const QString &);
const QString modemHangupResp();
void setModemHangupResp(const QString &);
const QString modemAnswerStr();
void setModemAnswerStr(const QString &);
const QString modemRingResp();
void setModemRingResp(const QString &);
const QString modemAnswerResp();
void setModemAnswerResp(const QString &);
QString volumeOff();
void setVolumeOff(const QString &);
QString volumeMedium();
void setVolumeMedium(const QString &);
QString volumeHigh();
void setVolumeHigh(const QString &);
#if 0
void setUseCDLine(const int n);
int UseCDLine();
#endif
// functions to set/get account information
int count() const;
bool setAccount(const QString &);
bool setAccountbyIndex(int);
bool isUniqueAccname(const QString &);
bool deleteAccount();
bool deleteAccount(const QString &);
int newaccount();
int copyaccount(int i);
const QString accname();
void setAccname(const QString &);
QStringList &phonenumbers();
const QString phonenumber();
void setPhonenumber(const QString &);
const QString dialPrefix();
void setDialPrefix(const QString &);
int authMethod();
void setAuthMethod(int);
const QString storedUsername();
void setStoredUsername(const QString &);
const QString storedPassword();
void setStoredPassword(const QString &);
bool storePassword();
void setStorePassword(bool);
const QString speed();
void setSpeed(const QString &);
const QString command_before_connect();
void setCommand_before_connect(const QString &);
const QString command_on_connect();
void setCommand_on_connect(const QString &);
const QString command_on_disconnect();
void setCommand_on_disconnect(const QString &);
const QString command_before_disconnect();
void setCommand_before_disconnect(const QString &);
const QString ipaddr();
void setIpaddr(const QString &);
const QString subnetmask();
void setSubnetmask(const QString &);
bool AcctEnabled();
void setAcctEnabled(bool set);
int VolAcctEnabled();
void setVolAcctEnabled(int set);
bool autoDNS();
void setAutoDNS(bool set);
bool exDNSDisabled();
void setExDNSDisabled(bool set);
bool autoname();
void setAutoname(bool set);
const QString gateway();
void setGateway(const QString &);
bool defaultroute();
void setDefaultroute(bool set);
QStringList &dns();
void setDns(QStringList &);
const QString domain();
void setDomain(const QString &);
QStringList &scriptType();
void setScriptType(QStringList &);
QStringList &script();
void setScript(QStringList &);
QStringList &pppdArgument();
void setpppdArgumentDefaults();
void setpppdArgument(QStringList &);
//functions to change/set the child pppd process info
bool pppdRunning() const;
void setpppdRunning(bool set);
int pppdError() const;
void setpppdError(int err);
// functions to set/query the accounting info
- const QString accountingFile();
- void setAccountingFile(const QString &);
+// const QString accountingFile();
+// void setAccountingFile(const QString &);
- const QString totalCosts();
- void setTotalCosts(const QString &);
+// const QString totalCosts();
+// void setTotalCosts(const QString &);
- int totalBytes();
- void setTotalBytes(int);
+// int totalBytes();
+// void setTotalBytes(int);
// // graphing widget
// void setGraphingOptions(bool enabled,
// QColor bg,
// QColor text,
// QColor in,
// QColor out);
// void graphingOptions(bool &enabled,
// QColor &bg,
// QColor &text,
// QColor &in,
// QColor &out);
// bool graphingEnabled();
// // window positions
// void winPosConWin(int &, int &);
// void setWinPosConWin(int, int);
// void winPosStatWin(int &, int &);
// void setWinPosStatWin(int, int);
private:
static PPPData *_data;
-
+ int modemDeviceGroup;
QString passwd;
static Config* config; // configuration object
int highcount; // index of highest account
int caccount; // index of the current account
QString cgroup; // name of current config group
pid_t suidprocessid; // process ID of setuid child
bool pppdisrunning; // pppd process
// daemon
int pppderror; // error encounterd running pppd
int pppdVer, pppdMod, pppdPatch; // pppd version
QStringList phonelist;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index fb2f3e5..3a97535 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,126 +1,128 @@
#include "pppconfig.h"
#include "pppmodule.h"
#include "pppdata.h"
#include "kpppwidget.h"
#include "interfaceinformationimp.h"
//#include "devices.h"
/**
* Constructor, find all of the possible interfaces
*/
PPPModule::PPPModule() : Module()
{
Interface *iface;
iface = new Interface( 0, "device" );
iface->setHardwareName( "account" );
list.append( iface );
}
/**
* Delete any interfaces that we own.
*/
PPPModule::~PPPModule(){
Interface *i;
for ( i=list.first(); i != 0; i=list.next() )
delete i;
}
/**
* Change the current profile
*/
void PPPModule::setProfile(const QString &newProfile){
profile = newProfile;
}
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
* @return QString the icon name (minus .png, .gif etc)
*/
QString PPPModule::getPixmapName(Interface* ){
return "ppp";
}
/**
* Check to see if the interface i is owned by this module.
* @param Interface* interface to check against
* @return bool true if i is owned by this module, false otherwise.
*/
bool PPPModule::isOwner(Interface *i){
return list.find( i ) != -1;
}
/**
* Create, and return the WLANConfigure Module
* @return QWidget* pointer to this modules configure.
*/
QWidget *PPPModule::configure(Interface *i){
qDebug("return ModemWidget");
- PPPConfigWidget *pppconfig = new PPPConfigWidget( 0, "PPPConfig", false,
+ PPPConfigWidget *pppconfig = new PPPConfigWidget( i, 0, "PPPConfig",
+ false,
Qt::WDestructiveClose );
return pppconfig;
}
/**
* Create, and return the Information Module
* @return QWidget* pointer to this modules info.
*/
QWidget *PPPModule::information(Interface *i){
// We don't have any advanced pppd information widget yet :-D
// TODO ^
qDebug("return PPPModule::information");
- InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i);
+ InterfaceInformationImp *information = new InterfaceInformationImp( 0, "InterfaceSetupImp", i);
return information;
}
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
*/
QList<Interface> PPPModule::getInterfaces(){
// List all of the files in the peer directory
qDebug("PPPModule::getInterfaces");
return list;
}
/**
* Attempt to add a new interface as defined by name
* @param name the name of the type of interface that should be created given
* by possibleNewInterfaces();
* @return Interface* NULL if it was unable to be created.
*/
Interface *PPPModule::addNewInterface(const QString &newInterface){
qDebug("try to add iface %s",newInterface.latin1());
- PPPConfigWidget imp(0, "PPPConfigImp", true);
+ Interface *iface;
+ iface = new Interface();
+ PPPConfigWidget imp(iface, 0, "PPPConfigImp", true);
imp.showMaximized();
if(imp.exec() == QDialog::Accepted ){
- qDebug("ACCEPTED");
- PPPData::data()->save();
- Interface *iface;
- iface = new Interface( 0, PPPData::data()->modemDevice() );
- iface->setHardwareName( PPPData::data()->accname() );
- list.append( iface );
- return iface;
+ iface->setModuleOwner( this );
+ list.append( iface );
+ return iface;
+ }else {
+ delete iface;
+ iface = NULL;
}
- return NULL;
+ return iface;
}
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.
*/
bool PPPModule::remove(Interface*){
// Can't remove a hardware device, you can stop it though.
return false;
}
void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces)
{
newIfaces.insert(QObject::tr("PPP") ,
QObject::tr("generic ppp device"));
}