author | benmeyer <benmeyer> | 2002-10-22 21:04:58 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-22 21:04:58 (UTC) |
commit | c306ba7e1c73ec200b1621d224fc77f45e798e13 (patch) (unidiff) | |
tree | 1eb110c64b99c2e6ea2f8ab44c053f1e65f320f3 /noncore | |
parent | 1e1b3e398d6b978a9c2bbd85d8f6b7aafbf72b2f (diff) | |
download | opie-c306ba7e1c73ec200b1621d224fc77f45e798e13.zip opie-c306ba7e1c73ec200b1621d224fc77f45e798e13.tar.gz opie-c306ba7e1c73ec200b1621d224fc77f45e798e13.tar.bz2 |
Fix segfault
-rw-r--r-- | noncore/net/networksetup/TODO | 6 | ||||
-rw-r--r-- | noncore/net/networksetup/interface.cpp | 4 | ||||
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 2 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wextensions.cpp | 2 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanimp.cpp | 2 | ||||
-rw-r--r-- | noncore/net/networksetup/wlan/wlanmodule.cpp | 20 | ||||
-rw-r--r-- | noncore/settings/networksettings/TODO | 6 | ||||
-rw-r--r-- | noncore/settings/networksettings/interface.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wextensions.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanimp.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/wlan/wlanmodule.cpp | 20 |
12 files changed, 36 insertions, 36 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO index 7a71142..d61c510 100644 --- a/noncore/net/networksetup/TODO +++ b/noncore/net/networksetup/TODO | |||
@@ -1,11 +1,9 @@ | |||
1 | WLAN needs to be re-written to not use Config | 1 | WLAN needs to be re-written to not use Config |
2 | -remove WLAN Config item | 2 | WHERE Is DHCP info stored??? |
3 | -sub class out the wlan info | ||
4 | -check if an interface supports wireless extensions before config. | ||
5 | 3 | ||
6 | PPP module needs to be written | 4 | PPP module needs to be written |
7 | 5 | ||
8 | Write a class that parses /proc and not ifconfig | 6 | Write a class that parses /proc and not ifconfig |
9 | 7 | ||
10 | Possible other modules: ipsec, bluetooth | 8 | Possible other modules: ipsec, bluetooth, ipchains |
11 | 9 | ||
diff --git a/noncore/net/networksetup/interface.cpp b/noncore/net/networksetup/interface.cpp index a84b91f..929b3a1 100644 --- a/noncore/net/networksetup/interface.cpp +++ b/noncore/net/networksetup/interface.cpp | |||
@@ -1,21 +1,21 @@ | |||
1 | #include "interface.h" | 1 | #include "interface.h" |
2 | #include <qdatetime.h> | 2 | #include <qdatetime.h> |
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | #include <qfileinfo.h> | 5 | #include <qfileinfo.h> |
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | 7 | ||
8 | #define IFCONFIG "/sbin/ifconfig" | 8 | #define IFCONFIG "/sbin/ifconfig" |
9 | #define HDCP_INFO_DIR "/etc/dhcpc" | 9 | #define DHCP_INFO_DIR "/etc/dhcpc" |
10 | 10 | ||
11 | #include <stdio.h> | 11 | #include <stdio.h> |
12 | #include <stdlib.h> | 12 | #include <stdlib.h> |
13 | 13 | ||
14 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ | 14 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ |
15 | refresh(); | 15 | refresh(); |
16 | } | 16 | } |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Set status | 19 | * Set status |
20 | * @param newStatus - the new status | 20 | * @param newStatus - the new status |
21 | * emit updateInterface | 21 | * emit updateInterface |
@@ -162,25 +162,25 @@ bool Interface::refresh(){ | |||
162 | } | 162 | } |
163 | } | 163 | } |
164 | file.close(); | 164 | file.close(); |
165 | QFile::remove(fileName); | 165 | QFile::remove(fileName); |
166 | 166 | ||
167 | // DHCP TESTING | 167 | // DHCP TESTING |
168 | // reset DHCP info | 168 | // reset DHCP info |
169 | dhcpServerIp = ""; | 169 | dhcpServerIp = ""; |
170 | leaseObtained = ""; | 170 | leaseObtained = ""; |
171 | leaseExpires = ""; | 171 | leaseExpires = ""; |
172 | dhcp = false; | 172 | dhcp = false; |
173 | 173 | ||
174 | QString dhcpDirectory(HDCP_INFO_DIR); | 174 | QString dhcpDirectory(DHCP_INFO_DIR); |
175 | QDir d(dhcpDirectory); | 175 | QDir d(dhcpDirectory); |
176 | if(!d.exists(dhcpDirectory)) | 176 | if(!d.exists(dhcpDirectory)) |
177 | dhcpDirectory = "/var/run"; | 177 | dhcpDirectory = "/var/run"; |
178 | 178 | ||
179 | // See if we have | 179 | // See if we have |
180 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); | 180 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); |
181 | // If there is no DHCP information then exit now with no errors. | 181 | // If there is no DHCP information then exit now with no errors. |
182 | if(!QFile::exists(dhcpFile)){ | 182 | if(!QFile::exists(dhcpFile)){ |
183 | emit(updateInterface(this)); | 183 | emit(updateInterface(this)); |
184 | return true; | 184 | return true; |
185 | } | 185 | } |
186 | 186 | ||
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 9d81ab1..c86acdc 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp | |||
@@ -69,42 +69,44 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par | |||
69 | currentProfileLabel->setText(line); | 69 | currentProfileLabel->setText(line); |
70 | break; | 70 | break; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | file.close(); | 73 | file.close(); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Deconstructor. Save profiles. Delete loaded libraries. | 78 | * Deconstructor. Save profiles. Delete loaded libraries. |
79 | */ | 79 | */ |
80 | MainWindowImp::~MainWindowImp(){ | 80 | MainWindowImp::~MainWindowImp(){ |
81 | qDebug("start Saving mainwindow"); | ||
81 | // Save profiles. | 82 | // Save profiles. |
82 | Config cfg("NetworkSetup"); | 83 | Config cfg("NetworkSetup"); |
83 | cfg.setGroup("General"); | 84 | cfg.setGroup("General"); |
84 | cfg.writeEntry("Profiles", profiles.join(" ")); | 85 | cfg.writeEntry("Profiles", profiles.join(" ")); |
85 | 86 | ||
86 | // Delete all interfaces that don't have owners. | 87 | // Delete all interfaces that don't have owners. |
87 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 88 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
88 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 89 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
89 | if(iIt.key()->getModuleOwner() == NULL) | 90 | if(iIt.key()->getModuleOwner() == NULL) |
90 | delete iIt.key(); | 91 | delete iIt.key(); |
91 | } | 92 | } |
92 | 93 | ||
93 | // Delete Modules and Libraries | 94 | // Delete Modules and Libraries |
94 | QMap<Module*, QLibrary*>::Iterator it; | 95 | QMap<Module*, QLibrary*>::Iterator it; |
95 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 96 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
96 | delete it.key(); | 97 | delete it.key(); |
97 | delete it.data(); | 98 | delete it.data(); |
98 | } | 99 | } |
100 | qDebug("done Saving mainwindow"); | ||
99 | } | 101 | } |
100 | 102 | ||
101 | /** | 103 | /** |
102 | * Load all modules that are found in the path | 104 | * Load all modules that are found in the path |
103 | * @param path a directory that is scaned for any plugins that can be loaded | 105 | * @param path a directory that is scaned for any plugins that can be loaded |
104 | * and attempts to load them | 106 | * and attempts to load them |
105 | */ | 107 | */ |
106 | void MainWindowImp::loadModules(QString path){ | 108 | void MainWindowImp::loadModules(QString path){ |
107 | //qDebug(path.latin1()); | 109 | //qDebug(path.latin1()); |
108 | QDir d(path); | 110 | QDir d(path); |
109 | if(!d.exists()) | 111 | if(!d.exists()) |
110 | return; | 112 | return; |
diff --git a/noncore/net/networksetup/wlan/wextensions.cpp b/noncore/net/networksetup/wlan/wextensions.cpp index ef4ba8f..e545bd1 100644 --- a/noncore/net/networksetup/wlan/wextensions.cpp +++ b/noncore/net/networksetup/wlan/wextensions.cpp | |||
@@ -148,25 +148,25 @@ bool WExtensions::stats(int &signal, int &noise, int &quality){ | |||
148 | QTextStream wstream( &wfile ); | 148 | QTextStream wstream( &wfile ); |
149 | wstream.readLine(); // skip the first two lines | 149 | wstream.readLine(); // skip the first two lines |
150 | wstream.readLine(); // because they only contain headers | 150 | wstream.readLine(); // because they only contain headers |
151 | while(!wstream.atEnd()){ | 151 | while(!wstream.atEnd()){ |
152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
153 | if(name == QString("%1:").arg(interface)){ | 153 | if(name == QString("%1:").arg(interface)){ |
154 | if ( quality > 92 ) | 154 | if ( quality > 92 ) |
155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
160 | qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); | 160 | //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); |
161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; | 161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; |
162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; | 162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; |
163 | quality = ( quality*100 ) / 92; | 163 | quality = ( quality*100 ) / 92; |
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | qDebug("WExtensions::statsCard no longer present."); | 168 | qDebug("WExtensions::statsCard no longer present."); |
169 | quality = -1; | 169 | quality = -1; |
170 | signal = IW_LOWER; | 170 | signal = IW_LOWER; |
171 | noise = IW_LOWER; | 171 | noise = IW_LOWER; |
172 | return false; | 172 | return false; |
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index ea19207..94c7518 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp | |||
@@ -7,25 +7,25 @@ | |||
7 | /* system() */ | 7 | /* system() */ |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qdir.h> | 10 | #include <qdir.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
15 | #include <qradiobutton.h> | 15 | #include <qradiobutton.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qregexp.h> | 17 | #include <qregexp.h> |
18 | 18 | ||
19 | WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name){ | 19 | WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name, Qt::WDestructiveClose){ |
20 | config = new Config("wireless"); | 20 | config = new Config("wireless"); |
21 | readConfig(); | 21 | readConfig(); |
22 | } | 22 | } |
23 | 23 | ||
24 | WLANImp::~WLANImp( ){ | 24 | WLANImp::~WLANImp( ){ |
25 | delete config; | 25 | delete config; |
26 | } | 26 | } |
27 | 27 | ||
28 | void WLANImp::readConfig() | 28 | void WLANImp::readConfig() |
29 | { | 29 | { |
30 | qWarning( "WLANImp::readConfig() called." ); | 30 | qWarning( "WLANImp::readConfig() called." ); |
31 | config->setGroup( "Properties" ); | 31 | config->setGroup( "Properties" ); |
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp index 73e753c..7507c54 100644 --- a/noncore/net/networksetup/wlan/wlanmodule.cpp +++ b/noncore/net/networksetup/wlan/wlanmodule.cpp | |||
@@ -1,33 +1,32 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include "wlanimp.h" | 2 | #include "wlanimp.h" |
3 | #include "info.h" | 3 | #include "info.h" |
4 | #include "wextensions.h" | 4 | #include "wextensions.h" |
5 | 5 | ||
6 | #include <qlabel.h> | 6 | #include <qlabel.h> |
7 | #include <qprogressbar.h> | 7 | #include <qprogressbar.h> |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Constructor, find all of the possible interfaces | 10 | * Constructor, find all of the possible interfaces |
11 | */ | 11 | */ |
12 | WLANModule::WLANModule() : Module() { | 12 | WLANModule::WLANModule() : Module() { |
13 | // get output from iwconfig | ||
14 | } | 13 | } |
15 | 14 | ||
16 | /** | 15 | /** |
17 | */ | 16 | */ |
18 | WLANModule::~WLANModule(){ | 17 | WLANModule::~WLANModule(){ |
19 | Interface *i; | 18 | Interface *i; |
20 | for ( i=list.first(); i != 0; i=list.next() ) | 19 | for ( i=list.first(); i != 0; i=list.next() ) |
21 | delete i; | 20 | delete i; |
22 | } | 21 | } |
23 | 22 | ||
24 | /** | 23 | /** |
25 | * Change the current profile | 24 | * Change the current profile |
26 | */ | 25 | */ |
27 | void WLANModule::setProfile(QString newProfile){ | 26 | void WLANModule::setProfile(QString newProfile){ |
28 | profile = newProfile; | 27 | profile = newProfile; |
29 | } | 28 | } |
30 | 29 | ||
31 | /** | 30 | /** |
32 | * get the icon name for this device. | 31 | * get the icon name for this device. |
33 | * @param Interface* can be used in determining the icon. | 32 | * @param Interface* can be used in determining the icon. |
@@ -38,69 +37,70 @@ QString WLANModule::getPixmapName(Interface* ){ | |||
38 | } | 37 | } |
39 | 38 | ||
40 | /** | 39 | /** |
41 | * Check to see if the interface i is owned by this module. | 40 | * Check to see if the interface i is owned by this module. |
42 | * @param Interface* interface to check against | 41 | * @param Interface* interface to check against |
43 | * @return bool true if i is owned by this module, false otherwise. | 42 | * @return bool true if i is owned by this module, false otherwise. |
44 | */ | 43 | */ |
45 | bool WLANModule::isOwner(Interface *i){ | 44 | bool WLANModule::isOwner(Interface *i){ |
46 | WExtensions we(i->getInterfaceName()); | 45 | WExtensions we(i->getInterfaceName()); |
47 | if(!we.doesHaveWirelessExtensions()) | 46 | if(!we.doesHaveWirelessExtensions()) |
48 | return false; | 47 | return false; |
49 | 48 | ||
50 | //if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ | 49 | i->setHardwareName("802.11b"); |
51 | i->setHardwareName("802.11b"); | 50 | list.append(i); |
52 | list.append(i); | 51 | return true; |
53 | return true; | ||
54 | //} | ||
55 | //return false; | ||
56 | } | 52 | } |
57 | 53 | ||
58 | /** | 54 | /** |
59 | * Create, set tabWiget and return the WLANConfigure Module | 55 | * Create, set tabWiget and return the WLANConfigure Module |
60 | * @param tabWidget a pointer to the tab widget that this configure has. | 56 | * @param tabWidget a pointer to the tab widget that this configure has. |
61 | * @return QWidget* pointer to the tab widget in this modules configure. | 57 | * @return QWidget* pointer to the tab widget in this modules configure. |
62 | */ | 58 | */ |
63 | QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ | 59 | QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ |
64 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); | 60 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); |
65 | (*tabWidget) = wlanconfig->tabWidget; | 61 | (*tabWidget) = wlanconfig->tabWidget; |
66 | return wlanconfig; | 62 | return wlanconfig; |
67 | } | 63 | } |
68 | 64 | ||
69 | /** | 65 | /** |
70 | * Create, set tabWiget and return the Information Module | 66 | * Create, set tabWiget and return the Information Module |
71 | * @param tabWidget a pointer to the tab widget that this information has. | 67 | * @param tabWidget a pointer to the tab widget that this information has. |
72 | * @return QWidget* pointer to the tab widget in this modules info. | 68 | * @return QWidget* pointer to the tab widget in this modules info. |
73 | */ | 69 | */ |
74 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ | 70 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ |
75 | WExtensions we(i->getInterfaceName()); | 71 | WExtensions we(i->getInterfaceName()); |
76 | if(!we.doesHaveWirelessExtensions()) | 72 | if(!we.doesHaveWirelessExtensions()) |
77 | return NULL; | 73 | return NULL; |
78 | 74 | ||
79 | WlanInfo *info = new WlanInfo(0, "wireless info"); | 75 | WlanInfo *info = new WlanInfo(0, "wireless info", Qt::WDestructiveClose); |
80 | (*tabWidget) = info->tabWidget; | 76 | (*tabWidget) = info->tabWidget; |
81 | 77 | ||
82 | info->essidLabel->setText(we.essid()); | 78 | info->essidLabel->setText(we.essid()); |
83 | info->apLabel->setText(we.ap()); | 79 | info->apLabel->setText(we.ap()); |
84 | info->stationLabel->setText(we.station()); | 80 | info->stationLabel->setText(we.station()); |
85 | info->modeLabel->setText(we.mode()); | 81 | info->modeLabel->setText(we.mode()); |
86 | info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); | 82 | info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); |
87 | int signal = 0; | 83 | int signal = 0; |
88 | int noise = 0; | 84 | int noise = 0; |
89 | int quality = 0; | 85 | int quality = 0; |
90 | we.stats(signal, noise, quality); | 86 | we.stats(signal, noise, quality); |
91 | info->signalProgressBar->setProgress(signal); | 87 | info->signalProgressBar->setProgress(signal); |
92 | info->noiseProgressBar->setProgress(noise); | 88 | info->noiseProgressBar->setProgress(noise); |
93 | info->qualityProgressBar->setProgress(quality); | 89 | info->qualityProgressBar->setProgress(quality); |
94 | info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); | 90 | info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); |
91 | //WlanInfo info (0, "wireless info", true); | ||
92 | //info.show(); | ||
93 | //return NULL; | ||
94 | |||
95 | return info; | 95 | return info; |
96 | } | 96 | } |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Get all active (up or down) interfaces | 99 | * Get all active (up or down) interfaces |
100 | * @return QList<Interface> A list of interfaces that exsist that havn't | 100 | * @return QList<Interface> A list of interfaces that exsist that havn't |
101 | * been called by isOwner() | 101 | * been called by isOwner() |
102 | */ | 102 | */ |
103 | QList<Interface> WLANModule::getInterfaces(){ | 103 | QList<Interface> WLANModule::getInterfaces(){ |
104 | return list; | 104 | return list; |
105 | } | 105 | } |
106 | 106 | ||
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO index 7a71142..d61c510 100644 --- a/noncore/settings/networksettings/TODO +++ b/noncore/settings/networksettings/TODO | |||
@@ -1,11 +1,9 @@ | |||
1 | WLAN needs to be re-written to not use Config | 1 | WLAN needs to be re-written to not use Config |
2 | -remove WLAN Config item | 2 | WHERE Is DHCP info stored??? |
3 | -sub class out the wlan info | ||
4 | -check if an interface supports wireless extensions before config. | ||
5 | 3 | ||
6 | PPP module needs to be written | 4 | PPP module needs to be written |
7 | 5 | ||
8 | Write a class that parses /proc and not ifconfig | 6 | Write a class that parses /proc and not ifconfig |
9 | 7 | ||
10 | Possible other modules: ipsec, bluetooth | 8 | Possible other modules: ipsec, bluetooth, ipchains |
11 | 9 | ||
diff --git a/noncore/settings/networksettings/interface.cpp b/noncore/settings/networksettings/interface.cpp index a84b91f..929b3a1 100644 --- a/noncore/settings/networksettings/interface.cpp +++ b/noncore/settings/networksettings/interface.cpp | |||
@@ -1,21 +1,21 @@ | |||
1 | #include "interface.h" | 1 | #include "interface.h" |
2 | #include <qdatetime.h> | 2 | #include <qdatetime.h> |
3 | #include <qfile.h> | 3 | #include <qfile.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | #include <qfileinfo.h> | 5 | #include <qfileinfo.h> |
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | 7 | ||
8 | #define IFCONFIG "/sbin/ifconfig" | 8 | #define IFCONFIG "/sbin/ifconfig" |
9 | #define HDCP_INFO_DIR "/etc/dhcpc" | 9 | #define DHCP_INFO_DIR "/etc/dhcpc" |
10 | 10 | ||
11 | #include <stdio.h> | 11 | #include <stdio.h> |
12 | #include <stdlib.h> | 12 | #include <stdlib.h> |
13 | 13 | ||
14 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ | 14 | Interface::Interface(QObject * parent, const char * name, bool newSatus): QObject(parent, name), status(newSatus), attached(false), hardwareName("Unknown"), moduleOwner(NULL), macAddress(""), ip("0.0.0.0"), broadcast(""), subnetMask("0.0.0.0"), dhcp(false){ |
15 | refresh(); | 15 | refresh(); |
16 | } | 16 | } |
17 | 17 | ||
18 | /** | 18 | /** |
19 | * Set status | 19 | * Set status |
20 | * @param newStatus - the new status | 20 | * @param newStatus - the new status |
21 | * emit updateInterface | 21 | * emit updateInterface |
@@ -162,25 +162,25 @@ bool Interface::refresh(){ | |||
162 | } | 162 | } |
163 | } | 163 | } |
164 | file.close(); | 164 | file.close(); |
165 | QFile::remove(fileName); | 165 | QFile::remove(fileName); |
166 | 166 | ||
167 | // DHCP TESTING | 167 | // DHCP TESTING |
168 | // reset DHCP info | 168 | // reset DHCP info |
169 | dhcpServerIp = ""; | 169 | dhcpServerIp = ""; |
170 | leaseObtained = ""; | 170 | leaseObtained = ""; |
171 | leaseExpires = ""; | 171 | leaseExpires = ""; |
172 | dhcp = false; | 172 | dhcp = false; |
173 | 173 | ||
174 | QString dhcpDirectory(HDCP_INFO_DIR); | 174 | QString dhcpDirectory(DHCP_INFO_DIR); |
175 | QDir d(dhcpDirectory); | 175 | QDir d(dhcpDirectory); |
176 | if(!d.exists(dhcpDirectory)) | 176 | if(!d.exists(dhcpDirectory)) |
177 | dhcpDirectory = "/var/run"; | 177 | dhcpDirectory = "/var/run"; |
178 | 178 | ||
179 | // See if we have | 179 | // See if we have |
180 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); | 180 | QString dhcpFile(QString(dhcpDirectory+"/dhcpcd-%1.info").arg(this->name())); |
181 | // If there is no DHCP information then exit now with no errors. | 181 | // If there is no DHCP information then exit now with no errors. |
182 | if(!QFile::exists(dhcpFile)){ | 182 | if(!QFile::exists(dhcpFile)){ |
183 | emit(updateInterface(this)); | 183 | emit(updateInterface(this)); |
184 | return true; | 184 | return true; |
185 | } | 185 | } |
186 | 186 | ||
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 9d81ab1..c86acdc 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -69,42 +69,44 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par | |||
69 | currentProfileLabel->setText(line); | 69 | currentProfileLabel->setText(line); |
70 | break; | 70 | break; |
71 | } | 71 | } |
72 | } | 72 | } |
73 | file.close(); | 73 | file.close(); |
74 | } | 74 | } |
75 | } | 75 | } |
76 | 76 | ||
77 | /** | 77 | /** |
78 | * Deconstructor. Save profiles. Delete loaded libraries. | 78 | * Deconstructor. Save profiles. Delete loaded libraries. |
79 | */ | 79 | */ |
80 | MainWindowImp::~MainWindowImp(){ | 80 | MainWindowImp::~MainWindowImp(){ |
81 | qDebug("start Saving mainwindow"); | ||
81 | // Save profiles. | 82 | // Save profiles. |
82 | Config cfg("NetworkSetup"); | 83 | Config cfg("NetworkSetup"); |
83 | cfg.setGroup("General"); | 84 | cfg.setGroup("General"); |
84 | cfg.writeEntry("Profiles", profiles.join(" ")); | 85 | cfg.writeEntry("Profiles", profiles.join(" ")); |
85 | 86 | ||
86 | // Delete all interfaces that don't have owners. | 87 | // Delete all interfaces that don't have owners. |
87 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 88 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
88 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 89 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
89 | if(iIt.key()->getModuleOwner() == NULL) | 90 | if(iIt.key()->getModuleOwner() == NULL) |
90 | delete iIt.key(); | 91 | delete iIt.key(); |
91 | } | 92 | } |
92 | 93 | ||
93 | // Delete Modules and Libraries | 94 | // Delete Modules and Libraries |
94 | QMap<Module*, QLibrary*>::Iterator it; | 95 | QMap<Module*, QLibrary*>::Iterator it; |
95 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 96 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
96 | delete it.key(); | 97 | delete it.key(); |
97 | delete it.data(); | 98 | delete it.data(); |
98 | } | 99 | } |
100 | qDebug("done Saving mainwindow"); | ||
99 | } | 101 | } |
100 | 102 | ||
101 | /** | 103 | /** |
102 | * Load all modules that are found in the path | 104 | * Load all modules that are found in the path |
103 | * @param path a directory that is scaned for any plugins that can be loaded | 105 | * @param path a directory that is scaned for any plugins that can be loaded |
104 | * and attempts to load them | 106 | * and attempts to load them |
105 | */ | 107 | */ |
106 | void MainWindowImp::loadModules(QString path){ | 108 | void MainWindowImp::loadModules(QString path){ |
107 | //qDebug(path.latin1()); | 109 | //qDebug(path.latin1()); |
108 | QDir d(path); | 110 | QDir d(path); |
109 | if(!d.exists()) | 111 | if(!d.exists()) |
110 | return; | 112 | return; |
diff --git a/noncore/settings/networksettings/wlan/wextensions.cpp b/noncore/settings/networksettings/wlan/wextensions.cpp index ef4ba8f..e545bd1 100644 --- a/noncore/settings/networksettings/wlan/wextensions.cpp +++ b/noncore/settings/networksettings/wlan/wextensions.cpp | |||
@@ -148,25 +148,25 @@ bool WExtensions::stats(int &signal, int &noise, int &quality){ | |||
148 | QTextStream wstream( &wfile ); | 148 | QTextStream wstream( &wfile ); |
149 | wstream.readLine(); // skip the first two lines | 149 | wstream.readLine(); // skip the first two lines |
150 | wstream.readLine(); // because they only contain headers | 150 | wstream.readLine(); // because they only contain headers |
151 | while(!wstream.atEnd()){ | 151 | while(!wstream.atEnd()){ |
152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; | 152 | wstream >> name >> status >> quality >> c >> signal >> c >> noise; |
153 | if(name == QString("%1:").arg(interface)){ | 153 | if(name == QString("%1:").arg(interface)){ |
154 | if ( quality > 92 ) | 154 | if ( quality > 92 ) |
155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); | 155 | qDebug( "WIFIAPPLET: D'oh! Quality %d > estimated max!\n", quality ); |
156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) | 156 | if ( ( signal > IW_UPPER ) || ( signal < IW_LOWER ) ) |
157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); | 157 | qDebug( "WIFIAPPLET: Doh! Strength %d > estimated max!\n", signal ); |
158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) | 158 | if ( ( noise > IW_UPPER ) || ( noise < IW_LOWER ) ) |
159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); | 159 | qDebug( "WIFIAPPLET: Doh! Noise %d > estimated max!\n", noise ); |
160 | qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); | 160 | //qDebug(QString("q:%1, s:%2, n:%3").arg(quality).arg(signal).arg(noise).latin1()); |
161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; | 161 | signal = ( ( signal-IW_LOWER ) * 100 ) / IW_UPPER; |
162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; | 162 | noise = ( ( noise-IW_LOWER ) * 100 ) / IW_UPPER; |
163 | quality = ( quality*100 ) / 92; | 163 | quality = ( quality*100 ) / 92; |
164 | return true; | 164 | return true; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | 167 | ||
168 | qDebug("WExtensions::statsCard no longer present."); | 168 | qDebug("WExtensions::statsCard no longer present."); |
169 | quality = -1; | 169 | quality = -1; |
170 | signal = IW_LOWER; | 170 | signal = IW_LOWER; |
171 | noise = IW_LOWER; | 171 | noise = IW_LOWER; |
172 | return false; | 172 | return false; |
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index ea19207..94c7518 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp | |||
@@ -7,25 +7,25 @@ | |||
7 | /* system() */ | 7 | /* system() */ |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qdir.h> | 10 | #include <qdir.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
15 | #include <qradiobutton.h> | 15 | #include <qradiobutton.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qregexp.h> | 17 | #include <qregexp.h> |
18 | 18 | ||
19 | WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name){ | 19 | WLANImp::WLANImp( QWidget* parent, const char* name):WLAN(parent, name, Qt::WDestructiveClose){ |
20 | config = new Config("wireless"); | 20 | config = new Config("wireless"); |
21 | readConfig(); | 21 | readConfig(); |
22 | } | 22 | } |
23 | 23 | ||
24 | WLANImp::~WLANImp( ){ | 24 | WLANImp::~WLANImp( ){ |
25 | delete config; | 25 | delete config; |
26 | } | 26 | } |
27 | 27 | ||
28 | void WLANImp::readConfig() | 28 | void WLANImp::readConfig() |
29 | { | 29 | { |
30 | qWarning( "WLANImp::readConfig() called." ); | 30 | qWarning( "WLANImp::readConfig() called." ); |
31 | config->setGroup( "Properties" ); | 31 | config->setGroup( "Properties" ); |
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index 73e753c..7507c54 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp | |||
@@ -1,33 +1,32 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include "wlanimp.h" | 2 | #include "wlanimp.h" |
3 | #include "info.h" | 3 | #include "info.h" |
4 | #include "wextensions.h" | 4 | #include "wextensions.h" |
5 | 5 | ||
6 | #include <qlabel.h> | 6 | #include <qlabel.h> |
7 | #include <qprogressbar.h> | 7 | #include <qprogressbar.h> |
8 | 8 | ||
9 | /** | 9 | /** |
10 | * Constructor, find all of the possible interfaces | 10 | * Constructor, find all of the possible interfaces |
11 | */ | 11 | */ |
12 | WLANModule::WLANModule() : Module() { | 12 | WLANModule::WLANModule() : Module() { |
13 | // get output from iwconfig | ||
14 | } | 13 | } |
15 | 14 | ||
16 | /** | 15 | /** |
17 | */ | 16 | */ |
18 | WLANModule::~WLANModule(){ | 17 | WLANModule::~WLANModule(){ |
19 | Interface *i; | 18 | Interface *i; |
20 | for ( i=list.first(); i != 0; i=list.next() ) | 19 | for ( i=list.first(); i != 0; i=list.next() ) |
21 | delete i; | 20 | delete i; |
22 | } | 21 | } |
23 | 22 | ||
24 | /** | 23 | /** |
25 | * Change the current profile | 24 | * Change the current profile |
26 | */ | 25 | */ |
27 | void WLANModule::setProfile(QString newProfile){ | 26 | void WLANModule::setProfile(QString newProfile){ |
28 | profile = newProfile; | 27 | profile = newProfile; |
29 | } | 28 | } |
30 | 29 | ||
31 | /** | 30 | /** |
32 | * get the icon name for this device. | 31 | * get the icon name for this device. |
33 | * @param Interface* can be used in determining the icon. | 32 | * @param Interface* can be used in determining the icon. |
@@ -38,69 +37,70 @@ QString WLANModule::getPixmapName(Interface* ){ | |||
38 | } | 37 | } |
39 | 38 | ||
40 | /** | 39 | /** |
41 | * Check to see if the interface i is owned by this module. | 40 | * Check to see if the interface i is owned by this module. |
42 | * @param Interface* interface to check against | 41 | * @param Interface* interface to check against |
43 | * @return bool true if i is owned by this module, false otherwise. | 42 | * @return bool true if i is owned by this module, false otherwise. |
44 | */ | 43 | */ |
45 | bool WLANModule::isOwner(Interface *i){ | 44 | bool WLANModule::isOwner(Interface *i){ |
46 | WExtensions we(i->getInterfaceName()); | 45 | WExtensions we(i->getInterfaceName()); |
47 | if(!we.doesHaveWirelessExtensions()) | 46 | if(!we.doesHaveWirelessExtensions()) |
48 | return false; | 47 | return false; |
49 | 48 | ||
50 | //if(i->getInterfaceName() == "eth0" || i->getInterfaceName() == "wlan0"){ | 49 | i->setHardwareName("802.11b"); |
51 | i->setHardwareName("802.11b"); | 50 | list.append(i); |
52 | list.append(i); | 51 | return true; |
53 | return true; | ||
54 | //} | ||
55 | //return false; | ||
56 | } | 52 | } |
57 | 53 | ||
58 | /** | 54 | /** |
59 | * Create, set tabWiget and return the WLANConfigure Module | 55 | * Create, set tabWiget and return the WLANConfigure Module |
60 | * @param tabWidget a pointer to the tab widget that this configure has. | 56 | * @param tabWidget a pointer to the tab widget that this configure has. |
61 | * @return QWidget* pointer to the tab widget in this modules configure. | 57 | * @return QWidget* pointer to the tab widget in this modules configure. |
62 | */ | 58 | */ |
63 | QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ | 59 | QWidget *WLANModule::configure(Interface *, QTabWidget **tabWidget){ |
64 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); | 60 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig"); |
65 | (*tabWidget) = wlanconfig->tabWidget; | 61 | (*tabWidget) = wlanconfig->tabWidget; |
66 | return wlanconfig; | 62 | return wlanconfig; |
67 | } | 63 | } |
68 | 64 | ||
69 | /** | 65 | /** |
70 | * Create, set tabWiget and return the Information Module | 66 | * Create, set tabWiget and return the Information Module |
71 | * @param tabWidget a pointer to the tab widget that this information has. | 67 | * @param tabWidget a pointer to the tab widget that this information has. |
72 | * @return QWidget* pointer to the tab widget in this modules info. | 68 | * @return QWidget* pointer to the tab widget in this modules info. |
73 | */ | 69 | */ |
74 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ | 70 | QWidget *WLANModule::information(Interface *i, QTabWidget **tabWidget){ |
75 | WExtensions we(i->getInterfaceName()); | 71 | WExtensions we(i->getInterfaceName()); |
76 | if(!we.doesHaveWirelessExtensions()) | 72 | if(!we.doesHaveWirelessExtensions()) |
77 | return NULL; | 73 | return NULL; |
78 | 74 | ||
79 | WlanInfo *info = new WlanInfo(0, "wireless info"); | 75 | WlanInfo *info = new WlanInfo(0, "wireless info", Qt::WDestructiveClose); |
80 | (*tabWidget) = info->tabWidget; | 76 | (*tabWidget) = info->tabWidget; |
81 | 77 | ||
82 | info->essidLabel->setText(we.essid()); | 78 | info->essidLabel->setText(we.essid()); |
83 | info->apLabel->setText(we.ap()); | 79 | info->apLabel->setText(we.ap()); |
84 | info->stationLabel->setText(we.station()); | 80 | info->stationLabel->setText(we.station()); |
85 | info->modeLabel->setText(we.mode()); | 81 | info->modeLabel->setText(we.mode()); |
86 | info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); | 82 | info->freqLabel->setText(QString("%1 GHz").arg(we.frequency())); |
87 | int signal = 0; | 83 | int signal = 0; |
88 | int noise = 0; | 84 | int noise = 0; |
89 | int quality = 0; | 85 | int quality = 0; |
90 | we.stats(signal, noise, quality); | 86 | we.stats(signal, noise, quality); |
91 | info->signalProgressBar->setProgress(signal); | 87 | info->signalProgressBar->setProgress(signal); |
92 | info->noiseProgressBar->setProgress(noise); | 88 | info->noiseProgressBar->setProgress(noise); |
93 | info->qualityProgressBar->setProgress(quality); | 89 | info->qualityProgressBar->setProgress(quality); |
94 | info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); | 90 | info->rateLabel->setText(QString("%1 Mb/s").arg(we.rate())); |
91 | //WlanInfo info (0, "wireless info", true); | ||
92 | //info.show(); | ||
93 | //return NULL; | ||
94 | |||
95 | return info; | 95 | return info; |
96 | } | 96 | } |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Get all active (up or down) interfaces | 99 | * Get all active (up or down) interfaces |
100 | * @return QList<Interface> A list of interfaces that exsist that havn't | 100 | * @return QList<Interface> A list of interfaces that exsist that havn't |
101 | * been called by isOwner() | 101 | * been called by isOwner() |
102 | */ | 102 | */ |
103 | QList<Interface> WLANModule::getInterfaces(){ | 103 | QList<Interface> WLANModule::getInterfaces(){ |
104 | return list; | 104 | return list; |
105 | } | 105 | } |
106 | 106 | ||