summaryrefslogtreecommitdiff
authortille <tille>2003-05-25 14:25:23 (UTC)
committer tille <tille>2003-05-25 14:25:23 (UTC)
commit61c6231cdcde59f8a3ecff31b9fab37f7e9d8852 (patch) (side-by-side diff)
tree4724031209e2263c872ad6160ea61a793f09ed1e
parentefa6dfa3428746451dd5a9b5e1ba57806ae96dba (diff)
downloadopie-61c6231cdcde59f8a3ecff31b9fab37f7e9d8852.zip
opie-61c6231cdcde59f8a3ecff31b9fab37f7e9d8852.tar.gz
opie-61c6231cdcde59f8a3ecff31b9fab37f7e9d8852.tar.bz2
save device specific settings
Diffstat (more/less context) (show 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.cpp15
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.h4
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp52
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h16
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp18
7 files changed, 120 insertions, 99 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
@@ -249,87 +249,87 @@ void ConWindow::startClock() {
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();
}
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());
-
+ 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
@@ -47,33 +47,34 @@ PPPData* PPPData::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;
@@ -314,34 +315,42 @@ bool PPPData::pppdVersionMin(int ver, int mod, int 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) {
+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=
@@ -1080,59 +1089,59 @@ void PPPData::setScriptType(QStringList &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);
}
@@ -1198,33 +1207,34 @@ bool PPPData::pppdRunning() const {
}
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) {
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
@@ -228,33 +228,33 @@ public:
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);
@@ -406,63 +406,63 @@ public:
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
@@ -43,33 +43,34 @@ QString PPPModule::getPixmapName(Interface* ){
/**
* 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);
return information;
}
@@ -81,44 +82,45 @@ QWidget *PPPModule::information(Interface *i){
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() );
+ 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"));
}