summaryrefslogtreecommitdiff
authortille <tille>2003-06-02 14:10:31 (UTC)
committer tille <tille>2003-06-02 14:10:31 (UTC)
commitc74e5cd0fc051750c3d88cba0178f62b8ce3b5bb (patch) (side-by-side diff)
tree6a546f05d112ef9b2fb7575d4b49cfc5de4c3d52
parent2d0134f0bee1c0d33fc8cdc66ecc390080adba25 (diff)
downloadopie-c74e5cd0fc051750c3d88cba0178f62b8ce3b5bb.zip
opie-c74e5cd0fc051750c3d88cba0178f62b8ce3b5bb.tar.gz
opie-c74e5cd0fc051750c3d88cba0178f62b8ce3b5bb.tar.bz2
layout fixes and cleanup
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/TODO1
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp375
-rw-r--r--noncore/settings/networksettings/ppp/accounts.h58
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp164
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp2
5 files changed, 242 insertions, 358 deletions
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO
index 1136c2d..9425628 100644
--- a/noncore/settings/networksettings/ppp/TODO
+++ b/noncore/settings/networksettings/ppp/TODO
@@ -1,7 +1,8 @@
- add possibility to input username and password ;)
- 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
+- remove interfaces
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index 3fa2f84..f704c84 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -1,469 +1,384 @@
/*
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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 <klocale.h>
-#define i18n QObject::tr
-//#include <kglobal.h>
-//#include <kwin.h>
-//#include <kdialogbase.h>
#include <qvgroupbox.h>
#include "pppdata.h"
#include "accounts.h"
-//#include "accounting.h"
-//#include "providerdb.h"
#include "edit.h"
void parseargs(char* buf, char** args);
AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name )
: QWidget( parent, name ), _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(i18n("&Edit..."), this);
+ edit_b = new QPushButton(tr("&Edit..."), this);
connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
- QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account"));
+ QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
l1->addWidget(edit_b);
- new_b = new QPushButton(i18n("&New..."), this);
+ new_b = new QPushButton(tr("&New..."), this);
connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
l1->addWidget(new_b);
- QWhatsThis::add(new_b, i18n("Create a new dialup connection\n"
+ QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
"to the Internet"));
- copy_b = new QPushButton(i18n("Co&py"), this);
+ copy_b = new QPushButton(tr("Co&py"), this);
connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount()));
l1->addWidget(copy_b);
QWhatsThis::add(copy_b,
- i18n("Makes a copy of the selected account. All\n"
+ 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(i18n("De&lete"), this);
+ delete_b = new QPushButton(tr("De&lete"), this);
connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount()));
l1->addWidget(delete_b);
QWhatsThis::add(delete_b,
- i18n("<p>Deletes the selected account\n\n"
+ 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);
-// QVBoxLayout *l121 = new QVBoxLayout;
-// l12->addLayout(l121);
-// l121->addStretch(1);
- // costlabel = new QLabel(i18n("Phone costs:"), parent);
-// costlabel->setEnabled(FALSE);
-// l121->addWidget(costlabel);
-
-// costedit = new QLineEdit(parent);
-// costedit->setFocusPolicy(QWidget::NoFocus);
-// costedit->setFixedHeight(costedit->sizeHint().height());
-// costedit->setEnabled(FALSE);
-// l121->addWidget(costedit);
-// l121->addStretch(1);
-// QString tmp = i18n("<p>This shows the accumulated phone costs\n"
-// "for the selected account.\n"
-// "\n"
-// "<b>Important</b>: If you have more than one \n"
-// "account - beware, this is <b>NOT</b> the sum \n"
-// "of the phone costs of all your accounts!");
-// QWhatsThis::add(costlabel, tmp);
-// QWhatsThis::add(costedit, tmp);
-
-// vollabel = new QLabel(i18n("Volume:"), parent);
-// vollabel->setEnabled(FALSE);
-// l121->addWidget(vollabel);
-
-// voledit = new QLineEdit(parent,"voledit");
-// voledit->setFocusPolicy(QWidget::NoFocus);
-// voledit->setFixedHeight(voledit->sizeHint().height());
-// voledit->setEnabled(FALSE);
-// l121->addWidget(voledit);
-// tmp = i18n("<p>This shows the number of bytes transferred\n"
-// "for the selected account (not for all of your\n"
-// "accounts. You can select what to display in\n"
-// "the accounting dialog.\n"
-// "\n"
-// "<a href=\"#volaccounting\">More on volume accounting</a>");
-
-// QWhatsThis::add(vollabel,tmp);
-// QWhatsThis::add(voledit, tmp);
-
-// QVBoxLayout *l122 = new QVBoxLayout;
-// l12->addStretch(1);
-// l12->addLayout(l122);
-
-// l122->addStretch(1);
-// reset = new QPushButton(i18n("&Reset..."), parent);
-// reset->setEnabled(FALSE);
-// connect(reset, SIGNAL(clicked()),
-// this, SLOT(resetClicked()));
-// l122->addWidget(reset);
-
-// log = new QPushButton(i18n("&View Logs"), this);
-// connect(log, SIGNAL(clicked()),
-// this, SLOT(viewLogClicked()));
-// l122->addWidget(log);
-// l122->addStretch(1);
-
//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());
}
}
-// slotListBoxSelect(accountlist_l->currentItem());
+
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", i18n("Maximum number of accounts reached."));
- return;
- }
- int result;
-// int query = QMessageBox::information(this,
-// i18n("Do you want to use the wizard to create the new account or the "
-// "standard, dialog-based setup?\n"
-// "The wizard is easier and sufficient in most cases. If you need "
-// "very special settings, you might want to try the standard, "
-// "dialog-based setup."),
-// i18n("Create New Account"),
-// i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel"));
-
-// switch(query) {
-// case QMessageBox::Yes:
-// {
-// if (_pppdata->newaccount() == -1)
-// return;
-// // ProviderDB pdb(this);
-// // result = pdb.exec();
-// break;
-// }
-// case QMessageBox::No:
- if (_pppdata->newaccount() == -1){
- qDebug("_pppdata->newaccount() == -1");
- return;
- }
+ 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");
+ return;
+ }
result = doTab();
-// break;
-// default:
-// return;
-// }
- if(result == QDialog::Accepted) {
- accountlist_l->insertItem(_pppdata->accname());
- accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),
- true);
-// emit resetaccounts();
- _pppdata->save();
- } else
- _pppdata->deleteAccount();
+ if(result == QDialog::Accepted) {
+ accountlist_l->insertItem(_pppdata->accname());
+ accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true);
+
+ _pppdata->save();
+ } else
+ _pppdata->deleteAccount();
}
void AccountWidget::copyaccount() {
if(accountlist_l->count() == MAX_ACCOUNTS) {
- QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
+ QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
return;
}
if(accountlist_l->currentItem()<0) {
- QMessageBox::information(this, "sorry", i18n("No account selected."));
+ QMessageBox::information(this, "sorry", tr("No account selected."));
return;
}
_pppdata->copyaccount(accountlist_l->currentItem());
accountlist_l->insertItem(_pppdata->accname());
// emit resetaccounts();
_pppdata->save();
}
void AccountWidget::deleteaccount() {
- QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?")
+ QString s = tr("Are you sure you want to delete\nthe account \"%1\"?")
.arg(accountlist_l->text(accountlist_l->currentItem()));
- if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes)
+ if(QMessageBox::warning(this, s, tr("Confirm")) != QMessageBox::Yes)
return;
if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
accountlist_l->removeItem(accountlist_l->currentItem());
emit resetaccounts();
_pppdata->save();
slotListBoxSelect(accountlist_l->currentItem());
}
int AccountWidget::doTab(){
- QDialog *dlg = new QDialog( this, "newAccount", true );
+ 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 );
+ layout->addWidget( tabWindow );
bool isnewaccount;
- if(_pppdata->accname().isEmpty()) {
- dlg->setCaption(i18n("New Account"));
- isnewaccount = true;
- } else {
- QString tit = i18n("Edit Account: ");
- tit += _pppdata->accname();
- dlg->setCaption(tit);
- isnewaccount = false;
- }
-
- dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
- tabWindow->addTab( dial_w, i18n("Dial") );
- ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, i18n("IP Setup"));
- tabWindow->addTab( ip_w, i18n("IP") );
- gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, i18n("Gateway Setup"));
- tabWindow->addTab( gateway_w, i18n("Gateway") );
- dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, i18n("DNS Servers") );
- tabWindow->addTab( dns_w, i18n("DNS") );
- script_w = new ScriptWidget( _pppdata, tabWindow, isnewaccount, i18n("Edit Login Script"));
- tabWindow->addTab( script_w, i18n("Login Script") );
- ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, i18n("Execute Programs"));
- tabWindow->addTab( exec_w, i18n("Execute") );
-// acct = new AccountingSelector( tabWindow, isnewaccount );
-// tabWindow->addTab( acct, i18n("Accounting"));
-
- int result = 0;
- bool ok = false;
- qDebug("AccountWidget::doTab dlg->showMinimized");
- dlg->showMinimized();
- while (!ok){
-
- result = dlg->exec();
- ok = true;
+ 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;
+ }
- if(result == QDialog::Accepted) {
- if (script_w->check()) {
- if(dial_w->save()) {
- ip_w->save();
- dns_w->save();
- gateway_w->save();
- script_w->save();
- exec_w->save();
-// acct->save();
- } else {
- QMessageBox::critical(this, "error", i18n( "You must enter a unique\n"
- "account name"));
- ok = false;
- }
- } else {
- QMessageBox::critical(this, "error", i18n("Login script has unbalanced "
- "loop Start/End"));
- ok = false;
- }
+// // DIAL WIDGET
+ dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
+ tabWindow->addTab( dial_w, tr("Dial") );
+
+// // 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>"));
+ 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();
+ exec_w->save();
+ }
+ }
}
- }
- delete tabWindow;
- return result;
+ delete dlg;
+
+ return result;
}
QString AccountWidget::prettyPrintVolume(unsigned int n) {
int idx = 0;
- const QString quant[] = {i18n("Byte"), i18n("KB"),
- i18n("MB"), i18n("GB"), QString::null};
+ 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--)
n1 = n1 / 1024.0;
QString s = QString::number( n1, 'f', idx==0 ? 0 : 1 );
s += " " + quant[idx];
return s;
}
/////////////////////////////////////////////////////////////////////////////
//
// Queries the user what to reset: costs, volume or both
//
/////////////////////////////////////////////////////////////////////////////
-QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) {
-// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
- setCaption(i18n("Reset Accounting"));
-
- QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
- QVGroupBox *f = new QVGroupBox(i18n("What to Reset"), this);
-
- QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
-// costs = new QCheckBox(i18n("Reset the accumulated phone costs"), f);
-// costs->setChecked(true);
-// l1->addWidget(costs);
-// QWhatsThis::add(costs, i18n("Check this to set the phone costs\n"
-// "to zero. Typically you'll want to\n"
-// "do this once a month."));
-
-// volume = new QCheckBox(i18n("Reset volume accounting"), f);
-// volume->setChecked(true);
-// l1->addWidget(volume);
-// QWhatsThis::add(volume, i18n("Check this to set the volume accounting\n"
-// "to zero. Typically you'll want to do this\n"
-// "once a month."));
-
- l1->activate();
+// QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) {
+// // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
+// setCaption(tr("Reset Accounting"));
+
+// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
+// QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this);
+
+// QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
+// // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f);
+// // costs->setChecked(true);
+// // l1->addWidget(costs);
+// // QWhatsThis::add(costs, tr("Check this to set the phone costs\n"
+// // "to zero. Typically you'll want to\n"
+// // "do this once a month."));
+
+// // volume = new QCheckBox(tr("Reset volume accounting"), f);
+// // volume->setChecked(true);
+// // l1->addWidget(volume);
+// // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n"
+// // "to zero. Typically you'll want to do this\n"
+// // "once a month."));
+
+// l1->activate();
+
+// // this activates the f-layout and sets minimumSize()
+// f->show();
+
+// tl->addWidget(f);
+
+// QButtonGroup *bbox = new QButtonGroup(this);
+// // bbox->addStretch(1);
+// QPushButton *ok = new QPushButton( bbox, tr("OK") );
+// bbox->insert(ok);
+// ok->setDefault(true);
+// QPushButton *cancel = new QPushButton( bbox, tr("Cancel") );
+// bbox->insert(cancel);
+
+// connect(ok, SIGNAL(clicked()),
+// this, SLOT(accepted()));
+// connect(cancel, SIGNAL(clicked()),
+// this, SLOT(reject()));
+
+// bbox->layout();
+// tl->addWidget(bbox);
- // this activates the f-layout and sets minimumSize()
- f->show();
-
- tl->addWidget(f);
-
- QButtonGroup *bbox = new QButtonGroup(this);
-// bbox->addStretch(1);
- QPushButton *ok = new QPushButton( bbox, i18n("OK") );
- bbox->insert(ok);
- ok->setDefault(true);
- QPushButton *cancel = new QPushButton( bbox, i18n("Cancel") );
- bbox->insert(cancel);
-
- connect(ok, SIGNAL(clicked()),
- this, SLOT(accepted()));
- connect(cancel, SIGNAL(clicked()),
- this, SLOT(reject()));
-
- bbox->layout();
- tl->addWidget(bbox);
-
- // TODO: activate if KGroupBox is fixed
- // setFixedSize(sizeHint());
-}
+// }
-void QueryReset::accepted() {
- int result = costs->isChecked() ? COSTS : 0;
- result += volume->isChecked() ? VOLUME : 0;
+// void QueryReset::accepted() {
+// int result = costs->isChecked() ? COSTS : 0;
+// result += volume->isChecked() ? VOLUME : 0;
- done(result);
-}
+// done(result);
+// }
diff --git a/noncore/settings/networksettings/ppp/accounts.h b/noncore/settings/networksettings/ppp/accounts.h
index 5e8509d..eae3922 100644
--- a/noncore/settings/networksettings/ppp/accounts.h
+++ b/noncore/settings/networksettings/ppp/accounts.h
@@ -1,112 +1,100 @@
/* -*- C++ -*-
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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.
*/
#ifndef _ACCOUNTS_H_
#define _ACCOUNTS_H_
#include <qwidget.h>
#include <qdialog.h>
#include <qpushbutton.h>
#include <qlistbox.h>
//#include "acctselect.h"
class QDialog;
class QCheckBox;
class QLineEdit;
class QTabWidget;
class DialWidget;
class ScriptWidget;
class IPWidget;
class DNSWidget;
class GatewayWidget;
class PPPData;
class AccountWidget : public QWidget {
Q_OBJECT
public:
AccountWidget( PPPData *pd, QWidget *parent=0, const char *name=0 );
~AccountWidget() {}
private slots:
void editaccount();
void copyaccount();
void newaccount();
void deleteaccount();
void slotListBoxSelect(int);
-// void resetClicked();
-// void viewLogClicked();
private:
int doTab();
signals:
void resetaccounts();
-// void resetCosts(const QString &);
-// void resetVolume(const QString &);
private:
- QString prettyPrintVolume(unsigned int);
+ QString prettyPrintVolume(unsigned int);
PPPData *_pppdata;
- QTabWidget *tabWindow;
- DialWidget *dial_w;
-// AccountingSelector *acct;
- IPWidget *ip_w;
- DNSWidget *dns_w;
- GatewayWidget *gateway_w;
- ScriptWidget *script_w;
-
-// QPushButton *reset;
-// QPushButton *log;
-// QLabel *costlabel;
-// QLineEdit *costedit;
-// QLabel *vollabel;
-// QLineEdit *voledit;
-
- QListBox *accountlist_l;
- QPushButton *edit_b;
- QPushButton *copy_b;
- QPushButton *new_b;
- QPushButton *delete_b;
+ QTabWidget *tabWindow;
+ DialWidget *dial_w;
+ IPWidget *ip_w;
+ DNSWidget *dns_w;
+ GatewayWidget *gateway_w;
+ ScriptWidget *script_w;
+
+ QListBox *accountlist_l;
+ QPushButton *edit_b;
+ QPushButton *copy_b;
+ QPushButton *new_b;
+ QPushButton *delete_b;
};
-class QueryReset : public QDialog {
- Q_OBJECT
-public:
- QueryReset(QWidget *parent);
+// class QueryReset : public QDialog {
+// Q_OBJECT
+// public:
+// QueryReset(QWidget *parent);
- enum {COSTS=1, VOLUME=2};
+// enum {COSTS=1, VOLUME=2};
-private slots:
- void accepted();
+// private slots:
+// void accepted();
-private:
- QCheckBox *costs, *volume;
-};
+// private:
+// QCheckBox *costs, *volume;
+// };
#endif
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index 8ae714e..10bc25c 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -1,941 +1,921 @@
/*
* kPPP: A pppd Front End for the KDE project
*
* $Id$
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* based on EzPPP:
* Copyright (C) 1997 Jay Painter
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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 <string.h>
#include <termios.h>
#include <qlayout.h>
#include <qmessagebox.h>
#include <qwhatsthis.h>
#include <qregexp.h>
#include <qapplication.h>
-//#include <kiconloader.h>
#include <qbuttongroup.h>
-//#include <klocale.h>
-#define i18n QObject::tr
#include <qvgroupbox.h>
#include <qhbox.h>
#include <qdialog.h>
-//#include <kwin.h>
#include "edit.h"
#include "pppdata.h"
-//#include "newwidget.h"
#include "iplined.h"
#include "auth.h"
DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount
, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
const int GRIDROWS = 6;
QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );//, KDialog::spacingHint());
- connect_label = new QLabel(i18n("Connection name:"), this);
+ connect_label = new QLabel(tr("Connection name:"), this);
tl->addWidget(connect_label, 0, 0);
connectname_l = new QLineEdit(this);
// connectname_l->setMaxLength(ACCNAME_SIZE);
tl->addWidget(connectname_l, 0, 1);
- QString tmp = i18n("Type in a unique name for this connection");
+ QString tmp = tr("Type in a unique name for this connection");
QWhatsThis::add(connect_label,tmp);
QWhatsThis::add(connectname_l,tmp);
- number_label = new QLabel(i18n("Phone number:"), this);
+ number_label = new QLabel(tr("Phone number:"), this);
number_label->setAlignment(AlignTop|AlignLeft);
tl->addWidget(number_label, 1, 0);
QHBoxLayout *lpn = new QHBoxLayout(5);
tl->addLayout(lpn, 1, 1);
numbers = new QListBox(this);
// numbers->setMinimumSize(120, 70);
lpn->addWidget(numbers);
QVBoxLayout *lpn1 = new QVBoxLayout;
lpn->addLayout(lpn1);
- add = new QPushButton(i18n("&Add..."), this);
- del = new QPushButton(i18n("&Remove"), this);
+ add = new QPushButton(tr("&Add..."), this);
+ del = new QPushButton(tr("&Remove"), this);
up = new QPushButton(this);
//FIXME: QPixmap pm = BarIcon("up");
// up->setPixmap(pm);
down = new QPushButton(this);
//FIXME: pm = BarIcon("down");
// down->setPixmap(pm);
lpn1->addWidget(add);
lpn1->addWidget(del);
lpn1->addStretch(1);
lpn1->addWidget(up);
lpn1->addWidget(down);
connect(add, SIGNAL(clicked()),
this, SLOT(addNumber()));
connect(del, SIGNAL(clicked()),
this, SLOT(delNumber()));
connect(up, SIGNAL(clicked()),
this, SLOT(upNumber()));
connect(down, SIGNAL(clicked()),
this, SLOT(downNumber()));
connect(numbers, SIGNAL(highlighted(int)),
this, SLOT(selectionChanged(int)));
numbersChanged();
- tmp = i18n("<p>Specifies the phone numbers to dial. You\n"
+ tmp = tr("<p>Specifies the phone numbers to dial. You\n"
"can supply multiple numbers here, simply\n"
"click on \"Add\". You can arrange the\n"
"order the numbers are tried by using the\n"
"arrow buttons.\n\n"
"When a number is busy or fails, <i>kppp</i> will \n"
"try the next number and so on");
QWhatsThis::add(number_label,tmp);
QWhatsThis::add(numbers,tmp);
- auth_l = new QLabel(i18n("Authentication:"), this);
+ auth_l = new QLabel(tr("Authentication:"), this);
tl->addWidget(auth_l, 3, 0);
auth = new QComboBox(this);
- auth->insertItem(i18n("Script-based"));
- auth->insertItem(i18n("PAP"));
- auth->insertItem(i18n("Terminal-based"));
- auth->insertItem(i18n("CHAP"));
- auth->insertItem(i18n("PAP/CHAP"));
+ auth->insertItem(tr("Script-based"));
+ auth->insertItem(tr("PAP"));
+ auth->insertItem(tr("Terminal-based"));
+ auth->insertItem(tr("CHAP"));
+ auth->insertItem(tr("PAP/CHAP"));
tl->addWidget(auth, 3, 1);
- tmp = i18n("<p>Specifies the method used to identify yourself to\n"
+ tmp = tr("<p>Specifies the method used to identify yourself to\n"
"the PPP server. Most universities still use\n"
"<b>Terminal</b>- or <b>Script</b>-based authentication,\n"
"while most ISP use <b>PAP</b> and/or <b>CHAP</b>. If\n"
"unsure, contact your ISP.\n"
"\n"
"If you can choose between PAP and CHAP,\n"
"choose CHAP, because it's much safer. If you don't know\n"
"whether PAP or CHAP is right, choose PAP/CHAP.");
QWhatsThis::add(auth_l,tmp);
QWhatsThis::add(auth,tmp);
- store_password = new QCheckBox(i18n("Store password"), this);
+ store_password = new QCheckBox(tr("Store password"), this);
store_password->setChecked(true);
tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight);
QWhatsThis::add(store_password,
- i18n("<p>When this is turned on, your ISP password\n"
+ tr("<p>When this is turned on, your ISP password\n"
"will be saved in <i>kppp</i>'s config file, so\n"
"you do not need to type it in every time.\n"
"\n"
"<b><font color=\"red\">Warning:</font> your password will be stored as\n"
"plain text in the config file, which is\n"
"readable only to you. Make sure nobody\n"
"gains access to this file!"));
- pppdargs = new QPushButton(i18n("Customize pppd Arguments..."), this);
+ pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this);
connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton()));
tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter);
// Set defaults if editing an existing connection
if(!isnewaccount) {
connectname_l->setText(_pppdata->accname());
// insert the phone numbers into the listbox
QString n = _pppdata->phonenumber();
QString tmp = "";
uint idx = 0;
while(idx != n.length()) {
if(n[idx] == ':') {
if(tmp.length() > 0)
numbers->insertItem(tmp);
tmp = "";
} else
tmp += n[idx];
idx++;
}
if(tmp.length() > 0)
numbers->insertItem(tmp);
auth->setCurrentItem(_pppdata->authMethod());
store_password->setChecked(_pppdata->storePassword());
} else {
// select PAP/CHAP as default
auth->setCurrentItem(AUTH_PAPCHAP);
}
numbersChanged();
tl->activate();
}
bool DialWidget::save() {
//first check to make sure that the account name is unique!
if(connectname_l->text().isEmpty() ||
!_pppdata->isUniqueAccname(connectname_l->text())) {
return false;
} else {
_pppdata->setAccname(connectname_l->text());
QString number = "";
for(uint i = 0; i < numbers->count(); i++) {
if(i != 0)
number += ":";
number += numbers->text(i);
}
_pppdata->setPhonenumber(number);
_pppdata->setAuthMethod(auth->currentItem());
_pppdata->setStorePassword(store_password->isChecked());
return true;
}
}
void DialWidget::numbersChanged() {
int sel = numbers->currentItem();
del->setEnabled(sel != -1);
up->setEnabled(sel != -1 && sel != 0);
down->setEnabled(sel != -1 && sel != (int)numbers->count()-1);
}
void DialWidget::selectionChanged(int) {
numbersChanged();
}
void DialWidget::addNumber() {
PhoneNumberDialog dlg(this);
if(dlg.exec()) {
numbers->insertItem(dlg.phoneNumber());
numbersChanged();
}
}
void DialWidget::delNumber() {
if(numbers->currentItem() != -1) {
numbers->removeItem(numbers->currentItem());
numbersChanged();
}
}
void DialWidget::upNumber() {
int idx = numbers->currentItem();
if(idx != -1) {
QString item = numbers->text(idx);
numbers->removeItem(idx);
numbers->insertItem(item, idx-1);
numbers->setCurrentItem(idx-1);
numbersChanged();
}
}
void DialWidget::downNumber() {
int idx = numbers->currentItem();
if(idx != -1) {
QString item = numbers->text(idx);
numbers->removeItem(idx);
numbers->insertItem(item, idx+1);
numbers->setCurrentItem(idx+1);
numbersChanged();
}
}
void DialWidget::pppdargsbutton() {
PPPdArguments pa(_pppdata, this);
pa.exec();
}
/////////////////////////////////////////////////////////////////////////////
// ExecWidget
/////////////////////////////////////////////////////////////////////////////
ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) :
QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint());
- QLabel *l = new QLabel(\
-i18n("Here you can select commands to run at certain stages of the\n"
- "connection. The commands are run with your real user id, so\n"
- "you cannot run any commands here requiring root permissions\n"
- "(unless, of course, you are root).\n\n"
- "Be sure to supply the whole path to the program otherwise\n"
- "kppp might be unable to find it."), this);
-// l->setMinimumHeight(l->sizeHint().height());
+ QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this);
+
tl->addWidget(l);
tl->addStretch(1);
QGridLayout *l1 = new QGridLayout(4, 2, 10);
tl->addLayout(l1);
l1->setColStretch(0, 0);
l1->setColStretch(1, 1);
- before_connect_l = new QLabel(i18n("Before connect:"), this);
+ before_connect_l = new QLabel(tr("Before connect:"), this);
before_connect_l->setAlignment(AlignVCenter);
l1->addWidget(before_connect_l, 0, 0);
before_connect = new QLineEdit(this);
// before_connect->setMaxLength(COMMAND_SIZE);
l1->addWidget(before_connect, 0, 1);
- QString tmp = i18n("Allows you to run a program <b>before</b> a connection\n"
+ QString tmp = tr("Allows you to run a program <b>before</b> a connection\n"
"is established. It is called immediately before\n"
"dialing has begun.\n\n"
"This might be useful, e.g. to stop HylaFAX blocking the\n"
"modem.");
QWhatsThis::add(before_connect_l,tmp);
QWhatsThis::add(before_connect,tmp);
- command_label = new QLabel(i18n("Upon connect:"), this);
+ command_label = new QLabel(tr("Upon connect:"), this);
command_label->setAlignment(AlignVCenter);
l1->addWidget(command_label, 1, 0);
command = new QLineEdit(this);
// command->setMaxLength(COMMAND_SIZE);
l1->addWidget(command, 1, 1);
- tmp = i18n("Allows you to run a program <b>after</b> a connection\n"
+ tmp = tr("Allows you to run a program <b>after</b> a connection\n"
"is established. When your program is called, all\n"
"preparations for an Internet connection are finished.\n"
"\n"
"Very useful for fetching mail and news");
QWhatsThis::add(command_label,tmp);
QWhatsThis::add(command,tmp);
- predisconnect_label = new QLabel(i18n("Before disconnect:"),
+ predisconnect_label = new QLabel(tr("Before disconnect:"),
this);
predisconnect_label->setAlignment(AlignVCenter);
l1->addWidget(predisconnect_label, 2, 0);
predisconnect = new QLineEdit(this);
// predisconnect->setMaxLength(COMMAND_SIZE);
l1->addWidget(predisconnect, 2, 1);
- tmp = i18n("Allows you to run a program <b>before</b> a connection\n"
+ tmp = tr("Allows you to run a program <b>before</b> a connection\n"
"is closed. The connection will stay open until\n"
"the program exits.");
QWhatsThis::add(predisconnect_label,tmp);
QWhatsThis::add(predisconnect,tmp);
- discommand_label = new QLabel(i18n("Upon disconnect:"),
+ discommand_label = new QLabel(tr("Upon disconnect:"),
this);
discommand_label->setAlignment(AlignVCenter);
l1->addWidget(discommand_label, 3, 0);
discommand = new QLineEdit(this);
// discommand->setMaxLength(COMMAND_SIZE);
l1->addWidget(discommand, 3, 1);
- tmp = i18n("Allows you to run a program <b>after</b> a connection\n"
+ tmp = tr("Allows you to run a program <b>after</b> a connection\n"
"has been closed.");
QWhatsThis::add(discommand_label,tmp);
QWhatsThis::add(discommand,tmp);
// extra space between entries
l1->addRowSpacing(1, 5);
l1->addRowSpacing(3, 5);
tl->addStretch(1);
tl->activate();
// Set defaults if editing an existing connection
if(!isnewaccount) {
before_connect->setText(_pppdata->command_before_connect());
command->setText(_pppdata->command_on_connect());
discommand->setText(_pppdata->command_on_disconnect());
predisconnect->setText(_pppdata->command_before_disconnect());
}
}
bool ExecWidget::save() {
_pppdata->setCommand_before_connect(before_connect->text());
_pppdata->setCommand_on_connect(command->text());
_pppdata->setCommand_before_disconnect(predisconnect->text());
_pppdata->setCommand_on_disconnect(discommand->text());
return true;
}
/////////////////////////////////////////////////////////////////////////////
//
// IPWidget
//
/////////////////////////////////////////////////////////////////////////////
IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 3 );//KDialog::spacingHint());
- box = new QVGroupBox(i18n("Configuration"), this);
+ box = new QVGroupBox(tr("Configuration"), this);
// box->setInsideSpacing( 1 );//KDialog::spacingHint());
rb = new QButtonGroup(this);
rb->hide();
connect(rb, SIGNAL(clicked(int)),
SLOT(hitIPSelect(int)));
dynamicadd_rb = new QRadioButton(box);
- dynamicadd_rb->setText(i18n("Dynamic IP address"));
+ dynamicadd_rb->setText(tr("Dynamic IP address"));
QWhatsThis::add(dynamicadd_rb,
- i18n("Select this option when your computer gets an\n"
+ tr("Select this option when your computer gets an\n"
"internet address (IP) every time a\n"
"connection is made.\n"
"\n"
"Almost every Internet Service Provider uses\n"
"this method, so this should be turned on."));
staticadd_rb = new QRadioButton(box);
- staticadd_rb->setText(i18n("Static IP address"));
+ staticadd_rb->setText(tr("Static IP address"));
rb->insert(dynamicadd_rb, 0);
rb->insert(staticadd_rb, 1);
QWhatsThis::add(staticadd_rb,
- i18n("Select this option when your computer has a\n"
+ tr("Select this option when your computer has a\n"
"fixed internet address (IP). Most computers\n"
"don't have this, so you should probably select\n"
"dynamic IP addressing unless you know what you\n"
"are doing."));
QWidget *ipWidget = new QWidget(box);
QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2);
ipLayout->setSpacing( 2 );//KDialog::spacingHint());
- ipaddress_label = new QLabel(i18n("IP address:"), ipWidget);
- QString tmp = i18n("If your computer has a permanent internet\n"
+ ipaddress_label = new QLabel(tr("IP address:"), ipWidget);
+ QString tmp = tr("If your computer has a permanent internet\n"
"address, you must supply your IP address here.");
ipLayout->addWidget(ipaddress_label, 0, 0);
ipaddress_l = new IPLineEdit(ipWidget);
ipLayout->addWidget(ipaddress_l, 0, 1);
QWhatsThis::add(ipaddress_label,tmp);
QWhatsThis::add(ipaddress_l,tmp);
- sub_label = new QLabel(i18n("Subnet mask:"), ipWidget);
- tmp = i18n("<p>If your computer has a static Internet address,\n"
+ sub_label = new QLabel(tr("Subnet mask:"), ipWidget);
+ tmp = tr("<p>If your computer has a static Internet address,\n"
"you must supply a network mask here. In almost\n"
"all cases this netmask will be <b>255.255.255.0</b>,\n"
"but your mileage may vary.\n"
"\n"
"If unsure, contact your Internet Service Provider");
ipLayout->addWidget(sub_label, 1, 0);
subnetmask_l = new IPLineEdit(ipWidget);
ipLayout->addWidget(subnetmask_l, 1, 1);
QWhatsThis::add(sub_label,tmp);
QWhatsThis::add(subnetmask_l,tmp);
- autoname = new QCheckBox(i18n("Auto-configure hostname from this IP"), this);
+ autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this);
autoname->setChecked(_pppdata->autoname());
connect(autoname,SIGNAL(toggled(bool)),
this,SLOT(autoname_t(bool)));
QWhatsThis::add(autoname,
- i18n("<p>Whenever you connect, this reconfigures\n"
+ tr("<p>Whenever you connect, this reconfigures\n"
"your hostname to match the IP address you\n"
"got from the PPP server. This may be useful\n"
"if you need to use a protocol which depends\n"
"on this information, but it can also cause several\n"
"<a href=\"kppp-7.html#autohostname\">problems</a>.\n"
"\n"
"Don't enable this unless you really need it."));
topLayout->addWidget(box);
topLayout->addWidget(autoname);
topLayout->addStretch();
//load info from gpppdata
if(!isnewaccount) {
if(_pppdata->ipaddr() == "0.0.0.0" &&
_pppdata->subnetmask() == "0.0.0.0") {
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
autoname->setChecked(_pppdata->autoname());
}
else {
ipaddress_l->setText(_pppdata->ipaddr());
subnetmask_l->setText(_pppdata->subnetmask());
staticadd_rb->setChecked(true);
autoname->setChecked(false);
}
}
else {
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
}
}
void IPWidget::autoname_t(bool on) {
static bool was_warned = false;
// big-fat warning when selecting the auto configure hostname option
if(on && !was_warned) {
QMessageBox::information(this,
- i18n("Selecting this option might cause some weird "
+ tr("Selecting this option might cause some weird "
"problems with the X-server and applications "
"while kppp is connected. Don't use it until "
"you know what you are doing!\n"
"For more information take a look at the "
"handbook (or help) in the section \"Frequently "
"asked questions\"."),
- i18n("Warning"));
+ tr("Warning"));
was_warned = true;
}
}
void IPWidget::save() {
if(dynamicadd_rb->isChecked()) {
_pppdata->setIpaddr("0.0.0.0");
_pppdata->setSubnetmask("0.0.0.0");
} else {
_pppdata->setIpaddr(ipaddress_l->text());
_pppdata->setSubnetmask(subnetmask_l->text());
}
_pppdata->setAutoname(autoname->isChecked());
}
void IPWidget::hitIPSelect( int i ) {
if(i == 0) {
ipaddress_label->setEnabled(false);
sub_label->setEnabled(false);
ipaddress_l->setEnabled(false);
subnetmask_l->setEnabled(false);
}
else {
ipaddress_label->setEnabled(true);
sub_label->setEnabled(true);
ipaddress_l->setEnabled(true);
subnetmask_l->setEnabled(true);
}
}
DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
- // box = new QGroupBox(this);
- QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );//, KDialog::spacingHint());
+ QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );
- dnsdomain_label = new QLabel(i18n("Domain name:"), this);
+ dnsdomain_label = new QLabel(tr("Domain name:"), this);
tl->addWidget(dnsdomain_label, 0, 0);
dnsdomain = new QLineEdit(this);
-// dnsdomain->setMaxLength(DOMAIN_SIZE);
+
tl->addWidget(dnsdomain, 0, 1);
- QString tmp = i18n("If you enter a domain name here, this domain\n"
+ QString tmp = tr("If you enter a domain name here, this domain\n"
"name is used for your computer while you are\n"
"connected. When the connection is closed, the\n"
"original domain name of your computer is\n"
"restored.\n"
"\n"
"If you leave this field blank, no changes are\n"
"made to the domain name.");
QWhatsThis::add(dnsdomain_label,tmp);
QWhatsThis::add(dnsdomain,tmp);
- conf_label = new QLabel(i18n("Configuration:"), this);
+ conf_label = new QLabel(tr("Configuration:"), this);
tl->addWidget(conf_label, 1, 0);
bg = new QButtonGroup("Group", this);
connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int)));
bg->hide();
- autodns = new QRadioButton(i18n("Automatic"), this);
+ autodns = new QRadioButton(tr("Automatic"), this);
bg->insert(autodns, 0);
tl->addWidget(autodns, 1, 1);
- // no automatic DNS detection for pppd < 2.3.7
if(!_pppdata->pppdVersionMin(2, 3, 7))
autodns->setEnabled(false);
- mandns = new QRadioButton(i18n("Manual"), this);
+ mandns = new QRadioButton(tr("Manual"), this);
bg->insert(mandns, 1);
tl->addWidget(mandns, 2, 1);
- dns_label = new QLabel(i18n("DNS IP address:"), this);
+ dns_label = new QLabel(tr("DNS IP address:"), this);
tl->addWidget(dns_label, 3, 0);
QHBoxLayout *l2 = new QHBoxLayout;
tl->addLayout(l2, 3, 1);
dnsipaddr = new IPLineEdit(this);
connect(dnsipaddr, SIGNAL(returnPressed()),
SLOT(adddns()));
connect(dnsipaddr, SIGNAL(textChanged(const QString &)),
SLOT(DNS_Edit_Changed(const QString &)));
l2->addWidget(dnsipaddr, 1);
l2->addStretch(1);
- tmp = i18n("<p>Allows you to specify a new DNS server to be\n"
+ tmp = tr("<p>Allows you to specify a new DNS server to be\n"
"used while you are connected. When the\n"
"connection is closed, this DNS entry will be\n"
"removed again.\n"
"\n"
"To add a DNS server, type in the IP address of\n"
"the DNS server here and click on <b>Add</b>");
QWhatsThis::add(dns_label, tmp);
QWhatsThis::add(dnsipaddr, tmp);
QHBoxLayout *l1 = new QHBoxLayout;
tl->addLayout(l1, 4, 1);
- add = new QPushButton(i18n("Add"), this);
+ add = new QPushButton(tr("Add"), this);
connect(add, SIGNAL(clicked()), SLOT(adddns()));
-// int width = add->sizeHint().width();
-// width = QMAX(width,60);
-// add->setMinimumWidth(width);
l1->addWidget(add);
- l1->addStretch(1);
+// l1->addStretch(1);
QWhatsThis::add(add,
- i18n("Click this button to add the DNS server\n"
+ tr("Click this button to add the DNS server\n"
"specified in the field above. The entry\n"
"will then be added to the list below"));
- remove = new QPushButton(i18n("Remove"), this);
+ remove = new QPushButton(tr("Remove"), this);
connect(remove, SIGNAL(clicked()), SLOT(removedns()));
-// width = remove->sizeHint().width();
-// width = QMAX(width,60);
-// remove->setMinimumWidth(width);
l1->addWidget(remove);
QWhatsThis::add(remove,
- i18n("Click this button to remove the selected DNS\n"
+ tr("Click this button to remove the selected DNS\n"
"server entry from the list below"));
- servers_label = new QLabel(i18n("DNS address list:"), this);
+ servers_label = new QLabel(tr("DNS address list:"), this);
servers_label->setAlignment(AlignTop|AlignLeft);
tl->addWidget(servers_label, 5, 0);
dnsservers = new QListBox(this);
dnsservers->setMinimumSize(150, 80);
connect(dnsservers, SIGNAL(highlighted(int)),
SLOT(DNS_Entry_Selected(int)));
tl->addWidget(dnsservers, 5, 1);
- tmp = i18n("<p>This shows all defined DNS servers to use\n"
+ tmp = tr("<p>This shows all defined DNS servers to use\n"
"while you are connected. Use the <b>Add</b> and\n"
"<b>Remove</b> buttons to modify the list");
QWhatsThis::add(servers_label,tmp);
QWhatsThis::add(dnsservers,tmp);
- exdnsdisabled_toggle = new QCheckBox(i18n( \
-"Disable existing DNS servers during connection"),
- this);
+ exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this);
+ // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this);
exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled());
tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter);
QWhatsThis::add(exdnsdisabled_toggle,
- i18n("<p>When this option is selected, all DNS\n"
+ tr("<p>When this option is selected, all DNS\n"
"servers specified in <tt>/etc/resolv.conf</tt> are\n"
"temporary disabled while the dialup connection\n"
"is established. After the connection is\n"
"closed, the servers will be re-enabled\n"
"\n"
"Typically, there is no reason to use this\n"
"option, but it may become useful under \n"
"some circumstances."));
// restore data if editing
if(!isnewaccount) {
dnsservers->insertStringList(_pppdata->dns());
dnsdomain->setText(_pppdata->domain());
}
int mode = _pppdata->autoDNS() ? 0 : 1;
bg->setButton(mode);
DNS_Mode_Selected(mode);
tl->activate();
}
void DNSWidget::DNS_Edit_Changed(const QString &text) {
QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
add->setEnabled(text.find(r) != -1);
}
void DNSWidget::DNS_Entry_Selected(int) {
remove->setEnabled(true);
}
void DNSWidget::DNS_Mode_Selected(int mode) {
bool on = (mode == 1);
dns_label->setEnabled(on);
servers_label->setEnabled(on);
dnsipaddr->setText("");
dnsipaddr->setEnabled(on);
add->setEnabled(false);
remove->setEnabled(dnsservers->count()>0 && on);
dnsservers->clearSelection();
dnsservers->setEnabled(on);
dnsservers->triggerUpdate(false);
}
void DNSWidget::save() {
_pppdata->setAutoDNS(bg->id(bg->selected()) == 0);
QStringList serverlist;
for(uint i=0; i < dnsservers->count(); i++)
serverlist.append(dnsservers->text(i));
_pppdata->setDns(serverlist);
// strip leading dot
QString s(dnsdomain->text());
if(s.left(1) == ".")
_pppdata->setDomain(s.mid(1));
else
_pppdata->setDomain(dnsdomain->text());
_pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
}
void DNSWidget::adddns() {
if(dnsservers->count() < MAX_DNS_ENTRIES) {
dnsservers->insertItem(dnsipaddr->text());
dnsipaddr->setText("");
}
}
void DNSWidget::removedns() {
int i;
i = dnsservers->currentItem();
if(i != -1)
dnsservers->removeItem(i);
remove->setEnabled(dnsservers->count()>0);
}
//
// GatewayWidget
//
GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
- topLayout->setSpacing( 2 );//KDialog::spacingHint());
+ topLayout->setSpacing( 2 );
+ topLayout->setMargin( 0 );
- box = new QVGroupBox(i18n("Configuration"), this);
-// box->setInsideSpacing( 2 );//KDialog::spacingHint());
+ box = new QVGroupBox(tr("Configuration"), this);
rb = new QButtonGroup(this);
rb->hide();
connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
defaultgateway = new QRadioButton(box);
- defaultgateway->setText(i18n("Default gateway"));
+ defaultgateway->setText(tr("Default gateway"));
rb->insert(defaultgateway, 0);
QWhatsThis::add(defaultgateway,
- i18n("This makes the PPP peer computer (the computer\n"
+ tr("This makes the PPP peer computer (the computer\n"
"you are connected to with your modem) to act as\n"
"a gateway. Your computer will send all packets not\n"
"going to a computer inside your local net to this\n"
"computer, which will route these packets.\n"
"\n"
"This is the default for most ISPs, so you should\n"
"probably leave this option on."));
staticgateway = new QRadioButton(box);
- staticgateway->setText(i18n("Static gateway"));
+ staticgateway->setText(tr("Static gateway"));
rb->insert(staticgateway, 1);
QWhatsThis::add(staticgateway,
- i18n("<p>Allows you to specify which computer you want\n"
+ tr("<p>Allows you to specify which computer you want\n"
"to use as gateway (see <i>Default Gateway</i> above)"));
QHBox *gateBox = new QHBox(box);
- gate_label = new QLabel(i18n("Gateway IP address:"), gateBox);
+ gate_label = new QLabel(tr("Gateway IP address:"), gateBox);
gatewayaddr = new IPLineEdit(gateBox);
- defaultroute = new QCheckBox(i18n("Assign the default route to this gateway"),
+ defaultroute = new QCheckBox(tr("Assign the default route to this gateway"),
this);
QWhatsThis::add(defaultroute,
- i18n("If this option is enabled, all packets not\n"
+ tr("If this option is enabled, all packets not\n"
"going to the local net are routed through\n"
"the PPP connection.\n"
"\n"
"Normally, you should turn this on"));
topLayout->addWidget(box);
topLayout->addWidget(defaultroute);
topLayout->addStretch();
//load info from gpppdata
if(!isnewaccount) {
if(_pppdata->gateway() == "0.0.0.0") {
defaultgateway->setChecked(true);
hitGatewaySelect(0);
}
else {
gatewayaddr->setText(_pppdata->gateway());
staticgateway->setChecked(true);
}
defaultroute->setChecked(_pppdata->defaultroute());
}
else {
defaultgateway->setChecked(true);
hitGatewaySelect(0);
defaultroute->setChecked(true);
}
}
void GatewayWidget::save() {
_pppdata->setGateway(gatewayaddr->text());
_pppdata->setDefaultroute(defaultroute->isChecked());
}
void GatewayWidget::hitGatewaySelect( int i ) {
if(i == 0) {
gatewayaddr->setText("0.0.0.0");
gatewayaddr->setEnabled(false);
gate_label->setEnabled(false);
}
else {
gatewayaddr->setEnabled(true);
gatewayaddr->setText("");
gate_label->setEnabled(true);
}
}
ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name),_pppdata(pd)
{
QVBoxLayout *tl = new QVBoxLayout(this, 0 );
se = new ScriptEdit(this);
connect(se, SIGNAL(returnPressed()), SLOT(addButton()));
tl->addWidget(se);
// insert equal-sized buttons
QHBoxLayout *hl = new QHBoxLayout( this );
tl->addLayout( hl );
- add = new QPushButton( i18n("Add"), this );
+ add = new QPushButton( tr("Add"), this );
hl->addWidget( add );
connect(add, SIGNAL(clicked()), SLOT(addButton()));
- insert = new QPushButton( i18n("Insert"), this );
+ insert = new QPushButton( tr("Insert"), this );
hl->addWidget( insert );
connect(insert, SIGNAL(clicked()), SLOT(insertButton()));
- remove = new QPushButton( i18n("Remove"), this );
+ remove = new QPushButton( tr("Remove"), this );
hl->addWidget( remove );
connect(remove, SIGNAL(clicked()), SLOT(removeButton()));
QHBoxLayout *l12 = new QHBoxLayout(0);
tl->addLayout(l12);
stl = new QListBox(this);
// stl->setVScrollBarMode( QScrollView::AlwaysOff );
connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int)));
// stl->setMinimumSize(QSize(70, 140));
sl = new QListBox(this);
// sl->setVScrollBarMode( QScrollView::AlwaysOff );
connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int)));
// sl->setMinimumSize(QSize(150, 140));
slb = new QScrollBar(this);
// slb->setFixedWidth(slb->sizeHint().width());
connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int)));
l12->addWidget(stl, 1);
l12->addWidget(sl, 3);
l12->addWidget(slb, 0);
//load data from gpppdata
if(!isnewaccount) {
QStringList &comlist = _pppdata->scriptType();
QStringList &arglist = _pppdata->script();
QStringList::Iterator itcom = comlist.begin();
QStringList::Iterator itarg = arglist.begin();
for ( ;
itcom != comlist.end() && itarg != arglist.end();
++itcom, ++itarg )
{
stl->insertItem(*itcom);
sl->insertItem(*itarg);
}
}
insert->setEnabled(false);
remove->setEnabled(false);
adjustScrollBar();
tl->activate();
}
bool ScriptWidget::check() {
uint lstart = 0;
uint lend = 0;
uint errcnt = 0;
if(sl->count() > 0) {
for( uint i=0; i <= sl->count()-1; i++) {
if(stl->text(i) == "LoopStart") {
lstart++;
}
if (stl->text(i) == "LoopEnd") {
lend++;
}
if ( lend > lstart ) errcnt++;
}
return ( (errcnt == 0 ) && (lstart == lend) );
}
return true;
}
void ScriptWidget::save() {
QStringList typelist, arglist;
for(uint i=0; i < sl->count(); i++) {
typelist.append(stl->text(i));
arglist.append(sl->text(i));
}
_pppdata->setScriptType(typelist);
_pppdata->setScript(arglist);
}
void ScriptWidget::adjustScrollBar() {
if((int)sl->count() <= sl->numItemsVisible())
slb->setRange(0, 0);
else
slb->setRange(0, (sl->count() - sl->numItemsVisible())+1);
}
void ScriptWidget::scrolling(int i) {
sl->setTopItem(i);
stl->setTopItem(i);
}
void ScriptWidget::slhighlighted(int i) {
insert->setEnabled(true);
remove->setEnabled(true);
stl->setCurrentItem(i);
@@ -1062,137 +1042,137 @@ void ScriptWidget::insertButton() {
break;
case ScriptEdit::SendNoEcho:
stl->insertItem("SendNoEcho", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Pause:
stl->insertItem("Pause", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Hangup:
stl->insertItem("Hangup", stl->currentItem());
sl->insertItem("", sl->currentItem());
break;
case ScriptEdit::Answer:
stl->insertItem("Answer", stl->currentItem());
sl->insertItem("", sl->currentItem());
break;
case ScriptEdit::Timeout:
stl->insertItem("Timeout", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Password:
stl->insertItem("Password", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::ID:
stl->insertItem("ID", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Prompt:
stl->insertItem("Prompt", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::PWPrompt:
stl->insertItem("PWPrompt", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::LoopStart:
stl->insertItem("LoopStart", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::LoopEnd:
stl->insertItem("LoopEnd", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Scan:
stl->insertItem("Scan", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Save:
stl->insertItem("Save", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
default:
break;
}
adjustScrollBar();
se->setText("");
}
void ScriptWidget::removeButton() {
if(sl->currentItem() >= 0) {
int stlc = stl->currentItem();
sl->removeItem(sl->currentItem());
stl->removeItem(stlc);
adjustScrollBar();
insert->setEnabled(sl->currentItem() != -1);
remove->setEnabled(sl->currentItem() != -1);
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Used to specify a new phone number
//
/////////////////////////////////////////////////////////////////////////////
PhoneNumberDialog::PhoneNumberDialog(QWidget *parent)
: QDialog(parent,"PhoneNumberDialog",true)
{
- setCaption( i18n("Add Phone Number") );
+ setCaption( tr("Add Phone Number") );
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 3 );
layout->setMargin( 3 );
// QHBox *hbox = new QHBox(this);
// setMainWidget(hbox);
// hbox->setSpacing( 2 );//KDialog::spacingHint());
QLabel *label = new QLabel(this, tr("Enter a phone number:"));
layout->addWidget( label );
le = new QLineEdit(this, "lineEdit");
layout->addWidget( le );
connect(le, SIGNAL(textChanged(const QString &)),
this, SLOT(textChanged(const QString &)));
le->setFocus();
textChanged("");
}
QString PhoneNumberDialog::phoneNumber() {
QString s = le->text();
return s;
}
void PhoneNumberDialog::textChanged(const QString &s) {
// enableButtonOK(s.length() > 0);
}
//#include "edit.moc"
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index 7a6524f..517dd8b 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -37,193 +37,193 @@
// #include <kmessagebox.h>
// #include <kapplication.h>
#include <assert.h>
#define SEPARATOR -sseepp-
#define SEP QString("%1SEPARATOR%1")
PPPData::PPPData()
: 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)
{
highcount = readNumConfig(GENERAL_GRP, NUMACCOUNTS_KEY, 0) - 1;
if (highcount > MAX_ACCOUNTS)
highcount = MAX_ACCOUNTS;
if(highcount >= 0 && defaultAccount().isEmpty()) {
setAccountbyIndex(0);
setDefaultAccount(accname());
} else if(!setAccount(defaultAccount()))
setDefaultAccount(accname());
// start out with internal debugging disabled
// the user is still free to specify `debug' on his own
setPPPDebug(false);
::pppdVersion(&pppdVer, &pppdMod, &pppdPatch);
}
Config PPPData::config()
{
return Config("NetworkSetupPPP");
}
//
// save configuration
//
void PPPData::save()
{
qDebug("PPPData saving data");
writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count());
QString key;
QStringList keys;
Config cfg = config();
for( QMap<QString,QString>::Iterator it = stringEntries.begin();
it != stringEntries.end(); ++it ){
QString val = it.data();
key = it.key();
// qDebug("saving %s -> %s", key.latin1(), val.latin1() );
keys = QStringList::split( "SEPARATOR", key );
qDebug("group >%s< key >%s< value >%s<", keys[0].latin1(), keys[1].latin1(), val.latin1() );
cfg.setGroup(keys[0]);
cfg.writeEntry(keys[1], val);
}
for( QMap<QString,int>::Iterator it = intEntries.begin();
it != intEntries.end(); ++it ){
int val = it.data();
key = it.key();
// qDebug("saving %s -> %i", key.latin1(), val );
keys = QStringList::split( "SEPARATOR", key );
qDebug("group >%s< key >%s< val %i", keys[0].latin1(), keys[1].latin1(), val );
cfg.setGroup(keys[0]);
cfg.writeEntry(keys[1], val);
}
for( QMap<QString,QStringList>::Iterator it = listEntries.begin();
it != listEntries.end(); ++it ){
QStringList val = it.data();
key = it.key();
QChar sep = sepEntries[key];
// qDebug("saving %s -> %s", key.latin1(), val.join(sep).latin1() );
keys = QStringList::split( "SEPARATOR", key );
qDebug("group >%s< key >%s<values >%s<", keys[0].latin1(), keys[1].latin1(), val.join(sep).latin1() );
cfg.setGroup(keys[0]);
cfg.writeEntry(keys[1], val, sep);
}
}
//
// cancel changes
//
void PPPData::cancel() {
stringEntries.clear();
intEntries.clear();
listEntries.clear();
}
// functions to read/write date to configuration file
QString PPPData::readConfig(const QString &group, const QString &key,
const QString &defvalue = "")
{
- qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
+// qDebug("PPPData::readConfig key >%s< group >%s<",key.latin1(), group.latin1());
QString idx = SEP.arg(group).arg(key);
if (stringEntries.find(idx) != stringEntries.end())
return stringEntries[idx];
Config cfg = config();
cfg.setGroup(group);
return cfg.readEntry(key, defvalue);
}
int PPPData::readNumConfig(const QString &group, const QString &key,
int defvalue)
{
QString idx = SEP.arg(group).arg(key);
if (intEntries.find(idx) != intEntries.end())
return intEntries[idx];
Config cfg = config();
cfg.setGroup(group);
return cfg.readNumEntry(key, defvalue);
// if (config) {
// config->setGroup(group);
// return config->readNumEntry(key, defvalue);
// } else
// return defvalue;
}
bool PPPData::readListConfig(const QString &group, const QString &key,
QStringList &list, char sep) {
list.clear();
QString idx = SEP.arg(group).arg(key);
if (listEntries.find(idx) != listEntries.end()){
list = listEntries[idx];
return true;
}
Config cfg = config();
cfg.setGroup(group);
list = cfg.readListEntry(key, sep);
if (list.count() > 0) return true;
return false;
// if (config) {
// config->setGroup(group);
// list = config->readListEntry(key, sep);
// return true;
// } else
// return false;
}
void PPPData::writeConfig(const QString &group, const QString &key,
const QString &value) {
stringEntries.insert( SEP.arg(group).arg(key), value );
// if (config) {
// config->setGroup(group);
// config->writeEntry(key, value);
// }
}
void PPPData::writeConfig(const QString &group, const QString &key, int value)
{
intEntries.insert( SEP.arg(group).arg(key), value );
// if (config) {
// config->setGroup(group);
// config->writeEntry(key, value);
// }
}
void PPPData::writeListConfig(const QString &group, const QString &key,
QStringList &list, char sep)
{
listEntries.insert( SEP.arg(group).arg(key), list );
sepEntries.insert( SEP.arg(group).arg(key), sep );
// if (config) {
// config->setGroup(group);
// config->writeEntry(key, list, sep);
// }
}
//
// functions to set/return general information
//
QString PPPData::password() const {
return passwd;
}
void PPPData::setPassword(const QString &pw) {
passwd = pw;
}