summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/mainwindowimp.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index 9f07f0d..01063c2 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -29,13 +29,14 @@
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31 31
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()));
39 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 40 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
40 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 41 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
41 42
@@ -53,14 +54,15 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par
53 Config cfg("NetworkSetup"); 54 Config cfg("NetworkSetup");
54 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 55 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
55 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 56 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
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...
64 QString line = stream.readLine(); // line of text excluding '\n' 66 QString line = stream.readLine(); // line of text excluding '\n'
65 if(line.contains("SCHEME")){ 67 if(line.contains("SCHEME")){
66 line = line.mid(7, line.length()); 68 line = line.mid(7, line.length());
@@ -92,13 +94,13 @@ MainWindowImp::~MainWindowImp(){
92/** 94/**
93 * Load all modules that are found in the path 95 * Load all modules that are found in the path
94 * @param path a directory that is scaned for any plugins that can be loaded 96 * @param path a directory that is scaned for any plugins that can be loaded
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;
102 104
103 // Don't want sym links 105 // Don't want sym links
104 d.setFilter( QDir::Files | QDir::NoSymLinks ); 106 d.setFilter( QDir::Files | QDir::NoSymLinks );
@@ -117,13 +119,13 @@ void MainWindowImp::loadModules(QString path){
117 * Attempt to load a function and resolve a function. 119 * Attempt to load a function and resolve a function.
118 * @param pluginFileName - the name of the file in which to attempt to load 120 * @param pluginFileName - the name of the file in which to attempt to load
119 * @param resolveString - function pointer to resolve 121 * @param resolveString - function pointer to resolve
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 ){
127 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 129 qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
128 delete lib; 130 delete lib;
129 return NULL; 131 return NULL;
@@ -487,16 +489,34 @@ void MainWindowImp::removeProfile(){
487 489
488 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 490 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
489 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 491 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
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/**
500 * A new profile has been selected, change. 520 * A new profile has been selected, change.
501 * @param newProfile the new profile. 521 * @param newProfile the new profile.
502 */ 522 */
@@ -505,14 +525,14 @@ void MainWindowImp::changeProfile(){
505 QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); 525 QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok");
506 return; 526 return;
507 } 527 }
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);
516 file.close(); 536 file.close();
517 } 537 }
518 // restart all up devices? 538 // restart all up devices?