author | mickeyl <mickeyl> | 2004-04-09 15:00:06 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-04-09 15:00:06 (UTC) |
commit | fb2f09533c7476a266a877c351007c2706b2da0d (patch) (side-by-side diff) | |
tree | 9742d4cb8fd07fd5530c3c29b5f049dcecd46ef4 | |
parent | 39547839995c9f72ca9216ba5c2127246428ece8 (diff) | |
download | opie-fb2f09533c7476a266a877c351007c2706b2da0d.zip opie-fb2f09533c7476a266a877c351007c2706b2da0d.tar.gz opie-fb2f09533c7476a266a877c351007c2706b2da0d.tar.bz2 |
- eliminate cylic dependency
- complete using opie debugging framework
- sanitize #include order
21 files changed, 96 insertions, 55 deletions
diff --git a/noncore/settings/networksettings/interfaces/config.in b/noncore/settings/networksettings/interfaces/config.in index d84cd24..2175800 100644 --- a/noncore/settings/networksettings/interfaces/config.in +++ b/noncore/settings/networksettings/interfaces/config.in @@ -1,4 +1,4 @@ config INTERFACES - boolean - default "y" if NETWORKSETUP + boolean "Build interfaces for networksettings" + default "y" depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE diff --git a/noncore/settings/networksettings/networksettings.pro b/noncore/settings/networksettings/networksettings.pro index 55d2291..9ad9be4 100644 --- a/noncore/settings/networksettings/networksettings.pro +++ b/noncore/settings/networksettings/networksettings.pro @@ -1,12 +1,11 @@ -CONFIG = qt warn_on quick-app +CONFIG = qt warn_on quick-app HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h module.h SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp INCLUDEPATH += $(OPIEDIR)/include interfaces/ . DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan/ ppp/ LIBS += -lqpe -L$(OPIEDIR)/plugins/networksettings -Linterfaces/ -linterfaces -lopiecore2 -lopieui2 INTERFACES = mainwindow.ui addconnection.ui TARGET = networksettings - include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp index aedc0b9..f05e7ac 100644 --- a/noncore/settings/networksettings/ppp/accounts.cpp +++ b/noncore/settings/networksettings/ppp/accounts.cpp @@ -1,161 +1,163 @@ /* * 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 "accounts.h" #include "authwidget.h" #include "pppdata.h" #include "edit.h" /* OPIE */ +#include <opie2/odebug.h> #include <qpe/qpeapplication.h> +using namespace Opie::Core; /* QT */ #include <qdir.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> /* STD */ #include <stdlib.h> void parseargs(char* buf, char** args); AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f ) : ChooserWidget( pd, parent, name, f ) { QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); QWhatsThis::add(new_b, tr("Create a new dialup connection\n" "to the Internet")); 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")); QWhatsThis::add(delete_b, tr("<p>Deletes the selected account\n\n" "<font color=\"red\"><b>Use with care!</b></font>")); copy_b->setEnabled( false ); //FIXME // delete_b->setEnabled( false ); //FIXME listListbox->insertStringList(_pppdata->getAccountList()); for (uint i = 0; i < listListbox->count(); i++) { if ( listListbox->text(i) == _pppdata->accname() ) listListbox->setCurrentItem( i ); } } void AccountWidget::slotListBoxSelect(int idx) { bool ok = _pppdata->setAccount( listListbox->text(idx) ); ok = (bool)(idx != -1); delete_b->setEnabled(ok); edit_b->setEnabled(ok); //FIXME copy_b->setEnabled(ok); } void AccountWidget::edit() { _pppdata->setAccount(listListbox->text(listListbox->currentItem())); int result = doTab(); if(result == QDialog::Accepted) { listListbox->changeItem(_pppdata->accname(),listListbox->currentItem()); // emit resetaccounts(); _pppdata->save(); } } void AccountWidget::create() { // if(listListbox->count() == MAX_ACCOUNTS) { // QMessageBox::information(this, "sorry", // tr("Maximum number of accounts reached.")); // return; // } int result; if (_pppdata->newaccount() == -1) { odebug << "_pppdata->newaccount() == -1" << oendl; return; } result = doTab(); if(result == QDialog::Accepted) { listListbox->insertItem(_pppdata->accname()); listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true); _pppdata->save(); } else _pppdata->deleteAccount(); } void AccountWidget::copy() { // if(listListbox->count() == MAX_ACCOUNTS) { // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); // return; // } if(listListbox->currentItem()<0) { QMessageBox::information(this, "sorry", tr("No account selected.")); return; } _pppdata->copyaccount(listListbox->currentText()); listListbox->insertItem(_pppdata->accname()); // emit resetaccounts(); _pppdata->save(); } void AccountWidget::remove() { diff --git a/noncore/settings/networksettings/ppp/authwidget.cpp b/noncore/settings/networksettings/ppp/authwidget.cpp index f3d842f..c94c3bc 100644 --- a/noncore/settings/networksettings/ppp/authwidget.cpp +++ b/noncore/settings/networksettings/ppp/authwidget.cpp @@ -1,140 +1,144 @@ - -#include <qlayout.h> -#include <qmessagebox.h> -#include <qtoolbutton.h> -#include <qwhatsthis.h> - #include "auth.h" #include "authwidget.h" #include "edit.h" #include "pppdata.h" +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* QT */ +#include <qlayout.h> +#include <qmessagebox.h> +#include <qtoolbutton.h> +#include <qwhatsthis.h> +/* XPM */ 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() ); diff --git a/noncore/settings/networksettings/ppp/config.in b/noncore/settings/networksettings/ppp/config.in index 0b71434..570ebfe 100644 --- a/noncore/settings/networksettings/ppp/config.in +++ b/noncore/settings/networksettings/ppp/config.in @@ -1,4 +1,4 @@ config PPP boolean "opie-networksettingsplugin-kppp (PPP module)" - default "n" if NETWORKSETUP + default "y" depends ( LIBQPE || LIBQPE-X11 ) && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES diff --git a/noncore/settings/networksettings/ppp/connect.cpp b/noncore/settings/networksettings/ppp/connect.cpp index b75410c..24d33f4 100644 --- a/noncore/settings/networksettings/ppp/connect.cpp +++ b/noncore/settings/networksettings/ppp/connect.cpp @@ -1,165 +1,166 @@ /* * kPPP: A pppd front end for the KDE project * * * Copyright (C) 1997 Bernd Johannes Wuebben * wuebben@math.cornell.edu * Copyright (C) 1998-2001 Harri Porten <porten@kde.org> * * 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 <config.h> +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; +/* QT */ #include <qlayout.h> #include <qregexp.h> - #include <qapplication.h> -//#include <kdebug.h> -//#include <klocale.h> #include <qmessagebox.h> #include <qpushbutton.h> +/* STD */ #include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <netdb.h> #include <sys/types.h> #include <sys/socket.h> #include <arpa/inet.h> #include <netinet/in.h> #include <sys/ioctl.h> #include <assert.h> #ifdef _XPG4_2 #define __xnet_connect connect #endif #include <errno.h> #ifdef HAVE_SYS_PARAM_H #include <sys/param.h> #endif #ifdef __linux__ #include "runtests.h" #endif #include "auth.h" #include "connect.h" //#include "docking.h" #include "interfaceppp.h" #include "modem.h" #include "kpppconfig.h" #include "pppdata.h" #include "kpppwidget.h" //#include "requester.h" //#include "utils.h" #define execute_command system QString old_hostname; bool modified_hostname; ConnectWidget::ConnectWidget(InterfacePPP *ifp, QWidget *parent, const char *name) : QWidget(parent, name), myreadbuffer(""), main_timer_ID(0), vmain(0), substate(-1), scriptindex(0), loopnest(0), loopend(false), semaphore(false), expecting(false), readbuffer(""), scanvar(""), scanning(false), pausing(false), dialnumber(0), _ifaceppp(ifp) { modified_hostname = false; QVBoxLayout *tl = new QVBoxLayout(this, 8, 10); QString tit = QObject::tr("Connecting to: "); 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(QObject::tr("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); if (_ifaceppp->getStatus()) messg->setText(QObject::tr("Online")); else messg->setText(QObject::tr("Offline")); l0->addSpacing(10); l0->addWidget(messg); l0->addSpacing(10); QHBoxLayout *l1 = new QHBoxLayout(10); tl->addLayout(l1); l1->addStretch(1); debug = new QPushButton(QObject::tr("Log"), this); debug->setToggleButton(true); debug->setEnabled( false ); // FIXME: disable the log button connect(debug, SIGNAL(clicked()), SIGNAL(toggleDebugWindow())); cancel = new QPushButton(QObject::tr("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())); inittimer = new QTimer(this); connect(inittimer, SIGNAL(timeout()), SLOT(init())); if_timeout_timer = new QTimer(this); connect(if_timeout_timer, SIGNAL(timeout()), SLOT(if_waiting_timed_out())); connect(this,SIGNAL(if_waiting_signal()),this,SLOT(if_waiting_slot())); prompt = new PWEntry( this, "pw" ); if_timer = new QTimer(this); connect(if_timer,SIGNAL(timeout()), SLOT(if_waiting_slot())); } diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp index 350ff32..42de44c 100644 --- a/noncore/settings/networksettings/ppp/devices.cpp +++ b/noncore/settings/networksettings/ppp/devices.cpp @@ -1,163 +1,165 @@ /* * 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 "interfaceppp.h" #include "devices.h" #include "authwidget.h" #include "pppdata.h" #include "edit.h" #include "general.h" /* OPIE */ +#include <opie2/odebug.h> #include <qpe/qpeapplication.h> +using namespace Opie::Core; /* QT */ #include <qdir.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> /* STD */ #include <stdlib.h> void parseargs(char* buf, char** args); DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) : ChooserWidget(ip->data(), parent, name, f) { _ifaceppp = ip; QWhatsThis::add(edit_b, tr("Allows you to modify the selected device")); QWhatsThis::add(new_b, tr("Create a new device") ); QWhatsThis::add(copy_b, tr("Makes a copy of the selected device. All\n" "settings of the selected device are copied\n" "to a new device, that you can modify to fit your\n" "needs")); QWhatsThis::add(delete_b, tr("<p>Deletes the selected device\n\n" "<font color=\"red\"><b>Use with care!</b></font>")); copy_b->setEnabled( false ); //FIXME // delete_b->setEnabled( false ); //FIXME QStringList tmp = _pppdata->getDevicesNamesList(); odebug << "DevicesWidget::DevicesWidget got devices " << tmp.join("--").latin1() << "" << oendl; listListbox->insertStringList(tmp); for (uint i = 0; i < listListbox->count(); i++){ odebug << "listListbox->text(i) " << listListbox->text(i).latin1() << " == _pppdata->devname() " << _pppdata->devname().latin1() << "" << oendl; if ( listListbox->text(i) == _pppdata->devname() ) listListbox->setCurrentItem( i ); } } void DevicesWidget::slotListBoxSelect(int idx) { bool ok = _pppdata->setDevice( listListbox->text(idx) ); delete_b->setEnabled((bool)(idx != -1)); edit_b->setEnabled((bool)(idx != -1)); //FIXME copy_b->setEnabled((bool)(idx != -1)); } void DevicesWidget::edit() { _pppdata->setDevice(listListbox->text(listListbox->currentItem())); int result = doTab(); if(result == QDialog::Accepted) { listListbox->changeItem(_pppdata->devname(),listListbox->currentItem()); _pppdata->save(); } } void DevicesWidget::create() { // if(listListbox->count() == MAX_ACCOUNTS) { // QMessageBox::information(this, "sorry", // tr("Maximum number of accounts reached.")); // return; // } int result; if (_pppdata->newdevice() == -1){ return; } result = doTab(); if(result == QDialog::Accepted) { listListbox->insertItem(_pppdata->devname()); listListbox->setSelected(listListbox->findItem(_pppdata->devname()),true ); _pppdata->save(); } else _pppdata->deleteDevice(); } void DevicesWidget::copy() { // if(listListbox->count() == MAX_ACCOUNTS) { // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); // return; // } if(listListbox->currentItem()<0) { QMessageBox::information(this, "sorry", tr("No devices selected.")); return; } _pppdata->copydevice(listListbox->currentText()); listListbox->insertItem(_pppdata->devname()); _pppdata->save(); } void DevicesWidget::remove() { QString s = tr("Are you sure you want to delete\nthe device \"%1\"?") .arg(listListbox->text(listListbox->currentItem())); if(QMessageBox::warning(this,tr("Confirm"),s, QMessageBox::Yes,QMessageBox::No ) != QMessageBox::Yes) return; if(_pppdata->deleteDevice(listListbox->text(listListbox->currentItem()))) listListbox->removeItem(listListbox->currentItem()); // _pppdata->save(); diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp index 69bb682..40ba19b 100644 --- a/noncore/settings/networksettings/ppp/general.cpp +++ b/noncore/settings/networksettings/ppp/general.cpp @@ -1,163 +1,165 @@ /* * 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 "general.h" #include "interfaceppp.h" #include "modeminfo.h" #include "modemcmds.h" #include "pppdata.h" /* OPIE */ +#include <opie2/odebug.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> +using namespace Opie::Core; /* QT */ #include <qcheckbox.h> #include <qcombobox.h> #include <qlabel.h> #include <qlayout.h> #include <qpushbutton.h> #include <qslider.h> #include <qspinbox.h> #include <qwhatsthis.h> /* STD */ #include <termios.h> #include <string.h> ModemWidget::ModemWidget( PPPData *pd, QWidget *parent, const char *name ) : QWidget(parent, name), _pppdata(pd) { int k; QGridLayout *tl = new QGridLayout(this, 8, 2, 0 );//, KDialog::spacingHint()); QLabel *label1; label1 = new QLabel(tr("Modem &name:"), this); tl->addWidget(label1, 0, 0); modemname = new QLineEdit(this, "modemName"); modemname->setText( _pppdata->devname() ); label1->setBuddy(modemname); tl->addWidget(modemname, 0, 1); label1 = new QLabel(tr("Modem de&vice:"), this); tl->addWidget(label1, 1, 0); modemdevice = new QComboBox(false, this); modemdevice->setEditable( true ); modemdevice->setDuplicatesEnabled ( false ); modemdevice->setInsertionPolicy( QComboBox::AtTop ); label1->setBuddy(modemdevice); Config cfg("NetworkSetupPPP"); cfg.setGroup("Devices_General"); QStringList devs = cfg.readListEntry("devices",','); if (devs.isEmpty()) devs << "/dev/modem" << "/dev/ircomm0" << "/dev/ttyS0"; modemdevice->insertStringList( devs ); tl->addWidget(modemdevice, 1, 1); // connect(modemdevice, SIGNAL(activated(int)), // SLOT(setmodemdc(int))); // connect(modemdevice, SIGNAL(textChanged(const QString&) ), // SLOT( setmodemdc(const QString&) ) ); QString tmp = tr("This specifies the serial port your modem is attached \n" "to. On Linux/x86, typically this is either /dev/ttyS0 \n" "(COM1 under DOS) or /dev/ttyS1 (COM2 under DOS).\n" "\n" "If you have an internal ISDN card with AT command\n" "emulation (most cards under Linux support this), you\n" "should select one of the /dev/ttyIx devices."); QWhatsThis::add(label1,tmp); QWhatsThis::add(modemdevice,tmp); label1 = new QLabel(tr("&Flow control:"), this); tl->addWidget(label1, 2, 0); flowcontrol = new QComboBox(false, this); label1->setBuddy(flowcontrol); flowcontrol->insertItem(tr("Hardware [CRTSCTS]")); flowcontrol->insertItem(tr("Software [XON/XOFF]")); flowcontrol->insertItem(tr("None")); tl->addWidget(flowcontrol, 2, 1); // connect(flowcontrol, SIGNAL(activated(int)), // SLOT(setflowcontrol(int))); tmp = tr("<p>Specifies how the serial port and modem\n" "communicate. You should not change this unless\n" "you know what you are doing.\n" "\n" "<b>Default</b>: CRTSCTS"); QWhatsThis::add(label1,tmp); QWhatsThis::add(flowcontrol,tmp); QLabel *labelenter = new QLabel(tr("&Line termination:"), this); tl->addWidget(labelenter, 3, 0); enter = new QComboBox(false, this); labelenter->setBuddy(enter); enter->insertItem("CR"); enter->insertItem("LF"); enter->insertItem("CR/LF"); tl->addWidget(enter, 3, 1); // connect(enter, SIGNAL(activated(int)), SLOT(setenter(int))); tmp = tr("<p>Specifies how AT commands are sent to your\n" "modem. Most modems will work fine with the\n" "default <i>CR/LF</i>. If your modem does not react\n" "to the init string, you should try different\n" "settings here\n" "\n" "<b>Default</b>: CR/LF"); QWhatsThis::add(labelenter,tmp); QWhatsThis::add(enter, tmp); QLabel *baud_label = new QLabel(tr("Co&nnection speed:"), this); tl->addWidget(baud_label, 4, 0); baud_c = new QComboBox(this); baud_label->setBuddy(baud_c); static const char *baudrates[] = { #ifdef B460800 "460800", #endif #ifdef B230400 "230400", #endif #ifdef B115200 "115200", #endif diff --git a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp index 5a76293..4755aed 100644 --- a/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceinformationppp.cpp @@ -1,41 +1,45 @@ #include "interfaceinformationppp.h" +#include "connect.h" +#include "conwindow.h" + +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; +/* QT */ #include <qpushbutton.h> #include <qlabel.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, Qt::WStyle_ContextHelp) { odebug << "InterfaceInformationPPP::InterfaceInformationPPP " << name << "" << oendl; con = new ConnectWidget( (InterfacePPP*)i, this, "con" ); con->setSizePolicy( QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed) ); macAddressLabel->hide(); subnetMaskLabel->hide(); broadcastLabel->hide(); TextLabel23->hide(); TextLabel21->hide(); TextLabel24->hide(); InterfaceInformationLayout->addWidget( con, 1, 0 ); connect(i, SIGNAL(begin_connect()),con, SLOT(preinit())); connect(i, SIGNAL(hangup_now() ), con, SLOT(cancelbutton() ) ); } diff --git a/noncore/settings/networksettings/ppp/interfaceppp.cpp b/noncore/settings/networksettings/ppp/interfaceppp.cpp index 5cc6f70..7d52f66 100644 --- a/noncore/settings/networksettings/ppp/interfaceppp.cpp +++ b/noncore/settings/networksettings/ppp/interfaceppp.cpp @@ -1,139 +1,143 @@ +#include "auth.h" +#include "interfaceppp.h" +#include "modem.h" +#include "pppdata.h" + +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; +/* QT */ #include <qmessagebox.h> #include <qlayout.h> #include <qlineedit.h> #include <qlabel.h> -#include "auth.h" -#include "interfaceppp.h" -#include "modem.h" -#include "pppdata.h" - InterfacePPP::InterfacePPP(QObject *parent, const char *name, bool status) : Interface(parent, name, status), _modemPtr(0), _dataPtr(0) { odebug << "InterfacePPP::InterfacePPP(" << oendl; } PPPData* InterfacePPP::data()const { if (!_dataPtr){ odebug << "creating new Data obj" << oendl; _dataPtr = new PPPData(); _dataPtr->setDevice( getInterfaceName() ); _dataPtr->setAccount( getHardwareName() ); } return _dataPtr; } Modem* InterfacePPP::modem()const { if (!_modemPtr){ odebug << "creating new modem obj" << oendl; _modemPtr = new Modem( data() ); } return _modemPtr; } bool InterfacePPP::refresh() { odebug << "InterfacePPP::refresh()" << oendl; QString old = getInterfaceName(); setInterfaceName( modem()->pppDevice() ); (void)Interface::refresh(); setInterfaceName( old ); emit updateInterface(this); return true; } void InterfacePPP::start() { odebug << "InterfacePPP::start" << oendl; if (data()->password().isEmpty() && !data()->storedUsername().isEmpty() ) { QDialog mb( 0, "Dialog", true ); mb.setCaption( tr( "No password" ) ); QVBoxLayout layout( &mb ); QLabel text ( &mb ); text.setText( tr("Username defined but no password\n Please enter a password") ); QLineEdit lineedit( &mb ); lineedit.setEchoMode( QLineEdit::Password ); layout.addWidget( &text ); layout.addWidget( &lineedit ); if ( mb.exec() == QDialog::Accepted ) { data()->setPassword( lineedit.text() ); } } QFileInfo info(pppdPath()); if(!info.exists()){ QMessageBox::warning(0, tr("Error"), QObject::tr("<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 = QObject::tr( "<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 = QObject::tr( "<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){ //FIXME: ID_Edit->text().isEmpty()) { QMessageBox::warning(0,tr("Error"), QObject::tr("<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 = QObject::tr("<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 = QObject::tr("You must specify a telephone number!"); QMessageBox::warning(0, tr("Error"), s); return; } diff --git a/noncore/settings/networksettings/ppp/modem.cpp b/noncore/settings/networksettings/ppp/modem.cpp index f3f2639..5913a22 100644 --- a/noncore/settings/networksettings/ppp/modem.cpp +++ b/noncore/settings/networksettings/ppp/modem.cpp @@ -1,154 +1,159 @@ /* * kPPP: A pppd Front End for the KDE project * * $Id$ * * Copyright (C) 1997 Bernd Johannes Wuebben * wuebben@math.cornell.edu * * This file was added by Harri Porten <porten@tu-harburg.de> * * * 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. */ +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* STD */ #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <setjmp.h> #include <regex.h> #include <qregexp.h> #include <assert.h> #include <string.h> #ifdef HAVE_RESOLV_H # include <arpa/nameser.h> # include <resolv.h> #endif #ifndef _PATH_RESCONF #define _PATH_RESCONF "/etc/resolv.conf" #endif #define strlcpy strcpy #include "auth.h" #include "modem.h" #include "pppdata.h" #define qError qDebug #define MY_ASSERT(x) if (!(x)) { \ ofatal << "ASSERT: \"" << #x << "\" in " << __FILE__ << " (" << __LINE__ << ")\n" << oendl; \ exit(1); } static sigjmp_buf jmp_buffer; //Modem *Modem::modem = 0; const char* pppdPath() { // wasting a few bytes static char buffer[sizeof(PPPDSEARCHPATH)+sizeof(PPPDNAME)]; static char *pppdPath = 0L; char *p; if(pppdPath == 0L) { const char *c = PPPDSEARCHPATH; while(*c != '\0') { while(*c == ':') c++; p = buffer; while(*c != '\0' && *c != ':') *p++ = *c++; *p = '\0'; strcat(p, "/"); strcat(p, PPPDNAME); if(access(buffer, F_OK) == 0) return (pppdPath = buffer); } } return pppdPath; } Modem::Modem( PPPData* pd ) { _pppdata = pd; modemfd = -1; _pppdExitStatus = -1; pppdPid = -1; sn = m_modemDebug = 0L; data_mode = false; modem_is_locked = false; lockfile[0] = '\0'; device = "/dev/modem"; } Modem::~Modem() { } speed_t Modem::modemspeed() { // convert the string modem speed int the gpppdata object to a t_speed type // to set the modem. The constants here should all be ifdef'd because // other systems may not have them int i = _pppdata->speed().toInt()/100; switch(i) { case 24: return B2400; break; case 96: return B9600; break; case 192: return B19200; break; case 384: return B38400; break; #ifdef B57600 case 576: return B57600; break; #endif #ifdef B115200 case 1152: return B115200; break; #endif #ifdef B230400 case 2304: return B230400; break; #endif #ifdef B460800 case 4608: return B460800; break; #endif diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro index 62ca2b5..45fa0ee 100644 --- a/noncore/settings/networksettings/ppp/ppp.pro +++ b/noncore/settings/networksettings/ppp/ppp.pro @@ -1,17 +1,14 @@ -#TEMPLATE = app -# TEMPLATE = lib -#CONFIG += qt plugin warn_on CONFIG += qt plugin warn_on DESTDIR = $(OPIEDIR)/plugins/networksettings HEADERS = pppmodule.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 chooserwidget.h devices.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 chooserwidget.cpp devices.cpp INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/ DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -L../interfaces/ -linterfaces TARGET = kppp 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 a8c99fd..d2a1490 100644 --- a/noncore/settings/networksettings/ppp/pppconfig.cpp +++ b/noncore/settings/networksettings/ppp/pppconfig.cpp @@ -1,75 +1,79 @@ - -#include <qlayout.h> -#include <qmessagebox.h> -#include <qtabwidget.h> - #include "accounts.h" #include "devices.h" #include "general.h" #include "interfaceppp.h" #include "modem.h" #include "pppconfig.h" #include "pppdata.h" #include "runtests.h" +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* QT */ +#include <qlayout.h> +#include <qmessagebox.h> +#include <qtabwidget.h> + PPPConfigWidget::PPPConfigWidget( InterfacePPP* iface, QWidget *parent, const char *name, bool modal, WFlags fl ) : QDialog(parent, name, modal, fl) { setCaption(tr("Configure Modem")); int result = runTests(); if(result == TEST_CRITICAL){ QMessageBox::critical(0, tr("Modem failure"), tr("A critical failure appeard while testing the modem") ); return; } interface = iface; odebug << "PPPConfigWidget::PPPConfigWidget" << oendl; odebug << " interface->getHardwareName >" << interface->getHardwareName().latin1() << "<" << oendl; odebug << " _pppdata->accname >" << interface->data()->accname().latin1() << "<" << oendl; 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", Qt::WStyle_ContextHelp ); tabWindow->addTab( accounts, tr("&Accounts") ); devices = new DevicesWidget( interface, tabWindow, "devices", Qt::WStyle_ContextHelp ); tabWindow->addTab( devices, tr("&Devices") ); //OLD: // modem1 = new ModemWidget( interface, tabWindow, "modem1" ); // tabWindow->addTab( modem1, tr("&Device") ); // modem2 = new ModemWidget2( interface, tabWindow, "modem2" ); // tabWindow->addTab( modem2, tr("&Modem") ); } PPPConfigWidget::~PPPConfigWidget() { } void PPPConfigWidget::accept() { odebug << "PPPConfigWidget::accept" << oendl; odebug << " _pppdata->accname >" << interface->data()->accname().latin1() << "<" << oendl; odebug << " interface->getHardwareName >" << interface->getHardwareName().latin1() << "<" << oendl; interface->setInterfaceName( interface->data()->devname() ); interface->setHardwareName( interface->data()->accname() ); 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 567ccf8..eb03ef4 100644 --- a/noncore/settings/networksettings/ppp/pppdata.cpp +++ b/noncore/settings/networksettings/ppp/pppdata.cpp @@ -1,165 +1,167 @@ /* * 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 "pppdata.h" #include "runtests.h" -//#include "devices.h" -//#include <klocale.h> + +/* OPIE */ +#include <opie2/odebug.h> #include <qpe/config.h> +using namespace Opie::Core; + +/* QT */ #include <qmessagebox.h> #include <qapplication.h> -// #include <klocale.h> -// #include <kconfig.h> -// #include <kmessagebox.h> -// #include <kapplication.h> + +/* STD */ #include <assert.h> #define SEPARATOR -sseepp- #define SEP QString("%1SEPARATOR%1") PPPData::PPPData() : passwd(""), _modemName(""), highcount(-1), // start out with no entries highcountdev(-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; highcountdev = readNumConfig(GENERAL_GRP, NUMDEVICES_KEY, 0) - 1; Config cfg = config(); cfg.setGroup(GENERAL_GRP); accountList = cfg.readListEntry(ACCOUNT_LIST, ',' ); deviceList = cfg.readListEntry(DEVICESNAMES_LIST, ',' ); odebug << "PPPData::PPPData has a accountList " << accountList.join("---").latin1() << "" << oendl; odebug << "PPPData::PPPData has a deviceList " << deviceList.join("---").latin1() << "" << oendl; // 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() { odebug << "PPPData saving data" << oendl; writeConfig(GENERAL_GRP, NUMACCOUNTS_KEY, count()); writeConfig(GENERAL_GRP, NUMDEVICES_KEY, highcountdev + 1); QString key; QStringList keys; Config cfg = config(); cfg.setGroup(GENERAL_GRP); cfg.writeEntry(ACCOUNT_LIST, accountList, ',' ); cfg.writeEntry(DEVICESNAMES_LIST, deviceList, ',' ); for( QMap<QString,QString>::Iterator it = stringEntries.begin(); it != stringEntries.end(); ++it ){ QString val = it.data(); key = it.key(); // odebug << "saving " << key.latin1() << " -> " << val.latin1() << "" << oendl; keys = QStringList::split( "SEPARATOR", key ); //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< value >" << val.latin1() << "<" << oendl; 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(); // odebug << "saving " << key.latin1() << " -> " << val << "" << oendl; keys = QStringList::split( "SEPARATOR", key ); //odebug << "group >" << keys[0].latin1() << "< key >" << keys[1].latin1() << "< val " << val << "" << oendl; 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]; // odebug << "saving " << key.latin1() << " -> " << val.join(sep).latin1() << "" << oendl; keys = QStringList::split( "SEPARATOR", key ); 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 = "") { // odebug << "PPPData::readConfig key >" << key.latin1() << "< group >" << group.latin1() << "<" << oendl; 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) { diff --git a/noncore/settings/networksettings/ppp/pppmodule.cpp b/noncore/settings/networksettings/ppp/pppmodule.cpp index 2291e8a..b102a10 100644 --- a/noncore/settings/networksettings/ppp/pppmodule.cpp +++ b/noncore/settings/networksettings/ppp/pppmodule.cpp @@ -1,139 +1,141 @@ #include "modem.h" #include "pppconfig.h" #include "pppmodule.h" #include "pppdata.h" #include "interfaceinformationppp.h" #include "interfaceppp.h" /* OPIE */ +#include <opie2/odebug.h> #include <qpe/config.h> #include <qpe/qpeapplication.h> +using namespace Opie::Core; /* QT */ /* STD */ #include <errno.h> #include <signal.h> // don't polute global namespace namespace { /* * If network settings is qutting and we've ppp * devices open we need to save the pid_t the PPData * and the interface number */ struct Connection { pid_t pid; QString device; QString name; }; class InterfaceKeeper { public: InterfaceKeeper(); ~InterfaceKeeper(); void addInterface( pid_t, const QString& pppDev, const QString& name ); QMap<QString, Connection> interfaces()const; // will check if still available private: bool isAvailable( pid_t )const; QMap<QString, Connection> m_interfaces; }; } /** * Constructor, find all of the possible interfaces * We also need to restore the state.. it could be that * an interface was up while closing the application * we need to be able to shut it down... */ PPPModule::PPPModule() : Module() { InterfaceKeeper inFace; QMap<QString,Connection> running = inFace.interfaces(); QStringList handledInterfaceNames; QMap<QString,QString> ifaces = PPPData::getConfiguredInterfaces(); QMap<QString,QString>::Iterator it; InterfacePPP *iface; odebug << "getting interfaces" << oendl; for( it = ifaces.begin(); it != ifaces.end(); ++it ) { odebug << "ifaces " << it.key().latin1() << " " << it.data().latin1() << "" << oendl; iface = new InterfacePPP( 0, it.key() ); iface->setHardwareName( it.data() ); list.append( (Interface*)iface ); // check if (*it) is one of the running ifaces if ( running.contains( it.data() ) ) { odebug << "iface is running " << it.key().latin1() << "" << oendl; handledInterfaceNames << running[it.data()].device; iface->setStatus( true ); iface->setPPPDpid( running[it.data()].pid ); iface->modem()->setPPPDevice( running[it.data()].device ); iface->refresh(); } } setHandledInterfaceNames( handledInterfaceNames ); } /** * Delete any interfaces that we own. */ PPPModule::~PPPModule() { odebug << "PPPModule::~PPPModule() " << oendl; QMap<QString,QString> ifaces; InterfaceKeeper keeper; Interface *i; for ( i=list.first(); i != 0; i=list.next() ) { /* if online save the state */ if ( i->getStatus() ) { odebug << "Iface " << i->getHardwareName().latin1() << " is still up" << oendl; InterfacePPP* ppp = static_cast<InterfacePPP*>(i); keeper.addInterface( ppp->pppPID(), ppp->pppDev(), ppp->getHardwareName() ); } ifaces.insert( i->getInterfaceName(), i->getHardwareName() ); delete i; } PPPData::setConfiguredInterfaces( ifaces ); } /** * 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 diff --git a/noncore/settings/networksettings/wlan/config.in b/noncore/settings/networksettings/wlan/config.in index d4661cb..233764e 100644 --- a/noncore/settings/networksettings/wlan/config.in +++ b/noncore/settings/networksettings/wlan/config.in @@ -1,6 +1,6 @@ config WLAN boolean "opie-networksettingsplugin-wlan (wireless LAN module)" - default "n" if NETWORKSETUP + default "y" depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES && LIBOPIE2NET #comment "opie-networksettingsplugin-wlan needs libopie2ui, libopie2net and networksetup" - #depends !( LIBOPIE2NET && NETWORKSETUP)
\ No newline at end of file + #depends !( LIBOPIE2NET && NETWORKSETUP) diff --git a/noncore/settings/networksettings/wlan/infoimp.cpp b/noncore/settings/networksettings/wlan/infoimp.cpp index c558f5e..273bed8 100644 --- a/noncore/settings/networksettings/wlan/infoimp.cpp +++ b/noncore/settings/networksettings/wlan/infoimp.cpp @@ -1,56 +1,61 @@ #include "infoimp.h" #include "wextensions.h" +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* QT */ #include <qtimer.h> #include <qprogressbar.h> #include <qlabel.h> /** * Constructor. If wireless extensions are enabled on device name then * start a timer that every second will update the information. */ WlanInfoImp::WlanInfoImp( QWidget* parent, const char* name, WFlags fl): WlanInfo(parent, name, fl){ WExtensions *wExtensions = new WExtensions(name); if(!wExtensions->doesHaveWirelessExtensions()){ delete wExtensions; odebug << "WlanInfoImp::No wireless extension" << oendl; return; } delete wExtensions; timer = new QTimer( this ); connect( timer, SIGNAL(timeout()), this, SLOT(update())); timer->start( 1000, false ); } /** * Updates the information about the wireless device. */ void WlanInfoImp::update(){ WExtensions *wExtensions = new WExtensions(this->name()); if(!wExtensions->doesHaveWirelessExtensions()){ odebug << "No extension" << oendl; delete wExtensions; timer->stop(); return; } essidLabel->setText(wExtensions->essid()); apLabel->setText(wExtensions->ap()); stationLabel->setText(wExtensions->station()); modeLabel->setText(wExtensions->mode()); channelLabel->setText(QString("%1").arg(wExtensions->channel())); int signal = 0; int noise = 0; int quality = 0; wExtensions->stats(signal, noise, quality); if(signalProgressBar->progress() != signal) signalProgressBar->setProgress(signal); if(noiseProgressBar->progress() != noise) noiseProgressBar->setProgress(noise); if(qualityProgressBar->progress() != quality) qualityProgressBar->setProgress(quality); rateLabel->setText(QString("%1 Mb/s").arg(wExtensions->rate())); delete wExtensions; } // infoimp.cpp diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index 9c64323..fe21f02 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp @@ -1,143 +1,150 @@ #include "wextensions.h" +/* OPIE */ +#include <opie2/odebug.h> +using namespace Opie::Core; + +/* QT */ #include <qfile.h> #include <qtextstream.h> +/* STD */ #include <arpa/inet.h> #include <sys/socket.h> #include <sys/ioctl.h> - #include <math.h> #define PROCNETWIRELESS "/proc/net/wireless" #define IW_LOWER 0 #define IW_UPPER 256 +#warning This is duplicated code. Use libopienet2! + /** * Constructor. Sets hasWirelessExtensions */ WExtensions::WExtensions(QString interfaceName): hasWirelessExtensions(false), interface(interfaceName) { fd = socket( AF_INET, SOCK_DGRAM, 0 ); if(fd == -1) return; const char* buffer[200]; memset( &iwr, 0, sizeof( iwr ) ); iwr.u.essid.pointer = (caddr_t) buffer; iwr.u.essid.length = IW_ESSID_MAX_SIZE; iwr.u.essid.flags = 0; // check if it is an IEEE 802.11 standard conform // wireless device by sending SIOCGIWESSID // which also gives back the Extended Service Set ID // (see IEEE 802.11 for more information) const char* iname = interface.latin1(); strcpy( iwr.ifr_ifrn.ifrn_name, (const char *)iname ); if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr ) ) hasWirelessExtensions = true; } /** * @return QString the station name of the access point. */ QString WExtensions::station(){ if(!hasWirelessExtensions) return QString(); const char* buffer[200]; iwr.u.data.pointer = (caddr_t) buffer; iwr.u.data.length = IW_ESSID_MAX_SIZE; iwr.u.data.flags = 0; if ( 0 == ioctl( fd, SIOCGIWNICKN, &iwr )){ iwr.u.data.pointer[(unsigned int) iwr.u.data.length-1] = '\0'; return QString(iwr.u.data.pointer); } return QString(); } /** * @return QString the essid of the host 802.11 access point. */ QString WExtensions::essid(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWESSID, &iwr )){ iwr.u.essid.pointer[(unsigned int) iwr.u.essid.length] = '\0'; return QString(iwr.u.essid.pointer); } return QString(); } /** * @return QString the mode of interface */ QString WExtensions::mode(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWMODE, &iwr ) ) return QString("%1").arg(iwr.u.mode == IW_MODE_ADHOC ? "Ad-Hoc" : "Managed"); return QString(); } /** * Get the frequency that the interface is running at. * @return int the frequency that the interfacae is running at. */ double WExtensions::frequency(){ if(!hasWirelessExtensions) return 0; if ( 0 == ioctl( fd, SIOCGIWFREQ, &iwr )) return (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); return 0; } /** * Get the channel that the interface is running at. * @return int the channel that the interfacae is running at. */ int WExtensions::channel(){ if(!hasWirelessExtensions) return 0; if ( 0 != ioctl( fd, SIOCGIWFREQ, &iwr )) return 0; // http://www.elanix.com/pdf/an137e.pdf double num = (double( iwr.u.freq.m ) * pow( 10, iwr.u.freq.e ) / 1000000000); double left = 2.401; double right = 2.416; for(int channel = 1; channel<= 15; channel++){ if( num >= left && num <= right ) return channel; left += 0.005; right += 0.005; } odebug << QString("Unknown frequency: %1, returning -1 for the channel.").arg(num).latin1() << oendl; return -1; } /*** * Get the current rate that the card is transmiting at. * @return double the rate, 0 if error. */ double WExtensions::rate(){ if(!hasWirelessExtensions) return 0; if(0 == ioctl(fd, SIOCGIWRATE, &iwr)){ return ((double)iwr.u.bitrate.value)/1000000; } return 0; } /** * @return QString the AccessPoint that the interface is connected to. */ QString WExtensions::ap(){ if(!hasWirelessExtensions) return QString(); if ( 0 == ioctl( fd, SIOCGIWAP, &iwr )){ QString ap; ap = ap.sprintf( "%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", iwr.u.ap_addr.sa_data[0]&0xff, iwr.u.ap_addr.sa_data[1]&0xff, diff --git a/noncore/settings/networksettings/wlan/wlan.pro b/noncore/settings/networksettings/wlan/wlan.pro index 89867ae..c94dc0e 100644 --- a/noncore/settings/networksettings/wlan/wlan.pro +++ b/noncore/settings/networksettings/wlan/wlan.pro @@ -1,28 +1,25 @@ -# TEMPLATE = lib -#TEMPLATE = app CONFIG += qt plugin warn_on -#CONFIG += qt plugin warn_on DESTDIR = $(OPIEDIR)/plugins/networksettings HEADERS = infoimp.h wlanmodule.h wextensions.h keyedit.h SOURCES = infoimp.cpp wlanmodule.cpp wextensions.cpp keyedit.cpp INCLUDEPATH += $(OPIEDIR)/include ../ ../interfaces/ DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -L../interfaces/ -linterfaces -lopiecore2 -lopienet2 INTERFACES = wlan.ui info.ui TARGET = wlan VERSION = 1.0.0 #CONFIG += wirelessopts wirelessopts { HEADERS += wlanimp.h SOURCES += wlanimp.cpp } ! wirelessopts { HEADERS += wlanimp2.h SOURCES += wlanimp2.cpp } include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp index e4aa2f9..4294b12 100644 --- a/noncore/settings/networksettings/wlan/wlanimp2.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp @@ -1,174 +1,176 @@ #include "wlanimp2.h" #include "keyedit.h" #include "interfacesetupimp.h" - #include "../interfaces/interface.h" #include <assert.h> #include <errno.h> #include <string.h> +/* OPIE */ +#include <opie2/odebug.h> +#include <opie2/oprocess.h> +#include <opie2/onetwork.h> +#include <opie2/opcap.h> +#include <qpe/resource.h> +using namespace Opie::Core; +using namespace Opie::Net; + +/* QT */ #include <qapplication.h> #include <qfile.h> #include <qdir.h> #include <qdialog.h> #include <qtextstream.h> #include <qmessagebox.h> #include <qlineedit.h> #include <qlabel.h> #include <qspinbox.h> #include <qradiobutton.h> #include <qpushbutton.h> #include <qcheckbox.h> #include <qtabwidget.h> #include <qcombobox.h> #include <qlistview.h> #include <qvbox.h> #include <qprogressbar.h> -#ifdef QWS - #include <qpe/resource.h> - #include <opie2/oprocess.h> - #include <opie2/onetwork.h> - #include <opie2/opcap.h> -#else - #define OProcess KProcess - #include <kprocess.h> -#endif +/* STD */ +#include <assert.h> +#include <errno.h> +#include <string.h> #define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" #define PREUP "/etc/network/if-pre-up.d/wireless-tools" /** * Constructor, read in the wireless.opts file for parsing later. */ -using namespace Opie::Net; -using namespace Opie::Core; WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl) : WLAN(parent, name, modal, fl), interface(i), currentProfile("*") { interfaces = new Interfaces(); interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, interfaces); tabWidget->insertTab(interfaceSetup, "TCP/IP"); // Check sanity - the existance of the wireless-tools if-pre-up script QFile file(QString(PREUP)); if (file.exists()) { owarn << QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools") << oendl; } connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) ); connect( netView, SIGNAL( clicked(QListViewItem*) ), this, SLOT( selectNetwork(QListViewItem*) ) ); netView->setColumnAlignment( col_chn, AlignCenter ); netView->setItemMargin( 3 ); netView->setAllColumnsShowFocus( true ); } WLANImp::~WLANImp() { //FIXME: delete interfaces; } /** * Change the profile for both wireless settings and network settings. */ void WLANImp::setProfile(const QString &profile){ interfaceSetup->setProfile(profile); parseOpts(); } void WLANImp::parseOpts() { bool error; QString opt; if (! interfaces->isInterfaceSet()) return; opt = interfaces->getInterfaceOption("wireless_essid", error); if(opt == "any" || opt == "off" || opt.isNull()){ essid->setEditText("any"); } else { essid->setEditText(opt); } opt = interfaces->getInterfaceOption("wireless_mode", error).simplifyWhiteSpace(); for ( int i = 0; i < mode->count(); i++) if ( mode->text( i ) == opt ) mode->setCurrentItem( i ); opt = interfaces->getInterfaceOption("wireless_ap", error).simplifyWhiteSpace(); if (! opt.isNull()) { specifyAp->setChecked(true); macEdit->setText(opt); } opt = interfaces->getInterfaceOption("wireless_channel", error).simplifyWhiteSpace(); if (! opt.isNull()) { specifyChan->setChecked(true); networkChannel->setValue(opt.toInt()); } opt = interfaces->getInterfaceOption("wireless_key", error).simplifyWhiteSpace(); if (opt.isNull()) opt = interfaces->getInterfaceOption("wireless_enc", error).simplifyWhiteSpace(); parseKeyStr(opt); } void WLANImp::parseKeyStr(QString keystr) { int loc = 0; int index = 1; QString key; QStringList keys = QStringList::split(QRegExp("\\s+"), keystr); int enc = -1; // encryption state for (QStringList::Iterator it = keys.begin(); it != keys.end(); ++it) { if ((*it).left(3) == "off") { // encryption disabled enc = 0; } else if ((*it).left(2) == "on") { // encryption enabled enc = 1; } else if ((*it).left(4) == "open") { // open mode, accept non encrypted packets acceptNonEnc->setChecked(true); } else if ((*it).left(10) == "restricted") { // restricted mode, only accept encrypted packets rejectNonEnc->setChecked(true); } else if ((*it).left(3) == "key") { // new set of options } else if ((*it).left(1) == "[") { index = (*it).mid(1, 1).toInt(); // switch current key to index switch (index) { case 1: keyRadio0->setChecked(true); break; case 2: keyRadio1->setChecked(true); break; case 3: keyRadio2->setChecked(true); break; case 4: keyRadio3->setChecked(true); break; } } else { // key key = (*it); } if (! key.isNull()) { if (enc == -1) enc = 1; QStringList::Iterator next = ++it; if (it == keys.end()) { break; } if ((*(next)).left(1) == "[") { // set key at index index = (*(next)).mid(1, 1).toInt(); } else { index = 1; } switch (index) { case 1: keyLineEdit0->setText(key); diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index 886af10..ba89fa4 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp @@ -1,137 +1,139 @@ #include "wlanmodule.h" #include "wlanimp2.h" #include "infoimp.h" #include "wextensions.h" #include "interfaceinformationimp.h" /* OPIE */ +#include <opie2/odebug.h> #include <qpe/qpeapplication.h> +using namespace Opie::Core; /* QT */ #include <qcheckbox.h> #include <qcombobox.h> #include <qlabel.h> #include <qlineedit.h> #include <qprogressbar.h> #include <qspinbox.h> #include <qtabwidget.h> /** * Constructor, find all of the possible interfaces */ WLANModule::WLANModule() : Module(), wlanconfigWiget(0) { } /** * Delete any interfaces that we own. */ WLANModule::~WLANModule(){ Interface *i; for ( i=list.first(); i != 0; i=list.next() ) delete i; } /** * Change the current profile */ void WLANModule::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 WLANModule::getPixmapName(Interface* ){ return "wlan"; } /** * 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 WLANModule::isOwner(Interface *i){ WExtensions we(i->getInterfaceName()); if(!we.doesHaveWirelessExtensions()) return false; i->setHardwareName("802.11b"); list.append(i); return true; } /** * Create, and return the WLANConfigure Module * @return QWidget* pointer to this modules configure. */ QWidget *WLANModule::configure(Interface *i){ WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, true, Qt::WDestructiveClose); wlanconfig->setProfile(profile); return wlanconfig; } /** * Create, and return the Information Module * @return QWidget* pointer to this modules info. */ QWidget *WLANModule::information(Interface *i){ WExtensions we(i->getInterfaceName()); if(!we.doesHaveWirelessExtensions()) return NULL; return getInfo( 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> WLANModule::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 *WLANModule::addNewInterface(const QString &){ // We can't add a 802.11 interface, either the hardware will be there // or it wont. return NULL; } /** * Attempts to remove the interface, doesn't delete i * @return bool true if successful, false otherwise. */ bool WLANModule::remove(Interface*){ // Can't remove a hardware device, you can stop it though. return false; } void WLANModule::receive(const QCString ¶m, const QByteArray &arg) { odebug << "WLANModule::receive "+param << oendl; QStringList params = QStringList::split(",",param); int count = params.count(); odebug << "WLANModule got " << count << " params" << oendl; if (count < 2){ odebug << "Erorr less than 2 parameter" << oendl; odebug << "RETURNING" << oendl; return; } QDataStream stream(arg,IO_ReadOnly); QString interface; QString action; |