-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index a61f620..63b9603 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp @@ -148,24 +148,25 @@ MainWindowImp::~MainWindowImp(){ /** * Query the kernel for all of the interfaces. */ void MainWindowImp::getAllInterfaces(){ int sockfd = socket(PF_INET, SOCK_DGRAM, 0); if(sockfd == -1) return; struct ifreq ifr; QStringList ifaces; QFile procFile(QString(_PROCNETDEV)); int result; + Interface *i; if (! procFile.exists()) { struct ifreq ifrs[100]; struct ifconf ifc; ifc.ifc_len = sizeof(ifrs); ifc.ifc_req = ifrs; result = ioctl(sockfd, SIOCGIFCONF, &ifc); for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { struct ifreq *pifr = &ifrs[i]; ifaces += pifr->ifr_name; @@ -178,25 +179,25 @@ void MainWindowImp::getAllInterfaces(){ procTs.readLine(); // eat a line procTs.readLine(); // eat a line while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { if((loc = line.find(":")) != -1) { ifaces += line.left(loc); } } } for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { int flags = 0, family; - Interface *i = NULL; + i = NULL; strcpy(ifr.ifr_name, (*it).latin1()); struct ifreq ifcopy; ifcopy = ifr; result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); flags = ifcopy.ifr_flags; i = new Interface(this, ifr.ifr_name, false); i->setAttached(true); if ((flags & IFF_UP) == IFF_UP) i->setStatus(true); else @@ -207,25 +208,41 @@ void MainWindowImp::getAllInterfaces(){ else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) i->setHardwareName("Point to Point"); else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) i->setHardwareName("Multicast"); else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) i->setHardwareName("Loopback"); else i->setHardwareName("Unknown"); qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); interfaceNames.insert(i->getInterfaceName(), i); updateInterface(i); - connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); + connect(i, SIGNAL(updateInterface(Interface *)), + this, SLOT(updateInterface(Interface *))); + } + // now lets ask the plugins too ;) + QMap<Module*, QLibrary*>::Iterator it; + QList<Interface> ilist; + for( it = libraries.begin(); it != libraries.end(); ++it ){ + if(it.key()){ + ilist = it.key()->getInterfaces(); + for( i = ilist.first(); i != 0; i = ilist.next() ){ + qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() ); + interfaceNames.insert(i->getInterfaceName(), i); + updateInterface(i); + connect(i, SIGNAL(updateInterface(Interface *)), + this, SLOT(updateInterface(Interface *))); + } + } } } /** * Load all modules that are found in the path * @param path a directory that is scaned for any plugins that can be loaded * and attempts to load them */ void MainWindowImp::loadModules(const QString &path){ #ifdef DEBUG qDebug("MainWindowImp::loadModules: %s", path.latin1()); #endif @@ -307,26 +324,25 @@ Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString & return object; #endif } /** * The Add button was clicked. Bring up the add dialog and if OK is hit * load the plugin and append it to the list */ void MainWindowImp::addClicked(){ QMap<Module*, QLibrary*>::Iterator it; QMap<QString, QString> list; QMap<QString, Module*> newInterfaceOwners; - //list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); - //list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); + for( it = libraries.begin(); it != libraries.end(); ++it ){ if(it.key()){ (it.key())->possibleNewInterfaces(list); } } // See if the list has anything that we can add. if(list.count() == 0){ QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); return; } AddConnectionImp addNewConnection(this, "AddConnectionImp", true); addNewConnection.addConnections(list); |