Diffstat (limited to 'noncore/settings/networksettings/ppp/accounts.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/accounts.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/noncore/settings/networksettings/ppp/accounts.cpp b/noncore/settings/networksettings/ppp/accounts.cpp index 11d4739..3fa2f84 100644 --- a/noncore/settings/networksettings/ppp/accounts.cpp +++ b/noncore/settings/networksettings/ppp/accounts.cpp | |||
@@ -41,26 +41,26 @@ | |||
41 | //#include <kwin.h> | 41 | //#include <kwin.h> |
42 | //#include <kdialogbase.h> | 42 | //#include <kdialogbase.h> |
43 | #include <qvgroupbox.h> | 43 | #include <qvgroupbox.h> |
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 | ||
51 | void parseargs(char* buf, char** args); | 51 | void parseargs(char* buf, char** args); |
52 | 52 | ||
53 | AccountWidget::AccountWidget( QWidget *parent, const char *name ) | 53 | AccountWidget::AccountWidget( PPPData *pd, QWidget *parent, const char *name ) |
54 | : QWidget( parent, name ) | 54 | : QWidget( parent, name ), _pppdata(pd) |
55 | { | 55 | { |
56 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); | 56 | QVBoxLayout *l1 = new QVBoxLayout(this, 10, 10); |
57 | accountlist_l = new QListBox(this); | 57 | accountlist_l = new QListBox(this); |
58 | 58 | ||
59 | connect(accountlist_l, SIGNAL(highlighted(int)), | 59 | connect(accountlist_l, SIGNAL(highlighted(int)), |
60 | this, SLOT(slotListBoxSelect(int))); | 60 | this, SLOT(slotListBoxSelect(int))); |
61 | connect(accountlist_l, SIGNAL(selected(int)), | 61 | connect(accountlist_l, SIGNAL(selected(int)), |
62 | this, SLOT(editaccount())); | 62 | this, SLOT(editaccount())); |
63 | l1->addWidget(accountlist_l, 10); | 63 | l1->addWidget(accountlist_l, 10); |
64 | 64 | ||
65 | edit_b = new QPushButton(i18n("&Edit..."), this); | 65 | edit_b = new QPushButton(i18n("&Edit..."), this); |
66 | connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); | 66 | connect(edit_b, SIGNAL(clicked()), SLOT(editaccount())); |
@@ -143,50 +143,50 @@ AccountWidget::AccountWidget( QWidget *parent, const char *name ) | |||
143 | // reset->setEnabled(FALSE); | 143 | // reset->setEnabled(FALSE); |
144 | // connect(reset, SIGNAL(clicked()), | 144 | // connect(reset, SIGNAL(clicked()), |
145 | // this, SLOT(resetClicked())); | 145 | // this, SLOT(resetClicked())); |
146 | // l122->addWidget(reset); | 146 | // l122->addWidget(reset); |
147 | 147 | ||
148 | // log = new QPushButton(i18n("&View Logs"), this); | 148 | // log = new QPushButton(i18n("&View Logs"), this); |
149 | // connect(log, SIGNAL(clicked()), | 149 | // connect(log, SIGNAL(clicked()), |
150 | // this, SLOT(viewLogClicked())); | 150 | // this, SLOT(viewLogClicked())); |
151 | // l122->addWidget(log); | 151 | // l122->addWidget(log); |
152 | // l122->addStretch(1); | 152 | // l122->addStretch(1); |
153 | 153 | ||
154 | //load up account list from gppdata to the list box | 154 | //load up account list from gppdata to the list box |
155 | if(PPPData::data()->count() > 0) { | 155 | if(_pppdata->count() > 0) { |
156 | for(int i=0; i <= PPPData::data()->count()-1; i++) { | 156 | for(int i=0; i <= _pppdata->count()-1; i++) { |
157 | PPPData::data()->setAccountbyIndex(i); | 157 | _pppdata->setAccountbyIndex(i); |
158 | accountlist_l->insertItem(PPPData::data()->accname()); | 158 | accountlist_l->insertItem(_pppdata->accname()); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | // slotListBoxSelect(accountlist_l->currentItem()); | 162 | // slotListBoxSelect(accountlist_l->currentItem()); |
163 | qDebug("setting listview index to %i",PPPData::data()->currentAccountID() ); | 163 | qDebug("setting listview index to %i",_pppdata->currentAccountID() ); |
164 | accountlist_l->setCurrentItem( PPPData::data()->currentAccountID() ); | 164 | accountlist_l->setCurrentItem( _pppdata->currentAccountID() ); |
165 | // slotListBoxSelect( PPPData::data()->currentAccountID()); | 165 | // slotListBoxSelect( _pppdata->currentAccountID()); |
166 | 166 | ||
167 | l1->activate(); | 167 | l1->activate(); |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | 171 | ||
172 | void AccountWidget::slotListBoxSelect(int idx) { | 172 | void AccountWidget::slotListBoxSelect(int idx) { |
173 | delete_b->setEnabled((bool)(idx != -1)); | 173 | delete_b->setEnabled((bool)(idx != -1)); |
174 | edit_b->setEnabled((bool)(idx != -1)); | 174 | edit_b->setEnabled((bool)(idx != -1)); |
175 | copy_b->setEnabled((bool)(idx != -1)); | 175 | copy_b->setEnabled((bool)(idx != -1)); |
176 | if(idx!=-1) { | 176 | if(idx!=-1) { |
177 | qDebug("setting account to %i", idx); | 177 | qDebug("setting account to %i", idx); |
178 | QString account = PPPData::data()->accname(); | 178 | QString account = _pppdata->accname(); |
179 | PPPData::data()->setAccountbyIndex(accountlist_l->currentItem()); | 179 | _pppdata->setAccountbyIndex(accountlist_l->currentItem()); |
180 | // PPPData::data()->setAccount(account); | 180 | // _pppdata->setAccount(account); |
181 | } | 181 | } |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
185 | // void AccountWidget::viewLogClicked(){ | 185 | // void AccountWidget::viewLogClicked(){ |
186 | 186 | ||
187 | // QApplication::flushX(); | 187 | // QApplication::flushX(); |
188 | // if(fork() == 0) { | 188 | // if(fork() == 0) { |
189 | // setgid(getgid()); | 189 | // setgid(getgid()); |
190 | // setuid(getuid()); | 190 | // setuid(getuid()); |
191 | // system("kppplogview -kppp"); | 191 | // system("kppplogview -kppp"); |
192 | // _exit(0); | 192 | // _exit(0); |
@@ -205,153 +205,153 @@ void AccountWidget::slotListBoxSelect(int idx) { | |||
205 | // // emit resetCosts(accountlist_l->text(accountlist_l->currentItem())); | 205 | // // emit resetCosts(accountlist_l->text(accountlist_l->currentItem())); |
206 | // // costedit->setText("0"); | 206 | // // costedit->setText("0"); |
207 | // // } | 207 | // // } |
208 | 208 | ||
209 | // // if(what && QueryReset::VOLUME) { | 209 | // // if(what && QueryReset::VOLUME) { |
210 | // // emit resetVolume(accountlist_l->text(accountlist_l->currentItem())); | 210 | // // emit resetVolume(accountlist_l->text(accountlist_l->currentItem())); |
211 | // // voledit->setText(prettyPrintVolume(0)); | 211 | // // voledit->setText(prettyPrintVolume(0)); |
212 | // // } | 212 | // // } |
213 | // } | 213 | // } |
214 | 214 | ||
215 | 215 | ||
216 | void AccountWidget::editaccount() { | 216 | void AccountWidget::editaccount() { |
217 | PPPData::data()->setAccount(accountlist_l->text(accountlist_l->currentItem())); | 217 | _pppdata->setAccount(accountlist_l->text(accountlist_l->currentItem())); |
218 | 218 | ||
219 | int result = doTab(); | 219 | int result = doTab(); |
220 | 220 | ||
221 | if(result == QDialog::Accepted) { | 221 | if(result == QDialog::Accepted) { |
222 | accountlist_l->changeItem(PPPData::data()->accname(),accountlist_l->currentItem()); | 222 | accountlist_l->changeItem(_pppdata->accname(),accountlist_l->currentItem()); |
223 | // emit resetaccounts(); | 223 | // emit resetaccounts(); |
224 | PPPData::data()->save(); | 224 | _pppdata->save(); |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | 228 | ||
229 | void AccountWidget::newaccount() { | 229 | void AccountWidget::newaccount() { |
230 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 230 | if(accountlist_l->count() == MAX_ACCOUNTS) { |
231 | QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); | 231 | QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); |
232 | return; | 232 | return; |
233 | } | 233 | } |
234 | 234 | ||
235 | int result; | 235 | int result; |
236 | // int query = QMessageBox::information(this, | 236 | // int query = QMessageBox::information(this, |
237 | // i18n("Do you want to use the wizard to create the new account or the " | 237 | // i18n("Do you want to use the wizard to create the new account or the " |
238 | // "standard, dialog-based setup?\n" | 238 | // "standard, dialog-based setup?\n" |
239 | // "The wizard is easier and sufficient in most cases. If you need " | 239 | // "The wizard is easier and sufficient in most cases. If you need " |
240 | // "very special settings, you might want to try the standard, " | 240 | // "very special settings, you might want to try the standard, " |
241 | // "dialog-based setup."), | 241 | // "dialog-based setup."), |
242 | // i18n("Create New Account"), | 242 | // i18n("Create New Account"), |
243 | // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel")); | 243 | // i18n("Wizard"), i18n("Dialog Setup"), i18n("Cancel")); |
244 | 244 | ||
245 | // switch(query) { | 245 | // switch(query) { |
246 | // case QMessageBox::Yes: | 246 | // case QMessageBox::Yes: |
247 | // { | 247 | // { |
248 | // if (PPPData::data()->newaccount() == -1) | 248 | // if (_pppdata->newaccount() == -1) |
249 | // return; | 249 | // return; |
250 | // // ProviderDB pdb(this); | 250 | // // ProviderDB pdb(this); |
251 | // // result = pdb.exec(); | 251 | // // result = pdb.exec(); |
252 | // break; | 252 | // break; |
253 | // } | 253 | // } |
254 | // case QMessageBox::No: | 254 | // case QMessageBox::No: |
255 | if (PPPData::data()->newaccount() == -1){ | 255 | if (_pppdata->newaccount() == -1){ |
256 | qDebug("PPPData::data()->newaccount() == -1"); | 256 | qDebug("_pppdata->newaccount() == -1"); |
257 | return; | 257 | return; |
258 | } | 258 | } |
259 | result = doTab(); | 259 | result = doTab(); |
260 | // break; | 260 | // break; |
261 | // default: | 261 | // default: |
262 | // return; | 262 | // return; |
263 | // } | 263 | // } |
264 | 264 | ||
265 | if(result == QDialog::Accepted) { | 265 | if(result == QDialog::Accepted) { |
266 | accountlist_l->insertItem(PPPData::data()->accname()); | 266 | accountlist_l->insertItem(_pppdata->accname()); |
267 | accountlist_l->setSelected(accountlist_l->findItem(PPPData::data()->accname()), | 267 | accountlist_l->setSelected(accountlist_l->findItem(_pppdata->accname()), |
268 | true); | 268 | true); |
269 | // emit resetaccounts(); | 269 | // emit resetaccounts(); |
270 | PPPData::data()->save(); | 270 | _pppdata->save(); |
271 | } else | 271 | } else |
272 | PPPData::data()->deleteAccount(); | 272 | _pppdata->deleteAccount(); |
273 | } | 273 | } |
274 | 274 | ||
275 | 275 | ||
276 | void AccountWidget::copyaccount() { | 276 | void AccountWidget::copyaccount() { |
277 | if(accountlist_l->count() == MAX_ACCOUNTS) { | 277 | if(accountlist_l->count() == MAX_ACCOUNTS) { |
278 | QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); | 278 | QMessageBox::information(this, "sorry", i18n("Maximum number of accounts reached.")); |
279 | return; | 279 | return; |
280 | } | 280 | } |
281 | 281 | ||
282 | if(accountlist_l->currentItem()<0) { | 282 | if(accountlist_l->currentItem()<0) { |
283 | QMessageBox::information(this, "sorry", i18n("No account selected.")); | 283 | QMessageBox::information(this, "sorry", i18n("No account selected.")); |
284 | return; | 284 | return; |
285 | } | 285 | } |
286 | 286 | ||
287 | PPPData::data()->copyaccount(accountlist_l->currentItem()); | 287 | _pppdata->copyaccount(accountlist_l->currentItem()); |
288 | 288 | ||
289 | accountlist_l->insertItem(PPPData::data()->accname()); | 289 | accountlist_l->insertItem(_pppdata->accname()); |
290 | // emit resetaccounts(); | 290 | // emit resetaccounts(); |
291 | PPPData::data()->save(); | 291 | _pppdata->save(); |
292 | } | 292 | } |
293 | 293 | ||
294 | 294 | ||
295 | void AccountWidget::deleteaccount() { | 295 | void AccountWidget::deleteaccount() { |
296 | 296 | ||
297 | QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?") | 297 | QString s = i18n("Are you sure you want to delete\nthe account \"%1\"?") |
298 | .arg(accountlist_l->text(accountlist_l->currentItem())); | 298 | .arg(accountlist_l->text(accountlist_l->currentItem())); |
299 | 299 | ||
300 | if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes) | 300 | if(QMessageBox::warning(this, s, i18n("Confirm")) != QMessageBox::Yes) |
301 | return; | 301 | return; |
302 | 302 | ||
303 | if(PPPData::data()->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) | 303 | if(_pppdata->deleteAccount(accountlist_l->text(accountlist_l->currentItem()))) |
304 | accountlist_l->removeItem(accountlist_l->currentItem()); | 304 | accountlist_l->removeItem(accountlist_l->currentItem()); |
305 | 305 | ||
306 | emit resetaccounts(); | 306 | emit resetaccounts(); |
307 | PPPData::data()->save(); | 307 | _pppdata->save(); |
308 | 308 | ||
309 | slotListBoxSelect(accountlist_l->currentItem()); | 309 | slotListBoxSelect(accountlist_l->currentItem()); |
310 | 310 | ||
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | int AccountWidget::doTab(){ | 314 | int AccountWidget::doTab(){ |
315 | QDialog *dlg = new QDialog( this, "newAccount", true ); | 315 | QDialog *dlg = new QDialog( this, "newAccount", true ); |
316 | QVBoxLayout *layout = new QVBoxLayout( dlg ); | 316 | QVBoxLayout *layout = new QVBoxLayout( dlg ); |
317 | layout->setSpacing( 0 ); | 317 | layout->setSpacing( 0 ); |
318 | layout->setMargin( 1 ); | 318 | layout->setMargin( 1 ); |
319 | 319 | ||
320 | tabWindow = new QTabWidget( dlg, "tabWindow" ); | 320 | tabWindow = new QTabWidget( dlg, "tabWindow" ); |
321 | layout->addWidget( tabWindow ); | 321 | layout->addWidget( tabWindow ); |
322 | 322 | ||
323 | bool isnewaccount; | 323 | bool isnewaccount; |
324 | 324 | ||
325 | if(PPPData::data()->accname().isEmpty()) { | 325 | if(_pppdata->accname().isEmpty()) { |
326 | dlg->setCaption(i18n("New Account")); | 326 | dlg->setCaption(i18n("New Account")); |
327 | isnewaccount = true; | 327 | isnewaccount = true; |
328 | } else { | 328 | } else { |
329 | QString tit = i18n("Edit Account: "); | 329 | QString tit = i18n("Edit Account: "); |
330 | tit += PPPData::data()->accname(); | 330 | tit += _pppdata->accname(); |
331 | dlg->setCaption(tit); | 331 | dlg->setCaption(tit); |
332 | isnewaccount = false; | 332 | isnewaccount = false; |
333 | } | 333 | } |
334 | 334 | ||
335 | dial_w = new DialWidget( tabWindow, isnewaccount, "Dial Setup"); | 335 | dial_w = new DialWidget( _pppdata, tabWindow, isnewaccount, "Dial Setup"); |
336 | tabWindow->addTab( dial_w, i18n("Dial") ); | 336 | tabWindow->addTab( dial_w, i18n("Dial") ); |
337 | ip_w = new IPWidget( tabWindow, isnewaccount, i18n("IP Setup")); | 337 | ip_w = new IPWidget( _pppdata, tabWindow, isnewaccount, i18n("IP Setup")); |
338 | tabWindow->addTab( ip_w, i18n("IP") ); | 338 | tabWindow->addTab( ip_w, i18n("IP") ); |
339 | gateway_w = new GatewayWidget( tabWindow, isnewaccount, i18n("Gateway Setup")); | 339 | gateway_w = new GatewayWidget( _pppdata, tabWindow, isnewaccount, i18n("Gateway Setup")); |
340 | tabWindow->addTab( gateway_w, i18n("Gateway") ); | 340 | tabWindow->addTab( gateway_w, i18n("Gateway") ); |
341 | dns_w = new DNSWidget( tabWindow, isnewaccount, i18n("DNS Servers") ); | 341 | dns_w = new DNSWidget( _pppdata, tabWindow, isnewaccount, i18n("DNS Servers") ); |
342 | tabWindow->addTab( dns_w, i18n("DNS") ); | 342 | tabWindow->addTab( dns_w, i18n("DNS") ); |
343 | script_w = new ScriptWidget( tabWindow, isnewaccount, i18n("Edit Login Script")); | 343 | script_w = new ScriptWidget( _pppdata, tabWindow, isnewaccount, i18n("Edit Login Script")); |
344 | tabWindow->addTab( script_w, i18n("Login Script") ); | 344 | tabWindow->addTab( script_w, i18n("Login Script") ); |
345 | ExecWidget *exec_w = new ExecWidget( tabWindow, isnewaccount, i18n("Execute Programs")); | 345 | ExecWidget *exec_w = new ExecWidget( _pppdata, tabWindow, isnewaccount, i18n("Execute Programs")); |
346 | tabWindow->addTab( exec_w, i18n("Execute") ); | 346 | tabWindow->addTab( exec_w, i18n("Execute") ); |
347 | // acct = new AccountingSelector( tabWindow, isnewaccount ); | 347 | // acct = new AccountingSelector( tabWindow, isnewaccount ); |
348 | // tabWindow->addTab( acct, i18n("Accounting")); | 348 | // tabWindow->addTab( acct, i18n("Accounting")); |
349 | 349 | ||
350 | int result = 0; | 350 | int result = 0; |
351 | bool ok = false; | 351 | bool ok = false; |
352 | qDebug("AccountWidget::doTab dlg->showMinimized"); | 352 | qDebug("AccountWidget::doTab dlg->showMinimized"); |
353 | dlg->showMinimized(); | 353 | dlg->showMinimized(); |
354 | while (!ok){ | 354 | while (!ok){ |
355 | 355 | ||
356 | result = dlg->exec(); | 356 | result = dlg->exec(); |
357 | ok = true; | 357 | ok = true; |