-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 @@ -54,13 +54,7 @@ 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))); @@ -69,14 +63,7 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name ) 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); @@ -173,5 +160,8 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name ) } - 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(); @@ -185,25 +175,9 @@ void AccountWidget::slotListBoxSelect(int idx) { 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); + } } 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 @@ -27,6 +27,11 @@ PPPConfigWidget::PPPConfigWidget( Interface* iface, QWidget *parent, 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; @@ -56,4 +61,7 @@ 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() ); 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 @@ -56,11 +56,10 @@ PPPData* PPPData::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) { } @@ -330,5 +329,4 @@ const QString PPPData::modemDevice() { bool PPPData::setModemDevice(const QString &n) { - //FIXME: change modem group bool ret = false; for (int i = 0; devices[i]; i++) @@ -805,5 +803,5 @@ int PPPData::newaccount() { int PPPData::copyaccount(int i) { - +// FIXME // if(highcount >= MAX_ACCOUNTS) return -1; @@ -1222,27 +1220,33 @@ 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 @@ -32,7 +32,8 @@ #include <sys/types.h> +#include <qcolor.h> +#include <qmap.h> #include <qstring.h> #include <qstringlist.h> -#include <qcolor.h> #include "kpppconfig.h" @@ -59,4 +60,5 @@ class Config; #define MODEM_GRP "PPP_Modem" #define ACCOUNT_GRP "PPP_Account" +#define ACCLIST_GRP "PPP_Accounts_List" //#define GRAPH_GRP "Graph" //#define WINPOS_GRP "WindowPosition" @@ -141,20 +143,12 @@ class Config; #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 { @@ -171,4 +165,6 @@ public: void cancel(); + QMap<QString,QString> getConfiguredInterfaces(); + void setConfiguredInterfaces( QMap<QString,QString> ); // function to read/write date to configuration file @@ -190,4 +186,5 @@ public: void setPassword(const QString &); + int currentAccountID() { return caccount; }; const QString defaultAccount(); void setDefaultAccount(const QString &); 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 @@ -11,8 +11,14 @@ 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 ); + } } @@ -21,7 +27,12 @@ PPPModule::PPPModule() : Module() */ 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(); } |