summaryrefslogtreecommitdiff
path: root/noncore/net/networksetup/mainwindowimp.cpp
Unidiff
Diffstat (limited to 'noncore/net/networksetup/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/networksetup/mainwindowimp.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp
index 9f07f0d..01063c2 100644
--- a/noncore/net/networksetup/mainwindowimp.cpp
+++ b/noncore/net/networksetup/mainwindowimp.cpp
@@ -32,7 +32,8 @@
32#define TEMP_ALL "/tmp/ifconfig-a" 32#define TEMP_ALL "/tmp/ifconfig-a"
33#define TEMP_UP "/tmp/ifconfig" 33#define TEMP_UP "/tmp/ifconfig"
34 34
35#define SCHEME "/var/lib/pcmcia/scheme" 35#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
36
36MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){ 37MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name, true), advancedUserMode(false){
37 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 38 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
38 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 39 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
@@ -56,8 +57,9 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
56 profilesList->insertItem((*it)); 57 profilesList->insertItem((*it));
57 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); 58 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
58 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 59 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
60 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
59 61
60 QFile file(SCHEME); 62 QFile file(scheme);
61 if ( file.open(IO_ReadOnly) ) { // file opened successfully 63 if ( file.open(IO_ReadOnly) ) { // file opened successfully
62 QTextStream stream( &file ); // use a text stream 64 QTextStream stream( &file ); // use a text stream
63 while ( !stream.eof() ) { // until end of file... 65 while ( !stream.eof() ) { // until end of file...
@@ -95,7 +97,7 @@ MainWindowImp::~MainWindowImp(){
95 * and attempts to load them 97 * and attempts to load them
96 */ 98 */
97void MainWindowImp::loadModules(QString path){ 99void MainWindowImp::loadModules(QString path){
98 qDebug(path.latin1()); 100 //qDebug(path.latin1());
99 QDir d(path); 101 QDir d(path);
100 if(!d.exists()) 102 if(!d.exists())
101 return; 103 return;
@@ -120,7 +122,7 @@ void MainWindowImp::loadModules(QString path){
120 * @return pointer to the function with name resolveString or NULL 122 * @return pointer to the function with name resolveString or NULL
121 */ 123 */
122Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ 124Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){
123 qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); 125 //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1());
124 QLibrary *lib = new QLibrary(pluginFileName); 126 QLibrary *lib = new QLibrary(pluginFileName);
125 void *functionPointer = lib->resolve(resolveString); 127 void *functionPointer = lib->resolve(resolveString);
126 if( !functionPointer ){ 128 if( !functionPointer ){
@@ -490,10 +492,28 @@ void MainWindowImp::removeProfile(){
490 profilesList->clear(); 492 profilesList->clear();
491 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 493 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
492 profilesList->insertItem((*it)); 494 profilesList->insertItem((*it));
493 }
494 495
495 // Remove any interface settings and mappings. 496 // Remove any interface settings and mappings.
496 //TODO 497 Interfaces interfaces;
498 // Go through them one by one
499 QMap<Interface*, QListViewItem*>::Iterator it;
500 for( it = items.begin(); it != items.end(); ++it ){
501 QString interfaceName = it.key()->getInterfaceName();
502 qDebug(interfaceName.latin1());
503 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){
504 interfaces.removeInterface();
505 if(interfaces.setMapping(interfaceName)){
506 if(profilesList->count() == 1)
507 interfaces.removeMapping();
508 else{
509 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
510 }
511 }
512 interfaces.write();
513 break;
514 }
515 }
516 }
497} 517}
498 518
499/** 519/**
@@ -508,8 +528,8 @@ void MainWindowImp::changeProfile(){
508 QString newProfile = profilesList->text(profilesList->currentItem()); 528 QString newProfile = profilesList->text(profilesList->currentItem());
509 if(newProfile != currentProfileLabel->text()){ 529 if(newProfile != currentProfileLabel->text()){
510 currentProfileLabel->setText(newProfile); 530 currentProfileLabel->setText(newProfile);
511 QFile::remove(SCHEME); 531 QFile::remove(scheme);
512 QFile file(SCHEME); 532 QFile file(scheme);
513 if ( file.open(IO_ReadWrite) ) { 533 if ( file.open(IO_ReadWrite) ) {
514 QTextStream stream( &file ); 534 QTextStream stream( &file );
515 stream << QString("SCHEME=%1").arg(newProfile); 535 stream << QString("SCHEME=%1").arg(newProfile);