summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/accounts.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings/ppp/accounts.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp206
1 files changed, 116 insertions, 90 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index 28d8732..b8a1925a 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -26,4 +26,12 @@
+#include "accounts.h"
+#include "authwidget.h"
+#include "pppdata.h"
+#include "edit.h"
+
+/* OPIE */
+#include <qpe/qpeapplication.h>
+
+/* QT */
#include <qdir.h>
-#include <stdlib.h>
#include <qlayout.h>
@@ -33,3 +41,2 @@
#include <qmessagebox.h>
-
#include <qapplication.h>
@@ -39,6 +46,4 @@
-#include "accounts.h"
-#include "authwidget.h"
-#include "pppdata.h"
-#include "edit.h"
+/* STD */
+#include <stdlib.h>
@@ -48,16 +53,16 @@ void parseargs(char* buf, char** args);
AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f )
- : ChooserWidget( pd, parent, name, f )
+ : ChooserWidget( pd, parent, name, f )
{
- QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
- QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
- "to the Internet"));
- QWhatsThis::add(copy_b,
- tr("Makes a copy of the selected account. All\n"
- "settings of the selected account are copied\n"
- "to a new account, that you can modify to fit your\n"
- "needs"));
- QWhatsThis::add(delete_b,
- tr("<p>Deletes the selected account\n\n"
- "<font color=\"red\"><b>Use with care!</b></font>"));
+ QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
+ QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
+ "to the Internet"));
+ QWhatsThis::add(copy_b,
+ tr("Makes a copy of the selected account. All\n"
+ "settings of the selected account are copied\n"
+ "to a new account, that you can modify to fit your\n"
+ "needs"));
+ QWhatsThis::add(delete_b,
+ tr("<p>Deletes the selected account\n\n"
+ "<font color=\"red\"><b>Use with care!</b></font>"));
@@ -65,11 +70,12 @@ AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WF
- copy_b->setEnabled( false ); //FIXME
- // delete_b->setEnabled( false ); //FIXME
+ copy_b->setEnabled( false ); //FIXME
+ // delete_b->setEnabled( false ); //FIXME
- listListbox->insertStringList(_pppdata->getAccountList());
+ listListbox->insertStringList(_pppdata->getAccountList());
- for (uint i = 0; i < listListbox->count(); i++){
- if ( listListbox->text(i) == _pppdata->accname() )
- listListbox->setCurrentItem( i );
- }
+ for (uint i = 0; i < listListbox->count(); i++)
+ {
+ if ( listListbox->text(i) == _pppdata->accname() )
+ listListbox->setCurrentItem( i );
+ }
}
@@ -78,3 +84,4 @@ AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WF
-void AccountWidget::slotListBoxSelect(int idx) {
+void AccountWidget::slotListBoxSelect(int idx)
+{
bool ok = _pppdata->setAccount( listListbox->text(idx) );
@@ -83,15 +90,17 @@ void AccountWidget::slotListBoxSelect(int idx) {
edit_b->setEnabled(ok);
-//FIXME copy_b->setEnabled(ok);
+ //FIXME copy_b->setEnabled(ok);
}
-void AccountWidget::edit() {
- _pppdata->setAccount(listListbox->text(listListbox->currentItem()));
+void AccountWidget::edit()
+{
+ _pppdata->setAccount(listListbox->text(listListbox->currentItem()));
- int result = doTab();
+ int result = doTab();
- if(result == QDialog::Accepted) {
- listListbox->changeItem(_pppdata->accname(),listListbox->currentItem());
-// emit resetaccounts();
- _pppdata->save();
- }
+ if(result == QDialog::Accepted)
+ {
+ listListbox->changeItem(_pppdata->accname(),listListbox->currentItem());
+ // emit resetaccounts();
+ _pppdata->save();
+ }
}
@@ -99,12 +108,14 @@ void AccountWidget::edit() {
-void AccountWidget::create() {
+void AccountWidget::create()
+{
-// if(listListbox->count() == MAX_ACCOUNTS) {
-// QMessageBox::information(this, "sorry",
-// tr("Maximum number of accounts reached."));
-// return;
-// }
+ // if(listListbox->count() == MAX_ACCOUNTS) {
+ // QMessageBox::information(this, "sorry",
+ // tr("Maximum number of accounts reached."));
+ // return;
+ // }
int result;
- if (_pppdata->newaccount() == -1){
+ if (_pppdata->newaccount() == -1)
+ {
qDebug("_pppdata->newaccount() == -1");
@@ -114,3 +125,4 @@ void AccountWidget::create() {
- if(result == QDialog::Accepted) {
+ if(result == QDialog::Accepted)
+ {
listListbox->insertItem(_pppdata->accname());
@@ -119,3 +131,4 @@ void AccountWidget::create() {
_pppdata->save();
- } else
+ }
+ else
_pppdata->deleteAccount();
@@ -124,18 +137,20 @@ void AccountWidget::create() {
-void AccountWidget::copy() {
-// if(listListbox->count() == MAX_ACCOUNTS) {
-// QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
-// return;
-// }
-
- if(listListbox->currentItem()<0) {
- QMessageBox::information(this, "sorry", tr("No account selected."));
- return;
- }
+void AccountWidget::copy()
+{
+ // if(listListbox->count() == MAX_ACCOUNTS) {
+ // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
+ // return;
+ // }
+
+ if(listListbox->currentItem()<0)
+ {
+ QMessageBox::information(this, "sorry", tr("No account selected."));
+ return;
+ }
- _pppdata->copyaccount(listListbox->currentText());
+ _pppdata->copyaccount(listListbox->currentText());
- listListbox->insertItem(_pppdata->accname());
-// emit resetaccounts();
- _pppdata->save();
+ listListbox->insertItem(_pppdata->accname());
+ // emit resetaccounts();
+ _pppdata->save();
}
@@ -143,21 +158,22 @@ void AccountWidget::copy() {
-void AccountWidget::remove() {
+void AccountWidget::remove()
+{
- QString s = tr("Are you sure you want to delete\nthe account \"%1\"?")
- .arg(listListbox->text(listListbox->currentItem()));
+ QString s = tr("Are you sure you want to delete\nthe account \"%1\"?")
+ .arg(listListbox->text(listListbox->currentItem()));
- if(QMessageBox::warning(this,tr("Confirm"),s,
- QMessageBox::Yes,QMessageBox::No
- ) != QMessageBox::Yes)
- return;
+ if(QMessageBox::warning(this,tr("Confirm"),s,
+ QMessageBox::Yes,QMessageBox::No
+ ) != QMessageBox::Yes)
+ return;
- if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem())))
- listListbox->removeItem(listListbox->currentItem());
+ if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem())))
+ listListbox->removeItem(listListbox->currentItem());
-// emit resetaccounts();
-// _pppdata->save();
+ // emit resetaccounts();
+ // _pppdata->save();
- slotListBoxSelect(listListbox->currentItem());
+ slotListBoxSelect(listListbox->currentItem());
@@ -166,3 +182,4 @@ void AccountWidget::remove() {
-int AccountWidget::doTab(){
+int AccountWidget::doTab()
+{
QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp );
@@ -177,6 +194,9 @@ int AccountWidget::doTab(){
- if(_pppdata->accname().isEmpty()) {
+ if(_pppdata->accname().isEmpty())
+ {
dlg->setCaption(tr("New Account"));
isnewaccount = true;
- } else {
+ }
+ else
+ {
QString tit = tr("Edit Account: ");
@@ -187,3 +207,3 @@ int AccountWidget::doTab(){
-// // DIAL WIDGET
+ // // DIAL WIDGET
dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
@@ -191,7 +211,7 @@ int AccountWidget::doTab(){
-// // AUTH WIDGET
- auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
- tabWindow->addTab( auth_w, tr("Authentication") );
+ // // AUTH WIDGET
+ auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
+ tabWindow->addTab( auth_w, tr("Authentication") );
-// // IP WIDGET
+ // // IP WIDGET
ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup"));
@@ -199,3 +219,3 @@ int AccountWidget::doTab(){
-// // GATEWAY WIDGET
+ // // GATEWAY WIDGET
gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup"));
@@ -203,3 +223,3 @@ int AccountWidget::doTab(){
-// // DNS WIDGET
+ // // DNS WIDGET
dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") );
@@ -207,5 +227,5 @@ int AccountWidget::doTab(){
-// // EXECUTE WIDGET
- ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs"));
- tabWindow->addTab( exec_w, tr("Execute") );
+ // // EXECUTE WIDGET
+ ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs"));
+ tabWindow->addTab( exec_w, tr("Execute") );
@@ -214,14 +234,20 @@ int AccountWidget::doTab(){
- while (!ok){
- dlg->showMaximized();
- result = dlg->exec();
+ while (!ok)
+ {
+ result = QPEApplication::execDialog( dlg );
ok = true;
- if(result == QDialog::Accepted) {
- if (!auth_w->check()){
+ if(result == QDialog::Accepted)
+ {
+ if (!auth_w->check())
+ {
ok = false;
- } else if(!dial_w->save()) {
+ }
+ else if(!dial_w->save())
+ {
QMessageBox::critical(this, "error", tr( "You must enter a unique account name"));
ok = false;
- }else{
+ }
+ else
+ {
ip_w->save();