summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/ppp/accounts.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/ppp/accounts.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings/ppp/accounts.cpp104
1 files changed, 54 insertions, 50 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index d902517..19db9ef 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -44,48 +44,48 @@
44 44
45#include "pppdata.h" 45#include "pppdata.h"
46#include "accounts.h" 46#include "accounts.h"
47//#include "accounting.h" 47//#include "accounting.h"
48//#include "providerdb.h" 48//#include "providerdb.h"
49#include "edit.h" 49#include "edit.h"
50 50
51void parseargs(char* buf, char** args); 51void parseargs(char* buf, char** args);
52 52
53AccountWidget::AccountWidget( QWidget *parent, const char *name ) 53AccountWidget::AccountWidget( QWidget *parent, const char *name )
54 : QWidget( parent, name ) 54 : QWidget( parent, name )
55{ 55{
56 int min = 0; 56// int min = 0;
57 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); 57 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
58 58
59 // add a hbox 59 // add a hbox
60// QHBoxLayout *l11 = new QHBoxLayout; 60// QHBoxLayout *l11 = new QHBoxLayout;
61// l1->addLayout(l11); 61// l1->addLayout(l11);
62 62
63 accountlist_l = new QListBox(this); 63 accountlist_l = new QListBox(this);
64 accountlist_l->setMinimumSize(160, 128); 64// accountlist_l->setMinimumSize(160, 128);
65 connect(accountlist_l, SIGNAL(highlighted(int)), 65 connect(accountlist_l, SIGNAL(highlighted(int)),
66 this, SLOT(slotListBoxSelect(int))); 66 this, SLOT(slotListBoxSelect(int)));
67 connect(accountlist_l, SIGNAL(selected(int)), 67 connect(accountlist_l, SIGNAL(selected(int)),
68 this, SLOT(editaccount())); 68 this, SLOT(editaccount()));
69 l1->addWidget(accountlist_l, 10); 69 l1->addWidget(accountlist_l, 10);
70 70
71// QVBoxLayout *l111 = new QVBoxLayout(this); 71// QVBoxLayout *l111 = new QVBoxLayout(this);
72// l11->addLayout(l111, 1); 72// l11->addLayout(l111, 1);
73 edit_b = new QPushButton(i18n("&Edit..."), this); 73 edit_b = new QPushButton(i18n("&Edit..."), this);
74 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); 74 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
75 QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account")); 75 QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account"));
76 76
77 min = edit_b->sizeHint().width(); 77// min = edit_b->sizeHint().width();
78 min = QMAX(70,min); 78// min = QMAX(70,min);
79 edit_b->setMinimumWidth(min); 79// edit_b->setMinimumWidth(min);
80 80
81 l1->addWidget(edit_b); 81 l1->addWidget(edit_b);
82 82
83 new_b = new QPushButton(i18n("&New..."), this); 83 new_b = new QPushButton(i18n("&New..."), this);
84 connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); 84 connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
85 l1->addWidget(new_b); 85 l1->addWidget(new_b);
86 QWhatsThis::add(new_b, i18n("Create a new dialup connection\n" 86 QWhatsThis::add(new_b, i18n("Create a new dialup connection\n"
87 "to the Internet")); 87 "to the Internet"));
88 88
89 copy_b = new QPushButton(i18n("Co&py"), this); 89 copy_b = new QPushButton(i18n("Co&py"), this);
90 connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); 90 connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount()));
91 l1->addWidget(copy_b); 91 l1->addWidget(copy_b);
@@ -156,55 +156,55 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name )
156// reset->setEnabled(FALSE); 156// reset->setEnabled(FALSE);
157// connect(reset, SIGNAL(clicked()), 157// connect(reset, SIGNAL(clicked()),
158 // this, SLOT(resetClicked())); 158 // this, SLOT(resetClicked()));
159// l122->addWidget(reset); 159// l122->addWidget(reset);
160 160
161// log = new QPushButton(i18n("&View Logs"), this); 161// log = new QPushButton(i18n("&View Logs"), this);
162// connect(log, SIGNAL(clicked()), 162// connect(log, SIGNAL(clicked()),
163 // this, SLOT(viewLogClicked())); 163 // this, SLOT(viewLogClicked()));
164// l122->addWidget(log); 164// l122->addWidget(log);
165// l122->addStretch(1); 165// l122->addStretch(1);
166 166
167 //load up account list from gppdata to the list box 167 //load up account list from gppdata to the list box
168 if(gpppdata.count() > 0) { 168 if(PPPData::data()->count() > 0) {
169 for(int i=0; i <= gpppdata.count()-1; i++) { 169 for(int i=0; i <= PPPData::data()->count()-1; i++) {
170 gpppdata.setAccountbyIndex(i); 170 PPPData::data()->setAccountbyIndex(i);
171 accountlist_l->insertItem(gpppdata.accname()); 171 accountlist_l->insertItem(PPPData::data()->accname());
172 } 172 }
173 } 173 }
174 174
175 slotListBoxSelect(accountlist_l->currentItem()); 175 slotListBoxSelect(accountlist_l->currentItem());
176 176
177 l1->activate(); 177 l1->activate();
178} 178}
179 179
180 180
181 181
182void AccountWidget::slotListBoxSelect(int idx) { 182void AccountWidget::slotListBoxSelect(int idx) {
183 delete_b->setEnabled((bool)(idx != -1)); 183 delete_b->setEnabled((bool)(idx != -1));
184 edit_b->setEnabled((bool)(idx != -1)); 184 edit_b->setEnabled((bool)(idx != -1));
185 copy_b->setEnabled((bool)(idx != -1)); 185 copy_b->setEnabled((bool)(idx != -1));
186 if(idx!=-1) { 186 if(idx!=-1) {
187 QString account = gpppdata.accname(); 187 QString account = PPPData::data()->accname();
188 gpppdata.setAccountbyIndex(accountlist_l->currentItem()); 188 PPPData::data()->setAccountbyIndex(accountlist_l->currentItem());
189// reset->setEnabled(TRUE); 189// reset->setEnabled(TRUE);
190// costlabel->setEnabled(TRUE); 190// costlabel->setEnabled(TRUE);
191// costedit->setEnabled(TRUE); 191// costedit->setEnabled(TRUE);
192// costedit->setText(AccountingBase::getCosts(accountlist_l->text(accountlist_l->currentItem()))); 192// costedit->setText(AccountingBase::getCosts(accountlist_l->text(accountlist_l->currentItem())));
193 193
194// vollabel->setEnabled(TRUE); 194// vollabel->setEnabled(TRUE);
195// voledit->setEnabled(TRUE); 195// voledit->setEnabled(TRUE);
196 int bytes = gpppdata.totalBytes(); 196// int bytes = PPPData::data()->totalBytes();
197// voledit->setText(prettyPrintVolume(bytes)); 197// voledit->setText(prettyPrintVolume(bytes));
198 gpppdata.setAccount(account); 198 PPPData::data()->setAccount(account);
199 } else{ 199 } else{
200 // reset->setEnabled(FALSE); 200 // reset->setEnabled(FALSE);
201// costlabel->setEnabled(FALSE); 201// costlabel->setEnabled(FALSE);
202// costedit->setText(""); 202// costedit->setText("");
203// costedit->setEnabled(FALSE); 203// costedit->setEnabled(FALSE);
204// vollabel->setEnabled(FALSE); 204// vollabel->setEnabled(FALSE);
205// voledit->setText(""); 205// voledit->setText("");
206// voledit->setEnabled(FALSE); 206// voledit->setEnabled(FALSE);
207 } 207 }
208} 208}
209 209
210 210
@@ -231,157 +231,161 @@ void AccountWidget::slotListBoxSelect(int idx) {
231// // emit resetCosts(accountlist_l->text(accountlist_l->currentItem())); 231// // emit resetCosts(accountlist_l->text(accountlist_l->currentItem()));
232// // costedit->setText("0"); 232// // costedit->setText("0");
233// // } 233// // }
234 234
235// // if(what && QueryReset::VOLUME) { 235// // if(what && QueryReset::VOLUME) {
236// // emit resetVolume(accountlist_l->text(accountlist_l->currentItem())); 236// // emit resetVolume(accountlist_l->text(accountlist_l->currentItem()));
237// // voledit->setText(prettyPrintVolume(0)); 237// // voledit->setText(prettyPrintVolume(0));
238// // } 238// // }
239// } 239// }
240 240
241 241
242void AccountWidget::editaccount() { 242void AccountWidget::editaccount() {
243 gpppdata.setAccount(accountlist_l->text(accountlist_l->currentItem())); 243 PPPData::data()->setAccount(accountlist_l->text(accountlist_l->currentItem()));
244 244
245 int result = doTab(); 245 int result = doTab();
246 246
247 if(result == QDialog::Accepted) { 247 if(result == QDialog::Accepted) {
248 accountlist_l->changeItem(gpppdata.accname(),accountlist_l->currentItem()); 248 accountlist_l->changeItem(PPPData::data()->accname(),accountlist_l->currentItem());
249// emit resetaccounts(); 249// emit resetaccounts();
250 gpppdata.save(); 250 PPPData::data()->save();
251 } 251 }
252} 252}
253 253
254 254
255void AccountWidget::newaccount() { 255void AccountWidget::newaccount() {
256 if(accountlist_l->count() == MAX_ACCOUNTS) { 256 if(accountlist_l->count() == MAX_ACCOUNTS) {
257 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); 257 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
258 return; 258 return;
259 } 259 }
260 260
261 int result; 261 int result;
262// int query = QMessageBox::information(this, 262// int query = QMessageBox::information(this,
263// i18n("Do you want to use the wizard to create the new account or the " 263// i18n("Do you want to use the wizard to create the new account or the "
264 // "standard, dialog-based setup?\n" 264 // "standard, dialog-based setup?\n"
265 // "The wizard is easier and sufficient in most cases. If you need " 265 // "The wizard is easier and sufficient in most cases. If you need "
266 // "very special settings, you might want to try the standard, " 266 // "very special settings, you might want to try the standard, "
267 // "dialog-based setup."), 267 // "dialog-based setup."),
268 // i18n("Create New Account"), 268 // i18n("Create New Account"),
269 // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel")); 269 // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel"));
270 270
271// switch(query) { 271// switch(query) {
272// case QMessageBox::Yes: 272// case QMessageBox::Yes:
273// { 273// {
274// if (gpppdata.newaccount() == -1) 274// if (PPPData::data()->newaccount() == -1)
275 // return; 275 // return;
276// // ProviderDB pdb(this); 276// // ProviderDB pdb(this);
277// // result = pdb.exec(); 277// // result = pdb.exec();
278// break; 278// break;
279// } 279// }
280// case QMessageBox::No: 280// case QMessageBox::No:
281 if (gpppdata.newaccount() == -1){ 281 if (PPPData::data()->newaccount() == -1){
282 qDebug("gpppdata.newaccount() == -1"); 282 qDebug("PPPData::data()->newaccount() == -1");
283 return; 283 return;
284 } 284 }
285 result = doTab(); 285 result = doTab();
286// break; 286// break;
287// default: 287// default:
288// return; 288// return;
289// } 289// }
290 290
291 if(result == QDialog::Accepted) { 291 if(result == QDialog::Accepted) {
292 accountlist_l->insertItem(gpppdata.accname()); 292 accountlist_l->insertItem(PPPData::data()->accname());
293 accountlist_l->setSelected(accountlist_l->findItem(gpppdata.accname()), 293 accountlist_l->setSelected(accountlist_l->findItem(PPPData::data()->accname()),
294 true); 294 true);
295// emit resetaccounts(); 295// emit resetaccounts();
296 gpppdata.save(); 296 PPPData::data()->save();
297 } else 297 } else
298 gpppdata.deleteAccount(); 298 PPPData::data()->deleteAccount();
299} 299}
300 300
301 301
302void AccountWidget::copyaccount() { 302void AccountWidget::copyaccount() {
303 if(accountlist_l->count() == MAX_ACCOUNTS) { 303 if(accountlist_l->count() == MAX_ACCOUNTS) {
304 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); 304 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached."));
305 return; 305 return;
306 } 306 }
307 307
308 if(accountlist_l->currentItem()<0) { 308 if(accountlist_l->currentItem()<0) {
309 QMessageBox::information(this, "sorry", i18n("No account selected.")); 309 QMessageBox::information(this, "sorry", i18n("No account selected."));
310 return; 310 return;
311 } 311 }
312 312
313 gpppdata.copyaccount(accountlist_l->currentItem()); 313 PPPData::data()->copyaccount(accountlist_l->currentItem());
314 314
315 accountlist_l->insertItem(gpppdata.accname()); 315 accountlist_l->insertItem(PPPData::data()->accname());
316// emit resetaccounts(); 316// emit resetaccounts();
317 gpppdata.save(); 317 PPPData::data()->save();
318} 318}
319 319
320 320
321void AccountWidget::deleteaccount() { 321void AccountWidget::deleteaccount() {
322 322
323 QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?") 323 QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?")
324 .arg(accountlist_l->text(accountlist_l->currentItem())); 324 .arg(accountlist_l->text(accountlist_l->currentItem()));
325 325
326 if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes) 326 if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes)
327 return; 327 return;
328 328
329 if(gpppdata.deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) 329 if(PPPData::data()->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
330 accountlist_l->removeItem(accountlist_l->currentItem()); 330 accountlist_l->removeItem(accountlist_l->currentItem());
331 331
332 emit resetaccounts(); 332 emit resetaccounts();
333 gpppdata.save(); 333 PPPData::data()->save();
334 334
335 slotListBoxSelect(accountlist_l->currentItem()); 335 slotListBoxSelect(accountlist_l->currentItem());
336 336
337} 337}
338 338
339 339
340int AccountWidget::doTab(){ 340int AccountWidget::doTab(){
341 QDialog *dlg = new QDialog( this ); 341 QDialog *dlg = new QDialog( this, "newAccount", true );
342 tabWindow = new QTabWidget( dlg ); 342 QVBoxLayout *layout = new QVBoxLayout( dlg );
343 // tabWindow = new KDialogBase( KDialogBase::Tabbed, QString::null, 343 layout->setSpacing( 0 );
344// KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, 344 layout->setMargin( 1 );
345// 0, 0, true); 345
346// KWin::setIcons(tabWindow->winId(), kapp->icon(), kapp->miniIcon()); 346 tabWindow = new QTabWidget( dlg, "tabWindow" );
347 layout->addWidget( tabWindow );
348
347 bool isnewaccount; 349 bool isnewaccount;
348 350
349 if(gpppdata.accname().isEmpty()) { 351 if(PPPData::data()->accname().isEmpty()) {
350 tabWindow->setCaption(i18n("New Account")); 352 dlg->setCaption(i18n("New Account"));
351 isnewaccount = true; 353 isnewaccount = true;
352 } else { 354 } else {
353 QString tit = i18n("Edit Account: "); 355 QString tit = i18n("Edit Account: ");
354 tit += gpppdata.accname(); 356 tit += PPPData::data()->accname();
355 tabWindow->setCaption(tit); 357 dlg->setCaption(tit);
356 isnewaccount = false; 358 isnewaccount = false;
357 } 359 }
358 360
359 dial_w = new DialWidget( tabWindow ); 361 dial_w = new DialWidget( tabWindow, isnewaccount, "Dial Setup");
360 tabWindow->addTab( dial_w, i18n("Dial") );//, i18n("Dial Setup")), isnewaccount); 362 tabWindow->addTab( dial_w, i18n("Dial") );
361 ip_w = new IPWidget( tabWindow ); 363 ip_w = new IPWidget( tabWindow, isnewaccount, i18n("IP Setup"));
362 tabWindow->addTab( ip_w, i18n("IP") );//, i18n("IP Setup")), isnewaccount); 364 tabWindow->addTab( ip_w, i18n("IP") );
363 gateway_w = new GatewayWidget( tabWindow ); 365 gateway_w = new GatewayWidget( tabWindow, isnewaccount, i18n("Gateway Setup"));
364 tabWindow->addTab( gateway_w, i18n("Gateway") );//, i18n("Gateway Setup")), isnewaccount); 366 tabWindow->addTab( gateway_w, i18n("Gateway") );
365 dns_w = new DNSWidget( tabWindow ); 367 dns_w = new DNSWidget( tabWindow, isnewaccount, i18n("DNS Servers") );
366 tabWindow->addTab( dns_w, i18n("DNS") );//, i18n("DNS Servers")), isnewaccount); 368 tabWindow->addTab( dns_w, i18n("DNS") );
367 script_w = new ScriptWidget( tabWindow ); 369 script_w = new ScriptWidget( tabWindow, isnewaccount, i18n("Edit Login Script"));
368 tabWindow->addTab( script_w, i18n("Login Script") ); //, i18n("Edit Login Script")), isnewaccount); 370 tabWindow->addTab( script_w, i18n("Login Script") );
369 ExecWidget *exec_w = new ExecWidget( tabWindow ); 371 ExecWidget *exec_w = new ExecWidget( tabWindow, isnewaccount, i18n("Execute Programs"));
370 tabWindow->addTab( exec_w, i18n("Execute") );//, i18n("Execute Programs")), isnewaccount); 372 tabWindow->addTab( exec_w, i18n("Execute") );
371// acct = new AccountingSelector( tabWindow, isnewaccount ); 373// acct = new AccountingSelector( tabWindow, isnewaccount );
372// tabWindow->addTab( acct, i18n("Accounting")); 374// tabWindow->addTab( acct, i18n("Accounting"));
373 375
374 int result = 0; 376 int result = 0;
375 bool ok = false; 377 bool ok = false;
378 qDebug("AccountWidget::doTab dlg->showMinimized");
379 dlg->showMinimized();
376 while (!ok){ 380 while (!ok){
377 381
378 result = dlg->exec(); 382 result = dlg->exec();
379 ok = true; 383 ok = true;
380 384
381 if(result == QDialog::Accepted) { 385 if(result == QDialog::Accepted) {
382 if (script_w->check()) { 386 if (script_w->check()) {
383 if(dial_w->save()) { 387 if(dial_w->save()) {
384 ip_w->save(); 388 ip_w->save();
385 dns_w->save(); 389 dns_w->save();
386 gateway_w->save(); 390 gateway_w->save();
387 script_w->save(); 391 script_w->save();