summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp4
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp14
-rw-r--r--noncore/settings/networksettings/ppp/edit.cpp8
-rw-r--r--noncore/settings/networksettings/ppp/general.cpp4
-rw-r--r--noncore/settings/networksettings/ppp/kpppwidget.cpp12
-rw-r--r--noncore/settings/networksettings/ppp/pppdargs.cpp4
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp2.cpp2
7 files changed, 24 insertions, 24 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
index 698dfd3..ff65424 100644
--- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
@@ -1,104 +1,104 @@
#include "interfaceinformationimp.h"
#include "interfaceadvanced.h"
/* OPIE */
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
/* QT */
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qgroupbox.h>
#include <qmessagebox.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.
*/
InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i)
{
- connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
- connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &)));
+ connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*)));
+ connect(i, SIGNAL(updateMessage(const QString&)), this, SLOT(showMessage(const QString&)));
updateInterface(interface);
connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
Config cfg("networksettings", Config::User);
cfg.setGroup("interface");
CheckBoxSilent->setChecked( cfg.readBoolEntry("silent", false) );
}
InterfaceInformationImp::~InterfaceInformationImp()
{
Config cfg("networksettings", Config::User);
cfg.setGroup("interface");
cfg.writeEntry("silent", CheckBoxSilent->isChecked() );
}
/**
* Update the interface information and buttons.
* @param Intarface *i the interface to update (should be the one we already
* know about).
*/
void InterfaceInformationImp::updateInterface(Interface *)
{
if(interface->getStatus())
{
startButton->setEnabled(false);
stopButton->setEnabled(true);
restartButton->setEnabled(true);
}
else
{
startButton->setEnabled(true);
stopButton->setEnabled(false);
restartButton->setEnabled(false);
}
macAddressLabel->setText(interface->getMacAddress());
ipAddressLabel->setText(interface->getIp());
subnetMaskLabel->setText(interface->getSubnetMask());
broadcastLabel->setText(interface->getBroadcast());
}
/**
* Create the advanced widget. Fill it with the current interface's information.
* Display it.
*/
void InterfaceInformationImp::advanced()
{
InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog);
a->interfaceName->setText(interface->getInterfaceName());
a->macAddressLabel->setText(interface->getMacAddress());
a->ipAddressLabel->setText(interface->getIp());
a->subnetMaskLabel->setText(interface->getSubnetMask());
a->broadcastLabel->setText(interface->getBroadcast());
a->dhcpServerLabel->setText(interface->getDhcpServerIp());
a->leaseObtainedLabel->setText(interface->getLeaseObtained());
a->leaseExpiresLabel->setText(interface->getLeaseExpires());
a->dhcpInformation->setEnabled(interface->isDhcp());
QPEApplication::showWidget( a );
}
/**
* Messages from the interface if start/stop went as planned.
* Purly for user feedback.
* @param message the message to display.
*/
void InterfaceInformationImp::showMessage(const QString &message)
{
if (CheckBoxSilent->isChecked()) return;
QMessageBox::information(this, "Message", message, QMessageBox::Ok);
}
// infoimp.cpp
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index b0a1dd9..1e16b97 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,464 +1,464 @@
#include "mainwindowimp.h"
#include "addconnectionimp.h"
#include "interfaceinformationimp.h"
#include "interfacesetupimp.h"
#include "interfaces.h"
#include "module.h"
/* OPIE */
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/qlibrary.h>
#include <qpe/resource.h>
/* QT */
#include <qpushbutton.h>
#include <qlistbox.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <qheader.h>
#include <qlabel.h>
#include <qtabwidget.h> // in order to disable the profiles tab
#include <qmessagebox.h>
#if QT_VERSION < 300
#include <qlist.h>
#else
#include <qptrlist.h>
#endif
#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qregexp.h>
/* STD */
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
#define _PROCNETDEV "/proc/net/dev"
MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME)
{
connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
//FIXME: disable profiles for the moment:
tabWidget->setTabEnabled( tab, false );
// Load connections.
// /usr/local/kde/lib/libinterfaces.la
#ifdef QWS
loadModules(QPEApplication::qpeDir() + "plugins/networksettings");
#else
loader = KLibLoader::self();
loadModules(QString("/usr/")+KStandardDirs::kde_default("lib"));
#endif
getAllInterfaces();
Interfaces i;
QStringList list = i.getInterfaceList();
QMap<QString, Interface*>::Iterator it;
for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni )
{
/*
* we skipped it in getAllInterfaces now
* we need to ignore it as well
*/
if (m_handledIfaces.contains( *ni) )
{
qDebug("Not up iface handled by module");
continue;
}
bool found = false;
for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it )
{
if(it.key() == (*ni))
found = true;
}
if(!found)
{
if(!(*ni).contains("_"))
{
Interface *i = new Interface(this, *ni, false);
i->setAttached(false);
i->setHardwareName(tr("Disconnected"));
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
- connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
+ connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*)));
}
}
}
//getInterfaceList();
connectionList->header()->hide();
Config cfg("NetworkSetup");
profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
for ( QStringList::Iterator it = profiles.begin();
it != profiles.end(); ++it)
profilesList->insertItem((*it));
currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
QFile file(scheme);
if ( file.open(IO_ReadOnly) )
{ // file opened successfully
QTextStream stream( &file ); // use a text stream
while ( !stream.eof() )
{ // until end of file...
QString line = stream.readLine(); // line of text excluding '\n'
if(line.contains("SCHEME"))
{
line = line.mid(7, line.length());
currentProfileLabel->setText(line);
break;
}
}
file.close();
}
makeChannel();
}
/**
* Deconstructor. Save profiles. Delete loaded libraries.
*/
MainWindowImp::~MainWindowImp()
{
// Save profiles.
Config cfg("NetworkSetup");
cfg.setGroup("General");
cfg.writeEntry("Profiles", profiles.join(" "));
// Delete all interfaces that don't have owners.
QMap<Interface*, QListViewItem*>::Iterator iIt;
for( iIt = items.begin(); iIt != items.end(); ++iIt )
{
if(iIt.key()->getModuleOwner() == NULL)
delete iIt.key();
}
#ifdef QWS
// Delete Modules and Libraries
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
delete it.key();
// I wonder why I can't delete the libraries
// What fucking shit this is.
//delete it.data();
}
#else
// klibloader automaticly deletes the libraries for us...
#endif
}
/**
* Query the kernel for all of the interfaces.
*/
void MainWindowImp::getAllInterfaces()
{
int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
if(sockfd == -1)
return;
struct ifreq ifr;
QStringList ifaces;
QFile procFile(QString(_PROCNETDEV));
int result;
Interface *i;
if (! procFile.exists())
{
struct ifreq ifrs[100];
struct ifconf ifc;
ifc.ifc_len = sizeof(ifrs);
ifc.ifc_req = ifrs;
result = ioctl(sockfd, SIOCGIFCONF, &ifc);
for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++)
{
struct ifreq *pifr = &ifrs[i];
ifaces += pifr->ifr_name;
}
}
else
{
procFile.open(IO_ReadOnly);
QString line;
QTextStream procTs(&procFile);
int loc = -1;
procTs.readLine(); // eat a line
procTs.readLine(); // eat a line
while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null)
{
if((loc = line.find(":")) != -1)
{
ifaces += line.left(loc);
}
}
}
for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it)
{
int flags = 0;
if ( m_handledIfaces.contains( (*it) ) )
{
qDebug(" %s is handled by a module", (*it).latin1() );
continue;
}
// int family;
i = NULL;
strcpy(ifr.ifr_name, (*it).latin1());
struct ifreq ifcopy;
ifcopy = ifr;
result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
flags = ifcopy.ifr_flags;
i = new Interface(this, ifr.ifr_name, false);
i->setAttached(true);
if ((flags & IFF_UP) == IFF_UP)
i->setStatus(true);
else
i->setStatus(false);
if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
i->setHardwareName("Ethernet");
else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
i->setHardwareName("Point to Point");
else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
i->setHardwareName("Multicast");
else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
i->setHardwareName("Loopback");
else
i->setHardwareName("Unknown");
qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name);
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
- connect(i, SIGNAL(updateInterface(Interface *)),
- this, SLOT(updateInterface(Interface *)));
+ connect(i, SIGNAL(updateInterface(Interface*)),
+ this, SLOT(updateInterface(Interface*)));
}
// now lets ask the plugins too ;)
QMap<Module*, QLibrary*>::Iterator it;
QList<Interface> ilist;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
if(it.key())
{
ilist = it.key()->getInterfaces();
for( i = ilist.first(); i != 0; i = ilist.next() )
{
qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() );
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
- connect(i, SIGNAL(updateInterface(Interface *)),
- this, SLOT(updateInterface(Interface *)));
+ connect(i, SIGNAL(updateInterface(Interface*)),
+ this, SLOT(updateInterface(Interface*)));
}
}
}
}
/**
* Load all modules that are found in the path
* @param path a directory that is scaned for any plugins that can be loaded
* and attempts to load them
*/
void MainWindowImp::loadModules(const QString &path)
{
#ifdef DEBUG
qDebug("MainWindowImp::loadModules: %s", path.latin1());
#endif
QDir d(path);
if(!d.exists())
return;
// Don't want sym links
d.setFilter( QDir::Files | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) )
{
#ifdef QWS
if(fi->fileName().contains(".so"))
{
#else
if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_"))
{
#endif
loadPlugin(path + "/" + fi->fileName());
qDebug("loaded plugin: >%s< ",QString(path + "/" + fi->fileName()).latin1());
}
++it;
}
}
/**
* Attempt to load a function and resolve a function.
* @param pluginFileName - the name of the file in which to attempt to load
* @param resolveString - function pointer to resolve
* @return pointer to the function with name resolveString or NULL
*/
Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString)
{
#ifdef DEBUG
qDebug("MainWindowImp::loadPlugin: %s: resolving %s", pluginFileName.latin1(), resolveString.latin1());
#endif
#ifdef QWS
QLibrary *lib = new QLibrary(pluginFileName);
void *functionPointer = lib->resolve(resolveString);
if( !functionPointer )
{
#ifdef DEBUG
qDebug("MainWindowImp::loadPlugin: Warning: %s is not a plugin", pluginFileName.latin1());
#endif
delete lib;
return NULL;
}
// Try to get an object.
Module *object = ((Module* (*)()) functionPointer)();
if(object == NULL)
{
#ifdef DEBUG
qDebug("MainWindowImp: Couldn't create object, but did load library!");
#endif
delete lib;
return NULL;
}
m_handledIfaces += object->handledInterfaceNames();
// Store for deletion later
libraries.insert(object, lib);
return object;
#else
QLibrary *lib = loader->library(pluginFileName);
if( !lib || !lib->hasSymbol(resolveString) )
{
qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
return NULL;
}
// Try to get an object.
Module *object = ((Module* (*)()) lib->symbol(resolveString))();
if(object == NULL)
{
#ifdef DEBUG
qDebug("MainWindowImp: Couldn't create object, but did load library!");
#endif
return NULL;
}
#ifdef DEBUG
qDebug("MainWindowImp::loadPlugin:: Found object, storing.");
#endif
// Store for deletion later
libraries.insert(object, lib);
return object;
#endif
}
/**
* The Add button was clicked. Bring up the add dialog and if OK is hit
* load the plugin and append it to the list
*/
void MainWindowImp::addClicked()
{
QMap<Module*, QLibrary*>::Iterator it;
QMap<QString, QString> list;
QMap<QString, Module*> newInterfaceOwners;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
if(it.key())
{
(it.key())->possibleNewInterfaces(list);
}
}
// See if the list has anything that we can add.
if(list.count() == 0)
{
QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
return;
}
AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
addNewConnection.addConnections(list);
if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) )
{
QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
if(!item)
return;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
if(it.key())
{
Interface *i = (it.key())->addNewInterface(item->text(0));
if(i)
{
qDebug("iface name %s",i->getInterfaceName().latin1());
interfaceNames.insert(i->getInterfaceName(), i);
updateInterface(i);
}
}
}
}
}
/**
* Prompt the user to see if they really want to do this.
* If they do then remove from the list and unload.
*/
void MainWindowImp::removeClicked()
{
QListViewItem *item = connectionList->currentItem();
if(!item)
{
QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
return;
}
Interface *i = interfaceItems[item];
if(i->getModuleOwner() == NULL)
{
QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
}
else
{
if(!i->getModuleOwner()->remove(i))
QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok);
else
{
delete item;
// QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
}
}
}
/**
* Pull up the configure about the currently selected interface.
* Report an error if no interface is selected.
* If the interface has a module owner then request its configure.
*/
void MainWindowImp::configureClicked()
{
QListViewItem *item = connectionList->currentItem();
if(!item)
{
QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok);
return;
@@ -523,226 +523,226 @@ void MainWindowImp::informationClicked()
}
/**
* Update this interface. If no QListViewItem exists create one.
* @param Interface* pointer to the interface that needs to be updated.
*/
void MainWindowImp::updateInterface(Interface *i)
{
if(!advancedUserMode)
{
if(i->getInterfaceName() == "lo")
return;
}
QListViewItem *item = NULL;
// Find the interface, making it if needed.
if(items.find(i) == items.end())
{
item = new QListViewItem(connectionList, "", "", "");
// See if you can't find a module owner for this interface
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
if(it.key()->isOwner(i))
i->setModuleOwner(it.key());
}
items.insert(i, item);
interfaceItems.insert(item, i);
}
else
item = items[i];
// Update the icons and information
#ifdef QWS
item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
#else
item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down")));
#endif
QString typeName = "lan";
if(i->getInterfaceName() == "lo")
typeName = "lo";
if(i->getInterfaceName().contains("irda"))
typeName = "irda";
if(i->getInterfaceName().contains("wlan"))
typeName = "wlan";
if(i->getInterfaceName().contains("usb"))
typeName = "usb";
if(!i->isAttached())
typeName = "connect_no";
// Actually try to use the Module
if(i->getModuleOwner() != NULL)
typeName = i->getModuleOwner()->getPixmapName(i);
#ifdef QWS
item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName)));
#else
item->setPixmap(1, (SmallIcon(typeName)));
#endif
item->setText(2, i->getHardwareName());
item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
}
void MainWindowImp::newProfileChanged(const QString& newText)
{
if(newText.length() > 0)
newProfileButton->setEnabled(true);
else
newProfileButton->setEnabled(false);
}
/**
* Adds a new profile to the list of profiles.
* Don't add profiles that already exists.
* Appends to the list and QStringList
*/
void MainWindowImp::addProfile()
{
QString newProfileName = newProfile->text();
if(profiles.grep(newProfileName).count() > 0)
{
QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
return;
}
profiles.append(newProfileName);
profilesList->insertItem(newProfileName);
}
/**
* Removes the currently selected profile in the combo.
* Doesn't delete if there are less then 2 profiles.
*/
void MainWindowImp::removeProfile()
{
if(profilesList->count() <= 1)
{
QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
return;
}
QString profileToRemove = profilesList->currentText();
if(profileToRemove == "All")
{
QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
return;
}
// Can't remove the curent profile
if(profileToRemove == currentProfileLabel->text())
{
QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
return;
}
if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
{
profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
profilesList->clear();
for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
profilesList->insertItem((*it));
// Remove any interface settings and mappings.
Interfaces interfaces;
// Go through them one by one
QMap<Interface*, QListViewItem*>::Iterator it;
for( it = items.begin(); it != items.end(); ++it )
{
QString interfaceName = it.key()->getInterfaceName();
qDebug(interfaceName.latin1());
if(interfaces.setInterface(interfaceName + "_" + profileToRemove))
{
interfaces.removeInterface();
if(interfaces.setMapping(interfaceName))
{
if(profilesList->count() == 1)
interfaces.removeMapping();
else
{
interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
}
}
interfaces.write();
break;
}
}
}
}
/**
* A new profile has been selected, change.
* @param newProfile the new profile.
*/
void MainWindowImp::changeProfile()
{
if(profilesList->currentItem() == -1)
{
QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
return;
}
QString newProfile = profilesList->text(profilesList->currentItem());
if(newProfile != currentProfileLabel->text())
{
currentProfileLabel->setText(newProfile);
QFile::remove(scheme);
QFile file(scheme);
if ( file.open(IO_ReadWrite) )
{
QTextStream stream( &file );
stream << QString("SCHEME=%1").arg(newProfile);
file.close();
}
// restart all up devices?
if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok)
{
// Go through them one by one
QMap<Interface*, QListViewItem*>::Iterator it;
for( it = items.begin(); it != items.end(); ++it )
{
if(it.key()->getStatus() == true)
it.key()->restart();
}
}
}
// TODO change the profile in the modules
}
void MainWindowImp::makeChannel()
{
channel = new QCopChannel( "QPE/Application/networksettings", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(receive(const QCString&, const QByteArray&)) );
+ connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
+ this, SLOT(receive(const QCString&,const QByteArray&)) );
}
void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
{
bool found = false;
qDebug("MainWindowImp::receive QCop msg >"+msg+"<");
if (msg == "raise")
{
raise();
return;
}
QString dest = msg.left(msg.find("("));
QCString param = msg.right(msg.length() - msg.find("(") - 1);
param = param.left( param.length() - 1 );
qDebug("dest >%s< param >"+param+"<",dest.latin1());
QMap<Module*, QLibrary*>::Iterator it;
for( it = libraries.begin(); it != libraries.end(); ++it )
{
qDebug("plugin >%s<", it.key()->type().latin1() );
if(it.key()->type() == dest)
{
it.key()->receive( param, arg );
found = true;
}
}
if (found) QPEApplication::setKeepRunning();
else qDebug("Huh what do ya want");
}
diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp
index 7d21605..3b2393c 100644
--- a/noncore/settings/networksettings/ppp/edit.cpp
+++ b/noncore/settings/networksettings/ppp/edit.cpp
@@ -383,386 +383,386 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char
staticadd_rb = new QRadioButton(box);
staticadd_rb->setText(tr("Static IP address"));
rb->insert(dynamicadd_rb, 0);
rb->insert(staticadd_rb, 1);
QWhatsThis::add(staticadd_rb,
tr("Select this option when your computer has a\n"
"fixed internet address (IP). Most computers\n"
"don't have this, so you should probably select\n"
"dynamic IP addressing unless you know what you\n"
"are doing."));
QWidget *ipWidget = new QWidget(box);
QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2);
ipLayout->setSpacing( 2 );//KDialog::spacingHint());
ipaddress_label = new QLabel(tr("IP address:"), ipWidget);
QString tmp = tr("If your computer has a permanent internet\n"
"address, you must supply your IP address here.");
ipLayout->addWidget(ipaddress_label, 0, 0);
ipaddress_l = new IPLineEdit(ipWidget);
ipLayout->addWidget(ipaddress_l, 0, 1);
QWhatsThis::add(ipaddress_label,tmp);
QWhatsThis::add(ipaddress_l,tmp);
sub_label = new QLabel(tr("Subnet mask:"), ipWidget);
tmp = tr("<p>If your computer has a static Internet address,\n"
"you must supply a network mask here. In almost\n"
"all cases this netmask will be <b>255.255.255.0</b>,\n"
"but your mileage may vary.\n"
"\n"
"If unsure, contact your Internet Service Provider");
ipLayout->addWidget(sub_label, 1, 0);
subnetmask_l = new IPLineEdit(ipWidget);
ipLayout->addWidget(subnetmask_l, 1, 1);
QWhatsThis::add(sub_label,tmp);
QWhatsThis::add(subnetmask_l,tmp);
autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this);
autoname->setChecked(_pppdata->autoname());
connect(autoname,SIGNAL(toggled(bool)),
this,SLOT(autoname_t(bool)));
QWhatsThis::add(autoname,
tr("<p>Whenever you connect, this reconfigures\n"
"your hostname to match the IP address you\n"
"got from the PPP server. This may be useful\n"
"if you need to use a protocol which depends\n"
"on this information, but it can also cause several\n"
"<a href=\"kppp-7.html#autohostname\">problems</a>.\n"
"\n"
"Don't enable this unless you really need it."));
topLayout->addWidget(box);
topLayout->addWidget(autoname);
topLayout->addStretch();
//load info from gpppdata
if(!isnewaccount)
{
if(_pppdata->ipaddr() == "0.0.0.0" &&
_pppdata->subnetmask() == "0.0.0.0")
{
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
autoname->setChecked(_pppdata->autoname());
}
else
{
ipaddress_l->setText(_pppdata->ipaddr());
subnetmask_l->setText(_pppdata->subnetmask());
staticadd_rb->setChecked(true);
autoname->setChecked(false);
}
}
else
{
dynamicadd_rb->setChecked(true);
hitIPSelect(0);
}
}
void IPWidget::autoname_t(bool on)
{
static bool was_warned = false;
// big-fat warning when selecting the auto configure hostname option
if(on && !was_warned)
{
QMessageBox::information(this,
tr("Selecting this option might cause some weird "
"problems with the X-server and applications "
"while kppp is connected. Don't use it until "
"you know what you are doing!\n"
"For more information take a look at the "
"handbook (or help) in the section \"Frequently "
"asked questions\"."),
tr("Warning"));
was_warned = true;
}
}
void IPWidget::save()
{
if(dynamicadd_rb->isChecked())
{
_pppdata->setIpaddr("0.0.0.0");
_pppdata->setSubnetmask("0.0.0.0");
}
else
{
_pppdata->setIpaddr(ipaddress_l->text());
_pppdata->setSubnetmask(subnetmask_l->text());
}
_pppdata->setAutoname(autoname->isChecked());
}
void IPWidget::hitIPSelect( int i )
{
if(i == 0)
{
ipaddress_label->setEnabled(false);
sub_label->setEnabled(false);
ipaddress_l->setEnabled(false);
subnetmask_l->setEnabled(false);
}
else
{
ipaddress_label->setEnabled(true);
sub_label->setEnabled(true);
ipaddress_l->setEnabled(true);
subnetmask_l->setEnabled(true);
}
}
DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
QGridLayout *tl = new QGridLayout(this, 7, 2, 0 );
dnsdomain_label = new QLabel(tr("Domain name:"), this);
tl->addWidget(dnsdomain_label, 0, 0);
dnsdomain = new QLineEdit(this);
tl->addWidget(dnsdomain, 0, 1);
QString tmp = tr("If you enter a domain name here, this domain\n"
"name is used for your computer while you are\n"
"connected. When the connection is closed, the\n"
"original domain name of your computer is\n"
"restored.\n"
"\n"
"If you leave this field blank, no changes are\n"
"made to the domain name.");
QWhatsThis::add(dnsdomain_label,tmp);
QWhatsThis::add(dnsdomain,tmp);
conf_label = new QLabel(tr("Configuration:"), this);
tl->addWidget(conf_label, 1, 0);
bg = new QButtonGroup("Group", this);
connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int)));
bg->hide();
autodns = new QRadioButton(tr("Automatic"), this);
bg->insert(autodns, 0);
tl->addWidget(autodns, 1, 1);
if(!_pppdata->pppdVersionMin(2, 3, 7))
autodns->setEnabled(false);
mandns = new QRadioButton(tr("Manual"), this);
bg->insert(mandns, 1);
tl->addWidget(mandns, 2, 1);
dns_label = new QLabel(tr("DNS IP address:"), this);
tl->addWidget(dns_label, 3, 0);
QHBoxLayout *l2 = new QHBoxLayout;
tl->addLayout(l2, 3, 1);
dnsipaddr = new IPLineEdit(this);
connect(dnsipaddr, SIGNAL(returnPressed()),
SLOT(adddns()));
- connect(dnsipaddr, SIGNAL(textChanged(const QString &)),
- SLOT(DNS_Edit_Changed(const QString &)));
+ connect(dnsipaddr, SIGNAL(textChanged(const QString&)),
+ SLOT(DNS_Edit_Changed(const QString&)));
l2->addWidget(dnsipaddr, 1);
l2->addStretch(1);
tmp = tr("<p>Allows you to specify a new DNS server to be\n"
"used while you are connected. When the\n"
"connection is closed, this DNS entry will be\n"
"removed again.\n"
"\n"
"To add a DNS server, type in the IP address of\n"
"the DNS server here and click on <b>Add</b>");
QWhatsThis::add(dns_label, tmp);
QWhatsThis::add(dnsipaddr, tmp);
QHBoxLayout *l1 = new QHBoxLayout;
tl->addLayout(l1, 4, 1);
add = new QPushButton(tr("Add"), this);
connect(add, SIGNAL(clicked()), SLOT(adddns()));
l1->addWidget(add);
// l1->addStretch(1);
QWhatsThis::add(add,
tr("Click this button to add the DNS server\n"
"specified in the field above. The entry\n"
"will then be added to the list below"));
remove = new QPushButton(tr("Remove"), this);
connect(remove, SIGNAL(clicked()), SLOT(removedns()));
l1->addWidget(remove);
QWhatsThis::add(remove,
tr("Click this button to remove the selected DNS\n"
"server entry from the list below"));
servers_label = new QLabel(tr("DNS address list:"), this);
servers_label->setAlignment(AlignTop|AlignLeft);
tl->addWidget(servers_label, 5, 0);
dnsservers = new QListBox(this);
dnsservers->setMinimumSize(150, 80);
connect(dnsservers, SIGNAL(highlighted(int)),
SLOT(DNS_Entry_Selected(int)));
tl->addWidget(dnsservers, 5, 1);
tmp = tr("<p>This shows all defined DNS servers to use\n"
"while you are connected. Use the <b>Add</b> and\n"
"<b>Remove</b> buttons to modify the list");
QWhatsThis::add(servers_label,tmp);
QWhatsThis::add(dnsservers,tmp);
exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this);
// exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this);
exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled());
tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter);
QWhatsThis::add(exdnsdisabled_toggle,
tr("<p>When this option is selected, all DNS\n"
"servers specified in <tt>/etc/resolv.conf</tt> are\n"
"temporary disabled while the dialup connection\n"
"is established. After the connection is\n"
"closed, the servers will be re-enabled\n"
"\n"
"Typically, there is no reason to use this\n"
"option, but it may become useful under \n"
"some circumstances."));
// restore data if editing
if(!isnewaccount)
{
dnsservers->insertStringList(_pppdata->dns());
dnsdomain->setText(_pppdata->domain());
}
int mode = _pppdata->autoDNS() ? 0 : 1;
bg->setButton(mode);
DNS_Mode_Selected(mode);
tl->activate();
}
void DNSWidget::DNS_Edit_Changed(const QString &text)
{
QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+");
add->setEnabled(text.find(r) != -1);
}
void DNSWidget::DNS_Entry_Selected(int)
{
remove->setEnabled(true);
}
void DNSWidget::DNS_Mode_Selected(int mode)
{
bool on = (mode == 1);
dns_label->setEnabled(on);
servers_label->setEnabled(on);
dnsipaddr->setText("");
dnsipaddr->setEnabled(on);
add->setEnabled(false);
remove->setEnabled(dnsservers->count()>0 && on);
dnsservers->clearSelection();
dnsservers->setEnabled(on);
dnsservers->triggerUpdate(false);
}
void DNSWidget::save()
{
_pppdata->setAutoDNS(bg->id(bg->selected()) == 0);
QStringList serverlist;
for(uint i=0; i < dnsservers->count(); i++)
serverlist.append(dnsservers->text(i));
_pppdata->setDns(serverlist);
// strip leading dot
QString s(dnsdomain->text());
if(s.left(1) == ".")
_pppdata->setDomain(s.mid(1));
else
_pppdata->setDomain(dnsdomain->text());
_pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked());
}
void DNSWidget::adddns()
{
if(dnsservers->count() < MAX_DNS_ENTRIES)
{
dnsservers->insertItem(dnsipaddr->text());
dnsipaddr->setText("");
}
}
void DNSWidget::removedns()
{
int i;
i = dnsservers->currentItem();
if(i != -1)
dnsservers->removeItem(i);
remove->setEnabled(dnsservers->count()>0);
}
//
// GatewayWidget
//
GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name )
: QWidget(parent, name), _pppdata(pd)
{
QVBoxLayout *topLayout = new QVBoxLayout(this);
topLayout->setSpacing( 2 );
topLayout->setMargin( 0 );
box = new QVGroupBox(tr("Configuration"), this);
rb = new QButtonGroup(this);
rb->hide();
connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int)));
defaultgateway = new QRadioButton(box);
defaultgateway->setText(tr("Default gateway"));
rb->insert(defaultgateway, 0);
QWhatsThis::add(defaultgateway,
tr("This makes the PPP peer computer (the computer\n"
"you are connected to with your modem) to act as\n"
"a gateway. Your computer will send all packets not\n"
"going to a computer inside your local net to this\n"
"computer, which will route these packets.\n"
"\n"
"This is the default for most ISPs, so you should\n"
"probably leave this option on."));
staticgateway = new QRadioButton(box);
staticgateway->setText(tr("Static gateway"));
rb->insert(staticgateway, 1);
QWhatsThis::add(staticgateway,
tr("<p>Allows you to specify which computer you want\n"
"to use as gateway (see <i>Default Gateway</i> above)"));
QHBox *gateBox = new QHBox(box);
gate_label = new QLabel(tr("Gateway IP address:"), gateBox);
gatewayaddr = new IPLineEdit(gateBox);
defaultroute = new QCheckBox(tr("Assign the default route to this gateway"),
this);
QWhatsThis::add(defaultroute,
tr("If this option is enabled, all packets not\n"
"going to the local net are routed through\n"
"the PPP connection.\n"
"\n"
"Normally, you should turn this on"));
topLayout->addWidget(box);
@@ -995,217 +995,217 @@ void ScriptWidget::addButton()
case ScriptEdit::Timeout:
stl->insertItem("Timeout");
sl->insertItem(se->text());
break;
case ScriptEdit::Password:
stl->insertItem("Password");
sl->insertItem(se->text());
break;
case ScriptEdit::ID:
stl->insertItem("ID");
sl->insertItem(se->text());
break;
case ScriptEdit::Prompt:
stl->insertItem("Prompt");
sl->insertItem(se->text());
break;
case ScriptEdit::PWPrompt:
stl->insertItem("PWPrompt");
sl->insertItem(se->text());
break;
case ScriptEdit::LoopStart:
stl->insertItem("LoopStart");
sl->insertItem(se->text());
break;
case ScriptEdit::LoopEnd:
stl->insertItem("LoopEnd");
sl->insertItem(se->text());
break;
case ScriptEdit::Scan:
stl->insertItem("Scan");
sl->insertItem(se->text());
break;
case ScriptEdit::Save:
stl->insertItem("Save");
sl->insertItem(se->text());
break;
default:
break;
}
//get the scrollbar adjusted, and scroll the list so we can see what
//we're adding to
adjustScrollBar();
slb->setValue(slb->maxValue());
//clear the text in the entry box
se->setText("");
}
void ScriptWidget::insertButton()
{
//exit if there is no highlighted item, or we've reached the
//maximum entries in the script list
if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1))
return;
switch(se->type())
{
case ScriptEdit::Expect:
stl->insertItem("Expect", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Send:
stl->insertItem("Send", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::SendNoEcho:
stl->insertItem("SendNoEcho", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Pause:
stl->insertItem("Pause", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Hangup:
stl->insertItem("Hangup", stl->currentItem());
sl->insertItem("", sl->currentItem());
break;
case ScriptEdit::Answer:
stl->insertItem("Answer", stl->currentItem());
sl->insertItem("", sl->currentItem());
break;
case ScriptEdit::Timeout:
stl->insertItem("Timeout", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Password:
stl->insertItem("Password", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::ID:
stl->insertItem("ID", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Prompt:
stl->insertItem("Prompt", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::PWPrompt:
stl->insertItem("PWPrompt", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::LoopStart:
stl->insertItem("LoopStart", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::LoopEnd:
stl->insertItem("LoopEnd", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Scan:
stl->insertItem("Scan", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
case ScriptEdit::Save:
stl->insertItem("Save", stl->currentItem());
sl->insertItem(se->text(), sl->currentItem());
break;
default:
break;
}
adjustScrollBar();
se->setText("");
}
void ScriptWidget::removeButton()
{
if(sl->currentItem() >= 0)
{
int stlc = stl->currentItem();
sl->removeItem(sl->currentItem());
stl->removeItem(stlc);
adjustScrollBar();
insert->setEnabled(sl->currentItem() != -1);
remove->setEnabled(sl->currentItem() != -1);
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Used to specify a new phone number
//
/////////////////////////////////////////////////////////////////////////////
PhoneNumberDialog::PhoneNumberDialog(QWidget *parent)
: QDialog(parent,"PhoneNumberDialog",true)
{
setCaption( tr("Add Phone Number") );
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setSpacing( 3 );
layout->setMargin( 3 );
// QHBox *hbox = new QHBox(this);
// setMainWidget(hbox);
// hbox->setSpacing( 2 );//KDialog::spacingHint());
QLabel *label = new QLabel(this, tr("Enter a phone number:"));
layout->addWidget( label );
le = new QLineEdit(this, "lineEdit");
layout->addWidget( le );
- connect(le, SIGNAL(textChanged(const QString &)),
- this, SLOT(textChanged(const QString &)));
+ connect(le, SIGNAL(textChanged(const QString&)),
+ this, SLOT(textChanged(const QString&)));
le->setFocus();
textChanged("");
}
QString PhoneNumberDialog::phoneNumber()
{
QString s = le->text();
return s;
}
void PhoneNumberDialog::textChanged(const QString &s)
{
// enableButtonOK(s.length() > 0);
}
//#include "edit.moc"
diff --git a/noncore/settings/networksettings/ppp/general.cpp b/noncore/settings/networksettings/ppp/general.cpp
index ff1b11b..81dab38 100644
--- a/noncore/settings/networksettings/ppp/general.cpp
+++ b/noncore/settings/networksettings/ppp/general.cpp
@@ -1,280 +1,280 @@
/*
* 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 <qpe/config.h>
#include <qpe/qpeapplication.h>
/* 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 &) ) );
+ // 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
#ifdef B57600
"57600",
#endif
"38400",
"19200",
"9600",
"2400",
0
};
for(k = 0; baudrates[k]; k++)
baud_c->insertItem(baudrates[k]);
baud_c->setCurrentItem(3);
// connect(baud_c, SIGNAL(activated(int)),
// this, SLOT(speed_selection(int)));
tl->addWidget(baud_c, 4, 1);
tmp = tr("Specifies the speed your modem and the serial\n"
"port talk to each other. You should begin with\n"
"the default of 38400 bits/sec. If everything\n"
"works you can try to increase this value, but to\n"
"no more than 115200 bits/sec (unless you know\n"
"that your serial port supports higher speeds).");
QWhatsThis::add(baud_label,tmp);
QWhatsThis::add(baud_c,tmp);
for(int i=0; i <= enter->count()-1; i++)
{
if(_pppdata->enter() == enter->text(i))
enter->setCurrentItem(i);
}
tl->addRowSpacing(5, 10);
//Modem Lock File
modemlockfile = new QCheckBox(tr("&Use lock file"), this);
modemlockfile->setChecked(_pppdata->modemLockFile());
// connect(modemlockfile, SIGNAL(toggled(bool)),
// SLOT(modemlockfilechanged(bool)));
tl->addMultiCellWidget(modemlockfile, 6, 6, 0, 1);
// l12->addStretch(1);
QWhatsThis::add(modemlockfile,
tr("<p>To prevent other programs from accessing the\n"
"modem while a connection is established, a\n"
"file can be created to indicate that the modem\n"
"is in use. On Linux an example file would be\n"
"<tt>/var/lock/LCK..ttyS1</tt>\n"
"Here you can select whether this locking will\n"
"be done.\n"
"\n"
"<b>Default</b>: On"));
// Modem Timeout Line Edit Box
QHBoxLayout *timeoutLayout = new QHBoxLayout( this );
QLabel *timeoutlabel = new QLabel( tr("Modem timeout:") ,this, "timeout" );
modemtimeout = new QSpinBox( 1, 120, 1, this, "modemTimeout" );
// modemtimeout = new KIntNumInput(_pppdata->modemTimeout(), this);
// modemtimeout->setLabel(tr("Modem &timeout:"));
// modemtimeout->setRange(1, 120, 1);
modemtimeout->setSuffix(tr(" sec"));
modemtimeout->setValue( _pppdata->modemTimeout() );
// connect(modemtimeout, SIGNAL(valueChanged(int)),
// SLOT(modemtimeoutchanged(int)));
timeoutLayout->addWidget(timeoutlabel);
timeoutLayout->addWidget(modemtimeout);
tl->addMultiCellLayout(timeoutLayout, 7, 7, 0, 1);
QWhatsThis::add(modemtimeout,
tr("This specifies how long <i>kppp</i> waits for a\n"
"<i>CONNECT</i> response from your modem. The\n"
"recommended value is 30 seconds."));
//set stuff from gpppdata
for(int i=0; i <= enter->count()-1; i++)
{
if(_pppdata->enter() == enter->text(i))
enter->setCurrentItem(i);
}
for(int i=0; i <= modemdevice->count()-1; i++)
{
if(_pppdata->modemDevice() == modemdevice->text(i))
modemdevice->setCurrentItem(i);
}
for(int i=0; i <= flowcontrol->count()-1; i++)
{
if(_pppdata->flowcontrol() == flowcontrol->text(i))
flowcontrol->setCurrentItem(i);
}
//set the modem speed
for(int i=0; i < baud_c->count(); i++)
if(baud_c->text(i) == _pppdata->speed())
baud_c->setCurrentItem(i);
tl->setRowStretch(1, 1);
}
ModemWidget::~ModemWidget()
{
QStringList devs;
for (int i=0;i<modemdevice->count();i++)
{
QString s = modemdevice->text(i);
s.simplifyWhiteSpace();
if (! s.isEmpty() ) devs << s;
}
QString edited = modemdevice->currentText();
if ( !( edited ).isEmpty() )
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp
index e466358..e21bbc7 100644
--- a/noncore/settings/networksettings/ppp/kpppwidget.cpp
+++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp
@@ -207,671 +207,671 @@ KPPPWidget::KPPPWidget(PPPData*pd, Interface *i, QWidget *parent, const char *na
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(_pppdata);
// 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(_pppdata, 0, "conw", this);
// KWin::setIcons(con_win->winId(), kapp->icon(), kapp->miniIcon());
// statdlg = new PPPStatsDlg(0, "stats", this, stats);
// statdlg->hide();
// load up the accounts combo box
// resetaccounts();
con = new ConnectWidget(_pppdata, 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(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()));
// 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->setAccount(m_strCmdlAccount);
// if (!result){
// QString string;
// string = QObject::tr("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->save();
}
void KPPPWidget::shutDown() {
interruptConnection();
saveMyself();
}
void KPPPWidget::log_window_toggled(bool on) {
_pppdata->set_show_log_window(on);
}
// void KPPPWidget::resetaccounts() {
// connectto_c->clear();
// int count = _pppdata->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->setAccountbyIndex(i);
// connectto_c->insertItem(_pppdata->accname());
// }
// //set the default account
// if(!_pppdata->defaultAccount().isEmpty()) {
// for(int i=0; i < count; i++)
// if(_pppdata->defaultAccount() == connectto_c->text(i)) {
// connectto_c->setCurrentItem(i);
// _pppdata->setAccountbyIndex(i);
// ID_Edit->setText(_pppdata->storedUsername());
// PW_Edit->setText(_pppdata->storedPassword());
// }
// }
// else
// if(count > 0) {
// _pppdata->setDefaultAccount(connectto_c->text(0));
// _pppdata->save();
// ID_Edit->setText(_pppdata->storedUsername());
// PW_Edit->setText(_pppdata->storedPassword());
// }
-// connect(ID_Edit, SIGNAL(textChanged(const QString &)),
-// this, SLOT(usernameChanged(const QString &)));
+// connect(ID_Edit, SIGNAL(textChanged(const QString&)),
+// this, SLOT(usernameChanged(const QString&)));
-// connect(PW_Edit, SIGNAL(textChanged(const QString &)),
-// this, SLOT(passwordChanged(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->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->pppdRunning() || _pppdata->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->setpppdRunning(false);
qDebug( "Executing command on disconnect since pppd has died." );
QApplication::flushX();
execute_command(_pppdata->command_on_disconnect());
// stopAccounting();
con_win->stopClock();
// DockWidget::dock_widget->stop_stats();
// DockWidget::dock_widget->hide();
if(!_pppdata->pppdError())
_pppdata->setpppdError(E_PPPD_DIED);
removedns();
Modem::modem->unlockdevice();
//
con->pppdDied();
if(!_pppdata->automatic_redial()) {
quit_b->setFocus();
show();
con_win->stopClock();
// stopAccounting();
con_win->hide();
con->hide();
_pppdata->setpppdRunning(false);
// // not in a signal handler !!! KNotifyClient::beep();
QString msg;
if (_pppdata->pppdError() == E_IF_TIMEOUT)
msg = QObject::tr("Timeout expired while waiting for the PPP interface "
"to come up!");
else {
msg = QObject::tr("<p>The pppd daemon died unexpectedly!</p>");
Modem::modem->pppdExitStatus();
if (Modem::modem->lastStatus != 99) { // more recent pppds only
msg += QObject::tr("<p>Exit status: %1").arg(Modem::modem->lastStatus);
msg += QObject::tr("</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, QObject::tr("Error"), QObject::tr("&OK"), QObject::tr("&Details...")) == QMessageBox::No)
// // PPPL_ShowLog();
// } else { /* reconnect on disconnect */
if (false){
qDebug( "Trying to reconnect... " );
if(_pppdata->authMethod() == AUTH_PAP ||
_pppdata->authMethod() == AUTH_CHAP ||
_pppdata->authMethod() == AUTH_PAPCHAP)
Modem::modem->setSecret(_pppdata->authMethod(),
encodeWord(_pppdata->storedUsername()),
encodeWord(_pppdata->password()));
con_win->hide();
con_win->stopClock();
// stopAccounting();
_pppdata->setpppdRunning(false);
// not in a signal handler !!! KNotifyClient::beep();
emit cmdl_start();
}
}
_pppdata->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 = QObject::tr("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->setDefaultAccount(connectto_c->text(i));
_pppdata->save();
ID_Edit->setText(_pppdata->storedUsername());
PW_Edit->setText(_pppdata->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->setAccount(connectto_c->currentText());
// _pppdata->setPassword(PW_Edit->text());
// } else {
_pppdata->setPassword(_pppdata->storedPassword());
// }
QFileInfo info(pppdPath());
if(!info.exists()){
QMessageBox::warning(this, "error", QObject::tr("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 = QObject::tr("kppp cannot execute:\n %1\n"
"Please make sure that you have given kppp "
"setuid permission and that "
"pppd is executable.").arg(_pppdata->pppdPath());
KMessageBox::error(this, string);
return;
}
#endif
QFileInfo info2(_pppdata->modemDevice());
if(!info2.exists()){
QString string;
string = QObject::tr("kppp can not find:\n %1\nPlease make sure you have setup "
"your modem device properly "
"and/or adjust the location of the modem device on "
"the modem tab of "
"the setup dialog.").arg(_pppdata->modemDevice());
QMessageBox::warning(this, "error", string);
return;
}
// if this is a PAP or CHAP account, ensure that username is
// supplied
if(_pppdata->authMethod() == AUTH_PAP ||
_pppdata->authMethod() == AUTH_CHAP ||
_pppdata->authMethod() == AUTH_PAPCHAP ) {
if(ID_Edit->text().isEmpty()) {
QMessageBox::warning(this,"error",
QObject::tr("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->authMethod(),
encodeWord(_pppdata->storedUsername()),
encodeWord(_pppdata->password()))) {
QString s;
s = QObject::tr("Cannot create PAP/CHAP authentication\n"
"file \"%1\"").arg(PAP_AUTH_FILE);
QMessageBox::warning(this, "error", s);
return;
}
}
}
if (_pppdata->phonenumber().isEmpty()) {
QString s = QObject::tr("You must specify a telephone number!");
QMessageBox::warning(this, "error", s);
return;
}
this->hide();
QString tit = QObject::tr("Connecting to: %1").arg(_pppdata->accname());
// con->setCaption(tit);
// con->show();
emit begin_connect();
}
void KPPPWidget::disconnect() {
if (!_pppdata->command_before_disconnect().isEmpty()) {
con_win->hide();
con->show();
con->setCaption(QObject::tr("Disconnecting..."));
con->setMsg(QObject::tr("Executing command before disconnection."));
qApp->processEvents();
QApplication::flushX();
// pid_t id =
execute_command(_pppdata->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->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->pppdRunning()) {
int ok = QMessageBox::warning(this,
QObject::tr("Exiting kPPP will close your PPP Session."),
QObject::tr("Quit kPPP?"));
if(ok == QMessageBox::Yes) {
Modem::modem->killPPPDaemon();
QApplication::flushX();
execute_command(_pppdata->command_on_disconnect());
removedns();
Modem::modem->unlockdevice();
}
} else {
if (!_pppdata->accname().isEmpty() && !_pppdata->storePassword())
_pppdata->setStoredPassword("");
}
_pppdata->save();
qApp->quit();
}
// void KPPPWidget::rulesetLoadError() {
// QMessageBox::warning(this,"error", ruleset_load_errmsg);
// }
// void KPPPWidget::startAccounting() {
// // volume accounting
// stats->totalbytes = 0;
// kdDebug() << "AcctEnabled: " << _pppdata->AcctEnabled() << endl;
// // load the ruleset
// if(!_pppdata->AcctEnabled())
// return;
// QString d = AccountingBase::getAccountingFile(_pppdata->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)));
+// connect(acct, SIGNAL(changed(QString,QString)),
+// con_win, SLOT(slotAccounting(QString,QString)));
// // if(!acct->loadRuleSet(_pppdata->accountingFile())) {
// // QString s= QObject::tr("Can not load the accounting "
// // "ruleset \"%1\"!").arg(_pppdata->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->setTotalBytes(stats->totalbytes);
// if(!_pppdata->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->setStoredUsername(ID_Edit->text());
}
void KPPPWidget::passwordChanged(const QString &) {
// store the password if so requested
if(_pppdata->storePassword())
_pppdata->setStoredPassword(PW_Edit->text());
else
_pppdata->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() {
#ifdef KPPP_SHOW_NEWS
/*
* Introduce the QuickHelp feature to new users of this version
*/
#define QUICKHELP_HINT "Hint_QuickHelp"
if(_pppdata->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) {
QDialog dlg(0, 0, true);
dlg.setCaption(QObject::tr("Recent Changes in KPPP"));
QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10);
QHBoxLayout *l1 = new QHBoxLayout(10);
QVBoxLayout *l2 = new QVBoxLayout(10);
tl->addLayout(l1);
QLabel *icon = new QLabel(&dlg);
icon->setPixmap(BarIcon("exclamation"));
icon->setFixedSize(icon->sizeHint());
l1->addWidget(icon);
l1->addLayout(l2);
QLabel *l = new QLabel(QObject::tr("From version 1.4.8 on, kppp has a new feature\n"
"called \"Quickhelp\". It's similar to a tooltip,\n"
"but you can activate it whenever you want.\n"
"\n"
"To activate it, simply click on a control like\n"
"a button or a label with the right mouse button.\n"
"If the item supports Quickhelp, a popup menu\n"
"will appear leading to Quickhelp.\n"
"\n"
"To test it, right-click somewhere in this text."),
&dlg);
QCheckBox *cb = new QCheckBox(QObject::tr("Don't show this hint again"), &dlg);
cb->setFixedSize(cb->sizeHint());
KButtonBox *bbox = new KButtonBox(&dlg);
bbox->addStretch(1);
QPushButton *ok = bbox->addButton(QObject::tr("OK"));
ok->setDefault(true);
dlg.connect(ok, SIGNAL(clicked()),
&dlg, SLOT(accept()));
bbox->addStretch(1);
bbox->layout();
l2->addWidget(l);
l2->addWidget(cb);
tl->addWidget(bbox);
QString tmp = QObject::tr("This is an example of <b>QuickHelp</b>.\n"
"This window will stay open until you\n"
"click a mouse button or a press a key.\n");
QWhatsThis::add(cb,tmp);
QWhatsThis::add(l, tmp);
dlg.exec();
if(cb->isChecked()) {
_pppdata->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1);
_pppdata->save();
}
}
#endif
}
//#include "kpppwidget.moc"
diff --git a/noncore/settings/networksettings/ppp/pppdargs.cpp b/noncore/settings/networksettings/ppp/pppdargs.cpp
index 66a4d82..d6d8d88 100644
--- a/noncore/settings/networksettings/ppp/pppdargs.cpp
+++ b/noncore/settings/networksettings/ppp/pppdargs.cpp
@@ -1,151 +1,151 @@
/*
* 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 library 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 library 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 <qlayout.h>
#include <qbuttongroup.h>
#include <qapplication.h>
#include "pppdargs.h"
#include "pppdata.h"
PPPdArguments::PPPdArguments( PPPData *pd, QWidget *parent, const char *name)
: QDialog(parent, name, TRUE), _pppdata(pd)
{
setCaption(tr("Customize pppd Arguments"));
// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
QVBoxLayout *l = new QVBoxLayout(this, 10, 10);
QHBoxLayout *tl = new QHBoxLayout(10);
l->addLayout(tl);
QVBoxLayout *l1 = new QVBoxLayout();
QVBoxLayout *l2 = new QVBoxLayout();
tl->addLayout(l1, 1);
tl->addLayout(l2, 0);
QHBoxLayout *l11 = new QHBoxLayout(10);
l1->addLayout(l11);
argument_label = new QLabel(tr("Argument:"), this);
l11->addWidget(argument_label);
argument = new QLineEdit(this);
connect(argument, SIGNAL(returnPressed()),
SLOT(addbutton()));
l11->addWidget(argument);
- connect(argument, SIGNAL(textChanged(const QString &)),
- this, SLOT(textChanged(const QString &)));
+ connect(argument, SIGNAL(textChanged(const QString&)),
+ this, SLOT(textChanged(const QString&)));
arguments = new QListBox(this);
arguments->setMinimumSize(1, fontMetrics().lineSpacing()*10);
connect(arguments, SIGNAL(highlighted(int)),
this, SLOT(itemSelected(int)));
l1->addWidget(arguments, 1);
add = new QPushButton(tr("Add"), this);
connect(add, SIGNAL(clicked()), SLOT(addbutton()));
l2->addWidget(add);
l2->addStretch(1);
remove = new QPushButton(tr("Remove"), this);
connect(remove, SIGNAL(clicked()), SLOT(removebutton()));
l2->addWidget(remove);
defaults = new QPushButton(tr("Defaults"), this);
connect(defaults, SIGNAL(clicked()), SLOT(defaultsbutton()));
l2->addWidget(defaults);
l->addSpacing(5);
//load info from gpppdata
init();
add->setEnabled(false);
remove->setEnabled(false);
argument->setFocus();
}
void PPPdArguments::addbutton() {
if(!argument->text().isEmpty() && arguments->count() < MAX_PPPD_ARGUMENTS) {
arguments->insertItem(argument->text());
argument->setText("");
}
}
void PPPdArguments::removebutton() {
if(arguments->currentItem() >= 0)
arguments->removeItem(arguments->currentItem());
}
void PPPdArguments::defaultsbutton() {
// all of this is a hack
// save current list
QStringList arglist(_pppdata->pppdArgument());
// get defaults
_pppdata->setpppdArgumentDefaults();
init();
// restore old list
_pppdata->setpppdArgument(arglist);
}
void PPPdArguments::accept() {
QStringList arglist;
for(uint i=0; i < arguments->count(); i++)
arglist.append(arguments->text(i));
_pppdata->setpppdArgument(arglist);
QDialog::accept();
}
void PPPdArguments::init() {
while(arguments->count())
arguments->removeItem(0);
QStringList &arglist = _pppdata->pppdArgument();
for ( QStringList::Iterator it = arglist.begin();
it != arglist.end();
++it )
arguments->insertItem(*it);
}
void PPPdArguments::textChanged(const QString &s) {
add->setEnabled(s.length() > 0);
}
void PPPdArguments::itemSelected(int idx) {
remove->setEnabled(idx != -1);
}
diff --git a/noncore/settings/networksettings/wlan/wlanimp2.cpp b/noncore/settings/networksettings/wlan/wlanimp2.cpp
index 92339d6..dd1db28 100644
--- a/noncore/settings/networksettings/wlan/wlanimp2.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp2.cpp
@@ -1,249 +1,249 @@
#include "wlanimp2.h"
#include "keyedit.h"
#include "interfacesetupimp.h"
#include "../interfaces/interface.h"
#include <assert.h>
#include <errno.h>
#include <string.h>
#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
#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.
*/
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()) {
qWarning(QString("WLANImp: Unable to open /etc/network/if-pre-up.d/wireless-tools"));
}
connect( rescanButton, SIGNAL( clicked() ), this, SLOT( rescanNeighbourhood() ) );
- connect( netView, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( selectNetwork( QListViewItem* ) ) );
+ 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);
break;
case 2:
keyLineEdit1->setText(key);
break;
case 3:
keyLineEdit2->setText(key);
break;
case 4:
keyLineEdit3->setText(key);
break;
}
key = QString::null;
}
}
if (enc == 1) {
wepEnabled->setChecked(true);
} else {
wepEnabled->setChecked(false);
}
}
/**
* Check to see if the current config is valid
* Save interfaces
*/
void WLANImp::accept() {
if (wepEnabled->isChecked()) {
if ((keyRadio0->isChecked() && keyLineEdit0->text().isEmpty()) ||
(keyRadio1->isChecked() && keyLineEdit1->text().isEmpty()) ||
(keyRadio2->isChecked() && keyLineEdit2->text().isEmpty()) ||
(keyRadio3->isChecked() && keyLineEdit3->text().isEmpty())) {
QMessageBox::information(this, "Error", "Please enter a WEP key.", QMessageBox::Ok);
return;
}
}
if (essid->currentText().isEmpty()) {
QMessageBox::information(this, "Error", "Please select/enter an ESSID.", QMessageBox::Ok);
return;
}
if (specifyAp->isChecked() && macEdit->text().isEmpty()) {
QMessageBox::information(this, "Error", "Please enter the MAC address of the Access Point.", QMessageBox::Ok);
return;
}
// Try to save the interfaces settings.
writeOpts();
// Close out the dialog
// FIXME: QDialog::accept();
}
void WLANImp::writeOpts() {
// eh can't really do anything about it other then return. :-D
if(!interfaces->isInterfaceSet()){
QMessageBox::warning(0,"Inface not set","should not happen!!!");
return;
}
bool error = false;
qDebug("setting wlan interface %s", interfaces->getInterfaceName( error ).latin1() );
if (error) QMessageBox::warning(0,"Inface not set","should not happen!!!");
interfaces->setInterfaceOption(QString("wireless_mode"), mode->currentText());
interfaces->setInterfaceOption(QString("wireless_essid"), essid->currentText());
if (specifyAp->isChecked()) {
interfaces->setInterfaceOption(QString("wireless_ap"), macEdit->text());
} else {
interfaces->removeInterfaceOption(QString("wireless_ap"));
}
if (specifyChan->isChecked()) {
interfaces->setInterfaceOption(QString("wireless_channel"), networkChannel->text());
} else {