summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/accounts.cpp
Unidiff
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
@@ -24,147 +24,164 @@
24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 */ 25 */
26 26
27#include "accounts.h"
28#include "authwidget.h"
29#include "pppdata.h"
30#include "edit.h"
31
32/* OPIE */
33#include <qpe/qpeapplication.h>
34
35/* QT */
27#include <qdir.h> 36#include <qdir.h>
28#include <stdlib.h>
29#include <qlayout.h> 37#include <qlayout.h>
30#include <qtabwidget.h> 38#include <qtabwidget.h>
31#include <qtabdialog.h> 39#include <qtabdialog.h>
32#include <qwhatsthis.h> 40#include <qwhatsthis.h>
33#include <qmessagebox.h> 41#include <qmessagebox.h>
34
35#include <qapplication.h> 42#include <qapplication.h>
36#include <qbuttongroup.h> 43#include <qbuttongroup.h>
37#include <qmessagebox.h> 44#include <qmessagebox.h>
38#include <qvgroupbox.h> 45#include <qvgroupbox.h>
39 46
40#include "accounts.h" 47/* STD */
41#include "authwidget.h" 48#include <stdlib.h>
42#include "pppdata.h"
43#include "edit.h"
44 49
45void parseargs(char* buf, char** args); 50void parseargs(char* buf, char** args);
46 51
47 52
48AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f ) 53AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name, WFlags f )
49 : ChooserWidget( pd, parent, name, f ) 54 : ChooserWidget( pd, parent, name, f )
50{ 55{
51 56
52 QWhatsThis::add(edit_b, tr("Allows you to modify the selected account")); 57 QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
53 QWhatsThis::add(new_b, tr("Create a new dialup connection\n" 58 QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
54 "to the Internet")); 59 "to the Internet"));
55 QWhatsThis::add(copy_b, 60 QWhatsThis::add(copy_b,
56 tr("Makes a copy of the selected account. All\n" 61 tr("Makes a copy of the selected account. All\n"
57 "settings of the selected account are copied\n" 62 "settings of the selected account are copied\n"
58 "to a new account, that you can modify to fit your\n" 63 "to a new account, that you can modify to fit your\n"
59 "needs")); 64 "needs"));
60 QWhatsThis::add(delete_b, 65 QWhatsThis::add(delete_b,
61 tr("<p>Deletes the selected account\n\n" 66 tr("<p>Deletes the selected account\n\n"
62 "<font color=\"red\"><b>Use with care!</b></font>")); 67 "<font color=\"red\"><b>Use with care!</b></font>"));
63 68
64 69
65 70
66 copy_b->setEnabled( false ); //FIXME 71 copy_b->setEnabled( false ); //FIXME
67 // delete_b->setEnabled( false ); //FIXME 72 // delete_b->setEnabled( false ); //FIXME
68 73
69 listListbox->insertStringList(_pppdata->getAccountList()); 74 listListbox->insertStringList(_pppdata->getAccountList());
70 75
71 for (uint i = 0; i < listListbox->count(); i++){ 76 for (uint i = 0; i < listListbox->count(); i++)
72 if ( listListbox->text(i) == _pppdata->accname() ) 77 {
73 listListbox->setCurrentItem( i ); 78 if ( listListbox->text(i) == _pppdata->accname() )
74 } 79 listListbox->setCurrentItem( i );
80 }
75} 81}
76 82
77 83
78 84
79void AccountWidget::slotListBoxSelect(int idx) { 85void AccountWidget::slotListBoxSelect(int idx)
86{
80 bool ok = _pppdata->setAccount( listListbox->text(idx) ); 87 bool ok = _pppdata->setAccount( listListbox->text(idx) );
81 ok = (bool)(idx != -1); 88 ok = (bool)(idx != -1);
82 delete_b->setEnabled(ok); 89 delete_b->setEnabled(ok);
83 edit_b->setEnabled(ok); 90 edit_b->setEnabled(ok);
84//FIXME copy_b->setEnabled(ok); 91 //FIXME copy_b->setEnabled(ok);
85} 92}
86 93
87void AccountWidget::edit() { 94void AccountWidget::edit()
88 _pppdata->setAccount(listListbox->text(listListbox->currentItem())); 95{
96 _pppdata->setAccount(listListbox->text(listListbox->currentItem()));
89 97
90 int result = doTab(); 98 int result = doTab();
91 99
92 if(result == QDialog::Accepted) { 100 if(result == QDialog::Accepted)
93 listListbox->changeItem(_pppdata->accname(),listListbox->currentItem()); 101 {
94// emit resetaccounts(); 102 listListbox->changeItem(_pppdata->accname(),listListbox->currentItem());
95 _pppdata->save(); 103 // emit resetaccounts();
96 } 104 _pppdata->save();
105 }
97} 106}
98 107
99 108
100void AccountWidget::create() { 109void AccountWidget::create()
110{
101 111
102// if(listListbox->count() == MAX_ACCOUNTS) { 112 // if(listListbox->count() == MAX_ACCOUNTS) {
103// QMessageBox::information(this, "sorry", 113 // QMessageBox::information(this, "sorry",
104// tr("Maximum number of accounts reached.")); 114 // tr("Maximum number of accounts reached."));
105// return; 115 // return;
106// } 116 // }
107 117
108 int result; 118 int result;
109 if (_pppdata->newaccount() == -1){ 119 if (_pppdata->newaccount() == -1)
120 {
110 qDebug("_pppdata->newaccount() == -1"); 121 qDebug("_pppdata->newaccount() == -1");
111 return; 122 return;
112 } 123 }
113 result = doTab(); 124 result = doTab();
114 125
115 if(result == QDialog::Accepted) { 126 if(result == QDialog::Accepted)
127 {
116 listListbox->insertItem(_pppdata->accname()); 128 listListbox->insertItem(_pppdata->accname());
117 listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true); 129 listListbox->setSelected(listListbox->findItem(_pppdata->accname()),true);
118 130
119 _pppdata->save(); 131 _pppdata->save();
120 } else 132 }
133 else
121 _pppdata->deleteAccount(); 134 _pppdata->deleteAccount();
122} 135}
123 136
124 137
125void AccountWidget::copy() { 138void AccountWidget::copy()
126// if(listListbox->count() == MAX_ACCOUNTS) { 139{
127// QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); 140 // if(listListbox->count() == MAX_ACCOUNTS) {
128// return; 141 // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
129// } 142 // return;
130 143 // }
131 if(listListbox->currentItem()<0) { 144
132 QMessageBox::information(this, "sorry", tr("No account selected.")); 145 if(listListbox->currentItem()<0)
133 return; 146 {
134 } 147 QMessageBox::information(this, "sorry", tr("No account selected."));
148 return;
149 }
135 150
136 _pppdata->copyaccount(listListbox->currentText()); 151 _pppdata->copyaccount(listListbox->currentText());
137 152
138 listListbox->insertItem(_pppdata->accname()); 153 listListbox->insertItem(_pppdata->accname());
139// emit resetaccounts(); 154 // emit resetaccounts();
140 _pppdata->save(); 155 _pppdata->save();
141} 156}
142 157
143 158
144void AccountWidget::remove() { 159void AccountWidget::remove()
160{
145 161
146 QString s = tr("Are you sure you want to delete\nthe account \"%1\"?") 162 QString s = tr("Are you sure you want to delete\nthe account \"%1\"?")
147 .arg(listListbox->text(listListbox->currentItem())); 163 .arg(listListbox->text(listListbox->currentItem()));
148 164
149 if(QMessageBox::warning(this,tr("Confirm"),s, 165 if(QMessageBox::warning(this,tr("Confirm"),s,
150 QMessageBox::Yes,QMessageBox::No 166 QMessageBox::Yes,QMessageBox::No
151 ) != QMessageBox::Yes) 167 ) != QMessageBox::Yes)
152 return; 168 return;
153 169
154 if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem()))) 170 if(_pppdata->deleteAccount(listListbox->text(listListbox->currentItem())))
155 listListbox->removeItem(listListbox->currentItem()); 171 listListbox->removeItem(listListbox->currentItem());
156 172
157 173
158// emit resetaccounts(); 174 // emit resetaccounts();
159// _pppdata->save(); 175 // _pppdata->save();
160 176
161 177
162 slotListBoxSelect(listListbox->currentItem()); 178 slotListBoxSelect(listListbox->currentItem());
163 179
164} 180}
165 181
166 182
167int AccountWidget::doTab(){ 183int AccountWidget::doTab()
184{
168 QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp ); 185 QDialog *dlg = new QDialog( 0, "newAccount", true, Qt::WStyle_ContextHelp );
169 QVBoxLayout *layout = new QVBoxLayout( dlg ); 186 QVBoxLayout *layout = new QVBoxLayout( dlg );
170 layout->setSpacing( 0 ); 187 layout->setSpacing( 0 );
@@ -175,55 +192,64 @@ int AccountWidget::doTab(){
175 192
176 bool isnewaccount; 193 bool isnewaccount;
177 194
178 if(_pppdata->accname().isEmpty()) { 195 if(_pppdata->accname().isEmpty())
196 {
179 dlg->setCaption(tr("New Account")); 197 dlg->setCaption(tr("New Account"));
180 isnewaccount = true; 198 isnewaccount = true;
181 } else { 199 }
200 else
201 {
182 QString tit = tr("Edit Account: "); 202 QString tit = tr("Edit Account: ");
183 tit += _pppdata->accname(); 203 tit += _pppdata->accname();
184 dlg->setCaption(tit); 204 dlg->setCaption(tit);
185 isnewaccount = false; 205 isnewaccount = false;
186 } 206 }
187 207
188// // DIAL WIDGET 208 // // DIAL WIDGET
189 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); 209 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
190 tabWindow->addTab( dial_w, tr("Dial") ); 210 tabWindow->addTab( dial_w, tr("Dial") );
191 211
192// // AUTH WIDGET 212 // // AUTH WIDGET
193 auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script")); 213 auth_w = new AuthWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
194 tabWindow->addTab( auth_w, tr("Authentication") ); 214 tabWindow->addTab( auth_w, tr("Authentication") );
195 215
196// // IP WIDGET 216 // // IP WIDGET
197 ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup")); 217 ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup"));
198 tabWindow->addTab( ip_w, tr("IP") ); 218 tabWindow->addTab( ip_w, tr("IP") );
199 219
200// // GATEWAY WIDGET 220 // // GATEWAY WIDGET
201 gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup")); 221 gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup"));
202 tabWindow->addTab( gateway_w, tr("Gateway") ); 222 tabWindow->addTab( gateway_w, tr("Gateway") );
203 223
204// // DNS WIDGET 224 // // DNS WIDGET
205 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") ); 225 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") );
206 tabWindow->addTab( dns_w, tr("DNS") ); 226 tabWindow->addTab( dns_w, tr("DNS") );
207 227
208// // EXECUTE WIDGET 228 // // EXECUTE WIDGET
209 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs")); 229 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs"));
210 tabWindow->addTab( exec_w, tr("Execute") ); 230 tabWindow->addTab( exec_w, tr("Execute") );
211 231
212 int result = 0; 232 int result = 0;
213 bool ok = false; 233 bool ok = false;
214 234
215 while (!ok){ 235 while (!ok)
216 dlg->showMaximized(); 236 {
217 result = dlg->exec(); 237 result = QPEApplication::execDialog( dlg );
218 ok = true; 238 ok = true;
219 239
220 if(result == QDialog::Accepted) { 240 if(result == QDialog::Accepted)
221 if (!auth_w->check()){ 241 {
242 if (!auth_w->check())
243 {
222 ok = false; 244 ok = false;
223 } else if(!dial_w->save()) { 245 }
246 else if(!dial_w->save())
247 {
224 QMessageBox::critical(this, "error", tr( "You must enter a unique account name")); 248 QMessageBox::critical(this, "error", tr( "You must enter a unique account name"));
225 ok = false; 249 ok = false;
226 }else{ 250 }
251 else
252 {
227 ip_w->save(); 253 ip_w->save();
228 dns_w->save(); 254 dns_w->save();
229 gateway_w->save(); 255 gateway_w->save();