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