summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/debug.cpp141
-rw-r--r--noncore/settings/networksettings/ppp/debug.h70
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.cpp26
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.h43
-rw-r--r--noncore/settings/networksettings/ppp/ppp.pro4
-rw-r--r--noncore/settings/networksettings/ppp/pppmodule.cpp1
6 files changed, 3 insertions, 282 deletions
diff --git a/noncore/settings/networksettings/ppp/debug.cpp b/noncore/settings/networksettings/ppp/debug.cpp
deleted file mode 100644
index 447ccf2..0000000
--- a/noncore/settings/networksettings/ppp/debug.cpp
+++ b/dev/null
@@ -1,141 +0,0 @@
-/*
- * kPPP: A pppd front end for the KDE project
- *
- * $Id$
- * Copyright (C) 1997 Bernd Wuebben
- * wuebben@math.cornel.edu
- *
- * 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 "debug.h"
-//#include "main.h"
-#include "pppdata.h"
-//#include <klocale.h>
-#define i18n QObject::tr
-#include "kpppwidget.h"
-#include <assert.h>
-
-extern KPPPWidget *p_kppp;
-
-myMultiEdit::myMultiEdit(QWidget *parent, const char *name)
- : QMultiLineEdit(parent, name)
-{
- setReadOnly(true);
-}
-
-void myMultiEdit::insertChar(unsigned char c) {
- QMultiLineEdit::insert(QChar(c));
-}
-
-
-void myMultiEdit::newLine() {
- QMultiLineEdit::newLine();
-}
-
-
-DebugWidget::DebugWidget(QWidget *parent, const char *name)
- : QDialog(parent, name, FALSE)
-{
- setCaption(i18n("Login Script Debug Window"));
-
- text_window = new myMultiEdit(this,"debugwindow");
- text_window->setGeometry(2,5,400, 300);
- // text_window->setReadOnly(FALSE);
-
- statuslabel = new QLabel("", this, "statuslabel");
-
- statuslabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
- statuslabel->setAlignment( AlignLeft|AlignVCenter );
- statuslabel->setGeometry(2, 307, 400, 20);
- //statusPageLabel->setFont( QFont("helvetica",12,QFont::Normal) );
-
- dismiss = new QPushButton(this);
- dismiss->setGeometry(330,340,70,30);
- dismiss->setText(i18n("Close"));
- dismiss->setFocus();
- connect(dismiss, SIGNAL(clicked()), SLOT(hide()));
-
-
- /* fline = new QFrame(this,"line");
- fline->setFrameStyle(QFrame::HLine |QFrame::Sunken);
- fline->setGeometry(2,332,398,5);*/
- adjustSize();
- setMinimumSize(width(),height());
-
-}
-
-void DebugWidget::hideEvent(QHideEvent *)
-{
- assert(p_kppp);
-// p_kppp->con->debug->setOn(false);
-}
-
-void DebugWidget::clear() {
- text_window->clear();
-}
-
-
-void DebugWidget::addChar(unsigned char c) {
- QString stuff;
-
- if(c == '\r' || c == '\n') {
- if(c == '\n')
- text_window->newLine();
- } else
- text_window->insertChar(c);
-}
-
-
-void DebugWidget::statusLabel(const QString &s) {
- statuslabel->setText(s);
-}
-
-
-/*
-void DebugWidget::keyPressEvent(QKeyEvent *k) {
-}
-
-*/
-void DebugWidget::resizeEvent(QResizeEvent *e){
- int w = width() ;
- int h = height();
- e = e;
-
- text_window->setGeometry(2,5,w - 2 ,h - 63);
- statuslabel->setGeometry(2, h - 56 , w -2 , 20);
- dismiss->setGeometry(w - 72 , h - 32, 70, 30);
- // fline->setGeometry(2,h -70 ,w - 4,5);
-}
-
-
-void DebugWidget::enter() {
- text_window->append("\r\n");
-}
-
-
-void DebugWidget::toggleVisibility() {
- if(isVisible())
- hide();
- else
- show();
-
- bool showlog = isVisible();
- PPPData::data()->set_show_log_window(showlog);
-}
-
-
-
-
diff --git a/noncore/settings/networksettings/ppp/debug.h b/noncore/settings/networksettings/ppp/debug.h
deleted file mode 100644
index 3565cec..0000000
--- a/noncore/settings/networksettings/ppp/debug.h
+++ b/dev/null
@@ -1,70 +0,0 @@
-/*
- * kPPP: A pppd front end for the KDE project
- *
- * $Id$
- * Copyright (C) 1997 Bernd Wuebben
- * wuebben@math.cornel.edu
- *
- *
- * 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 _DEBUGWIDGET_
-#define _DEBUGWIDGET_
-
-#include <qdialog.h>
-#include <qstring.h>
-#include <qlabel.h>
-#include <qmultilineedit.h>
-#include <qpushbutton.h>
-
-
-class myMultiEdit : public QMultiLineEdit {
-public:
-
- myMultiEdit(QWidget *parent=0, const char *name=0);
-
- void newLine();
- void insertChar(unsigned char c);
-};
-
-
-class DebugWidget : public QDialog {
- Q_OBJECT
-public:
- DebugWidget(QWidget *parent=0, const char *name=0);
-
- void clear();
-
-public slots:
- void statusLabel(const QString &);
- void toggleVisibility();
- void addChar(unsigned char);
-
-protected:
- virtual void hideEvent(QHideEvent *);
- virtual void resizeEvent(QResizeEvent *e);
-
-private:
- void enter();
- QFrame *fline;
- QPushButton *dismiss;
- myMultiEdit *text_window;
-
- QLabel *statuslabel;
-};
-
-#endif
-
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp
index 8d70cd4..f8a8dc3 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.cpp
+++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp
@@ -52,787 +52,761 @@
// #include <kstandarddirs.h>
// #include <kwin.h>
// #include <khelpmenu.h>
#include <qpushbutton.h>
//#include <kguiitem.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include "runtests.h"
//#include "main.h"
#include "auth.h"
#include "modem.h"
//#include "ppplog.h"
//#include "opener.h"
//#include "requester.h"
//#include "pppstats.h"
#include "pppdata.h"
#include "general.h"
#define execute_command system
KPPPWidget *p_kppp = 0;
KPPPWidget::KPPPWidget( QWidget *parent, const char *name, bool modal, WFlags fl )
: QDialog(parent, name, modal, fl)
// , acct(0)
// , m_bCmdlAccount (false)
{
// tabWindow = 0;
p_kppp = this;
// before doing anything else, run a few tests
int result = runTests();
if(result == TEST_CRITICAL)
exit(4);
// installEventFilter(this);
// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
// QGridLayout *l1 = new QGridLayout(3, 4);
// tl->addLayout(l1);
// l1->addColSpacing(0, 10);
// l1->addColSpacing(3, 10);
// l1->setColStretch(1, 3);
// l1->setColStretch(2, 4);
// label1 = new QLabel(i18n("C&onnect to: "), this);
// l1->addWidget(label1, 0, 1);
// connectto_c = new QComboBox(false, this);
// label1->setBuddy(connectto_c);
// connect(connectto_c, SIGNAL(activated(int)),
// SLOT(newdefaultaccount(int)));
// l1->addWidget(connectto_c, 0, 2);
// ID_Label = new QLabel(i18n("&Login ID:"), this);
// l1->addWidget(ID_Label, 1, 1);
// // the entry line for usernames
// ID_Edit = new QLineEdit(this);
// ID_Label->setBuddy(ID_Edit);
// l1->addWidget(ID_Edit, 1, 2);
// connect(ID_Edit, SIGNAL(returnPressed()),
// this, SLOT(enterPressedInID()));
// QString tmp = i18n("<p>Type in the username that you got from your\n"
// "ISP. This is especially important for PAP\n"
// "and CHAP. You may omit this when you use\n"
// "terminal-based or script-based authentication.\n"
// "\n"
// "<b>Important</b>: case is important here:\n"
// "<i>myusername</i> is not the same as <i>MyUserName</i>!");
// QWhatsThis::add(ID_Label,tmp);
// QWhatsThis::add(ID_Edit,tmp);
// PW_Label = new QLabel(i18n("&Password:"), this);
// l1->addWidget(PW_Label, 2, 1);
// PW_Edit= new QLineEdit(this);
// PW_Label->setBuddy(PW_Edit);
// PW_Edit->setEchoMode(QLineEdit::Password);
// l1->addWidget(PW_Edit, 2, 2);
// connect(PW_Edit, SIGNAL(returnPressed()),
// this, SLOT(enterPressedInPW()));
// tmp = i18n("<p>Type in the password that you got from your\n"
// "ISP. This is especially important for PAP\n"
// "and CHAP. You may omit this when you use\n"
// "terminal-based or script-based authentication.\n"
// "\n"
// "<b>Important</b>: case is important here:\n"
// "<i>mypassword</i> is not the same as <i>MyPassword</i>!");
// QWhatsThis::add(PW_Label,tmp);
// QWhatsThis::add(PW_Edit,tmp);
// QHBoxLayout *l3 = new QHBoxLayout;
// tl->addSpacing(5);
// tl->addLayout(l3);
// tl->addSpacing(5);
// l3->addSpacing(10);
// log = new QCheckBox(i18n("Show lo&g window"), this);
// connect(log, SIGNAL(toggled(bool)),
// this, SLOT(log_window_toggled(bool)));
// log->setChecked(PPPData::data()->get_show_log_window());
// l3->addWidget(log);
// QWhatsThis::add(log,
// i18n("<p>This controls whether a log window is shown.\n"
// "A log window shows the communication between\n"
// "<i>kppp</i> and your modem. This will help you\n"
// "in tracking down problems.\n"
// "\n"
// "Turn it off if <i>kppp</i> routinely connects without\n"
// "problems"));
// // fline = new QSeparator( KSeparator::HLine, this);
// // tl->addWidget(fline);
// QHBoxLayout *l2 = new QHBoxLayout(this);
// tl->addLayout(l2);
// int minw = 0;
// quit_b = new QPushButton(i18n("&Quit"), this);
// // quit_b-> setGuiItem (KGuiItem(i18n("&Quit"), "exit" ) );
// connect( quit_b, SIGNAL(clicked()), SLOT(quitbutton()));
// if(quit_b->sizeHint().width() > minw)
// minw = quit_b->sizeHint().width();
// setup_b = new QPushButton(i18n("&Setup..."), this);
// // setup_b->setGuiItem (KGuiItem(i18n("&Setup...")) );
// connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton()));
// if(setup_b->sizeHint().width() > minw)
// minw = setup_b->sizeHint().width();
// if(PPPData::data()->access() != KConfig::ReadWrite)
// setup_b->setEnabled(false);
// help_b = new QPushButton(i18n("&Help"), this);
// connect( help_b, SIGNAL(clicked()), SLOT(helpbutton()));
// KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true);
// help_b->setPopup((QPopupMenu*)helpMenu->menu());
// help_b->setGuiItem (KGuiItem(i18n("&Help"), "help" ) );
// if(help_b->sizeHint().width() > minw)
// minw = help_b->sizeHint().width();
// connect_b = new QPushButton(i18n("&Connect"), this);
// connect_b->setDefault(true);
// connect_b->setFocus();
// connect(connect_b, SIGNAL(clicked()), SLOT(beginConnect()));
// if(connect_b->sizeHint().width() > minw)
// minw = connect_b->sizeHint().width();
// quit_b->setFixedWidth(minw);
// setup_b->setFixedWidth(minw);
// // help_b->setFixedWidth(help_b->sizeHint().width());
// connect_b->setFixedWidth(minw);
// l2->addWidget(quit_b);
// l2->addWidget(setup_b);
// // l2->addWidget(help_b);
// l2->addSpacing(20);
// l2->addWidget(connect_b);
setFixedSize(sizeHint());
(void)new Modem;
// we also connect cmld_start to the beginConnect so that I can run
// the dialer through a command line argument
connect(this,SIGNAL(cmdl_start()),this,SLOT(beginConnect()));
// stats = new PPPStats;
// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
// constructor of con_win reads position from config file
// con_win = new ConWindow(0, "conw", this);
// KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon());
// statdlg = new PPPStatsDlg(0, "stats", this, stats);
// statdlg->hide();
- debugwindow = new DebugWidget(0,"debugwindow");
- // KWin::setIcons(debugwindow->winId(), kapp->icon(), kapp->miniIcon());
- debugwindow->hide();
-
// load up the accounts combo box
// resetaccounts();
// con = new ConnectWidget(0, "con");
//KWin::setIcons(con->winId(), kapp->icon(), kapp->miniIcon() );
// connect(this, SIGNAL(begin_connect()),con, SLOT(preinit()));
// Is this the best we can do here? it's not right.
// QRect desk = QApplication::desktop()->screenGeometry(
// QApplication::desktop()->screenNumber(topLevelWidget()));
// con->setGeometry(desk.center().x()-175, desk.center().y()-55, 350,110);
// connect the ConnectWidgets various signals
-// connect(con, SIGNAL(closeDebugWindow()),
-// debugwindow, SLOT(hide()));
-// connect(con, SIGNAL(debugMessage(const QString &)),
-// debugwindow, SLOT(statusLabel(const QString &)));
-// connect(con, SIGNAL(toggleDebugWindow()),
-// debugwindow, SLOT(toggleVisibility()));
-// connect(con, SIGNAL(debugPutChar(unsigned char)),
-// debugwindow, SLOT(addChar(unsigned char)));
// // connect(con, SIGNAL(startAccounting()),
// // this, SLOT(startAccounting()));
// // connect(con, SIGNAL(stopAccounting()),
// // this, SLOT(stopAccounting()));
// connect(qApp, SIGNAL(saveYourself()),
// this, SLOT(saveMyself()));
// connect(qApp, SIGNAL(shutDown()),
// this, SLOT(shutDown()));
-// debugwindow->setGeometry(desk.center().x()+190, desk.center().y()-55,
-// debugwindow->width(),debugwindow->height());
-
-// move(desk.center().x()-width()/2, desk.center().y()-height()/2);
-
// KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
// m_strCmdlAccount = args->getOption("c");
// m_bQuitOnDisconnect = args->isSet("q");
// if(!m_strCmdlAccount.isEmpty()) {
// m_bCmdlAccount = true;
// kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl;
// }
// if(m_bCmdlAccount){
// bool result = PPPData::data()->setAccount(m_strCmdlAccount);
// if (!result){
// QString string;
// string = i18n("No such Account:\n%1").arg(m_strCmdlAccount);
// KMessageBox::error(this, string);
// m_bCmdlAccount = false;
// this->show();
// } else {
// beginConnect();
// }
// } else
// expandbutton();
// show();
//#define KPPP_SHOW_NEWS
#ifdef KPPP_SHOW_NEWS
// keep user informed about recent changes
if(!m_bCmdlAccount)
showNews();
#endif
}
KPPPWidget::~KPPPWidget()
{
p_kppp = 0;
// delete stats;
}
// bool KPPPWidget::eventFilter(QObject *o, QEvent *e) {
// if(e->type() == QEvent::User) {
// switch(((SignalEvent*)e)->sigType()) {
// case SIGINT:
// qDebug( "Received a SIGINT" );
// interruptConnection();
// break;
// case SIGCHLD:
// sigChld();
// break;
// case SIGUSR1:
// sigPPPDDied();
// break;
// }
// return true;
// }
// if(o == connect_b) {
// if(e->type() == QEvent::KeyPress) {
// if(connect_b->hasFocus() && ((QKeyEvent *)e)->key() == Qt::Key_Return) {
// beginConnect();
// return true;
// }
// }
// }
// return false;
// }
void KPPPWidget::enterPressedInID() {
PW_Edit->setFocus();
}
void KPPPWidget::enterPressedInPW() {
connect_b->setFocus();
}
// triggered by the session manager
void KPPPWidget::saveMyself() {
PPPData::data()->save();
}
void KPPPWidget::shutDown() {
interruptConnection();
saveMyself();
}
void KPPPWidget::log_window_toggled(bool on) {
PPPData::data()->set_show_log_window(on);
}
// void KPPPWidget::resetaccounts() {
// connectto_c->clear();
// int count = PPPData::data()->count();
// // enable/disable controls
// connectto_c->setEnabled(count > 0);
// connect_b->setEnabled(count > 0);
// log->setEnabled(count > 0);
// ID_Edit->setEnabled(count > 0);
// PW_Edit->setEnabled(count > 0);
// //load the accounts
// for(int i=0; i < count; i++) {
// PPPData::data()->setAccountbyIndex(i);
// connectto_c->insertItem(PPPData::data()->accname());
// }
// //set the default account
// if(!PPPData::data()->defaultAccount().isEmpty()) {
// for(int i=0; i < count; i++)
// if(PPPData::data()->defaultAccount() == connectto_c->text(i)) {
// connectto_c->setCurrentItem(i);
// PPPData::data()->setAccountbyIndex(i);
// ID_Edit->setText(PPPData::data()->storedUsername());
// PW_Edit->setText(PPPData::data()->storedPassword());
// }
// }
// else
// if(count > 0) {
// PPPData::data()->setDefaultAccount(connectto_c->text(0));
// PPPData::data()->save();
// ID_Edit->setText(PPPData::data()->storedUsername());
// PW_Edit->setText(PPPData::data()->storedPassword());
// }
// connect(ID_Edit, SIGNAL(textChanged(const QString &)),
// this, SLOT(usernameChanged(const QString &)));
// connect(PW_Edit, SIGNAL(textChanged(const QString &)),
// this, SLOT(passwordChanged(const QString &)));
// if (ID_Edit->text().isEmpty())
// ID_Edit->setFocus();
// else if (PW_Edit->text().isEmpty())
// PW_Edit->setFocus();
// }
void KPPPWidget::interruptConnection() {
// interrupt dial up
// if (con->isVisible())
// emit con->cancelbutton();
// disconnect if online
if (PPPData::data()->pppdRunning())
emit disconnect();
}
void KPPPWidget::sigPPPDDied() {
qDebug( "Received a SIGUSR1" );
// if we are not connected pppdpid is -1 so have have to check for that
// in the followin line to make sure that we don't raise a false alarm
// such as would be the case when the log file viewer exits.
if(PPPData::data()->pppdRunning() || PPPData::data()->pppdError()) {
qDebug( "It was pppd that died" );
// when we killpppd() on Cancel in ConnectWidget
// we set pppid to -1 so we won't
// enter this block
// just to be sure
Modem::modem->removeSecret(AUTH_PAP);
Modem::modem->removeSecret(AUTH_CHAP);
PPPData::data()->setpppdRunning(false);
qDebug( "Executing command on disconnect since pppd has died." );
QApplication::flushX();
execute_command(PPPData::data()->command_on_disconnect());
// stopAccounting();
// con_win->stopClock();
// DockWidget::dock_widget->stop_stats();
// DockWidget::dock_widget->hide();
if(!PPPData::data()->pppdError())
PPPData::data()->setpppdError(E_PPPD_DIED);
removedns();
Modem::modem->unlockdevice();
// con->pppdDied();
if(!PPPData::data()->automatic_redial()) {
quit_b->setFocus();
show();
// con_win->stopClock();
// stopAccounting();
// con_win->hide();
// con->hide();
PPPData::data()->setpppdRunning(false);
// // not in a signal handler !!! KNotifyClient::beep();
QString msg;
if (PPPData::data()->pppdError() == E_IF_TIMEOUT)
msg = i18n("Timeout expired while waiting for the PPP interface "
"to come up!");
else {
msg = i18n("<p>The pppd daemon died unexpectedly!</p>");
Modem::modem->pppdExitStatus();
if (Modem::modem->lastStatus != 99) { // more recent pppds only
msg += i18n("<p>Exit status: %1").arg(Modem::modem->lastStatus);
msg += i18n("</p><p>See 'man pppd' for an explanation of the error "
"codes or take a look at the kppp FAQ on "
" <a href=http://devel-home.kde.org/~kppp/index.html>"
"http://devel-home.kde.org/~kppp/index.html</a></p>");
}
}
// if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No)
// // PPPL_ShowLog();
// } else { /* reconnect on disconnect */
if (false){
qDebug( "Trying to reconnect... " );
if(PPPData::data()->authMethod() == AUTH_PAP ||
PPPData::data()->authMethod() == AUTH_CHAP ||
PPPData::data()->authMethod() == AUTH_PAPCHAP)
Modem::modem->setSecret(PPPData::data()->authMethod(),
encodeWord(PPPData::data()->storedUsername()),
encodeWord(PPPData::data()->password()));
// con_win->hide();
// con_win->stopClock();
// stopAccounting();
PPPData::data()->setpppdRunning(false);
// not in a signal handler !!! KNotifyClient::beep();
emit cmdl_start();
}
}
PPPData::data()->setpppdError(0);
}
}
// void KPPPWidget::sigChld() {
// qDebug( "sigchld()" );
// // pid_t id = wait(0L);
// // if(id == helperPid && helperPid != -1) {
// // kdDebug(5002) << "It was the setuid child that died" << endl;
// // helperPid = -1;
// QString msg = i18n("kppp's helper process just died.\n"
// "Since a further execution would be pointless, "
// "kppp will shut down now.");
// QMessageBox::warning(0L,"error", msg);
// //remove_pidfile();
// exit(1);
// // }
// }
void KPPPWidget::newdefaultaccount(int i) {
PPPData::data()->setDefaultAccount(connectto_c->text(i));
PPPData::data()->save();
ID_Edit->setText(PPPData::data()->storedUsername());
PW_Edit->setText(PPPData::data()->storedPassword());
}
void KPPPWidget::beginConnect() {
// make sure to connect to the account that is selected in the combo box
// (exeption: an account given by a command line argument)
// if(!m_bCmdlAccount) {
// PPPData::data()->setAccount(connectto_c->currentText());
// PPPData::data()->setPassword(PW_Edit->text());
// } else {
PPPData::data()->setPassword(PPPData::data()->storedPassword());
// }
QFileInfo info(pppdPath());
if(!info.exists()){
QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n"
"Make sure that pppd is installed and "
"that you have entered the correct path."));
return;
}
#if 0
if(!info.isExecutable()){
QString string;
string = i18n("kppp cannot execute:\n %1\n"
"Please make sure that you have given kppp "
"setuid permission and that "
"pppd is executable.").arg(PPPData::data()->pppdPath());
KMessageBox::error(this, string);
return;
}
#endif
QFileInfo info2(PPPData::data()->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::data()->modemDevice());
QMessageBox::warning(this, "error", string);
return;
}
// if this is a PAP or CHAP account, ensure that username is
// supplied
if(PPPData::data()->authMethod() == AUTH_PAP ||
PPPData::data()->authMethod() == AUTH_CHAP ||
PPPData::data()->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!"));
return;
} else {
if(!Modem::modem->setSecret(PPPData::data()->authMethod(),
encodeWord(PPPData::data()->storedUsername()),
encodeWord(PPPData::data()->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::data()->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::data()->accname());
// con->setCaption(tit);
// con->show();
- bool show_debug = PPPData::data()->get_show_log_window();
-// con->debug->setOn(show_debug); // toggle button
- debugwindow->clear();
- if (!show_debug)
- debugwindow->hide();
- else {
- debugwindow->show();
-// con->raise();
- }
emit begin_connect();
}
void KPPPWidget::disconnect() {
if (!PPPData::data()->command_before_disconnect().isEmpty()) {
// con_win->hide();
// con->show();
// con->setCaption(i18n("Disconnecting..."));
// con->setMsg(i18n("Executing command before disconnection."));
qApp->processEvents();
QApplication::flushX();
// pid_t id =
execute_command(PPPData::data()->command_before_disconnect());
// int i, status;
// do {
// kapp->processEvents();
// i = waitpid(id, &status, WNOHANG);
// usleep(500000);
// } while (i == 0 && errno == 0);
// con->hide();
}
qApp->processEvents();
// statdlg->stop_stats();
Modem::modem->killPPPDaemon();
QApplication::flushX();
execute_command(PPPData::data()->command_on_disconnect());
Modem::modem->removeSecret(AUTH_PAP);
Modem::modem->removeSecret(AUTH_CHAP);
removedns();
Modem::modem->unlockdevice();
// con_win->stopClock();
// p_kppp->stopAccounting();
// con_win->hide();
// DockWidget::dock_widget->stop_stats();
// DockWidget::dock_widget->hide();
// if(m_bQuitOnDisconnect)
// kapp->exit(0);
// else {
this->quit_b->setFocus();
this->show();
// }
}
// void KPPPWidget::helpbutton() {
// kapp->invokeHelp();
// }
void KPPPWidget::quitbutton() {
if(PPPData::data()->pppdRunning()) {
int ok = QMessageBox::warning(this,
i18n("Exiting kPPP will close your PPP Session."),
i18n("Quit kPPP?"));
if(ok == QMessageBox::Yes) {
Modem::modem->killPPPDaemon();
QApplication::flushX();
execute_command(PPPData::data()->command_on_disconnect());
removedns();
Modem::modem->unlockdevice();
}
} else {
if (!PPPData::data()->accname().isEmpty() && !PPPData::data()->storePassword())
PPPData::data()->setStoredPassword("");
}
PPPData::data()->save();
qApp->quit();
}
// void KPPPWidget::rulesetLoadError() {
// QMessageBox::warning(this,"error", ruleset_load_errmsg);
// }
// void KPPPWidget::startAccounting() {
// // volume accounting
// stats->totalbytes = 0;
// kdDebug() << "AcctEnabled: " << PPPData::data()->AcctEnabled() << endl;
// // load the ruleset
// if(!PPPData::data()->AcctEnabled())
// return;
// QString d = AccountingBase::getAccountingFile(PPPData::data()->accountingFile());
// // if(::access(d.data(), X_OK) != 0)
// acct = new Accounting(this, stats);
// // else
// // acct = new ExecutableAccounting(this);
// // connect to the accounting object
// connect(acct, SIGNAL(changed(QString, QString)),
// con_win, SLOT(slotAccounting(QString, QString)));
// // if(!acct->loadRuleSet(PPPData::data()->accountingFile())) {
// // QString s= i18n("Can not load the accounting "
// // "ruleset \"%1\"!").arg(PPPData::data()->accountingFile());
// // starting the messagebox with a timer will prevent us
// // from blocking the calling function ConnectWidget::timerEvent
// ruleset_load_errmsg = s;
// QTimer::singleShot(0, this, SLOT(rulesetLoadError()));
// return;
// }
// //else
// // acct->slotStart();
// }
// void KPPPWidget::stopAccounting() {
// // store volume accounting
// // if(stats->totalbytes != 0)
// // PPPData::data()->setTotalBytes(stats->totalbytes);
// if(!PPPData::data()->AcctEnabled())
// return;
// // if(acct != 0) {
// // acct->slotStop();
// // delete acct;
// // acct = 0;
// // }
// }
// void KPPPWidget::showStats() {
// if(statdlg) {
// statdlg->show();
// statdlg->raise();
// }
// }
void KPPPWidget::usernameChanged(const QString &) {
// store username for later use
PPPData::data()->setStoredUsername(ID_Edit->text());
}
void KPPPWidget::passwordChanged(const QString &) {
// store the password if so requested
if(PPPData::data()->storePassword())
PPPData::data()->setStoredPassword(PW_Edit->text());
else
PPPData::data()->setStoredPassword("");
}
void KPPPWidget::setPW_Edit(const QString &pw) {
PW_Edit->setText(pw);
}
// void KPPPWidget::resetCosts(const QString &s) {
// AccountingBase::resetCosts(s);
// }
// void KPPPWidget::resetVolume(const QString &s) {
// AccountingBase::resetVolume(s);
// }
/**
* 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 KPPPWidget::encodeWord(const QString &s) {
QString r = s;
r.replace(QRegExp("\\"), "\\\\");
return r;
}
// void KPPPWidget::setQuitOnDisconnect (bool b)
// {
// m_bQuitOnDisconnect = b;
// }
void KPPPWidget::showNews() {
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.h b/noncore/settings/networksettings/ppp/kpppwidget.h
index 266d829..d7e74af 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.h
+++ b/noncore/settings/networksettings/ppp/kpppwidget.h
@@ -1,157 +1,114 @@
/*
*
* kPPP: A pppd front end for the KDE project
*
* $Id$
*
* Copyright (C) 1997 Bernd Johannes Wuebben
* wuebben@math.cornell.edu
*
* Copyright (C) 1998-2002 Harri Porten <porten@kde.org>
*
* 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 __KPPPWIDGET_H__
#define __KPPPWIDGET_H__
#include <qstring.h>
-//#include "accounting.h"
#include "conwindow.h"
#include "accounts.h"
#include "connect.h"
-#include "debug.h"
-//#include "pppstatdlg.h"
-//class GraphSetup;
-//class AboutWidget;
-//class PPPStats;
-class QDialog;
class QPushButton;
-/* class SignalEvent : public QEvent { */
-/* public: */
-/* SignalEvent(int s) : QEvent(User), sig(s) { } */
-/* int sigType() const { return sig; } */
-/* private: */
-/* int sig; */
-/* }; */
-
class KPPPWidget : public QDialog {
Q_OBJECT
public:
KPPPWidget( QWidget *parent=0, const char *name=0, bool modal = false, WFlags fl = 0 );
~KPPPWidget();
void setPW_Edit(const QString &);
- // virtual bool eventFilter(QObject *, QEvent *);
- void setQuitOnDisconnect (bool b);
- // bool quitOnDisconnect () {return m_bQuitOnDisconnect;};
private slots:
void newdefaultaccount(int);
-// void expandbutton();
void beginConnect();
void quitbutton();
- // void helpbutton();
- // void setup();
- // void rulesetLoadError();
void usernameChanged(const QString &);
void passwordChanged(const QString &);
void enterPressedInID();
void enterPressedInPW();
void saveMyself();
void shutDown();
-/* protected slots: */
-/* virtual void accept(); */
-/* virtual void reject(); */
public slots:
- // void resetaccounts();
-/* void resetCosts(const QString &); */
-/* void resetVolume(const QString &); */
void disconnect();
void log_window_toggled(bool on);
-/* void startAccounting(); */
-/* void stopAccounting(); */
-/* void showStats(); */
signals:
void begin_connect();
void cmdl_start();
public:
QCheckBox *log;
bool connected;
- DebugWidget *debugwindow;
QString con_speed;
// ConnectWidget *con;
// ConWindow *con_win;
// PPPStatsDlg *statdlg;
// AccountingBase *acct;
QPushButton *quit_b;
//PPPStats *stats;
private:
// void prepareSetupDialog();
void interruptConnection();
void sigChld();
void sigPPPDDied();
QString encodeWord(const QString &s);
void showNews ();
QString ruleset_load_errmsg;
- // QPushButton *help_b;
QPushButton *setup_b;
QFrame *fline;
QFrame *fline1;
QPushButton *connect_b;
QComboBox *connectto_c;
QLabel *ID_Label;
QLabel *PW_Label;
QLineEdit *ID_Edit;
QLineEdit *PW_Edit;
QLabel *label1;
QLabel *label2;
QLabel *label3;
QLabel *label4;
QLabel *label5;
QLabel *label6;
QLabel *radio_label;
-
- // QTabWidget *tabWindow;
- // AccountWidget *accounts;
- // GeneralWidget *general;
- // ModemWidget *modem1;
- // ModemWidget2 *modem2;
- // GraphSetup *graph;
- // AboutWidget *about;
-
-
/* QString m_strCmdlAccount; */
/* bool m_bQuitOnDisconnect; */
/* bool m_bCmdlAccount; */
};
#endif
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro
index ebfc713..a2e0118 100644
--- a/noncore/settings/networksettings/ppp/ppp.pro
+++ b/noncore/settings/networksettings/ppp/ppp.pro
@@ -1,18 +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 knuminput.h knumvalidator.h kpppwidget.h conwindow.h debug.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h
-SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp knuminput.cpp knumvalidator.cpp kpppwidget.cpp conwindow.cpp debug.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.cpp
+HEADERS = pppmodule.h devices.h modem.h modeminfo.h pppdata.h kpppconfig.h pppdata.h runtests.h general.h modemcmds.h knuminput.h knumvalidator.h kpppwidget.h conwindow.h accounts.h connect.h edit.h scriptedit.h pppdargs.h iplined.h pwentry.h pppconfig.h
+SOURCES = pppmodule.cpp modem.cpp modeminfo.cpp pppdata.cpp runtests.cpp general.cpp modemcmds.cpp knuminput.cpp knumvalidator.cpp kpppwidget.cpp conwindow.cpp accounts.cpp connect.cpp edit.cpp scriptedit.cpp pppdargs.cpp iplined.cpp pwentry.cpp pppconfig.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/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp
index e13f8c8..fb2f3e5 100644
--- a/noncore/settings/networksettings/ppp/pppmodule.cpp
+++ b/noncore/settings/networksettings/ppp/pppmodule.cpp
@@ -1,125 +1,126 @@
#include "pppconfig.h"
#include "pppmodule.h"
#include "pppdata.h"
#include "kpppwidget.h"
#include "interfaceinformationimp.h"
//#include "devices.h"
/**
* Constructor, find all of the possible interfaces
*/
PPPModule::PPPModule() : Module()
{
Interface *iface;
iface = new Interface( 0, "device" );
iface->setHardwareName( "account" );
list.append( iface );
}
/**
* Delete any interfaces that we own.
*/
PPPModule::~PPPModule(){
Interface *i;
for ( i=list.first(); i != 0; i=list.next() )
delete i;
}
/**
* Change the current profile
*/
void PPPModule::setProfile(const QString &newProfile){
profile = newProfile;
}
/**
* get the icon name for this device.
* @param Interface* can be used in determining the icon.
* @return QString the icon name (minus .png, .gif etc)
*/
QString PPPModule::getPixmapName(Interface* ){
return "ppp";
}
/**
* Check to see if the interface i is owned by this module.
* @param Interface* interface to check against
* @return bool true if i is owned by this module, false otherwise.
*/
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( 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);
return information;
}
/**
* 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){
qDebug("try to add iface %s",newInterface.latin1());
PPPConfigWidget imp(0, "PPPConfigImp", true);
imp.showMaximized();
if(imp.exec() == QDialog::Accepted ){
qDebug("ACCEPTED");
PPPData::data()->save();
Interface *iface;
iface = new Interface( 0, PPPData::data()->modemDevice() );
iface->setHardwareName( PPPData::data()->accname() );
list.append( iface );
return iface;
}
return NULL;
}
/**
* Attempts to remove the interface, doesn't delete i
* @return bool true if successfull, false otherwise.
*/
bool PPPModule::remove(Interface*){
// Can't remove a hardware device, you can stop it though.
return false;
}
void PPPModule::possibleNewInterfaces(QMap<QString, QString> &newIfaces)
{
newIfaces.insert(QObject::tr("PPP") ,
QObject::tr("generic ppp device"));
}