Diffstat (limited to 'noncore/settings/networksettings/mainwindow/mainwindowimp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp index fb7d7c9..5f23aea 100644 --- a/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindow/mainwindowimp.cpp | |||
@@ -99,385 +99,385 @@ MainWindowImp::MainWindowImp(QWidget *parent, const char *name, WFlags) : MainWi | |||
99 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); | 99 | profiles = QStringList::split(" ", cfg.readEntry("Profiles", "All")); |
100 | for ( QStringList::Iterator it = profiles.begin(); | 100 | for ( QStringList::Iterator it = profiles.begin(); |
101 | it != profiles.end(); ++it) | 101 | it != profiles.end(); ++it) |
102 | profilesList->insertItem((*it)); | 102 | profilesList->insertItem((*it)); |
103 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); | 103 | currentProfileLabel->setText(cfg.readEntry("CurrentProfile", "All")); |
104 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); | 104 | advancedUserMode = cfg.readBoolEntry("AdvancedUserMode", false); |
105 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); | 105 | scheme = cfg.readEntry("SchemeFile", DEFAULT_SCHEME); |
106 | 106 | ||
107 | QFile file(scheme); | 107 | QFile file(scheme); |
108 | if ( file.open(IO_ReadOnly) ) | 108 | if ( file.open(IO_ReadOnly) ) |
109 | { // file opened successfully | 109 | { // file opened successfully |
110 | QTextStream stream( &file ); // use a text stream | 110 | QTextStream stream( &file ); // use a text stream |
111 | while ( !stream.eof() ) | 111 | while ( !stream.eof() ) |
112 | { // until end of file... | 112 | { // until end of file... |
113 | QString line = stream.readLine(); // line of text excluding '\n' | 113 | QString line = stream.readLine(); // line of text excluding '\n' |
114 | if(line.contains("SCHEME")) | 114 | if(line.contains("SCHEME")) |
115 | { | 115 | { |
116 | line = line.mid(7, line.length()); | 116 | line = line.mid(7, line.length()); |
117 | currentProfileLabel->setText(line); | 117 | currentProfileLabel->setText(line); |
118 | break; | 118 | break; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | file.close(); | 121 | file.close(); |
122 | } | 122 | } |
123 | makeChannel(); | 123 | makeChannel(); |
124 | } | 124 | } |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Deconstructor. Save profiles. Delete loaded libraries. | 127 | * Deconstructor. Save profiles. Delete loaded libraries. |
128 | */ | 128 | */ |
129 | MainWindowImp::~MainWindowImp() | 129 | MainWindowImp::~MainWindowImp() |
130 | { | 130 | { |
131 | // Save profiles. | 131 | // Save profiles. |
132 | Config cfg("NetworkSetup"); | 132 | Config cfg("NetworkSetup"); |
133 | cfg.setGroup("General"); | 133 | cfg.setGroup("General"); |
134 | cfg.writeEntry("Profiles", profiles.join(" ")); | 134 | cfg.writeEntry("Profiles", profiles.join(" ")); |
135 | 135 | ||
136 | // Delete all interfaces that don't have owners. | 136 | // Delete all interfaces that don't have owners. |
137 | QMap<Interface*, QListViewItem*>::Iterator iIt; | 137 | QMap<Interface*, QListViewItem*>::Iterator iIt; |
138 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) | 138 | for( iIt = items.begin(); iIt != items.end(); ++iIt ) |
139 | { | 139 | { |
140 | if(iIt.key()->getModuleOwner() == NULL) | 140 | if(iIt.key()->getModuleOwner() == NULL) |
141 | delete iIt.key(); | 141 | delete iIt.key(); |
142 | } | 142 | } |
143 | 143 | ||
144 | // Delete Modules and Libraries | 144 | // Delete Modules and Libraries |
145 | QMap<Module*, QLibrary*>::Iterator it; | 145 | QMap<Module*, QLibrary*>::Iterator it; |
146 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 146 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
147 | { | 147 | { |
148 | delete it.key(); | 148 | delete it.key(); |
149 | // I wonder why I can't delete the libraries | 149 | // I wonder why I can't delete the libraries |
150 | // What fucking shit this is. | 150 | // What fucking shit this is. |
151 | //delete it.data(); | 151 | //delete it.data(); |
152 | } | 152 | } |
153 | } | 153 | } |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * Query the kernel for all of the interfaces. | 156 | * Query the kernel for all of the interfaces. |
157 | */ | 157 | */ |
158 | void MainWindowImp::getAllInterfaces() | 158 | void MainWindowImp::getAllInterfaces() |
159 | { | 159 | { |
160 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); | 160 | int sockfd = socket(PF_INET, SOCK_DGRAM, 0); |
161 | if(sockfd == -1) | 161 | if(sockfd == -1) |
162 | return; | 162 | return; |
163 | 163 | ||
164 | struct ifreq ifr; | 164 | struct ifreq ifr; |
165 | QStringList ifaces; | 165 | QStringList ifaces; |
166 | QFile procFile(QString(_PROCNETDEV)); | 166 | QFile procFile(QString(_PROCNETDEV)); |
167 | int result; | 167 | int result; |
168 | Interface *i; | 168 | Interface *i; |
169 | 169 | ||
170 | if (! procFile.exists()) | 170 | if (! procFile.exists()) |
171 | { | 171 | { |
172 | struct ifreq ifrs[100]; | 172 | struct ifreq ifrs[100]; |
173 | struct ifconf ifc; | 173 | struct ifconf ifc; |
174 | ifc.ifc_len = sizeof(ifrs); | 174 | ifc.ifc_len = sizeof(ifrs); |
175 | ifc.ifc_req = ifrs; | 175 | ifc.ifc_req = ifrs; |
176 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); | 176 | result = ioctl(sockfd, SIOCGIFCONF, &ifc); |
177 | 177 | ||
178 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) | 178 | for (unsigned int i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) |
179 | { | 179 | { |
180 | struct ifreq *pifr = &ifrs[i]; | 180 | struct ifreq *pifr = &ifrs[i]; |
181 | 181 | ||
182 | ifaces += pifr->ifr_name; | 182 | ifaces += pifr->ifr_name; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | else | 185 | else |
186 | { | 186 | { |
187 | procFile.open(IO_ReadOnly); | 187 | procFile.open(IO_ReadOnly); |
188 | QString line; | 188 | QString line; |
189 | QTextStream procTs(&procFile); | 189 | QTextStream procTs(&procFile); |
190 | int loc = -1; | 190 | int loc = -1; |
191 | 191 | ||
192 | procTs.readLine(); // eat a line | 192 | procTs.readLine(); // eat a line |
193 | procTs.readLine(); // eat a line | 193 | procTs.readLine(); // eat a line |
194 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) | 194 | while((line = procTs.readLine().simplifyWhiteSpace()) != QString::null) |
195 | { | 195 | { |
196 | if((loc = line.find(":")) != -1) | 196 | if((loc = line.find(":")) != -1) |
197 | { | 197 | { |
198 | ifaces += line.left(loc); | 198 | ifaces += line.left(loc); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) | 203 | for (QStringList::Iterator it = ifaces.begin(); it != ifaces.end(); ++it) |
204 | { | 204 | { |
205 | int flags = 0; | 205 | int flags = 0; |
206 | if ( m_handledIfaces.contains( (*it) ) ) | 206 | if ( m_handledIfaces.contains( (*it) ) ) |
207 | { | 207 | { |
208 | odebug << " " << (*it).latin1() << " is handled by a module" << oendl; | 208 | odebug << " " << (*it).latin1() << " is handled by a module" << oendl; |
209 | continue; | 209 | continue; |
210 | } | 210 | } |
211 | // int family; | 211 | // int family; |
212 | i = NULL; | 212 | i = NULL; |
213 | 213 | ||
214 | strcpy(ifr.ifr_name, (*it).latin1()); | 214 | strcpy(ifr.ifr_name, (*it).latin1()); |
215 | 215 | ||
216 | struct ifreq ifcopy; | 216 | struct ifreq ifcopy; |
217 | ifcopy = ifr; | 217 | ifcopy = ifr; |
218 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); | 218 | result = ioctl(sockfd, SIOCGIFFLAGS, &ifcopy); |
219 | flags = ifcopy.ifr_flags; | 219 | flags = ifcopy.ifr_flags; |
220 | i = new Interface(this, ifr.ifr_name, false); | 220 | i = new Interface(this, ifr.ifr_name, false); |
221 | i->setAttached(true); | 221 | i->setAttached(true); |
222 | if ((flags & IFF_UP) == IFF_UP) | 222 | if ((flags & IFF_UP) == IFF_UP) |
223 | i->setStatus(true); | 223 | i->setStatus(true); |
224 | else | 224 | else |
225 | i->setStatus(false); | 225 | i->setStatus(false); |
226 | 226 | ||
227 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | 227 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) |
228 | i->setHardwareName("Ethernet"); | 228 | i->setHardwareName("Ethernet"); |
229 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | 229 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) |
230 | i->setHardwareName("Point to Point"); | 230 | i->setHardwareName("Point to Point"); |
231 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | 231 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) |
232 | i->setHardwareName("Multicast"); | 232 | i->setHardwareName("Multicast"); |
233 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | 233 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) |
234 | i->setHardwareName("Loopback"); | 234 | i->setHardwareName("Loopback"); |
235 | else | 235 | else |
236 | i->setHardwareName("Unknown"); | 236 | i->setHardwareName("Unknown"); |
237 | 237 | ||
238 | owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl; | 238 | owarn << "Adding interface " << ifr.ifr_name << " to interfaceNames\n" << oendl; |
239 | interfaceNames.insert(i->getInterfaceName(), i); | 239 | interfaceNames.insert(i->getInterfaceName(), i); |
240 | updateInterface(i); | 240 | updateInterface(i); |
241 | connect(i, SIGNAL(updateInterface(Interface*)), | 241 | connect(i, SIGNAL(updateInterface(Interface*)), |
242 | this, SLOT(updateInterface(Interface*))); | 242 | this, SLOT(updateInterface(Interface*))); |
243 | } | 243 | } |
244 | // now lets ask the plugins too ;) | 244 | // now lets ask the plugins too ;) |
245 | QMap<Module*, QLibrary*>::Iterator it; | 245 | QMap<Module*, QLibrary*>::Iterator it; |
246 | QList<Interface> ilist; | 246 | QList<Interface> ilist; |
247 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 247 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
248 | { | 248 | { |
249 | if(it.key()) | 249 | if(it.key()) |
250 | { | 250 | { |
251 | ilist = it.key()->getInterfaces(); | 251 | ilist = it.key()->getInterfaces(); |
252 | for( i = ilist.first(); i != 0; i = ilist.next() ) | 252 | for( i = ilist.first(); i != 0; i = ilist.next() ) |
253 | { | 253 | { |
254 | owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl; | 254 | owarn << "Adding interface " << i->getInterfaceName().latin1() << " to interfaceNames\n" << oendl; |
255 | interfaceNames.insert(i->getInterfaceName(), i); | 255 | interfaceNames.insert(i->getInterfaceName(), i); |
256 | updateInterface(i); | 256 | updateInterface(i); |
257 | connect(i, SIGNAL(updateInterface(Interface*)), | 257 | connect(i, SIGNAL(updateInterface(Interface*)), |
258 | this, SLOT(updateInterface(Interface*))); | 258 | this, SLOT(updateInterface(Interface*))); |
259 | } | 259 | } |
260 | } | 260 | } |
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | /** | 264 | /** |
265 | * Load all modules that are found in the path | 265 | * Load all modules that are found in the path |
266 | * @param path a directory that is scaned for any plugins that can be loaded | 266 | * @param path a directory that is scaned for any plugins that can be loaded |
267 | * and attempts to load them | 267 | * and attempts to load them |
268 | */ | 268 | */ |
269 | void MainWindowImp::loadModules(const QString &path) | 269 | void MainWindowImp::loadModules(const QString &path) |
270 | { | 270 | { |
271 | #ifdef DEBUG | 271 | #ifdef DEBUG |
272 | odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; | 272 | odebug << "MainWindowImp::loadModules: " << path.latin1() << "" << oendl; |
273 | #endif | 273 | #endif |
274 | QDir d(path); | 274 | QDir d(path); |
275 | if(!d.exists()) | 275 | if(!d.exists()) |
276 | return; | 276 | return; |
277 | 277 | ||
278 | QString lang = ::getenv("LANG"); | 278 | QString lang = ::getenv("LANG"); |
279 | // Don't want sym links | 279 | // Don't want sym links |
280 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 280 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
281 | const QFileInfoList *list = d.entryInfoList(); | 281 | const QFileInfoList *list = d.entryInfoList(); |
282 | QFileInfoListIterator it( *list ); | 282 | QFileInfoListIterator it( *list ); |
283 | QFileInfo *fi; | 283 | QFileInfo *fi; |
284 | while ( (fi=it.current()) ) | 284 | while ( (fi=it.current()) ) |
285 | { | 285 | { |
286 | if(fi->fileName().contains(".so")) | 286 | if(fi->fileName().contains(".so")) |
287 | { | 287 | { |
288 | /* if loaded install translation */ | 288 | /* if loaded install translation */ |
289 | if( loadPlugin(path + "/" + fi->fileName()) != 0l ){ | 289 | if( loadPlugin(path + "/" + fi->fileName()) != 0l ){ |
290 | QTranslator *trans = new QTranslator(qApp); | 290 | QTranslator *trans = new QTranslator(qApp); |
291 | QString fn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm"; | 291 | QString fn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+ fi->fileName().left( fi->fileName().find(".") )+".qm"; |
292 | if( trans->load( fn ) ) | 292 | if( trans->load( fn ) ) |
293 | qApp->installTranslator( trans ); | 293 | qApp->installTranslator( trans ); |
294 | else | 294 | else |
295 | delete trans; | 295 | delete trans; |
296 | } | 296 | } |
297 | odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl; | 297 | odebug << "loaded plugin: >" << QString(path + "/" + fi->fileName()).latin1() << "< " << oendl; |
298 | } | 298 | } |
299 | ++it; | 299 | ++it; |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | /** | 303 | /** |
304 | * Attempt to load a function and resolve a function. | 304 | * Attempt to load a function and resolve a function. |
305 | * @param pluginFileName - the name of the file in which to attempt to load | 305 | * @param pluginFileName - the name of the file in which to attempt to load |
306 | * @param resolveString - function pointer to resolve | 306 | * @param resolveString - function pointer to resolve |
307 | * @return pointer to the function with name resolveString or NULL | 307 | * @return pointer to the function with name resolveString or NULL |
308 | */ | 308 | */ |
309 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) | 309 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString) |
310 | { | 310 | { |
311 | #ifdef DEBUG | 311 | #ifdef DEBUG |
312 | odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl; | 312 | odebug << "MainWindowImp::loadPlugin: " << pluginFileName.latin1() << ": resolving " << resolveString.latin1() << "" << oendl; |
313 | #endif | 313 | #endif |
314 | QLibrary *lib = new QLibrary(pluginFileName); | 314 | QLibrary *lib = new QLibrary(pluginFileName); |
315 | void *functionPointer = lib->resolve(resolveString); | 315 | void *functionPointer = lib->resolve(resolveString); |
316 | if( !functionPointer ) | 316 | if( !functionPointer ) |
317 | { | 317 | { |
318 | #ifdef DEBUG | 318 | #ifdef DEBUG |
319 | odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl; | 319 | odebug << "MainWindowImp::loadPlugin: Warning: " << pluginFileName.latin1() << " is not a plugin" << oendl; |
320 | #endif | 320 | #endif |
321 | delete lib; | 321 | delete lib; |
322 | return 0; | 322 | return 0; |
323 | } | 323 | } |
324 | // Try to get an object. | 324 | // Try to get an object. |
325 | Module *object = ((Module* (*)()) functionPointer)(); | 325 | Module *object = ((Module* (*)()) functionPointer)(); |
326 | if(object == 0) | 326 | if(object == 0) |
327 | { | 327 | { |
328 | #ifdef DEBUG | 328 | #ifdef DEBUG |
329 | odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; | 329 | odebug << "MainWindowImp: Couldn't create object, but did load library!" << oendl; |
330 | #endif | 330 | #endif |
331 | delete lib; | 331 | delete lib; |
332 | return 0; | 332 | return 0; |
333 | } | 333 | } |
334 | 334 | ||
335 | m_handledIfaces += object->handledInterfaceNames(); | 335 | m_handledIfaces += object->handledInterfaceNames(); |
336 | // Store for deletion later | 336 | // Store for deletion later |
337 | libraries.insert(object, lib); | 337 | libraries.insert(object, lib); |
338 | return object; | 338 | return object; |
339 | } | 339 | } |
340 | 340 | ||
341 | /** | 341 | /** |
342 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 342 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
343 | * load the plugin and append it to the list | 343 | * load the plugin and append it to the list |
344 | */ | 344 | */ |
345 | void MainWindowImp::addClicked() | 345 | void MainWindowImp::addClicked() |
346 | { | 346 | { |
347 | QMap<Module*, QLibrary*>::Iterator it; | 347 | QMap<Module*, QLibrary*>::Iterator it; |
348 | QMap<QString, QString> list; | 348 | QMap<QString, QString> list; |
349 | QMap<QString, Module*> newInterfaceOwners; | 349 | QMap<QString, Module*> newInterfaceOwners; |
350 | 350 | ||
351 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 351 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
352 | { | 352 | { |
353 | if(it.key()) | 353 | if(it.key()) |
354 | { | 354 | { |
355 | (it.key())->possibleNewInterfaces(list); | 355 | (it.key())->possibleNewInterfaces(list); |
356 | } | 356 | } |
357 | } | 357 | } |
358 | // See if the list has anything that we can add. | 358 | // See if the list has anything that we can add. |
359 | if(list.count() == 0) | 359 | if(list.count() == 0) |
360 | { | 360 | { |
361 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 361 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 364 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
365 | addNewConnection.addConnections(list); | 365 | addNewConnection.addConnections(list); |
366 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) | 366 | if( QDialog::Accepted == QPEApplication::execDialog( &addNewConnection ) ) |
367 | { | 367 | { |
368 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 368 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
369 | if(!item) | 369 | if(!item) |
370 | return; | 370 | return; |
371 | 371 | ||
372 | for( it = libraries.begin(); it != libraries.end(); ++it ) | 372 | for( it = libraries.begin(); it != libraries.end(); ++it ) |
373 | { | 373 | { |
374 | if(it.key()) | 374 | if(it.key()) |
375 | { | 375 | { |
376 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 376 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
377 | if(i) | 377 | if(i) |
378 | { | 378 | { |
379 | odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl; | 379 | odebug << "iface name " << i->getInterfaceName().latin1() << "" << oendl; |
380 | interfaceNames.insert(i->getInterfaceName(), i); | 380 | interfaceNames.insert(i->getInterfaceName(), i); |
381 | updateInterface(i); | 381 | updateInterface(i); |
382 | } | 382 | } |
383 | } | 383 | } |
384 | } | 384 | } |
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | /** | 388 | /** |
389 | * Prompt the user to see if they really want to do this. | 389 | * Prompt the user to see if they really want to do this. |
390 | * If they do then remove from the list and unload. | 390 | * If they do then remove from the list and unload. |
391 | */ | 391 | */ |
392 | void MainWindowImp::removeClicked() | 392 | void MainWindowImp::removeClicked() |
393 | { | 393 | { |
394 | QListViewItem *item = connectionList->currentItem(); | 394 | QListViewItem *item = connectionList->currentItem(); |
395 | if(!item) | 395 | if(!item) |
396 | { | 396 | { |
397 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 397 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
398 | return; | 398 | return; |
399 | } | 399 | } |
400 | 400 | ||
401 | Interface *i = interfaceItems[item]; | 401 | Interface *i = interfaceItems[item]; |
402 | if(i->getModuleOwner() == NULL) | 402 | if(i->getModuleOwner() == NULL) |
403 | { | 403 | { |
404 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 404 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
405 | } | 405 | } |
406 | else | 406 | else |
407 | { | 407 | { |
408 | if(!i->getModuleOwner()->remove(i)) | 408 | if(!i->getModuleOwner()->remove(i)) |
409 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); | 409 | QMessageBox::information(this, tr("Error"), tr("Unable to remove."), QMessageBox::Ok); |
410 | else | 410 | else |
411 | { | 411 | { |
412 | delete item; | 412 | delete item; |
413 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 413 | // QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
414 | } | 414 | } |
415 | } | 415 | } |
416 | } | 416 | } |
417 | 417 | ||
418 | /** | 418 | /** |
419 | * Pull up the configure about the currently selected interface. | 419 | * Pull up the configure about the currently selected interface. |
420 | * Report an error if no interface is selected. | 420 | * Report an error if no interface is selected. |
421 | * If the interface has a module owner then request its configure. | 421 | * If the interface has a module owner then request its configure. |
422 | */ | 422 | */ |
423 | void MainWindowImp::configureClicked() | 423 | void MainWindowImp::configureClicked() |
424 | { | 424 | { |
425 | QListViewItem *item = connectionList->currentItem(); | 425 | QListViewItem *item = connectionList->currentItem(); |
426 | if(!item) | 426 | if(!item) |
427 | { | 427 | { |
428 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); | 428 | QMessageBox::information(this, tr("Sorry"),tr("Please select an interface first."), QMessageBox::Ok); |
429 | return; | 429 | return; |
430 | } | 430 | } |
431 | 431 | ||
432 | QString currentProfileText = currentProfileLabel->text(); | 432 | QString currentProfileText = currentProfileLabel->text(); |
433 | if(currentProfileText.upper() == "ALL"); | 433 | if(currentProfileText.upper() == "ALL"); |
434 | currentProfileText = ""; | 434 | currentProfileText = ""; |
435 | 435 | ||
436 | Interface *i = interfaceItems[item]; | 436 | Interface *i = interfaceItems[item]; |
437 | 437 | ||
438 | if(i->getModuleOwner()) | 438 | if(i->getModuleOwner()) |
439 | { | 439 | { |
440 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 440 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
441 | if(moduleConfigure != NULL) | 441 | if(moduleConfigure != NULL) |
442 | { | 442 | { |
443 | i->getModuleOwner()->setProfile(currentProfileText); | 443 | i->getModuleOwner()->setProfile(currentProfileText); |
444 | QPEApplication::showWidget( moduleConfigure ); | 444 | QPEApplication::showWidget( moduleConfigure ); |
445 | return; | 445 | return; |
446 | } | 446 | } |
447 | } | 447 | } |
448 | 448 | ||
449 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); | 449 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(this, "InterfaceSetupImp", i, true, Qt::WDestructiveClose | Qt::WStyle_ContextHelp ); |
450 | configure->setProfile(currentProfileText); | 450 | configure->setProfile(currentProfileText); |
451 | QPEApplication::showDialog( configure ); | 451 | QPEApplication::showDialog( configure ); |
452 | } | 452 | } |
453 | 453 | ||
454 | /** | 454 | /** |
455 | * Pull up the information about the currently selected interface. | 455 | * Pull up the information about the currently selected interface. |
456 | * Report an error if no interface is selected. | 456 | * Report an error if no interface is selected. |
457 | * If the interface has a module owner then request its configure. | 457 | * If the interface has a module owner then request its configure. |
458 | */ | 458 | */ |
459 | void MainWindowImp::informationClicked() | 459 | void MainWindowImp::informationClicked() |
460 | { | 460 | { |
461 | QListViewItem *item = connectionList->currentItem(); | 461 | QListViewItem *item = connectionList->currentItem(); |
462 | if(!item) | 462 | if(!item) |
463 | { | 463 | { |
464 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 464 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
465 | return; | 465 | return; |
466 | } | 466 | } |
467 | 467 | ||
468 | Interface *i = interfaceItems[item]; | 468 | Interface *i = interfaceItems[item]; |
469 | // if(!i->isAttached()){ | 469 | // if(!i->isAttached()){ |
470 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 470 | // QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
471 | // return; | 471 | // return; |
472 | // } | 472 | // } |
473 | 473 | ||
474 | if(i->getModuleOwner()) | 474 | if(i->getModuleOwner()) |
475 | { | 475 | { |
476 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 476 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
477 | if(moduleInformation != NULL) | 477 | if(moduleInformation != NULL) |
478 | { | 478 | { |
479 | QPEApplication::showWidget( moduleInformation ); | 479 | QPEApplication::showWidget( moduleInformation ); |
480 | #ifdef DEBUG | 480 | #ifdef DEBUG |
481 | odebug << "MainWindowImp::informationClicked:: Module owner has created, we showed." << oendl; | 481 | odebug << "MainWindowImp::informationClicked:: Module owner has created, we showed." << oendl; |
482 | #endif | 482 | #endif |
483 | return; | 483 | return; |