-rw-r--r-- | noncore/settings/networksettings/ppp/TODO | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/accounts.cpp | 42 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppconfig.cpp | 8 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.cpp | 54 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppdata.h | 23 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/pppmodule.cpp | 23 |
6 files changed, 78 insertions, 78 deletions
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO new file mode 100644 index 0000000..2410880 --- a/dev/null +++ b/noncore/settings/networksettings/ppp/TODO @@ -0,0 +1,6 @@ +- impl. PPPData::copyaccount & PPPData::deleteAccount +- update modem attribute inputs when modem has changed +- fix layout of edit account +- save pppd arguments in edit account +- popup configure modem with the correct account prselected + not quite shure why it does not work... IMHO it should work diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp index 19db9ef..11d4739 100644 --- a/noncore/settings/networksettings/ppp/accounts.cpp +++ b/noncore/settings/networksettings/ppp/accounts.cpp @@ -1,463 +1,437 @@ /* * 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 <qdir.h> #include <stdlib.h> #include <qlayout.h> #include <qtabwidget.h> #include <qtabdialog.h> #include <qwhatsthis.h> #include <qmessagebox.h> #include <qapplication.h> #include <qbuttongroup.h> #include <qmessagebox.h> //#include <klocale.h> #define i18n QObject::tr //#include <kglobal.h> //#include <kwin.h> //#include <kdialogbase.h> #include <qvgroupbox.h> #include "pppdata.h" #include "accounts.h" //#include "accounting.h" //#include "providerdb.h" #include "edit.h" void parseargs(char* buf, char** args); AccountWidget::AccountWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) { -// int min = 0; QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); - - // add a hbox -// QHBoxLayout *l11 = new QHBoxLayout; -// l1->addLayout(l11); - accountlist_l = new QListBox(this); -// accountlist_l->setMinimumSize(160, 128); + connect(accountlist_l, SIGNAL(highlighted(int)), this, SLOT(slotListBoxSelect(int))); connect(accountlist_l, SIGNAL(selected(int)), this, SLOT(editaccount())); l1->addWidget(accountlist_l, 10); -// QVBoxLayout *l111 = new QVBoxLayout(this); -// l11->addLayout(l111, 1); edit_b = new QPushButton(i18n("&Edit..."), this); connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account")); - -// min = edit_b->sizeHint().width(); -// min = QMAX(70,min); -// edit_b->setMinimumWidth(min); - l1->addWidget(edit_b); new_b = new QPushButton(i18n("&New..."), this); connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); l1->addWidget(new_b); QWhatsThis::add(new_b, i18n("Create a new dialup connection\n" "to the Internet")); copy_b = new QPushButton(i18n("Co&py"), this); connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); l1->addWidget(copy_b); QWhatsThis::add(copy_b, i18n("Makes a copy of the selected account. All\n" "settings of the selected account are copied\n" "to a new account, that you can modify to fit your\n" "needs")); delete_b = new QPushButton(i18n("De&lete"), this); connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); l1->addWidget(delete_b); QWhatsThis::add(delete_b, i18n("<p>Deletes the selected account\n\n" "<font color=\"red\"><b>Use with care!</b></font>")); QHBoxLayout *l12 = new QHBoxLayout; l1->addStretch(1); l1->addLayout(l12); // QVBoxLayout *l121 = new QVBoxLayout; // l12->addLayout(l121); // l121->addStretch(1); // costlabel = new QLabel(i18n("Phone costs:"), parent); // costlabel->setEnabled(FALSE); // l121->addWidget(costlabel); // costedit = new QLineEdit(parent); // costedit->setFocusPolicy(QWidget::NoFocus); // costedit->setFixedHeight(costedit->sizeHint().height()); // costedit->setEnabled(FALSE); // l121->addWidget(costedit); // l121->addStretch(1); // QString tmp = i18n("<p>This shows the accumulated phone costs\n" // "for the selected account.\n" // "\n" // "<b>Important</b>: If you have more than one \n" // "account - beware, this is <b>NOT</b> the sum \n" // "of the phone costs of all your accounts!"); // QWhatsThis::add(costlabel, tmp); // QWhatsThis::add(costedit, tmp); // vollabel = new QLabel(i18n("Volume:"), parent); // vollabel->setEnabled(FALSE); // l121->addWidget(vollabel); // voledit = new QLineEdit(parent,"voledit"); // voledit->setFocusPolicy(QWidget::NoFocus); // voledit->setFixedHeight(voledit->sizeHint().height()); // voledit->setEnabled(FALSE); // l121->addWidget(voledit); // tmp = i18n("<p>This shows the number of bytes transferred\n" // "for the selected account (not for all of your\n" // "accounts. You can select what to display in\n" // "the accounting dialog.\n" // "\n" // "<a href=\"#volaccounting\">More on volume accounting</a>"); // QWhatsThis::add(vollabel,tmp); // QWhatsThis::add(voledit, tmp); // QVBoxLayout *l122 = new QVBoxLayout; // l12->addStretch(1); // l12->addLayout(l122); // l122->addStretch(1); // reset = new QPushButton(i18n("&Reset..."), parent); // reset->setEnabled(FALSE); // connect(reset, SIGNAL(clicked()), // this, SLOT(resetClicked())); // l122->addWidget(reset); // log = new QPushButton(i18n("&View Logs"), this); // connect(log, SIGNAL(clicked()), // this, SLOT(viewLogClicked())); // l122->addWidget(log); // l122->addStretch(1); //load up account list from gppdata to the list box if(PPPData::data()->count() > 0) { for(int i=0; i <= PPPData::data()->count()-1; i++) { PPPData::data()->setAccountbyIndex(i); accountlist_l->insertItem(PPPData::data()->accname()); } } - slotListBoxSelect(accountlist_l->currentItem()); +// slotListBoxSelect(accountlist_l->currentItem()); + qDebug("setting listview index to %i",PPPData::data()->currentAccountID() ); + accountlist_l->setCurrentItem( PPPData::data()->currentAccountID() ); +// slotListBoxSelect( PPPData::data()->currentAccountID()); l1->activate(); } void AccountWidget::slotListBoxSelect(int idx) { delete_b->setEnabled((bool)(idx != -1)); edit_b->setEnabled((bool)(idx != -1)); copy_b->setEnabled((bool)(idx != -1)); if(idx!=-1) { + qDebug("setting account to %i", idx); QString account = PPPData::data()->accname(); PPPData::data()->setAccountbyIndex(accountlist_l->currentItem()); -// reset->setEnabled(TRUE); -// costlabel->setEnabled(TRUE); -// costedit->setEnabled(TRUE); -// costedit->setText(AccountingBase::getCosts(accountlist_l->text(accountlist_l->currentItem()))); - -// vollabel->setEnabled(TRUE); -// voledit->setEnabled(TRUE); -// int bytes = PPPData::data()->totalBytes(); -// voledit->setText(prettyPrintVolume(bytes)); - PPPData::data()->setAccount(account); - } else{ - // reset->setEnabled(FALSE); -// costlabel->setEnabled(FALSE); -// costedit->setText(""); -// costedit->setEnabled(FALSE); -// vollabel->setEnabled(FALSE); -// voledit->setText(""); -// voledit->setEnabled(FALSE); - } + // PPPData::data()->setAccount(account); + } } // void AccountWidget::viewLogClicked(){ // QApplication::flushX(); // if(fork() == 0) { // setgid(getgid()); // setuid(getuid()); // system("kppplogview -kppp"); // _exit(0); // } // } // void AccountWidget::resetClicked(){ // if(accountlist_l->currentItem() == -1) // return; // // QueryReset dlg(this); // // int what = dlg.exec(); // // if(what && QueryReset::COSTS) { // // emit resetCosts(accountlist_l->text(accountlist_l->currentItem())); // // costedit->setText("0"); // // } // // if(what && QueryReset::VOLUME) { // // emit resetVolume(accountlist_l->text(accountlist_l->currentItem())); // // voledit->setText(prettyPrintVolume(0)); // // } // } void AccountWidget::editaccount() { PPPData::data()->setAccount(accountlist_l->text(accountlist_l->currentItem())); int result = doTab(); if(result == QDialog::Accepted) { accountlist_l->changeItem(PPPData::data()->accname(),accountlist_l->currentItem()); // emit resetaccounts(); PPPData::data()->save(); } } void AccountWidget::newaccount() { if(accountlist_l->count() == MAX_ACCOUNTS) { QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); return; } int result; // int query = QMessageBox::information(this, // i18n("Do you want to use the wizard to create the new account or the " // "standard, dialog-based setup?\n" // "The wizard is easier and sufficient in most cases. If you need " // "very special settings, you might want to try the standard, " // "dialog-based setup."), // i18n("Create New Account"), // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel")); // switch(query) { // case QMessageBox::Yes: // { // if (PPPData::data()->newaccount() == -1) // return; // // ProviderDB pdb(this); // // result = pdb.exec(); // break; // } // case QMessageBox::No: if (PPPData::data()->newaccount() == -1){ qDebug("PPPData::data()->newaccount() == -1"); return; } result = doTab(); // break; // default: // return; // } if(result == QDialog::Accepted) { accountlist_l->insertItem(PPPData::data()->accname()); accountlist_l->setSelected(accountlist_l->findItem(PPPData::data()->accname()), true); // emit resetaccounts(); PPPData::data()->save(); } else PPPData::data()->deleteAccount(); } void AccountWidget::copyaccount() { if(accountlist_l->count() == MAX_ACCOUNTS) { QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); return; } if(accountlist_l->currentItem()<0) { QMessageBox::information(this, "sorry", i18n("No account selected.")); return; } PPPData::data()->copyaccount(accountlist_l->currentItem()); accountlist_l->insertItem(PPPData::data()->accname()); // emit resetaccounts(); PPPData::data()->save(); } void AccountWidget::deleteaccount() { QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?") .arg(accountlist_l->text(accountlist_l->currentItem())); if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes) return; if(PPPData::data()->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) accountlist_l->removeItem(accountlist_l->currentItem()); emit resetaccounts(); PPPData::data()->save(); slotListBoxSelect(accountlist_l->currentItem()); } int AccountWidget::doTab(){ QDialog *dlg = new QDialog( this, "newAccount", true ); QVBoxLayout *layout = new QVBoxLayout( dlg ); layout->setSpacing( 0 ); layout->setMargin( 1 ); tabWindow = new QTabWidget( dlg, "tabWindow" ); layout->addWidget( tabWindow ); bool isnewaccount; if(PPPData::data()->accname().isEmpty()) { dlg->setCaption(i18n("New Account")); isnewaccount = true; } else { QString tit = i18n("Edit Account: "); tit += PPPData::data()->accname(); dlg->setCaption(tit); isnewaccount = false; } dial_w = new DialWidget( tabWindow, isnewaccount, "Dial Setup"); tabWindow->addTab( dial_w, i18n("Dial") ); ip_w = new IPWidget( tabWindow, isnewaccount, i18n("IP Setup")); tabWindow->addTab( ip_w, i18n("IP") ); gateway_w = new GatewayWidget( tabWindow, isnewaccount, i18n("Gateway Setup")); tabWindow->addTab( gateway_w, i18n("Gateway") ); dns_w = new DNSWidget( tabWindow, isnewaccount, i18n("DNS Servers") ); tabWindow->addTab( dns_w, i18n("DNS") ); script_w = new ScriptWidget( tabWindow, isnewaccount, i18n("Edit Login Script")); tabWindow->addTab( script_w, i18n("Login Script") ); ExecWidget *exec_w = new ExecWidget( tabWindow, isnewaccount, i18n("Execute Programs")); tabWindow->addTab( exec_w, i18n("Execute") ); // acct = new AccountingSelector( tabWindow, isnewaccount ); // tabWindow->addTab( acct, i18n("Accounting")); int result = 0; bool ok = false; qDebug("AccountWidget::doTab dlg->showMinimized"); dlg->showMinimized(); while (!ok){ result = dlg->exec(); ok = true; if(result == QDialog::Accepted) { if (script_w->check()) { if(dial_w->save()) { ip_w->save(); dns_w->save(); gateway_w->save(); script_w->save(); exec_w->save(); // acct->save(); } else { QMessageBox::critical(this, "error", i18n( "You must enter a unique\n" "account name")); ok = false; } } else { QMessageBox::critical(this, "error", i18n("Login script has unbalanced " "loop Start/End")); ok = false; } } } delete tabWindow; return result; } QString AccountWidget::prettyPrintVolume(unsigned int n) { int idx = 0; const QString quant[] = {i18n("Byte"), i18n("KB"), i18n("MB"), i18n("GB"), QString::null}; float n1 = n; while(n >= 1024 && quant[idx] != QString::null) { idx++; n /= 1024; } int i = idx; while(i--) n1 = n1 / 1024.0; QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 ); s += " " + quant[idx]; return s; } ///////////////////////////////////////////////////////////////////////////// // // Queries the user what to reset: costs, volume or both // ///////////////////////////////////////////////////////////////////////////// QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); setCaption(i18n("Reset Accounting")); QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); QVGroupBox *f = new QVGroupBox(i18n("What to Reset"), this); QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); // costs = new QCheckBox(i18n("Reset the accumulated phone costs"), f); // costs->setChecked(true); // l1->addWidget(costs); // QWhatsThis::add(costs, i18n("Check this to set the phone costs\n" // "to zero. Typically you'll want to\n" // "do this once a month.")); // volume = new QCheckBox(i18n("Reset volume accounting"), f); // volume->setChecked(true); // l1->addWidget(volume); // QWhatsThis::add(volume, i18n("Check this to set the volume accounting\n" // "to zero. Typically you'll want to do this\n" // "once a month.")); l1->activate(); // this activates the f-layout and sets minimumSize() f->show(); diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp index e2521a6..4c5f7aa 100644 --- a/noncore/settings/networksettings/ppp/pppconfig.cpp +++ b/noncore/settings/networksettings/ppp/pppconfig.cpp @@ -1,69 +1,77 @@ #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" 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; } interface = iface; if (!PPPData::data()->setModemDevice( interface->getInterfaceName() )) PPPData::data()->setModemDevice("/dev/modem"); + qDebug("PPPConfigWidget::PPPConfigWidget"); + qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); if (!PPPData::data()->setAccount( interface->getHardwareName() )) PPPData::data()->setAccount( 0 ); + + qDebug(" PPPData::data()->accname >%s<",PPPData::data()->accname().latin1()); + qDebug(" PPPData::data()->currentAccountID() >%i<",PPPData::data()->currentAccountID()); (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() { + qDebug("PPPConfigWidget::accept"); + qDebug(" PPPData::data()->accname >%s<",PPPData::data()->accname().latin1()); + qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1()); 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/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp index 109e3b7..3f1675c 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp @@ -1,1248 +1,1252 @@ /* * 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), + : modemDeviceGroup(-1), 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), - modemDeviceGroup(-1) + pppderror(0) { } // // 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; } bool PPPData::readListConfig(const QString &group, const QString &key, QStringList &list, char sep) { list.clear(); if (config) { config->setGroup(group); list = config->readListEntry(key, sep); return true; } else return false; } void PPPData::writeConfig(const QString &group, const QString &key, const QString &value) { if (config) { config->setGroup(group); config->writeEntry(key, value); } } void PPPData::writeConfig(const QString &group, const QString &key, int value) { if (config) { config->setGroup(group); config->writeEntry(key, value); } } void PPPData::writeListConfig(const QString &group, const QString &key, QStringList &list, char sep) { if (config) { config->setGroup(group); config->writeEntry(key, list, sep); } } // // functions to set/return general information // QString PPPData::password() const { return passwd; } void PPPData::setPassword(const QString &pw) { passwd = pw; } const QString PPPData::defaultAccount() { return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY); } void PPPData::setDefaultAccount(const QString &n) { writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n); //now set the current account index to the default account setAccount(defaultAccount()); } bool PPPData::get_show_clock_on_caption() { return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true); } void PPPData::set_show_clock_on_caption(bool set) { writeConfig(GENERAL_GRP, SHOWCLOCK_KEY, (int) 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]); } 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) { writeConfig(modemGroup(), TONEDURATION_KEY, n); } int PPPData::busyWait() { return readNumConfig(modemGroup(), BUSYWAIT_KEY, BUSY_WAIT); } void PPPData::setbusyWait(int n) { writeConfig(modemGroup(), BUSYWAIT_KEY, n); } // //Advanced "Modem" dialog // // defaults: InitString=ATZ, InitString1="" etc. const QString PPPData::modemInitStr(int i) { assert(i >= 0 && i < NumInitStrings); if(i == 0) return readConfig(modemGroup(), INITSTR_KEY, "ATZ"); else return readConfig(modemGroup(), INITSTR_KEY + QString::number(i), ""); } void PPPData::setModemInitStr(int i, const QString &n) { assert(i >= 0 && i < NumInitStrings); QString k = INITSTR_KEY + (i > 0 ? QString::number(i) : ""); writeConfig(modemGroup(), k, n); } const QString PPPData::modemInitResp() { return readConfig(modemGroup(), INITRESP_KEY, "OK"); } void PPPData::setModemInitResp(const QString &n) { writeConfig(modemGroup(), INITRESP_KEY, n); } int PPPData::modemPreInitDelay() { return readNumConfig(modemGroup(), PREINITDELAY_KEY, 50); } void PPPData::setModemPreInitDelay(int n) { writeConfig(modemGroup(), PREINITDELAY_KEY, n); } int PPPData::modemInitDelay() { return readNumConfig(modemGroup(), INITDELAY_KEY, 50); } void PPPData::setModemInitDelay(int n) { writeConfig(modemGroup(), INITDELAY_KEY, n); } QString PPPData::modemNoDialToneDetectionStr() { return readConfig(modemGroup(), NODTDETECT_KEY, "ATX3"); } void PPPData::setModemNoDialToneDetectionStr(const QString &n) { writeConfig(modemGroup(), NODTDETECT_KEY, n); } const QString PPPData::modemDialStr() { return readConfig(modemGroup(), DIALSTR_KEY, "ATDT"); } void PPPData::setModemDialStr(const QString &n) { writeConfig(modemGroup(), DIALSTR_KEY, n); } const QString PPPData::modemConnectResp() { return readConfig(modemGroup(), CONNECTRESP_KEY, "CONNECT"); } void PPPData::setModemConnectResp(const QString &n) { writeConfig(modemGroup(), CONNECTRESP_KEY, n); } const QString PPPData::modemBusyResp() { return readConfig(modemGroup(), BUSYRESP_KEY, "BUSY"); } void PPPData::setModemBusyResp(const QString &n) { writeConfig(modemGroup(), BUSYRESP_KEY, n); } const QString PPPData::modemNoCarrierResp() { return readConfig(modemGroup(), NOCARRIERRESP_KEY, "NO CARRIER"); } void PPPData::setModemNoCarrierResp(const QString &n) { writeConfig(modemGroup(), NOCARRIERRESP_KEY, n); } const QString PPPData::modemNoDialtoneResp() { return readConfig(modemGroup(), NODIALTONERESP_KEY, "NO DIALTONE"); } void PPPData::setModemNoDialtoneResp(const QString &n) { writeConfig(modemGroup(), NODIALTONERESP_KEY, n); } const QString PPPData::modemHangupStr() { return readConfig(modemGroup(), HANGUPSTR_KEY, "+++ATH"); } void PPPData::setModemHangupStr(const QString &n) { writeConfig(modemGroup(), HANGUPSTR_KEY, n); } const QString PPPData::modemHangupResp() { return readConfig(modemGroup(), HANGUPRESP_KEY, "OK"); } void PPPData::setModemHangupResp(const QString &n) { writeConfig(modemGroup(), HANGUPRESP_KEY, n); } const QString PPPData::modemAnswerStr() { return readConfig(modemGroup(), ANSWERSTR_KEY, "ATA"); } QString PPPData::volumeOff() { return readConfig(modemGroup(), VOLUME_OFF, "M0L0"); } void PPPData::setVolumeOff(const QString &s) { writeConfig(modemGroup(), VOLUME_OFF, s); } QString PPPData::volumeMedium() { return readConfig(modemGroup(), VOLUME_MEDIUM, "M1L1"); } void PPPData::setVolumeMedium(const QString &s) { writeConfig(modemGroup(), VOLUME_MEDIUM, s); } QString PPPData::volumeHigh() { QString tmp = readConfig(modemGroup(), VOLUME_HIGH, "M1L3"); if(tmp == "M1L4") tmp = "M1L3"; return tmp; } void PPPData::setVolumeHigh(const QString &s) { writeConfig(modemGroup(), VOLUME_HIGH, s); } QString PPPData::volumeInitString() { QString s; switch(volume()) { case 0: s = volumeOff(); break; case 1: s = volumeMedium(); break; case 2: s = volumeHigh(); break; default: s = volumeMedium(); } return s; } int PPPData::volume() { return readNumConfig(modemGroup(), VOLUME_KEY, 1); } void PPPData::setVolume(int i) { writeConfig(modemGroup(), VOLUME_KEY, i); } int PPPData::waitForDialTone() { return readNumConfig(modemGroup(), DIALTONEWAIT_KEY, 1); } void PPPData::setWaitForDialTone(int i) { writeConfig(modemGroup(), DIALTONEWAIT_KEY, i); } void PPPData::setModemAnswerStr(const QString &n) { writeConfig(modemGroup(), ANSWERSTR_KEY, n); } const QString PPPData::modemRingResp() { return readConfig(modemGroup(), RINGRESP_KEY, "RING"); } void PPPData::setModemRingResp(const QString &n) { writeConfig(modemGroup(), RINGRESP_KEY, n); } const QString PPPData::modemAnswerResp() { return readConfig(modemGroup(), ANSWERRESP_KEY, "CONNECT"); } void PPPData::setModemAnswerResp(const QString &n) { writeConfig(modemGroup(), ANSWERRESP_KEY, n); } const QString PPPData::enter() { return readConfig(modemGroup(), ENTER_KEY, "CR"); } void PPPData::setEnter(const QString &n) { writeConfig(modemGroup(), ENTER_KEY, n); } // // functions to set/return account information // //returns number of accounts int PPPData::count() const { return highcount + 1; } bool PPPData::setAccount(const QString &aname) { for(int i = 0; i <= highcount; i++) { setAccountbyIndex(i); if(accname() == aname) { caccount = i; return true; } } return false; } bool PPPData::setAccountbyIndex(int i) { if(i >= 0 && i <= highcount) { caccount = i; cgroup.sprintf("%s%i", ACCOUNT_GRP, i); return true; } return false; } bool PPPData::isUniqueAccname(const QString &n) { int current = caccount; for(int i=0; i <= highcount; i++) { setAccountbyIndex(i); if(accname() == n && i != current) { setAccountbyIndex(current); return false; } } setAccountbyIndex(current); return true; } bool PPPData::deleteAccount() { //FIXME: // if(caccount < 0) return false; // QMap <QString, QString> map; // QMap <QString, QString>::Iterator it; // // set all entries of the current account to "" // map = config->entryMap(cgroup); // it = map.begin(); // while (it != map.end()) { // config->writeEntry(it.key(), ""); // it++; // } // // shift the succeeding accounts // for(int i = caccount+1; i <= highcount; i++) { // setAccountbyIndex(i); // map = config->entryMap(cgroup); // it = map.begin(); // setAccountbyIndex(i-1); // config->setGroup(cgroup); // while (it != map.end()) { // config->writeEntry(it.key(), *it); // it++; // } // } // // make sure the top account is cleared // setAccountbyIndex(highcount); // map = config->entryMap(cgroup); // it = map.begin(); // config->setGroup(cgroup); // while (it.key() != QString::null) { // config->writeEntry(it.key(), ""); // it++; // } // highcount--; // if(caccount > highcount) // caccount = highcount; // setAccountbyIndex(caccount); // return true; } bool PPPData::deleteAccount(const QString &aname) { if(!setAccount(aname)) return false; deleteAccount(); return true; } int PPPData::newaccount() { qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS); if(!config) open(); if (highcount >= MAX_ACCOUNTS) return -1; highcount++; setAccountbyIndex(highcount); setpppdArgumentDefaults(); qDebug("PPPData::newaccount -> %i",caccount); return caccount; } int PPPData::copyaccount(int i) { - +// FIXME // if(highcount >= MAX_ACCOUNTS) return -1; // setAccountbyIndex(i); // QMap <QString, QString> map = config->entryMap(cgroup); // QMap <QString, QString>::ConstIterator it = map.begin(); // QString newname = i18n("%1_copy").arg(accname()); // newaccount(); // while (it != map.end()) { // config->writeEntry(it.key(), *it); // it++; // } // setAccname(newname); // return caccount; } const QString PPPData::accname() { return readConfig(cgroup, NAME_KEY); } void PPPData::setAccname(const QString &n) { if(!cgroup.isNull()) { // are we manipulating the default account's name ? then change it, too. bool def = accname() == defaultAccount(); writeConfig(cgroup, NAME_KEY, n); if (def) setDefaultAccount(n); } } #define SEPARATOR_CHAR '&' QStringList &PPPData::phonenumbers() { readListConfig(cgroup, PHONENUMBER_KEY, phonelist, SEPARATOR_CHAR); return phonelist; } const QString PPPData::phonenumber() { return readConfig(cgroup, PHONENUMBER_KEY); } void PPPData::setPhonenumber(const QString &n) { writeConfig(cgroup, PHONENUMBER_KEY, n); } const QString PPPData::dialPrefix() { return readConfig(cgroup, DIAL_PREFIX_KEY, ""); } void PPPData::setDialPrefix(const QString &s) { writeConfig(cgroup, DIAL_PREFIX_KEY, s); } int PPPData::authMethod() { return readNumConfig(cgroup, AUTH_KEY, 0); } void PPPData::setAuthMethod(int value) { writeConfig(cgroup, AUTH_KEY, value); } const QString PPPData::storedUsername() { return readConfig(cgroup, STORED_USERNAME_KEY, ""); } void PPPData::setStoredUsername(const QString &b) { writeConfig(cgroup, STORED_USERNAME_KEY, b); } const QString PPPData::storedPassword() { return readConfig(cgroup, STORED_PASSWORD_KEY, ""); } void PPPData::setStoredPassword(const QString &b) { writeConfig(cgroup, STORED_PASSWORD_KEY, b); } bool PPPData::storePassword() { return (bool)readNumConfig(cgroup, STORE_PASSWORD_KEY, 1); } const QString PPPData::command_before_connect() { return readConfig(cgroup, BEFORE_CONNECT_KEY); } void PPPData::setCommand_before_connect(const QString &n) { writeConfig(cgroup, BEFORE_CONNECT_KEY, n); } void PPPData::setStorePassword(bool b) { writeConfig(cgroup, STORE_PASSWORD_KEY, (int)b); } const QString PPPData::command_on_connect() { return readConfig(cgroup, COMMAND_KEY); } void PPPData::setCommand_on_connect(const QString &n) { writeConfig(cgroup, COMMAND_KEY, n); } const QString PPPData::command_on_disconnect() { return readConfig(cgroup, DISCONNECT_COMMAND_KEY); } void PPPData::setCommand_on_disconnect(const QString &n) { writeConfig(cgroup, DISCONNECT_COMMAND_KEY, n); } const QString PPPData::command_before_disconnect() { return readConfig(cgroup, BEFORE_DISCONNECT_KEY); } void PPPData::setCommand_before_disconnect(const QString &n) { writeConfig(cgroup, BEFORE_DISCONNECT_KEY, n); } const QString PPPData::ipaddr() { return readConfig(cgroup, IPADDR_KEY); } void PPPData::setIpaddr(const QString &n) { writeConfig(cgroup, IPADDR_KEY, n); } const QString PPPData::subnetmask() { return readConfig(cgroup, SUBNETMASK_KEY); } void PPPData::setSubnetmask(const QString &n) { writeConfig(cgroup, SUBNETMASK_KEY, n); } bool PPPData::autoname() { return (bool) readNumConfig(cgroup, AUTONAME_KEY, false); } void PPPData::setAutoname(bool set) { writeConfig(cgroup, AUTONAME_KEY, (int) set); } bool PPPData::AcctEnabled() { return (bool) readNumConfig(cgroup, ACCTENABLED_KEY, false); } void PPPData::setAcctEnabled(bool set) { writeConfig(cgroup, ACCTENABLED_KEY, (int) set); } int PPPData::VolAcctEnabled() { return readNumConfig(cgroup, VOLACCTENABLED_KEY, 0); } void PPPData::setVolAcctEnabled(int set) { writeConfig(cgroup, VOLACCTENABLED_KEY, set); } const QString PPPData::gateway() { return readConfig(cgroup, GATEWAY_KEY); } 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); // } // void PPPData::setAccountingFile(const QString &n) { // writeConfig(cgroup, ACCTFILE_KEY, n); // } // const QString PPPData::totalCosts() { // return readConfig(cgroup, TOTALCOSTS_KEY); // } // void PPPData::setTotalCosts(const QString &n) { // writeConfig(cgroup, TOTALCOSTS_KEY, n); // } // int PPPData::totalBytes() { // return readNumConfig(cgroup, TOTALBYTES_KEY, 0); // } // 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() { if (modemDeviceGroup<0)qFatal("wrong modem %i",modemDeviceGroup); - return QString("MODEM_GRP_%1").arg(modemDeviceGroup); + return QString("%1_%1").arg(MODEM_GRP).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); -// } +QMap<QString,QString> PPPData::getConfiguredInterfaces() +{ + QMap<QString,QString> ifaces; + int count = readNumConfig( ACCLIST_GRP, ACCOUNTS_COUNT, -1 ); + QString accGrp; + for (int i = 0; i < count; i++){ + accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); + ifaces.insert( readConfig( accGrp, ACOUNTS_DEV, "error" ), + readConfig( accGrp, ACOUNTS_ACC, "error" ) ); + } -// 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); -// } + return ifaces; +} -// 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); -// } +void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces ) +{ + QMap<QString,QString>::Iterator it; + QString accGrp; + int i = 0; + for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){ + accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i); + writeConfig( accGrp, ACOUNTS_DEV, it.key() ); + writeConfig( accGrp, ACOUNTS_ACC, it.data() ); + } + writeConfig( ACCLIST_GRP, ACCOUNTS_COUNT, i ); + +} diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h index 41dfbd8..c1c7e69 100644 --- a/noncore/settings/networksettings/ppp/pppdata.h +++ b/noncore/settings/networksettings/ppp/pppdata.h @@ -1,447 +1,444 @@ /* -*- C++ -*- * * 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. */ #ifndef _PPPDATA_H_ #define _PPPDATA_H_ #include <unistd.h> #include <sys/types.h> +#include <qcolor.h> +#include <qmap.h> #include <qstring.h> #include <qstringlist.h> -#include <qcolor.h> #include "kpppconfig.h" class Config; // string lengths #define PATH_SIZE 120 #define MODEMSTR_SIZE 80 #define ACCNAME_SIZE 50 #define PHONENUMBER_SIZE 60 #define COMMAND_SIZE 255 #define IPADDR_SIZE 15 #define DOMAIN_SIZE 50 #define TIMEOUT_SIZE 60 // // keys for config file // // groups #define GENERAL_GRP "PPP_General" #define MODEM_GRP "PPP_Modem" #define ACCOUNT_GRP "PPP_Account" +#define ACCLIST_GRP "PPP_Accounts_List" //#define GRAPH_GRP "Graph" //#define WINPOS_GRP "WindowPosition" // general #define DEFAULTACCOUNT_KEY "DefaultAccount" #define PPPDVERSION_KEY "pppdVersion" #define PPPDTIMEOUT_KEY "pppdTimeout" #define SHOWCLOCK_KEY "ShowClock" #define SHOWLOGWIN_KEY "ShowLogWindow" #define AUTOREDIAL_KEY "AutomaticRedial" #define DISCONNECT_KEY "DisconnectOnXServerExit" #define QUITONDISCONNECT_KEY "QuitOnDisconnect" #define NUMACCOUNTS_KEY "NumberOfAccounts" #define ID_KEY "ID" // modem #define MODEMDEV_KEY "Device" #define LOCKFILE_KEY "UseLockFile" #define FLOWCONTROL_KEY "FlowControl" #define SPEED_KEY "Speed" #define TIMEOUT_KEY "Timeout" #define TONEDURATION_KEY "ToneDuration" #define BUSYWAIT_KEY "BusyWait" #define INITSTR_KEY "InitString" #define INITRESP_KEY "InitResponse" #define PREINITDELAY_KEY "PreInitDelay" #define INITDELAY_KEY "InitDelay" #define NODTDETECT_KEY "NoDialToneDetection" #define DIALTONEWAIT_KEY "WaitForDialTone" #define DIALSTR_KEY "DialString" #define CONNECTRESP_KEY "ConnectResponse" #define BUSYRESP_KEY "BusyResponse" #define NOCARRIERRESP_KEY "NoCarrierResponse" #define NODIALTONERESP_KEY "NoDialToneResp" #define HANGUPSTR_KEY "HangupString" #define HANGUPRESP_KEY "HangUpResponse" #define ANSWERSTR_KEY "AnswerString" #define RINGRESP_KEY "RingResponse" #define ANSWERRESP_KEY "AnswerResponse" #define ENTER_KEY "Enter" #define ESCAPESTR_KEY "EscapeString" #define ESCAPERESP_KEY "EscapeResponse" #define ESCAPEGUARDTIME_KEY "EscapeGuardTime" #define USECDLINE_KEY "UseCDLine" #define VOLUME_HIGH "VolumeHigh" #define VOLUME_MEDIUM "VolumeMedium" #define VOLUME_OFF "VolumeOff" #define VOLUME_KEY "Volume" // account #define NAME_KEY "Name" #define PHONENUMBER_KEY "Phonenumber" #define DIAL_PREFIX_KEY "DialPrefix" #define AUTH_KEY "Authentication" #define STORED_PASSWORD_KEY "Password" #define STORED_USERNAME_KEY "Username" #define STORE_PASSWORD_KEY "StorePassword" #define BEFORE_CONNECT_KEY "BeforeConnect" #define COMMAND_KEY "Command" #define DISCONNECT_COMMAND_KEY "DisconnectCommand" #define BEFORE_DISCONNECT_KEY "BeforeDisconnect" #define IPADDR_KEY "IPAddr" #define SUBNETMASK_KEY "SubnetMask" #define ACCTENABLED_KEY "AccountingEnabled" #define VOLACCTENABLED_KEY "VolumeAccountingEnabled" #define ACCTFILE_KEY "AccountingFile" #define AUTONAME_KEY "AutoName" #define GATEWAY_KEY "Gateway" #define DEFAULTROUTE_KEY "DefaultRoute" #define DOMAIN_KEY "Domain" #define DNS_KEY "DNS" #define AUTODNS_KEY "AutoDNS" #define EXDNSDISABLED_KEY "ExDNSDisabled" #define SCRIPTCOM_KEY "ScriptCommands" #define SCRIPTARG_KEY "ScriptArguments" #define PPPDARG_KEY "pppdArguments" #define PPP_DEBUG_OPTION "PPPDebug" #define ICONIFY_ON_CONNECT_KEY "iconifyOnConnect" #define DOCKING_KEY "DockIntoPanel" #define TOTALCOSTS_KEY "TotalCosts" #define TOTALBYTES_KEY "TotalBytes" -// graph colors -#define GENABLED "Enabled" -#define GCOLOR_BG "Background" -#define GCOLOR_TEXT "Text" -#define GCOLOR_IN "InBytes" -#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" +// account list +#define ACCOUNTS_COUNT "Accounts_Count" +#define ACOUNTS_DEV "Accounts_Modem" +#define ACOUNTS_ACC "Accounts_Account" class PPPData { public: PPPData(); ~PPPData() {}; static PPPData* data(); enum { NumInitStrings = 2 }; // general functions bool open(); void save(); void cancel(); + QMap<QString,QString> getConfiguredInterfaces(); + void setConfiguredInterfaces( QMap<QString,QString> ); // 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 &); + int currentAccountID() { return caccount; }; 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(); 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 totalCosts(); // void setTotalCosts(const QString &); // 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 &); diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index 3a97535..7cbccc2 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp @@ -1,128 +1,139 @@ #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() { + QMap<QString,QString> ifaces = PPPData::data()->getConfiguredInterfaces(); + QMap<QString,QString>::Iterator it; Interface *iface; - iface = new Interface( 0, "device" ); - iface->setHardwareName( "account" ); - list.append( iface ); + qDebug("getting interfaces"); + for( it = ifaces.begin(); it != ifaces.end(); ++it ){ + qDebug("ifaces %s", it.key().latin1()); + iface = new Interface( 0, it.key() ); + iface->setHardwareName( it.data() ); + list.append( iface ); + } } /** * Delete any interfaces that we own. */ PPPModule::~PPPModule(){ - Interface *i; - for ( i=list.first(); i != 0; i=list.next() ) - delete i; + QMap<QString,QString> ifaces; + Interface *i; + for ( i=list.first(); i != 0; i=list.next() ){ + ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); + delete i; + } + PPPData::data()->setConfiguredInterfaces( ifaces ); + PPPData::data()->save(); } /** * 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( 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; } /** * 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()); Interface *iface; iface = new Interface(); PPPConfigWidget imp(iface, 0, "PPPConfigImp", true); imp.showMaximized(); if(imp.exec() == QDialog::Accepted ){ iface->setModuleOwner( this ); list.append( iface ); return iface; }else { delete iface; iface = 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")); } |