author | benmeyer <benmeyer> | 2002-10-01 21:21:48 (UTC) |
---|---|---|
committer | benmeyer <benmeyer> | 2002-10-01 21:21:48 (UTC) |
commit | 1ed782f91c1af59e31c117809ca5d9150b8b6654 (patch) (unidiff) | |
tree | d29c3f84dee9a01649d246a625a71d38274dbaae /noncore/net/networksetup/mainwindowimp.cpp | |
parent | 2987dafbdfa6602c5e165fe862546ea32f5fd3ca (diff) | |
download | opie-1ed782f91c1af59e31c117809ca5d9150b8b6654.zip opie-1ed782f91c1af59e31c117809ca5d9150b8b6654.tar.gz opie-1ed782f91c1af59e31c117809ca5d9150b8b6654.tar.bz2 |
Getting modules to work
Diffstat (limited to 'noncore/net/networksetup/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/networksetup/mainwindowimp.cpp | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index 0f48a4b..89dac6f 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp | |||
@@ -142,76 +142,103 @@ void MainWindowImp::addClicked(){ | |||
142 | 142 | ||
143 | /** | 143 | /** |
144 | * Prompt the user to see if they really want to do this. | 144 | * Prompt the user to see if they really want to do this. |
145 | * If they do then remove from the list and unload. | 145 | * If they do then remove from the list and unload. |
146 | */ | 146 | */ |
147 | void MainWindowImp::removeClicked(){ | 147 | void MainWindowImp::removeClicked(){ |
148 | QListViewItem *item = serviceList->currentItem(); | 148 | QListViewItem *item = serviceList->currentItem(); |
149 | if(item == NULL) { | 149 | if(item == NULL) { |
150 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); | 150 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); |
151 | return; | 151 | return; |
152 | } | 152 | } |
153 | 153 | ||
154 | if(modules.find(interfaceItems[item]) == modules.end()){ | 154 | if((interfaceItems[item])->getModuleOwner() == NULL){ |
155 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); | 155 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); |
156 | } | 156 | } |
157 | else{ | 157 | else{ |
158 | // Try to remove. | 158 | // Try to remove. |
159 | } | 159 | } |
160 | 160 | ||
161 | } | 161 | } |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * See if there is a configuration for the selected protocal. | 164 | * See if there is a configuration for the selected protocal. |
165 | * Prompt with errors. | 165 | * Prompt with errors. |
166 | */ | 166 | */ |
167 | void MainWindowImp::configureClicked(){ | 167 | void MainWindowImp::configureClicked(){ |
168 | QListViewItem *item = serviceList->currentItem(); | 168 | QListViewItem *item = serviceList->currentItem(); |
169 | if(item == NULL){ | 169 | if(item == NULL){ |
170 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); | 170 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); |
171 | return; | 171 | return; |
172 | } | 172 | } |
173 | 173 | ||
174 | if(modules.find(interfaceItems[item]) == modules.end()){ | 174 | if((interfaceItems[item])->getModuleOwner() == NULL){ |
175 | InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]); | 175 | InterfaceSetupImp *conf = new InterfaceSetupImp(0, "InterfaceConfiguration", interfaceItems[item]); |
176 | conf->showMaximized(); | 176 | conf->showMaximized(); |
177 | conf->show(); | 177 | conf->show(); |
178 | } | 178 | } |
179 | else{ | 179 | else{ |
180 | InterfaceSetupImp *conf = new InterfaceSetupImp(this, "InterfaceConfiguration"); | 180 | QTabWidget *t = NULL; |
181 | conf->show(); | 181 | QWidget *conf = (interfaceItems[item])->getModuleOwner()->configure(&t); |
182 | if(conf != NULL){ | ||
183 | qDebug("Conf found"); | ||
184 | if(t != NULL){ | ||
185 | qDebug("Adding Interface"); | ||
186 | InterfaceSetupImp *i = new InterfaceSetupImp(t, "TCPIPInformation", interfaceItems[item], true); | ||
187 | t->insertTab(i, "TCP/IP"); | ||
188 | } | ||
189 | conf->showMaximized(); | ||
190 | conf->show(); | ||
191 | } | ||
192 | else{ | ||
193 | InterfaceSetupImp *i = new InterfaceSetupImp(0, "TCPIPInformation", interfaceItems[item], true); | ||
194 | i->showMaximized(); | ||
195 | i->show(); | ||
196 | } | ||
182 | } | 197 | } |
183 | } | 198 | } |
184 | 199 | ||
185 | /** | 200 | /** |
186 | * Pull up the information about the selected interface | 201 | * Pull up the information about the selected interface |
187 | * Report an error | 202 | * Report an error |
188 | */ | 203 | */ |
189 | void MainWindowImp::informationClicked(){ | 204 | void MainWindowImp::informationClicked(){ |
190 | QListViewItem *item = serviceList->currentItem(); | 205 | QListViewItem *item = serviceList->currentItem(); |
191 | if(item == NULL){ | 206 | if(item == NULL){ |
192 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); | 207 | QMessageBox::information(this, "Error","Please select an interface.", "Ok"); |
193 | return; | 208 | return; |
194 | } | 209 | } |
195 | 210 | ||
196 | if(modules.find(interfaceItems[item]) == modules.end()){ | 211 | if( (interfaceItems[item])->getModuleOwner() == NULL){ |
197 | InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]); | 212 | InterfaceInformationImp *i = new InterfaceInformationImp(0, "InterfaceInformationImp", interfaceItems[item]); |
198 | i->showMaximized(); | 213 | i->showMaximized(); |
199 | i->show(); | 214 | i->show(); |
200 | } | 215 | } |
201 | else{ | 216 | else{ |
202 | QTabWidget *t = new QTabWidget(this, "InterfaceInformationTAB"); | 217 | QTabWidget *t = NULL; |
203 | InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true); | 218 | QWidget *conf = (interfaceItems[item])->getModuleOwner()->information(&t); |
204 | t->insertTab(i, "TCP/IP"); | 219 | if(conf != NULL){ |
205 | t->show(); | 220 | if(t){ |
221 | qDebug("Adding Interface"); | ||
222 | InterfaceInformationImp *i = new InterfaceInformationImp(t, "TCPIPInformation", interfaceItems[item], true); | ||
223 | t->insertTab(i, "TCP/IP"); | ||
224 | } | ||
225 | conf->showMaximized(); | ||
226 | conf->show(); | ||
227 | } | ||
228 | else{ | ||
229 | InterfaceInformationImp *i = new InterfaceInformationImp(0, "TCPIPInformation", interfaceItems[item], true); | ||
230 | i->showMaximized(); | ||
231 | i->show(); | ||
232 | } | ||
206 | } | 233 | } |
207 | } | 234 | } |
208 | 235 | ||
209 | /** | 236 | /** |
210 | * Aquire the list of active interfaces from ifconfig | 237 | * Aquire the list of active interfaces from ifconfig |
211 | * Call ifconfig and ifconfig -a | 238 | * Call ifconfig and ifconfig -a |
212 | */ | 239 | */ |
213 | void MainWindowImp::getInterfaceList(){ | 240 | void MainWindowImp::getInterfaceList(){ |
214 | KShellProcess *processAll = new KShellProcess(); | 241 | KShellProcess *processAll = new KShellProcess(); |
215 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; | 242 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; |
216 | connect(processAll, SIGNAL(processExited(KProcess *)), | 243 | connect(processAll, SIGNAL(processExited(KProcess *)), |
217 | this, SLOT(jobDone(KProcess *))); | 244 | this, SLOT(jobDone(KProcess *))); |
@@ -277,47 +304,53 @@ void MainWindowImp::jobDone(KProcess *process){ | |||
277 | } | 304 | } |
278 | file.close(); | 305 | file.close(); |
279 | QFile::remove(fileName); | 306 | QFile::remove(fileName); |
280 | } | 307 | } |
281 | 308 | ||
282 | void MainWindowImp::updateInterface(Interface *i){ | 309 | void MainWindowImp::updateInterface(Interface *i){ |
283 | QListViewItem *item = NULL; | 310 | QListViewItem *item = NULL; |
284 | 311 | ||
285 | // See if we already have it | 312 | // See if we already have it |
286 | if(items.find(i) == items.end()){ | 313 | if(items.find(i) == items.end()){ |
287 | item = new QListViewItem(serviceList, "", "", ""); | 314 | item = new QListViewItem(serviceList, "", "", ""); |
288 | // See if you can't find a module owner for this interface | 315 | // See if you can't find a module owner for this interface |
289 | //EmployeeMap::Iterator it; | 316 | QMap<Module*, QLibrary*>::Iterator it; |
290 | //for( it = map.begin(); it != map.end(); ++it ) | 317 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
291 | // printf( "%s, %s earns %d\n", it.key().latin1(), it.data().name().latin1(), it.data().salary() ); | 318 | if(it.key()->isOwner(i)) |
292 | 319 | i->setModuleOwner(it.key()); | |
320 | } | ||
321 | |||
293 | items.insert(i, item); | 322 | items.insert(i, item); |
294 | interfaceItems.insert(item, i); | 323 | interfaceItems.insert(item, i); |
295 | } | 324 | } |
296 | else | 325 | else |
297 | item = items[i]; | 326 | item = items[i]; |
298 | 327 | ||
299 | QString statusImage = "down"; | 328 | QString statusImage = "down"; |
300 | if(i->getStatus()) | 329 | if(i->getStatus()) |
301 | statusImage = "up"; | 330 | statusImage = "up"; |
302 | QPixmap status = (Resource::loadPixmap(statusImage)); | 331 | QPixmap status = (Resource::loadPixmap(statusImage)); |
303 | item->setPixmap(0, status); | 332 | item->setPixmap(0, status); |
304 | 333 | ||
305 | QString typeName = "lan"; | 334 | QString typeName = "lan"; |
306 | if(i->getHardwareName().contains("Local Loopback")) | 335 | if(i->getHardwareName().contains("Local Loopback")) |
307 | typeName = "lo"; | 336 | typeName = "lo"; |
308 | if(i->getInterfaceName().contains("irda")) | 337 | if(i->getInterfaceName().contains("irda")) |
309 | typeName = "irda"; | 338 | typeName = "irda"; |
310 | if(i->getInterfaceName().contains("wlan")) | 339 | if(i->getInterfaceName().contains("wlan")) |
311 | typeName = "wlan"; | 340 | typeName = "wlan"; |
341 | // Actually try to use the Module | ||
342 | if(i->getModuleOwner() != NULL){ | ||
343 | typeName = i->getModuleOwner()->getPixmapName(i); | ||
344 | } | ||
312 | QPixmap type = (Resource::loadPixmap(typeName)); | 345 | QPixmap type = (Resource::loadPixmap(typeName)); |
313 | item->setPixmap(1, type); | 346 | item->setPixmap(1, type); |
314 | 347 | ||
315 | item->setText(2, i->getHardwareName()); | 348 | item->setText(2, i->getHardwareName()); |
316 | 349 | ||
317 | } | 350 | } |
318 | 351 | ||
319 | /** | 352 | /** |
320 | * Adds a new profile to the list of profiles. | 353 | * Adds a new profile to the list of profiles. |
321 | * Don't add profiles that already exists. | 354 | * Don't add profiles that already exists. |
322 | * Appends to the combo and QStringList | 355 | * Appends to the combo and QStringList |
323 | */ | 356 | */ |