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.cpp299
1 files changed, 107 insertions, 192 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp
index 3fa2f84..f704c84 100644
--- a/noncore/settings/networksettings/ppp/accounts.cpp
+++ b/noncore/settings/networksettings/ppp/accounts.cpp
@@ -35,17 +35,10 @@
35#include <qapplication.h> 35#include <qapplication.h>
36#include <qbuttongroup.h> 36#include <qbuttongroup.h>
37#include <qmessagebox.h> 37#include <qmessagebox.h>
38//#include <klocale.h>
39#define i18n QObject::tr
40//#include <kglobal.h>
41//#include <kwin.h>
42//#include <kdialogbase.h>
43#include <qvgroupbox.h> 38#include <qvgroupbox.h>
44 39
45#include "pppdata.h" 40#include "pppdata.h"
46#include "accounts.h" 41#include "accounts.h"
47//#include "accounting.h"
48//#include "providerdb.h"
49#include "edit.h" 42#include "edit.h"
50 43
51void parseargs(char* buf, char** args); 44void parseargs(char* buf, char** args);
@@ -62,95 +55,37 @@ AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name )
62 this, SLOT(editaccount())); 55 this, SLOT(editaccount()));
63 l1->addWidget(accountlist_l, 10); 56 l1->addWidget(accountlist_l, 10);
64 57
65 edit_b = new QPushButton(i18n("&Edit..."), this); 58 edit_b = new QPushButton(tr("&Edit..."), this);
66 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); 59 connect(edit_b, SIGNAL(clicked()), SLOT(editaccount()));
67 QWhatsThis::add(edit_b, i18n("Allows you to modify the selected account")); 60 QWhatsThis::add(edit_b, tr("Allows you to modify the selected account"));
68 l1->addWidget(edit_b); 61 l1->addWidget(edit_b);
69 62
70 new_b = new QPushButton(i18n("&New..."), this); 63 new_b = new QPushButton(tr("&New..."), this);
71 connect(new_b, SIGNAL(clicked()), SLOT(newaccount())); 64 connect(new_b, SIGNAL(clicked()), SLOT(newaccount()));
72 l1->addWidget(new_b); 65 l1->addWidget(new_b);
73 QWhatsThis::add(new_b, i18n("Create a new dialup connection\n" 66 QWhatsThis::add(new_b, tr("Create a new dialup connection\n"
74 "to the Internet")); 67 "to the Internet"));
75 68
76 copy_b = new QPushButton(i18n("Co&py"), this); 69 copy_b = new QPushButton(tr("Co&py"), this);
77 connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount())); 70 connect(copy_b, SIGNAL(clicked()), SLOT(copyaccount()));
78 l1->addWidget(copy_b); 71 l1->addWidget(copy_b);
79 QWhatsThis::add(copy_b, 72 QWhatsThis::add(copy_b,
80 i18n("Makes a copy of the selected account. All\n" 73 tr("Makes a copy of the selected account. All\n"
81 "settings of the selected account are copied\n" 74 "settings of the selected account are copied\n"
82 "to a new account, that you can modify to fit your\n" 75 "to a new account, that you can modify to fit your\n"
83 "needs")); 76 "needs"));
84 77
85 delete_b = new QPushButton(i18n("De&lete"), this); 78 delete_b = new QPushButton(tr("De&lete"), this);
86 connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount())); 79 connect(delete_b, SIGNAL(clicked()), SLOT(deleteaccount()));
87 l1->addWidget(delete_b); 80 l1->addWidget(delete_b);
88 QWhatsThis::add(delete_b, 81 QWhatsThis::add(delete_b,
89 i18n("<p>Deletes the selected account\n\n" 82 tr("<p>Deletes the selected account\n\n"
90 "<font color=\"red\"><b>Use with care!</b></font>")); 83 "<font color=\"red\"><b>Use with care!</b></font>"));
91 84
92 QHBoxLayout *l12 = new QHBoxLayout; 85 QHBoxLayout *l12 = new QHBoxLayout;
93 l1->addStretch(1); 86 l1->addStretch(1);
94 l1->addLayout(l12); 87 l1->addLayout(l12);
95 88
96// QVBoxLayout *l121 = new QVBoxLayout;
97// l12->addLayout(l121);
98// l121->addStretch(1);
99 // costlabel = new QLabel(i18n("Phone costs:"), parent);
100// costlabel->setEnabled(FALSE);
101// l121->addWidget(costlabel);
102
103// costedit = new QLineEdit(parent);
104// costedit->setFocusPolicy(QWidget::NoFocus);
105// costedit->setFixedHeight(costedit->sizeHint().height());
106// costedit->setEnabled(FALSE);
107// l121->addWidget(costedit);
108// l121->addStretch(1);
109// QString tmp = i18n("<p>This shows the accumulated phone costs\n"
110 // "for the selected account.\n"
111 // "\n"
112 // "<b>Important</b>: If you have more than one \n"
113 // "account - beware, this is <b>NOT</b> the sum \n"
114 // "of the phone costs of all your accounts!");
115// QWhatsThis::add(costlabel, tmp);
116// QWhatsThis::add(costedit, tmp);
117
118// vollabel = new QLabel(i18n("Volume:"), parent);
119// vollabel->setEnabled(FALSE);
120// l121->addWidget(vollabel);
121
122// voledit = new QLineEdit(parent,"voledit");
123// voledit->setFocusPolicy(QWidget::NoFocus);
124// voledit->setFixedHeight(voledit->sizeHint().height());
125// voledit->setEnabled(FALSE);
126// l121->addWidget(voledit);
127// tmp = i18n("<p>This shows the number of bytes transferred\n"
128 // "for the selected account (not for all of your\n"
129 // "accounts. You can select what to display in\n"
130 // "the accounting dialog.\n"
131 // "\n"
132 // "<a href=\"#volaccounting\">More on volume accounting</a>");
133
134// QWhatsThis::add(vollabel,tmp);
135// QWhatsThis::add(voledit, tmp);
136
137// QVBoxLayout *l122 = new QVBoxLayout;
138// l12->addStretch(1);
139// l12->addLayout(l122);
140
141// l122->addStretch(1);
142// reset = new QPushButton(i18n("&Reset..."), parent);
143// reset->setEnabled(FALSE);
144// connect(reset, SIGNAL(clicked()),
145 // this, SLOT(resetClicked()));
146// l122->addWidget(reset);
147
148// log = new QPushButton(i18n("&View Logs"), this);
149// connect(log, SIGNAL(clicked()),
150 // this, SLOT(viewLogClicked()));
151// l122->addWidget(log);
152// l122->addStretch(1);
153
154 //load up account list from gppdata to the list box 89 //load up account list from gppdata to the list box
155 if(_pppdata->count() > 0) { 90 if(_pppdata->count() > 0) {
156 for(int i=0; i <= _pppdata->count()-1; i++) { 91 for(int i=0; i <= _pppdata->count()-1; i++) {
@@ -159,10 +94,10 @@ AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name )
159 } 94 }
160 } 95 }
161 96
162// slotListBoxSelect(accountlist_l->currentItem()); 97
163 qDebug("setting listview index to %i",_pppdata->currentAccountID() ); 98 qDebug("setting listview index to %i",_pppdata->currentAccountID() );
164 accountlist_l->setCurrentItem( _pppdata->currentAccountID() ); 99 accountlist_l->setCurrentItem( _pppdata->currentAccountID() );
165// slotListBoxSelect( _pppdata->currentAccountID()); 100 slotListBoxSelect( _pppdata->currentAccountID());
166 101
167 l1->activate(); 102 l1->activate();
168} 103}
@@ -227,46 +162,24 @@ void AccountWidget::editaccount() {
227 162
228 163
229void AccountWidget::newaccount() { 164void AccountWidget::newaccount() {
165
230 if(accountlist_l->count() == MAX_ACCOUNTS) { 166 if(accountlist_l->count() == MAX_ACCOUNTS) {
231 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); 167 QMessageBox::information(this, "sorry",
168 tr("Maximum number of accounts reached."));
232 return; 169 return;
233 } 170 }
234 171
235 int result; 172 int result;
236// int query = QMessageBox::information(this,
237// i18n("Do you want to use the wizard to create the new account or the "
238 // "standard, dialog-based setup?\n"
239 // "The wizard is easier and sufficient in most cases. If you need "
240 // "very special settings, you might want to try the standard, "
241 // "dialog-based setup."),
242 // i18n("Create New Account"),
243 // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel"));
244
245// switch(query) {
246// case QMessageBox::Yes:
247// {
248// if (_pppdata->newaccount() == -1)
249 // return;
250// // ProviderDB pdb(this);
251// // result = pdb.exec();
252// break;
253// }
254// case QMessageBox::No:
255 if (_pppdata->newaccount() == -1){ 173 if (_pppdata->newaccount() == -1){
256 qDebug("_pppdata->newaccount() == -1"); 174 qDebug("_pppdata->newaccount() == -1");
257 return; 175 return;
258 } 176 }
259 result = doTab(); 177 result = doTab();
260// break;
261// default:
262// return;
263// }
264 178
265 if(result == QDialog::Accepted) { 179 if(result == QDialog::Accepted) {
266 accountlist_l->insertItem(_pppdata->accname()); 180 accountlist_l->insertItem(_pppdata->accname());
267 accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()), 181 accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()),true);
268 true); 182
269// emit resetaccounts();
270 _pppdata->save(); 183 _pppdata->save();
271 } else 184 } else
272 _pppdata->deleteAccount(); 185 _pppdata->deleteAccount();
@@ -275,12 +188,12 @@ void AccountWidget::newaccount() {
275 188
276void AccountWidget::copyaccount() { 189void AccountWidget::copyaccount() {
277 if(accountlist_l->count() == MAX_ACCOUNTS) { 190 if(accountlist_l->count() == MAX_ACCOUNTS) {
278 QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); 191 QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached."));
279 return; 192 return;
280 } 193 }
281 194
282 if(accountlist_l->currentItem()<0) { 195 if(accountlist_l->currentItem()<0) {
283 QMessageBox::information(this, "sorry", i18n("No account selected.")); 196 QMessageBox::information(this, "sorry", tr("No account selected."));
284 return; 197 return;
285 } 198 }
286 199
@@ -294,10 +207,10 @@ void AccountWidget::copyaccount() {
294 207
295void AccountWidget::deleteaccount() { 208void AccountWidget::deleteaccount() {
296 209
297 QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?") 210 QString s = tr("Are you sure you want to delete\nthe account \"%1\"?")
298 .arg(accountlist_l->text(accountlist_l->currentItem())); 211 .arg(accountlist_l->text(accountlist_l->currentItem()));
299 212
300 if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes) 213 if(QMessageBox::warning(this, s, tr("Confirm")) != QMessageBox::Yes)
301 return; 214 return;
302 215
303 if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) 216 if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem())))
@@ -312,7 +225,7 @@ void AccountWidget::deleteaccount() {
312 225
313 226
314int AccountWidget::doTab(){ 227int AccountWidget::doTab(){
315 QDialog *dlg = new QDialog( this, "newAccount", true ); 228 QDialog *dlg = new QDialog( 0, "newAccount", true );
316 QVBoxLayout *layout = new QVBoxLayout( dlg ); 229 QVBoxLayout *layout = new QVBoxLayout( dlg );
317 layout->setSpacing( 0 ); 230 layout->setSpacing( 0 );
318 layout->setMargin( 1 ); 231 layout->setMargin( 1 );
@@ -323,70 +236,74 @@ int AccountWidget::doTab(){
323 bool isnewaccount; 236 bool isnewaccount;
324 237
325 if(_pppdata->accname().isEmpty()) { 238 if(_pppdata->accname().isEmpty()) {
326 dlg->setCaption(i18n("New Account")); 239 dlg->setCaption(tr("New Account"));
327 isnewaccount = true; 240 isnewaccount = true;
328 } else { 241 } else {
329 QString tit = i18n("Edit Account: "); 242 QString tit = tr("Edit Account: ");
330 tit += _pppdata->accname(); 243 tit += _pppdata->accname();
331 dlg->setCaption(tit); 244 dlg->setCaption(tit);
332 isnewaccount = false; 245 isnewaccount = false;
333 } 246 }
334 247
248// // DIAL WIDGET
335 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); 249 dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup");
336 tabWindow->addTab( dial_w, i18n("Dial") ); 250 tabWindow->addTab( dial_w, tr("Dial") );
337 ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, i18n("IP Setup")); 251
338 tabWindow->addTab( ip_w, i18n("IP") ); 252// // IP WIDGET
339 gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, i18n("Gateway Setup")); 253 ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, tr("IP Setup"));
340 tabWindow->addTab( gateway_w, i18n("Gateway") ); 254 tabWindow->addTab( ip_w, tr("IP") );
341 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, i18n("DNS Servers") ); 255
342 tabWindow->addTab( dns_w, i18n("DNS") ); 256// // GATEWAY WIDGET
343 script_w = new ScriptWidget( _pppdata, tabWindow, isnewaccount, i18n("Edit Login Script")); 257 gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, tr("Gateway Setup"));
344 tabWindow->addTab( script_w, i18n("Login Script") ); 258 tabWindow->addTab( gateway_w, tr("Gateway") );
345 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, i18n("Execute Programs")); 259
346 tabWindow->addTab( exec_w, i18n("Execute") ); 260// // DNS WIDGET
347// acct = new AccountingSelector( tabWindow, isnewaccount ); 261 dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, tr("DNS Servers") );
348// tabWindow->addTab( acct, i18n("Accounting")); 262 tabWindow->addTab( dns_w, tr("DNS") );
263
264// // SCRIPT WIDGET
265 script_w = new ScriptWidget( _pppdata, tabWindow, isnewaccount, tr("Edit Login Script"));
266 tabWindow->addTab( script_w, tr("Login Script") );
267
268// // EXECUTE WIDGET
269 ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, tr("Execute Programs"));
270 tabWindow->addTab( exec_w, tr("Execute") );
349 271
350 int result = 0; 272 int result = 0;
351 bool ok = false; 273 bool ok = false;
352 qDebug("AccountWidget::doTab dlg->showMinimized");
353 dlg->showMinimized();
354 while (!ok){
355 274
275 while (!ok){
276 // dlg->showMinimized();
356 result = dlg->exec(); 277 result = dlg->exec();
357 ok = true; 278 ok = true;
358 279
359 if(result == QDialog::Accepted) { 280 if(result == QDialog::Accepted) {
360 if (script_w->check()) { 281 if (!script_w->check()){
361 if(dial_w->save()) { 282 QMessageBox::critical(this, "error", tr("<qt>Login script has unbalanced loop Start/End<qt>"));
283 ok = false;
284 } else if(!dial_w->save()) {
285 QMessageBox::critical(this, "error", tr( "You must enter a unique account name"));
286 ok = false;
287 }else{
362 ip_w->save(); 288 ip_w->save();
363 dns_w->save(); 289 dns_w->save();
364 gateway_w->save(); 290 gateway_w->save();
365 script_w->save(); 291 script_w->save();
366 exec_w->save(); 292 exec_w->save();
367 // acct->save();
368 } else {
369 QMessageBox::critical(this, "error", i18n( "You must enter a unique\n"
370 "account name"));
371 ok = false;
372 }
373 } else {
374 QMessageBox::critical(this, "error", i18n("Login script has unbalanced "
375 "loop Start/End"));
376 ok = false;
377 } 293 }
378 } 294 }
379 } 295 }
380 296
381 delete tabWindow; 297 delete dlg;
298
382 return result; 299 return result;
383} 300}
384 301
385 302
386QString AccountWidget::prettyPrintVolume(unsigned int n) { 303QString AccountWidget::prettyPrintVolume(unsigned int n) {
387 int idx = 0; 304 int idx = 0;
388 const QString quant[] = {i18n("Byte"), i18n("KB"), 305 const QString quant[] = {tr("Byte"), tr("KB"),
389 i18n("MB"), i18n("GB"), QString::null}; 306 tr("MB"), tr("GB"), QString::null};
390 307
391 float n1 = n; 308 float n1 = n;
392 while(n >= 1024 && quant[idx] != QString::null) { 309 while(n >= 1024 && quant[idx] != QString::null) {
@@ -409,61 +326,59 @@ QString AccountWidget::prettyPrintVolume(unsigned int n) {
409// Queries the user what to reset: costs, volume or both 326// Queries the user what to reset: costs, volume or both
410// 327//
411///////////////////////////////////////////////////////////////////////////// 328/////////////////////////////////////////////////////////////////////////////
412QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) { 329// QueryReset::QueryReset(QWidget *parent) : QDialog(parent, 0, true) {
413// KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon()); 330// // KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
414 setCaption(i18n("Reset Accounting")); 331// setCaption(tr("Reset Accounting"));
415 332
416 QVBoxLayout *tl = new QVBoxLayout(this, 10, 10); 333// QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
417 QVGroupBox *f = new QVGroupBox(i18n("What to Reset"), this); 334// QVGroupBox *f = new QVGroupBox(tr("What to Reset"), this);
418 335
419 QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); 336// QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10);
420// costs = new QCheckBox(i18n("Reset the accumulated phone costs"), f); 337// // costs = new QCheckBox(tr("Reset the accumulated phone costs"), f);
421// costs->setChecked(true); 338// // costs->setChecked(true);
422// l1->addWidget(costs); 339// // l1->addWidget(costs);
423// QWhatsThis::add(costs, i18n("Check this to set the phone costs\n" 340// // QWhatsThis::add(costs, tr("Check this to set the phone costs\n"
424 // "to zero. Typically you'll want to\n" 341 // // "to zero. Typically you'll want to\n"
425 // "do this once a month.")); 342 // // "do this once a month."));
426 343
427// volume = new QCheckBox(i18n("Reset volume accounting"), f); 344// // volume = new QCheckBox(tr("Reset volume accounting"), f);
428// volume->setChecked(true); 345// // volume->setChecked(true);
429// l1->addWidget(volume); 346// // l1->addWidget(volume);
430// QWhatsThis::add(volume, i18n("Check this to set the volume accounting\n" 347// // QWhatsThis::add(volume, tr("Check this to set the volume accounting\n"
431 // "to zero. Typically you'll want to do this\n" 348 // // "to zero. Typically you'll want to do this\n"
432 // "once a month.")); 349 // // "once a month."));
433 350
434 l1->activate(); 351// l1->activate();
352
353// // this activates the f-layout and sets minimumSize()
354// f->show();
355
356// tl->addWidget(f);
357
358// QButtonGroup *bbox = new QButtonGroup(this);
359// // bbox->addStretch(1);
360// QPushButton *ok = new QPushButton( bbox, tr("OK") );
361// bbox->insert(ok);
362// ok->setDefault(true);
363// QPushButton *cancel = new QPushButton( bbox, tr("Cancel") );
364// bbox->insert(cancel);
365
366// connect(ok, SIGNAL(clicked()),
367 // this, SLOT(accepted()));
368// connect(cancel, SIGNAL(clicked()),
369 // this, SLOT(reject()));
370
371// bbox->layout();
372// tl->addWidget(bbox);
435 373
436 // this activates the f-layout and sets minimumSize() 374// }
437 f->show();
438
439 tl->addWidget(f);
440
441 QButtonGroup *bbox = new QButtonGroup(this);
442// bbox->addStretch(1);
443 QPushButton *ok = new QPushButton( bbox, i18n("OK") );
444 bbox->insert(ok);
445 ok->setDefault(true);
446 QPushButton *cancel = new QPushButton( bbox, i18n("Cancel") );
447 bbox->insert(cancel);
448
449 connect(ok, SIGNAL(clicked()),
450 this, SLOT(accepted()));
451 connect(cancel, SIGNAL(clicked()),
452 this, SLOT(reject()));
453
454 bbox->layout();
455 tl->addWidget(bbox);
456
457 // TODO: activate if KGroupBox is fixed
458 // setFixedSize(sizeHint());
459}
460 375
461 376
462void QueryReset::accepted() { 377// void QueryReset::accepted() {
463 int result = costs->isChecked() ? COSTS : 0; 378// int result = costs->isChecked() ? COSTS : 0;
464 result += volume->isChecked() ? VOLUME : 0; 379// result += volume->isChecked() ? VOLUME : 0;
465 380
466 done(result); 381// done(result);
467} 382// }
468 383
469 384