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