summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/mainwindow/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindow/mainwindowimp.cpp749
1 files changed, 749 insertions, 0 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
new file mode 100644
index 0000000..5184630
--- a/dev/null
+++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp
@@ -0,0 +1,749 @@
1
2#include "mainwindowimp.h"
3#include "addconnectionimp.h"
4#include "interfaceinformationimp.h"
5#include "interfacesetupimp.h"
6#include "interfaces.h"
7#include "module.h"
8
9/* OPIE */
10#include <opie2/odebug.h>
11#include <qpe/qcopenvelope_qws.h>
12#include <qpe/qpeapplication.h>
13#include <qpe/config.h>
14#include <qpe/qlibrary.h>
15#include <qpe/resource.h>
16
17/* QT */
18#include <qpushbutton.h>
19#include <qlistbox.h>
20#include <qlineedit.h>
21#include <qlistview.h>
22#include <qheader.h>
23#include <qlabel.h>
24#include <qtabwidget.h> // in order to disable the profiles tab
25#include <qmessagebox.h>
26
27
28#if QT_VERSION < 300
29#include <qlist.h>
30#else
31#include <qptrlist.h>
32#endif
33#include <qdir.h>
34#include <qfile.h>
35#include <qtextstream.h>
36#include <qregexp.h>
37
38/* STD */
39#include <net/if.h>
40#include <sys/ioctl.h>
41#include <sys/socket.h>
42
43#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
44#define _PROCNETDEV "/proc/net/dev"
45
46MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWindow(parent, name, Qt::WStyle_ContextHelp), advancedUserMode(true), scheme(DEFAULT_SCHEME)
47{
48 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
49 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
50 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
51 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
52
53 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
54 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
55 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
56
57 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
58
59 //FIXME: disable profiles for the moment:
60 tabWidget->setTabEnabled( tab, false );
61
62 // Load connections.
63 // /usr/local/kde/lib/libinterfaces.la
64#ifdef QWS
65 loadModules(QPEApplication::qpeDir() + "plugins/networksettings");
66#else
67 loader = KLibLoader::self();
68 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib"));
69#endif
70 getAllInterfaces();
71
72 Interfaces i;
73 QStringList list = i.getInterfaceList();
74 QMap<QString, Interface*>::Iterator it;
75 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni )
76 {
77 /*
78 * we skipped it in getAllInterfaces now
79 * we need to ignore it as well
80 */
81 if (m_handledIfaces.contains( *ni) )
82 {
83 odebug << "Not up iface handled by module" << oendl;
84 continue;
85 }
86 bool found = false;
87 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it )
88 {
89 if(it.key() == (*ni))
90 found = true;
91 }
92 if(!found)
93 {
94 if(!(*ni).contains("_"))
95 {
96 Interface *i = new Interface(this, *ni, false);
97 i->setAttached(false);
98 i->setHardwareName(tr("Disconnected"));
99 interfaceNames.insert(i->getInterfaceName(), i);
100 updateInterface(i);
101 connect(i, SIGNAL(updateInterface(Interface*)), this, SLOT(updateInterface(Interface*)));
102 }
103 }
104 }
105
106 //getInterfaceList();
107 connectionList->header()->hide();
108
109 Config cfg("NetworkSetup");
110 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
111 for ( QStringList::Iterator it = profiles.begin();
112 it != profiles.end(); ++it)
113 profilesList->insertItem((*it));
114 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
115 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
116 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
117
118 QFile file(scheme);
119 if ( file.open(IO_ReadOnly) )
120 { // file opened successfully
121 QTextStream stream( &file ); // use a text stream
122 while ( !stream.eof() )
123 { // until end of file...
124 QString line = stream.readLine(); // line of text excluding '\n'
125 if(line.contains("SCHEME"))
126 {
127 line = line.mid(7, line.length());
128 currentProfileLabel->setText(line);
129 break;
130 }
131 }
132 file.close();
133 }
134 makeChannel();
135}
136
137/**
138 * Deconstructor. Save profiles. Delete loaded libraries.
139 */
140MainWindowImp::~MainWindowImp()
141{
142 // Save profiles.
143 Config cfg("NetworkSetup");
144 cfg.setGroup("General");
145 cfg.writeEntry("Profiles", profiles.join(" "));
146
147 // Delete all interfaces that don't have owners.
148 QMap<Interface*, QListViewItem*>::Iterator iIt;
149 for( iIt = items.begin(); iIt != items.end(); ++iIt )
150 {
151 if(iIt.key()->getModuleOwner() == NULL)
152 delete iIt.key();
153 }
154
155#ifdef QWS
156 // Delete Modules and Libraries
157 QMap<Module*, QLibrary*>::Iterator it;
158 for( it = libraries.begin(); it != libraries.end(); ++it )
159 {
160 delete it.key();
161 // I wonder why I can't delete the libraries
162 // What fucking shit this is.
163 //delete it.data();
164 }
165#else
166 // klibloader automaticly deletes the libraries for us...
167#endif
168}
169
170/**
171 * Query the kernel for all of the interfaces.
172 */
173void MainWindowImp::getAllInterfaces()
174{
175 int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
176 if(sockfd == -1)
177 return;
178
179 struct ifreq ifr;
180 QStringList ifaces;
181 QFile procFile(QString(_PROCNETDEV));
182 int result;
183 Interface *i;
184
185 if (! procFile.exists())
186 {
187 struct ifreq ifrs[100];
188 struct ifconf ifc;
189 ifc.ifc_len = sizeof(ifrs);
190 ifc.ifc_req = ifrs;
191 result = ioctl(sockfd, SIOCGIFCONF, &ifc);
192
193 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++)
194 {
195 struct ifreq *pifr = &ifrs[i];
196
197 ifaces += pifr->ifr_name;
198 }
199 }
200 else
201 {
202 procFile.open(IO_ReadOnly);
203 QString line;
204 QTextStream procTs(&procFile);
205 int loc = -1;
206
207 procTs.readLine(); // eat a line
208 procTs.readLine(); // eat a line
209 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null)
210 {
211 if((loc = line.find(":")) != -1)
212 {
213 ifaces += line.left(loc);
214 }
215 }
216 }
217
218 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it)
219 {
220 int flags = 0;
221 if ( m_handledIfaces.contains( (*it) ) )
222 {
223 odebug << " " << (*it).latin1() << " is handled by a module" << oendl;
224 continue;
225 }
226 // int family;
227 i = NULL;
228
229 strcpy(ifr.ifr_name, (*it).latin1());
230
231 struct ifreq ifcopy;
232 ifcopy = ifr;
233 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
234 flags = ifcopy.ifr_flags;
235 i = new Interface(this, ifr.ifr_name, false);
236 i->setAttached(true);
237 if ((flags & IFF_UP) == IFF_UP)
238 i->setStatus(true);
239 else
240 i->setStatus(false);
241
242 if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
243 i->setHardwareName("Ethernet");
244 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
245 i->setHardwareName("Point to Point");
246 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
247 i->setHardwareName("Multicast");
248 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
249 i->setHardwareName("Loopback");
250 else
251 i->setHardwareName("Unknown");
252
253 owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl;
254 interfaceNames.insert(i->getInterfaceName(), i);
255 updateInterface(i);
256 connect(i, SIGNAL(updateInterface(Interface*)),
257 this, SLOT(updateInterface(Interface*)));
258 }
259 // now lets ask the plugins too ;)
260 QMap<Module*, QLibrary*>::Iterator it;
261 QList<Interface> ilist;
262 for( it = libraries.begin(); it != libraries.end(); ++it )
263 {
264 if(it.key())
265 {
266 ilist = it.key()->getInterfaces();
267 for( i = ilist.first(); i != 0; i = ilist.next() )
268 {
269 owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl;
270 interfaceNames.insert(i->getInterfaceName(), i);
271 updateInterface(i);
272 connect(i, SIGNAL(updateInterface(Interface*)),
273 this, SLOT(updateInterface(Interface*)));
274 }
275 }
276 }
277}
278
279/**
280 * Load all modules that are found in the path
281 * @param path a directory that is scaned for any plugins that can be loaded
282 * and attempts to load them
283 */
284void MainWindowImp::loadModules(const QString &path)
285{
286#ifdef DEBUG
287 odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl;
288#endif
289 QDir d(path);
290 if(!d.exists())
291 return;
292
293 // Don't want sym links
294 d.setFilter( QDir::Files | QDir::NoSymLinks );
295 const QFileInfoList *list = d.entryInfoList();
296 QFileInfoListIterator it( *list );
297 QFileInfo *fi;
298 while ( (fi=it.current()) )
299 {
300#ifdef QWS
301 if(fi->fileName().contains(".so"))
302 {
303#else
304 if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_"))
305 {
306#endif
307 loadPlugin(path + "/" + fi->fileName());
308 odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl;
309 }
310 ++it;
311 }
312}
313
314/**
315 * Attempt to load a function and resolve a function.
316 * @param pluginFileName - the name of the file in which to attempt to load
317 * @param resolveString - function pointer to resolve
318 * @return pointer to the function with name resolveString or NULL
319 */
320Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString)
321{
322#ifdef DEBUG
323 odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl;
324#endif
325#ifdef QWS
326 QLibrary *lib = new QLibrary(pluginFileName);
327 void *functionPointer = lib->resolve(resolveString);
328 if( !functionPointer )
329 {
330#ifdef DEBUG
331 odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl;
332#endif
333 delete lib;
334 return NULL;
335 }
336 // Try to get an object.
337 Module *object = ((Module* (*)()) functionPointer)();
338 if(object == NULL)
339 {
340#ifdef DEBUG
341 odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl;
342#endif
343 delete lib;
344 return NULL;
345 }
346
347 m_handledIfaces += object->handledInterfaceNames();
348 // Store for deletion later
349 libraries.insert(object, lib);
350 return object;
351
352#else
353 QLibrary *lib = loader->library(pluginFileName);
354 if( !lib || !lib->hasSymbol(resolveString) )
355 {
356 odebug << QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1() << oendl;
357 return NULL;
358 }
359 // Try to get an object.
360 Module *object = ((Module* (*)()) lib->symbol(resolveString))();
361 if(object == NULL)
362 {
363#ifdef DEBUG
364 odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl;
365#endif
366 return NULL;
367 }
368#ifdef DEBUG
369 odebug << "MainWindowImp::loadPlugin:: Found object, storing." << oendl;
370#endif
371 // Store for deletion later
372 libraries.insert(object, lib);
373 return object;
374#endif
375}
376
377/**
378 * The Add button was clicked. Bring up the add dialog and if OK is hit
379 * load the plugin and append it to the list
380 */
381void MainWindowImp::addClicked()
382{
383 QMap<Module*, QLibrary*>::Iterator it;
384 QMap<QString, QString> list;
385 QMap<QString, Module*> newInterfaceOwners;
386
387 for( it = libraries.begin(); it != libraries.end(); ++it )
388 {
389 if(it.key())
390 {
391 (it.key())->possibleNewInterfaces(list);
392 }
393 }
394 // See if the list has anything that we can add.
395 if(list.count() == 0)
396 {
397 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
398 return;
399 }
400 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
401 addNewConnection.addConnections(list);
402 if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) )
403 {
404 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
405 if(!item)
406 return;
407
408 for( it = libraries.begin(); it != libraries.end(); ++it )
409 {
410 if(it.key())
411 {
412 Interface *i = (it.key())->addNewInterface(item->text(0));
413 if(i)
414 {
415 odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl;
416 interfaceNames.insert(i->getInterfaceName(), i);
417 updateInterface(i);
418 }
419 }
420 }
421 }
422}
423
424/**
425 * Prompt the user to see if they really want to do this.
426 * If they do then remove from the list and unload.
427 */
428void MainWindowImp::removeClicked()
429{
430 QListViewItem *item = connectionList->currentItem();
431 if(!item)
432 {
433 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
434 return;
435 }
436
437 Interface *i = interfaceItems[item];
438 if(i->getModuleOwner() == NULL)
439 {
440 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
441 }
442 else
443 {
444 if(!i->getModuleOwner()->remove(i))
445 QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok);
446 else
447 {
448 delete item;
449 // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
450 }
451 }
452}
453
454/**
455 * Pull up the configure about the currently selected interface.
456 * Report an error if no interface is selected.
457 * If the interface has a module owner then request its configure.
458 */
459void MainWindowImp::configureClicked()
460{
461 QListViewItem *item = connectionList->currentItem();
462 if(!item)
463 {
464 QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok);
465 return;
466 }
467
468 QString currentProfileText = currentProfileLabel->text();
469 if(currentProfileText.upper() == "ALL");
470 currentProfileText = "";
471
472 Interface *i = interfaceItems[item];
473
474 if(i->getModuleOwner())
475 {
476 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
477 if(moduleConfigure != NULL)
478 {
479 i->getModuleOwner()->setProfile(currentProfileText);
480 QPEApplication::showWidget( moduleConfigure );
481 return;
482 }
483 }
484
485 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp );
486 configure->setProfile(currentProfileText);
487 QPEApplication::showDialog( configure );
488}
489
490/**
491 * Pull up the information about the currently selected interface.
492 * Report an error if no interface is selected.
493 * If the interface has a module owner then request its configure.
494 */
495void MainWindowImp::informationClicked()
496{
497 QListViewItem *item = connectionList->currentItem();
498 if(!item)
499 {
500 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
501 return;
502 }
503
504 Interface *i = interfaceItems[item];
505 // if(!i->isAttached()){
506 // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
507 // return;
508 // }
509
510 if(i->getModuleOwner())
511 {
512 QWidget *moduleInformation = i->getModuleOwner()->information(i);
513 if(moduleInformation != NULL)
514 {
515 QPEApplication::showWidget( moduleInformation );
516#ifdef DEBUG
517 odebug << "MainWindowImp::informationClicked:: Module owner has created, we showed." << oendl;
518#endif
519 return;
520 }
521 }
522 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog | Qt::WStyle_ContextHelp);
523 QPEApplication::showWidget( information );
524}
525
526/**
527 * Update this interface. If no QListViewItem exists create one.
528 * @param Interface* pointer to the interface that needs to be updated.
529 */
530void MainWindowImp::updateInterface(Interface *i)
531{
532 if(!advancedUserMode)
533 {
534 if(i->getInterfaceName() == "lo")
535 return;
536 }
537
538 QListViewItem *item = NULL;
539
540 // Find the interface, making it if needed.
541 if(items.find(i) == items.end())
542 {
543 item = new QListViewItem(connectionList, "", "", "");
544 // See if you can't find a module owner for this interface
545 QMap<Module*, QLibrary*>::Iterator it;
546 for( it = libraries.begin(); it != libraries.end(); ++it )
547 {
548 if(it.key()->isOwner(i))
549 i->setModuleOwner(it.key());
550 }
551 items.insert(i, item);
552 interfaceItems.insert(item, i);
553 }
554 else
555 item = items[i];
556
557 // Update the icons and information
558#ifdef QWS
559 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
560#else
561 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down")));
562#endif
563
564 QString typeName = "lan";
565 if(i->getInterfaceName() == "lo")
566 typeName = "lo";
567 if(i->getInterfaceName().contains("irda"))
568 typeName = "irda";
569 if(i->getInterfaceName().contains("wlan"))
570 typeName = "wlan";
571 if(i->getInterfaceName().contains("usb"))
572 typeName = "usb";
573
574 if(!i->isAttached())
575 typeName = "connect_no";
576 // Actually try to use the Module
577 if(i->getModuleOwner() != NULL)
578 typeName = i->getModuleOwner()->getPixmapName(i);
579
580#ifdef QWS
581 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName)));
582#else
583 item->setPixmap(1, (SmallIcon(typeName)));
584#endif
585 item->setText(2, i->getHardwareName());
586 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
587 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
588}
589
590void MainWindowImp::newProfileChanged(const QString& newText)
591{
592 if(newText.length() > 0)
593 newProfileButton->setEnabled(true);
594 else
595 newProfileButton->setEnabled(false);
596}
597
598/**
599 * Adds a new profile to the list of profiles.
600 * Don't add profiles that already exists.
601 * Appends to the list and QStringList
602 */
603void MainWindowImp::addProfile()
604{
605 QString newProfileName = newProfile->text();
606 if(profiles.grep(newProfileName).count() > 0)
607 {
608 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
609 return;
610 }
611 profiles.append(newProfileName);
612 profilesList->insertItem(newProfileName);
613}
614
615/**
616 * Removes the currently selected profile in the combo.
617 * Doesn't delete if there are less then 2 profiles.
618 */
619void MainWindowImp::removeProfile()
620{
621 if(profilesList->count() <= 1)
622 {
623 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
624 return;
625 }
626 QString profileToRemove = profilesList->currentText();
627 if(profileToRemove == "All")
628 {
629 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
630 return;
631 }
632 // Can't remove the curent profile
633 if(profileToRemove == currentProfileLabel->text())
634 {
635 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
636 return;
637
638 }
639
640 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
641 {
642 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
643 profilesList->clear();
644 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
645 profilesList->insertItem((*it));
646
647 // Remove any interface settings and mappings.
648 Interfaces interfaces;
649 // Go through them one by one
650 QMap<Interface*, QListViewItem*>::Iterator it;
651 for( it = items.begin(); it != items.end(); ++it )
652 {
653 QString interfaceName = it.key()->getInterfaceName();
654 odebug << interfaceName.latin1() << oendl;
655 if(interfaces.setInterface(interfaceName + "_" + profileToRemove))
656 {
657 interfaces.removeInterface();
658 if(interfaces.setMapping(interfaceName))
659 {
660 if(profilesList->count() == 1)
661 interfaces.removeMapping();
662 else
663 {
664 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
665 }
666 }
667 interfaces.write();
668 break;
669 }
670 }
671 }
672}
673
674/**
675 * A new profile has been selected, change.
676 * @param newProfile the new profile.
677 */
678void MainWindowImp::changeProfile()
679{
680 if(profilesList->currentItem() == -1)
681 {
682 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
683 return;
684 }
685 QString newProfile = profilesList->text(profilesList->currentItem());
686 if(newProfile != currentProfileLabel->text())
687 {
688 currentProfileLabel->setText(newProfile);
689 QFile::remove(scheme);
690 QFile file(scheme);
691 if ( file.open(IO_ReadWrite) )
692 {
693 QTextStream stream( &file );
694 stream << QString("SCHEME=%1").arg(newProfile);
695 file.close();
696 }
697 // restart all up devices?
698 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok)
699 {
700 // Go through them one by one
701 QMap<Interface*, QListViewItem*>::Iterator it;
702 for( it = items.begin(); it != items.end(); ++it )
703 {
704 if(it.key()->getStatus() == true)
705 it.key()->restart();
706 }
707 }
708 }
709 // TODO change the profile in the modules
710}
711
712
713void MainWindowImp::makeChannel()
714{
715 channel = new QCopChannel( "QPE/Application/networksettings", this );
716 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
717 this, SLOT(receive(const QCString&,const QByteArray&)) );
718}
719
720void MainWindowImp::receive(const QCString &msg, const QByteArray &arg)
721{
722 bool found = false;
723 odebug << "MainWindowImp::receive QCop msg >"+msg+"<" << oendl;
724 if (msg == "raise")
725 {
726 raise();
727 return;
728 }
729
730 QString dest = msg.left(msg.find("("));
731 QCString param = msg.right(msg.length() - msg.find("(") - 1);
732 param = param.left( param.length() - 1 );
733 odebug << "dest >" << dest.latin1() << "< param >"+param+"<" << oendl;
734
735 QMap<Module*, QLibrary*>::Iterator it;
736 for( it = libraries.begin(); it != libraries.end(); ++it )
737 {
738 odebug << "plugin >" << it.key()->type().latin1() << "<" << oendl;
739 if(it.key()->type() == dest)
740 {
741 it.key()->receive( param, arg );
742 found = true;
743 }
744 }
745
746
747 if (found) QPEApplication::setKeepRunning();
748 else odebug << "Huh what do ya want" << oendl;
749}