-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 @@ -50,37 +50,24 @@ 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" @@ -169,45 +156,32 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name ) 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(); 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 @@ -23,14 +23,19 @@ PPPConfigWidget::PPPConfigWidget( Interface* iface, QWidget *parent, 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" ); @@ -52,12 +57,15 @@ 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(); } 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 @@ -52,19 +52,18 @@ PPPData* PPPData::data() _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 @@ -326,13 +325,12 @@ void PPPData::setpppdTimeout(int 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; @@ -801,13 +799,13 @@ int PPPData::newaccount() { 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); @@ -1218,31 +1216,37 @@ 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 @@ -28,15 +28,16 @@ #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 @@ -55,12 +56,13 @@ class Config; // // 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" @@ -137,28 +139,20 @@ class Config; #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(); @@ -167,12 +161,14 @@ public: // 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 = ','); @@ -186,12 +182,13 @@ public: 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(); 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 @@ -7,25 +7,36 @@ /** * 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){ |