summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.cpp114
-rw-r--r--noncore/settings/networksettings/interfaces/interfacesetupimp.cpp2
-rw-r--r--noncore/settings/networksettings/wlan/wlanmodule.cpp36
3 files changed, 92 insertions, 60 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp
index a62a90c..71d0cf5 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaces.cpp
@@ -8,21 +8,21 @@
#define AUTO "auto"
#define IFACE "iface"
#define MAPPING "mapping"
/**
* Constructor. Reads in the interfaces file and then split the file up by
- * the \n for interfaces variable.
+ * the \n for interfaces variable.
* @param useInterfacesFile if an interface file other then the default is
* desired to be used it should be passed in.
- */
+ */
Interfaces::Interfaces(QString useInterfacesFile){
acceptedFamily.append(INTERFACES_FAMILY_INET);
acceptedFamily.append(INTERFACES_FAMILY_IPX);
acceptedFamily.append(INTERFACES_FAMILY_INET6);
-
+
interfacesFile = useInterfacesFile;
QFile file(interfacesFile);
if (!file.open(IO_ReadOnly)){
qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() );
currentIface = interfaces.end();
currentMapping = interfaces.end();
@@ -33,24 +33,24 @@ Interfaces::Interfaces(QString useInterfacesFile){
while ( !stream.eof() ) {
line += stream.readLine();
line += "\n";
}
file.close();
interfaces = QStringList::split("\n", line, true);
-
+
currentIface = interfaces.end();
currentMapping = interfaces.end();
}
/**
* Get a list of all interfaces in the interface file. Usefull for
- * hardware that is not currently connected such as an 802.11b card
+ * hardware that is not currently connected such as an 802.11b card
* not plugged in, but configured for when it is plugged in.
* @return Return string list of interfaces.
- **/
+ **/
QStringList Interfaces::getInterfaceList(){
QStringList list;
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
if(line.contains(IFACE) && line.at(0) != '#'){
line = line.mid(QString(IFACE).length() +1, line.length());
@@ -64,16 +64,16 @@ QStringList Interfaces::getInterfaceList(){
}
return list;
}
/**
* Find out if interface is in an "auto" group or not.
- * Report any duplicates such as eth0 being in two differnt auto's
+ * Report any duplicates such as eth0 being in two differnt auto's
* @param interface interface to check to see if it is on or not.
* @return true is interface is in auto
- */
+ */
bool Interfaces::isAuto(const QString &interface) const {
QStringList autoLines = interfaces.grep(QRegExp(AUTO));
QStringList awi = autoLines.grep(QRegExp(interface));
if(awi.count() > 1)
qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
return awi.count() > 0;
@@ -81,18 +81,18 @@ bool Interfaces::isAuto(const QString &interface) const {
/**
* Attempt to set the auto option for interface to setAuto.
* @param interface the interface to set
* @param setAuto the value to set interface to.
* @return false if already set to setAuto.
- * */
+ * */
bool Interfaces::setAuto(const QString &interface, bool setAuto){
// Don't need to set it if it is already set.
if(isAuto(interface) == setAuto)
return false;
-
+
bool changed = false;
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
if((*it).contains(AUTO)){
//We know that they are not in any group so let add to this auto.
if(setAuto){
(*it) = (*it) += " " + interface;
@@ -122,37 +122,37 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){
/**
* Set the current interface to interface. This needs to be done before you
* can call getFamily(), getMethod, and get/setOption().
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
- * @return bool true if it is successfull.
- */
+ * @return bool true if it is successfull.
+ */
bool Interfaces::setInterface(QString interface){
interface = interface.simplifyWhiteSpace();
interface = interface.replace(QRegExp(" "), "");
return setStanza(IFACE, interface, currentIface);
}
/**
* A quick helper funtion to see if the current interface is set.
* @return bool true if set, false otherwise.
- */
+ */
bool Interfaces::isInterfaceSet() const {
return (interfaces.end() != currentIface);
}
/**
* Add a new interface of with the settings - family and method
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
* @param family the family of this interface inet or inet, ipx or inet6
* Must of one of the families defined in interfaces.h
* @param method for the family. see interfaces man page for family methods.
* @return true if successfull.
- */
+ */
bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
if(0 == acceptedFamily.contains(family))
return false;
QString newInterface = interface.simplifyWhiteSpace();
newInterface = newInterface.replace(QRegExp(" "), "");
interfaces.append("");
@@ -161,53 +161,53 @@ bool Interfaces::addInterface(const QString &interface, const QString &family, c
}
/**
* Copies interface with name interface to name newInterface
* @param newInterface name of the new interface.
* @return bool true if successfull
- */
+ */
bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
if(!setInterface(interface))
return false;
// Store the old interface and bump past the stanza line.
QStringList::Iterator it = currentIface;
it++;
-
+
// Add the new interface
bool error;
addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
if(!setInterface(newInterface))
return false;
-
+
QStringList::Iterator newIface = currentIface;
newIface++;
-
+
// Copy all of the lines
for ( ; it != interfaces.end(); ++it ){
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
break;
newIface = interfaces.insert(newIface, *it);
}
-
+
return true;
}
/**
* Remove the currently selected interface and all of its options.
* @return bool if successfull or not.
- */
+ */
bool Interfaces::removeInterface(){
return removeStanza(currentIface);
}
/**
* Gets the hardware name of the interface that is currently selected.
* @return QString name of the hardware interface (eth0, usb2, wlan1...).
* @param error set to true if any error occurs, false otherwise.
- */
+ */
QString Interfaces::getInterfaceName(bool &error){
if(currentIface == interfaces.end()){
error = true;
return QString();
}
QString line = (*currentIface);
@@ -223,13 +223,13 @@ QString Interfaces::getInterfaceName(bool &error){
}
/**
* Gets the family name of the interface that is currently selected.
* @return QString name of the family (inet, inet6, ipx).
* @param error set to true if any error occurs, false otherwise.
- */
+ */
QString Interfaces::getInterfaceFamily(bool &error){
QString name = getInterfaceName(error);
if(error)
return QString();
QString line = (*currentIface);
line = line.mid(QString(IFACE).length() +1, line.length());
@@ -246,13 +246,13 @@ QString Interfaces::getInterfaceFamily(bool &error){
/**
* Gets the method of the interface that is currently selected.
* @return QString name of the method such as staic or dhcp.
* See the man page of interfaces for possible methods depending on the family.
* @param error set to true if any error occurs, false otherwise.
- */
+ */
QString Interfaces::getInterfaceMethod(bool &error){
QString name = getInterfaceName(error);
if(error)
return QString();
QString family = getInterfaceFamily(error);
if(error)
@@ -264,197 +264,197 @@ QString Interfaces::getInterfaceMethod(bool &error){
line = line.simplifyWhiteSpace();
error = false;
return line;
}
/**
- * Sets the interface name to newName.
+ * Sets the interface name to newName.
* @param newName the new name of the interface. All whitespace is removed.
* @return bool true if successfull.
- */
+ */
bool Interfaces::setInterfaceName(const QString &newName){
if(currentIface == interfaces.end())
return false;
QString name = newName.simplifyWhiteSpace();
name = name.replace(QRegExp(" "), "");
bool returnValue = false;
(*currentIface) = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
- return !returnValue;
+ return !returnValue;
}
/**
- * Sets the interface family to newName.
+ * Sets the interface family to newName.
* @param newName the new name of the interface. Must be one of the families
* defined in the interfaces.h file.
* @return bool true if successfull.
- */
+ */
bool Interfaces::setInterfaceFamily(const QString &newName){
if(currentIface == interfaces.end())
return false;
if(acceptedFamily.contains(newName)==0)
return false;
bool returnValue = false;
(*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
- return !returnValue;
+ return !returnValue;
}
/**
* Sets the interface method to newName
* @param newName the new name of the interface
* @return bool true if successfull.
- */
+ */
bool Interfaces::setInterfaceMethod(const QString &newName){
if(currentIface == interfaces.end())
return false;
bool returnValue = false;
(*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
- return !returnValue;
+ return !returnValue;
}
/**
* Get a value for an option in the currently selected interface. For example
* calling getInterfaceOption("address") on the following stanza would
* return 192.168.1.1.
* iface eth0 static
* address 192.168.1.1
* @param option the options to get the value.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
- */
+ */
QString Interfaces::getInterfaceOption(const QString &option, bool &error){
return getOption(currentIface, option, error);
}
/**
* Set a value for an option in the currently selected interface. If option
* doesn't exist then it is added along with the value.
* @param option the options to set the value.
* @param value the value that option should be set to.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
- */
+ */
bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
return setOption(currentIface, option, value);
}
/**
- * Removes a value for an option in the currently selected interface.
+ * Removes a value for an option in the currently selected interface.
* @param option the options to set the value.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
- */
+ */
bool Interfaces::removeInterfaceOption(const QString &option){
return removeOption(currentIface, option);
}
/**
- * Removes a value for an option in the currently selected interface.
+ * Removes a value for an option in the currently selected interface.
* @param option the options to set the value.
* @param value the value that option should be set to.
* @param error set to true if any error occurs, false otherwise.
* @return QString the options value. QString::null if error == true
- */
+ */
bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
return removeOption(currentIface, option, value);
}
/**
* Removes all of the options from the currently selected interface.
- * @return bool error if if successfull
- */
+ * @return bool error if if successfull
+ */
bool Interfaces::removeAllInterfaceOptions(){
return removeAllOptions(currentIface);
}
/**
* Set the current map to interface's map. This needs to be done before you
* can call addMapping(), set/getMap(), and get/setScript().
* @param interface the name of the interface to set. All whitespace is
* removed from the interface name.
- * @return bool true if it is successfull.
- */
+ * @return bool true if it is successfull.
+ */
bool Interfaces::setMapping(const QString &interface){
QString interfaceName = interface.simplifyWhiteSpace();
interfaceName = interfaceName.replace(QRegExp(" "), "");
return setStanza(MAPPING, interfaceName, currentMapping);
}
/**
* Adds a new Mapping to the interfaces file with interfaces.
* @param interface the name(s) of the interfaces to set to this mapping
- */
+ */
void Interfaces::addMapping(const QString &option){
interfaces.append("");
interfaces.append(QString(MAPPING " %1").arg(option));
}
/**
* Remove the currently selected map and all of its options.
* @return bool if successfull or not.
*/
bool Interfaces::removeMapping(){
return removeStanza(currentMapping);
-}
+}
/**
* Set a map option within a mapping.
* @param map map to use
* @param value value to go with map
* @return bool true if it is successfull.
- */
+ */
bool Interfaces::setMap(const QString &map, const QString &value){
return setOption(currentMapping, map, value);
}
/**
* Removes a map option within a mapping.
* @param map map to use
* @param value value to go with map
* @return bool true if it is successfull.
- */
+ */
bool Interfaces::removeMap(const QString &map, const QString &value){
return removeOption(currentMapping, map, value);
}
/**
* Get a map value within a mapping.
* @param map map to get value of
* @param bool true if it is successfull.
* @return value that goes to the map
- */
+ */
QString Interfaces::getMap(const QString &map, bool &error){
return getOption(currentMapping, map, error);
}
/**
* Sets a script value of the current mapping to argument.
* @param argument the script name.
* @return true if successfull.
- */
+ */
bool Interfaces::setScript(const QString &argument){
return setOption(currentMapping, "script", argument);
}
/**
* @param error true if could not retrieve the current script argument.
* @return QString the argument of the script for the current mapping.
- */
+ */
QString Interfaces::getScript(bool &error){
return getOption(currentMapping, "script", error);
}
/**
- * Helper function used to parse through the QStringList and put pointers in
+ * Helper function used to parse through the QStringList and put pointers in
* the correct place.
* @param stanza The stanza (auto, iface, mapping) to look for.
* @param option string that must be in the stanza's main line.
* @param interator interator to place at location of stanza if successfull.
* @return bool true if the stanza is found.
- */
+ */
bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){
bool found = false;
iterator = interfaces.end();
for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
QString line = (*it).simplifyWhiteSpace();
if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
@@ -489,13 +489,13 @@ bool Interfaces::setStanza(const QString &stanza, const QString &option, QString
* @param option the option to use when setting value.
* @return bool true if successfull, false otherwise.
*/
bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
if(start == interfaces.end())
return false;
-
+
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
if(!found && value != ""){
// Got to the end of the stanza without finding it, so append it.
interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
@@ -520,13 +520,13 @@ bool Interfaces::setOption(const QStringList::Iterator &start, const QString &op
}
/**
* Removes a stanza and all of its options
* @param stanza the stanza to remove
* @return bool true if successfull.
- */
+ */
bool Interfaces::removeStanza(QStringList::Iterator &stanza){
if(stanza == interfaces.end())
return false;
(*stanza) = "";
return removeAllOptions(stanza);
}
@@ -537,13 +537,13 @@ bool Interfaces::removeStanza(QStringList::Iterator &stanza){
* @param option the option to remove
* @return bool true if successfull, false otherwise.
*/
bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){
if(start == interfaces.end())
return false;
-
+
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
// got to the end without finding it
break;
}
@@ -564,13 +564,13 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString
* @param option the option to use when setting value.
* @return bool true if successfull, false otherwise.
*/
bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){
if(start == interfaces.end())
return false;
-
+
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
// got to the end without finding it
break;
}
@@ -590,13 +590,13 @@ bool Interfaces::removeOption(const QStringList::Iterator &start, const QString
* @param start the start of the stanza
* @return bool true if successfull, false otherwise.
*/
bool Interfaces::removeAllOptions(const QStringList::Iterator &start){
if(start == interfaces.end())
return false;
-
+
QStringList::Iterator it = start;
it = ++it;
for (; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
break;
}
@@ -617,13 +617,13 @@ bool Interfaces::removeAllOptions(const QStringList::Iterator &start){
*/
QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){
if(start == interfaces.end()){
error = false;
return QString();
}
-
+
QString value;
bool found = false;
for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
break;
}
@@ -644,13 +644,13 @@ QString Interfaces::getOption(const QStringList::Iterator &start, const QString
}
/**
* Write out the interfaces file to the file passed into the constructor.
* Removes any excess blank lines over 1 line long.
* @return bool true if successfull, false if not.
- */
+ */
bool Interfaces::write(){
QFile::remove(interfacesFile);
QFile file(interfacesFile);
if (!file.open(IO_ReadWrite)){
qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1());
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
index f19cbdd..b40d101 100644
--- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp
@@ -184,12 +184,14 @@ void InterfaceSetupImp::setProfile(const QString &profile){
firstDNSLineEdit->setText(dns.mid(0, dns.find(" ")));
secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length()));
}else firstDNSLineEdit->setText(dns);
ipAddressEdit->setText(interfaces->getInterfaceOption("address", error));
subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error));
+ if (subnetMaskEdit->text().isEmpty())
+ subnetMaskEdit->setText( "255.255.255.0" );
gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error));
qWarning("InterfaceSetupImp::setProfile(%s)\n", profile.latin1());
qWarning("InterfaceSetupImp::setProfile: iface is %s\n", interfaces->getInterfaceName(error).latin1());
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp
index 7bded85..a4488f9 100644
--- a/noncore/settings/networksettings/wlan/wlanmodule.cpp
+++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp
@@ -129,15 +129,32 @@ void WLANModule::receive(const QCString &param, const QByteArray &arg)
return;
}
QDataStream stream(arg,IO_ReadOnly);
QString interface;
QString action;
+ int countMsgs = 0;
+ stream >> interface;
+ qDebug("got count? >%s<",interface.latin1());
+ if (interface == "count"){
+ qDebug("got count");
+ stream >> action;
+ qDebug("Got count num >%s<", action.latin1());
+ countMsgs = action.toInt();
+ }
+
QDialog *toShow;
- while (! stream.atEnd() ){
+ //while (! stream.atEnd() ){
+ for (int i = 0; i < countMsgs; i++){
+ qDebug("start stream %d/%d",i,countMsgs);
+ if (stream.atEnd()){
+ qDebug("end of stream");
+ return;
+ }
stream >> interface;
+ qDebug("got iface");
stream >> action;
qDebug("WLANModule got interface %s and acion %s", interface.latin1(), action.latin1());
// find interfaces
Interface *ifa=0;
for ( Interface *i=list.first(); i != 0; i=list.next() ){
if (i->getInterfaceName() == interface){
@@ -172,13 +189,17 @@ void WLANModule::receive(const QCString &param, const QByteArray &arg)
//FIXME: what if it got closed meanwhile?
wlanconfigWiget = (WLANImp*) configure(ifa);
toShow = (QDialog*) wlanconfigWiget;
}
wlanconfigWiget->showMaximized();
stream >> value;
- qDebug("WLANModule is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() );
+ qDebug("WLANModule (build 4) is setting %s of %s to %s", action.latin1(), interface.latin1(), value.latin1() );
+ if (value.isEmpty()){
+ qDebug("value is empty!!!\nreturning");
+ return;
+ }
if ( action.contains("ESSID") ){
QComboBox *combo = wlanconfigWiget->essid;
bool found = false;
for ( int i = 0; i < combo->count(); i++)
if ( combo->text( i ) == value ){
combo->setCurrentItem( i );
@@ -191,32 +212,41 @@ void WLANModule::receive(const QCString &param, const QByteArray &arg)
if ( combo->text( i ) == value ){
combo->setCurrentItem( i );
}
}else if (action.contains("Channel")){
bool ok;
+ qDebug("converting channel");
int chan = value.toInt( &ok );
if (ok){
+ qDebug("ok setting channel");
wlanconfigWiget->specifyChan->setChecked( true );
wlanconfigWiget->networkChannel->setValue( chan );
}
}else if (action.contains("MacAddr")){
wlanconfigWiget->specifyAp->setChecked( true );
wlanconfigWiget->macEdit->setText( value );
}else
qDebug("wlan plugin has no clue");
}
+ qDebug("next stream");
}// while stream
+ qDebug("end of stream");
if (toShow) toShow->exec();
+ qDebug("returning");
}
QWidget *WLANModule::getInfo( Interface *i)
{
qDebug("WLANModule::getInfo start");
WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose);
InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i);
info->tabWidget->insertTab(information, "TCP/IP", 0);
-
+ info->tabWidget->setCurrentPage( 0 );
+ info->tabWidget->showPage( information );
+ if (info->tabWidget->currentPage() == information ) qDebug("infotab OK");
+ else qDebug("infotab NOT OK");
+ qDebug("current idx %d", info->tabWidget->currentPageIndex());
qDebug("WLANModule::getInfo return");
return info;
}