-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 @@ -52,33 +52,20 @@ 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())); @@ -171,9 +158,12 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name ) 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(); } @@ -183,29 +173,13 @@ 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(){ 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 @@ -25,10 +25,15 @@ PPPConfigWidget::PPPConfigWidget( Interface* iface, QWidget *parent, 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 ); @@ -54,8 +59,11 @@ 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 @@ -54,15 +54,14 @@ PPPData* PPPData::data() 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) { } @@ -328,9 +327,8 @@ const QString PPPData::modemDevice() { } 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; @@ -803,9 +801,9 @@ int PPPData::newaccount() { return caccount; } int PPPData::copyaccount(int i) { - +// FIXME // if(highcount >= MAX_ACCOUNTS) return -1; // setAccountbyIndex(i); @@ -1220,29 +1218,35 @@ void PPPData::setpppdError(int 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 @@ -30,11 +30,12 @@ #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; @@ -57,8 +58,9 @@ 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 @@ -139,24 +141,16 @@ class Config; #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(); @@ -169,8 +163,10 @@ public: 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); @@ -188,8 +184,9 @@ public: // 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); 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 @@ -9,21 +9,32 @@ * 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 |