summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-09 18:10:11 (UTC)
committer kergoth <kergoth>2003-04-09 18:10:11 (UTC)
commitbacff63f1e4915c683a409e81b18ffcf5aeceda3 (patch) (unidiff)
treea1b898223bd132a29964ec28a89c0756fa9828cf
parentdc219288ae070e0fe91e2d7da768d620f8b91592 (diff)
downloadopie-bacff63f1e4915c683a409e81b18ffcf5aeceda3.zip
opie-bacff63f1e4915c683a409e81b18ffcf5aeceda3.tar.gz
opie-bacff63f1e4915c683a409e81b18ffcf5aeceda3.tar.bz2
Make networksettings actually compile again. Fix the ifdef on non-kde to actually work, and killed off more references to qt3 widget flags.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp2
-rw-r--r--noncore/settings/networksettings/mainwindowimp.cpp20
-rw-r--r--noncore/settings/networksettings/mainwindowimp.h4
-rw-r--r--noncore/settings/networksettings/wlan/wlanimp.cpp2
4 files changed, 14 insertions, 14 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
index 15293fd..e00dcce 100644
--- a/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaceinformationimp.cpp
@@ -1,79 +1,79 @@
1#include "interfaceinformationimp.h" 1#include "interfaceinformationimp.h"
2#include "interfaceadvanced.h" 2#include "interfaceadvanced.h"
3 3
4#include <qpushbutton.h> 4#include <qpushbutton.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qgroupbox.h> 6#include <qgroupbox.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8 8
9#ifdef QTE_VERSION 9#ifdef QWS
10#else 10#else
11 #define showMaximized show 11 #define showMaximized show
12#endif 12#endif
13 13
14/** 14/**
15 * Constructor for the InterfaceInformationImp class. This class pretty much 15 * Constructor for the InterfaceInformationImp class. This class pretty much
16 * just display's information about the interface that is passed to it. 16 * just display's information about the interface that is passed to it.
17 */ 17 */
18InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i){ 18InterfaceInformationImp::InterfaceInformationImp(QWidget *parent, const char *name, Interface *i, WFlags f):InterfaceInformation(parent, name, f), interface(i){
19 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 19 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
20 connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &))); 20 connect(i, SIGNAL(updateMessage(const QString &)), this, SLOT(showMessage(const QString &)));
21 updateInterface(interface); 21 updateInterface(interface);
22 connect(startButton, SIGNAL(clicked()), interface, SLOT(start())); 22 connect(startButton, SIGNAL(clicked()), interface, SLOT(start()));
23 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop())); 23 connect(stopButton, SIGNAL(clicked()), interface, SLOT(stop()));
24 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart())); 24 connect(restartButton, SIGNAL(clicked()), interface, SLOT(restart()));
25 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh())); 25 connect(refreshButton, SIGNAL(clicked()), interface, SLOT(refresh()));
26 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced())); 26 connect(advancedButton, SIGNAL(clicked()), this, SLOT(advanced()));
27} 27}
28 28
29/** 29/**
30 * Update the interface information and buttons. 30 * Update the interface information and buttons.
31 * @param Intarface *i the interface to update (should be the one we already 31 * @param Intarface *i the interface to update (should be the one we already
32 * know about). 32 * know about).
33 */ 33 */
34void InterfaceInformationImp::updateInterface(Interface *){ 34void InterfaceInformationImp::updateInterface(Interface *){
35 if(interface->getStatus()){ 35 if(interface->getStatus()){
36 startButton->setEnabled(false); 36 startButton->setEnabled(false);
37 stopButton->setEnabled(true); 37 stopButton->setEnabled(true);
38 restartButton->setEnabled(true); 38 restartButton->setEnabled(true);
39 } 39 }
40 else{ 40 else{
41 startButton->setEnabled(true); 41 startButton->setEnabled(true);
42 stopButton->setEnabled(false); 42 stopButton->setEnabled(false);
43 restartButton->setEnabled(false); 43 restartButton->setEnabled(false);
44 } 44 }
45 macAddressLabel->setText(interface->getMacAddress()); 45 macAddressLabel->setText(interface->getMacAddress());
46 ipAddressLabel->setText(interface->getIp()); 46 ipAddressLabel->setText(interface->getIp());
47 subnetMaskLabel->setText(interface->getSubnetMask()); 47 subnetMaskLabel->setText(interface->getSubnetMask());
48 broadcastLabel->setText(interface->getBroadcast()); 48 broadcastLabel->setText(interface->getBroadcast());
49} 49}
50 50
51/** 51/**
52 * Create the advanced widget. Fill it with the current interface's information. 52 * Create the advanced widget. Fill it with the current interface's information.
53 * Display it. 53 * Display it.
54 */ 54 */
55void InterfaceInformationImp::advanced(){ 55void InterfaceInformationImp::advanced(){
56 InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog); 56 InterfaceAdvanced *a = new InterfaceAdvanced(this, "InterfaceAdvanced", Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog);
57 a->interfaceName->setText(interface->getInterfaceName()); 57 a->interfaceName->setText(interface->getInterfaceName());
58 a->macAddressLabel->setText(interface->getMacAddress()); 58 a->macAddressLabel->setText(interface->getMacAddress());
59 a->ipAddressLabel->setText(interface->getIp()); 59 a->ipAddressLabel->setText(interface->getIp());
60 a->subnetMaskLabel->setText(interface->getSubnetMask()); 60 a->subnetMaskLabel->setText(interface->getSubnetMask());
61 a->broadcastLabel->setText(interface->getBroadcast()); 61 a->broadcastLabel->setText(interface->getBroadcast());
62 a->dhcpServerLabel->setText(interface->getDhcpServerIp()); 62 a->dhcpServerLabel->setText(interface->getDhcpServerIp());
63 a->leaseObtainedLabel->setText(interface->getLeaseObtained()); 63 a->leaseObtainedLabel->setText(interface->getLeaseObtained());
64 a->leaseExpiresLabel->setText(interface->getLeaseExpires()); 64 a->leaseExpiresLabel->setText(interface->getLeaseExpires());
65 a->dhcpInformation->setEnabled(interface->isDhcp()); 65 a->dhcpInformation->setEnabled(interface->isDhcp());
66 a->showMaximized(); 66 a->showMaximized();
67} 67}
68 68
69/** 69/**
70 * Messages from the interface if start/stop went as planned. 70 * Messages from the interface if start/stop went as planned.
71 * Purly for user feedback. 71 * Purly for user feedback.
72 * @param message the message to display. 72 * @param message the message to display.
73 */ 73 */
74void InterfaceInformationImp::showMessage(const QString &message){ 74void InterfaceInformationImp::showMessage(const QString &message){
75 QMessageBox::information(this, "Message", message, QMessageBox::Ok); 75 QMessageBox::information(this, "Message", message, QMessageBox::Ok);
76} 76}
77 77
78// infoimp.cpp 78// infoimp.cpp
79 79
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp
index d6b708b..581b7e3 100644
--- a/noncore/settings/networksettings/mainwindowimp.cpp
+++ b/noncore/settings/networksettings/mainwindowimp.cpp
@@ -1,590 +1,590 @@
1#include "mainwindowimp.h" 1#include "mainwindowimp.h"
2#include "addconnectionimp.h" 2#include "addconnectionimp.h"
3#include "interfaceinformationimp.h" 3#include "interfaceinformationimp.h"
4#include "interfacesetupimp.h" 4#include "interfacesetupimp.h"
5#include "interfaces.h" 5#include "interfaces.h"
6#include "module.h" 6#include "module.h"
7 7
8#include <qpushbutton.h> 8#include <qpushbutton.h>
9#include <qlistbox.h> 9#include <qlistbox.h>
10#include <qlineedit.h> 10#include <qlineedit.h>
11#include <qlistview.h> 11#include <qlistview.h>
12#include <qheader.h> 12#include <qheader.h>
13#include <qlabel.h> 13#include <qlabel.h>
14 14
15#include <qmessagebox.h> 15#include <qmessagebox.h>
16 16
17#ifdef QTE_VERSION 17#ifdef QWS
18 #include <qpe/config.h> 18 #include <qpe/config.h>
19 #include <qpe/qlibrary.h> 19 #include <qpe/qlibrary.h>
20 #include <qpe/resource.h> 20 #include <qpe/resource.h>
21 #include <qpe/qpeapplication.h> 21 #include <qpe/qpeapplication.h>
22 #define QLibrary 22// #define QLibrary Library
23#else 23#else
24 #include <klibloader.h> 24 #include <klibloader.h>
25 #define QLibrary KLibrary 25 #define QLibrary KLibrary
26 #include <kconfig.h> 26 #include <kconfig.h>
27 #define Config KConfig 27 #define Config KConfig
28 #include <kapplication.h> 28 #include <kapplication.h>
29 #include <kstandarddirs.h> 29 #include <kstandarddirs.h>
30 #include <kiconloader.h> 30 #include <kiconloader.h>
31 #define showMaximized show 31 #define showMaximized show
32#endif 32#endif
33 33
34#if QT_VERSION < 300 34#if QT_VERSION < 300
35#include <qlist.h> 35#include <qlist.h>
36#else 36#else
37#include <qptrlist.h> 37#include <qptrlist.h>
38#endif 38#endif
39#include <qdir.h> 39#include <qdir.h>
40#include <qfile.h> 40#include <qfile.h>
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qregexp.h> 42#include <qregexp.h>
43 43
44#include <net/if.h> 44#include <net/if.h>
45#include <sys/ioctl.h> 45#include <sys/ioctl.h>
46 46
47#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme" 47#define DEFAULT_SCHEME "/var/lib/pcmcia/scheme"
48 48
49MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){ 49MainWindowImp::MainWindowImp(QWidget *parent, const char *name) : MainWindow(parent, name), advancedUserMode(true), scheme(DEFAULT_SCHEME){
50 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked())); 50 connect(addConnectionButton, SIGNAL(clicked()), this, SLOT(addClicked()));
51 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked())); 51 connect(removeConnectionButton, SIGNAL(clicked()), this, SLOT(removeClicked()));
52 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked())); 52 connect(informationConnectionButton, SIGNAL(clicked()), this, SLOT(informationClicked()));
53 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked())); 53 connect(configureConnectionButton, SIGNAL(clicked()), this, SLOT(configureClicked()));
54 54
55 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile())); 55 connect(newProfileButton, SIGNAL(clicked()), this, SLOT(addProfile()));
56 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile())); 56 connect(removeProfileButton, SIGNAL(clicked()), this, SLOT(removeProfile()));
57 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile())); 57 connect(setCurrentProfileButton, SIGNAL(clicked()), this, SLOT(changeProfile()));
58 58
59 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&))); 59 connect(newProfile, SIGNAL(textChanged(const QString&)), this, SLOT(newProfileChanged(const QString&)));
60 // Load connections. 60 // Load connections.
61 // /usr/local/kde/lib/libinterfaces.la 61 // /usr/local/kde/lib/libinterfaces.la
62#ifdef QTE_VERSION 62#ifdef QWS
63 loadModules(QPEApplication::kdeDir() + "/plugins/networksettings"); 63 loadModules(QPEApplication::qpeDir() + "/plugins/networksettings");
64#else 64#else
65 loader = KLibLoader::self(); 65 loader = KLibLoader::self();
66 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib")); 66 loadModules(QString("/usr/")+KStandardDirs::kde_default("lib"));
67#endif 67#endif
68 getAllInterfaces(); 68 getAllInterfaces();
69 69
70 Interfaces i; 70 Interfaces i;
71 QStringList list = i.getInterfaceList(); 71 QStringList list = i.getInterfaceList();
72 QMap<QString, Interface*>::Iterator it; 72 QMap<QString, Interface*>::Iterator it;
73 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) { 73 for ( QStringList::Iterator ni = list.begin(); ni != list.end(); ++ni ) {
74 bool found = false; 74 bool found = false;
75 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){ 75 for( it = interfaceNames.begin(); it != interfaceNames.end(); ++it ){
76 if(it.key() == (*ni)) 76 if(it.key() == (*ni))
77 found = true; 77 found = true;
78 } 78 }
79 if(!found){ 79 if(!found){
80 if(!(*ni).contains("_")){ 80 if(!(*ni).contains("_")){
81 Interface *i = new Interface(this, *ni, false); 81 Interface *i = new Interface(this, *ni, false);
82 i->setAttached(false); 82 i->setAttached(false);
83 i->setHardwareName("Disconnected"); 83 i->setHardwareName("Disconnected");
84 interfaceNames.insert(i->getInterfaceName(), i); 84 interfaceNames.insert(i->getInterfaceName(), i);
85 updateInterface(i); 85 updateInterface(i);
86 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 86 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
87 } 87 }
88 } 88 }
89 } 89 }
90 90
91 //getInterfaceList(); 91 //getInterfaceList();
92 connectionList->header()->hide(); 92 connectionList->header()->hide();
93 93
94 Config cfg("NetworkSetup"); 94 Config cfg("NetworkSetup");
95 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); 95 profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All"));
96 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 96 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
97 profilesList->insertItem((*it)); 97 profilesList->insertItem((*it));
98 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); 98 currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All"));
99 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); 99 advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false);
100 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); 100 scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME);
101 101
102 QFile file(scheme); 102 QFile file(scheme);
103 if ( file.open(IO_ReadOnly) ) { // file opened successfully 103 if ( file.open(IO_ReadOnly) ) { // file opened successfully
104 QTextStream stream( &file ); // use a text stream 104 QTextStream stream( &file ); // use a text stream
105 while ( !stream.eof() ) { // until end of file... 105 while ( !stream.eof() ) { // until end of file...
106 QString line = stream.readLine(); // line of text excluding '\n' 106 QString line = stream.readLine(); // line of text excluding '\n'
107 if(line.contains("SCHEME")){ 107 if(line.contains("SCHEME")){
108 line = line.mid(7, line.length()); 108 line = line.mid(7, line.length());
109 currentProfileLabel->setText(line); 109 currentProfileLabel->setText(line);
110 break; 110 break;
111 } 111 }
112 } 112 }
113 file.close(); 113 file.close();
114 } 114 }
115} 115}
116 116
117/** 117/**
118 * Deconstructor. Save profiles. Delete loaded libraries. 118 * Deconstructor. Save profiles. Delete loaded libraries.
119 */ 119 */
120MainWindowImp::~MainWindowImp(){ 120MainWindowImp::~MainWindowImp(){
121 // Save profiles. 121 // Save profiles.
122 Config cfg("NetworkSetup"); 122 Config cfg("NetworkSetup");
123 cfg.setGroup("General"); 123 cfg.setGroup("General");
124 cfg.writeEntry("Profiles", profiles.join(" ")); 124 cfg.writeEntry("Profiles", profiles.join(" "));
125 125
126 // Delete all interfaces that don't have owners. 126 // Delete all interfaces that don't have owners.
127 QMap<Interface*, QListViewItem*>::Iterator iIt; 127 QMap<Interface*, QListViewItem*>::Iterator iIt;
128 for( iIt = items.begin(); iIt != items.end(); ++iIt ){ 128 for( iIt = items.begin(); iIt != items.end(); ++iIt ){
129 if(iIt.key()->getModuleOwner() == NULL) 129 if(iIt.key()->getModuleOwner() == NULL)
130 delete iIt.key(); 130 delete iIt.key();
131 } 131 }
132 132
133#ifdef QTE_VERSION 133#ifdef QWS
134 // Delete Modules and Libraries 134 // Delete Modules and Libraries
135 QMap<Module*, QLibrary*>::Iterator it; 135 QMap<Module*, QLibrary*>::Iterator it;
136 for( it = libraries.begin(); it != libraries.end(); ++it ){ 136 for( it = libraries.begin(); it != libraries.end(); ++it ){
137 delete it.key(); 137 delete it.key();
138 // I wonder why I can't delete the libraries 138 // I wonder why I can't delete the libraries
139 // What fucking shit this is. 139 // What fucking shit this is.
140 //delete it.data(); 140 //delete it.data();
141 } 141 }
142#else 142#else
143 // klibloader automaticly deletes the libraries for us... 143 // klibloader automaticly deletes the libraries for us...
144#endif 144#endif
145} 145}
146 146
147/** 147/**
148 * Query the kernel for all of the interfaces. 148 * Query the kernel for all of the interfaces.
149 */ 149 */
150void MainWindowImp::getAllInterfaces(){ 150void MainWindowImp::getAllInterfaces(){
151 int sockfd = socket(AF_INET, SOCK_DGRAM, 0); 151 int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
152 if(sockfd == -1) 152 if(sockfd == -1)
153 return; 153 return;
154 154
155 char buf[8*1024]; 155 char buf[8*1024];
156 struct ifconf ifc; 156 struct ifconf ifc;
157 ifc.ifc_len = sizeof(buf); 157 ifc.ifc_len = sizeof(buf);
158 ifc.ifc_req = (struct ifreq *) buf; 158 ifc.ifc_req = (struct ifreq *) buf;
159 int result=ioctl(sockfd, SIOCGIFCONF, &ifc); 159 int result=ioctl(sockfd, SIOCGIFCONF, &ifc);
160 160
161 for (char* ptr = buf; ptr < buf + ifc.ifc_len; ){ 161 for (char* ptr = buf; ptr < buf + ifc.ifc_len; ){
162 struct ifreq *ifr =(struct ifreq *) ptr; 162 struct ifreq *ifr =(struct ifreq *) ptr;
163 int len = sizeof(struct sockaddr); 163 int len = sizeof(struct sockaddr);
164#ifdef HAVE_SOCKADDR_SA_LEN 164#ifdef HAVE_SOCKADDR_SA_LEN
165 if (ifr->ifr_addr.sa_len > len) 165 if (ifr->ifr_addr.sa_len > len)
166 len = ifr->ifr_addr.sa_len; /* length > 16 */ 166 len = ifr->ifr_addr.sa_len; /* length > 16 */
167#endif 167#endif
168 ptr += sizeof(ifr->ifr_name) + len; /* for next one in buffer */ 168 ptr += sizeof(ifr->ifr_name) + len; /* for next one in buffer */
169 169
170 int flags; 170 int flags;
171 struct sockaddr_in *sinptr; 171 struct sockaddr_in *sinptr;
172 Interface *i = NULL; 172 Interface *i = NULL;
173 switch (ifr->ifr_addr.sa_family){ 173 switch (ifr->ifr_addr.sa_family){
174 case AF_INET: 174 case AF_INET:
175 sinptr = (struct sockaddr_in *) &ifr->ifr_addr; 175 sinptr = (struct sockaddr_in *) &ifr->ifr_addr;
176 flags=0; 176 flags=0;
177 177
178 struct ifreq ifcopy; 178 struct ifreq ifcopy;
179 ifcopy=*ifr; 179 ifcopy=*ifr;
180 result=ioctl(sockfd,SIOCGIFFLAGS,&ifcopy); 180 result=ioctl(sockfd,SIOCGIFFLAGS,&ifcopy);
181 flags=ifcopy.ifr_flags; 181 flags=ifcopy.ifr_flags;
182 i = new Interface(this, ifr->ifr_name, false); 182 i = new Interface(this, ifr->ifr_name, false);
183 i->setAttached(true); 183 i->setAttached(true);
184 if ((flags & IFF_UP) == IFF_UP) 184 if ((flags & IFF_UP) == IFF_UP)
185 i->setStatus(true); 185 i->setStatus(true);
186 else 186 else
187 i->setStatus(false); 187 i->setStatus(false);
188 188
189 if ((flags & IFF_BROADCAST) == IFF_BROADCAST) 189 if ((flags & IFF_BROADCAST) == IFF_BROADCAST)
190 i->setHardwareName("Ethernet"); 190 i->setHardwareName("Ethernet");
191 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) 191 else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT)
192 i->setHardwareName("Point to Point"); 192 i->setHardwareName("Point to Point");
193 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) 193 else if ((flags & IFF_MULTICAST) == IFF_MULTICAST)
194 i->setHardwareName("Multicast"); 194 i->setHardwareName("Multicast");
195 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) 195 else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK)
196 i->setHardwareName("Loopback"); 196 i->setHardwareName("Loopback");
197 else 197 else
198 i->setHardwareName("Unknown"); 198 i->setHardwareName("Unknown");
199 199
200 interfaceNames.insert(i->getInterfaceName(), i); 200 interfaceNames.insert(i->getInterfaceName(), i);
201 updateInterface(i); 201 updateInterface(i);
202 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); 202 connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *)));
203 break; 203 break;
204 204
205 default: 205 default:
206 qDebug(ifr->ifr_name); 206 qDebug(ifr->ifr_name);
207 qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1()); 207 qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1());
208 break; 208 break;
209 } 209 }
210 } 210 }
211} 211}
212 212
213/** 213/**
214 * Load all modules that are found in the path 214 * Load all modules that are found in the path
215 * @param path a directory that is scaned for any plugins that can be loaded 215 * @param path a directory that is scaned for any plugins that can be loaded
216 * and attempts to load them 216 * and attempts to load them
217 */ 217 */
218void MainWindowImp::loadModules(const QString &path){ 218void MainWindowImp::loadModules(const QString &path){
219#ifdef DEBUG 219#ifdef DEBUG
220 qDebug("MainWindowImp::loadModules: %s", path.latin1()); 220 qDebug("MainWindowImp::loadModules: %s", path.latin1());
221#endif 221#endif
222 QDir d(path); 222 QDir d(path);
223 if(!d.exists()) 223 if(!d.exists())
224 return; 224 return;
225 225
226 // Don't want sym links 226 // Don't want sym links
227 d.setFilter( QDir::Files | QDir::NoSymLinks ); 227 d.setFilter( QDir::Files | QDir::NoSymLinks );
228 const QFileInfoList *list = d.entryInfoList(); 228 const QFileInfoList *list = d.entryInfoList();
229 QFileInfoListIterator it( *list ); 229 QFileInfoListIterator it( *list );
230 QFileInfo *fi; 230 QFileInfo *fi;
231 while ( (fi=it.current()) ) { 231 while ( (fi=it.current()) ) {
232 if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){ 232 if(fi->fileName().contains(".so") && fi->fileName().contains("networksettings_")){
233 loadPlugin(path + "/" + fi->fileName()); 233 loadPlugin(path + "/" + fi->fileName());
234 } 234 }
235 ++it; 235 ++it;
236 } 236 }
237} 237}
238 238
239/** 239/**
240 * Attempt to load a function and resolve a function. 240 * Attempt to load a function and resolve a function.
241 * @param pluginFileName - the name of the file in which to attempt to load 241 * @param pluginFileName - the name of the file in which to attempt to load
242 * @param resolveString - function pointer to resolve 242 * @param resolveString - function pointer to resolve
243 * @return pointer to the function with name resolveString or NULL 243 * @return pointer to the function with name resolveString or NULL
244 */ 244 */
245Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ 245Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){
246#ifdef DEBUG 246#ifdef DEBUG
247 qDebug("MainWindowImp::loadPlugin: %s", pluginFileName.latin1()); 247 qDebug("MainWindowImp::loadPlugin: %s", pluginFileName.latin1());
248#endif 248#endif
249#ifdef QTE_VERSION 249#ifdef QWS
250 QLibrary *lib = new QLibrary(pluginFileName); 250 QLibrary *lib = new QLibrary(pluginFileName);
251 void *functionPointer = lib->resolve(resolveString); 251 void *functionPointer = lib->resolve(resolveString);
252 if( !functionPointer ){ 252 if( !functionPointer ){
253#ifdef DEBUG 253#ifdef DEBUG
254 qDebug("MainWindowImp::loadPlugin: File: %s is not a plugin, but though was.", pluginFileName.latin1()); 254 qDebug("MainWindowImp::loadPlugin: File: %s is not a plugin, but though was.", pluginFileName.latin1());
255#endif 255#endif
256 delete lib; 256 delete lib;
257 return NULL; 257 return NULL;
258 } 258 }
259 // Try to get an object. 259 // Try to get an object.
260 Module *object = ((Module* (*)()) functionPointer)(); 260 Module *object = ((Module* (*)()) functionPointer)();
261 if(object == NULL){ 261 if(object == NULL){
262#ifdef DEBUG 262#ifdef DEBUG
263 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 263 qDebug("MainWindowImp: Couldn't create object, but did load library!");
264#endif 264#endif
265 delete lib; 265 delete lib;
266 return NULL; 266 return NULL;
267 } 267 }
268 268
269 // Store for deletion later 269 // Store for deletion later
270 libraries.insert(object, lib); 270 libraries.insert(object, lib);
271 return object; 271 return object;
272 272
273#else 273#else
274 QLibrary *lib = loader->library(pluginFileName); 274 QLibrary *lib = loader->library(pluginFileName);
275 if( !lib || !lib->hasSymbol(resolveString) ){ 275 if( !lib || !lib->hasSymbol(resolveString) ){
276#ifdef DEBUG 276#ifdef DEBUG
277 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); 277 qDebug(QString("MainWindowImp::loadPlugin: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1());
278#endif 278#endif
279 return NULL; 279 return NULL;
280 } 280 }
281 // Try to get an object. 281 // Try to get an object.
282 Module *object = ((Module* (*)()) lib->symbol(resolveString))(); 282 Module *object = ((Module* (*)()) lib->symbol(resolveString))();
283 if(object == NULL){ 283 if(object == NULL){
284#ifdef DEBUG 284#ifdef DEBUG
285 qDebug("MainWindowImp: Couldn't create object, but did load library!"); 285 qDebug("MainWindowImp: Couldn't create object, but did load library!");
286#endif 286#endif
287 return NULL; 287 return NULL;
288 } 288 }
289#ifdef DEBUG 289#ifdef DEBUG
290 qDebug("MainWindowImp::loadPlugin:: Found object, storing."); 290 qDebug("MainWindowImp::loadPlugin:: Found object, storing.");
291#endif 291#endif
292 // Store for deletion later 292 // Store for deletion later
293 libraries.insert(object, lib); 293 libraries.insert(object, lib);
294 return object; 294 return object;
295#endif 295#endif
296} 296}
297 297
298/** 298/**
299 * The Add button was clicked. Bring up the add dialog and if OK is hit 299 * The Add button was clicked. Bring up the add dialog and if OK is hit
300 * load the plugin and append it to the list 300 * load the plugin and append it to the list
301 */ 301 */
302void MainWindowImp::addClicked(){ 302void MainWindowImp::addClicked(){
303 QMap<Module*, QLibrary*>::Iterator it; 303 QMap<Module*, QLibrary*>::Iterator it;
304 QMap<QString, QString> list; 304 QMap<QString, QString> list;
305 QMap<QString, Module*> newInterfaceOwners; 305 QMap<QString, Module*> newInterfaceOwners;
306 //list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); 306 //list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port");
307 //list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); 307 //list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port");
308 for( it = libraries.begin(); it != libraries.end(); ++it ){ 308 for( it = libraries.begin(); it != libraries.end(); ++it ){
309 if(it.key()){ 309 if(it.key()){
310 (it.key())->possibleNewInterfaces(list); 310 (it.key())->possibleNewInterfaces(list);
311 } 311 }
312 } 312 }
313 // See if the list has anything that we can add. 313 // See if the list has anything that we can add.
314 if(list.count() == 0){ 314 if(list.count() == 0){
315 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); 315 QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok);
316 return; 316 return;
317 } 317 }
318 AddConnectionImp addNewConnection(this, "AddConnectionImp", true); 318 AddConnectionImp addNewConnection(this, "AddConnectionImp", true);
319 addNewConnection.addConnections(list); 319 addNewConnection.addConnections(list);
320 addNewConnection.showMaximized(); 320 addNewConnection.showMaximized();
321 if(QDialog::Accepted == addNewConnection.exec()){ 321 if(QDialog::Accepted == addNewConnection.exec()){
322 QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); 322 QListViewItem *item = addNewConnection.registeredServicesList->currentItem();
323 if(!item) 323 if(!item)
324 return; 324 return;
325 325
326 for( it = libraries.begin(); it != libraries.end(); ++it ){ 326 for( it = libraries.begin(); it != libraries.end(); ++it ){
327 if(it.key()){ 327 if(it.key()){
328 Interface *i = (it.key())->addNewInterface(item->text(0)); 328 Interface *i = (it.key())->addNewInterface(item->text(0));
329 if(i){ 329 if(i){
330 interfaceNames.insert(i->getInterfaceName(), i); 330 interfaceNames.insert(i->getInterfaceName(), i);
331 updateInterface(i); 331 updateInterface(i);
332 } 332 }
333 } 333 }
334 } 334 }
335 } 335 }
336} 336}
337 337
338/** 338/**
339 * Prompt the user to see if they really want to do this. 339 * Prompt the user to see if they really want to do this.
340 * If they do then remove from the list and unload. 340 * If they do then remove from the list and unload.
341 */ 341 */
342void MainWindowImp::removeClicked(){ 342void MainWindowImp::removeClicked(){
343 QListViewItem *item = connectionList->currentItem(); 343 QListViewItem *item = connectionList->currentItem();
344 if(!item) { 344 if(!item) {
345 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 345 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
346 return; 346 return;
347 } 347 }
348 348
349 Interface *i = interfaceItems[item]; 349 Interface *i = interfaceItems[item];
350 if(i->getModuleOwner() == NULL){ 350 if(i->getModuleOwner() == NULL){
351 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); 351 QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok);
352 } 352 }
353 else{ 353 else{
354 if(!i->getModuleOwner()->remove(i)) 354 if(!i->getModuleOwner()->remove(i))
355 QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); 355 QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok);
356 else{ 356 else{
357 QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); 357 QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok);
358 // TODO memory managment.... 358 // TODO memory managment....
359 // who deletes the interface? 359 // who deletes the interface?
360 } 360 }
361 } 361 }
362} 362}
363 363
364/** 364/**
365 * Pull up the configure about the currently selected interface. 365 * Pull up the configure about the currently selected interface.
366 * Report an error if no interface is selected. 366 * Report an error if no interface is selected.
367 * If the interface has a module owner then request its configure. 367 * If the interface has a module owner then request its configure.
368 */ 368 */
369void MainWindowImp::configureClicked(){ 369void MainWindowImp::configureClicked(){
370 QListViewItem *item = connectionList->currentItem(); 370 QListViewItem *item = connectionList->currentItem();
371 if(!item){ 371 if(!item){
372 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); 372 QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok);
373 return; 373 return;
374 } 374 }
375 375
376 Interface *i = interfaceItems[item]; 376 Interface *i = interfaceItems[item];
377 if(i->getModuleOwner()){ 377 if(i->getModuleOwner()){
378 QWidget *moduleConfigure = i->getModuleOwner()->configure(i); 378 QWidget *moduleConfigure = i->getModuleOwner()->configure(i);
379 if(moduleConfigure != NULL){ 379 if(moduleConfigure != NULL){
380 moduleConfigure->showMaximized(); 380 moduleConfigure->showMaximized();
381 return; 381 return;
382 } 382 }
383 } 383 }
384 384
385 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WShowModal | Qt::WDestructiveClose | Qt::WType_Dialog); 385 InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog);
386 QString currentProfileText = currentProfileLabel->text(); 386 QString currentProfileText = currentProfileLabel->text();
387 if(currentProfileText.upper() == "ALL"); 387 if(currentProfileText.upper() == "ALL");
388 currentProfileText = ""; 388 currentProfileText = "";
389 configure->setProfile(currentProfileText); 389 configure->setProfile(currentProfileText);
390 configure->showMaximized(); 390 configure->showMaximized();
391} 391}
392 392
393/** 393/**
394 * Pull up the information about the currently selected interface. 394 * Pull up the information about the currently selected interface.
395 * Report an error if no interface is selected. 395 * Report an error if no interface is selected.
396 * If the interface has a module owner then request its configure. 396 * If the interface has a module owner then request its configure.
397 */ 397 */
398void MainWindowImp::informationClicked(){ 398void MainWindowImp::informationClicked(){
399 QListViewItem *item = connectionList->currentItem(); 399 QListViewItem *item = connectionList->currentItem();
400 if(!item){ 400 if(!item){
401 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); 401 QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok);
402 return; 402 return;
403 } 403 }
404 404
405 Interface *i = interfaceItems[item]; 405 Interface *i = interfaceItems[item];
406 if(!i->isAttached()){ 406 if(!i->isAttached()){
407 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); 407 QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok);
408 return; 408 return;
409 } 409 }
410 410
411 if(i->getModuleOwner()){ 411 if(i->getModuleOwner()){
412 QWidget *moduleInformation = i->getModuleOwner()->information(i); 412 QWidget *moduleInformation = i->getModuleOwner()->information(i);
413 if(moduleInformation != NULL){ 413 if(moduleInformation != NULL){
414 moduleInformation->showMaximized(); 414 moduleInformation->showMaximized();
415#ifdef DEBUG 415#ifdef DEBUG
416 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed."); 416 qDebug("MainWindowImp::informationClicked:: Module owner has created, we showed.");
417#endif 417#endif
418 return; 418 return;
419 } 419 }
420 } 420 }
421 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WShowModal | Qt::WDestructiveClose | Qt::WType_Dialog); 421 InterfaceInformationImp *information = new InterfaceInformationImp(this, "InterfaceSetupImp", i, Qt::WType_Modal | Qt::WDestructiveClose | Qt::WStyle_Dialog);
422 information->showMaximized(); 422 information->showMaximized();
423} 423}
424 424
425/** 425/**
426 * Update this interface. If no QListViewItem exists create one. 426 * Update this interface. If no QListViewItem exists create one.
427 * @param Interface* pointer to the interface that needs to be updated. 427 * @param Interface* pointer to the interface that needs to be updated.
428 */ 428 */
429void MainWindowImp::updateInterface(Interface *i){ 429void MainWindowImp::updateInterface(Interface *i){
430 if(!advancedUserMode){ 430 if(!advancedUserMode){
431 if(i->getInterfaceName() == "lo") 431 if(i->getInterfaceName() == "lo")
432 return; 432 return;
433 } 433 }
434 434
435 QListViewItem *item = NULL; 435 QListViewItem *item = NULL;
436 436
437 // Find the interface, making it if needed. 437 // Find the interface, making it if needed.
438 if(items.find(i) == items.end()){ 438 if(items.find(i) == items.end()){
439 item = new QListViewItem(connectionList, "", "", ""); 439 item = new QListViewItem(connectionList, "", "", "");
440 // See if you can't find a module owner for this interface 440 // See if you can't find a module owner for this interface
441 QMap<Module*, QLibrary*>::Iterator it; 441 QMap<Module*, QLibrary*>::Iterator it;
442 for( it = libraries.begin(); it != libraries.end(); ++it ){ 442 for( it = libraries.begin(); it != libraries.end(); ++it ){
443 if(it.key()->isOwner(i)) 443 if(it.key()->isOwner(i))
444 i->setModuleOwner(it.key()); 444 i->setModuleOwner(it.key());
445 } 445 }
446 items.insert(i, item); 446 items.insert(i, item);
447 interfaceItems.insert(item, i); 447 interfaceItems.insert(item, i);
448 } 448 }
449 else 449 else
450 item = items[i]; 450 item = items[i];
451 451
452 // Update the icons and information 452 // Update the icons and information
453#ifdef QTE_VERSION 453#ifdef QWS
454 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); 454 item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down")));
455#else 455#else
456 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down"))); 456 item->setPixmap(0, (SmallIcon(i->getStatus() ? "up": "down")));
457#endif 457#endif
458 458
459 QString typeName = "lan"; 459 QString typeName = "lan";
460 if(i->getHardwareName().contains("Local Loopback")) 460 if(i->getHardwareName().contains("Local Loopback"))
461 typeName = "lo"; 461 typeName = "lo";
462 if(i->getInterfaceName().contains("irda")) 462 if(i->getInterfaceName().contains("irda"))
463 typeName = "irda"; 463 typeName = "irda";
464 if(i->getInterfaceName().contains("wlan")) 464 if(i->getInterfaceName().contains("wlan"))
465 typeName = "wlan"; 465 typeName = "wlan";
466 if(i->getInterfaceName().contains("usb")) 466 if(i->getInterfaceName().contains("usb"))
467 typeName = "usb"; 467 typeName = "usb";
468 468
469 if(!i->isAttached()) 469 if(!i->isAttached())
470 typeName = "connect_no"; 470 typeName = "connect_no";
471 // Actually try to use the Module 471 // Actually try to use the Module
472 if(i->getModuleOwner() != NULL) 472 if(i->getModuleOwner() != NULL)
473 typeName = i->getModuleOwner()->getPixmapName(i); 473 typeName = i->getModuleOwner()->getPixmapName(i);
474 474
475#ifdef QTE_VERSION 475#ifdef QWS
476 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); 476 item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName)));
477#else 477#else
478 item->setPixmap(1, (SmallIcon(typeName))); 478 item->setPixmap(1, (SmallIcon(typeName)));
479#endif 479#endif
480 item->setText(2, i->getHardwareName()); 480 item->setText(2, i->getHardwareName());
481 item->setText(3, QString("(%1)").arg(i->getInterfaceName())); 481 item->setText(3, QString("(%1)").arg(i->getInterfaceName()));
482 item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); 482 item->setText(4, (i->getStatus()) ? i->getIp() : QString(""));
483} 483}
484 484
485void MainWindowImp::newProfileChanged(const QString& newText){ 485void MainWindowImp::newProfileChanged(const QString& newText){
486 if(newText.length() > 0) 486 if(newText.length() > 0)
487 newProfileButton->setEnabled(true); 487 newProfileButton->setEnabled(true);
488 else 488 else
489 newProfileButton->setEnabled(false); 489 newProfileButton->setEnabled(false);
490} 490}
491 491
492/** 492/**
493 * Adds a new profile to the list of profiles. 493 * Adds a new profile to the list of profiles.
494 * Don't add profiles that already exists. 494 * Don't add profiles that already exists.
495 * Appends to the list and QStringList 495 * Appends to the list and QStringList
496 */ 496 */
497void MainWindowImp::addProfile(){ 497void MainWindowImp::addProfile(){
498 QString newProfileName = newProfile->text(); 498 QString newProfileName = newProfile->text();
499 if(profiles.grep(newProfileName).count() > 0){ 499 if(profiles.grep(newProfileName).count() > 0){
500 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); 500 QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok);
501 return; 501 return;
502 } 502 }
503 profiles.append(newProfileName); 503 profiles.append(newProfileName);
504 profilesList->insertItem(newProfileName); 504 profilesList->insertItem(newProfileName);
505} 505}
506 506
507/** 507/**
508 * Removes the currently selected profile in the combo. 508 * Removes the currently selected profile in the combo.
509 * Doesn't delete if there are less then 2 profiles. 509 * Doesn't delete if there are less then 2 profiles.
510 */ 510 */
511void MainWindowImp::removeProfile(){ 511void MainWindowImp::removeProfile(){
512 if(profilesList->count() <= 1){ 512 if(profilesList->count() <= 1){
513 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); 513 QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok);
514 return; 514 return;
515 } 515 }
516 QString profileToRemove = profilesList->currentText(); 516 QString profileToRemove = profilesList->currentText();
517 if(profileToRemove == "All"){ 517 if(profileToRemove == "All"){
518 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); 518 QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok);
519 return; 519 return;
520 } 520 }
521 // Can't remove the curent profile 521 // Can't remove the curent profile
522 if(profileToRemove == currentProfileLabel->text()){ 522 if(profileToRemove == currentProfileLabel->text()){
523 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); 523 QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok);
524 return; 524 return;
525 525
526 } 526 }
527 527
528 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ 528 if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){
529 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); 529 profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), ""));
530 profilesList->clear(); 530 profilesList->clear();
531 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) 531 for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it)
532 profilesList->insertItem((*it)); 532 profilesList->insertItem((*it));
533 533
534 // Remove any interface settings and mappings. 534 // Remove any interface settings and mappings.
535 Interfaces interfaces; 535 Interfaces interfaces;
536 // Go through them one by one 536 // Go through them one by one
537 QMap<Interface*, QListViewItem*>::Iterator it; 537 QMap<Interface*, QListViewItem*>::Iterator it;
538 for( it = items.begin(); it != items.end(); ++it ){ 538 for( it = items.begin(); it != items.end(); ++it ){
539 QString interfaceName = it.key()->getInterfaceName(); 539 QString interfaceName = it.key()->getInterfaceName();
540 qDebug(interfaceName.latin1()); 540 qDebug(interfaceName.latin1());
541 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ 541 if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){
542 interfaces.removeInterface(); 542 interfaces.removeInterface();
543 if(interfaces.setMapping(interfaceName)){ 543 if(interfaces.setMapping(interfaceName)){
544 if(profilesList->count() == 1) 544 if(profilesList->count() == 1)
545 interfaces.removeMapping(); 545 interfaces.removeMapping();
546 else{ 546 else{
547 interfaces.removeMap("map", interfaceName + "_" + profileToRemove); 547 interfaces.removeMap("map", interfaceName + "_" + profileToRemove);
548 } 548 }
549 } 549 }
550 interfaces.write(); 550 interfaces.write();
551 break; 551 break;
552 } 552 }
553 } 553 }
554 } 554 }
555} 555}
556 556
557/** 557/**
558 * A new profile has been selected, change. 558 * A new profile has been selected, change.
559 * @param newProfile the new profile. 559 * @param newProfile the new profile.
560 */ 560 */
561void MainWindowImp::changeProfile(){ 561void MainWindowImp::changeProfile(){
562 if(profilesList->currentItem() == -1){ 562 if(profilesList->currentItem() == -1){
563 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); 563 QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok);
564 return; 564 return;
565 } 565 }
566 QString newProfile = profilesList->text(profilesList->currentItem()); 566 QString newProfile = profilesList->text(profilesList->currentItem());
567 if(newProfile != currentProfileLabel->text()){ 567 if(newProfile != currentProfileLabel->text()){
568 currentProfileLabel->setText(newProfile); 568 currentProfileLabel->setText(newProfile);
569 QFile::remove(scheme); 569 QFile::remove(scheme);
570 QFile file(scheme); 570 QFile file(scheme);
571 if ( file.open(IO_ReadWrite) ) { 571 if ( file.open(IO_ReadWrite) ) {
572 QTextStream stream( &file ); 572 QTextStream stream( &file );
573 stream << QString("SCHEME=%1").arg(newProfile); 573 stream << QString("SCHEME=%1").arg(newProfile);
574 file.close(); 574 file.close();
575 } 575 }
576 // restart all up devices? 576 // restart all up devices?
577 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ 577 if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){
578 // Go through them one by one 578 // Go through them one by one
579 QMap<Interface*, QListViewItem*>::Iterator it; 579 QMap<Interface*, QListViewItem*>::Iterator it;
580 for( it = items.begin(); it != items.end(); ++it ){ 580 for( it = items.begin(); it != items.end(); ++it ){
581 if(it.key()->getStatus() == true) 581 if(it.key()->getStatus() == true)
582 it.key()->restart(); 582 it.key()->restart();
583 } 583 }
584 } 584 }
585 } 585 }
586 // TODO change the profile in the modules 586 // TODO change the profile in the modules
587} 587}
588 588
589// mainwindowimp.cpp 589// mainwindowimp.cpp
590 590
diff --git a/noncore/settings/networksettings/mainwindowimp.h b/noncore/settings/networksettings/mainwindowimp.h
index 2ebf304..49f3eea 100644
--- a/noncore/settings/networksettings/mainwindowimp.h
+++ b/noncore/settings/networksettings/mainwindowimp.h
@@ -1,69 +1,69 @@
1#ifndef MAINWINOWIMP_H 1#ifndef MAINWINOWIMP_H
2#define MAINWINOWIMP_H 2#define MAINWINOWIMP_H
3 3
4#include "mainwindow.h" 4#include "mainwindow.h"
5#include <qmap.h> 5#include <qmap.h>
6#include <qstringlist.h> 6#include <qstringlist.h>
7 7
8class Module; 8class Module;
9class Interface; 9class Interface;
10class QLibrary; 10class QLibrary;
11class KProcess; 11class KProcess;
12#ifdef QTE_VERSION 12#ifdef QWS
13class QLibrary; 13class QLibrary;
14#else 14#else
15class KLibrary; 15class KLibrary;
16class KLibLoader; 16class KLibLoader;
17#define QLibrary KLibrary 17#define QLibrary KLibrary
18#endif 18#endif
19 19
20 20
21class MainWindowImp : public MainWindow { 21class MainWindowImp : public MainWindow {
22 Q_OBJECT 22 Q_OBJECT
23 23
24public: 24public:
25 MainWindowImp(QWidget *parent=0, const char *name=0); 25 MainWindowImp(QWidget *parent=0, const char *name=0);
26 ~MainWindowImp(); 26 ~MainWindowImp();
27 27
28private slots: 28private slots:
29 void getAllInterfaces(); 29 void getAllInterfaces();
30 30
31 void addClicked(); 31 void addClicked();
32 void removeClicked(); 32 void removeClicked();
33 void configureClicked(); 33 void configureClicked();
34 void informationClicked(); 34 void informationClicked();
35 35
36 void addProfile(); 36 void addProfile();
37 void removeProfile(); 37 void removeProfile();
38 void changeProfile(); 38 void changeProfile();
39 39
40 void updateInterface(Interface *i); 40 void updateInterface(Interface *i);
41 void newProfileChanged(const QString& newText); 41 void newProfileChanged(const QString& newText);
42 42
43private: 43private:
44 void loadModules(const QString &path); 44 void loadModules(const QString &path);
45 45
46 Module* loadPlugin(const QString &pluginFileName, 46 Module* loadPlugin(const QString &pluginFileName,
47 const QString &resolveString = "create_plugin"); 47 const QString &resolveString = "create_plugin");
48 48
49 // For our local list of names 49 // For our local list of names
50 QMap<QString, Interface*> interfaceNames; 50 QMap<QString, Interface*> interfaceNames;
51 51
52 QMap<Module*, QLibrary*> libraries; 52 QMap<Module*, QLibrary*> libraries;
53 QMap<Interface*, QListViewItem*> items; 53 QMap<Interface*, QListViewItem*> items;
54 QMap<QListViewItem*, Interface*> interfaceItems; 54 QMap<QListViewItem*, Interface*> interfaceItems;
55 55
56 QMap<KProcess*, QString> threads; 56 QMap<KProcess*, QString> threads;
57 QStringList profiles; 57 QStringList profiles;
58 58
59 bool advancedUserMode; 59 bool advancedUserMode;
60 QString scheme; 60 QString scheme;
61#ifndef QTE_VERSION 61#ifndef QWS
62 KLibLoader *loader; 62 KLibLoader *loader;
63#endif 63#endif
64}; 64};
65 65
66#endif 66#endif
67 67
68// mainwindowimp.h 68// mainwindowimp.h
69 69
diff --git a/noncore/settings/networksettings/wlan/wlanimp.cpp b/noncore/settings/networksettings/wlan/wlanimp.cpp
index 57266bb..8bf004f 100644
--- a/noncore/settings/networksettings/wlan/wlanimp.cpp
+++ b/noncore/settings/networksettings/wlan/wlanimp.cpp
@@ -1,208 +1,208 @@
1#include "wlanimp.h" 1#include "wlanimp.h"
2#include "interfacesetupimp.h" 2#include "interfacesetupimp.h"
3 3
4#include <qfile.h> 4#include <qfile.h>
5#include <qdir.h> 5#include <qdir.h>
6#include <qtextstream.h> 6#include <qtextstream.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qlabel.h> 9#include <qlabel.h>
10#include <qspinbox.h> 10#include <qspinbox.h>
11#include <qradiobutton.h> 11#include <qradiobutton.h>
12#include <qcheckbox.h> 12#include <qcheckbox.h>
13#include <qtabwidget.h> 13#include <qtabwidget.h>
14#include <qcombobox.h> 14#include <qcombobox.h>
15 15
16#ifdef QTE_VERSION 16#ifdef QWS
17 #include <opie/oprocess.h> 17 #include <opie/oprocess.h>
18#else 18#else
19 #define OProcess KProcess 19 #define OProcess KProcess
20 #include <kprocess.h> 20 #include <kprocess.h>
21#endif 21#endif
22 22
23#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts" 23#define WIRELESS_OPTS "/etc/pcmcia/wireless.opts"
24 24
25/** 25/**
26 * Constructor, read in the wireless.opts file for parsing later. 26 * Constructor, read in the wireless.opts file for parsing later.
27 */ 27 */
28WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") { 28WLANImp::WLANImp( QWidget* parent, const char* name, Interface *i, bool modal, WFlags fl):WLAN(parent, name, modal, fl), currentProfile("*") {
29 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i); 29 interfaceSetup = new InterfaceSetupImp(tabWidget, "InterfaceSetupImp", i);
30 tabWidget->insertTab(interfaceSetup, "TCP/IP"); 30 tabWidget->insertTab(interfaceSetup, "TCP/IP");
31 31
32 // Read in the config file. 32 // Read in the config file.
33 QString wlanFile = WIRELESS_OPTS; 33 QString wlanFile = WIRELESS_OPTS;
34 QFile file(wlanFile); 34 QFile file(wlanFile);
35 if (file.open(IO_ReadOnly)){ 35 if (file.open(IO_ReadOnly)){
36 QTextStream stream( &file ); 36 QTextStream stream( &file );
37 QString line = ""; 37 QString line = "";
38 while ( !stream.eof() ) { 38 while ( !stream.eof() ) {
39 line += stream.readLine(); 39 line += stream.readLine();
40 line += "\n"; 40 line += "\n";
41 } 41 }
42 file.close(); 42 file.close();
43 settingsFileText = QStringList::split("\n", line, true); 43 settingsFileText = QStringList::split("\n", line, true);
44 parseSettingFile(); 44 parseSettingFile();
45 } 45 }
46 else 46 else
47 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1()); 47 qDebug(QString("WLANImp: Can't open file: %1 for reading.").arg(wlanFile).latin1());
48 connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int))); 48 connect(networkType, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
49} 49}
50 50
51void WLANImp::typeChanged(int mod){ 51void WLANImp::typeChanged(int mod){
52 networkChannel->setEnabled(mod); 52 networkChannel->setEnabled(mod);
53 channelLabel->setEnabled(mod); 53 channelLabel->setEnabled(mod);
54} 54}
55 55
56/** 56/**
57 * Change the profile for both wireless settings and network settings. 57 * Change the profile for both wireless settings and network settings.
58 */ 58 */
59void WLANImp::setProfile(const QString &profile){ 59void WLANImp::setProfile(const QString &profile){
60 interfaceSetup->setProfile(profile); 60 interfaceSetup->setProfile(profile);
61 parseSettingFile(); 61 parseSettingFile();
62} 62}
63 63
64/** 64/**
65 * Parses the settings file that was read in and gets any setting from it. 65 * Parses the settings file that was read in and gets any setting from it.
66 */ 66 */
67void WLANImp::parseSettingFile(){ 67void WLANImp::parseSettingFile(){
68 bool foundCase = false; 68 bool foundCase = false;
69 bool found = false; 69 bool found = false;
70 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 70 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
71 QString line = (*it).simplifyWhiteSpace(); 71 QString line = (*it).simplifyWhiteSpace();
72 if(line.contains("case")) 72 if(line.contains("case"))
73 foundCase = true; 73 foundCase = true;
74 // See if we found our scheme to write or the sceme couldn't be found 74 // See if we found our scheme to write or the sceme couldn't be found
75 if((foundCase && line.contains("esac")) || 75 if((foundCase && line.contains("esac")) ||
76 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')) 76 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#'))
77 found = true; 77 found = true;
78 78
79 if(line.contains(";;")) 79 if(line.contains(";;"))
80 found = false; 80 found = false;
81 if(found){ 81 if(found){
82 // write out scheme 82 // write out scheme
83 if(line.contains("ESSID=")){ 83 if(line.contains("ESSID=")){
84 QString id = line.mid(line.find("ESSID=")+6, line.length()); 84 QString id = line.mid(line.find("ESSID=")+6, line.length());
85 if(id == "any"){ 85 if(id == "any"){
86 essAny->setChecked(false); 86 essAny->setChecked(false);
87 }else{ 87 }else{
88 essAny->setChecked(true); 88 essAny->setChecked(true);
89 essSpecificLineEdit->setText(id); 89 essSpecificLineEdit->setText(id);
90 } 90 }
91 } 91 }
92 if(line.contains("MODE=")){ 92 if(line.contains("MODE=")){
93 QString mode = line.mid(line.find("MODE=")+5, line.length()); 93 QString mode = line.mid(line.find("MODE=")+5, line.length());
94 if(mode == "Managed"){ 94 if(mode == "Managed"){
95 networkType->setCurrentItem(0); 95 networkType->setCurrentItem(0);
96 channelLabel->setEnabled(false); 96 channelLabel->setEnabled(false);
97 networkChannel->setEnabled(false); 97 networkChannel->setEnabled(false);
98 } 98 }
99 else{ 99 else{
100 networkType->setCurrentItem(1); 100 networkType->setCurrentItem(1);
101 networkChannel->setEnabled(true); 101 networkChannel->setEnabled(true);
102 channelLabel->setEnabled(true); 102 channelLabel->setEnabled(true);
103 } 103 }
104 } 104 }
105 if(line.contains("#KEY0=")) 105 if(line.contains("#KEY0="))
106 keyLineEdit0->setText(line.mid(6, line.length())); 106 keyLineEdit0->setText(line.mid(6, line.length()));
107 if(line.contains("#KEY1=")) 107 if(line.contains("#KEY1="))
108 keyLineEdit1->setText(line.mid(6, line.length())); 108 keyLineEdit1->setText(line.mid(6, line.length()));
109 if(line.contains("#KEY2=")) 109 if(line.contains("#KEY2="))
110 keyLineEdit2->setText(line.mid(6, line.length())); 110 keyLineEdit2->setText(line.mid(6, line.length()));
111 if(line.contains("#KEY3=")) 111 if(line.contains("#KEY3="))
112 keyLineEdit3->setText(line.mid(6, line.length())); 112 keyLineEdit3->setText(line.mid(6, line.length()));
113 113
114 if(line.contains("KEY=")){ 114 if(line.contains("KEY=")){
115 wepEnabled->setChecked(true); 115 wepEnabled->setChecked(true);
116 QString key; 116 QString key;
117 if(line.right(5) == (" open")){ 117 if(line.right(5) == (" open")){
118 key = line.mid(4, line.length()-5); 118 key = line.mid(4, line.length()-5);
119 authOpen->setChecked(true); 119 authOpen->setChecked(true);
120 authShared->setChecked(false); 120 authShared->setChecked(false);
121 } 121 }
122 else{ 122 else{
123 authOpen->setChecked(false); 123 authOpen->setChecked(false);
124 authShared->setChecked(true); 124 authShared->setChecked(true);
125 key = line.mid(4, line.length()); 125 key = line.mid(4, line.length());
126 } 126 }
127 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true); 127 if(key == keyLineEdit0->text()) keyRadio0->setChecked(true);
128 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true); 128 if(key == keyLineEdit1->text()) keyRadio1->setChecked(true);
129 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true); 129 if(key == keyLineEdit2->text()) keyRadio2->setChecked(true);
130 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true); 130 if(key == keyLineEdit3->text()) keyRadio3->setChecked(true);
131 } 131 }
132 if(line.contains("CHANNEL=")){ 132 if(line.contains("CHANNEL=")){
133 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt()); 133 networkChannel->setValue(line.mid(line.find("CHANNEL=")+8, line.length()).toInt());
134 } 134 }
135 } 135 }
136 } 136 }
137} 137}
138 138
139/** 139/**
140 * Saves settings to the wireless.opts file using the current profile 140 * Saves settings to the wireless.opts file using the current profile
141 */ 141 */
142void WLANImp::changeAndSaveSettingFile(){ 142void WLANImp::changeAndSaveSettingFile(){
143 QString wlanFile = WIRELESS_OPTS; 143 QString wlanFile = WIRELESS_OPTS;
144 QFile::remove(wlanFile); 144 QFile::remove(wlanFile);
145 QFile file(wlanFile); 145 QFile file(wlanFile);
146 146
147 if (!file.open(IO_ReadWrite)){ 147 if (!file.open(IO_ReadWrite)){
148 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1()); 148 qDebug(QString("WLANImp::changeAndSaveSettingFile(): Can't open file: %1 for writing.").arg(wlanFile).latin1());
149 return; 149 return;
150 } 150 }
151 151
152 QTextStream stream( &file ); 152 QTextStream stream( &file );
153 bool foundCase = false; 153 bool foundCase = false;
154 bool found = false; 154 bool found = false;
155 bool output = true; 155 bool output = true;
156 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) { 156 for ( QStringList::Iterator it = settingsFileText.begin(); it != settingsFileText.end(); ++it ) {
157 QString line = (*it).simplifyWhiteSpace(); 157 QString line = (*it).simplifyWhiteSpace();
158 if(line.contains("case")) 158 if(line.contains("case"))
159 foundCase = true; 159 foundCase = true;
160 // See if we found our scheme to write or the sceme couldn't be found 160 // See if we found our scheme to write or the sceme couldn't be found
161 if((foundCase && line.contains("esac") && !found) || 161 if((foundCase && line.contains("esac") && !found) ||
162 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){ 162 (foundCase && line.left(currentProfile.length()+7) == currentProfile + ",*,*,*)" && line.at(0) != '#')){
163 // write out scheme 163 // write out scheme
164 found = true; 164 found = true;
165 output = false; 165 output = false;
166 166
167 if(!line.contains("esac")) 167 if(!line.contains("esac"))
168 stream << line << "\n"; 168 stream << line << "\n";
169 if(!essAny->isChecked() == true){ 169 if(!essAny->isChecked() == true){
170 stream << "\tESSID=any\n"; 170 stream << "\tESSID=any\n";
171 stream << "\tMODE=Managed\n"; 171 stream << "\tMODE=Managed\n";
172 } 172 }
173 else{ 173 else{
174 stream << "\tESSID=" << essSpecificLineEdit->text() << '\n'; 174 stream << "\tESSID=" << essSpecificLineEdit->text() << '\n';
175 stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n'; 175 stream << "\tMODE=" << ( networkType->currentItem() == 0 ? "Managed" : "ad-hoc") << '\n';
176 stream << "\tCHANNEL=" << networkChannel->value() << "\n"; 176 stream << "\tCHANNEL=" << networkChannel->value() << "\n";
177 } 177 }
178 178
179 stream << "\t#KEY0=" << keyLineEdit0->text() << "\n"; 179 stream << "\t#KEY0=" << keyLineEdit0->text() << "\n";
180 stream << "\t#KEY1=" << keyLineEdit1->text() << "\n"; 180 stream << "\t#KEY1=" << keyLineEdit1->text() << "\n";
181 stream << "\t#KEY2=" << keyLineEdit2->text() << "\n"; 181 stream << "\t#KEY2=" << keyLineEdit2->text() << "\n";
182 stream << "\t#KEY3=" << keyLineEdit3->text() << "\n"; 182 stream << "\t#KEY3=" << keyLineEdit3->text() << "\n";
183 183
184 if(wepEnabled->isChecked()){ 184 if(wepEnabled->isChecked()){
185 stream << "\tKEY=\""; 185 stream << "\tKEY=\"";
186 if(keyRadio0->isChecked()) stream << keyLineEdit0->text(); 186 if(keyRadio0->isChecked()) stream << keyLineEdit0->text();
187 if(keyRadio1->isChecked()) stream << keyLineEdit1->text(); 187 if(keyRadio1->isChecked()) stream << keyLineEdit1->text();
188 if(keyRadio2->isChecked()) stream << keyLineEdit2->text(); 188 if(keyRadio2->isChecked()) stream << keyLineEdit2->text();
189 if(keyRadio3->isChecked()) stream << keyLineEdit3->text(); 189 if(keyRadio3->isChecked()) stream << keyLineEdit3->text();
190 if(authOpen->isChecked()) 190 if(authOpen->isChecked())
191 stream << " open"; 191 stream << " open";
192 else 192 else
193 stream << " restricted"; 193 stream << " restricted";
194 stream << "\"\n"; 194 stream << "\"\n";
195 } 195 }
196 stream << "\tRATE=auto\n"; 196 stream << "\tRATE=auto\n";
197 if(line.contains("esac")) 197 if(line.contains("esac"))
198 stream << line << "\n"; 198 stream << line << "\n";
199 } 199 }
200 if(line.contains(";;")) 200 if(line.contains(";;"))
201 output = true; 201 output = true;
202 if(output && (*it).length() ) 202 if(output && (*it).length() )
203 stream << (*it) << '\n'; 203 stream << (*it) << '\n';
204 } 204 }
205 file.close(); 205 file.close();
206} 206}
207 207
208/** 208/**