19 files changed, 59 insertions, 47 deletions
diff --git a/noncore/net/networksetup/TODO b/noncore/net/networksetup/TODO index 0584f81..ec6d2c6 100644 --- a/noncore/net/networksetup/TODO +++ b/noncore/net/networksetup/TODO | |||
@@ -1,16 +1,16 @@ | |||
1 | CLEAN UP | 1 | CLEAN UP |
2 | 2 | ||
3 | Fix Profiles | 3 | Fix Profiles |
4 | 4 | ||
5 | Write dns script | 5 | Write dns script |
6 | 6 | ||
7 | |||
8 | WLAN needs to be re-written to not use Config | 7 | WLAN needs to be re-written to not use Config |
9 | WHERE Is DHCP info stored??? | ||
10 | |||
11 | PPP module needs to be written | ||
12 | 8 | ||
13 | Write a class that parses /proc and not ifconfig | 9 | Write a class that parses /proc and not ifconfig |
10 | udchcp needs to output the dhcp information | ||
11 | |||
12 | Possible other modules to write: ppp, ipsec, bluetooth, ipchains | ||
13 | |||
14 | PPP module needs to scan pppd.tdb to see what is currently active | ||
14 | 15 | ||
15 | Possible other modules: ipsec, bluetooth, ipchains | ||
16 | 16 | ||
diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp index 97c05cc..d42b45d 100644 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.cpp +++ b/noncore/net/networksetup/interfaces/interfacesetupimp.cpp | |||
@@ -1,148 +1,149 @@ | |||
1 | #include "interfacesetupimp.h" | 1 | #include "interfacesetupimp.h" |
2 | #include "interface.h" | 2 | #include "interface.h" |
3 | #include "interfaces.h" | 3 | #include "interfaces.h" |
4 | 4 | ||
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | #include <qcombobox.h> | 6 | #include <qcombobox.h> |
7 | #include <qcheckbox.h> | 7 | #include <qcheckbox.h> |
8 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
9 | #include <qspinbox.h> | 9 | #include <qspinbox.h> |
10 | #include <qgroupbox.h> | 10 | #include <qgroupbox.h> |
11 | #include <qlabel.h> | 11 | #include <qlabel.h> |
12 | 12 | ||
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | 14 | ||
15 | #include <assert.h> | 15 | #include <assert.h> |
16 | 16 | ||
17 | #define DNSSCRIPT "changedns" | 17 | #define DNSSCRIPT "changedns" |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * Constuctor. Set up the connection and load the first profile. | 20 | * Constuctor. Set up the connection and load the first profile. |
21 | */ | 21 | */ |
22 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl){ | 22 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl){ |
23 | assert(parent); | 23 | assert(parent); |
24 | assert(i); | 24 | assert(i); |
25 | interface = i; | 25 | interface = i; |
26 | interfaces = new Interfaces(); | 26 | interfaces = new Interfaces(); |
27 | bool error = false; | 27 | bool error = false; |
28 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 28 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
29 | staticGroupBox->hide(); | 29 | staticGroupBox->hide(); |
30 | dhcpCheckBox->hide(); | 30 | dhcpCheckBox->hide(); |
31 | leaseTime->hide(); | 31 | leaseTime->hide(); |
32 | leaseHoursLabel->hide(); | 32 | leaseHoursLabel->hide(); |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Save the current settings, then write out the interfaces file and close. | 37 | * Save the current settings, then write out the interfaces file and close. |
38 | */ | 38 | */ |
39 | void InterfaceSetupImp::saveChanges(){ | 39 | void InterfaceSetupImp::saveChanges(){ |
40 | if(!saveSettings()) | 40 | if(!saveSettings()) |
41 | return; | 41 | return; |
42 | interfaces->write(); | 42 | interfaces->write(); |
43 | } | 43 | } |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Save the settings for the current Interface. | 46 | * Save the settings for the current Interface. |
47 | * @return bool true if successfull, false otherwise | 47 | * @return bool true if successfull, false otherwise |
48 | */ | 48 | */ |
49 | bool InterfaceSetupImp::saveSettings(){ | 49 | bool InterfaceSetupImp::saveSettings(){ |
50 | // eh can't really do anything about it other then return. :-D | 50 | // eh can't really do anything about it other then return. :-D |
51 | if(!interfaces->isInterfaceSet()) | 51 | if(!interfaces->isInterfaceSet()) |
52 | return true; | 52 | return true; |
53 | 53 | ||
54 | bool error = false; | 54 | bool error = false; |
55 | // Loopback case | 55 | // Loopback case |
56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
58 | return true; | 58 | return true; |
59 | } | 59 | } |
60 | 60 | ||
61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty() || firstDNSLineEdit->text().isEmpty())){ | 61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty() || firstDNSLineEdit->text().isEmpty())){ |
62 | QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n gateway and the first dns entries.", "Ok"); | 62 | QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n gateway and the first dns entries.", "Ok"); |
63 | return false; | 63 | return false; |
64 | } | 64 | } |
65 | interfaces->removeAllInterfaceOptions(); | 65 | interfaces->removeAllInterfaceOptions(); |
66 | 66 | ||
67 | // DHCP | 67 | // DHCP |
68 | if(dhcpCheckBox->isChecked()){ | 68 | if(dhcpCheckBox->isChecked()){ |
69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
70 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); | 70 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); |
71 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); | 71 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); |
72 | } | 72 | } |
73 | else{ | 73 | else{ |
74 | interfaces->setInterfaceMethod("static"); | 74 | interfaces->setInterfaceMethod("static"); |
75 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 75 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
76 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 76 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
77 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 77 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
78 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 78 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
79 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 79 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
80 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 80 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); |
81 | } | 81 | } |
82 | 82 | ||
83 | // IP Information | 83 | // IP Information |
84 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 84 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
85 | return true; | 85 | return true; |
86 | } | 86 | } |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * The Profile has changed. | 89 | * The Profile has changed. |
90 | * @profile the new profile. | 90 | * @profile the new profile. |
91 | */ | 91 | */ |
92 | void InterfaceSetupImp::setProfile(const QString &profile){ | 92 | void InterfaceSetupImp::setProfile(const QString &profile){ |
93 | QString newInterfaceName = interface->getInterfaceName(); | 93 | QString newInterfaceName = interface->getInterfaceName(); |
94 | if(profile.length() > 0) | 94 | if(profile.length() > 0) |
95 | newInterfaceName += "_" + profile; | 95 | newInterfaceName += "_" + profile; |
96 | qDebug("InterfaceSetupImp::setProfile"); | ||
96 | // See if we have to make a interface. | 97 | // See if we have to make a interface. |
97 | if(!interfaces->setInterface(newInterfaceName)){ | 98 | if(!interfaces->setInterface(newInterfaceName)){ |
98 | // Add making for this new interface if need too | 99 | // Add making for this new interface if need too |
99 | if(profile != ""){ | 100 | if(profile != ""){ |
100 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 101 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
101 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 102 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
102 | interfaces->addMapping(interface->getInterfaceName()); | 103 | interfaces->addMapping(interface->getInterfaceName()); |
103 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 104 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
104 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); | 105 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); |
105 | return; | 106 | return; |
106 | } | 107 | } |
107 | } | 108 | } |
108 | interfaces->setMap("map", newInterfaceName); | 109 | interfaces->setMap("map", newInterfaceName); |
109 | interfaces->setScript("getprofile.sh"); | 110 | interfaces->setScript("getprofile.sh"); |
110 | } | 111 | } |
111 | else{ | 112 | else{ |
112 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 113 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
113 | if(!interfaces->setInterface(newInterfaceName)){ | 114 | if(!interfaces->setInterface(newInterfaceName)){ |
114 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); | 115 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); |
115 | return; | 116 | return; |
116 | } | 117 | } |
117 | } | 118 | } |
118 | } | 119 | } |
119 | 120 | ||
120 | // We must have a valid interface to get this far so read some settings. | 121 | // We must have a valid interface to get this far so read some settings. |
121 | 122 | ||
122 | // DHCP | 123 | // DHCP |
123 | bool error = false; | 124 | bool error = false; |
124 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 125 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
125 | dhcpCheckBox->setChecked(true); | 126 | dhcpCheckBox->setChecked(true); |
126 | else | 127 | else |
127 | dhcpCheckBox->setChecked(false); | 128 | dhcpCheckBox->setChecked(false); |
128 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); | 129 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); |
129 | if(error) | 130 | if(error) |
130 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); | 131 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); |
131 | if(error) | 132 | if(error) |
132 | leaseTime->setValue(24); | 133 | leaseTime->setValue(24); |
133 | 134 | ||
134 | // IP Information | 135 | // IP Information |
135 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 136 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
136 | QString dns = interfaces->getInterfaceOption("up interfacednsscript -a", error); | 137 | QString dns = interfaces->getInterfaceOption("up interfacednsscript -a", error); |
137 | if(dns.contains(" ")){ | 138 | if(dns.contains(" ")){ |
138 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 139 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
139 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 140 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
140 | } | 141 | } |
141 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 142 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
142 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 143 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
143 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 144 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | // interfacesetup.cpp | 148 | // interfacesetup.cpp |
148 | 149 | ||
diff --git a/noncore/net/networksetup/interfaces/interfacesetupimp.h b/noncore/net/networksetup/interfaces/interfacesetupimp.h index 936f2be..3bbf34e 100644 --- a/noncore/net/networksetup/interfaces/interfacesetupimp.h +++ b/noncore/net/networksetup/interfaces/interfacesetupimp.h | |||
@@ -1,49 +1,55 @@ | |||
1 | #ifndef INTERFACESETUPIMP_H | 1 | #ifndef INTERFACESETUPIMP_H |
2 | #define INTERFACESETUPIMP_H | 2 | #define INTERFACESETUPIMP_H |
3 | 3 | ||
4 | #include "interfacesetup.h" | 4 | #include "interfacesetup.h" |
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | 6 | ||
7 | class Interface; | 7 | class Interface; |
8 | class Interfaces; | 8 | class Interfaces; |
9 | 9 | ||
10 | class InterfaceSetupImp : public InterfaceSetup { | 10 | class InterfaceSetupImp : public InterfaceSetup { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0); | 14 | InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0); |
15 | void saveChanges(); | 15 | void saveChanges(); |
16 | 16 | ||
17 | public slots: | 17 | public slots: |
18 | void setProfile(const QString &profile); | 18 | void setProfile(const QString &profile); |
19 | bool saveSettings(); | 19 | bool saveSettings(); |
20 | private: | 20 | private: |
21 | Interfaces *interfaces; | 21 | Interfaces *interfaces; |
22 | Interface *interface; | 22 | Interface *interface; |
23 | 23 | ||
24 | }; | 24 | }; |
25 | 25 | ||
26 | 26 | ||
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | 28 | ||
29 | class InterfaceSetupImpDialog : public QDialog { | 29 | class InterfaceSetupImpDialog : public QDialog { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | 31 | ||
32 | public: | 32 | public: |
33 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ | 33 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ |
34 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); | 34 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); |
35 | setCaption("Interface Setup"); | 35 | setCaption("Interface Setup"); |
36 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); | 36 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); |
37 | InterfaceSetupLayout->addWidget( interfaceSetup ); | 37 | InterfaceSetupLayout->addWidget( interfaceSetup ); |
38 | }; | 38 | }; |
39 | void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; | ||
39 | 40 | ||
41 | private: | ||
40 | InterfaceSetupImp *interfaceSetup; | 42 | InterfaceSetupImp *interfaceSetup; |
41 | 43 | ||
42 | protected slots: | 44 | protected slots: |
43 | void accept(){ interfaceSetup->saveChanges(); }; | 45 | void accept(){ |
46 | interfaceSetup->saveChanges(); | ||
47 | QDialog::accept(); | ||
48 | }; | ||
49 | |||
44 | }; | 50 | }; |
45 | 51 | ||
46 | #endif | 52 | #endif |
47 | 53 | ||
48 | // interfacesetupimp.h | 54 | // interfacesetupimp.h |
49 | 55 | ||
diff --git a/noncore/net/networksetup/mainwindowimp.cpp b/noncore/net/networksetup/mainwindowimp.cpp index b9fff56..6440bd4 100644 --- a/noncore/net/networksetup/mainwindowimp.cpp +++ b/noncore/net/networksetup/mainwindowimp.cpp | |||
@@ -41,504 +41,497 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par | |||
41 | 41 | ||
42 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 42 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
43 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 43 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
44 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 44 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
45 | 45 | ||
46 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 46 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
47 | // Load connections. | 47 | // Load connections. |
48 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); | 48 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); |
49 | getInterfaceList(); | 49 | getInterfaceList(); |
50 | connectionList->header()->hide(); | 50 | connectionList->header()->hide(); |
51 | 51 | ||
52 | 52 | ||
53 | Config cfg("NetworkSetup"); | 53 | Config cfg("NetworkSetup"); |
54 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 54 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
55 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 55 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
56 | profilesList->insertItem((*it)); | 56 | profilesList->insertItem((*it)); |
57 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 57 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
58 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 58 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
59 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 59 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
60 | 60 | ||
61 | QFile file(scheme); | 61 | QFile file(scheme); |
62 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | 62 | if ( file.open(IO_ReadOnly) ) { // file opened successfully |
63 | QTextStream stream( &file ); // use a text stream | 63 | QTextStream stream( &file ); // use a text stream |
64 | while ( !stream.eof() ) { // until end of file... | 64 | while ( !stream.eof() ) { // until end of file... |
65 | QString line = stream.readLine(); // line of text excluding '\n' | 65 | QString line = stream.readLine(); // line of text excluding '\n' |
66 | if(line.contains("SCHEME")){ | 66 | if(line.contains("SCHEME")){ |
67 | line = line.mid(7, line.length()); | 67 | line = line.mid(7, line.length()); |
68 | currentProfileLabel->setText(line); | 68 | currentProfileLabel->setText(line); |
69 | break; | 69 | break; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | file.close(); | 72 | file.close(); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Deconstructor. Save profiles. Delete loaded libraries. | 77 | * Deconstructor. Save profiles. Delete loaded libraries. |
78 | */ | 78 | */ |
79 | MainWindowImp::~MainWindowImp(){ | 79 | MainWindowImp::~MainWindowImp(){ |
80 | // Save profiles. | 80 | // Save profiles. |
81 | Config cfg("NetworkSetup"); | 81 | Config cfg("NetworkSetup"); |
82 | cfg.setGroup("General"); | 82 | cfg.setGroup("General"); |
83 | cfg.writeEntry("Profiles", profiles.join(" ")); | 83 | cfg.writeEntry("Profiles", profiles.join(" ")); |
84 | 84 | ||
85 | // Delete all interfaces that don't have owners. | 85 | // Delete all interfaces that don't have owners. |
86 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 86 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
87 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 87 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
88 | if(iIt.key()->getModuleOwner() == NULL) | 88 | if(iIt.key()->getModuleOwner() == NULL) |
89 | delete iIt.key(); | 89 | delete iIt.key(); |
90 | } | 90 | } |
91 | 91 | ||
92 | // Delete Modules and Libraries | 92 | // Delete Modules and Libraries |
93 | QMap<Module*, QLibrary*>::Iterator it; | 93 | QMap<Module*, QLibrary*>::Iterator it; |
94 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 94 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
95 | delete it.key(); | 95 | delete it.key(); |
96 | // I wonder why I can't delete the libraries | 96 | // I wonder why I can't delete the libraries |
97 | // What fucking shit this is. | 97 | // What fucking shit this is. |
98 | //delete it.data(); | 98 | //delete it.data(); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Load all modules that are found in the path | 103 | * Load all modules that are found in the path |
104 | * @param path a directory that is scaned for any plugins that can be loaded | 104 | * @param path a directory that is scaned for any plugins that can be loaded |
105 | * and attempts to load them | 105 | * and attempts to load them |
106 | */ | 106 | */ |
107 | void MainWindowImp::loadModules(QString path){ | 107 | void MainWindowImp::loadModules(QString path){ |
108 | //qDebug(path.latin1()); | 108 | //qDebug(path.latin1()); |
109 | QDir d(path); | 109 | QDir d(path); |
110 | if(!d.exists()) | 110 | if(!d.exists()) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | // Don't want sym links | 113 | // Don't want sym links |
114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
115 | const QFileInfoList *list = d.entryInfoList(); | 115 | const QFileInfoList *list = d.entryInfoList(); |
116 | QFileInfoListIterator it( *list ); | 116 | QFileInfoListIterator it( *list ); |
117 | QFileInfo *fi; | 117 | QFileInfo *fi; |
118 | while ( (fi=it.current()) ) { | 118 | while ( (fi=it.current()) ) { |
119 | if(fi->fileName().contains(".so")){ | 119 | if(fi->fileName().contains(".so")){ |
120 | loadPlugin(path + "/" + fi->fileName()); | 120 | loadPlugin(path + "/" + fi->fileName()); |
121 | } | 121 | } |
122 | ++it; | 122 | ++it; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Attempt to load a function and resolve a function. | 127 | * Attempt to load a function and resolve a function. |
128 | * @param pluginFileName - the name of the file in which to attempt to load | 128 | * @param pluginFileName - the name of the file in which to attempt to load |
129 | * @param resolveString - function pointer to resolve | 129 | * @param resolveString - function pointer to resolve |
130 | * @return pointer to the function with name resolveString or NULL | 130 | * @return pointer to the function with name resolveString or NULL |
131 | */ | 131 | */ |
132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ | 132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ |
133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); | 133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); |
134 | QLibrary *lib = new QLibrary(pluginFileName); | 134 | QLibrary *lib = new QLibrary(pluginFileName); |
135 | void *functionPointer = lib->resolve(resolveString); | 135 | void *functionPointer = lib->resolve(resolveString); |
136 | if( !functionPointer ){ | 136 | if( !functionPointer ){ |
137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
138 | delete lib; | 138 | delete lib; |
139 | return NULL; | 139 | return NULL; |
140 | } | 140 | } |
141 | 141 | ||
142 | // Try to get an object. | 142 | // Try to get an object. |
143 | Module *object = ((Module* (*)()) functionPointer)(); | 143 | Module *object = ((Module* (*)()) functionPointer)(); |
144 | if(object == NULL){ | 144 | if(object == NULL){ |
145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
146 | delete lib; | 146 | delete lib; |
147 | return NULL; | 147 | return NULL; |
148 | } | 148 | } |
149 | 149 | ||
150 | // Store for deletion later | 150 | // Store for deletion later |
151 | libraries.insert(object, lib); | 151 | libraries.insert(object, lib); |
152 | return object; | 152 | return object; |
153 | } | 153 | } |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 156 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
157 | * load the plugin and append it to the list | 157 | * load the plugin and append it to the list |
158 | */ | 158 | */ |
159 | void MainWindowImp::addClicked(){ | 159 | void MainWindowImp::addClicked(){ |
160 | QMap<Module*, QLibrary*>::Iterator it; | 160 | QMap<Module*, QLibrary*>::Iterator it; |
161 | QMap<QString, QString> list; | 161 | QMap<QString, QString> list; |
162 | QMap<QString, Module*> newInterfaceOwners; | 162 | QMap<QString, Module*> newInterfaceOwners; |
163 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 163 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
164 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 164 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
166 | if(it.key()){ | 166 | if(it.key()){ |
167 | (it.key())->possibleNewInterfaces(list); | 167 | (it.key())->possibleNewInterfaces(list); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | // See if the list has anything that we can add. | 170 | // See if the list has anything that we can add. |
171 | if(list.count() == 0){ | 171 | if(list.count() == 0){ |
172 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); | 172 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
176 | addNewConnection.addConnections(list); | 176 | addNewConnection.addConnections(list); |
177 | addNewConnection.showMaximized(); | 177 | addNewConnection.showMaximized(); |
178 | if(QDialog::Accepted == addNewConnection.exec()){ | 178 | if(QDialog::Accepted == addNewConnection.exec()){ |
179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
180 | if(!item) | 180 | if(!item) |
181 | return; | 181 | return; |
182 | 182 | ||
183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
184 | if(it.key()){ | 184 | if(it.key()){ |
185 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 185 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
186 | if(i){ | 186 | if(i){ |
187 | interfaceNames.insert(i->getInterfaceName(), i); | 187 | interfaceNames.insert(i->getInterfaceName(), i); |
188 | updateInterface(i); | 188 | updateInterface(i); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Prompt the user to see if they really want to do this. | 196 | * Prompt the user to see if they really want to do this. |
197 | * If they do then remove from the list and unload. | 197 | * If they do then remove from the list and unload. |
198 | */ | 198 | */ |
199 | void MainWindowImp::removeClicked(){ | 199 | void MainWindowImp::removeClicked(){ |
200 | QListViewItem *item = connectionList->currentItem(); | 200 | QListViewItem *item = connectionList->currentItem(); |
201 | if(!item) { | 201 | if(!item) { |
202 | QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); | 202 | QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | 205 | ||
206 | Interface *i = interfaceItems[item]; | 206 | Interface *i = interfaceItems[item]; |
207 | if(i->getModuleOwner() == NULL){ | 207 | if(i->getModuleOwner() == NULL){ |
208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); | 208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); |
209 | } | 209 | } |
210 | else{ | 210 | else{ |
211 | if(!i->getModuleOwner()->remove(i)) | 211 | if(!i->getModuleOwner()->remove(i)) |
212 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); | 212 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); |
213 | else{ | 213 | else{ |
214 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); | 214 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); |
215 | // TODO memory managment.... | 215 | // TODO memory managment.... |
216 | // who deletes the interface? | 216 | // who deletes the interface? |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | /** | 221 | /** |
222 | * Pull up the configure about the currently selected interface. | 222 | * Pull up the configure about the currently selected interface. |
223 | * Report an error if no interface is selected. | 223 | * Report an error if no interface is selected. |
224 | * If the interface has a module owner then request its configure. | 224 | * If the interface has a module owner then request its configure. |
225 | */ | 225 | */ |
226 | void MainWindowImp::configureClicked(){ | 226 | void MainWindowImp::configureClicked(){ |
227 | QListViewItem *item = connectionList->currentItem(); | 227 | QListViewItem *item = connectionList->currentItem(); |
228 | if(!item){ | 228 | if(!item){ |
229 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); | 229 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); |
230 | return; | 230 | return; |
231 | } | 231 | } |
232 | 232 | ||
233 | QString currentProfile = currentProfileLabel->text(); | ||
234 | if(profilesList->count() <= 1 || currentProfile == "All"){ | ||
235 | currentProfile = ""; | ||
236 | } | ||
237 | |||
238 | Interface *i = interfaceItems[item]; | 233 | Interface *i = interfaceItems[item]; |
239 | if(i->getModuleOwner()){ | 234 | if(i->getModuleOwner()){ |
240 | i->getModuleOwner()->setProfile(currentProfile); | ||
241 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
242 | if(moduleConfigure != NULL){ | 236 | if(moduleConfigure != NULL){ |
243 | moduleConfigure->showMaximized(); | 237 | moduleConfigure->showMaximized(); |
244 | moduleConfigure->show(); | 238 | moduleConfigure->show(); |
245 | return; | 239 | return; |
246 | } | 240 | } |
247 | } | 241 | } |
248 | 242 | ||
249 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose); | 243 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose); |
250 | //configure->setProfile(currentProfile); | 244 | QString currentProfileText = currentProfileLabel->text(); |
245 | if(currentProfileText.upper() == "ALL"); | ||
246 | currentProfileText = ""; | ||
247 | configure->setProfile(currentProfileText); | ||
251 | configure->showMaximized(); | 248 | configure->showMaximized(); |
252 | configure->show(); | 249 | configure->show(); |
253 | } | 250 | } |
254 | 251 | ||
255 | /** | 252 | /** |
256 | * Pull up the information about the currently selected interface. | 253 | * Pull up the information about the currently selected interface. |
257 | * Report an error if no interface is selected. | 254 | * Report an error if no interface is selected. |
258 | * If the interface has a module owner then request its configure. | 255 | * If the interface has a module owner then request its configure. |
259 | */ | 256 | */ |
260 | void MainWindowImp::informationClicked(){ | 257 | void MainWindowImp::informationClicked(){ |
261 | QListViewItem *item = connectionList->currentItem(); | 258 | QListViewItem *item = connectionList->currentItem(); |
262 | if(!item){ | 259 | if(!item){ |
263 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 260 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
264 | return; | 261 | return; |
265 | } | 262 | } |
266 | 263 | ||
267 | Interface *i = interfaceItems[item]; | 264 | Interface *i = interfaceItems[item]; |
268 | if(!i->isAttached()){ | 265 | if(!i->isAttached()){ |
269 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 266 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
270 | return; | 267 | return; |
271 | } | 268 | } |
272 | 269 | ||
273 | QStringList list; | ||
274 | for(uint i = 0; i < profilesList->count(); i++){ | ||
275 | list.append(profilesList->text(i)); | ||
276 | } | ||
277 | |||
278 | if(i->getModuleOwner()){ | 270 | if(i->getModuleOwner()){ |
279 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 271 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
280 | if(moduleInformation != NULL){ | 272 | if(moduleInformation != NULL){ |
281 | moduleInformation->showMaximized(); | 273 | moduleInformation->showMaximized(); |
282 | moduleInformation->show(); | 274 | moduleInformation->show(); |
283 | return; | 275 | return; |
284 | } | 276 | } |
285 | } | 277 | } |
286 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); | 278 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); |
287 | information->showMaximized(); | 279 | information->showMaximized(); |
288 | information->show(); | 280 | information->show(); |
289 | } | 281 | } |
290 | 282 | ||
291 | /** | 283 | /** |
292 | * Aquire the list of active interfaces from ifconfig | 284 | * Aquire the list of active interfaces from ifconfig |
293 | * Call ifconfig and ifconfig -a | 285 | * Call ifconfig and ifconfig -a |
294 | */ | 286 | */ |
295 | void MainWindowImp::getInterfaceList(){ | 287 | void MainWindowImp::getInterfaceList(){ |
296 | KShellProcess *processAll = new KShellProcess(); | 288 | KShellProcess *processAll = new KShellProcess(); |
297 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; | 289 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; |
298 | connect(processAll, SIGNAL(processExited(KProcess *)), | 290 | connect(processAll, SIGNAL(processExited(KProcess *)), |
299 | this, SLOT(jobDone(KProcess *))); | 291 | this, SLOT(jobDone(KProcess *))); |
300 | threads.insert(processAll, TEMP_ALL); | 292 | threads.insert(processAll, TEMP_ALL); |
301 | 293 | ||
302 | KShellProcess *process = new KShellProcess(); | 294 | KShellProcess *process = new KShellProcess(); |
303 | *process << "/sbin/ifconfig" << " > " TEMP_UP; | 295 | *process << "/sbin/ifconfig" << " > " TEMP_UP; |
304 | connect(process, SIGNAL(processExited(KProcess *)), | 296 | connect(process, SIGNAL(processExited(KProcess *)), |
305 | this, SLOT(jobDone(KProcess *))); | 297 | this, SLOT(jobDone(KProcess *))); |
306 | threads.insert(process, TEMP_UP); | 298 | threads.insert(process, TEMP_UP); |
307 | 299 | ||
308 | processAll->start(KShellProcess::NotifyOnExit); | 300 | processAll->start(KShellProcess::NotifyOnExit); |
309 | process->start(KShellProcess::NotifyOnExit); | 301 | process->start(KShellProcess::NotifyOnExit); |
310 | } | 302 | } |
311 | 303 | ||
312 | void MainWindowImp::jobDone(KProcess *process){ | 304 | void MainWindowImp::jobDone(KProcess *process){ |
313 | QString fileName = threads[process]; | 305 | QString fileName = threads[process]; |
314 | threads.remove(process); | 306 | threads.remove(process); |
315 | delete process; | 307 | delete process; |
316 | 308 | ||
317 | QFile file(fileName); | 309 | QFile file(fileName); |
318 | if (!file.open(IO_ReadOnly)){ | 310 | if (!file.open(IO_ReadOnly)){ |
319 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); | 311 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); |
320 | return; | 312 | return; |
321 | } | 313 | } |
322 | 314 | ||
323 | QTextStream stream( &file ); | 315 | QTextStream stream( &file ); |
324 | QString line; | 316 | QString line; |
325 | while ( !stream.eof() ) { | 317 | while ( !stream.eof() ) { |
326 | line = stream.readLine(); | 318 | line = stream.readLine(); |
327 | int space = line.find(" "); | 319 | int space = line.find(" "); |
328 | if(space > 1){ | 320 | if(space > 1){ |
329 | // We have found an interface | 321 | // We have found an interface |
330 | QString interfaceName = line.mid(0, space); | 322 | QString interfaceName = line.mid(0, space); |
331 | Interface *i; | 323 | Interface *i; |
332 | // We have found an interface | 324 | // We have found an interface |
333 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); | 325 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); |
334 | // See if we already have it | 326 | // See if we already have it |
335 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ | 327 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ |
336 | if(fileName == TEMP_ALL) | 328 | if(fileName == TEMP_ALL) |
337 | i = new Interface(this, interfaceName, false); | 329 | i = new Interface(this, interfaceName, false); |
338 | else | 330 | else |
339 | i = new Interface(this, interfaceName, true); | 331 | i = new Interface(this, interfaceName, true); |
340 | i->setAttached(true); | 332 | i->setAttached(true); |
341 | 333 | ||
342 | QString hardName = "Ethernet"; | 334 | QString hardName = "Ethernet"; |
343 | int hardwareName = line.find("Link encap:"); | 335 | int hardwareName = line.find("Link encap:"); |
344 | int macAddress = line.find("HWaddr"); | 336 | int macAddress = line.find("HWaddr"); |
345 | if(macAddress == -1) | 337 | if(macAddress == -1) |
346 | macAddress = line.length(); | 338 | macAddress = line.length(); |
347 | if(hardwareName != -1) | 339 | if(hardwareName != -1) |
348 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); | 340 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); |
349 | 341 | ||
350 | interfaceNames.insert(i->getInterfaceName(), i); | 342 | interfaceNames.insert(i->getInterfaceName(), i); |
351 | updateInterface(i); | 343 | updateInterface(i); |
352 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 344 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
353 | } | 345 | } |
354 | // It was an interface we already had. | 346 | // It was an interface we already had. |
355 | else{ | 347 | else{ |
356 | if(fileName != TEMP_ALL) | 348 | if(fileName != TEMP_ALL) |
357 | (interfaceNames[interfaceName])->setStatus(true); | 349 | (interfaceNames[interfaceName])->setStatus(true); |
358 | } | 350 | } |
359 | } | 351 | } |
360 | } | 352 | } |
361 | file.close(); | 353 | file.close(); |
362 | QFile::remove(fileName); | 354 | QFile::remove(fileName); |
363 | 355 | ||
364 | if(threads.count() == 0){ | 356 | if(threads.count() == 0){ |
365 | Interfaces i; | 357 | Interfaces i; |
366 | QStringList list = i.getInterfaceList(); | 358 | QStringList list = i.getInterfaceList(); |
367 | QMap<QString, Interface*>::Iterator it; | 359 | QMap<QString, Interface*>::Iterator it; |
368 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 360 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
369 | bool found = false; | 361 | bool found = false; |
370 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 362 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
371 | if(it.key() == (*ni)) | 363 | if(it.key() == (*ni)) |
372 | found = true; | 364 | found = true; |
373 | } | 365 | } |
374 | if(!found){ | 366 | if(!found){ |
375 | if(!(*ni).contains("_")){ | 367 | if(!(*ni).contains("_")){ |
376 | Interface *i = new Interface(this, *ni, false); | 368 | Interface *i = new Interface(this, *ni, false); |
377 | i->setAttached(false); | 369 | i->setAttached(false); |
378 | i->setHardwareName("Disconnected"); | 370 | i->setHardwareName("Disconnected"); |
379 | interfaceNames.insert(i->getInterfaceName(), i); | 371 | interfaceNames.insert(i->getInterfaceName(), i); |
380 | updateInterface(i); | 372 | updateInterface(i); |
381 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 373 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
382 | } | 374 | } |
383 | } | 375 | } |
384 | } | 376 | } |
385 | } | 377 | } |
386 | } | 378 | } |
387 | 379 | ||
388 | /** | 380 | /** |
389 | * Update this interface. If no QListViewItem exists create one. | 381 | * Update this interface. If no QListViewItem exists create one. |
390 | * @param Interface* pointer to the interface that needs to be updated. | 382 | * @param Interface* pointer to the interface that needs to be updated. |
391 | */ | 383 | */ |
392 | void MainWindowImp::updateInterface(Interface *i){ | 384 | void MainWindowImp::updateInterface(Interface *i){ |
393 | if(!advancedUserMode){ | 385 | if(!advancedUserMode){ |
394 | if(i->getInterfaceName() == "lo") | 386 | if(i->getInterfaceName() == "lo") |
395 | return; | 387 | return; |
396 | } | 388 | } |
397 | 389 | ||
398 | QListViewItem *item = NULL; | 390 | QListViewItem *item = NULL; |
399 | 391 | ||
400 | // Find the interface, making it if needed. | 392 | // Find the interface, making it if needed. |
401 | if(items.find(i) == items.end()){ | 393 | if(items.find(i) == items.end()){ |
402 | item = new QListViewItem(connectionList, "", "", ""); | 394 | item = new QListViewItem(connectionList, "", "", ""); |
403 | // See if you can't find a module owner for this interface | 395 | // See if you can't find a module owner for this interface |
404 | QMap<Module*, QLibrary*>::Iterator it; | 396 | QMap<Module*, QLibrary*>::Iterator it; |
405 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 397 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
406 | if(it.key()->isOwner(i)) | 398 | if(it.key()->isOwner(i)) |
407 | i->setModuleOwner(it.key()); | 399 | i->setModuleOwner(it.key()); |
408 | } | 400 | } |
409 | items.insert(i, item); | 401 | items.insert(i, item); |
410 | interfaceItems.insert(item, i); | 402 | interfaceItems.insert(item, i); |
411 | } | 403 | } |
412 | else | 404 | else |
413 | item = items[i]; | 405 | item = items[i]; |
414 | 406 | ||
415 | // Update the icons and information | 407 | // Update the icons and information |
416 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 408 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
417 | 409 | ||
418 | QString typeName = "lan"; | 410 | QString typeName = "lan"; |
419 | if(i->getHardwareName().contains("Local Loopback")) | 411 | if(i->getHardwareName().contains("Local Loopback")) |
420 | typeName = "lo"; | 412 | typeName = "lo"; |
421 | if(i->getInterfaceName().contains("irda")) | 413 | if(i->getInterfaceName().contains("irda")) |
422 | typeName = "irda"; | 414 | typeName = "irda"; |
423 | if(i->getInterfaceName().contains("wlan")) | 415 | if(i->getInterfaceName().contains("wlan")) |
424 | typeName = "wlan"; | 416 | typeName = "wlan"; |
425 | if(i->getInterfaceName().contains("usb")) | 417 | if(i->getInterfaceName().contains("usb")) |
426 | typeName = "usb"; | 418 | typeName = "usb"; |
427 | 419 | ||
428 | if(!i->isAttached()) | 420 | if(!i->isAttached()) |
429 | typeName = "connect_no"; | 421 | typeName = "connect_no"; |
430 | // Actually try to use the Module | 422 | // Actually try to use the Module |
431 | if(i->getModuleOwner() != NULL) | 423 | if(i->getModuleOwner() != NULL) |
432 | typeName = i->getModuleOwner()->getPixmapName(i); | 424 | typeName = i->getModuleOwner()->getPixmapName(i); |
433 | 425 | ||
434 | item->setPixmap(1, (Resource::loadPixmap(typeName))); | 426 | item->setPixmap(1, (Resource::loadPixmap(typeName))); |
435 | item->setText(2, i->getHardwareName()); | 427 | item->setText(2, i->getHardwareName()); |
436 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 428 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
437 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 429 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
438 | } | 430 | } |
439 | 431 | ||
440 | void MainWindowImp::newProfileChanged(const QString& newText){ | 432 | void MainWindowImp::newProfileChanged(const QString& newText){ |
441 | if(newText.length() > 0) | 433 | if(newText.length() > 0) |
442 | newProfileButton->setEnabled(true); | 434 | newProfileButton->setEnabled(true); |
443 | else | 435 | else |
444 | newProfileButton->setEnabled(false); | 436 | newProfileButton->setEnabled(false); |
445 | } | 437 | } |
446 | 438 | ||
447 | /** | 439 | /** |
448 | * Adds a new profile to the list of profiles. | 440 | * Adds a new profile to the list of profiles. |
449 | * Don't add profiles that already exists. | 441 | * Don't add profiles that already exists. |
450 | * Appends to the list and QStringList | 442 | * Appends to the list and QStringList |
451 | */ | 443 | */ |
452 | void MainWindowImp::addProfile(){ | 444 | void MainWindowImp::addProfile(){ |
453 | QString newProfileName = newProfile->text(); | 445 | QString newProfileName = newProfile->text(); |
454 | if(profiles.grep(newProfileName).count() > 0){ | 446 | if(profiles.grep(newProfileName).count() > 0){ |
455 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); | 447 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); |
456 | return; | 448 | return; |
457 | } | 449 | } |
458 | profiles.append(newProfileName); | 450 | profiles.append(newProfileName); |
459 | profilesList->insertItem(newProfileName); | 451 | profilesList->insertItem(newProfileName); |
460 | } | 452 | } |
461 | 453 | ||
462 | /** | 454 | /** |
463 | * Removes the currently selected profile in the combo. | 455 | * Removes the currently selected profile in the combo. |
464 | * Doesn't delete if there are less then 2 profiles. | 456 | * Doesn't delete if there are less then 2 profiles. |
465 | */ | 457 | */ |
466 | void MainWindowImp::removeProfile(){ | 458 | void MainWindowImp::removeProfile(){ |
467 | if(profilesList->count() <= 1){ | 459 | if(profilesList->count() <= 1){ |
468 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); | 460 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); |
469 | return; | 461 | return; |
470 | } | 462 | } |
471 | QString profileToRemove = profilesList->currentText(); | 463 | QString profileToRemove = profilesList->currentText(); |
472 | if(profileToRemove == "All"){ | 464 | if(profileToRemove == "All"){ |
473 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); | 465 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); |
474 | return; | 466 | return; |
475 | } | 467 | } |
476 | // Can't remove the curent profile | 468 | // Can't remove the curent profile |
477 | if(profileToRemove == currentProfileLabel->text()){ | 469 | if(profileToRemove == currentProfileLabel->text()){ |
478 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); | 470 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); |
479 | return; | 471 | return; |
480 | 472 | ||
481 | } | 473 | } |
482 | 474 | ||
483 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 475 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ |
484 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 476 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
485 | profilesList->clear(); | 477 | profilesList->clear(); |
486 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 478 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
487 | profilesList->insertItem((*it)); | 479 | profilesList->insertItem((*it)); |
488 | 480 | ||
489 | // Remove any interface settings and mappings. | 481 | // Remove any interface settings and mappings. |
490 | Interfaces interfaces; | 482 | Interfaces interfaces; |
491 | // Go through them one by one | 483 | // Go through them one by one |
492 | QMap<Interface*, QListViewItem*>::Iterator it; | 484 | QMap<Interface*, QListViewItem*>::Iterator it; |
493 | for( it = items.begin(); it != items.end(); ++it ){ | 485 | for( it = items.begin(); it != items.end(); ++it ){ |
494 | QString interfaceName = it.key()->getInterfaceName(); | 486 | QString interfaceName = it.key()->getInterfaceName(); |
495 | qDebug(interfaceName.latin1()); | 487 | qDebug(interfaceName.latin1()); |
496 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ | 488 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ |
497 | interfaces.removeInterface(); | 489 | interfaces.removeInterface(); |
498 | if(interfaces.setMapping(interfaceName)){ | 490 | if(interfaces.setMapping(interfaceName)){ |
499 | if(profilesList->count() == 1) | 491 | if(profilesList->count() == 1) |
500 | interfaces.removeMapping(); | 492 | interfaces.removeMapping(); |
501 | else{ | 493 | else{ |
502 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 494 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
503 | } | 495 | } |
504 | } | 496 | } |
505 | interfaces.write(); | 497 | interfaces.write(); |
506 | break; | 498 | break; |
507 | } | 499 | } |
508 | } | 500 | } |
509 | } | 501 | } |
510 | } | 502 | } |
511 | 503 | ||
512 | /** | 504 | /** |
513 | * A new profile has been selected, change. | 505 | * A new profile has been selected, change. |
514 | * @param newProfile the new profile. | 506 | * @param newProfile the new profile. |
515 | */ | 507 | */ |
516 | void MainWindowImp::changeProfile(){ | 508 | void MainWindowImp::changeProfile(){ |
517 | if(profilesList->currentItem() == -1){ | 509 | if(profilesList->currentItem() == -1){ |
518 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); | 510 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); |
519 | return; | 511 | return; |
520 | } | 512 | } |
521 | QString newProfile = profilesList->text(profilesList->currentItem()); | 513 | QString newProfile = profilesList->text(profilesList->currentItem()); |
522 | if(newProfile != currentProfileLabel->text()){ | 514 | if(newProfile != currentProfileLabel->text()){ |
523 | currentProfileLabel->setText(newProfile); | 515 | currentProfileLabel->setText(newProfile); |
524 | QFile::remove(scheme); | 516 | QFile::remove(scheme); |
525 | QFile file(scheme); | 517 | QFile file(scheme); |
526 | if ( file.open(IO_ReadWrite) ) { | 518 | if ( file.open(IO_ReadWrite) ) { |
527 | QTextStream stream( &file ); | 519 | QTextStream stream( &file ); |
528 | stream << QString("SCHEME=%1").arg(newProfile); | 520 | stream << QString("SCHEME=%1").arg(newProfile); |
529 | file.close(); | 521 | file.close(); |
530 | } | 522 | } |
531 | // restart all up devices? | 523 | // restart all up devices? |
532 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 524 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ |
533 | // Go through them one by one | 525 | // Go through them one by one |
534 | QMap<Interface*, QListViewItem*>::Iterator it; | 526 | QMap<Interface*, QListViewItem*>::Iterator it; |
535 | for( it = items.begin(); it != items.end(); ++it ){ | 527 | for( it = items.begin(); it != items.end(); ++it ){ |
536 | if(it.key()->getStatus() == true) | 528 | if(it.key()->getStatus() == true) |
537 | it.key()->restart(); | 529 | it.key()->restart(); |
538 | } | 530 | } |
539 | } | 531 | } |
540 | } | 532 | } |
533 | // TODO change the profile in the modules | ||
541 | } | 534 | } |
542 | 535 | ||
543 | // mainwindowimp.cpp | 536 | // mainwindowimp.cpp |
544 | 537 | ||
diff --git a/noncore/net/networksetup/networksetup.pro b/noncore/net/networksetup/networksetup.pro index 1719a35..5666a42 100644 --- a/noncore/net/networksetup/networksetup.pro +++ b/noncore/net/networksetup/networksetup.pro | |||
@@ -1,11 +1,11 @@ | |||
1 | DESTDIR = $(OPIEDIR)/bin | 1 | #DESTDIR = $(OPIEDIR)/bin |
2 | TEMPLATE = app | 2 | TEMPLATE = app |
3 | #CONFIG = qt warn_on debug | 3 | #CONFIG = qt warn_on debug |
4 | CONFIG = qt warn_on release | 4 | CONFIG = qt warn_on release |
5 | HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h kprocctrl.h module.h kprocess.h | 5 | HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h kprocctrl.h module.h kprocess.h |
6 | SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp kprocctrl.cpp kprocess.cpp | 6 | SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp kprocctrl.cpp kprocess.cpp |
7 | INCLUDEPATH += $(OPIEDIR)/include interfaces/ | 7 | INCLUDEPATH += $(OPIEDIR)/include interfaces/ |
8 | DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan | 8 | DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan |
9 | LIBS += -lqpe -L$(OPIEDIR)/plugins/networksetup -linterfaces | 9 | LIBS += -lqpe -L$(OPIEDIR)/plugins/networksetup -Linterfaces/ -linterfaces |
10 | INTERFACES = mainwindow.ui addconnection.ui | 10 | INTERFACES = mainwindow.ui addconnection.ui |
11 | TARGET = networksetup | 11 | TARGET = networksetup |
diff --git a/noncore/net/networksetup/opie-networksetup.control b/noncore/net/networksetup/opie-networksetup.control index 35bac52..d14e2d1 100644 --- a/noncore/net/networksetup/opie-networksetup.control +++ b/noncore/net/networksetup/opie-networksetup.control | |||
@@ -1,8 +1,8 @@ | |||
1 | Files: bin/networksetup apps/Settings/networksetup.desktop pics/Network plugins/networksetup/* pics/networksetup $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 | 1 | Files: bin/networksetup apps/Settings/networksetup.desktop pics/Network plugins/networksetup/* pics/networksetup $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 $OPIEDIR/bin/changedns.sh $OPIEDIR/bin/getprofile.sh |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/settings | 3 | Section: opie/settings |
4 | Maintainer: Ben Meyer <meyerb@sharpsec.com> | 4 | Maintainer: Ben Meyer <meyerb@sharpsec.com> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | Description: Opie network setup tool | 8 | Description: Opie network setup tool |
diff --git a/noncore/net/networksetup/wlan/wlanimp.cpp b/noncore/net/networksetup/wlan/wlanimp.cpp index a466020..74bf390 100644 --- a/noncore/net/networksetup/wlan/wlanimp.cpp +++ b/noncore/net/networksetup/wlan/wlanimp.cpp | |||
@@ -1,227 +1,231 @@ | |||
1 | #include "wlanimp.h" | 1 | #include "wlanimp.h" |
2 | 2 | ||
3 | /* Config class */ | 3 | /* Config class */ |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | /* Global namespace */ | 5 | /* Global namespace */ |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | /* system() */ | 7 | /* system() */ |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qdir.h> | 10 | #include <qdir.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
15 | #include <qradiobutton.h> | 15 | #include <qradiobutton.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qregexp.h> | 17 | #include <qregexp.h> |
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qtabwidget.h> | 19 | #include <qtabwidget.h> |
20 | #include "interfacesetupimp.h" | 20 | #include "interfacesetupimp.h" |
21 | 21 | ||
22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ | 22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ |
23 | config = new Config("wireless"); | 23 | config = new Config("wireless"); |
24 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose); | 24 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose); |
25 | //configure->setProfile(currentProfile); | 25 | //configure->setProfile(currentProfile); |
26 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 26 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
27 | 27 | ||
28 | readConfig(); | 28 | readConfig(); |
29 | 29 | ||
30 | } | 30 | } |
31 | 31 | ||
32 | WLANImp::~WLANImp( ){ | 32 | WLANImp::~WLANImp( ){ |
33 | delete config; | 33 | delete config; |
34 | } | 34 | } |
35 | 35 | ||
36 | void WLANImp::setProfile(QString &profile){ | ||
37 | interfaceSetup->setProfile(profile); | ||
38 | } | ||
39 | |||
36 | void WLANImp::readConfig() | 40 | void WLANImp::readConfig() |
37 | { | 41 | { |
38 | qWarning( "WLANImp::readConfig() called." ); | 42 | qWarning( "WLANImp::readConfig() called." ); |
39 | config->setGroup( "Properties" ); | 43 | config->setGroup( "Properties" ); |
40 | QString ssid = config->readEntry( "SSID", "any" ); | 44 | QString ssid = config->readEntry( "SSID", "any" ); |
41 | if( ssid == "any" || ssid == "ANY" ){ | 45 | if( ssid == "any" || ssid == "ANY" ){ |
42 | essNon->setChecked( true ); | 46 | essNon->setChecked( true ); |
43 | } else { | 47 | } else { |
44 | essSpecific->setChecked( true ); | 48 | essSpecific->setChecked( true ); |
45 | essSpecificLineEdit->setText( ssid ); | 49 | essSpecificLineEdit->setText( ssid ); |
46 | } | 50 | } |
47 | QString mode = config->readEntry( "Mode", "Managed" ); | 51 | QString mode = config->readEntry( "Mode", "Managed" ); |
48 | if( mode == "adhoc" ) { | 52 | if( mode == "adhoc" ) { |
49 | network802->setChecked( true ); | 53 | network802->setChecked( true ); |
50 | } else { | 54 | } else { |
51 | networkInfrastructure->setChecked( true ); | 55 | networkInfrastructure->setChecked( true ); |
52 | } | 56 | } |
53 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); | 57 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); |
54 | // config->readEntry( "RATE", "auto" ); | 58 | // config->readEntry( "RATE", "auto" ); |
55 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); | 59 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); |
56 | config->readEntry( "AuthType", "opensystem" ); | 60 | config->readEntry( "AuthType", "opensystem" ); |
57 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); | 61 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); |
58 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 62 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
59 | switch( defaultkey ){ | 63 | switch( defaultkey ){ |
60 | case 0: | 64 | case 0: |
61 | keyRadio0->setChecked( true ); | 65 | keyRadio0->setChecked( true ); |
62 | break; | 66 | break; |
63 | case 1: | 67 | case 1: |
64 | keyRadio1->setChecked( true ); | 68 | keyRadio1->setChecked( true ); |
65 | break; | 69 | break; |
66 | case 2: | 70 | case 2: |
67 | keyRadio2->setChecked( true ); | 71 | keyRadio2->setChecked( true ); |
68 | break; | 72 | break; |
69 | case 3: | 73 | case 3: |
70 | keyRadio3->setChecked( true ); | 74 | keyRadio3->setChecked( true ); |
71 | break; | 75 | break; |
72 | } | 76 | } |
73 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); | 77 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); |
74 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); | 78 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); |
75 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); | 79 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); |
76 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); | 80 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); |
77 | return; | 81 | return; |
78 | } | 82 | } |
79 | 83 | ||
80 | bool WLANImp::writeConfig() | 84 | bool WLANImp::writeConfig() |
81 | { | 85 | { |
82 | qWarning( "WLANImp::writeConfig() called." ); | 86 | qWarning( "WLANImp::writeConfig() called." ); |
83 | config->setGroup( "Properties" ); | 87 | config->setGroup( "Properties" ); |
84 | if( essNon->isChecked() ) { | 88 | if( essNon->isChecked() ) { |
85 | config->writeEntry( "SSID", "any" ); | 89 | config->writeEntry( "SSID", "any" ); |
86 | } else { | 90 | } else { |
87 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); | 91 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); |
88 | } | 92 | } |
89 | if( networkInfrastructure->isChecked() ){ | 93 | if( networkInfrastructure->isChecked() ){ |
90 | config->writeEntry( "Mode", "Managed" ); | 94 | config->writeEntry( "Mode", "Managed" ); |
91 | } else if( network802->isChecked() ){ | 95 | } else if( network802->isChecked() ){ |
92 | config->writeEntry( "Mode", "adhoc" ); | 96 | config->writeEntry( "Mode", "adhoc" ); |
93 | } | 97 | } |
94 | config->writeEntry( "CHANNEL", networkChannel->value() ); | 98 | config->writeEntry( "CHANNEL", networkChannel->value() ); |
95 | // config->readEntry( "RATE", "auto" ); | 99 | // config->readEntry( "RATE", "auto" ); |
96 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); | 100 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); |
97 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); | 101 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); |
98 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); | 102 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); |
99 | if( keyRadio0->isChecked() ){ | 103 | if( keyRadio0->isChecked() ){ |
100 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); | 104 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); |
101 | } else if( keyRadio1->isChecked() ){ | 105 | } else if( keyRadio1->isChecked() ){ |
102 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); | 106 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); |
103 | } else if( keyRadio2->isChecked() ){ | 107 | } else if( keyRadio2->isChecked() ){ |
104 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); | 108 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); |
105 | } else if( keyRadio3->isChecked() ){ | 109 | } else if( keyRadio3->isChecked() ){ |
106 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); | 110 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); |
107 | } | 111 | } |
108 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); | 112 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); |
109 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); | 113 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); |
110 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); | 114 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); |
111 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); | 115 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); |
112 | return writeWirelessOpts( ); | 116 | return writeWirelessOpts( ); |
113 | } | 117 | } |
114 | 118 | ||
115 | /** | 119 | /** |
116 | */ | 120 | */ |
117 | void WLANImp::accept() | 121 | void WLANImp::accept() |
118 | { | 122 | { |
119 | if ( writeConfig() ){ | 123 | if ( writeConfig() ){ |
120 | interfaceSetup->saveChanges(); | 124 | interfaceSetup->saveChanges(); |
121 | QDialog::accept(); | 125 | QDialog::accept(); |
122 | } | 126 | } |
123 | } | 127 | } |
124 | 128 | ||
125 | bool WLANImp::writeWirelessOpts( QString scheme ) | 129 | bool WLANImp::writeWirelessOpts( QString scheme ) |
126 | { | 130 | { |
127 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 131 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
128 | QString prev = "/etc/pcmcia/wireless.opts"; | 132 | QString prev = "/etc/pcmcia/wireless.opts"; |
129 | QFile prevFile(prev); | 133 | QFile prevFile(prev); |
130 | if ( !prevFile.open( IO_ReadOnly ) ) | 134 | if ( !prevFile.open( IO_ReadOnly ) ) |
131 | return false; | 135 | return false; |
132 | 136 | ||
133 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; | 137 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; |
134 | QFile tmpFile(tmp); | 138 | QFile tmpFile(tmp); |
135 | if ( !tmpFile.open( IO_WriteOnly ) ) | 139 | if ( !tmpFile.open( IO_WriteOnly ) ) |
136 | return false; | 140 | return false; |
137 | 141 | ||
138 | bool retval = true; | 142 | bool retval = true; |
139 | 143 | ||
140 | QTextStream in( &prevFile ); | 144 | QTextStream in( &prevFile ); |
141 | QTextStream out( &tmpFile ); | 145 | QTextStream out( &tmpFile ); |
142 | 146 | ||
143 | config->setGroup("Properties"); | 147 | config->setGroup("Properties"); |
144 | 148 | ||
145 | QString line; | 149 | QString line; |
146 | bool found=false; | 150 | bool found=false; |
147 | bool done=false; | 151 | bool done=false; |
148 | while ( !in.atEnd() ) { | 152 | while ( !in.atEnd() ) { |
149 | QString line = in.readLine(); | 153 | QString line = in.readLine(); |
150 | QString wline = line.simplifyWhiteSpace(); | 154 | QString wline = line.simplifyWhiteSpace(); |
151 | if ( !done ) { | 155 | if ( !done ) { |
152 | if ( found ) { | 156 | if ( found ) { |
153 | // skip existing entry for this scheme, and write our own. | 157 | // skip existing entry for this scheme, and write our own. |
154 | if ( wline == ";;" ) { | 158 | if ( wline == ";;" ) { |
155 | found = false; | 159 | found = false; |
156 | continue; | 160 | continue; |
157 | } else { | 161 | } else { |
158 | continue; | 162 | continue; |
159 | } | 163 | } |
160 | } else { | 164 | } else { |
161 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { | 165 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { |
162 | found=true; | 166 | found=true; |
163 | continue; // skip this line | 167 | continue; // skip this line |
164 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { | 168 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { |
165 | // end - add new entry | 169 | // end - add new entry |
166 | // Not all fields have a GUI, but all are supported | 170 | // Not all fields have a GUI, but all are supported |
167 | // in the letwork configuration files. | 171 | // in the letwork configuration files. |
168 | static const char* txtfields[] = { | 172 | static const char* txtfields[] = { |
169 | 0 | 173 | 0 |
170 | }; | 174 | }; |
171 | QString readmode = config->readEntry( "Mode", "Managed" ); | 175 | QString readmode = config->readEntry( "Mode", "Managed" ); |
172 | QString mode; | 176 | QString mode; |
173 | if( readmode == "Managed" ){ | 177 | if( readmode == "Managed" ){ |
174 | mode = readmode; | 178 | mode = readmode; |
175 | } else if( readmode == "adhoc" ){ | 179 | } else if( readmode == "adhoc" ){ |
176 | mode = "Ad-Hoc"; | 180 | mode = "Ad-Hoc"; |
177 | } | 181 | } |
178 | QString key; | 182 | QString key; |
179 | if( wepEnabled->isChecked() ){ | 183 | if( wepEnabled->isChecked() ){ |
180 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 184 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
181 | switch( defaultkey ){ | 185 | switch( defaultkey ){ |
182 | case 0: | 186 | case 0: |
183 | key += keyLineEdit0->text(); | 187 | key += keyLineEdit0->text(); |
184 | break; | 188 | break; |
185 | case 1: | 189 | case 1: |
186 | key += keyLineEdit1->text(); | 190 | key += keyLineEdit1->text(); |
187 | break; | 191 | break; |
188 | case 2: | 192 | case 2: |
189 | key += keyLineEdit2->text(); | 193 | key += keyLineEdit2->text(); |
190 | break; | 194 | break; |
191 | case 3: | 195 | case 3: |
192 | key += keyLineEdit3->text(); | 196 | key += keyLineEdit3->text(); |
193 | break; | 197 | break; |
194 | } | 198 | } |
195 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") | 199 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") |
196 | key += " open"; | 200 | key += " open"; |
197 | } | 201 | } |
198 | out << scheme << ",*,*,*)" << "\n" | 202 | out << scheme << ",*,*,*)" << "\n" |
199 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" | 203 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" |
200 | << " MODE=" << mode << "\n" | 204 | << " MODE=" << mode << "\n" |
201 | << " KEY=" << Global::shellQuote( key ) << "\n" | 205 | << " KEY=" << Global::shellQuote( key ) << "\n" |
202 | << " RATE=" << "auto" << "\n" | 206 | << " RATE=" << "auto" << "\n" |
203 | ; | 207 | ; |
204 | if( mode != "Managed" ) | 208 | if( mode != "Managed" ) |
205 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; | 209 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; |
206 | const char** f = txtfields; | 210 | const char** f = txtfields; |
207 | while (*f) { | 211 | while (*f) { |
208 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; | 212 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; |
209 | ++f; | 213 | ++f; |
210 | } | 214 | } |
211 | out << " ;;\n"; | 215 | out << " ;;\n"; |
212 | done = true; | 216 | done = true; |
213 | } | 217 | } |
214 | } | 218 | } |
215 | } | 219 | } |
216 | out << line << "\n"; | 220 | out << line << "\n"; |
217 | } | 221 | } |
218 | 222 | ||
219 | prevFile.close(); | 223 | prevFile.close(); |
220 | tmpFile.close(); | 224 | tmpFile.close(); |
221 | QString initpath; | 225 | QString initpath; |
222 | //system("cardctl suspend"); | 226 | //system("cardctl suspend"); |
223 | if( QDir("/etc/rc.d/init.d").exists() ){ | 227 | if( QDir("/etc/rc.d/init.d").exists() ){ |
224 | initpath = "/etc/rc.d/init.d"; | 228 | initpath = "/etc/rc.d/init.d"; |
225 | } else if( QDir("/etc/init.d").exists() ){ | 229 | } else if( QDir("/etc/init.d").exists() ){ |
226 | initpath = "/etc/init.d"; | 230 | initpath = "/etc/init.d"; |
227 | } | 231 | } |
diff --git a/noncore/net/networksetup/wlan/wlanimp.h b/noncore/net/networksetup/wlan/wlanimp.h index 608d681..faa1674 100644 --- a/noncore/net/networksetup/wlan/wlanimp.h +++ b/noncore/net/networksetup/wlan/wlanimp.h | |||
@@ -1,31 +1,32 @@ | |||
1 | #ifndef WLANIMP_H | 1 | #ifndef WLANIMP_H |
2 | #define WLANIMP_H | 2 | #define WLANIMP_H |
3 | 3 | ||
4 | #include "wlan.h" | 4 | #include "wlan.h" |
5 | 5 | ||
6 | class InterfaceSetupImp; | 6 | class InterfaceSetupImp; |
7 | class Interface; | 7 | class Interface; |
8 | class Config; | 8 | class Config; |
9 | 9 | ||
10 | class WLANImp : public WLAN { | 10 | class WLANImp : public WLAN { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); | 14 | WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); |
15 | ~WLANImp( ); | 15 | ~WLANImp( ); |
16 | void setProfile(QString &profile); | ||
16 | 17 | ||
17 | protected: | 18 | protected: |
18 | void accept(); | 19 | void accept(); |
19 | 20 | ||
20 | private: | 21 | private: |
21 | void readConfig(); | 22 | void readConfig(); |
22 | bool writeConfig(); | 23 | bool writeConfig(); |
23 | bool writeWirelessOpts( QString scheme = "*" ); | 24 | bool writeWirelessOpts( QString scheme = "*" ); |
24 | bool writeWlanngOpts( QString scheme = "*" ); | 25 | bool writeWlanngOpts( QString scheme = "*" ); |
25 | Config* config; | 26 | Config* config; |
26 | InterfaceSetupImp *interfaceSetup; | 27 | InterfaceSetupImp *interfaceSetup; |
27 | 28 | ||
28 | }; | 29 | }; |
29 | 30 | ||
30 | #endif | 31 | #endif |
31 | 32 | ||
diff --git a/noncore/net/networksetup/wlan/wlanmodule.cpp b/noncore/net/networksetup/wlan/wlanmodule.cpp index c8becb0..b14fc0a 100644 --- a/noncore/net/networksetup/wlan/wlanmodule.cpp +++ b/noncore/net/networksetup/wlan/wlanmodule.cpp | |||
@@ -1,112 +1,113 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include "wlanimp.h" | 2 | #include "wlanimp.h" |
3 | #include "infoimp.h" | 3 | #include "infoimp.h" |
4 | #include "wextensions.h" | 4 | #include "wextensions.h" |
5 | #include "interfaceinformationimp.h" | 5 | #include "interfaceinformationimp.h" |
6 | 6 | ||
7 | #include <qlabel.h> | 7 | #include <qlabel.h> |
8 | #include <qprogressbar.h> | 8 | #include <qprogressbar.h> |
9 | #include <qtabwidget.h> | 9 | #include <qtabwidget.h> |
10 | 10 | ||
11 | /** | 11 | /** |
12 | * Constructor, find all of the possible interfaces | 12 | * Constructor, find all of the possible interfaces |
13 | */ | 13 | */ |
14 | WLANModule::WLANModule() : Module() { | 14 | WLANModule::WLANModule() : Module() { |
15 | } | 15 | } |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * Delete any interfaces that we own. | 18 | * Delete any interfaces that we own. |
19 | */ | 19 | */ |
20 | WLANModule::~WLANModule(){ | 20 | WLANModule::~WLANModule(){ |
21 | Interface *i; | 21 | Interface *i; |
22 | for ( i=list.first(); i != 0; i=list.next() ) | 22 | for ( i=list.first(); i != 0; i=list.next() ) |
23 | delete i; | 23 | delete i; |
24 | } | 24 | } |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * Change the current profile | 27 | * Change the current profile |
28 | */ | 28 | */ |
29 | void WLANModule::setProfile(QString newProfile){ | 29 | void WLANModule::setProfile(QString newProfile){ |
30 | profile = newProfile; | 30 | profile = newProfile; |
31 | } | 31 | } |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * get the icon name for this device. | 34 | * get the icon name for this device. |
35 | * @param Interface* can be used in determining the icon. | 35 | * @param Interface* can be used in determining the icon. |
36 | * @return QString the icon name (minus .png, .gif etc) | 36 | * @return QString the icon name (minus .png, .gif etc) |
37 | */ | 37 | */ |
38 | QString WLANModule::getPixmapName(Interface* ){ | 38 | QString WLANModule::getPixmapName(Interface* ){ |
39 | return "wlan"; | 39 | return "wlan"; |
40 | } | 40 | } |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Check to see if the interface i is owned by this module. | 43 | * Check to see if the interface i is owned by this module. |
44 | * @param Interface* interface to check against | 44 | * @param Interface* interface to check against |
45 | * @return bool true if i is owned by this module, false otherwise. | 45 | * @return bool true if i is owned by this module, false otherwise. |
46 | */ | 46 | */ |
47 | bool WLANModule::isOwner(Interface *i){ | 47 | bool WLANModule::isOwner(Interface *i){ |
48 | WExtensions we(i->getInterfaceName()); | 48 | WExtensions we(i->getInterfaceName()); |
49 | if(!we.doesHaveWirelessExtensions()) | 49 | if(!we.doesHaveWirelessExtensions()) |
50 | return false; | 50 | return false; |
51 | 51 | ||
52 | i->setHardwareName("802.11b"); | 52 | i->setHardwareName("802.11b"); |
53 | list.append(i); | 53 | list.append(i); |
54 | return true; | 54 | return true; |
55 | } | 55 | } |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Create, and return the WLANConfigure Module | 58 | * Create, and return the WLANConfigure Module |
59 | * @return QWidget* pointer to this modules configure. | 59 | * @return QWidget* pointer to this modules configure. |
60 | */ | 60 | */ |
61 | QWidget *WLANModule::configure(Interface *i){ | 61 | QWidget *WLANModule::configure(Interface *i){ |
62 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); | 62 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); |
63 | wlanconfig->setProfile(profile); | ||
63 | return wlanconfig; | 64 | return wlanconfig; |
64 | } | 65 | } |
65 | 66 | ||
66 | /** | 67 | /** |
67 | * Create, and return the Information Module | 68 | * Create, and return the Information Module |
68 | * @return QWidget* pointer to this modules info. | 69 | * @return QWidget* pointer to this modules info. |
69 | */ | 70 | */ |
70 | QWidget *WLANModule::information(Interface *i){ | 71 | QWidget *WLANModule::information(Interface *i){ |
71 | WExtensions we(i->getInterfaceName()); | 72 | WExtensions we(i->getInterfaceName()); |
72 | if(!we.doesHaveWirelessExtensions()) | 73 | if(!we.doesHaveWirelessExtensions()) |
73 | return NULL; | 74 | return NULL; |
74 | 75 | ||
75 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); | 76 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); |
76 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); | 77 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); |
77 | info->tabWidget->insertTab(information, "TCP/IP"); | 78 | info->tabWidget->insertTab(information, "TCP/IP"); |
78 | return info; | 79 | return info; |
79 | } | 80 | } |
80 | 81 | ||
81 | /** | 82 | /** |
82 | * Get all active (up or down) interfaces | 83 | * Get all active (up or down) interfaces |
83 | * @return QList<Interface> A list of interfaces that exsist that havn't | 84 | * @return QList<Interface> A list of interfaces that exsist that havn't |
84 | * been called by isOwner() | 85 | * been called by isOwner() |
85 | */ | 86 | */ |
86 | QList<Interface> WLANModule::getInterfaces(){ | 87 | QList<Interface> WLANModule::getInterfaces(){ |
87 | return list; | 88 | return list; |
88 | } | 89 | } |
89 | 90 | ||
90 | /** | 91 | /** |
91 | * Attempt to add a new interface as defined by name | 92 | * Attempt to add a new interface as defined by name |
92 | * @param name the name of the type of interface that should be created given | 93 | * @param name the name of the type of interface that should be created given |
93 | * by possibleNewInterfaces(); | 94 | * by possibleNewInterfaces(); |
94 | * @return Interface* NULL if it was unable to be created. | 95 | * @return Interface* NULL if it was unable to be created. |
95 | */ | 96 | */ |
96 | Interface *WLANModule::addNewInterface(QString ){ | 97 | Interface *WLANModule::addNewInterface(QString ){ |
97 | // We can't add a 802.11 interface, either the hardware will be there | 98 | // We can't add a 802.11 interface, either the hardware will be there |
98 | // or it wont. | 99 | // or it wont. |
99 | return NULL; | 100 | return NULL; |
100 | } | 101 | } |
101 | 102 | ||
102 | /** | 103 | /** |
103 | * Attempts to remove the interface, doesn't delete i | 104 | * Attempts to remove the interface, doesn't delete i |
104 | * @return bool true if successfull, false otherwise. | 105 | * @return bool true if successfull, false otherwise. |
105 | */ | 106 | */ |
106 | bool WLANModule::remove(Interface*){ | 107 | bool WLANModule::remove(Interface*){ |
107 | // Can't remove a hardware device, you can stop it though. | 108 | // Can't remove a hardware device, you can stop it though. |
108 | return false; | 109 | return false; |
109 | } | 110 | } |
110 | 111 | ||
111 | // wlanmodule.cpp | 112 | // wlanmodule.cpp |
112 | 113 | ||
diff --git a/noncore/settings/networksettings/TODO b/noncore/settings/networksettings/TODO index 0584f81..ec6d2c6 100644 --- a/noncore/settings/networksettings/TODO +++ b/noncore/settings/networksettings/TODO | |||
@@ -1,16 +1,16 @@ | |||
1 | CLEAN UP | 1 | CLEAN UP |
2 | 2 | ||
3 | Fix Profiles | 3 | Fix Profiles |
4 | 4 | ||
5 | Write dns script | 5 | Write dns script |
6 | 6 | ||
7 | |||
8 | WLAN needs to be re-written to not use Config | 7 | WLAN needs to be re-written to not use Config |
9 | WHERE Is DHCP info stored??? | ||
10 | |||
11 | PPP module needs to be written | ||
12 | 8 | ||
13 | Write a class that parses /proc and not ifconfig | 9 | Write a class that parses /proc and not ifconfig |
10 | udchcp needs to output the dhcp information | ||
11 | |||
12 | Possible other modules to write: ppp, ipsec, bluetooth, ipchains | ||
13 | |||
14 | PPP module needs to scan pppd.tdb to see what is currently active | ||
14 | 15 | ||
15 | Possible other modules: ipsec, bluetooth, ipchains | ||
16 | 16 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp index 97c05cc..d42b45d 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.cpp | |||
@@ -1,148 +1,149 @@ | |||
1 | #include "interfacesetupimp.h" | 1 | #include "interfacesetupimp.h" |
2 | #include "interface.h" | 2 | #include "interface.h" |
3 | #include "interfaces.h" | 3 | #include "interfaces.h" |
4 | 4 | ||
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | #include <qcombobox.h> | 6 | #include <qcombobox.h> |
7 | #include <qcheckbox.h> | 7 | #include <qcheckbox.h> |
8 | #include <qlineedit.h> | 8 | #include <qlineedit.h> |
9 | #include <qspinbox.h> | 9 | #include <qspinbox.h> |
10 | #include <qgroupbox.h> | 10 | #include <qgroupbox.h> |
11 | #include <qlabel.h> | 11 | #include <qlabel.h> |
12 | 12 | ||
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | 14 | ||
15 | #include <assert.h> | 15 | #include <assert.h> |
16 | 16 | ||
17 | #define DNSSCRIPT "changedns" | 17 | #define DNSSCRIPT "changedns" |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * Constuctor. Set up the connection and load the first profile. | 20 | * Constuctor. Set up the connection and load the first profile. |
21 | */ | 21 | */ |
22 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl){ | 22 | InterfaceSetupImp::InterfaceSetupImp(QWidget* parent, const char* name, Interface *i, WFlags fl) : InterfaceSetup(parent, name, fl){ |
23 | assert(parent); | 23 | assert(parent); |
24 | assert(i); | 24 | assert(i); |
25 | interface = i; | 25 | interface = i; |
26 | interfaces = new Interfaces(); | 26 | interfaces = new Interfaces(); |
27 | bool error = false; | 27 | bool error = false; |
28 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 28 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
29 | staticGroupBox->hide(); | 29 | staticGroupBox->hide(); |
30 | dhcpCheckBox->hide(); | 30 | dhcpCheckBox->hide(); |
31 | leaseTime->hide(); | 31 | leaseTime->hide(); |
32 | leaseHoursLabel->hide(); | 32 | leaseHoursLabel->hide(); |
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * Save the current settings, then write out the interfaces file and close. | 37 | * Save the current settings, then write out the interfaces file and close. |
38 | */ | 38 | */ |
39 | void InterfaceSetupImp::saveChanges(){ | 39 | void InterfaceSetupImp::saveChanges(){ |
40 | if(!saveSettings()) | 40 | if(!saveSettings()) |
41 | return; | 41 | return; |
42 | interfaces->write(); | 42 | interfaces->write(); |
43 | } | 43 | } |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * Save the settings for the current Interface. | 46 | * Save the settings for the current Interface. |
47 | * @return bool true if successfull, false otherwise | 47 | * @return bool true if successfull, false otherwise |
48 | */ | 48 | */ |
49 | bool InterfaceSetupImp::saveSettings(){ | 49 | bool InterfaceSetupImp::saveSettings(){ |
50 | // eh can't really do anything about it other then return. :-D | 50 | // eh can't really do anything about it other then return. :-D |
51 | if(!interfaces->isInterfaceSet()) | 51 | if(!interfaces->isInterfaceSet()) |
52 | return true; | 52 | return true; |
53 | 53 | ||
54 | bool error = false; | 54 | bool error = false; |
55 | // Loopback case | 55 | // Loopback case |
56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ | 56 | if(interfaces->getInterfaceMethod(error) == INTERFACES_LOOPBACK){ |
57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 57 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
58 | return true; | 58 | return true; |
59 | } | 59 | } |
60 | 60 | ||
61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty() || firstDNSLineEdit->text().isEmpty())){ | 61 | if(!dhcpCheckBox->isChecked() && (ipAddressEdit->text().isEmpty() || subnetMaskEdit->text().isEmpty() || firstDNSLineEdit->text().isEmpty())){ |
62 | QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n gateway and the first dns entries.", "Ok"); | 62 | QMessageBox::information(this, "Empy Fields.", "Please fill in address, subnet,\n gateway and the first dns entries.", "Ok"); |
63 | return false; | 63 | return false; |
64 | } | 64 | } |
65 | interfaces->removeAllInterfaceOptions(); | 65 | interfaces->removeAllInterfaceOptions(); |
66 | 66 | ||
67 | // DHCP | 67 | // DHCP |
68 | if(dhcpCheckBox->isChecked()){ | 68 | if(dhcpCheckBox->isChecked()){ |
69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); | 69 | interfaces->setInterfaceMethod(INTERFACES_METHOD_DHCP); |
70 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); | 70 | interfaces->setInterfaceOption("leasehours", QString("%1").arg(leaseTime->value())); |
71 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); | 71 | interfaces->setInterfaceOption("leasetime", QString("%1").arg(leaseTime->value()*60*60)); |
72 | } | 72 | } |
73 | else{ | 73 | else{ |
74 | interfaces->setInterfaceMethod("static"); | 74 | interfaces->setInterfaceMethod("static"); |
75 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); | 75 | interfaces->setInterfaceOption("address", ipAddressEdit->text()); |
76 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); | 76 | interfaces->setInterfaceOption("netmask", subnetMaskEdit->text()); |
77 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); | 77 | interfaces->setInterfaceOption("gateway", gatewayEdit->text()); |
78 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); | 78 | QString dns = firstDNSLineEdit->text() + " " + secondDNSLineEdit->text(); |
79 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); | 79 | interfaces->setInterfaceOption("up "DNSSCRIPT" -a ", dns); |
80 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); | 80 | interfaces->setInterfaceOption("down "DNSSCRIPT" -r ", dns); |
81 | } | 81 | } |
82 | 82 | ||
83 | // IP Information | 83 | // IP Information |
84 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); | 84 | interfaces->setAuto(interface->getInterfaceName(), autoStart->isChecked()); |
85 | return true; | 85 | return true; |
86 | } | 86 | } |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * The Profile has changed. | 89 | * The Profile has changed. |
90 | * @profile the new profile. | 90 | * @profile the new profile. |
91 | */ | 91 | */ |
92 | void InterfaceSetupImp::setProfile(const QString &profile){ | 92 | void InterfaceSetupImp::setProfile(const QString &profile){ |
93 | QString newInterfaceName = interface->getInterfaceName(); | 93 | QString newInterfaceName = interface->getInterfaceName(); |
94 | if(profile.length() > 0) | 94 | if(profile.length() > 0) |
95 | newInterfaceName += "_" + profile; | 95 | newInterfaceName += "_" + profile; |
96 | qDebug("InterfaceSetupImp::setProfile"); | ||
96 | // See if we have to make a interface. | 97 | // See if we have to make a interface. |
97 | if(!interfaces->setInterface(newInterfaceName)){ | 98 | if(!interfaces->setInterface(newInterfaceName)){ |
98 | // Add making for this new interface if need too | 99 | // Add making for this new interface if need too |
99 | if(profile != ""){ | 100 | if(profile != ""){ |
100 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); | 101 | interfaces->copyInterface(interface->getInterfaceName(), newInterfaceName); |
101 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 102 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
102 | interfaces->addMapping(interface->getInterfaceName()); | 103 | interfaces->addMapping(interface->getInterfaceName()); |
103 | if(!interfaces->setMapping(interface->getInterfaceName())){ | 104 | if(!interfaces->setMapping(interface->getInterfaceName())){ |
104 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); | 105 | qDebug("InterfaceSetupImp: Added Mapping, but still can't set."); |
105 | return; | 106 | return; |
106 | } | 107 | } |
107 | } | 108 | } |
108 | interfaces->setMap("map", newInterfaceName); | 109 | interfaces->setMap("map", newInterfaceName); |
109 | interfaces->setScript("getprofile.sh"); | 110 | interfaces->setScript("getprofile.sh"); |
110 | } | 111 | } |
111 | else{ | 112 | else{ |
112 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); | 113 | interfaces->addInterface(newInterfaceName, INTERFACES_FAMILY_INET, INTERFACES_METHOD_DHCP); |
113 | if(!interfaces->setInterface(newInterfaceName)){ | 114 | if(!interfaces->setInterface(newInterfaceName)){ |
114 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); | 115 | qDebug("InterfaceSetupImp: Added interface, but still can't set."); |
115 | return; | 116 | return; |
116 | } | 117 | } |
117 | } | 118 | } |
118 | } | 119 | } |
119 | 120 | ||
120 | // We must have a valid interface to get this far so read some settings. | 121 | // We must have a valid interface to get this far so read some settings. |
121 | 122 | ||
122 | // DHCP | 123 | // DHCP |
123 | bool error = false; | 124 | bool error = false; |
124 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) | 125 | if(interfaces->getInterfaceMethod(error) == INTERFACES_METHOD_DHCP) |
125 | dhcpCheckBox->setChecked(true); | 126 | dhcpCheckBox->setChecked(true); |
126 | else | 127 | else |
127 | dhcpCheckBox->setChecked(false); | 128 | dhcpCheckBox->setChecked(false); |
128 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); | 129 | leaseTime->setValue(interfaces->getInterfaceOption("leasehours", error).toInt()); |
129 | if(error) | 130 | if(error) |
130 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); | 131 | leaseTime->setValue(interfaces->getInterfaceOption("leasetime", error).toInt()/60/60); |
131 | if(error) | 132 | if(error) |
132 | leaseTime->setValue(24); | 133 | leaseTime->setValue(24); |
133 | 134 | ||
134 | // IP Information | 135 | // IP Information |
135 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); | 136 | autoStart->setChecked(interfaces->isAuto(interface->getInterfaceName())); |
136 | QString dns = interfaces->getInterfaceOption("up interfacednsscript -a", error); | 137 | QString dns = interfaces->getInterfaceOption("up interfacednsscript -a", error); |
137 | if(dns.contains(" ")){ | 138 | if(dns.contains(" ")){ |
138 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); | 139 | firstDNSLineEdit->setText(dns.mid(0, dns.find(" "))); |
139 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); | 140 | secondDNSLineEdit->setText(dns.mid(dns.find(" ")+1, dns.length())); |
140 | } | 141 | } |
141 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); | 142 | ipAddressEdit->setText(interfaces->getInterfaceOption("address", error)); |
142 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); | 143 | subnetMaskEdit->setText(interfaces->getInterfaceOption("netmask", error)); |
143 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); | 144 | gatewayEdit->setText(interfaces->getInterfaceOption("gateway", error)); |
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | // interfacesetup.cpp | 148 | // interfacesetup.cpp |
148 | 149 | ||
diff --git a/noncore/settings/networksettings/interfaces/interfacesetupimp.h b/noncore/settings/networksettings/interfaces/interfacesetupimp.h index 936f2be..3bbf34e 100644 --- a/noncore/settings/networksettings/interfaces/interfacesetupimp.h +++ b/noncore/settings/networksettings/interfaces/interfacesetupimp.h | |||
@@ -1,49 +1,55 @@ | |||
1 | #ifndef INTERFACESETUPIMP_H | 1 | #ifndef INTERFACESETUPIMP_H |
2 | #define INTERFACESETUPIMP_H | 2 | #define INTERFACESETUPIMP_H |
3 | 3 | ||
4 | #include "interfacesetup.h" | 4 | #include "interfacesetup.h" |
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | 6 | ||
7 | class Interface; | 7 | class Interface; |
8 | class Interfaces; | 8 | class Interfaces; |
9 | 9 | ||
10 | class InterfaceSetupImp : public InterfaceSetup { | 10 | class InterfaceSetupImp : public InterfaceSetup { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0); | 14 | InterfaceSetupImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, WFlags fl = 0); |
15 | void saveChanges(); | 15 | void saveChanges(); |
16 | 16 | ||
17 | public slots: | 17 | public slots: |
18 | void setProfile(const QString &profile); | 18 | void setProfile(const QString &profile); |
19 | bool saveSettings(); | 19 | bool saveSettings(); |
20 | private: | 20 | private: |
21 | Interfaces *interfaces; | 21 | Interfaces *interfaces; |
22 | Interface *interface; | 22 | Interface *interface; |
23 | 23 | ||
24 | }; | 24 | }; |
25 | 25 | ||
26 | 26 | ||
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | 28 | ||
29 | class InterfaceSetupImpDialog : public QDialog { | 29 | class InterfaceSetupImpDialog : public QDialog { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | 31 | ||
32 | public: | 32 | public: |
33 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ | 33 | InterfaceSetupImpDialog(QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = false, WFlags fl = 0) : QDialog(parent, name, modal, fl){ |
34 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); | 34 | QVBoxLayout *InterfaceSetupLayout = new QVBoxLayout( this ); |
35 | setCaption("Interface Setup"); | 35 | setCaption("Interface Setup"); |
36 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); | 36 | interfaceSetup = new InterfaceSetupImp(this, "InterfaceSetup",i,fl); |
37 | InterfaceSetupLayout->addWidget( interfaceSetup ); | 37 | InterfaceSetupLayout->addWidget( interfaceSetup ); |
38 | }; | 38 | }; |
39 | void setProfile(QString &profile){ interfaceSetup->setProfile(profile);}; | ||
39 | 40 | ||
41 | private: | ||
40 | InterfaceSetupImp *interfaceSetup; | 42 | InterfaceSetupImp *interfaceSetup; |
41 | 43 | ||
42 | protected slots: | 44 | protected slots: |
43 | void accept(){ interfaceSetup->saveChanges(); }; | 45 | void accept(){ |
46 | interfaceSetup->saveChanges(); | ||
47 | QDialog::accept(); | ||
48 | }; | ||
49 | |||
44 | }; | 50 | }; |
45 | 51 | ||
46 | #endif | 52 | #endif |
47 | 53 | ||
48 | // interfacesetupimp.h | 54 | // interfacesetupimp.h |
49 | 55 | ||
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index b9fff56..6440bd4 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -41,504 +41,497 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(par | |||
41 | 41 | ||
42 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); | 42 | connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); |
43 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); | 43 | connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); |
44 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); | 44 | connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); |
45 | 45 | ||
46 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); | 46 | connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); |
47 | // Load connections. | 47 | // Load connections. |
48 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); | 48 | loadModules(QPEApplication::qpeDir() + "/plugins/networksetup"); |
49 | getInterfaceList(); | 49 | getInterfaceList(); |
50 | connectionList->header()->hide(); | 50 | connectionList->header()->hide(); |
51 | 51 | ||
52 | 52 | ||
53 | Config cfg("NetworkSetup"); | 53 | Config cfg("NetworkSetup"); |
54 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 54 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
55 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 55 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
56 | profilesList->insertItem((*it)); | 56 | profilesList->insertItem((*it)); |
57 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 57 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
58 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 58 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
59 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 59 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
60 | 60 | ||
61 | QFile file(scheme); | 61 | QFile file(scheme); |
62 | if ( file.open(IO_ReadOnly) ) { // file opened successfully | 62 | if ( file.open(IO_ReadOnly) ) { // file opened successfully |
63 | QTextStream stream( &file ); // use a text stream | 63 | QTextStream stream( &file ); // use a text stream |
64 | while ( !stream.eof() ) { // until end of file... | 64 | while ( !stream.eof() ) { // until end of file... |
65 | QString line = stream.readLine(); // line of text excluding '\n' | 65 | QString line = stream.readLine(); // line of text excluding '\n' |
66 | if(line.contains("SCHEME")){ | 66 | if(line.contains("SCHEME")){ |
67 | line = line.mid(7, line.length()); | 67 | line = line.mid(7, line.length()); |
68 | currentProfileLabel->setText(line); | 68 | currentProfileLabel->setText(line); |
69 | break; | 69 | break; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | file.close(); | 72 | file.close(); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * Deconstructor. Save profiles. Delete loaded libraries. | 77 | * Deconstructor. Save profiles. Delete loaded libraries. |
78 | */ | 78 | */ |
79 | MainWindowImp::~MainWindowImp(){ | 79 | MainWindowImp::~MainWindowImp(){ |
80 | // Save profiles. | 80 | // Save profiles. |
81 | Config cfg("NetworkSetup"); | 81 | Config cfg("NetworkSetup"); |
82 | cfg.setGroup("General"); | 82 | cfg.setGroup("General"); |
83 | cfg.writeEntry("Profiles", profiles.join(" ")); | 83 | cfg.writeEntry("Profiles", profiles.join(" ")); |
84 | 84 | ||
85 | // Delete all interfaces that don't have owners. | 85 | // Delete all interfaces that don't have owners. |
86 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 86 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
87 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ | 87 | for( iIt = items.begin(); iIt != items.end(); ++iIt ){ |
88 | if(iIt.key()->getModuleOwner() == NULL) | 88 | if(iIt.key()->getModuleOwner() == NULL) |
89 | delete iIt.key(); | 89 | delete iIt.key(); |
90 | } | 90 | } |
91 | 91 | ||
92 | // Delete Modules and Libraries | 92 | // Delete Modules and Libraries |
93 | QMap<Module*, QLibrary*>::Iterator it; | 93 | QMap<Module*, QLibrary*>::Iterator it; |
94 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 94 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
95 | delete it.key(); | 95 | delete it.key(); |
96 | // I wonder why I can't delete the libraries | 96 | // I wonder why I can't delete the libraries |
97 | // What fucking shit this is. | 97 | // What fucking shit this is. |
98 | //delete it.data(); | 98 | //delete it.data(); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | /** | 102 | /** |
103 | * Load all modules that are found in the path | 103 | * Load all modules that are found in the path |
104 | * @param path a directory that is scaned for any plugins that can be loaded | 104 | * @param path a directory that is scaned for any plugins that can be loaded |
105 | * and attempts to load them | 105 | * and attempts to load them |
106 | */ | 106 | */ |
107 | void MainWindowImp::loadModules(QString path){ | 107 | void MainWindowImp::loadModules(QString path){ |
108 | //qDebug(path.latin1()); | 108 | //qDebug(path.latin1()); |
109 | QDir d(path); | 109 | QDir d(path); |
110 | if(!d.exists()) | 110 | if(!d.exists()) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | // Don't want sym links | 113 | // Don't want sym links |
114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 114 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
115 | const QFileInfoList *list = d.entryInfoList(); | 115 | const QFileInfoList *list = d.entryInfoList(); |
116 | QFileInfoListIterator it( *list ); | 116 | QFileInfoListIterator it( *list ); |
117 | QFileInfo *fi; | 117 | QFileInfo *fi; |
118 | while ( (fi=it.current()) ) { | 118 | while ( (fi=it.current()) ) { |
119 | if(fi->fileName().contains(".so")){ | 119 | if(fi->fileName().contains(".so")){ |
120 | loadPlugin(path + "/" + fi->fileName()); | 120 | loadPlugin(path + "/" + fi->fileName()); |
121 | } | 121 | } |
122 | ++it; | 122 | ++it; |
123 | } | 123 | } |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Attempt to load a function and resolve a function. | 127 | * Attempt to load a function and resolve a function. |
128 | * @param pluginFileName - the name of the file in which to attempt to load | 128 | * @param pluginFileName - the name of the file in which to attempt to load |
129 | * @param resolveString - function pointer to resolve | 129 | * @param resolveString - function pointer to resolve |
130 | * @return pointer to the function with name resolveString or NULL | 130 | * @return pointer to the function with name resolveString or NULL |
131 | */ | 131 | */ |
132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ | 132 | Module* MainWindowImp::loadPlugin(QString pluginFileName, QString resolveString){ |
133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); | 133 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); |
134 | QLibrary *lib = new QLibrary(pluginFileName); | 134 | QLibrary *lib = new QLibrary(pluginFileName); |
135 | void *functionPointer = lib->resolve(resolveString); | 135 | void *functionPointer = lib->resolve(resolveString); |
136 | if( !functionPointer ){ | 136 | if( !functionPointer ){ |
137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 137 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
138 | delete lib; | 138 | delete lib; |
139 | return NULL; | 139 | return NULL; |
140 | } | 140 | } |
141 | 141 | ||
142 | // Try to get an object. | 142 | // Try to get an object. |
143 | Module *object = ((Module* (*)()) functionPointer)(); | 143 | Module *object = ((Module* (*)()) functionPointer)(); |
144 | if(object == NULL){ | 144 | if(object == NULL){ |
145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 145 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
146 | delete lib; | 146 | delete lib; |
147 | return NULL; | 147 | return NULL; |
148 | } | 148 | } |
149 | 149 | ||
150 | // Store for deletion later | 150 | // Store for deletion later |
151 | libraries.insert(object, lib); | 151 | libraries.insert(object, lib); |
152 | return object; | 152 | return object; |
153 | } | 153 | } |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 156 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
157 | * load the plugin and append it to the list | 157 | * load the plugin and append it to the list |
158 | */ | 158 | */ |
159 | void MainWindowImp::addClicked(){ | 159 | void MainWindowImp::addClicked(){ |
160 | QMap<Module*, QLibrary*>::Iterator it; | 160 | QMap<Module*, QLibrary*>::Iterator it; |
161 | QMap<QString, QString> list; | 161 | QMap<QString, QString> list; |
162 | QMap<QString, Module*> newInterfaceOwners; | 162 | QMap<QString, Module*> newInterfaceOwners; |
163 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 163 | list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
164 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 164 | list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 165 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
166 | if(it.key()){ | 166 | if(it.key()){ |
167 | (it.key())->possibleNewInterfaces(list); | 167 | (it.key())->possibleNewInterfaces(list); |
168 | } | 168 | } |
169 | } | 169 | } |
170 | // See if the list has anything that we can add. | 170 | // See if the list has anything that we can add. |
171 | if(list.count() == 0){ | 171 | if(list.count() == 0){ |
172 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); | 172 | QMessageBox::information(this, "Sorry", "Nothing to add.", "Ok"); |
173 | return; | 173 | return; |
174 | } | 174 | } |
175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 175 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
176 | addNewConnection.addConnections(list); | 176 | addNewConnection.addConnections(list); |
177 | addNewConnection.showMaximized(); | 177 | addNewConnection.showMaximized(); |
178 | if(QDialog::Accepted == addNewConnection.exec()){ | 178 | if(QDialog::Accepted == addNewConnection.exec()){ |
179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 179 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
180 | if(!item) | 180 | if(!item) |
181 | return; | 181 | return; |
182 | 182 | ||
183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 183 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
184 | if(it.key()){ | 184 | if(it.key()){ |
185 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 185 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
186 | if(i){ | 186 | if(i){ |
187 | interfaceNames.insert(i->getInterfaceName(), i); | 187 | interfaceNames.insert(i->getInterfaceName(), i); |
188 | updateInterface(i); | 188 | updateInterface(i); |
189 | } | 189 | } |
190 | } | 190 | } |
191 | } | 191 | } |
192 | } | 192 | } |
193 | } | 193 | } |
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Prompt the user to see if they really want to do this. | 196 | * Prompt the user to see if they really want to do this. |
197 | * If they do then remove from the list and unload. | 197 | * If they do then remove from the list and unload. |
198 | */ | 198 | */ |
199 | void MainWindowImp::removeClicked(){ | 199 | void MainWindowImp::removeClicked(){ |
200 | QListViewItem *item = connectionList->currentItem(); | 200 | QListViewItem *item = connectionList->currentItem(); |
201 | if(!item) { | 201 | if(!item) { |
202 | QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); | 202 | QMessageBox::information(this, "Sorry","Please select an interface First.", "Ok"); |
203 | return; | 203 | return; |
204 | } | 204 | } |
205 | 205 | ||
206 | Interface *i = interfaceItems[item]; | 206 | Interface *i = interfaceItems[item]; |
207 | if(i->getModuleOwner() == NULL){ | 207 | if(i->getModuleOwner() == NULL){ |
208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); | 208 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", "Ok"); |
209 | } | 209 | } |
210 | else{ | 210 | else{ |
211 | if(!i->getModuleOwner()->remove(i)) | 211 | if(!i->getModuleOwner()->remove(i)) |
212 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); | 212 | QMessageBox::information(this, "Error", "Unable to remove.", "Ok"); |
213 | else{ | 213 | else{ |
214 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); | 214 | QMessageBox::information(this, "Success", "Interface was removed.", "Ok"); |
215 | // TODO memory managment.... | 215 | // TODO memory managment.... |
216 | // who deletes the interface? | 216 | // who deletes the interface? |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | 220 | ||
221 | /** | 221 | /** |
222 | * Pull up the configure about the currently selected interface. | 222 | * Pull up the configure about the currently selected interface. |
223 | * Report an error if no interface is selected. | 223 | * Report an error if no interface is selected. |
224 | * If the interface has a module owner then request its configure. | 224 | * If the interface has a module owner then request its configure. |
225 | */ | 225 | */ |
226 | void MainWindowImp::configureClicked(){ | 226 | void MainWindowImp::configureClicked(){ |
227 | QListViewItem *item = connectionList->currentItem(); | 227 | QListViewItem *item = connectionList->currentItem(); |
228 | if(!item){ | 228 | if(!item){ |
229 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); | 229 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); |
230 | return; | 230 | return; |
231 | } | 231 | } |
232 | 232 | ||
233 | QString currentProfile = currentProfileLabel->text(); | ||
234 | if(profilesList->count() <= 1 || currentProfile == "All"){ | ||
235 | currentProfile = ""; | ||
236 | } | ||
237 | |||
238 | Interface *i = interfaceItems[item]; | 233 | Interface *i = interfaceItems[item]; |
239 | if(i->getModuleOwner()){ | 234 | if(i->getModuleOwner()){ |
240 | i->getModuleOwner()->setProfile(currentProfile); | ||
241 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 235 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
242 | if(moduleConfigure != NULL){ | 236 | if(moduleConfigure != NULL){ |
243 | moduleConfigure->showMaximized(); | 237 | moduleConfigure->showMaximized(); |
244 | moduleConfigure->show(); | 238 | moduleConfigure->show(); |
245 | return; | 239 | return; |
246 | } | 240 | } |
247 | } | 241 | } |
248 | 242 | ||
249 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose); | 243 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose); |
250 | //configure->setProfile(currentProfile); | 244 | QString currentProfileText = currentProfileLabel->text(); |
245 | if(currentProfileText.upper() == "ALL"); | ||
246 | currentProfileText = ""; | ||
247 | configure->setProfile(currentProfileText); | ||
251 | configure->showMaximized(); | 248 | configure->showMaximized(); |
252 | configure->show(); | 249 | configure->show(); |
253 | } | 250 | } |
254 | 251 | ||
255 | /** | 252 | /** |
256 | * Pull up the information about the currently selected interface. | 253 | * Pull up the information about the currently selected interface. |
257 | * Report an error if no interface is selected. | 254 | * Report an error if no interface is selected. |
258 | * If the interface has a module owner then request its configure. | 255 | * If the interface has a module owner then request its configure. |
259 | */ | 256 | */ |
260 | void MainWindowImp::informationClicked(){ | 257 | void MainWindowImp::informationClicked(){ |
261 | QListViewItem *item = connectionList->currentItem(); | 258 | QListViewItem *item = connectionList->currentItem(); |
262 | if(!item){ | 259 | if(!item){ |
263 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 260 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
264 | return; | 261 | return; |
265 | } | 262 | } |
266 | 263 | ||
267 | Interface *i = interfaceItems[item]; | 264 | Interface *i = interfaceItems[item]; |
268 | if(!i->isAttached()){ | 265 | if(!i->isAttached()){ |
269 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 266 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
270 | return; | 267 | return; |
271 | } | 268 | } |
272 | 269 | ||
273 | QStringList list; | ||
274 | for(uint i = 0; i < profilesList->count(); i++){ | ||
275 | list.append(profilesList->text(i)); | ||
276 | } | ||
277 | |||
278 | if(i->getModuleOwner()){ | 270 | if(i->getModuleOwner()){ |
279 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 271 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
280 | if(moduleInformation != NULL){ | 272 | if(moduleInformation != NULL){ |
281 | moduleInformation->showMaximized(); | 273 | moduleInformation->showMaximized(); |
282 | moduleInformation->show(); | 274 | moduleInformation->show(); |
283 | return; | 275 | return; |
284 | } | 276 | } |
285 | } | 277 | } |
286 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); | 278 | InterfaceInformationImp *information = new InterfaceInformationImp(0, "InterfaceSetupImp", i, true); |
287 | information->showMaximized(); | 279 | information->showMaximized(); |
288 | information->show(); | 280 | information->show(); |
289 | } | 281 | } |
290 | 282 | ||
291 | /** | 283 | /** |
292 | * Aquire the list of active interfaces from ifconfig | 284 | * Aquire the list of active interfaces from ifconfig |
293 | * Call ifconfig and ifconfig -a | 285 | * Call ifconfig and ifconfig -a |
294 | */ | 286 | */ |
295 | void MainWindowImp::getInterfaceList(){ | 287 | void MainWindowImp::getInterfaceList(){ |
296 | KShellProcess *processAll = new KShellProcess(); | 288 | KShellProcess *processAll = new KShellProcess(); |
297 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; | 289 | *processAll << "/sbin/ifconfig" << "-a" << " > " TEMP_ALL; |
298 | connect(processAll, SIGNAL(processExited(KProcess *)), | 290 | connect(processAll, SIGNAL(processExited(KProcess *)), |
299 | this, SLOT(jobDone(KProcess *))); | 291 | this, SLOT(jobDone(KProcess *))); |
300 | threads.insert(processAll, TEMP_ALL); | 292 | threads.insert(processAll, TEMP_ALL); |
301 | 293 | ||
302 | KShellProcess *process = new KShellProcess(); | 294 | KShellProcess *process = new KShellProcess(); |
303 | *process << "/sbin/ifconfig" << " > " TEMP_UP; | 295 | *process << "/sbin/ifconfig" << " > " TEMP_UP; |
304 | connect(process, SIGNAL(processExited(KProcess *)), | 296 | connect(process, SIGNAL(processExited(KProcess *)), |
305 | this, SLOT(jobDone(KProcess *))); | 297 | this, SLOT(jobDone(KProcess *))); |
306 | threads.insert(process, TEMP_UP); | 298 | threads.insert(process, TEMP_UP); |
307 | 299 | ||
308 | processAll->start(KShellProcess::NotifyOnExit); | 300 | processAll->start(KShellProcess::NotifyOnExit); |
309 | process->start(KShellProcess::NotifyOnExit); | 301 | process->start(KShellProcess::NotifyOnExit); |
310 | } | 302 | } |
311 | 303 | ||
312 | void MainWindowImp::jobDone(KProcess *process){ | 304 | void MainWindowImp::jobDone(KProcess *process){ |
313 | QString fileName = threads[process]; | 305 | QString fileName = threads[process]; |
314 | threads.remove(process); | 306 | threads.remove(process); |
315 | delete process; | 307 | delete process; |
316 | 308 | ||
317 | QFile file(fileName); | 309 | QFile file(fileName); |
318 | if (!file.open(IO_ReadOnly)){ | 310 | if (!file.open(IO_ReadOnly)){ |
319 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); | 311 | qDebug(QString("MainWindowImp: Can't open file: %1").arg(fileName).latin1()); |
320 | return; | 312 | return; |
321 | } | 313 | } |
322 | 314 | ||
323 | QTextStream stream( &file ); | 315 | QTextStream stream( &file ); |
324 | QString line; | 316 | QString line; |
325 | while ( !stream.eof() ) { | 317 | while ( !stream.eof() ) { |
326 | line = stream.readLine(); | 318 | line = stream.readLine(); |
327 | int space = line.find(" "); | 319 | int space = line.find(" "); |
328 | if(space > 1){ | 320 | if(space > 1){ |
329 | // We have found an interface | 321 | // We have found an interface |
330 | QString interfaceName = line.mid(0, space); | 322 | QString interfaceName = line.mid(0, space); |
331 | Interface *i; | 323 | Interface *i; |
332 | // We have found an interface | 324 | // We have found an interface |
333 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); | 325 | //qDebug(QString("MainWindowImp: Found Interface: %1").arg(line).latin1()); |
334 | // See if we already have it | 326 | // See if we already have it |
335 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ | 327 | if(interfaceNames.find(interfaceName) == interfaceNames.end()){ |
336 | if(fileName == TEMP_ALL) | 328 | if(fileName == TEMP_ALL) |
337 | i = new Interface(this, interfaceName, false); | 329 | i = new Interface(this, interfaceName, false); |
338 | else | 330 | else |
339 | i = new Interface(this, interfaceName, true); | 331 | i = new Interface(this, interfaceName, true); |
340 | i->setAttached(true); | 332 | i->setAttached(true); |
341 | 333 | ||
342 | QString hardName = "Ethernet"; | 334 | QString hardName = "Ethernet"; |
343 | int hardwareName = line.find("Link encap:"); | 335 | int hardwareName = line.find("Link encap:"); |
344 | int macAddress = line.find("HWaddr"); | 336 | int macAddress = line.find("HWaddr"); |
345 | if(macAddress == -1) | 337 | if(macAddress == -1) |
346 | macAddress = line.length(); | 338 | macAddress = line.length(); |
347 | if(hardwareName != -1) | 339 | if(hardwareName != -1) |
348 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); | 340 | i->setHardwareName(line.mid(hardwareName+11, macAddress-(hardwareName+11)) ); |
349 | 341 | ||
350 | interfaceNames.insert(i->getInterfaceName(), i); | 342 | interfaceNames.insert(i->getInterfaceName(), i); |
351 | updateInterface(i); | 343 | updateInterface(i); |
352 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 344 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
353 | } | 345 | } |
354 | // It was an interface we already had. | 346 | // It was an interface we already had. |
355 | else{ | 347 | else{ |
356 | if(fileName != TEMP_ALL) | 348 | if(fileName != TEMP_ALL) |
357 | (interfaceNames[interfaceName])->setStatus(true); | 349 | (interfaceNames[interfaceName])->setStatus(true); |
358 | } | 350 | } |
359 | } | 351 | } |
360 | } | 352 | } |
361 | file.close(); | 353 | file.close(); |
362 | QFile::remove(fileName); | 354 | QFile::remove(fileName); |
363 | 355 | ||
364 | if(threads.count() == 0){ | 356 | if(threads.count() == 0){ |
365 | Interfaces i; | 357 | Interfaces i; |
366 | QStringList list = i.getInterfaceList(); | 358 | QStringList list = i.getInterfaceList(); |
367 | QMap<QString, Interface*>::Iterator it; | 359 | QMap<QString, Interface*>::Iterator it; |
368 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { | 360 | for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { |
369 | bool found = false; | 361 | bool found = false; |
370 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ | 362 | for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ |
371 | if(it.key() == (*ni)) | 363 | if(it.key() == (*ni)) |
372 | found = true; | 364 | found = true; |
373 | } | 365 | } |
374 | if(!found){ | 366 | if(!found){ |
375 | if(!(*ni).contains("_")){ | 367 | if(!(*ni).contains("_")){ |
376 | Interface *i = new Interface(this, *ni, false); | 368 | Interface *i = new Interface(this, *ni, false); |
377 | i->setAttached(false); | 369 | i->setAttached(false); |
378 | i->setHardwareName("Disconnected"); | 370 | i->setHardwareName("Disconnected"); |
379 | interfaceNames.insert(i->getInterfaceName(), i); | 371 | interfaceNames.insert(i->getInterfaceName(), i); |
380 | updateInterface(i); | 372 | updateInterface(i); |
381 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 373 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
382 | } | 374 | } |
383 | } | 375 | } |
384 | } | 376 | } |
385 | } | 377 | } |
386 | } | 378 | } |
387 | 379 | ||
388 | /** | 380 | /** |
389 | * Update this interface. If no QListViewItem exists create one. | 381 | * Update this interface. If no QListViewItem exists create one. |
390 | * @param Interface* pointer to the interface that needs to be updated. | 382 | * @param Interface* pointer to the interface that needs to be updated. |
391 | */ | 383 | */ |
392 | void MainWindowImp::updateInterface(Interface *i){ | 384 | void MainWindowImp::updateInterface(Interface *i){ |
393 | if(!advancedUserMode){ | 385 | if(!advancedUserMode){ |
394 | if(i->getInterfaceName() == "lo") | 386 | if(i->getInterfaceName() == "lo") |
395 | return; | 387 | return; |
396 | } | 388 | } |
397 | 389 | ||
398 | QListViewItem *item = NULL; | 390 | QListViewItem *item = NULL; |
399 | 391 | ||
400 | // Find the interface, making it if needed. | 392 | // Find the interface, making it if needed. |
401 | if(items.find(i) == items.end()){ | 393 | if(items.find(i) == items.end()){ |
402 | item = new QListViewItem(connectionList, "", "", ""); | 394 | item = new QListViewItem(connectionList, "", "", ""); |
403 | // See if you can't find a module owner for this interface | 395 | // See if you can't find a module owner for this interface |
404 | QMap<Module*, QLibrary*>::Iterator it; | 396 | QMap<Module*, QLibrary*>::Iterator it; |
405 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 397 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
406 | if(it.key()->isOwner(i)) | 398 | if(it.key()->isOwner(i)) |
407 | i->setModuleOwner(it.key()); | 399 | i->setModuleOwner(it.key()); |
408 | } | 400 | } |
409 | items.insert(i, item); | 401 | items.insert(i, item); |
410 | interfaceItems.insert(item, i); | 402 | interfaceItems.insert(item, i); |
411 | } | 403 | } |
412 | else | 404 | else |
413 | item = items[i]; | 405 | item = items[i]; |
414 | 406 | ||
415 | // Update the icons and information | 407 | // Update the icons and information |
416 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 408 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
417 | 409 | ||
418 | QString typeName = "lan"; | 410 | QString typeName = "lan"; |
419 | if(i->getHardwareName().contains("Local Loopback")) | 411 | if(i->getHardwareName().contains("Local Loopback")) |
420 | typeName = "lo"; | 412 | typeName = "lo"; |
421 | if(i->getInterfaceName().contains("irda")) | 413 | if(i->getInterfaceName().contains("irda")) |
422 | typeName = "irda"; | 414 | typeName = "irda"; |
423 | if(i->getInterfaceName().contains("wlan")) | 415 | if(i->getInterfaceName().contains("wlan")) |
424 | typeName = "wlan"; | 416 | typeName = "wlan"; |
425 | if(i->getInterfaceName().contains("usb")) | 417 | if(i->getInterfaceName().contains("usb")) |
426 | typeName = "usb"; | 418 | typeName = "usb"; |
427 | 419 | ||
428 | if(!i->isAttached()) | 420 | if(!i->isAttached()) |
429 | typeName = "connect_no"; | 421 | typeName = "connect_no"; |
430 | // Actually try to use the Module | 422 | // Actually try to use the Module |
431 | if(i->getModuleOwner() != NULL) | 423 | if(i->getModuleOwner() != NULL) |
432 | typeName = i->getModuleOwner()->getPixmapName(i); | 424 | typeName = i->getModuleOwner()->getPixmapName(i); |
433 | 425 | ||
434 | item->setPixmap(1, (Resource::loadPixmap(typeName))); | 426 | item->setPixmap(1, (Resource::loadPixmap(typeName))); |
435 | item->setText(2, i->getHardwareName()); | 427 | item->setText(2, i->getHardwareName()); |
436 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 428 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
437 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 429 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
438 | } | 430 | } |
439 | 431 | ||
440 | void MainWindowImp::newProfileChanged(const QString& newText){ | 432 | void MainWindowImp::newProfileChanged(const QString& newText){ |
441 | if(newText.length() > 0) | 433 | if(newText.length() > 0) |
442 | newProfileButton->setEnabled(true); | 434 | newProfileButton->setEnabled(true); |
443 | else | 435 | else |
444 | newProfileButton->setEnabled(false); | 436 | newProfileButton->setEnabled(false); |
445 | } | 437 | } |
446 | 438 | ||
447 | /** | 439 | /** |
448 | * Adds a new profile to the list of profiles. | 440 | * Adds a new profile to the list of profiles. |
449 | * Don't add profiles that already exists. | 441 | * Don't add profiles that already exists. |
450 | * Appends to the list and QStringList | 442 | * Appends to the list and QStringList |
451 | */ | 443 | */ |
452 | void MainWindowImp::addProfile(){ | 444 | void MainWindowImp::addProfile(){ |
453 | QString newProfileName = newProfile->text(); | 445 | QString newProfileName = newProfile->text(); |
454 | if(profiles.grep(newProfileName).count() > 0){ | 446 | if(profiles.grep(newProfileName).count() > 0){ |
455 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); | 447 | QMessageBox::information(this, "Can't Add","Profile already exists.", "Ok"); |
456 | return; | 448 | return; |
457 | } | 449 | } |
458 | profiles.append(newProfileName); | 450 | profiles.append(newProfileName); |
459 | profilesList->insertItem(newProfileName); | 451 | profilesList->insertItem(newProfileName); |
460 | } | 452 | } |
461 | 453 | ||
462 | /** | 454 | /** |
463 | * Removes the currently selected profile in the combo. | 455 | * Removes the currently selected profile in the combo. |
464 | * Doesn't delete if there are less then 2 profiles. | 456 | * Doesn't delete if there are less then 2 profiles. |
465 | */ | 457 | */ |
466 | void MainWindowImp::removeProfile(){ | 458 | void MainWindowImp::removeProfile(){ |
467 | if(profilesList->count() <= 1){ | 459 | if(profilesList->count() <= 1){ |
468 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); | 460 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", "Ok"); |
469 | return; | 461 | return; |
470 | } | 462 | } |
471 | QString profileToRemove = profilesList->currentText(); | 463 | QString profileToRemove = profilesList->currentText(); |
472 | if(profileToRemove == "All"){ | 464 | if(profileToRemove == "All"){ |
473 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); | 465 | QMessageBox::information(this, "Can't remove.","Can't remove default.", "Ok"); |
474 | return; | 466 | return; |
475 | } | 467 | } |
476 | // Can't remove the curent profile | 468 | // Can't remove the curent profile |
477 | if(profileToRemove == currentProfileLabel->text()){ | 469 | if(profileToRemove == currentProfileLabel->text()){ |
478 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); | 470 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), "Ok"); |
479 | return; | 471 | return; |
480 | 472 | ||
481 | } | 473 | } |
482 | 474 | ||
483 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 475 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ |
484 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 476 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
485 | profilesList->clear(); | 477 | profilesList->clear(); |
486 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 478 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
487 | profilesList->insertItem((*it)); | 479 | profilesList->insertItem((*it)); |
488 | 480 | ||
489 | // Remove any interface settings and mappings. | 481 | // Remove any interface settings and mappings. |
490 | Interfaces interfaces; | 482 | Interfaces interfaces; |
491 | // Go through them one by one | 483 | // Go through them one by one |
492 | QMap<Interface*, QListViewItem*>::Iterator it; | 484 | QMap<Interface*, QListViewItem*>::Iterator it; |
493 | for( it = items.begin(); it != items.end(); ++it ){ | 485 | for( it = items.begin(); it != items.end(); ++it ){ |
494 | QString interfaceName = it.key()->getInterfaceName(); | 486 | QString interfaceName = it.key()->getInterfaceName(); |
495 | qDebug(interfaceName.latin1()); | 487 | qDebug(interfaceName.latin1()); |
496 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ | 488 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ |
497 | interfaces.removeInterface(); | 489 | interfaces.removeInterface(); |
498 | if(interfaces.setMapping(interfaceName)){ | 490 | if(interfaces.setMapping(interfaceName)){ |
499 | if(profilesList->count() == 1) | 491 | if(profilesList->count() == 1) |
500 | interfaces.removeMapping(); | 492 | interfaces.removeMapping(); |
501 | else{ | 493 | else{ |
502 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 494 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
503 | } | 495 | } |
504 | } | 496 | } |
505 | interfaces.write(); | 497 | interfaces.write(); |
506 | break; | 498 | break; |
507 | } | 499 | } |
508 | } | 500 | } |
509 | } | 501 | } |
510 | } | 502 | } |
511 | 503 | ||
512 | /** | 504 | /** |
513 | * A new profile has been selected, change. | 505 | * A new profile has been selected, change. |
514 | * @param newProfile the new profile. | 506 | * @param newProfile the new profile. |
515 | */ | 507 | */ |
516 | void MainWindowImp::changeProfile(){ | 508 | void MainWindowImp::changeProfile(){ |
517 | if(profilesList->currentItem() == -1){ | 509 | if(profilesList->currentItem() == -1){ |
518 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); | 510 | QMessageBox::information(this, "Can't Change.","Please select a profile.", "Ok"); |
519 | return; | 511 | return; |
520 | } | 512 | } |
521 | QString newProfile = profilesList->text(profilesList->currentItem()); | 513 | QString newProfile = profilesList->text(profilesList->currentItem()); |
522 | if(newProfile != currentProfileLabel->text()){ | 514 | if(newProfile != currentProfileLabel->text()){ |
523 | currentProfileLabel->setText(newProfile); | 515 | currentProfileLabel->setText(newProfile); |
524 | QFile::remove(scheme); | 516 | QFile::remove(scheme); |
525 | QFile file(scheme); | 517 | QFile file(scheme); |
526 | if ( file.open(IO_ReadWrite) ) { | 518 | if ( file.open(IO_ReadWrite) ) { |
527 | QTextStream stream( &file ); | 519 | QTextStream stream( &file ); |
528 | stream << QString("SCHEME=%1").arg(newProfile); | 520 | stream << QString("SCHEME=%1").arg(newProfile); |
529 | file.close(); | 521 | file.close(); |
530 | } | 522 | } |
531 | // restart all up devices? | 523 | // restart all up devices? |
532 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 524 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ |
533 | // Go through them one by one | 525 | // Go through them one by one |
534 | QMap<Interface*, QListViewItem*>::Iterator it; | 526 | QMap<Interface*, QListViewItem*>::Iterator it; |
535 | for( it = items.begin(); it != items.end(); ++it ){ | 527 | for( it = items.begin(); it != items.end(); ++it ){ |
536 | if(it.key()->getStatus() == true) | 528 | if(it.key()->getStatus() == true) |
537 | it.key()->restart(); | 529 | it.key()->restart(); |
538 | } | 530 | } |
539 | } | 531 | } |
540 | } | 532 | } |
533 | // TODO change the profile in the modules | ||
541 | } | 534 | } |
542 | 535 | ||
543 | // mainwindowimp.cpp | 536 | // mainwindowimp.cpp |
544 | 537 | ||
diff --git a/noncore/settings/networksettings/networksetup.pro b/noncore/settings/networksettings/networksetup.pro index 1719a35..5666a42 100644 --- a/noncore/settings/networksettings/networksetup.pro +++ b/noncore/settings/networksettings/networksetup.pro | |||
@@ -1,11 +1,11 @@ | |||
1 | DESTDIR = $(OPIEDIR)/bin | 1 | #DESTDIR = $(OPIEDIR)/bin |
2 | TEMPLATE = app | 2 | TEMPLATE = app |
3 | #CONFIG = qt warn_on debug | 3 | #CONFIG = qt warn_on debug |
4 | CONFIG = qt warn_on release | 4 | CONFIG = qt warn_on release |
5 | HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h kprocctrl.h module.h kprocess.h | 5 | HEADERS = mainwindowimp.h addconnectionimp.h defaultmodule.h kprocctrl.h module.h kprocess.h |
6 | SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp kprocctrl.cpp kprocess.cpp | 6 | SOURCES = main.cpp mainwindowimp.cpp addconnectionimp.cpp kprocctrl.cpp kprocess.cpp |
7 | INCLUDEPATH += $(OPIEDIR)/include interfaces/ | 7 | INCLUDEPATH += $(OPIEDIR)/include interfaces/ |
8 | DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan | 8 | DEPENDPATH += $(OPIEDIR)/include interfaces/ wlan |
9 | LIBS += -lqpe -L$(OPIEDIR)/plugins/networksetup -linterfaces | 9 | LIBS += -lqpe -L$(OPIEDIR)/plugins/networksetup -Linterfaces/ -linterfaces |
10 | INTERFACES = mainwindow.ui addconnection.ui | 10 | INTERFACES = mainwindow.ui addconnection.ui |
11 | TARGET = networksetup | 11 | TARGET = networksetup |
diff --git a/noncore/settings/networksettings/opie-networksettings.control b/noncore/settings/networksettings/opie-networksettings.control index 35bac52..d14e2d1 100644 --- a/noncore/settings/networksettings/opie-networksettings.control +++ b/noncore/settings/networksettings/opie-networksettings.control | |||
@@ -1,8 +1,8 @@ | |||
1 | Files: bin/networksetup apps/Settings/networksetup.desktop pics/Network plugins/networksetup/* pics/networksetup $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 | 1 | Files: bin/networksetup apps/Settings/networksetup.desktop pics/Network plugins/networksetup/* pics/networksetup $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 $OPIEDIR/bin/changedns.sh $OPIEDIR/bin/getprofile.sh |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/settings | 3 | Section: opie/settings |
4 | Maintainer: Ben Meyer <meyerb@sharpsec.com> | 4 | Maintainer: Ben Meyer <meyerb@sharpsec.com> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | Description: Opie network setup tool | 8 | Description: Opie network setup tool |
diff --git a/noncore/settings/networksettings/opie-networksetup.control b/noncore/settings/networksettings/opie-networksetup.control index 35bac52..d14e2d1 100644 --- a/noncore/settings/networksettings/opie-networksetup.control +++ b/noncore/settings/networksettings/opie-networksetup.control | |||
@@ -1,8 +1,8 @@ | |||
1 | Files: bin/networksetup apps/Settings/networksetup.desktop pics/Network plugins/networksetup/* pics/networksetup $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 | 1 | Files: bin/networksetup apps/Settings/networksetup.desktop pics/Network plugins/networksetup/* pics/networksetup $QTDIR/lib/libinterfaces.so.1.0.0 $QTDIR/lib/libinterfaces.so.1.0 $QTDIR/lib/libinterfaces.so.1 $OPIEDIR/bin/changedns.sh $OPIEDIR/bin/getprofile.sh |
2 | Priority: optional | 2 | Priority: optional |
3 | Section: opie/settings | 3 | Section: opie/settings |
4 | Maintainer: Ben Meyer <meyerb@sharpsec.com> | 4 | Maintainer: Ben Meyer <meyerb@sharpsec.com> |
5 | Architecture: arm | 5 | Architecture: arm |
6 | Version: $QPE_VERSION-$SUB_VERSION | 6 | Version: $QPE_VERSION-$SUB_VERSION |
7 | Depends: opie-base ($QPE_VERSION) | 7 | Depends: opie-base ($QPE_VERSION) |
8 | Description: Opie network setup tool | 8 | Description: Opie network setup tool |
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp index a466020..74bf390 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.cpp +++ b/noncore/settings/networksettings/wlan/wlanimp.cpp | |||
@@ -1,227 +1,231 @@ | |||
1 | #include "wlanimp.h" | 1 | #include "wlanimp.h" |
2 | 2 | ||
3 | /* Config class */ | 3 | /* Config class */ |
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | /* Global namespace */ | 5 | /* Global namespace */ |
6 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
7 | /* system() */ | 7 | /* system() */ |
8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
9 | #include <qfile.h> | 9 | #include <qfile.h> |
10 | #include <qdir.h> | 10 | #include <qdir.h> |
11 | #include <qtextstream.h> | 11 | #include <qtextstream.h> |
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
15 | #include <qradiobutton.h> | 15 | #include <qradiobutton.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qregexp.h> | 17 | #include <qregexp.h> |
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qtabwidget.h> | 19 | #include <qtabwidget.h> |
20 | #include "interfacesetupimp.h" | 20 | #include "interfacesetupimp.h" |
21 | 21 | ||
22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ | 22 | WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl){ |
23 | config = new Config("wireless"); | 23 | config = new Config("wireless"); |
24 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose); | 24 | interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);//, Qt::WDestructiveClose); |
25 | //configure->setProfile(currentProfile); | 25 | //configure->setProfile(currentProfile); |
26 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); | 26 | tabWidget->insertTab(interfaceSetup, "TCP/IP"); |
27 | 27 | ||
28 | readConfig(); | 28 | readConfig(); |
29 | 29 | ||
30 | } | 30 | } |
31 | 31 | ||
32 | WLANImp::~WLANImp( ){ | 32 | WLANImp::~WLANImp( ){ |
33 | delete config; | 33 | delete config; |
34 | } | 34 | } |
35 | 35 | ||
36 | void WLANImp::setProfile(QString &profile){ | ||
37 | interfaceSetup->setProfile(profile); | ||
38 | } | ||
39 | |||
36 | void WLANImp::readConfig() | 40 | void WLANImp::readConfig() |
37 | { | 41 | { |
38 | qWarning( "WLANImp::readConfig() called." ); | 42 | qWarning( "WLANImp::readConfig() called." ); |
39 | config->setGroup( "Properties" ); | 43 | config->setGroup( "Properties" ); |
40 | QString ssid = config->readEntry( "SSID", "any" ); | 44 | QString ssid = config->readEntry( "SSID", "any" ); |
41 | if( ssid == "any" || ssid == "ANY" ){ | 45 | if( ssid == "any" || ssid == "ANY" ){ |
42 | essNon->setChecked( true ); | 46 | essNon->setChecked( true ); |
43 | } else { | 47 | } else { |
44 | essSpecific->setChecked( true ); | 48 | essSpecific->setChecked( true ); |
45 | essSpecificLineEdit->setText( ssid ); | 49 | essSpecificLineEdit->setText( ssid ); |
46 | } | 50 | } |
47 | QString mode = config->readEntry( "Mode", "Managed" ); | 51 | QString mode = config->readEntry( "Mode", "Managed" ); |
48 | if( mode == "adhoc" ) { | 52 | if( mode == "adhoc" ) { |
49 | network802->setChecked( true ); | 53 | network802->setChecked( true ); |
50 | } else { | 54 | } else { |
51 | networkInfrastructure->setChecked( true ); | 55 | networkInfrastructure->setChecked( true ); |
52 | } | 56 | } |
53 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); | 57 | networkChannel->setValue( config->readNumEntry( "CHANNEL", 1 ) ); |
54 | // config->readEntry( "RATE", "auto" ); | 58 | // config->readEntry( "RATE", "auto" ); |
55 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); | 59 | config->readEntry( "dot11PrivacyInvoked" ) == "true" ? wepEnabled->setChecked( true ) : wepEnabled->setChecked( false ); |
56 | config->readEntry( "AuthType", "opensystem" ); | 60 | config->readEntry( "AuthType", "opensystem" ); |
57 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); | 61 | config->readEntry( "PRIV_KEY128", "false" ) == "false" ? key40->setChecked( true ) : key128->setChecked( true ); |
58 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 62 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
59 | switch( defaultkey ){ | 63 | switch( defaultkey ){ |
60 | case 0: | 64 | case 0: |
61 | keyRadio0->setChecked( true ); | 65 | keyRadio0->setChecked( true ); |
62 | break; | 66 | break; |
63 | case 1: | 67 | case 1: |
64 | keyRadio1->setChecked( true ); | 68 | keyRadio1->setChecked( true ); |
65 | break; | 69 | break; |
66 | case 2: | 70 | case 2: |
67 | keyRadio2->setChecked( true ); | 71 | keyRadio2->setChecked( true ); |
68 | break; | 72 | break; |
69 | case 3: | 73 | case 3: |
70 | keyRadio3->setChecked( true ); | 74 | keyRadio3->setChecked( true ); |
71 | break; | 75 | break; |
72 | } | 76 | } |
73 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); | 77 | keyLineEdit0->setText(config->readEntry( "dot11WEPDefaultKey0" )); |
74 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); | 78 | keyLineEdit1->setText(config->readEntry( "dot11WEPDefaultKey1" )); |
75 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); | 79 | keyLineEdit2->setText(config->readEntry( "dot11WEPDefaultKey2" )); |
76 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); | 80 | keyLineEdit3->setText(config->readEntry( "dot11WEPDefaultKey3" )); |
77 | return; | 81 | return; |
78 | } | 82 | } |
79 | 83 | ||
80 | bool WLANImp::writeConfig() | 84 | bool WLANImp::writeConfig() |
81 | { | 85 | { |
82 | qWarning( "WLANImp::writeConfig() called." ); | 86 | qWarning( "WLANImp::writeConfig() called." ); |
83 | config->setGroup( "Properties" ); | 87 | config->setGroup( "Properties" ); |
84 | if( essNon->isChecked() ) { | 88 | if( essNon->isChecked() ) { |
85 | config->writeEntry( "SSID", "any" ); | 89 | config->writeEntry( "SSID", "any" ); |
86 | } else { | 90 | } else { |
87 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); | 91 | config->writeEntry( "SSID", essSpecificLineEdit->text() ); |
88 | } | 92 | } |
89 | if( networkInfrastructure->isChecked() ){ | 93 | if( networkInfrastructure->isChecked() ){ |
90 | config->writeEntry( "Mode", "Managed" ); | 94 | config->writeEntry( "Mode", "Managed" ); |
91 | } else if( network802->isChecked() ){ | 95 | } else if( network802->isChecked() ){ |
92 | config->writeEntry( "Mode", "adhoc" ); | 96 | config->writeEntry( "Mode", "adhoc" ); |
93 | } | 97 | } |
94 | config->writeEntry( "CHANNEL", networkChannel->value() ); | 98 | config->writeEntry( "CHANNEL", networkChannel->value() ); |
95 | // config->readEntry( "RATE", "auto" ); | 99 | // config->readEntry( "RATE", "auto" ); |
96 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); | 100 | wepEnabled->isChecked() ? config->writeEntry( "dot11PrivacyInvoked", "true" ) : config->writeEntry( "dot11PrivacyInvoked", "false" ); |
97 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); | 101 | authOpen->isChecked() ? config->writeEntry( "AuthType", "opensystem" ) : config->writeEntry( "AuthType", "sharedkey" ); |
98 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); | 102 | key40->isChecked() ? config->writeEntry( "PRIV_KEY128", "false" ) : config->writeEntry( "PRIV_KEY128", "true" ); |
99 | if( keyRadio0->isChecked() ){ | 103 | if( keyRadio0->isChecked() ){ |
100 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); | 104 | config->writeEntry( "dot11WEPDefaultKeyID", 0 ); |
101 | } else if( keyRadio1->isChecked() ){ | 105 | } else if( keyRadio1->isChecked() ){ |
102 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); | 106 | config->writeEntry( "dot11WEPDefaultKeyID", 1 ); |
103 | } else if( keyRadio2->isChecked() ){ | 107 | } else if( keyRadio2->isChecked() ){ |
104 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); | 108 | config->writeEntry( "dot11WEPDefaultKeyID", 2 ); |
105 | } else if( keyRadio3->isChecked() ){ | 109 | } else if( keyRadio3->isChecked() ){ |
106 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); | 110 | config->writeEntry( "dot11WEPDefaultKeyID", 3 ); |
107 | } | 111 | } |
108 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); | 112 | config->writeEntry( "dot11WEPDefaultKey0", keyLineEdit0->text() ); |
109 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); | 113 | config->writeEntry( "dot11WEPDefaultKey1", keyLineEdit1->text() ); |
110 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); | 114 | config->writeEntry( "dot11WEPDefaultKey2", keyLineEdit2->text() ); |
111 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); | 115 | config->writeEntry( "dot11WEPDefaultKey3", keyLineEdit3->text() ); |
112 | return writeWirelessOpts( ); | 116 | return writeWirelessOpts( ); |
113 | } | 117 | } |
114 | 118 | ||
115 | /** | 119 | /** |
116 | */ | 120 | */ |
117 | void WLANImp::accept() | 121 | void WLANImp::accept() |
118 | { | 122 | { |
119 | if ( writeConfig() ){ | 123 | if ( writeConfig() ){ |
120 | interfaceSetup->saveChanges(); | 124 | interfaceSetup->saveChanges(); |
121 | QDialog::accept(); | 125 | QDialog::accept(); |
122 | } | 126 | } |
123 | } | 127 | } |
124 | 128 | ||
125 | bool WLANImp::writeWirelessOpts( QString scheme ) | 129 | bool WLANImp::writeWirelessOpts( QString scheme ) |
126 | { | 130 | { |
127 | qWarning( "WLANImp::writeWirelessOpts entered." ); | 131 | qWarning( "WLANImp::writeWirelessOpts entered." ); |
128 | QString prev = "/etc/pcmcia/wireless.opts"; | 132 | QString prev = "/etc/pcmcia/wireless.opts"; |
129 | QFile prevFile(prev); | 133 | QFile prevFile(prev); |
130 | if ( !prevFile.open( IO_ReadOnly ) ) | 134 | if ( !prevFile.open( IO_ReadOnly ) ) |
131 | return false; | 135 | return false; |
132 | 136 | ||
133 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; | 137 | QString tmp = "/etc/pcmcia/wireless.opts-qpe-new"; |
134 | QFile tmpFile(tmp); | 138 | QFile tmpFile(tmp); |
135 | if ( !tmpFile.open( IO_WriteOnly ) ) | 139 | if ( !tmpFile.open( IO_WriteOnly ) ) |
136 | return false; | 140 | return false; |
137 | 141 | ||
138 | bool retval = true; | 142 | bool retval = true; |
139 | 143 | ||
140 | QTextStream in( &prevFile ); | 144 | QTextStream in( &prevFile ); |
141 | QTextStream out( &tmpFile ); | 145 | QTextStream out( &tmpFile ); |
142 | 146 | ||
143 | config->setGroup("Properties"); | 147 | config->setGroup("Properties"); |
144 | 148 | ||
145 | QString line; | 149 | QString line; |
146 | bool found=false; | 150 | bool found=false; |
147 | bool done=false; | 151 | bool done=false; |
148 | while ( !in.atEnd() ) { | 152 | while ( !in.atEnd() ) { |
149 | QString line = in.readLine(); | 153 | QString line = in.readLine(); |
150 | QString wline = line.simplifyWhiteSpace(); | 154 | QString wline = line.simplifyWhiteSpace(); |
151 | if ( !done ) { | 155 | if ( !done ) { |
152 | if ( found ) { | 156 | if ( found ) { |
153 | // skip existing entry for this scheme, and write our own. | 157 | // skip existing entry for this scheme, and write our own. |
154 | if ( wline == ";;" ) { | 158 | if ( wline == ";;" ) { |
155 | found = false; | 159 | found = false; |
156 | continue; | 160 | continue; |
157 | } else { | 161 | } else { |
158 | continue; | 162 | continue; |
159 | } | 163 | } |
160 | } else { | 164 | } else { |
161 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { | 165 | if ( wline.left(scheme.length()+7) == scheme + ",*,*,*)" ) { |
162 | found=true; | 166 | found=true; |
163 | continue; // skip this line | 167 | continue; // skip this line |
164 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { | 168 | } else if ( wline == "esac" || wline == "*,*,*,*)" ) { |
165 | // end - add new entry | 169 | // end - add new entry |
166 | // Not all fields have a GUI, but all are supported | 170 | // Not all fields have a GUI, but all are supported |
167 | // in the letwork configuration files. | 171 | // in the letwork configuration files. |
168 | static const char* txtfields[] = { | 172 | static const char* txtfields[] = { |
169 | 0 | 173 | 0 |
170 | }; | 174 | }; |
171 | QString readmode = config->readEntry( "Mode", "Managed" ); | 175 | QString readmode = config->readEntry( "Mode", "Managed" ); |
172 | QString mode; | 176 | QString mode; |
173 | if( readmode == "Managed" ){ | 177 | if( readmode == "Managed" ){ |
174 | mode = readmode; | 178 | mode = readmode; |
175 | } else if( readmode == "adhoc" ){ | 179 | } else if( readmode == "adhoc" ){ |
176 | mode = "Ad-Hoc"; | 180 | mode = "Ad-Hoc"; |
177 | } | 181 | } |
178 | QString key; | 182 | QString key; |
179 | if( wepEnabled->isChecked() ){ | 183 | if( wepEnabled->isChecked() ){ |
180 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); | 184 | int defaultkey = config->readNumEntry( "dot11WEPDefaultKeyID", 0 ); |
181 | switch( defaultkey ){ | 185 | switch( defaultkey ){ |
182 | case 0: | 186 | case 0: |
183 | key += keyLineEdit0->text(); | 187 | key += keyLineEdit0->text(); |
184 | break; | 188 | break; |
185 | case 1: | 189 | case 1: |
186 | key += keyLineEdit1->text(); | 190 | key += keyLineEdit1->text(); |
187 | break; | 191 | break; |
188 | case 2: | 192 | case 2: |
189 | key += keyLineEdit2->text(); | 193 | key += keyLineEdit2->text(); |
190 | break; | 194 | break; |
191 | case 3: | 195 | case 3: |
192 | key += keyLineEdit3->text(); | 196 | key += keyLineEdit3->text(); |
193 | break; | 197 | break; |
194 | } | 198 | } |
195 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") | 199 | if( config->readEntry( "AuthType", "opensystem" ) == "opensystem") |
196 | key += " open"; | 200 | key += " open"; |
197 | } | 201 | } |
198 | out << scheme << ",*,*,*)" << "\n" | 202 | out << scheme << ",*,*,*)" << "\n" |
199 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" | 203 | << " ESSID=" << Global::shellQuote( config->readEntry( "SSID", "any" ) ) << "\n" |
200 | << " MODE=" << mode << "\n" | 204 | << " MODE=" << mode << "\n" |
201 | << " KEY=" << Global::shellQuote( key ) << "\n" | 205 | << " KEY=" << Global::shellQuote( key ) << "\n" |
202 | << " RATE=" << "auto" << "\n" | 206 | << " RATE=" << "auto" << "\n" |
203 | ; | 207 | ; |
204 | if( mode != "Managed" ) | 208 | if( mode != "Managed" ) |
205 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; | 209 | out << " CHANNEL=" << config->readNumEntry( "CHANNEL", 1 ) << "\n"; |
206 | const char** f = txtfields; | 210 | const char** f = txtfields; |
207 | while (*f) { | 211 | while (*f) { |
208 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; | 212 | out << " " << *f << "=" << config->readEntry(*f,"") << "\n"; |
209 | ++f; | 213 | ++f; |
210 | } | 214 | } |
211 | out << " ;;\n"; | 215 | out << " ;;\n"; |
212 | done = true; | 216 | done = true; |
213 | } | 217 | } |
214 | } | 218 | } |
215 | } | 219 | } |
216 | out << line << "\n"; | 220 | out << line << "\n"; |
217 | } | 221 | } |
218 | 222 | ||
219 | prevFile.close(); | 223 | prevFile.close(); |
220 | tmpFile.close(); | 224 | tmpFile.close(); |
221 | QString initpath; | 225 | QString initpath; |
222 | //system("cardctl suspend"); | 226 | //system("cardctl suspend"); |
223 | if( QDir("/etc/rc.d/init.d").exists() ){ | 227 | if( QDir("/etc/rc.d/init.d").exists() ){ |
224 | initpath = "/etc/rc.d/init.d"; | 228 | initpath = "/etc/rc.d/init.d"; |
225 | } else if( QDir("/etc/init.d").exists() ){ | 229 | } else if( QDir("/etc/init.d").exists() ){ |
226 | initpath = "/etc/init.d"; | 230 | initpath = "/etc/init.d"; |
227 | } | 231 | } |
diff --git a/noncore/settings/networksettings/wlan/wlanimp.h b/noncore/settings/networksettings/wlan/wlanimp.h index 608d681..faa1674 100644 --- a/noncore/settings/networksettings/wlan/wlanimp.h +++ b/noncore/settings/networksettings/wlan/wlanimp.h | |||
@@ -1,31 +1,32 @@ | |||
1 | #ifndef WLANIMP_H | 1 | #ifndef WLANIMP_H |
2 | #define WLANIMP_H | 2 | #define WLANIMP_H |
3 | 3 | ||
4 | #include "wlan.h" | 4 | #include "wlan.h" |
5 | 5 | ||
6 | class InterfaceSetupImp; | 6 | class InterfaceSetupImp; |
7 | class Interface; | 7 | class Interface; |
8 | class Config; | 8 | class Config; |
9 | 9 | ||
10 | class WLANImp : public WLAN { | 10 | class WLANImp : public WLAN { |
11 | Q_OBJECT | 11 | Q_OBJECT |
12 | 12 | ||
13 | public: | 13 | public: |
14 | WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); | 14 | WLANImp( QWidget* parent = 0, const char* name = 0, Interface *i=0, bool modal = FALSE, WFlags fl = 0 ); |
15 | ~WLANImp( ); | 15 | ~WLANImp( ); |
16 | void setProfile(QString &profile); | ||
16 | 17 | ||
17 | protected: | 18 | protected: |
18 | void accept(); | 19 | void accept(); |
19 | 20 | ||
20 | private: | 21 | private: |
21 | void readConfig(); | 22 | void readConfig(); |
22 | bool writeConfig(); | 23 | bool writeConfig(); |
23 | bool writeWirelessOpts( QString scheme = "*" ); | 24 | bool writeWirelessOpts( QString scheme = "*" ); |
24 | bool writeWlanngOpts( QString scheme = "*" ); | 25 | bool writeWlanngOpts( QString scheme = "*" ); |
25 | Config* config; | 26 | Config* config; |
26 | InterfaceSetupImp *interfaceSetup; | 27 | InterfaceSetupImp *interfaceSetup; |
27 | 28 | ||
28 | }; | 29 | }; |
29 | 30 | ||
30 | #endif | 31 | #endif |
31 | 32 | ||
diff --git a/noncore/settings/networksettings/wlan/wlanmodule.cpp b/noncore/settings/networksettings/wlan/wlanmodule.cpp index c8becb0..b14fc0a 100644 --- a/noncore/settings/networksettings/wlan/wlanmodule.cpp +++ b/noncore/settings/networksettings/wlan/wlanmodule.cpp | |||
@@ -1,112 +1,113 @@ | |||
1 | #include "wlanmodule.h" | 1 | #include "wlanmodule.h" |
2 | #include "wlanimp.h" | 2 | #include "wlanimp.h" |
3 | #include "infoimp.h" | 3 | #include "infoimp.h" |
4 | #include "wextensions.h" | 4 | #include "wextensions.h" |
5 | #include "interfaceinformationimp.h" | 5 | #include "interfaceinformationimp.h" |
6 | 6 | ||
7 | #include <qlabel.h> | 7 | #include <qlabel.h> |
8 | #include <qprogressbar.h> | 8 | #include <qprogressbar.h> |
9 | #include <qtabwidget.h> | 9 | #include <qtabwidget.h> |
10 | 10 | ||
11 | /** | 11 | /** |
12 | * Constructor, find all of the possible interfaces | 12 | * Constructor, find all of the possible interfaces |
13 | */ | 13 | */ |
14 | WLANModule::WLANModule() : Module() { | 14 | WLANModule::WLANModule() : Module() { |
15 | } | 15 | } |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * Delete any interfaces that we own. | 18 | * Delete any interfaces that we own. |
19 | */ | 19 | */ |
20 | WLANModule::~WLANModule(){ | 20 | WLANModule::~WLANModule(){ |
21 | Interface *i; | 21 | Interface *i; |
22 | for ( i=list.first(); i != 0; i=list.next() ) | 22 | for ( i=list.first(); i != 0; i=list.next() ) |
23 | delete i; | 23 | delete i; |
24 | } | 24 | } |
25 | 25 | ||
26 | /** | 26 | /** |
27 | * Change the current profile | 27 | * Change the current profile |
28 | */ | 28 | */ |
29 | void WLANModule::setProfile(QString newProfile){ | 29 | void WLANModule::setProfile(QString newProfile){ |
30 | profile = newProfile; | 30 | profile = newProfile; |
31 | } | 31 | } |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * get the icon name for this device. | 34 | * get the icon name for this device. |
35 | * @param Interface* can be used in determining the icon. | 35 | * @param Interface* can be used in determining the icon. |
36 | * @return QString the icon name (minus .png, .gif etc) | 36 | * @return QString the icon name (minus .png, .gif etc) |
37 | */ | 37 | */ |
38 | QString WLANModule::getPixmapName(Interface* ){ | 38 | QString WLANModule::getPixmapName(Interface* ){ |
39 | return "wlan"; | 39 | return "wlan"; |
40 | } | 40 | } |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Check to see if the interface i is owned by this module. | 43 | * Check to see if the interface i is owned by this module. |
44 | * @param Interface* interface to check against | 44 | * @param Interface* interface to check against |
45 | * @return bool true if i is owned by this module, false otherwise. | 45 | * @return bool true if i is owned by this module, false otherwise. |
46 | */ | 46 | */ |
47 | bool WLANModule::isOwner(Interface *i){ | 47 | bool WLANModule::isOwner(Interface *i){ |
48 | WExtensions we(i->getInterfaceName()); | 48 | WExtensions we(i->getInterfaceName()); |
49 | if(!we.doesHaveWirelessExtensions()) | 49 | if(!we.doesHaveWirelessExtensions()) |
50 | return false; | 50 | return false; |
51 | 51 | ||
52 | i->setHardwareName("802.11b"); | 52 | i->setHardwareName("802.11b"); |
53 | list.append(i); | 53 | list.append(i); |
54 | return true; | 54 | return true; |
55 | } | 55 | } |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Create, and return the WLANConfigure Module | 58 | * Create, and return the WLANConfigure Module |
59 | * @return QWidget* pointer to this modules configure. | 59 | * @return QWidget* pointer to this modules configure. |
60 | */ | 60 | */ |
61 | QWidget *WLANModule::configure(Interface *i){ | 61 | QWidget *WLANModule::configure(Interface *i){ |
62 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); | 62 | WLANImp *wlanconfig = new WLANImp(0, "WlanConfig", i, false, Qt::WDestructiveClose); |
63 | wlanconfig->setProfile(profile); | ||
63 | return wlanconfig; | 64 | return wlanconfig; |
64 | } | 65 | } |
65 | 66 | ||
66 | /** | 67 | /** |
67 | * Create, and return the Information Module | 68 | * Create, and return the Information Module |
68 | * @return QWidget* pointer to this modules info. | 69 | * @return QWidget* pointer to this modules info. |
69 | */ | 70 | */ |
70 | QWidget *WLANModule::information(Interface *i){ | 71 | QWidget *WLANModule::information(Interface *i){ |
71 | WExtensions we(i->getInterfaceName()); | 72 | WExtensions we(i->getInterfaceName()); |
72 | if(!we.doesHaveWirelessExtensions()) | 73 | if(!we.doesHaveWirelessExtensions()) |
73 | return NULL; | 74 | return NULL; |
74 | 75 | ||
75 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); | 76 | WlanInfoImp *info = new WlanInfoImp(0, i->getInterfaceName(), Qt::WDestructiveClose); |
76 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); | 77 | InterfaceInformationImp *information = new InterfaceInformationImp(info->tabWidget, "InterfaceSetupImp", i); |
77 | info->tabWidget->insertTab(information, "TCP/IP"); | 78 | info->tabWidget->insertTab(information, "TCP/IP"); |
78 | return info; | 79 | return info; |
79 | } | 80 | } |
80 | 81 | ||
81 | /** | 82 | /** |
82 | * Get all active (up or down) interfaces | 83 | * Get all active (up or down) interfaces |
83 | * @return QList<Interface> A list of interfaces that exsist that havn't | 84 | * @return QList<Interface> A list of interfaces that exsist that havn't |
84 | * been called by isOwner() | 85 | * been called by isOwner() |
85 | */ | 86 | */ |
86 | QList<Interface> WLANModule::getInterfaces(){ | 87 | QList<Interface> WLANModule::getInterfaces(){ |
87 | return list; | 88 | return list; |
88 | } | 89 | } |
89 | 90 | ||
90 | /** | 91 | /** |
91 | * Attempt to add a new interface as defined by name | 92 | * Attempt to add a new interface as defined by name |
92 | * @param name the name of the type of interface that should be created given | 93 | * @param name the name of the type of interface that should be created given |
93 | * by possibleNewInterfaces(); | 94 | * by possibleNewInterfaces(); |
94 | * @return Interface* NULL if it was unable to be created. | 95 | * @return Interface* NULL if it was unable to be created. |
95 | */ | 96 | */ |
96 | Interface *WLANModule::addNewInterface(QString ){ | 97 | Interface *WLANModule::addNewInterface(QString ){ |
97 | // We can't add a 802.11 interface, either the hardware will be there | 98 | // We can't add a 802.11 interface, either the hardware will be there |
98 | // or it wont. | 99 | // or it wont. |
99 | return NULL; | 100 | return NULL; |
100 | } | 101 | } |
101 | 102 | ||
102 | /** | 103 | /** |
103 | * Attempts to remove the interface, doesn't delete i | 104 | * Attempts to remove the interface, doesn't delete i |
104 | * @return bool true if successfull, false otherwise. | 105 | * @return bool true if successfull, false otherwise. |
105 | */ | 106 | */ |
106 | bool WLANModule::remove(Interface*){ | 107 | bool WLANModule::remove(Interface*){ |
107 | // Can't remove a hardware device, you can stop it though. | 108 | // Can't remove a hardware device, you can stop it though. |
108 | return false; | 109 | return false; |
109 | } | 110 | } |
110 | 111 | ||
111 | // wlanmodule.cpp | 112 | // wlanmodule.cpp |
112 | 113 | ||