summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/accounts.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/ppp/accounts.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp59
1 files changed, 15 insertions, 44 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index f704c84..7760d5e 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -16,159 +16,131 @@
*
* 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 <qvgroupbox.h>
-#include "pppdata.h"
#include "accounts.h"
+#include "authwidget.h"
+#include "pppdata.h"
#include "edit.h"
void parseargs(char* buf, char** args);
AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name )
- : QWidget( parent, name ), _pppdata(pd)
+ : QWidget( parent, name )//, _pppdata(pd)
{
+ _pppdata = pd;
QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
accountlist_l = new QListBox(this);
connect(accountlist_l, SIGNAL(highlighted(int)),
this, SLOT(slotListBoxSelect(int)));
connect(accountlist_l, SIGNAL(selected(int)),
this, SLOT(editaccount()));
l1->addWidget(accountlist_l, 10);
edit_b = new QPushButton(tr("&Edit..."), this);
connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
l1->addWidget(edit_b);
new_b = new QPushButton(tr("&New..."), this);
connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
l1->addWidget(new_b);
QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
"to the Internet"));
copy_b = new QPushButton(tr("Co&py"), this);
connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount()));
l1->addWidget(copy_b);
QWhatsThis::add(copy_b,
tr("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(tr("De&lete"), this);
connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount()));
l1->addWidget(delete_b);
QWhatsThis::add(delete_b,
tr("<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);
+ int currAccId = _pppdata->currentAccountID();
+ qDebug("currentAccountID %i", currAccId);
+
//load up account list from gppdata to the list box
if(_pppdata->count() > 0) {
for(int i=0; i <= _pppdata->count()-1; i++) {
_pppdata->setAccountbyIndex(i);
accountlist_l->insertItem(_pppdata->accname());
}
}
-
+ _pppdata->setAccountbyIndex( currAccId );
qDebug("setting listview index to %i",_pppdata->currentAccountID() );
accountlist_l->setCurrentItem( _pppdata->currentAccountID() );
- slotListBoxSelect( _pppdata->currentAccountID());
+ slotListBoxSelect( _pppdata->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->accname();
_pppdata->setAccountbyIndex(accountlist_l->currentItem());
- // _pppdata->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->setAccount(accountlist_l->text(accountlist_l->currentItem()));
int result = doTab();
if(result == QDialog::Accepted) {
accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem());
// emit resetaccounts();
_pppdata->save();
}
}
void AccountWidget::newaccount() {
if(accountlist_l->count() == MAX_ACCOUNTS) {
QMessageBox::information(this, "sorry",
tr("Maximum number of accounts reached."));
return;
}
int result;
if (_pppdata->newaccount() == -1){
qDebug("_pppdata->newaccount() == -1");
@@ -228,88 +200,87 @@ int AccountWidget::doTab(){
QDialog *dlg = new QDialog( 0, "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->accname().isEmpty()) {
dlg->setCaption(tr("New Account"));
isnewaccount = true;
} else {
QString tit = tr("Edit Account: ");
tit += _pppdata->accname();
dlg->setCaption(tit);
isnewaccount = false;
}
// // DIAL WIDGET
dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
tabWindow->addTab( dial_w, tr("Dial") );
+// // AUTH WIDGET
+ auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
+ tabWindow->addTab( auth_w, tr("Authentication") );
+
// // IP WIDGET
ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup"));
tabWindow->addTab( ip_w, tr("IP") );
// // GATEWAY WIDGET
gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup"));
tabWindow->addTab( gateway_w, tr("Gateway") );
// // DNS WIDGET
dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") );
tabWindow->addTab( dns_w, tr("DNS") );
-// // SCRIPT WIDGET
- script_w = new ScriptWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
- tabWindow->addTab( script_w, tr("Login Script") );
-
// // EXECUTE WIDGET
ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs"));
tabWindow->addTab( exec_w, tr("Execute") );
int result = 0;
bool ok = false;
while (!ok){
// dlg->showMinimized();
result = dlg->exec();
ok = true;
if(result == QDialog::Accepted) {
- if (!script_w->check()){
- QMessageBox::critical(this, "error", tr("<qt>Login script has unbalanced loop Start/End<qt>"));
+ if (!auth_w->check()){
ok = false;
} else if(!dial_w->save()) {
QMessageBox::critical(this, "error", tr( "You must enter a unique account name"));
ok = false;
}else{
ip_w->save();
dns_w->save();
gateway_w->save();
- script_w->save();
+ auth_w->save();
exec_w->save();
}
}
}
delete dlg;
return result;
}
QString AccountWidget::prettyPrintVolume(unsigned int n) {
int idx = 0;
const QString quant[] = {tr("Byte"), tr("KB"),
tr("MB"), tr("GB"), QString::null};
float n1 = n;
while(n >= 1024 && quant[idx] != QString::null) {
idx++;
n /= 1024;
}
int i = idx;
while(i--)