-rw-r--r-- | noncore/net/networksetup/TODO | 13 | ||||
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 8 | ||||
-rw-r--r-- | noncore/settings/networksettings/TODO | 13 | ||||
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 8 |
4 files changed, 26 insertions, 16 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO index c587f58..7a71142 100644 --- a/noncore/net/networksetup/TODO +++ b/noncore/net/networksetup/TODO | |||
@@ -1,6 +1,11 @@ | |||
1 | Write a class that parses /proc and not ifconfig | ||
2 | WLAN needs to be re-written to not use Config | 1 | WLAN needs to be re-written to not use Config |
3 | remove WLAN Config item | 2 | -remove WLAN Config item |
3 | -sub class out the wlan info | ||
4 | -check if an interface supports wireless extensions before config. | ||
5 | |||
6 | PPP module needs to be written | ||
7 | |||
8 | Write a class that parses /proc and not ifconfig | ||
9 | |||
10 | Possible other modules: ipsec, bluetooth | ||
4 | 11 | ||
5 | [ ] Wlanmodule needs to check if an interface supports wireless | ||
6 | extensions. | ||
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 8e4e898..843f630 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp | |||
@@ -130,205 +130,205 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString) | |||
130 | delete lib; | 130 | delete lib; |
131 | return NULL; | 131 | return NULL; |
132 | } | 132 | } |
133 | 133 | ||
134 | // Try to get an object. | 134 | // Try to get an object. |
135 | Module *object = ((Module* (*)()) functionPointer)(); | 135 | Module *object = ((Module* (*)()) functionPointer)(); |
136 | if(object == NULL){ | 136 | if(object == NULL){ |
137 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 137 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
138 | delete lib; | 138 | delete lib; |
139 | return NULL; | 139 | return NULL; |
140 | } | 140 | } |
141 | 141 | ||
142 | // Store for deletion later | 142 | // Store for deletion later |
143 | libraries.insert(object, lib); | 143 | libraries.insert(object, lib); |
144 | return object; | 144 | return object; |
145 | } | 145 | } |
146 | 146 | ||
147 | /** | 147 | /** |
148 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 148 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
149 | * load the plugin and append it to the list | 149 | * load the plugin and append it to the list |
150 | */ | 150 | */ |
151 | void MainWindowImp::addClicked(){ | 151 | void MainWindowImp::addClicked(){ |
152 | QMap<Module*, QLibrary*>::Iterator it; | 152 | QMap<Module*, QLibrary*>::Iterator it; |
153 | QMap<QString, QString> list; | 153 | QMap<QString, QString> list; |
154 | QMap<QString, Module*> newInterfaceOwners; | 154 | QMap<QString, Module*> newInterfaceOwners; |
155 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 155 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
156 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 156 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
157 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 157 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
158 | if(it.key()){ | 158 | if(it.key()){ |
159 | (it.key())->possibleNewInterfaces(list); | 159 | (it.key())->possibleNewInterfaces(list); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | // See if the list has anything that we can add. | 162 | // See if the list has anything that we can add. |
163 | if(list.count() == 0){ | 163 | if(list.count() == 0){ |
164 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); | 164 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); |
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 167 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
168 | addNewConnection.addConnections(list); | 168 | addNewConnection.addConnections(list); |
169 | addNewConnection.showMaximized(); | 169 | addNewConnection.showMaximized(); |
170 | if(QDialog::Accepted == addNewConnection.exec()){ | 170 | if(QDialog::Accepted == addNewConnection.exec()){ |
171 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 171 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
172 | if(!item) | 172 | if(!item) |
173 | return; | 173 | return; |
174 | 174 | ||
175 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 175 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
176 | if(it.key()){ | 176 | if(it.key()){ |
177 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 177 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
178 | if(i){ | 178 | if(i){ |
179 | interfaceNames.insert(i->getInterfaceName(), i); | 179 | interfaceNames.insert(i->getInterfaceName(), i); |
180 | updateInterface(i); | 180 | updateInterface(i); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | } | 183 | } |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | /** | 187 | /** |
188 | * Prompt the user to see if they really want to do this. | 188 | * Prompt the user to see if they really want to do this. |
189 | * If they do then remove from the list and unload. | 189 | * If they do then remove from the list and unload. |
190 | */ | 190 | */ |
191 | void MainWindowImp::removeClicked(){ | 191 | void MainWindowImp::removeClicked(){ |
192 | QListViewItem *item = connectionList->currentItem(); | 192 | QListViewItem *item = connectionList->currentItem(); |
193 | if(!item) { | 193 | if(!item) { |
194 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); | 194 | QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | 197 | ||
198 | Interface *i = interfaceItems[item]; | 198 | Interface *i = interfaceItems[item]; |
199 | if(i->getModuleOwner() == NULL){ | 199 | if(i->getModuleOwner() == NULL){ |
200 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); | 200 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); |
201 | } | 201 | } |
202 | else{ | 202 | else{ |
203 | if(!i->getModuleOwner()->remove(i)) | 203 | if(!i->getModuleOwner()->remove(i)) |
204 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); | 204 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); |
205 | else{ | 205 | else{ |
206 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); | 206 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); |
207 | // TODO memory managment.... | 207 | // TODO memory managment.... |
208 | // who deletes the interface? | 208 | // who deletes the interface? |
209 | } | 209 | } |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * Pull up the configure about the currently selected interface. | 214 | * Pull up the configure about the currently selected interface. |
215 | * Report an error if no interface is selected. | 215 | * Report an error if no interface is selected. |
216 | * If the interface has a module owner then request its configure with a empty | 216 | * If the interface has a module owner then request its configure with a empty |
217 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 217 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
218 | */ | 218 | */ |
219 | void MainWindowImp::configureClicked(){ | 219 | void MainWindowImp::configureClicked(){ |
220 | QListViewItem *item = connectionList->currentItem(); | 220 | QListViewItem *item = connectionList->currentItem(); |
221 | if(!item){ | 221 | if(!item){ |
222 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 222 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | 225 | ||
226 | QString currentProfile = currentProfileLabel->text(); | 226 | QString currentProfile = currentProfileLabel->text(); |
227 | if(profilesList->count() <= 1 || currentProfile == "All"){ | 227 | if(profilesList->count() <= 1 || currentProfile == "All"){ |
228 | currentProfile = ""; | 228 | currentProfile = ""; |
229 | } | 229 | } |
230 | 230 | ||
231 | Interface *i = interfaceItems[item]; | 231 | Interface *i = interfaceItems[item]; |
232 | if(i->getModuleOwner()){ | 232 | if(i->getModuleOwner()){ |
233 | i->getModuleOwner()->setProfile(currentProfile); | 233 | i->getModuleOwner()->setProfile(currentProfile); |
234 | QTabWidget *tabWidget = NULL; | 234 | QTabWidget *tabWidget = NULL; |
235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget); | 235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget); |
236 | if(moduleConfigure != NULL){ | 236 | if(moduleConfigure != NULL){ |
237 | if(tabWidget != NULL){ | 237 | if(tabWidget != NULL){ |
238 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); | 238 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); |
239 | configure->setProfile(currentProfile); | 239 | configure->setProfile(currentProfile); |
240 | tabWidget->insertTab(configure, "TCP/IP"); | 240 | tabWidget->insertTab(configure, "TCP/IP"); |
241 | 241 | ||
242 | } | 242 | } |
243 | moduleConfigure->showMaximized(); | 243 | moduleConfigure->showMaximized(); |
244 | moduleConfigure->show(); | 244 | moduleConfigure->show(); |
245 | return; | 245 | return; |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); | 249 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); |
250 | configure->setProfile(currentProfile); | 250 | configure->setProfile(currentProfile); |
251 | configure->showMaximized(); | 251 | configure->showMaximized(); |
252 | configure->show(); | 252 | configure->show(); |
253 | } | 253 | } |
254 | 254 | ||
255 | /** | 255 | /** |
256 | * Pull up the information about the currently selected interface. | 256 | * Pull up the information about the currently selected interface. |
257 | * Report an error if no interface is selected. | 257 | * Report an error if no interface is selected. |
258 | * If the interface has a module owner then request its configure with a empty | 258 | * If the interface has a module owner then request its configure with a empty |
259 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 259 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
260 | */ | 260 | */ |
261 | void MainWindowImp::informationClicked(){ | 261 | void MainWindowImp::informationClicked(){ |
262 | QListViewItem *item = connectionList->currentItem(); | 262 | QListViewItem *item = connectionList->currentItem(); |
263 | if(!item){ | 263 | if(!item){ |
264 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 264 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | Interface *i = interfaceItems[item]; | 268 | Interface *i = interfaceItems[item]; |
269 | if(!i->isAttached()){ | 269 | if(!i->isAttached()){ |
270 | QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); | 270 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | 273 | ||
274 | QStringList list; | 274 | QStringList list; |
275 | for(uint i = 0; i < profilesList->count(); i++){ | 275 | for(uint i = 0; i < profilesList->count(); i++){ |
276 | list.append(profilesList->text(i)); | 276 | list.append(profilesList->text(i)); |
277 | } | 277 | } |
278 | 278 | ||
279 | if(i->getModuleOwner()){ | 279 | if(i->getModuleOwner()){ |
280 | QTabWidget *tabWidget = NULL; | 280 | QTabWidget *tabWidget = NULL; |
281 | QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget); | 281 | QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget); |
282 | if(moduleInformation != NULL){ | 282 | if(moduleInformation != NULL){ |
283 | if(tabWidget != NULL){ | 283 | if(tabWidget != NULL){ |
284 | InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); | 284 | InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); |
285 | tabWidget->insertTab(information, "TCP/IP"); | 285 | tabWidget->insertTab(information, "TCP/IP"); |
286 | } | 286 | } |
287 | moduleInformation->showMaximized(); | 287 | moduleInformation->showMaximized(); |
288 | moduleInformation->show(); | 288 | moduleInformation->show(); |
289 | return; | 289 | return; |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); | 293 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); |
294 | information->showMaximized(); | 294 | information->showMaximized(); |
295 | information->show(); | 295 | information->show(); |
296 | } | 296 | } |
297 | 297 | ||
298 | /** | 298 | /** |
299 | * Aquire the list of active interfaces from ifconfig | 299 | * Aquire the list of active interfaces from ifconfig |
300 | * Call ifconfig and ifconfig -a | 300 | * Call ifconfig and ifconfig -a |
301 | */ | 301 | */ |
302 | void MainWindowImp::getInterfaceList(){ | 302 | void MainWindowImp::getInterfaceList(){ |
303 | KShellProcess *processAll = new KShellProcess(); | 303 | KShellProcess *processAll = new KShellProcess(); |
304 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; | 304 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; |
305 | connect(processAll, SIGNAL(processExited(KProcess *)), | 305 | connect(processAll, SIGNAL(processExited(KProcess *)), |
306 | this, SLOT(jobDone(KProcess *))); | 306 | this, SLOT(jobDone(KProcess *))); |
307 | threads.insert(processAll, TEMP_ALL); | 307 | threads.insert(processAll, TEMP_ALL); |
308 | 308 | ||
309 | KShellProcess *process = new KShellProcess(); | 309 | KShellProcess *process = new KShellProcess(); |
310 | *process << "/sbin/ifconfig" << " > " TEMP_UP; | 310 | *process << "/sbin/ifconfig" << " > " TEMP_UP; |
311 | connect(process, SIGNAL(processExited(KProcess *)), | 311 | connect(process, SIGNAL(processExited(KProcess *)), |
312 | this, SLOT(jobDone(KProcess *))); | 312 | this, SLOT(jobDone(KProcess *))); |
313 | threads.insert(process, TEMP_UP); | 313 | threads.insert(process, TEMP_UP); |
314 | 314 | ||
315 | processAll->start(KShellProcess::NotifyOnExit); | 315 | processAll->start(KShellProcess::NotifyOnExit); |
316 | process->start(KShellProcess::NotifyOnExit); | 316 | process->start(KShellProcess::NotifyOnExit); |
317 | } | 317 | } |
318 | 318 | ||
319 | void MainWindowImp::jobDone(KProcess *process){ | 319 | void MainWindowImp::jobDone(KProcess *process){ |
320 | QString fileName = threads[process]; | 320 | QString fileName = threads[process]; |
321 | threads.remove(process); | 321 | threads.remove(process); |
322 | delete process; | 322 | delete process; |
323 | 323 | ||
324 | QFile file(fileName); | 324 | QFile file(fileName); |
325 | if (!file.open(IO_ReadOnly)){ | 325 | if (!file.open(IO_ReadOnly)){ |
326 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); | 326 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | 329 | ||
330 | QTextStream stream( &file ); | 330 | QTextStream stream( &file ); |
331 | QString line; | 331 | QString line; |
332 | while ( !stream.eof() ) { | 332 | while ( !stream.eof() ) { |
333 | line = stream.readLine(); | 333 | line = stream.readLine(); |
334 | int space = line.find(" "); | 334 | int space = line.find(" "); |
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO index c587f58..7a71142 100644 --- a/noncore/settings/networksettings/TODO +++ b/noncore/settings/networksettings/TODO | |||
@@ -1,6 +1,11 @@ | |||
1 | Write a class that parses /proc and not ifconfig | ||
2 | WLAN needs to be re-written to not use Config | 1 | WLAN needs to be re-written to not use Config |
3 | remove WLAN Config item | 2 | -remove WLAN Config item |
3 | -sub class out the wlan info | ||
4 | -check if an interface supports wireless extensions before config. | ||
5 | |||
6 | PPP module needs to be written | ||
7 | |||
8 | Write a class that parses /proc and not ifconfig | ||
9 | |||
10 | Possible other modules: ipsec, bluetooth | ||
4 | 11 | ||
5 | [ ] Wlanmodule needs to check if an interface supports wireless | ||
6 | extensions. | ||
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 8e4e898..843f630 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -130,205 +130,205 @@ Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString) | |||
130 | delete lib; | 130 | delete lib; |
131 | return NULL; | 131 | return NULL; |
132 | } | 132 | } |
133 | 133 | ||
134 | // Try to get an object. | 134 | // Try to get an object. |
135 | Module *object = ((Module* (*)()) functionPointer)(); | 135 | Module *object = ((Module* (*)()) functionPointer)(); |
136 | if(object == NULL){ | 136 | if(object == NULL){ |
137 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 137 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
138 | delete lib; | 138 | delete lib; |
139 | return NULL; | 139 | return NULL; |
140 | } | 140 | } |
141 | 141 | ||
142 | // Store for deletion later | 142 | // Store for deletion later |
143 | libraries.insert(object, lib); | 143 | libraries.insert(object, lib); |
144 | return object; | 144 | return object; |
145 | } | 145 | } |
146 | 146 | ||
147 | /** | 147 | /** |
148 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 148 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
149 | * load the plugin and append it to the list | 149 | * load the plugin and append it to the list |
150 | */ | 150 | */ |
151 | void MainWindowImp::addClicked(){ | 151 | void MainWindowImp::addClicked(){ |
152 | QMap<Module*, QLibrary*>::Iterator it; | 152 | QMap<Module*, QLibrary*>::Iterator it; |
153 | QMap<QString, QString> list; | 153 | QMap<QString, QString> list; |
154 | QMap<QString, Module*> newInterfaceOwners; | 154 | QMap<QString, Module*> newInterfaceOwners; |
155 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 155 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
156 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 156 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
157 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 157 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
158 | if(it.key()){ | 158 | if(it.key()){ |
159 | (it.key())->possibleNewInterfaces(list); | 159 | (it.key())->possibleNewInterfaces(list); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | // See if the list has anything that we can add. | 162 | // See if the list has anything that we can add. |
163 | if(list.count() == 0){ | 163 | if(list.count() == 0){ |
164 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); | 164 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); |
165 | return; | 165 | return; |
166 | } | 166 | } |
167 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 167 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
168 | addNewConnection.addConnections(list); | 168 | addNewConnection.addConnections(list); |
169 | addNewConnection.showMaximized(); | 169 | addNewConnection.showMaximized(); |
170 | if(QDialog::Accepted == addNewConnection.exec()){ | 170 | if(QDialog::Accepted == addNewConnection.exec()){ |
171 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 171 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
172 | if(!item) | 172 | if(!item) |
173 | return; | 173 | return; |
174 | 174 | ||
175 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 175 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
176 | if(it.key()){ | 176 | if(it.key()){ |
177 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 177 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
178 | if(i){ | 178 | if(i){ |
179 | interfaceNames.insert(i->getInterfaceName(), i); | 179 | interfaceNames.insert(i->getInterfaceName(), i); |
180 | updateInterface(i); | 180 | updateInterface(i); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | } | 183 | } |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | /** | 187 | /** |
188 | * Prompt the user to see if they really want to do this. | 188 | * Prompt the user to see if they really want to do this. |
189 | * If they do then remove from the list and unload. | 189 | * If they do then remove from the list and unload. |
190 | */ | 190 | */ |
191 | void MainWindowImp::removeClicked(){ | 191 | void MainWindowImp::removeClicked(){ |
192 | QListViewItem *item = connectionList->currentItem(); | 192 | QListViewItem *item = connectionList->currentItem(); |
193 | if(!item) { | 193 | if(!item) { |
194 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); | 194 | QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); |
195 | return; | 195 | return; |
196 | } | 196 | } |
197 | 197 | ||
198 | Interface *i = interfaceItems[item]; | 198 | Interface *i = interfaceItems[item]; |
199 | if(i->getModuleOwner() == NULL){ | 199 | if(i->getModuleOwner() == NULL){ |
200 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); | 200 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); |
201 | } | 201 | } |
202 | else{ | 202 | else{ |
203 | if(!i->getModuleOwner()->remove(i)) | 203 | if(!i->getModuleOwner()->remove(i)) |
204 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); | 204 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); |
205 | else{ | 205 | else{ |
206 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); | 206 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); |
207 | // TODO memory managment.... | 207 | // TODO memory managment.... |
208 | // who deletes the interface? | 208 | // who deletes the interface? |
209 | } | 209 | } |
210 | } | 210 | } |
211 | } | 211 | } |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * Pull up the configure about the currently selected interface. | 214 | * Pull up the configure about the currently selected interface. |
215 | * Report an error if no interface is selected. | 215 | * Report an error if no interface is selected. |
216 | * If the interface has a module owner then request its configure with a empty | 216 | * If the interface has a module owner then request its configure with a empty |
217 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 217 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
218 | */ | 218 | */ |
219 | void MainWindowImp::configureClicked(){ | 219 | void MainWindowImp::configureClicked(){ |
220 | QListViewItem *item = connectionList->currentItem(); | 220 | QListViewItem *item = connectionList->currentItem(); |
221 | if(!item){ | 221 | if(!item){ |
222 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 222 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); |
223 | return; | 223 | return; |
224 | } | 224 | } |
225 | 225 | ||
226 | QString currentProfile = currentProfileLabel->text(); | 226 | QString currentProfile = currentProfileLabel->text(); |
227 | if(profilesList->count() <= 1 || currentProfile == "All"){ | 227 | if(profilesList->count() <= 1 || currentProfile == "All"){ |
228 | currentProfile = ""; | 228 | currentProfile = ""; |
229 | } | 229 | } |
230 | 230 | ||
231 | Interface *i = interfaceItems[item]; | 231 | Interface *i = interfaceItems[item]; |
232 | if(i->getModuleOwner()){ | 232 | if(i->getModuleOwner()){ |
233 | i->getModuleOwner()->setProfile(currentProfile); | 233 | i->getModuleOwner()->setProfile(currentProfile); |
234 | QTabWidget *tabWidget = NULL; | 234 | QTabWidget *tabWidget = NULL; |
235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget); | 235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i, &tabWidget); |
236 | if(moduleConfigure != NULL){ | 236 | if(moduleConfigure != NULL){ |
237 | if(tabWidget != NULL){ | 237 | if(tabWidget != NULL){ |
238 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); | 238 | InterfaceSetupImp *configure = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i, true); |
239 | configure->setProfile(currentProfile); | 239 | configure->setProfile(currentProfile); |
240 | tabWidget->insertTab(configure, "TCP/IP"); | 240 | tabWidget->insertTab(configure, "TCP/IP"); |
241 | 241 | ||
242 | } | 242 | } |
243 | moduleConfigure->showMaximized(); | 243 | moduleConfigure->showMaximized(); |
244 | moduleConfigure->show(); | 244 | moduleConfigure->show(); |
245 | return; | 245 | return; |
246 | } | 246 | } |
247 | } | 247 | } |
248 | 248 | ||
249 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); | 249 | InterfaceSetupImp *configure = new InterfaceSetupImp(0, "InterfaceSetupImp", i, true); |
250 | configure->setProfile(currentProfile); | 250 | configure->setProfile(currentProfile); |
251 | configure->showMaximized(); | 251 | configure->showMaximized(); |
252 | configure->show(); | 252 | configure->show(); |
253 | } | 253 | } |
254 | 254 | ||
255 | /** | 255 | /** |
256 | * Pull up the information about the currently selected interface. | 256 | * Pull up the information about the currently selected interface. |
257 | * Report an error if no interface is selected. | 257 | * Report an error if no interface is selected. |
258 | * If the interface has a module owner then request its configure with a empty | 258 | * If the interface has a module owner then request its configure with a empty |
259 | * tab. If tab is !NULL then append the interfaces setup widget to it. | 259 | * tab. If tab is !NULL then append the interfaces setup widget to it. |
260 | */ | 260 | */ |
261 | void MainWindowImp::informationClicked(){ | 261 | void MainWindowImp::informationClicked(){ |
262 | QListViewItem *item = connectionList->currentItem(); | 262 | QListViewItem *item = connectionList->currentItem(); |
263 | if(!item){ | 263 | if(!item){ |
264 | QMessageBox::information(this, "Error","Please select an interface.", QMessageBox::Ok); | 264 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | Interface *i = interfaceItems[item]; | 268 | Interface *i = interfaceItems[item]; |
269 | if(!i->isAttached()){ | 269 | if(!i->isAttached()){ |
270 | QMessageBox::information(this, "Error","No information about\na disconnected interface.", QMessageBox::Ok); | 270 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | 273 | ||
274 | QStringList list; | 274 | QStringList list; |
275 | for(uint i = 0; i < profilesList->count(); i++){ | 275 | for(uint i = 0; i < profilesList->count(); i++){ |
276 | list.append(profilesList->text(i)); | 276 | list.append(profilesList->text(i)); |
277 | } | 277 | } |
278 | 278 | ||
279 | if(i->getModuleOwner()){ | 279 | if(i->getModuleOwner()){ |
280 | QTabWidget *tabWidget = NULL; | 280 | QTabWidget *tabWidget = NULL; |
281 | QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget); | 281 | QWidget *moduleInformation = i->getModuleOwner()->information(i, &tabWidget); |
282 | if(moduleInformation != NULL){ | 282 | if(moduleInformation != NULL){ |
283 | if(tabWidget != NULL){ | 283 | if(tabWidget != NULL){ |
284 | InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); | 284 | InterfaceInformationImp *information = new InterfaceInformationImp(tabWidget, "InterfaceSetupImp", i, true); |
285 | tabWidget->insertTab(information, "TCP/IP"); | 285 | tabWidget->insertTab(information, "TCP/IP"); |
286 | } | 286 | } |
287 | moduleInformation->showMaximized(); | 287 | moduleInformation->showMaximized(); |
288 | moduleInformation->show(); | 288 | moduleInformation->show(); |
289 | return; | 289 | return; |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); | 293 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); |
294 | information->showMaximized(); | 294 | information->showMaximized(); |
295 | information->show(); | 295 | information->show(); |
296 | } | 296 | } |
297 | 297 | ||
298 | /** | 298 | /** |
299 | * Aquire the list of active interfaces from ifconfig | 299 | * Aquire the list of active interfaces from ifconfig |
300 | * Call ifconfig and ifconfig -a | 300 | * Call ifconfig and ifconfig -a |
301 | */ | 301 | */ |
302 | void MainWindowImp::getInterfaceList(){ | 302 | void MainWindowImp::getInterfaceList(){ |
303 | KShellProcess *processAll = new KShellProcess(); | 303 | KShellProcess *processAll = new KShellProcess(); |
304 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; | 304 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; |
305 | connect(processAll, SIGNAL(processExited(KProcess *)), | 305 | connect(processAll, SIGNAL(processExited(KProcess *)), |
306 | this, SLOT(jobDone(KProcess *))); | 306 | this, SLOT(jobDone(KProcess *))); |
307 | threads.insert(processAll, TEMP_ALL); | 307 | threads.insert(processAll, TEMP_ALL); |
308 | 308 | ||
309 | KShellProcess *process = new KShellProcess(); | 309 | KShellProcess *process = new KShellProcess(); |
310 | *process << "/sbin/ifconfig" << " > " TEMP_UP; | 310 | *process << "/sbin/ifconfig" << " > " TEMP_UP; |
311 | connect(process, SIGNAL(processExited(KProcess *)), | 311 | connect(process, SIGNAL(processExited(KProcess *)), |
312 | this, SLOT(jobDone(KProcess *))); | 312 | this, SLOT(jobDone(KProcess *))); |
313 | threads.insert(process, TEMP_UP); | 313 | threads.insert(process, TEMP_UP); |
314 | 314 | ||
315 | processAll->start(KShellProcess::NotifyOnExit); | 315 | processAll->start(KShellProcess::NotifyOnExit); |
316 | process->start(KShellProcess::NotifyOnExit); | 316 | process->start(KShellProcess::NotifyOnExit); |
317 | } | 317 | } |
318 | 318 | ||
319 | void MainWindowImp::jobDone(KProcess *process){ | 319 | void MainWindowImp::jobDone(KProcess *process){ |
320 | QString fileName = threads[process]; | 320 | QString fileName = threads[process]; |
321 | threads.remove(process); | 321 | threads.remove(process); |
322 | delete process; | 322 | delete process; |
323 | 323 | ||
324 | QFile file(fileName); | 324 | QFile file(fileName); |
325 | if (!file.open(IO_ReadOnly)){ | 325 | if (!file.open(IO_ReadOnly)){ |
326 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); | 326 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); |
327 | return; | 327 | return; |
328 | } | 328 | } |
329 | 329 | ||
330 | QTextStream stream( &file ); | 330 | QTextStream stream( &file ); |
331 | QString line; | 331 | QString line; |
332 | while ( !stream.eof() ) { | 332 | while ( !stream.eof() ) { |
333 | line = stream.readLine(); | 333 | line = stream.readLine(); |
334 | int space = line.find(" "); | 334 | int space = line.find(" "); |