Diffstat (limited to 'noncore/settings/networksettings/mainwindow/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp index fb7d7c9..5f23aea 100644 --- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | |||
@@ -195,193 +195,193 @@ void MainWindowImp::getAllInterfaces() | |||
195 | { | 195 | { |
196 | if((loc = line.find(":")) != -1) | 196 | if((loc = line.find(":")) != -1) |
197 | { | 197 | { |
198 | ifaces += line.left(loc); | 198 | ifaces += line.left(loc); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) | 203 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) |
204 | { | 204 | { |
205 | int flags = 0; | 205 | int flags = 0; |
206 | if ( m_handledIfaces.contains( (*it) ) ) | 206 | if ( m_handledIfaces.contains( (*it) ) ) |
207 | { | 207 | { |
208 | odebug << " " << (*it).latin1() << " is handled by a module" << oendl; | 208 | odebug << " " << (*it).latin1() << " is handled by a module" << oendl; |
209 | continue; | 209 | continue; |
210 | } | 210 | } |
211 | // int family; | 211 | // int family; |
212 | i = NULL; | 212 | i = NULL; |
213 | 213 | ||
214 | strcpy(ifr.ifr_name, (*it).latin1()); | 214 | strcpy(ifr.ifr_name, (*it).latin1()); |
215 | 215 | ||
216 | struct ifreq ifcopy; | 216 | struct ifreq ifcopy; |
217 | ifcopy = ifr; | 217 | ifcopy = ifr; |
218 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | 218 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); |
219 | flags = ifcopy.ifr_flags; | 219 | flags = ifcopy.ifr_flags; |
220 | i = new Interface(this, ifr.ifr_name, false); | 220 | i = new Interface(this, ifr.ifr_name, false); |
221 | i->setAttached(true); | 221 | i->setAttached(true); |
222 | if ((flags & IFF_UP) == IFF_UP) | 222 | if ((flags & IFF_UP) == IFF_UP) |
223 | i->setStatus(true); | 223 | i->setStatus(true); |
224 | else | 224 | else |
225 | i->setStatus(false); | 225 | i->setStatus(false); |
226 | 226 | ||
227 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | 227 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) |
228 | i->setHardwareName("Ethernet"); | 228 | i->setHardwareName("Ethernet"); |
229 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | 229 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) |
230 | i->setHardwareName("Point to Point"); | 230 | i->setHardwareName("Point to Point"); |
231 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | 231 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) |
232 | i->setHardwareName("Multicast"); | 232 | i->setHardwareName("Multicast"); |
233 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | 233 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) |
234 | i->setHardwareName("Loopback"); | 234 | i->setHardwareName("Loopback"); |
235 | else | 235 | else |
236 | i->setHardwareName("Unknown"); | 236 | i->setHardwareName("Unknown"); |
237 | 237 | ||
238 | owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl; | 238 | owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl; |
239 | interfaceNames.insert(i->getInterfaceName(), i); | 239 | interfaceNames.insert(i->getInterfaceName(), i); |
240 | updateInterface(i); | 240 | updateInterface(i); |
241 | connect(i, SIGNAL(updateInterface(Interface*)), | 241 | connect(i, SIGNAL(updateInterface(Interface*)), |
242 | this, SLOT(updateInterface(Interface*))); | 242 | this, SLOT(updateInterface(Interface*))); |
243 | } | 243 | } |
244 | // now lets ask the plugins too ;) | 244 | // now lets ask the plugins too ;) |
245 | QMap<Module*, QLibrary*>::Iterator it; | 245 | QMap<Module*, QLibrary*>::Iterator it; |
246 | QList<Interface> ilist; | 246 | QList<Interface> ilist; |
247 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 247 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
248 | { | 248 | { |
249 | if(it.key()) | 249 | if(it.key()) |
250 | { | 250 | { |
251 | ilist = it.key()->getInterfaces(); | 251 | ilist = it.key()->getInterfaces(); |
252 | for( i = ilist.first(); i != 0; i = ilist.next() ) | 252 | for( i = ilist.first(); i != 0; i = ilist.next() ) |
253 | { | 253 | { |
254 | owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl; | 254 | owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl; |
255 | interfaceNames.insert(i->getInterfaceName(), i); | 255 | interfaceNames.insert(i->getInterfaceName(), i); |
256 | updateInterface(i); | 256 | updateInterface(i); |
257 | connect(i, SIGNAL(updateInterface(Interface*)), | 257 | connect(i, SIGNAL(updateInterface(Interface*)), |
258 | this, SLOT(updateInterface(Interface*))); | 258 | this, SLOT(updateInterface(Interface*))); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | /** | 264 | /** |
265 | * Load all modules that are found in the path | 265 | * Load all modules that are found in the path |
266 | * @param path a directory that is scaned for any plugins that can be loaded | 266 | * @param path a directory that is scaned for any plugins that can be loaded |
267 | * and attempts to load them | 267 | * and attempts to load them |
268 | */ | 268 | */ |
269 | void MainWindowImp::loadModules(const QString &path) | 269 | void MainWindowImp::loadModules(const QString &path) |
270 | { | 270 | { |
271 | #ifdef DEBUG | 271 | #ifdef DEBUG |
272 | odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; | 272 | odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; |
273 | #endif | 273 | #endif |
274 | QDir d(path); | 274 | QDir d(path); |
275 | if(!d.exists()) | 275 | if(!d.exists()) |
276 | return; | 276 | return; |
277 | 277 | ||
278 | QString lang = ::getenv("LANG"); | 278 | QString lang = ::getenv("LANG"); |
279 | // Don't want sym links | 279 | // Don't want sym links |
280 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 280 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
281 | const QFileInfoList *list = d.entryInfoList(); | 281 | const QFileInfoList *list = d.entryInfoList(); |
282 | QFileInfoListIterator it( *list ); | 282 | QFileInfoListIterator it( *list ); |
283 | QFileInfo *fi; | 283 | QFileInfo *fi; |
284 | while ( (fi=it.current()) ) | 284 | while ( (fi=it.current()) ) |
285 | { | 285 | { |
286 | if(fi->fileName().contains(".so")) | 286 | if(fi->fileName().contains(".so")) |
287 | { | 287 | { |
288 | /* if loaded install translation */ | 288 | /* if loaded install translation */ |
289 | if( loadPlugin(path + "/" + fi->fileName()) != 0l ){ | 289 | if( loadPlugin(path + "/" + fi->fileName()) != 0l ){ |
290 | QTranslator *trans = new QTranslator(qApp); | 290 | QTranslator *trans = new QTranslator(qApp); |
291 | QString fn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm"; | 291 | QString fn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm"; |
292 | if( trans->load( fn ) ) | 292 | if( trans->load( fn ) ) |
293 | qApp->installTranslator( trans ); | 293 | qApp->installTranslator( trans ); |
294 | else | 294 | else |
295 | delete trans; | 295 | delete trans; |
296 | } | 296 | } |
297 | odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl; | 297 | odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl; |
298 | } | 298 | } |
299 | ++it; | 299 | ++it; |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | /** | 303 | /** |
304 | * Attempt to load a function and resolve a function. | 304 | * Attempt to load a function and resolve a function. |
305 | * @param pluginFileName - the name of the file in which to attempt to load | 305 | * @param pluginFileName - the name of the file in which to attempt to load |
306 | * @param resolveString - function pointer to resolve | 306 | * @param resolveString - function pointer to resolve |
307 | * @return pointer to the function with name resolveString or NULL | 307 | * @return pointer to the function with name resolveString or NULL |
308 | */ | 308 | */ |
309 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) | 309 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) |
310 | { | 310 | { |
311 | #ifdef DEBUG | 311 | #ifdef DEBUG |
312 | odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl; | 312 | odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl; |
313 | #endif | 313 | #endif |
314 | QLibrary *lib = new QLibrary(pluginFileName); | 314 | QLibrary *lib = new QLibrary(pluginFileName); |
315 | void *functionPointer = lib->resolve(resolveString); | 315 | void *functionPointer = lib->resolve(resolveString); |
316 | if( !functionPointer ) | 316 | if( !functionPointer ) |
317 | { | 317 | { |
318 | #ifdef DEBUG | 318 | #ifdef DEBUG |
319 | odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl; | 319 | odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl; |
320 | #endif | 320 | #endif |
321 | delete lib; | 321 | delete lib; |
322 | return 0; | 322 | return 0; |
323 | } | 323 | } |
324 | // Try to get an object. | 324 | // Try to get an object. |
325 | Module *object = ((Module* (*)()) functionPointer)(); | 325 | Module *object = ((Module* (*)()) functionPointer)(); |
326 | if(object == 0) | 326 | if(object == 0) |
327 | { | 327 | { |
328 | #ifdef DEBUG | 328 | #ifdef DEBUG |
329 | odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; | 329 | odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; |
330 | #endif | 330 | #endif |
331 | delete lib; | 331 | delete lib; |
332 | return 0; | 332 | return 0; |
333 | } | 333 | } |
334 | 334 | ||
335 | m_handledIfaces += object->handledInterfaceNames(); | 335 | m_handledIfaces += object->handledInterfaceNames(); |
336 | // Store for deletion later | 336 | // Store for deletion later |
337 | libraries.insert(object, lib); | 337 | libraries.insert(object, lib); |
338 | return object; | 338 | return object; |
339 | } | 339 | } |
340 | 340 | ||
341 | /** | 341 | /** |
342 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 342 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
343 | * load the plugin and append it to the list | 343 | * load the plugin and append it to the list |
344 | */ | 344 | */ |
345 | void MainWindowImp::addClicked() | 345 | void MainWindowImp::addClicked() |
346 | { | 346 | { |
347 | QMap<Module*, QLibrary*>::Iterator it; | 347 | QMap<Module*, QLibrary*>::Iterator it; |
348 | QMap<QString, QString> list; | 348 | QMap<QString, QString> list; |
349 | QMap<QString, Module*> newInterfaceOwners; | 349 | QMap<QString, Module*> newInterfaceOwners; |
350 | 350 | ||
351 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 351 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
352 | { | 352 | { |
353 | if(it.key()) | 353 | if(it.key()) |
354 | { | 354 | { |
355 | (it.key())->possibleNewInterfaces(list); | 355 | (it.key())->possibleNewInterfaces(list); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | // See if the list has anything that we can add. | 358 | // See if the list has anything that we can add. |
359 | if(list.count() == 0) | 359 | if(list.count() == 0) |
360 | { | 360 | { |
361 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 361 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 364 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
365 | addNewConnection.addConnections(list); | 365 | addNewConnection.addConnections(list); |
366 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) | 366 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) |
367 | { | 367 | { |
368 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 368 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
369 | if(!item) | 369 | if(!item) |
370 | return; | 370 | return; |
371 | 371 | ||
372 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 372 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
373 | { | 373 | { |
374 | if(it.key()) | 374 | if(it.key()) |
375 | { | 375 | { |
376 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 376 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
377 | if(i) | 377 | if(i) |
378 | { | 378 | { |
379 | odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl; | 379 | odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl; |
380 | interfaceNames.insert(i->getInterfaceName(), i); | 380 | interfaceNames.insert(i->getInterfaceName(), i); |
381 | updateInterface(i); | 381 | updateInterface(i); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||