summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings
Unidiff
Diffstat (limited to 'noncore/settings/networksettings') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp24
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(){
148/** 148/**
149 * Query the kernel for all of the interfaces. 149 * Query the kernel for all of the interfaces.
150 */ 150 */
151void MainWindowImp::getAllInterfaces(){ 151void MainWindowImp::getAllInterfaces(){
152 int sockfd = socket(PF_INET, SOCK_DGRAM, 0); 152 int sockfd = socket(PF_INET, SOCK_DGRAM, 0);
153 if(sockfd == -1) 153 if(sockfd == -1)
154 return; 154 return;
155 155
156 struct ifreq ifr; 156 struct ifreq ifr;
157 QStringList ifaces; 157 QStringList ifaces;
158 QFile procFile(QString(_PROCNETDEV)); 158 QFile procFile(QString(_PROCNETDEV));
159 int result; 159 int result;
160 Interface *i;
160 161
161 if (! procFile.exists()) { 162 if (! procFile.exists()) {
162 struct ifreq ifrs[100]; 163 struct ifreq ifrs[100];
163 struct ifconf ifc; 164 struct ifconf ifc;
164 ifc.ifc_len = sizeof(ifrs); 165 ifc.ifc_len = sizeof(ifrs);
165 ifc.ifc_req = ifrs; 166 ifc.ifc_req = ifrs;
166 result = ioctl(sockfd, SIOCGIFCONF, &ifc); 167 result = ioctl(sockfd, SIOCGIFCONF, &ifc);
167 168
168 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { 169 for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) {
169 struct ifreq *pifr = &ifrs[i]; 170 struct ifreq *pifr = &ifrs[i];
170 171
171 ifaces += pifr->ifr_name; 172 ifaces += pifr->ifr_name;
@@ -178,25 +179,25 @@ void MainWindowImp::getAllInterfaces(){
178 179
179 procTs.readLine(); // eat a line 180 procTs.readLine(); // eat a line
180 procTs.readLine(); // eat a line 181 procTs.readLine(); // eat a line
181 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { 182 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) {
182 if((loc = line.find(":")) != -1) { 183 if((loc = line.find(":")) != -1) {
183 ifaces += line.left(loc); 184 ifaces += line.left(loc);
184 } 185 }
185 } 186 }
186 } 187 }
187 188
188 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { 189 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) {
189 int flags = 0, family; 190 int flags = 0, family;
190 Interface *i = NULL; 191 i = NULL;
191 192
192 strcpy(ifr.ifr_name, (*it).latin1()); 193 strcpy(ifr.ifr_name, (*it).latin1());
193 194
194 struct ifreq ifcopy; 195 struct ifreq ifcopy;
195 ifcopy = ifr; 196 ifcopy = ifr;
196 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); 197 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
197 flags = ifcopy.ifr_flags; 198 flags = ifcopy.ifr_flags;
198 i = new Interface(this, ifr.ifr_name, false); 199 i = new Interface(this, ifr.ifr_name, false);
199 i->setAttached(true); 200 i->setAttached(true);
200 if ((flags & IFF_UP) == IFF_UP) 201 if ((flags & IFF_UP) == IFF_UP)
201 i->setStatus(true); 202 i->setStatus(true);
202 else 203 else
@@ -207,25 +208,41 @@ void MainWindowImp::getAllInterfaces(){
207 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) 208 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
208 i->setHardwareName("Point to Point"); 209 i->setHardwareName("Point to Point");
209 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) 210 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
210 i->setHardwareName("Multicast"); 211 i->setHardwareName("Multicast");
211 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) 212 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
212 i->setHardwareName("Loopback"); 213 i->setHardwareName("Loopback");
213 else 214 else
214 i->setHardwareName("Unknown"); 215 i->setHardwareName("Unknown");
215 216
216 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); 217 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name);
217 interfaceNames.insert(i->getInterfaceName(), i); 218 interfaceNames.insert(i->getInterfaceName(), i);
218 updateInterface(i); 219 updateInterface(i);
219 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 220 connect(i, SIGNAL(updateInterface(Interface *)),
221 this, SLOT(updateInterface(Interface *)));
222 }
223 // now lets ask the plugins too ;)
224 QMap<Module*, QLibrary*>::Iterator it;
225 QList<Interface> ilist;
226 for( it = libraries.begin(); it != libraries.end(); ++it ){
227 if(it.key()){
228 ilist = it.key()->getInterfaces();
229 for( i = ilist.first(); i != 0; i = ilist.next() ){
230 qWarning("Adding interface %s to interfaceNames\n", i->getInterfaceName().latin1() );
231 interfaceNames.insert(i->getInterfaceName(), i);
232 updateInterface(i);
233 connect(i, SIGNAL(updateInterface(Interface *)),
234 this, SLOT(updateInterface(Interface *)));
235 }
236 }
220 } 237 }
221} 238}
222 239
223/** 240/**
224 * Load all modules that are found in the path 241 * Load all modules that are found in the path
225 * @param path a directory that is scaned for any plugins that can be loaded 242 * @param path a directory that is scaned for any plugins that can be loaded
226 * and attempts to load them 243 * and attempts to load them
227 */ 244 */
228void MainWindowImp::loadModules(const QString &path){ 245void MainWindowImp::loadModules(const QString &path){
229#ifdef DEBUG 246#ifdef DEBUG
230 qDebug("MainWindowImp::loadModules: %s", path.latin1()); 247 qDebug("MainWindowImp::loadModules: %s", path.latin1());
231#endif 248#endif
@@ -307,26 +324,25 @@ Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &
307 return object; 324 return object;
308#endif 325#endif
309} 326}
310 327
311/** 328/**
312 * The Add button was clicked. Bring up the add dialog and if OK is hit 329 * The Add button was clicked. Bring up the add dialog and if OK is hit
313 * load the plugin and append it to the list 330 * load the plugin and append it to the list
314 */ 331 */
315void MainWindowImp::addClicked(){ 332void MainWindowImp::addClicked(){
316 QMap<Module*, QLibrary*>::Iterator it; 333 QMap<Module*, QLibrary*>::Iterator it;
317 QMap<QString, QString> list; 334 QMap<QString, QString> list;
318 QMap<QString, Module*> newInterfaceOwners; 335 QMap<QString, Module*> newInterfaceOwners;
319 //list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 336
320 //list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
321 for( it = libraries.begin(); it != libraries.end(); ++it ){ 337 for( it = libraries.begin(); it != libraries.end(); ++it ){
322 if(it.key()){ 338 if(it.key()){
323 (it.key())->possibleNewInterfaces(list); 339 (it.key())->possibleNewInterfaces(list);
324 } 340 }
325 } 341 }
326 // See if the list has anything that we can add. 342 // See if the list has anything that we can add.
327 if(list.count() == 0){ 343 if(list.count() == 0){
328 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); 344 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
329 return; 345 return;
330 } 346 }
331 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 347 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
332 addNewConnection.addConnections(list); 348 addNewConnection.addConnections(list);