author | kergoth <kergoth> | 2003-01-26 20:11:54 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-01-26 20:11:54 (UTC) |
commit | 06d7d61516ee27b60c39453ef61215708aa3468a (patch) (unidiff) | |
tree | 57ce20b532778956f1f2e4c2ebe7003d4866bdd0 | |
parent | 5c4af98c127d777ba9f7de0c2298fb931a9cc877 (diff) | |
download | opie-06d7d61516ee27b60c39453ef61215708aa3468a.zip opie-06d7d61516ee27b60c39453ef61215708aa3468a.tar.gz opie-06d7d61516ee27b60c39453ef61215708aa3468a.tar.bz2 |
networksetup -> networksettings, as reported by an OZ user.
-rw-r--r-- | noncore/settings/networksettings/mainwindowimp.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/ppp.pro | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/networksettings/mainwindowimp.cpp b/noncore/settings/networksettings/mainwindowimp.cpp index 9efc8c2..0ddc489 100644 --- a/noncore/settings/networksettings/mainwindowimp.cpp +++ b/noncore/settings/networksettings/mainwindowimp.cpp | |||
@@ -154,368 +154,368 @@ void MainWindowImp::getAllInterfaces(){ | |||
154 | result=ioctl(sockfd,SIOCGIFFLAGS,&ifcopy); | 154 | result=ioctl(sockfd,SIOCGIFFLAGS,&ifcopy); |
155 | flags=ifcopy.ifr_flags; | 155 | flags=ifcopy.ifr_flags; |
156 | i = new Interface(this, ifr->ifr_name, false); | 156 | i = new Interface(this, ifr->ifr_name, false); |
157 | i->setAttached(true); | 157 | i->setAttached(true); |
158 | if ((flags & IFF_UP) == IFF_UP) | 158 | if ((flags & IFF_UP) == IFF_UP) |
159 | i->setStatus(true); | 159 | i->setStatus(true); |
160 | else | 160 | else |
161 | i->setStatus(false); | 161 | i->setStatus(false); |
162 | 162 | ||
163 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) | 163 | if ((flags & IFF_BROADCAST) == IFF_BROADCAST) |
164 | i->setHardwareName("Ethernet"); | 164 | i->setHardwareName("Ethernet"); |
165 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) | 165 | else if ((flags & IFF_POINTOPOINT) == IFF_POINTOPOINT) |
166 | i->setHardwareName("Point to Point"); | 166 | i->setHardwareName("Point to Point"); |
167 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) | 167 | else if ((flags & IFF_MULTICAST) == IFF_MULTICAST) |
168 | i->setHardwareName("Multicast"); | 168 | i->setHardwareName("Multicast"); |
169 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) | 169 | else if ((flags & IFF_LOOPBACK) == IFF_LOOPBACK) |
170 | i->setHardwareName("Loopback"); | 170 | i->setHardwareName("Loopback"); |
171 | else | 171 | else |
172 | i->setHardwareName("Unknown"); | 172 | i->setHardwareName("Unknown"); |
173 | 173 | ||
174 | interfaceNames.insert(i->getInterfaceName(), i); | 174 | interfaceNames.insert(i->getInterfaceName(), i); |
175 | updateInterface(i); | 175 | updateInterface(i); |
176 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); | 176 | connect(i, SIGNAL(updateInterface(Interface *)), this, SLOT(updateInterface(Interface *))); |
177 | break; | 177 | break; |
178 | 178 | ||
179 | default: | 179 | default: |
180 | qDebug(ifr->ifr_name); | 180 | qDebug(ifr->ifr_name); |
181 | qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1()); | 181 | qDebug(QString("%1").arg(ifr->ifr_addr.sa_family).latin1()); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | /** | 187 | /** |
188 | * Load all modules that are found in the path | 188 | * Load all modules that are found in the path |
189 | * @param path a directory that is scaned for any plugins that can be loaded | 189 | * @param path a directory that is scaned for any plugins that can be loaded |
190 | * and attempts to load them | 190 | * and attempts to load them |
191 | */ | 191 | */ |
192 | void MainWindowImp::loadModules(const QString &path){ | 192 | void MainWindowImp::loadModules(const QString &path){ |
193 | //qDebug(path.latin1()); | 193 | //qDebug(path.latin1()); |
194 | QDir d(path); | 194 | QDir d(path); |
195 | if(!d.exists()) | 195 | if(!d.exists()) |
196 | return; | 196 | return; |
197 | 197 | ||
198 | // Don't want sym links | 198 | // Don't want sym links |
199 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 199 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
200 | const QFileInfoList *list = d.entryInfoList(); | 200 | const QFileInfoList *list = d.entryInfoList(); |
201 | QFileInfoListIterator it( *list ); | 201 | QFileInfoListIterator it( *list ); |
202 | QFileInfo *fi; | 202 | QFileInfo *fi; |
203 | while ( (fi=it.current()) ) { | 203 | while ( (fi=it.current()) ) { |
204 | if(fi->fileName().contains(".so")){ | 204 | if(fi->fileName().contains(".so")){ |
205 | loadPlugin(path + "/" + fi->fileName()); | 205 | loadPlugin(path + "/" + fi->fileName()); |
206 | } | 206 | } |
207 | ++it; | 207 | ++it; |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | /** | 211 | /** |
212 | * Attempt to load a function and resolve a function. | 212 | * Attempt to load a function and resolve a function. |
213 | * @param pluginFileName - the name of the file in which to attempt to load | 213 | * @param pluginFileName - the name of the file in which to attempt to load |
214 | * @param resolveString - function pointer to resolve | 214 | * @param resolveString - function pointer to resolve |
215 | * @return pointer to the function with name resolveString or NULL | 215 | * @return pointer to the function with name resolveString or NULL |
216 | */ | 216 | */ |
217 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ | 217 | Module* MainWindowImp::loadPlugin(const QString &pluginFileName, const QString &resolveString){ |
218 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); | 218 | //qDebug(QString("MainWindowImp::loadPlugin: %1").arg(pluginFileName).latin1()); |
219 | QLibrary *lib = new QLibrary(pluginFileName); | 219 | QLibrary *lib = new QLibrary(pluginFileName); |
220 | void *functionPointer = lib->resolve(resolveString); | 220 | void *functionPointer = lib->resolve(resolveString); |
221 | if( !functionPointer ){ | 221 | if( !functionPointer ){ |
222 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); | 222 | qDebug(QString("MainWindowImp: File: %1 is not a plugin, but though was.").arg(pluginFileName).latin1()); |
223 | delete lib; | 223 | delete lib; |
224 | return NULL; | 224 | return NULL; |
225 | } | 225 | } |
226 | 226 | ||
227 | // Try to get an object. | 227 | // Try to get an object. |
228 | Module *object = ((Module* (*)()) functionPointer)(); | 228 | Module *object = ((Module* (*)()) functionPointer)(); |
229 | if(object == NULL){ | 229 | if(object == NULL){ |
230 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); | 230 | qDebug("MainWindowImp: Couldn't create object, but did load library!"); |
231 | delete lib; | 231 | delete lib; |
232 | return NULL; | 232 | return NULL; |
233 | } | 233 | } |
234 | 234 | ||
235 | // Store for deletion later | 235 | // Store for deletion later |
236 | libraries.insert(object, lib); | 236 | libraries.insert(object, lib); |
237 | return object; | 237 | return object; |
238 | } | 238 | } |
239 | 239 | ||
240 | /** | 240 | /** |
241 | * The Add button was clicked. Bring up the add dialog and if OK is hit | 241 | * The Add button was clicked. Bring up the add dialog and if OK is hit |
242 | * load the plugin and append it to the list | 242 | * load the plugin and append it to the list |
243 | */ | 243 | */ |
244 | void MainWindowImp::addClicked(){ | 244 | void MainWindowImp::addClicked(){ |
245 | QMap<Module*, QLibrary*>::Iterator it; | 245 | QMap<Module*, QLibrary*>::Iterator it; |
246 | QMap<QString, QString> list; | 246 | QMap<QString, QString> list; |
247 | QMap<QString, Module*> newInterfaceOwners; | 247 | QMap<QString, Module*> newInterfaceOwners; |
248 | //list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); | 248 | //list.insert("USB (PPP) / (ADD_TEST)", "A dialup connection over the USB port"); |
249 | //list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); | 249 | //list.insert("IrDa (PPP) / (ADD_TEST)", "A dialup connection over the IdDa port"); |
250 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 250 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
251 | if(it.key()){ | 251 | if(it.key()){ |
252 | (it.key())->possibleNewInterfaces(list); | 252 | (it.key())->possibleNewInterfaces(list); |
253 | } | 253 | } |
254 | } | 254 | } |
255 | // See if the list has anything that we can add. | 255 | // See if the list has anything that we can add. |
256 | if(list.count() == 0){ | 256 | if(list.count() == 0){ |
257 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); | 257 | QMessageBox::information(this, "Sorry", "Nothing to add.", QMessageBox::Ok); |
258 | return; | 258 | return; |
259 | } | 259 | } |
260 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); | 260 | AddConnectionImp addNewConnection(this, "AddConnectionImp", true); |
261 | addNewConnection.addConnections(list); | 261 | addNewConnection.addConnections(list); |
262 | addNewConnection.showMaximized(); | 262 | addNewConnection.showMaximized(); |
263 | if(QDialog::Accepted == addNewConnection.exec()){ | 263 | if(QDialog::Accepted == addNewConnection.exec()){ |
264 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); | 264 | QListViewItem *item = addNewConnection.registeredServicesList->currentItem(); |
265 | if(!item) | 265 | if(!item) |
266 | return; | 266 | return; |
267 | 267 | ||
268 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 268 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
269 | if(it.key()){ | 269 | if(it.key()){ |
270 | Interface *i = (it.key())->addNewInterface(item->text(0)); | 270 | Interface *i = (it.key())->addNewInterface(item->text(0)); |
271 | if(i){ | 271 | if(i){ |
272 | interfaceNames.insert(i->getInterfaceName(), i); | 272 | interfaceNames.insert(i->getInterfaceName(), i); |
273 | updateInterface(i); | 273 | updateInterface(i); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | } | 276 | } |
277 | } | 277 | } |
278 | } | 278 | } |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * Prompt the user to see if they really want to do this. | 281 | * Prompt the user to see if they really want to do this. |
282 | * If they do then remove from the list and unload. | 282 | * If they do then remove from the list and unload. |
283 | */ | 283 | */ |
284 | void MainWindowImp::removeClicked(){ | 284 | void MainWindowImp::removeClicked(){ |
285 | QListViewItem *item = connectionList->currentItem(); | 285 | QListViewItem *item = connectionList->currentItem(); |
286 | if(!item) { | 286 | if(!item) { |
287 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 287 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
288 | return; | 288 | return; |
289 | } | 289 | } |
290 | 290 | ||
291 | Interface *i = interfaceItems[item]; | 291 | Interface *i = interfaceItems[item]; |
292 | if(i->getModuleOwner() == NULL){ | 292 | if(i->getModuleOwner() == NULL){ |
293 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); | 293 | QMessageBox::information(this, "Can't remove interface.", "Interface is built in.", QMessageBox::Ok); |
294 | } | 294 | } |
295 | else{ | 295 | else{ |
296 | if(!i->getModuleOwner()->remove(i)) | 296 | if(!i->getModuleOwner()->remove(i)) |
297 | QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); | 297 | QMessageBox::information(this, "Error", "Unable to remove.", QMessageBox::Ok); |
298 | else{ | 298 | else{ |
299 | QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); | 299 | QMessageBox::information(this, "Success", "Interface was removed.", QMessageBox::Ok); |
300 | // TODO memory managment.... | 300 | // TODO memory managment.... |
301 | // who deletes the interface? | 301 | // who deletes the interface? |
302 | } | 302 | } |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | /** | 306 | /** |
307 | * Pull up the configure about the currently selected interface. | 307 | * Pull up the configure about the currently selected interface. |
308 | * Report an error if no interface is selected. | 308 | * Report an error if no interface is selected. |
309 | * If the interface has a module owner then request its configure. | 309 | * If the interface has a module owner then request its configure. |
310 | */ | 310 | */ |
311 | void MainWindowImp::configureClicked(){ | 311 | void MainWindowImp::configureClicked(){ |
312 | QListViewItem *item = connectionList->currentItem(); | 312 | QListViewItem *item = connectionList->currentItem(); |
313 | if(!item){ | 313 | if(!item){ |
314 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); | 314 | QMessageBox::information(this, "Sorry","Please select an interface first.", QMessageBox::Ok); |
315 | return; | 315 | return; |
316 | } | 316 | } |
317 | 317 | ||
318 | Interface *i = interfaceItems[item]; | 318 | Interface *i = interfaceItems[item]; |
319 | if(i->getModuleOwner()){ | 319 | if(i->getModuleOwner()){ |
320 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); | 320 | QWidget *moduleConfigure = i->getModuleOwner()->configure(i); |
321 | if(moduleConfigure != NULL){ | 321 | if(moduleConfigure != NULL){ |
322 | moduleConfigure->showMaximized(); | 322 | moduleConfigure->showMaximized(); |
323 | return; | 323 | return; |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose); | 327 | InterfaceSetupImpDialog *configure = new InterfaceSetupImpDialog(0, "InterfaceSetupImp", i, true, Qt::WDestructiveClose); |
328 | QString currentProfileText = currentProfileLabel->text(); | 328 | QString currentProfileText = currentProfileLabel->text(); |
329 | if(currentProfileText.upper() == "ALL"); | 329 | if(currentProfileText.upper() == "ALL"); |
330 | currentProfileText = ""; | 330 | currentProfileText = ""; |
331 | configure->setProfile(currentProfileText); | 331 | configure->setProfile(currentProfileText); |
332 | configure->showMaximized(); | 332 | configure->showMaximized(); |
333 | } | 333 | } |
334 | 334 | ||
335 | /** | 335 | /** |
336 | * Pull up the information about the currently selected interface. | 336 | * Pull up the information about the currently selected interface. |
337 | * Report an error if no interface is selected. | 337 | * Report an error if no interface is selected. |
338 | * If the interface has a module owner then request its configure. | 338 | * If the interface has a module owner then request its configure. |
339 | */ | 339 | */ |
340 | void MainWindowImp::informationClicked(){ | 340 | void MainWindowImp::informationClicked(){ |
341 | QListViewItem *item = connectionList->currentItem(); | 341 | QListViewItem *item = connectionList->currentItem(); |
342 | if(!item){ | 342 | if(!item){ |
343 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); | 343 | QMessageBox::information(this, "Sorry","Please select an interface First.", QMessageBox::Ok); |
344 | return; | 344 | return; |
345 | } | 345 | } |
346 | 346 | ||
347 | Interface *i = interfaceItems[item]; | 347 | Interface *i = interfaceItems[item]; |
348 | if(!i->isAttached()){ | 348 | if(!i->isAttached()){ |
349 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); | 349 | QMessageBox::information(this, "Sorry","No information about\na disconnected interface.", QMessageBox::Ok); |
350 | return; | 350 | return; |
351 | } | 351 | } |
352 | 352 | ||
353 | if(i->getModuleOwner()){ | 353 | if(i->getModuleOwner()){ |
354 | QWidget *moduleInformation = i->getModuleOwner()->information(i); | 354 | QWidget *moduleInformation = i->getModuleOwner()->information(i); |
355 | if(moduleInformation != NULL){ | 355 | if(moduleInformation != NULL){ |
356 | moduleInformation->showMaximized(); | 356 | moduleInformation->showMaximized(); |
357 | return; | 357 | return; |
358 | } | 358 | } |
359 | } | 359 | } |
360 | InterfaceInformationImp information(0, "InterfaceSetupImp", i); | 360 | InterfaceInformationImp information(0, "InterfaceSetupImp", i); |
361 | information.showMaximized(); | 361 | information.showMaximized(); |
362 | } | 362 | } |
363 | 363 | ||
364 | /** | 364 | /** |
365 | * Update this interface. If no QListViewItem exists create one. | 365 | * Update this interface. If no QListViewItem exists create one. |
366 | * @param Interface* pointer to the interface that needs to be updated. | 366 | * @param Interface* pointer to the interface that needs to be updated. |
367 | */ | 367 | */ |
368 | void MainWindowImp::updateInterface(Interface *i){ | 368 | void MainWindowImp::updateInterface(Interface *i){ |
369 | if(!advancedUserMode){ | 369 | if(!advancedUserMode){ |
370 | if(i->getInterfaceName() == "lo") | 370 | if(i->getInterfaceName() == "lo") |
371 | return; | 371 | return; |
372 | } | 372 | } |
373 | 373 | ||
374 | QListViewItem *item = NULL; | 374 | QListViewItem *item = NULL; |
375 | 375 | ||
376 | // Find the interface, making it if needed. | 376 | // Find the interface, making it if needed. |
377 | if(items.find(i) == items.end()){ | 377 | if(items.find(i) == items.end()){ |
378 | item = new QListViewItem(connectionList, "", "", ""); | 378 | item = new QListViewItem(connectionList, "", "", ""); |
379 | // See if you can't find a module owner for this interface | 379 | // See if you can't find a module owner for this interface |
380 | QMap<Module*, QLibrary*>::Iterator it; | 380 | QMap<Module*, QLibrary*>::Iterator it; |
381 | for( it = libraries.begin(); it != libraries.end(); ++it ){ | 381 | for( it = libraries.begin(); it != libraries.end(); ++it ){ |
382 | if(it.key()->isOwner(i)) | 382 | if(it.key()->isOwner(i)) |
383 | i->setModuleOwner(it.key()); | 383 | i->setModuleOwner(it.key()); |
384 | } | 384 | } |
385 | items.insert(i, item); | 385 | items.insert(i, item); |
386 | interfaceItems.insert(item, i); | 386 | interfaceItems.insert(item, i); |
387 | } | 387 | } |
388 | else | 388 | else |
389 | item = items[i]; | 389 | item = items[i]; |
390 | 390 | ||
391 | // Update the icons and information | 391 | // Update the icons and information |
392 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); | 392 | item->setPixmap(0, (Resource::loadPixmap(i->getStatus() ? "up": "down"))); |
393 | 393 | ||
394 | QString typeName = "lan"; | 394 | QString typeName = "lan"; |
395 | if(i->getHardwareName().contains("Local Loopback")) | 395 | if(i->getHardwareName().contains("Local Loopback")) |
396 | typeName = "lo"; | 396 | typeName = "lo"; |
397 | if(i->getInterfaceName().contains("irda")) | 397 | if(i->getInterfaceName().contains("irda")) |
398 | typeName = "irda"; | 398 | typeName = "irda"; |
399 | if(i->getInterfaceName().contains("wlan")) | 399 | if(i->getInterfaceName().contains("wlan")) |
400 | typeName = "wlan"; | 400 | typeName = "wlan"; |
401 | if(i->getInterfaceName().contains("usb")) | 401 | if(i->getInterfaceName().contains("usb")) |
402 | typeName = "usb"; | 402 | typeName = "usb"; |
403 | 403 | ||
404 | if(!i->isAttached()) | 404 | if(!i->isAttached()) |
405 | typeName = "connect_no"; | 405 | typeName = "connect_no"; |
406 | // Actually try to use the Module | 406 | // Actually try to use the Module |
407 | if(i->getModuleOwner() != NULL) | 407 | if(i->getModuleOwner() != NULL) |
408 | typeName = i->getModuleOwner()->getPixmapName(i); | 408 | typeName = i->getModuleOwner()->getPixmapName(i); |
409 | 409 | ||
410 | item->setPixmap(1, (Resource::loadPixmap(QString("networksetup/") + typeName))); | 410 | item->setPixmap(1, (Resource::loadPixmap(QString("networksettings/") + typeName))); |
411 | item->setText(2, i->getHardwareName()); | 411 | item->setText(2, i->getHardwareName()); |
412 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); | 412 | item->setText(3, QString("(%1)").arg(i->getInterfaceName())); |
413 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); | 413 | item->setText(4, (i->getStatus()) ? i->getIp() : QString("")); |
414 | } | 414 | } |
415 | 415 | ||
416 | void MainWindowImp::newProfileChanged(const QString& newText){ | 416 | void MainWindowImp::newProfileChanged(const QString& newText){ |
417 | if(newText.length() > 0) | 417 | if(newText.length() > 0) |
418 | newProfileButton->setEnabled(true); | 418 | newProfileButton->setEnabled(true); |
419 | else | 419 | else |
420 | newProfileButton->setEnabled(false); | 420 | newProfileButton->setEnabled(false); |
421 | } | 421 | } |
422 | 422 | ||
423 | /** | 423 | /** |
424 | * Adds a new profile to the list of profiles. | 424 | * Adds a new profile to the list of profiles. |
425 | * Don't add profiles that already exists. | 425 | * Don't add profiles that already exists. |
426 | * Appends to the list and QStringList | 426 | * Appends to the list and QStringList |
427 | */ | 427 | */ |
428 | void MainWindowImp::addProfile(){ | 428 | void MainWindowImp::addProfile(){ |
429 | QString newProfileName = newProfile->text(); | 429 | QString newProfileName = newProfile->text(); |
430 | if(profiles.grep(newProfileName).count() > 0){ | 430 | if(profiles.grep(newProfileName).count() > 0){ |
431 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); | 431 | QMessageBox::information(this, "Can't Add","Profile already exists.", QMessageBox::Ok); |
432 | return; | 432 | return; |
433 | } | 433 | } |
434 | profiles.append(newProfileName); | 434 | profiles.append(newProfileName); |
435 | profilesList->insertItem(newProfileName); | 435 | profilesList->insertItem(newProfileName); |
436 | } | 436 | } |
437 | 437 | ||
438 | /** | 438 | /** |
439 | * Removes the currently selected profile in the combo. | 439 | * Removes the currently selected profile in the combo. |
440 | * Doesn't delete if there are less then 2 profiles. | 440 | * Doesn't delete if there are less then 2 profiles. |
441 | */ | 441 | */ |
442 | void MainWindowImp::removeProfile(){ | 442 | void MainWindowImp::removeProfile(){ |
443 | if(profilesList->count() <= 1){ | 443 | if(profilesList->count() <= 1){ |
444 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); | 444 | QMessageBox::information(this, "Can't remove.","At least one profile\nis needed.", QMessageBox::Ok); |
445 | return; | 445 | return; |
446 | } | 446 | } |
447 | QString profileToRemove = profilesList->currentText(); | 447 | QString profileToRemove = profilesList->currentText(); |
448 | if(profileToRemove == "All"){ | 448 | if(profileToRemove == "All"){ |
449 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); | 449 | QMessageBox::information(this, "Can't remove.","Can't remove default.", QMessageBox::Ok); |
450 | return; | 450 | return; |
451 | } | 451 | } |
452 | // Can't remove the curent profile | 452 | // Can't remove the curent profile |
453 | if(profileToRemove == currentProfileLabel->text()){ | 453 | if(profileToRemove == currentProfileLabel->text()){ |
454 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); | 454 | QMessageBox::information(this, "Can't remove.",QString("%1 is the current profile.").arg(profileToRemove), QMessageBox::Ok); |
455 | return; | 455 | return; |
456 | 456 | ||
457 | } | 457 | } |
458 | 458 | ||
459 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ | 459 | if(QMessageBox::information(this, "Question",QString("Remove profile: %1").arg(profileToRemove), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok){ |
460 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); | 460 | profiles = QStringList::split(" ", profiles.join(" ").replace(QRegExp(profileToRemove), "")); |
461 | profilesList->clear(); | 461 | profilesList->clear(); |
462 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) | 462 | for ( QStringList::Iterator it = profiles.begin(); it != profiles.end(); ++it) |
463 | profilesList->insertItem((*it)); | 463 | profilesList->insertItem((*it)); |
464 | 464 | ||
465 | // Remove any interface settings and mappings. | 465 | // Remove any interface settings and mappings. |
466 | Interfaces interfaces; | 466 | Interfaces interfaces; |
467 | // Go through them one by one | 467 | // Go through them one by one |
468 | QMap<Interface*, QListViewItem*>::Iterator it; | 468 | QMap<Interface*, QListViewItem*>::Iterator it; |
469 | for( it = items.begin(); it != items.end(); ++it ){ | 469 | for( it = items.begin(); it != items.end(); ++it ){ |
470 | QString interfaceName = it.key()->getInterfaceName(); | 470 | QString interfaceName = it.key()->getInterfaceName(); |
471 | qDebug(interfaceName.latin1()); | 471 | qDebug(interfaceName.latin1()); |
472 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ | 472 | if(interfaces.setInterface(interfaceName + "_" + profileToRemove)){ |
473 | interfaces.removeInterface(); | 473 | interfaces.removeInterface(); |
474 | if(interfaces.setMapping(interfaceName)){ | 474 | if(interfaces.setMapping(interfaceName)){ |
475 | if(profilesList->count() == 1) | 475 | if(profilesList->count() == 1) |
476 | interfaces.removeMapping(); | 476 | interfaces.removeMapping(); |
477 | else{ | 477 | else{ |
478 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); | 478 | interfaces.removeMap("map", interfaceName + "_" + profileToRemove); |
479 | } | 479 | } |
480 | } | 480 | } |
481 | interfaces.write(); | 481 | interfaces.write(); |
482 | break; | 482 | break; |
483 | } | 483 | } |
484 | } | 484 | } |
485 | } | 485 | } |
486 | } | 486 | } |
487 | 487 | ||
488 | /** | 488 | /** |
489 | * A new profile has been selected, change. | 489 | * A new profile has been selected, change. |
490 | * @param newProfile the new profile. | 490 | * @param newProfile the new profile. |
491 | */ | 491 | */ |
492 | void MainWindowImp::changeProfile(){ | 492 | void MainWindowImp::changeProfile(){ |
493 | if(profilesList->currentItem() == -1){ | 493 | if(profilesList->currentItem() == -1){ |
494 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); | 494 | QMessageBox::information(this, "Can't Change.","Please select a profile.", QMessageBox::Ok); |
495 | return; | 495 | return; |
496 | } | 496 | } |
497 | QString newProfile = profilesList->text(profilesList->currentItem()); | 497 | QString newProfile = profilesList->text(profilesList->currentItem()); |
498 | if(newProfile != currentProfileLabel->text()){ | 498 | if(newProfile != currentProfileLabel->text()){ |
499 | currentProfileLabel->setText(newProfile); | 499 | currentProfileLabel->setText(newProfile); |
500 | QFile::remove(scheme); | 500 | QFile::remove(scheme); |
501 | QFile file(scheme); | 501 | QFile file(scheme); |
502 | if ( file.open(IO_ReadWrite) ) { | 502 | if ( file.open(IO_ReadWrite) ) { |
503 | QTextStream stream( &file ); | 503 | QTextStream stream( &file ); |
504 | stream << QString("SCHEME=%1").arg(newProfile); | 504 | stream << QString("SCHEME=%1").arg(newProfile); |
505 | file.close(); | 505 | file.close(); |
506 | } | 506 | } |
507 | // restart all up devices? | 507 | // restart all up devices? |
508 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ | 508 | if(QMessageBox::information(this, "Question","Restart all running interfaces?", QMessageBox::Ok, QMessageBox::No) == QMessageBox::Ok){ |
509 | // Go through them one by one | 509 | // Go through them one by one |
510 | QMap<Interface*, QListViewItem*>::Iterator it; | 510 | QMap<Interface*, QListViewItem*>::Iterator it; |
511 | for( it = items.begin(); it != items.end(); ++it ){ | 511 | for( it = items.begin(); it != items.end(); ++it ){ |
512 | if(it.key()->getStatus() == true) | 512 | if(it.key()->getStatus() == true) |
513 | it.key()->restart(); | 513 | it.key()->restart(); |
514 | } | 514 | } |
515 | } | 515 | } |
516 | } | 516 | } |
517 | // TODO change the profile in the modules | 517 | // TODO change the profile in the modules |
518 | } | 518 | } |
519 | 519 | ||
520 | // mainwindowimp.cpp | 520 | // mainwindowimp.cpp |
521 | 521 | ||
diff --git a/noncore/settings/networksettings/ppp/ppp.pro b/noncore/settings/networksettings/ppp/ppp.pro index ec18a59..0e9e5b8 100644 --- a/noncore/settings/networksettings/ppp/ppp.pro +++ b/noncore/settings/networksettings/ppp/ppp.pro | |||
@@ -1,16 +1,16 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | #CONFIG += qt warn_on debug | 3 | #CONFIG += qt warn_on debug |
4 | DESTDIR = $(OPIEDIR)/plugins/networksetup | 4 | DESTDIR = $(OPIEDIR)/plugins/networksettings |
5 | HEADERS = pppimp.h pppmodule.h | 5 | HEADERS = pppimp.h pppmodule.h |
6 | SOURCES = pppimp.cpp pppmodule.cpp | 6 | SOURCES = pppimp.cpp pppmodule.cpp |
7 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ | 7 | INCLUDEPATH+= $(OPIEDIR)/include ../ ../interfaces/ |
8 | DEPENDPATH+= $(OPIEDIR)/include | 8 | DEPENDPATH+= $(OPIEDIR)/include |
9 | LIBS += -lqpe -L../interfaces/ -linterfaces | 9 | LIBS += -lqpe -L../interfaces/ -linterfaces |
10 | INTERFACES= ppp.ui | 10 | INTERFACES= ppp.ui |
11 | TARGET = pppplugin | 11 | TARGET = pppplugin |
12 | VERSION = 1.0.0 | 12 | VERSION = 1.0.0 |
13 | 13 | ||
14 | 14 | ||
15 | 15 | ||
16 | include ( $(OPIEDIR)/include.pro ) | 16 | include ( $(OPIEDIR)/include.pro ) |