summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/TODO12
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp59
-rw-r--r--noncore/settings/networksettings/ppp/accounts.h18
-rw-r--r--noncore/settings/networksettings/ppp/authwidget.cpp195
-rw-r--r--noncore/settings/networksettings/ppp/authwidget.h46
-rw-r--r--noncore/settings/networksettings/ppp/connect.cpp1
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp52
-rw-r--r--noncore/settings/networksettings/ppp/edit.h3
-rw-r--r--noncore/settings/networksettings/ppp/interfaceinformationppp.cpp9
-rw-r--r--noncore/settings/networksettings/ppp/interfaceppp.cpp25
-rw-r--r--noncore/settings/networksettings/ppp/interfaceppp.h1
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.cpp2
-rw-r--r--noncore/settings/networksettings/ppp/ppp.pro6
-rw-r--r--noncore/settings/networksettings/ppp/pppconfig.cpp4
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.cpp26
-rw-r--r--noncore/settings/networksettings/ppp/pppdata.h4
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp6
17 files changed, 313 insertions, 156 deletions
diff --git a/noncore/settings/networksettings/ppp/TODO b/noncore/settings/networksettings/ppp/TODO
index 5635438..80fc5a6 100644
--- a/noncore/settings/networksettings/ppp/TODO
+++ b/noncore/settings/networksettings/ppp/TODO
@@ -1,7 +1,9 @@
-- add possibility to input username and password ;)
-- impl. PPPData::copyaccount & PPPData::deleteAccount
+- ask for password is non is set
+
+- stop pppd, i.e. fix interfaceinformationppp
+
- update modem attribute inputs when modem has changed
-- fix layout of edit account, i.e. get it shown maximised
-- popup configure modem with the correct account prselected
- not quite shure why it does not work... IMHO it should work
+- impl. PPPData::copyaccount & PPPData::deleteAccount
+- check if the same interface device combination allready exists
+- fix layout of edit account, i.e. get it shown maximised
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--)
diff --git a/noncore/settings/networksettings/ppp/accounts.h b/noncore/settings/networksettings/ppp/accounts.h
index eae3922..8c16a7c 100644
--- a/noncore/settings/networksettings/ppp/accounts.h
+++ b/noncore/settings/networksettings/ppp/accounts.h
@@ -17,84 +17,70 @@
* 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 AuthWidget;
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);
private:
int doTab();
signals:
void resetaccounts();
private:
QString prettyPrintVolume(unsigned int);
PPPData *_pppdata;
QTabWidget *tabWindow;
DialWidget *dial_w;
IPWidget *ip_w;
DNSWidget *dns_w;
GatewayWidget *gateway_w;
- ScriptWidget *script_w;
+ AuthWidget *auth_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);
-
-// enum {COSTS=1, VOLUME=2};
-
-// private slots:
-// void accepted();
-
-// private:
-// QCheckBox *costs, *volume;
-// };
-
#endif
diff --git a/noncore/settings/networksettings/ppp/authwidget.cpp b/noncore/settings/networksettings/ppp/authwidget.cpp
new file mode 100644
index 0000000..86bea98
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/authwidget.cpp
@@ -0,0 +1,195 @@
+
+#include <qlayout.h>
+#include <qmessagebox.h>
+#include <qtoolbutton.h>
+#include <qwhatsthis.h>
+
+#include "auth.h"
+#include "authwidget.h"
+#include "edit.h"
+#include "pppdata.h"
+
+
+static const char* const image0_data[] = {
+"16 16 2 1",
+". c None",
+"# c #000000",
+"................",
+"...#...###...##.",
+"..#.#..#..#.##..",
+"..###..###.##...",
+".#...#.#..##....",
+".#...#.#.##.....",
+"........##.#..#.",
+"..##...##...##..",
+".#..#.###...##..",
+".#...##..#.#..#.",
+".#..##..........",
+".#.##.#..#.#..#.",
+"..##...##...##..",
+".##....##...##..",
+".#....#..#.#..#.",
+"................"};
+
+
+AuthWidget::AuthWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
+ : QWidget( parent, name),
+ scriptWidget(0),
+ _pppdata(pd),
+ isNewAccount(isnewaccount)
+{
+ layout = new QGridLayout(this);
+
+ auth_l = new QLabel(tr("Authentication: "), this);
+ layout->addWidget(auth_l, 0, 0);
+
+ auth = new QComboBox(this);
+ auth->insertItem(tr("Script-based"));
+ auth->insertItem(tr("PAP"));
+ auth->insertItem(tr("Terminal-based"));
+ auth->insertItem(tr("CHAP"));
+ auth->insertItem(tr("PAP/CHAP"));
+ layout->addWidget(auth, 0, 1);
+
+ connect( auth, SIGNAL(activated(const QString&)),
+ SLOT(authChanged(const QString&)));
+
+ QString 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);
+
+ user_l = new QLabel( tr("Username: "), this);
+ layout->addWidget( user_l, 1, 0 );
+ userName = new QLineEdit( this, "usernameEdit" );
+ layout->addWidget( userName, 1, 1 );
+ tmp = tr("Enter your username here...");
+ QWhatsThis::add( user_l, tmp );
+ QWhatsThis::add( userName, tmp );
+
+ pw_l = new QLabel( tr("Password: "), this);
+ layout->addWidget( pw_l, 2, 0 );
+ passWord = new QLineEdit( this, "pw" );
+ passWord->setAutoMask( true );
+ passWord->setEchoMode( QLineEdit::Password );
+ layout->addWidget( passWord, 2, 1 );
+ hidePw = new QToolButton( this );
+ hidePw->setPixmap( QPixmap( ( const char** ) image0_data ) );
+ hidePw->setToggleButton( true );
+ layout->addWidget( hidePw, 2, 2 );
+
+ connect(hidePw, SIGNAL(toggled(bool)), SLOT(toggleEchoMode(bool)));
+
+ tmp = tr("Enter your password here");
+ QWhatsThis::add( pw_l, tmp );
+ QWhatsThis::add( passWord, tmp );
+
+ store_password = new QCheckBox(tr("Store password"), this);
+ layout->addMultiCellWidget(store_password, 3, 3, 0, 1, AlignRight);
+ QWhatsThis::add(store_password,
+ 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!"));
+
+ if (isNewAccount){
+ // select PAP/CHAP as default
+ auth->setCurrentItem(AUTH_PAPCHAP);
+ store_password->setChecked(true);
+ }else{
+ auth->setCurrentItem(_pppdata->authMethod());
+ authChanged( auth->currentText() );
+ userName->setText( _pppdata->storedUsername() );
+ store_password->setChecked(_pppdata->storePassword());
+ if (store_password->isChecked())
+ passWord->setText( _pppdata->storedPassword() );
+ }
+}
+
+bool AuthWidget::check()
+{
+ bool ret = true;
+ if (scriptWidget){
+ if (!scriptWidget->check()){
+ QMessageBox::critical(this, tr("error"), tr("<qt>Login script has unbalanced loop Start/End<qt>"));
+ ret = false;
+ }
+ }
+ return ret;
+}
+
+void AuthWidget::save()
+{
+ _pppdata->setAuthMethod(auth->currentItem());
+ if (scriptWidget) scriptWidget->save();
+ _pppdata->setStoredUsername( userName->text() );
+ _pppdata->setStorePassword(store_password->isChecked());
+ if (store_password->isChecked())
+ _pppdata->setStoredPassword( passWord->text() );
+}
+
+void AuthWidget::authChanged( const QString &authStr )
+{
+ qDebug("AuthWidget::authChanged( %s )", authStr.latin1() );
+ if ( authStr.contains( tr("Script-based") ) ){
+ showUsernamePassword( false );
+ showScriptWindow( true );
+ } else if ( authStr.contains( tr("PAP") ) ||
+ authStr.contains( tr("CHAP") ) ){
+ showUsernamePassword( true );
+ showScriptWindow( false );
+ } else {
+ qDebug("do not really know how to handle");
+ showUsernamePassword( false );
+ showScriptWindow( false );
+ }
+}
+
+
+void AuthWidget::showUsernamePassword( bool show )
+{
+ if (show){
+ user_l->show();
+ userName->show();
+ pw_l->show();
+ passWord->show();
+ store_password->show();
+ }else{//!show
+ user_l->hide();
+ userName->hide();
+ pw_l->hide();
+ passWord->hide();
+ store_password->hide();
+ }
+}
+
+void AuthWidget::showScriptWindow( bool show )
+{
+ if (show){
+ if (!scriptWidget){
+ scriptWidget = new ScriptWidget( _pppdata, this, isNewAccount, "scriptWid");
+ layout->addMultiCellWidget( scriptWidget, 1, 4, 0, 1 );
+ }
+ scriptWidget->show();
+ }else{ // !show
+ if (scriptWidget) scriptWidget->hide();
+ }
+}
+
+void AuthWidget::toggleEchoMode( bool t )
+{
+ passWord->setEchoMode( t ? QLineEdit::Normal : QLineEdit::Password );
+}
+
diff --git a/noncore/settings/networksettings/ppp/authwidget.h b/noncore/settings/networksettings/ppp/authwidget.h
new file mode 100644
index 0000000..33ec4c2
--- a/dev/null
+++ b/noncore/settings/networksettings/ppp/authwidget.h
@@ -0,0 +1,46 @@
+#ifndef _AUTHWIDGET_H
+#define _AUTHWIDGET_H
+
+#include <qwidget.h>
+
+class ScriptWidget;
+class PPPData;
+class QCheckBox;
+class QComboBox;
+class QLabel;
+class QGridLayout;
+class QLineEdit;
+class QToolButton;
+
+class AuthWidget : public QWidget {
+ Q_OBJECT
+public:
+ AuthWidget(PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
+ ~AuthWidget() {};
+
+public slots:
+ bool check();
+ void save();
+
+private slots:
+ void authChanged(const QString&);
+ void showUsernamePassword(bool);
+ void showScriptWindow(bool);
+ void toggleEchoMode(bool);
+
+private:
+ ScriptWidget *scriptWidget;
+ PPPData *_pppdata;
+ bool isNewAccount;
+ QGridLayout *layout;
+ QComboBox *auth;
+ QLabel *auth_l;
+ QLabel *user_l;
+ QLineEdit *userName;
+ QLabel *pw_l;
+ QLineEdit *passWord;
+ QToolButton *hidePw;
+ QCheckBox *store_password;
+};
+
+#endif
diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp
index 89d9930..a93f93d 100644
--- a/noncore/settings/networksettings/ppp/connect.cpp
+++ b/noncore/settings/networksettings/ppp/connect.cpp
@@ -103,48 +103,49 @@ ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *nam
setCaption(tit);
QHBoxLayout *l0 = new QHBoxLayout(10);
tl->addLayout(l0);
l0->addSpacing(10);
messg = new QLabel(this, "messg");
messg->setFrameStyle(QFrame::Panel|QFrame::Sunken);
messg->setAlignment(AlignCenter);
messg->setText(i18n("Unable to create modem lock file."));
messg->setMinimumHeight(messg->sizeHint().height() + 5);
// int messw = (messg->sizeHint().width() * 12) / 10;
// messw = QMAX(messw,280);
// messg->setMinimumWidth(messw);
messg->setText(i18n("Offline"));
l0->addSpacing(10);
l0->addWidget(messg);
l0->addSpacing(10);
QHBoxLayout *l1 = new QHBoxLayout(10);
tl->addLayout(l1);
l1->addStretch(1);
debug = new QPushButton(i18n("Log"), this);
debug->setToggleButton(true);
+ debug->setEnabled( false ); // FIXME: disable the log button
connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow()));
cancel = new QPushButton(i18n("Cancel"), this);
cancel->setFocus();
connect(cancel, SIGNAL(clicked()), SLOT(cancelbutton()));
// int maxw = QMAX(cancel->sizeHint().width(),
// debug->sizeHint().width());
// maxw = QMAX(maxw,65);
// debug->setFixedWidth(maxw);
// cancel->setFixedWidth(maxw);
l1->addWidget(debug);
l1->addWidget(cancel);
// setFixedSize(sizeHint());
pausetimer = new QTimer(this);
connect(pausetimer, SIGNAL(timeout()), SLOT(pause()));
qApp->processEvents();
timeout_timer = new QTimer(this);
connect(timeout_timer, SIGNAL(timeout()), SLOT(script_timed_out()));
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index 45d6e4f..b880978 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -13,211 +13,167 @@
* 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 <qbuttongroup.h>
#include <qvgroupbox.h>
#include <qhbox.h>
#include <qdialog.h>
+#include <qpe/resource.h>
#include "edit.h"
#include "pppdata.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());
+ QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 );
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 = tr("Type in a unique name for this connection");
QWhatsThis::add(connect_label,tmp);
QWhatsThis::add(connectname_l,tmp);
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(tr("&Add..."), this);
del = new QPushButton(tr("&Remove"), this);
up = new QPushButton(this);
-//FIXME: QPixmap pm = BarIcon("up");
-// up->setPixmap(pm);
+ up->setPixmap( Resource::loadPixmap("inline/up") );
down = new QPushButton(this);
-//FIXME: pm = BarIcon("down");
-// down->setPixmap(pm);
+ down->setPixmap( Resource::loadPixmap("inline/down") );
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 = 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(tr("Authentication:"), this);
- tl->addWidget(auth_l, 3, 0);
-
- auth = new QComboBox(this);
- 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 = 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(tr("Store password"), this);
- store_password->setChecked(true);
- tl->addMultiCellWidget(store_password, 4, 4, 0, 1, AlignRight);
- QWhatsThis::add(store_password,
- 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(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();
diff --git a/noncore/settings/networksettings/ppp/edit.h b/noncore/settings/networksettings/ppp/edit.h
index 2cc0fed..8b5ec03 100644
--- a/noncore/settings/networksettings/ppp/edit.h
+++ b/noncore/settings/networksettings/ppp/edit.h
@@ -49,51 +49,48 @@
class IPLineEdit;
class PPPData;
class DialWidget : public QWidget {
Q_OBJECT
public:
DialWidget( PPPData*, QWidget *parent=0, bool isnewaccount = true, const char *name=0 );
~DialWidget() {}
public slots:
bool save();
void pppdargsbutton();
void numbersChanged();
void selectionChanged(int);
void addNumber();
void delNumber();
void upNumber();
void downNumber();
private:
QLineEdit *connectname_l;
QLabel *connect_label;
QLabel *number_label;
QPushButton *pppdargs;
- QComboBox *auth;
- QLabel *auth_l;
- QCheckBox *store_password;
// for the phonenumber selection
QPushButton *add, *del, *up, *down;
QListBox *numbers;
PPPData *_pppdata;
};
/////////////////////////////////////////////////////////////////////////////
//
// tab-window to select what to execute when
//
/////////////////////////////////////////////////////////////////////////////
class ExecWidget : public QWidget {
Q_OBJECT
public:
ExecWidget(PPPData*, QWidget *parent=0, bool isnewaccount=true, const char *name=0);
public slots:
bool save();
private:
QLineEdit *before_connect;
QLabel *before_connect_l;
diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
index 3cf1167..553daa2 100644
--- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
+++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp
@@ -1,32 +1,37 @@
#include "interfaceinformationppp.h"
#include <qpushbutton.h>
#include <qlabel.h>
//#include <qgroupbox.h>
#include <qmessagebox.h>
+#include <qabstractlayout.h>
#include "connect.h"
#include "conwindow.h"
#ifdef QWS
#else
#define showMaximized show
#endif
/**
* Constructor for the InterfaceInformationImp class. This class pretty much
* just display's information about the interface that is passed to it.
*/
InterfaceInformationPPP::InterfaceInformationPPP(QWidget *parent, const char *name, Interface *i, WFlags f)
:InterfaceInformationImp(parent, name, i, f)
{
qDebug("InterfaceInformationPPP::InterfaceInformationPPP");
con = new ConnectWidget( (InterfacePPP*)i, this, "con" );
- // InterfaceInformationLayout->addMultiCellWidget( con, 7, 7, 0, 1 );
- InterfaceInformationLayout->addWidget( con, 7, 0 );
+ con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding,
+ QSizePolicy::Fixed) );
+ QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ InterfaceInformationLayout->addItem( spacer, 7, 0 );
+ InterfaceInformationLayout->addMultiCellWidget( con, 8, 8, 0, 1 );
+ // InterfaceInformationLayout->addWidget( con, 7, 0 );
connect(i, SIGNAL(begin_connect()),con, SLOT(preinit()));
}
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp
index dc24824..98bb4da 100644
--- a/noncore/settings/networksettings/ppp/interfaceppp.cpp
+++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp
@@ -24,118 +24,117 @@ PPPData* InterfacePPP::data()
_dataPtr->setAccount( getHardwareName() );
}
return _dataPtr;
}
Modem* InterfacePPP::modem()
{
if (!_modemPtr){
qDebug("creating new modem obj");
_modemPtr = new Modem( data() );
}
return _modemPtr;
}
bool InterfacePPP::refresh()
{
qDebug("InterfacePPP::refresh()");
QMessageBox::information(0,"Not Implemented","This feature is not yet implemneted... ;-(");
return false;
}
void InterfacePPP::start()
{
qDebug("InterfacePPP::start");
- if (data()->storedPassword() != "" ){
- data()->setPassword(data()->storedPassword());
- }else{
- //FIXME:
+ if (data()->password().isEmpty() ){
+//FIXME: ask for password
qDebug("using dummy password");
- data()->setPassword( "dummy" );
+ QMessageBox::critical( 0, "no password", "you should be prompted for a password, but you are not! ;-)");
}
QFileInfo info(pppdPath());
if(!info.exists()){
QMessageBox::warning(0, tr("Error"),
i18n("<qt>Cannot find the PPP daemon!<br>"
"Make sure that pppd is installed and "
"that you have entered the correct path.</qt>"));
return;
}
//#if 0
if(!info.isExecutable()){
QString string;
string = i18n( "<qt>Cannot execute:<br> %1<br>"
"Please make sure that you have given "
"setuid permission and that "
"pppd is executable.<br>").arg(pppdPath());
QMessageBox::warning(0, tr("Error"), string);
return;
}
//#endif
QFileInfo info2(data()->modemDevice());
if(!info2.exists()){
QString string;
string = i18n( "<qt>Cannot find:<br> %1<br>"
"Please make sure you have setup "
"your modem device properly "
"and/or adjust the location of the modem device on "
"the modem tab of "
"the setup dialog.</qt>").arg(data()->modemDevice());
QMessageBox::warning(0, tr("Error"), string);
return;
}
// if this is a PAP or CHAP account, ensure that username is
// supplied
if(data()->authMethod() == AUTH_PAP ||
data()->authMethod() == AUTH_CHAP ||
data()->authMethod() == AUTH_PAPCHAP ) {
- if(false){ //ID_Edit->text().isEmpty()) {
+ if(false){ //FIXME: ID_Edit->text().isEmpty()) {
QMessageBox::warning(0,tr("Error"),
i18n("<qt>You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!</qt>"));
// FIXME: return;
} else {
if(!modem()->setSecret(data()->authMethod(),
PPPData::encodeWord(data()->storedUsername()),
PPPData::encodeWord(data()->password()))
) {
QString s;
s = i18n("<qt>Cannot create PAP/CHAP authentication<br>"
"file \"%1\"</qt>").arg(PAP_AUTH_FILE);
QMessageBox::warning(0, tr("Error"), s);
return;
}
}
}
if (data()->phonenumber().isEmpty()) {
QString s = i18n("You must specify a telephone number!");
QMessageBox::warning(0, tr("Error"), s);
return;
}
-// this->hide();
-
- QString tit = i18n("Connecting to: %1").arg(data()->accname());
-// con->setCaption(tit);
-
-// con->show();
-
+ // SEGFAULTS:
+// setStatus( true );
+// emit updateInterface((Interface*) this);
emit begin_connect();
qDebug("InterfacePPP::start END");
}
void InterfacePPP::stop()
{
qDebug("InterfacePPP::stop");
}
+void InterfacePPP::save()
+{
+ data()->save();
+ emit updateInterface((Interface*) this);
+}
diff --git a/noncore/settings/networksettings/ppp/interfaceppp.h b/noncore/settings/networksettings/ppp/interfaceppp.h
index 06a4dbf..6eb6a69 100644
--- a/noncore/settings/networksettings/ppp/interfaceppp.h
+++ b/noncore/settings/networksettings/ppp/interfaceppp.h
@@ -2,32 +2,33 @@
#define INTERFACEPPP_H
#include "interface.h"
class PPPData;
class Modem;
class InterfacePPP : public Interface
{
Q_OBJECT
public:
InterfacePPP(QObject *parent=0, const char *name="PPP", bool status=false);
PPPData* data();
Modem* modem();
signals:
void begin_connect();
public slots:
virtual bool refresh();
virtual void start();
virtual void stop();
+ void save();
private:
Modem *_modemPtr;
PPPData *_dataPtr;
};
#endif
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp
index 289e9f5..7b5c74d 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.cpp
+++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp
@@ -579,49 +579,49 @@ void KPPPWidget::beginConnect() {
}
#endif
QFileInfo info2(_pppdata->modemDevice());
if(!info2.exists()){
QString string;
string = i18n("kppp can not find:\n %1\nPlease make sure you have setup "
"your modem device properly "
"and/or adjust the location of the modem device on "
"the modem tab of "
"the setup dialog.").arg(_pppdata->modemDevice());
QMessageBox::warning(this, "error", string);
return;
}
// if this is a PAP or CHAP account, ensure that username is
// supplied
if(_pppdata->authMethod() == AUTH_PAP ||
_pppdata->authMethod() == AUTH_CHAP ||
_pppdata->authMethod() == AUTH_PAPCHAP ) {
if(ID_Edit->text().isEmpty()) {
QMessageBox::warning(this,"error",
i18n("You have selected the authentication method PAP or CHAP. This requires that you supply a username and a password!"));
-// FIXME: return;
+ return;
} else {
if(!Modem::modem->setSecret(_pppdata->authMethod(),
encodeWord(_pppdata->storedUsername()),
encodeWord(_pppdata->password()))) {
QString s;
s = i18n("Cannot create PAP/CHAP authentication\n"
"file \"%1\"").arg(PAP_AUTH_FILE);
QMessageBox::warning(this, "error", s);
return;
}
}
}
if (_pppdata->phonenumber().isEmpty()) {
QString s = i18n("You must specify a telephone number!");
QMessageBox::warning(this, "error", s);
return;
}
this->hide();
QString tit = i18n("Connecting to: %1").arg(_pppdata->accname());
// con->setCaption(tit);
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro
index 483aa58..56a7ace 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -1,20 +1,18 @@
#TEMPLATE = app
#
TEMPLATE = lib
#CONFIG += qt warn_on release
CONFIG += qt warn_on debug
DESTDIR = $(OPIEDIR)/plugins/networksettings
-HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h
-# kpppwidget.h
-SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp
-# kpppwidget.cpp
+HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h interfaceinformationppp.h interfaceppp.h authwidget.h
+SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp interfaceinformationppp.cpp interfaceppp.cpp authwidget.cpp
INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -L../interfaces/ -linterfaces
INTERFACES =
TARGET = pppplugin
VERSION = 1.0.0
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/settings/networksettings/ppp/pppconfig.cpp b/noncore/settings/networksettings/ppp/pppconfig.cpp
index 63f9335..5fa7d3f 100644
--- a/noncore/settings/networksettings/ppp/pppconfig.cpp
+++ b/noncore/settings/networksettings/ppp/pppconfig.cpp
@@ -21,52 +21,50 @@ PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent,
if(result == TEST_CRITICAL){
QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") );
return;
}
interface = iface;
qDebug("PPPConfigWidget::PPPConfigWidget");
qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1());
qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1());
qDebug(" _pppdata->currentAccountID() >%i<",interface->data()->currentAccountID());
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 0 );
layout->setMargin( 1 );
tabWindow = new QTabWidget( this, "tabWidget" );
layout->addWidget( tabWindow );
accounts = new AccountWidget( interface->data(), tabWindow, "accounts" );
tabWindow->addTab( accounts, tr("&Accounts") );
modem1 = new ModemWidget( interface, tabWindow, "modem1" );
tabWindow->addTab( modem1, tr("&Device") );
modem2 = new ModemWidget2( interface, tabWindow, "modem2" );
tabWindow->addTab( modem2, tr("&Modem") );
-// graph = new GraphSetup( tabWindow->addPage( tr("&Graph"), tr("Throughput Graph" ) ) );
-// general = new GeneralWidget( tabWindow->addPage( tr("M&isc"), tr("Miscellaneous Settings") ) );
}
PPPConfigWidget::~PPPConfigWidget()
{
}
void PPPConfigWidget::accept()
{
qDebug("PPPConfigWidget::accept");
qDebug(" _pppdata->accname >%s<",interface->data()->accname().latin1());
qDebug(" interface->getHardwareName >%s<", interface->getHardwareName().latin1());
interface->setInterfaceName( interface->data()->modemDevice() );
interface->setHardwareName( interface->data()->accname() );
- interface->data()->save();
+ interface->save();
QDialog::accept();
}
void PPPConfigWidget::reject()
{
interface->data()->cancel();
QDialog::reject();
}
diff --git a/noncore/settings/networksettings/ppp/pppdata.cpp b/noncore/settings/networksettings/ppp/pppdata.cpp
index 23db409..8f066ff 100644
--- a/noncore/settings/networksettings/ppp/pppdata.cpp
+++ b/noncore/settings/networksettings/ppp/pppdata.cpp
@@ -22,53 +22,54 @@
* 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 "pppdata.h"
#include "runtests.h"
#include "devices.h"
//#include <klocale.h>
#define i18n QObject::tr
#include <qpe/config.h>
#include <qmessagebox.h>
#include <qapplication.h>
// #include <klocale.h>
// #include <kconfig.h>
// #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)
+ passwd(""),
+ 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");
}
@@ -196,50 +197,51 @@ 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;
+QString PPPData::password(){
+ if ( storePassword() ) return storedPassword();
+ else return passwd;
}
void PPPData::setPassword(const QString &pw) {
passwd = pw;
}
const QString PPPData::defaultAccount() {
return readConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY);
}
void PPPData::setDefaultAccount(const QString &n) {
writeConfig(GENERAL_GRP, DEFAULTACCOUNT_KEY, n);
//now set the current account index to the default account
setAccount(defaultAccount());
}
bool PPPData::get_show_clock_on_caption() {
return (bool) readNumConfig(GENERAL_GRP, SHOWCLOCK_KEY, true);
}
@@ -732,49 +734,49 @@ bool PPPData::setAccountbyIndex(int i) {
if(i >= 0 && i <= highcount) {
caccount = i;
cgroup.sprintf("%s%i", ACCOUNT_GRP, i);
return true;
}
return false;
}
bool PPPData::isUniqueAccname(const QString &n) {
int current = caccount;
for(int i=0; i <= highcount; i++) {
setAccountbyIndex(i);
if(accname() == n && i != current) {
setAccountbyIndex(current);
return false;
}
}
setAccountbyIndex(current);
return true;
}
bool PPPData::deleteAccount() {
- //FIXME:
+ //FIXME: PPPData::deleteAccount
// if(caccount < 0)
return false;
// QMap <QString, QString> map;
// QMap <QString, QString>::Iterator it;
// // set all entries of the current account to ""
// map = config->entryMap(cgroup);
// it = map.begin();
// while (it != map.end()) {
// config->writeEntry(it.key(), "");
// it++;
// }
// // shift the succeeding accounts
// for(int i = caccount+1; i <= highcount; i++) {
// setAccountbyIndex(i);
// map = config->entryMap(cgroup);
// it = map.begin();
// setAccountbyIndex(i-1);
// config->setGroup(cgroup);
// while (it != map.end()) {
// config->writeEntry(it.key(), *it);
// it++;
@@ -805,49 +807,49 @@ bool PPPData::deleteAccount(const QString &aname) {
if(!setAccount(aname))
return false;
deleteAccount();
return true;
}
int PPPData::newaccount() {
qDebug("PPPData::newaccount highcount %i/%i",highcount,MAX_ACCOUNTS);
// if(!config) open();
if (highcount >= MAX_ACCOUNTS) return -1;
highcount++;
setAccountbyIndex(highcount);
setpppdArgumentDefaults();
qDebug("PPPData::newaccount -> %i",caccount);
return caccount;
}
int PPPData::copyaccount(int i) {
-// FIXME
+// FIXME: PPPData::copyaccount
// if(highcount >= MAX_ACCOUNTS)
return -1;
// setAccountbyIndex(i);
// QMap <QString, QString> map = config->entryMap(cgroup);
// QMap <QString, QString>::ConstIterator it = map.begin();
// QString newname = i18n("%1_copy").arg(accname());
// newaccount();
// while (it != map.end()) {
// config->writeEntry(it.key(), *it);
// it++;
// }
// setAccname(newname);
// return caccount;
}
const QString PPPData::accname() {
@@ -1255,44 +1257,46 @@ QString PPPData::modemGroup()
QMap<QString,QString> PPPData::getConfiguredInterfaces()
{
QMap<QString,QString> ifaces;
Config config = PPPData::config();
config.setGroup(ACCLIST_GRP);
int count = config.readNumEntry( ACCOUNTS_COUNT, -1 );
QString accGrp, dev, acc;
for (int i = 0; i < count; i++){
accGrp = QString("%1_%1").arg(ACCLIST_GRP).arg(i);
config.setGroup(accGrp);
dev = config.readEntry( ACOUNTS_DEV, "error" );
acc = config.readEntry( ACOUNTS_ACC, "error" );
ifaces.insert( dev, acc );
}
return ifaces;
}
void PPPData::setConfiguredInterfaces( QMap<QString,QString> ifaces )
{
QMap<QString,QString>::Iterator it;
int i = 0;
Config cfg = config();
- for( it = ifaces.begin(); it != ifaces.end(); ++it, ++i ){
- cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i));
+ for( it = ifaces.begin(); it != ifaces.end(); ++it ){
+ cfg.setGroup(QString("%1_%1").arg(ACCLIST_GRP).arg(i++));
cfg.writeEntry( ACOUNTS_DEV, it.key() );
cfg.writeEntry( ACOUNTS_ACC, it.data() );
+ qDebug("I %i",i);
}
cfg.setGroup( ACCLIST_GRP );
+ qDebug("saved %i account settings", i);
cfg.writeEntry( ACCOUNTS_COUNT, i );
}
/**
* pppd's getword() function knows about escape characters.
* If we write the username and password to the secrets file
* we'll therefore have to escape back slashes.
*/
QString PPPData::encodeWord(const QString &s) {
QString r = s;
r.replace(QRegExp("\\"), "\\\\");
return r;
}
diff --git a/noncore/settings/networksettings/ppp/pppdata.h b/noncore/settings/networksettings/ppp/pppdata.h
index c9cd482..6e1379d 100644
--- a/noncore/settings/networksettings/ppp/pppdata.h
+++ b/noncore/settings/networksettings/ppp/pppdata.h
@@ -160,52 +160,52 @@ public:
// general functions
void save();
void cancel();
static QMap<QString,QString> getConfiguredInterfaces();
static void setConfiguredInterfaces( QMap<QString,QString> );
// function to read/write date to configuration file
static Config config();
QString readConfig(const QString &, const QString &, const QString &);
int readNumConfig(const QString &, const QString &, int);
bool readListConfig(const QString &, const QString &,
QStringList &, char sep = ',');
void writeConfig(const QString &, const QString &, const QString &);
void writeConfig(const QString &, const QString &, int);
void writeListConfig(const QString &, const QString &,
QStringList &, char sep = ',');
// return the current account group
QString currentGroup() { return cgroup; }
QString modemGroup();
// functions to set/get general kppp info
- QString password() const;
+ QString password();
void setPassword(const QString &);
- int currentAccountID() { return caccount; };
+ int currentAccountID() { return caccount; };
const QString defaultAccount();
void setDefaultAccount(const QString &);
void set_xserver_exit_disconnect(bool set);
bool get_xserver_exit_disconnect();
void setPPPDebug(bool set);
bool getPPPDebug();
void set_quit_on_disconnect(bool);
bool quit_on_disconnect();
void set_show_clock_on_caption(bool set);
bool get_show_clock_on_caption();
void set_show_log_window(bool set);
bool get_show_log_window();
void set_automatic_redial(bool set);
bool automatic_redial();
// void set_iconify_on_connect(bool set);
// bool get_iconify_on_connect();
diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index 8c401a9..d4c137b 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -59,52 +59,50 @@ QString PPPModule::getPixmapName(Interface* ){
*/
bool PPPModule::isOwner(Interface *i){
return list.find( i ) != -1;
}
/**
* Create, and return the WLANConfigure Module
* @return QWidget* pointer to this modules configure.
*/
QWidget *PPPModule::configure(Interface *i){
qDebug("return ModemWidget");
PPPConfigWidget *pppconfig = new PPPConfigWidget( (InterfacePPP*)i,
0, "PPPConfig", false,
Qt::WDestructiveClose );
return pppconfig;
}
/**
* Create, and return the Information Module
* @return QWidget* pointer to this modules info.
*/
QWidget *PPPModule::information(Interface *i){
// We don't have any advanced pppd information widget yet :-D
// TODO ^
- qDebug("return PPPModule::information");
-// InterfaceInformationImp *information = new InterfaceInformationImp( 0, "InterfaceSetupImp", i);
- InterfaceInformationPPP *information = new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i );
- return information;
+
+ return new InterfaceInformationPPP( 0, "InterfaceInformationPPP", i );
}
/**
* Get all active (up or down) interfaces
* @return QList<Interface> A list of interfaces that exsist that havn't
* been called by isOwner()
*/
QList<Interface> PPPModule::getInterfaces(){
// List all of the files in the peer directory
qDebug("PPPModule::getInterfaces");
return list;
}
/**
* Attempt to add a new interface as defined by name
* @param name the name of the type of interface that should be created given
* by possibleNewInterfaces();
* @return Interface* NULL if it was unable to be created.
*/
Interface *PPPModule::addNewInterface(const QString &newInterface){
InterfacePPP *ifaceppp;
Interface *iface;
ifaceppp = new InterfacePPP();