summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 50131d8..7e24cda 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -170,50 +170,48 @@ void MainWindowImp::getAllInterfaces(){
170 170
171 ifaces += pifr->ifr_name; 171 ifaces += pifr->ifr_name;
172 } 172 }
173 } else { 173 } else {
174 procFile.open(IO_ReadOnly); 174 procFile.open(IO_ReadOnly);
175 QString line; 175 QString line;
176 QTextStream procTs(&procFile); 176 QTextStream procTs(&procFile);
177 int loc = -1; 177 int loc = -1;
178 178
179 procTs.readLine(); // eat a line 179 procTs.readLine(); // eat a line
180 procTs.readLine(); // eat a line 180 procTs.readLine(); // eat a line
181 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) { 181 while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) {
182 if((loc = line.find(":")) != -1) { 182 if((loc = line.find(":")) != -1) {
183 ifaces += line.left(loc); 183 ifaces += line.left(loc);
184 } 184 }
185 } 185 }
186 } 186 }
187 187
188 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) { 188 for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) {
189 int flags = 0, family; 189 int flags = 0, family;
190 Interface *i = NULL; 190 Interface *i = NULL;
191 191
192 strcpy(ifr.ifr_name, (*it).latin1()); 192 strcpy(ifr.ifr_name, (*it).latin1());
193 193
194 qWarning("ifr.ifr_name=%s\n", ifr.ifr_name);
195
196 struct ifreq ifcopy; 194 struct ifreq ifcopy;
197 ifcopy = ifr; 195 ifcopy = ifr;
198 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); 196 result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy);
199 flags = ifcopy.ifr_flags; 197 flags = ifcopy.ifr_flags;
200 i = new Interface(this, ifr.ifr_name, false); 198 i = new Interface(this, ifr.ifr_name, false);
201 i->setAttached(true); 199 i->setAttached(true);
202 if ((flags & IFF_UP) == IFF_UP) 200 if ((flags & IFF_UP) == IFF_UP)
203 i->setStatus(true); 201 i->setStatus(true);
204 else 202 else
205 i->setStatus(false); 203 i->setStatus(false);
206 204
207 if ((flags & IFF_BROADCAST) == IFF_BROADCAST) 205 if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
208 i->setHardwareName("Ethernet"); 206 i->setHardwareName("Ethernet");
209 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) 207 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
210 i->setHardwareName("Point to Point"); 208 i->setHardwareName("Point to Point");
211 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) 209 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
212 i->setHardwareName("Multicast"); 210 i->setHardwareName("Multicast");
213 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) 211 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
214 i->setHardwareName("Loopback"); 212 i->setHardwareName("Loopback");
215 else 213 else
216 i->setHardwareName("Unknown"); 214 i->setHardwareName("Unknown");
217 215
218 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name); 216 qWarning("Adding interface %s to interfaceNames\n", ifr.ifr_name);
219 interfaceNames.insert(i->getInterfaceName(), i); 217 interfaceNames.insert(i->getInterfaceName(), i);
@@ -368,61 +366,64 @@ void MainWindowImp::removeClicked(){
368 } 366 }
369 else{ 367 else{
370 if(!i->getModuleOwner()->remove(i)) 368 if(!i->getModuleOwner()->remove(i))
371 QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); 369 QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok);
372 else{ 370 else{
373 QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); 371 QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
374 // TODO memory managment.... 372 // TODO memory managment....
375 // who deletes the interface? 373 // who deletes the interface?
376 } 374 }
377 } 375 }
378} 376}
379 377
380/** 378/**
381 * Pull up the configure about the currently selected interface. 379 * Pull up the configure about the currently selected interface.
382 * Report an error if no interface is selected. 380 * Report an error if no interface is selected.
383 * If the interface has a module owner then request its configure. 381 * If the interface has a module owner then request its configure.
384 */ 382 */
385void MainWindowImp::configureClicked(){ 383void MainWindowImp::configureClicked(){
386 QListViewItem *item = connectionList->currentItem(); 384 QListViewItem *item = connectionList->currentItem();
387 if(!item){ 385 if(!item){
388 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); 386 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok);
389 return; 387 return;
390 } 388 }
391 389
390 QString currentProfileText = currentProfileLabel->text();
391 if(currentProfileText.upper() == "ALL");
392 currentProfileText = "";
393
392 Interface *i = interfaceItems[item]; 394 Interface *i = interfaceItems[item];
395
393 if(i->getModuleOwner()){ 396 if(i->getModuleOwner()){
394 QWidget *moduleConfigure = i->getModuleOwner()->configure(i); 397 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
395 if(moduleConfigure != NULL){ 398 if(moduleConfigure != NULL){
399 i->getModuleOwner()->setProfile(currentProfileText);
396 moduleConfigure->showMaximized(); 400 moduleConfigure->showMaximized();
397 return; 401 return;
398 } 402 }
399 } 403 }
400 404
401 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose ); 405 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose );
402 QString currentProfileText = currentProfileLabel->text();
403 if(currentProfileText.upper() == "ALL");
404 currentProfileText = "";
405 configure->setProfile(currentProfileText); 406 configure->setProfile(currentProfileText);
406 configure->showMaximized(); 407 configure->showMaximized();
407} 408}
408 409
409/** 410/**
410 * Pull up the information about the currently selected interface. 411 * Pull up the information about the currently selected interface.
411 * Report an error if no interface is selected. 412 * Report an error if no interface is selected.
412 * If the interface has a module owner then request its configure. 413 * If the interface has a module owner then request its configure.
413 */ 414 */
414void MainWindowImp::informationClicked(){ 415void MainWindowImp::informationClicked(){
415 QListViewItem *item = connectionList->currentItem(); 416 QListViewItem *item = connectionList->currentItem();
416 if(!item){ 417 if(!item){
417 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 418 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
418 return; 419 return;
419 } 420 }
420 421
421 Interface *i = interfaceItems[item]; 422 Interface *i = interfaceItems[item];
422 if(!i->isAttached()){ 423 if(!i->isAttached()){
423 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 424 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
424 return; 425 return;
425 } 426 }
426 427
427 if(i->getModuleOwner()){ 428 if(i->getModuleOwner()){
428 QWidget *moduleInformation = i->getModuleOwner()->information(i); 429 QWidget *moduleInformation = i->getModuleOwner()->information(i);