author | tille <tille> | 2003-05-25 18:19:04 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-25 18:19:04 (UTC) |
commit | 2ec401058a04c15d2725c94d38226d0ac4505496 (patch) (side-by-side diff) | |
tree | bbe34da6b452cb01f31e5a08acf114c8c9641c32 | |
parent | 7e1dce1560e45ef7fad91a8da2d0d96c1b166df9 (diff) | |
download | opie-2ec401058a04c15d2725c94d38226d0ac4505496.zip opie-2ec401058a04c15d2725c94d38226d0ac4505496.tar.gz opie-2ec401058a04c15d2725c94d38226d0ac4505496.tar.bz2 |
saves configured interfaces now
-rw-r--r-- | noncore/settings/networksettings/ppp/TODO | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/accounts.cpp | 40 | ||||
-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 | 17 |
6 files changed, 74 insertions, 74 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 @@ -53,31 +53,18 @@ 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); @@ -172,7 +159,10 @@ 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(); } @@ -184,26 +174,10 @@ void AccountWidget::slotListBoxSelect(int idx) { 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); } } 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 @@ -26,8 +26,13 @@ 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 ); @@ -55,6 +60,9 @@ 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(); 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 @@ -55,13 +55,12 @@ 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) { } @@ -329,7 +328,6 @@ 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){ @@ -804,7 +802,7 @@ int PPPData::newaccount() { } int PPPData::copyaccount(int i) { - +// FIXME // if(highcount >= MAX_ACCOUNTS) return -1; @@ -1221,28 +1219,34 @@ 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 @@ -31,9 +31,10 @@ #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" @@ -58,6 +59,7 @@ class Config; #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" @@ -140,22 +142,14 @@ class Config; #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: @@ -170,6 +164,8 @@ public: 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 &); @@ -189,6 +185,7 @@ public: QString password() const; 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 @@ -10,20 +10,31 @@ */ 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" ); + 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(){ + QMap<QString,QString> ifaces; Interface *i; - for ( i=list.first(); i != 0; i=list.next() ) + 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 |