author | tille <tille> | 2003-05-24 16:12:02 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-24 16:12:02 (UTC) |
commit | cc1aa3e178dff65854913bd5667579fc33ce707d (patch) (side-by-side diff) | |
tree | d37d7fd8fb3b9832c0825b015af862f2cc62f473 /noncore/settings/networksettings/ppp/kpppwidget.cpp | |
parent | 5667ded1d4583cfb79b2ddfd7aaae0e58ed6d552 (diff) | |
download | opie-cc1aa3e178dff65854913bd5667579fc33ce707d.zip opie-cc1aa3e178dff65854913bd5667579fc33ce707d.tar.gz opie-cc1aa3e178dff65854913bd5667579fc33ce707d.tar.bz2 |
saves config (still in the kppp way)
Diffstat (limited to 'noncore/settings/networksettings/ppp/kpppwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/ppp/kpppwidget.cpp | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/noncore/settings/networksettings/ppp/kpppwidget.cpp b/noncore/settings/networksettings/ppp/kpppwidget.cpp index 2f9feda..8d70cd4 100644 --- a/noncore/settings/networksettings/ppp/kpppwidget.cpp +++ b/noncore/settings/networksettings/ppp/kpppwidget.cpp @@ -155,13 +155,13 @@ KPPPWidget::KPPPWidget( QWidget *parent, const char *name, bool modal, WFlags fl // tl->addLayout(l3); // tl->addSpacing(5); // l3->addSpacing(10); // log = new QCheckBox(i18n("Show lo&g window"), this); // connect(log, SIGNAL(toggled(bool)), // this, SLOT(log_window_toggled(bool))); -// log->setChecked(gpppdata.get_show_log_window()); +// log->setChecked(PPPData::data()->get_show_log_window()); // l3->addWidget(log); // QWhatsThis::add(log, // i18n("<p>This controls whether a log window is shown.\n" // "A log window shows the communication between\n" // "<i>kppp</i> and your modem. This will help you\n" @@ -188,13 +188,13 @@ KPPPWidget::KPPPWidget( QWidget *parent, const char *name, bool modal, WFlags fl // connect( setup_b, SIGNAL(clicked()), SLOT(expandbutton())); // if(setup_b->sizeHint().width() > minw) // minw = setup_b->sizeHint().width(); -// if(gpppdata.access() != KConfig::ReadWrite) +// if(PPPData::data()->access() != KConfig::ReadWrite) // setup_b->setEnabled(false); // help_b = new QPushButton(i18n("&Help"), this); // connect( help_b, SIGNAL(clicked()), SLOT(helpbutton())); // KHelpMenu *helpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData(), true); @@ -288,13 +288,13 @@ KPPPWidget::KPPPWidget( QWidget *parent, const char *name, bool modal, WFlags fl // if(!m_strCmdlAccount.isEmpty()) { // m_bCmdlAccount = true; // kdDebug(5002) << "cmdl_account: " << m_bCmdlAccount << endl; // } // if(m_bCmdlAccount){ -// bool result = gpppdata.setAccount(m_strCmdlAccount); +// bool result = PPPData::data()->setAccount(m_strCmdlAccount); // if (!result){ // QString string; // string = i18n("No such Account:\n%1").arg(m_strCmdlAccount); // KMessageBox::error(this, string); // m_bCmdlAccount = false; // this->show(); @@ -360,62 +360,62 @@ void KPPPWidget::enterPressedInID() { void KPPPWidget::enterPressedInPW() { connect_b->setFocus(); } // triggered by the session manager void KPPPWidget::saveMyself() { - gpppdata.save(); + PPPData::data()->save(); } void KPPPWidget::shutDown() { interruptConnection(); saveMyself(); } void KPPPWidget::log_window_toggled(bool on) { - gpppdata.set_show_log_window(on); + PPPData::data()->set_show_log_window(on); } // void KPPPWidget::resetaccounts() { // connectto_c->clear(); -// int count = gpppdata.count(); +// int count = PPPData::data()->count(); // // enable/disable controls // connectto_c->setEnabled(count > 0); // connect_b->setEnabled(count > 0); // log->setEnabled(count > 0); // ID_Edit->setEnabled(count > 0); // PW_Edit->setEnabled(count > 0); // //load the accounts // for(int i=0; i < count; i++) { -// gpppdata.setAccountbyIndex(i); -// connectto_c->insertItem(gpppdata.accname()); +// PPPData::data()->setAccountbyIndex(i); +// connectto_c->insertItem(PPPData::data()->accname()); // } // //set the default account -// if(!gpppdata.defaultAccount().isEmpty()) { +// if(!PPPData::data()->defaultAccount().isEmpty()) { // for(int i=0; i < count; i++) -// if(gpppdata.defaultAccount() == connectto_c->text(i)) { +// if(PPPData::data()->defaultAccount() == connectto_c->text(i)) { // connectto_c->setCurrentItem(i); -// gpppdata.setAccountbyIndex(i); +// PPPData::data()->setAccountbyIndex(i); -// ID_Edit->setText(gpppdata.storedUsername()); -// PW_Edit->setText(gpppdata.storedPassword()); +// ID_Edit->setText(PPPData::data()->storedUsername()); +// PW_Edit->setText(PPPData::data()->storedPassword()); // } // } // else // if(count > 0) { -// gpppdata.setDefaultAccount(connectto_c->text(0)); -// gpppdata.save(); -// ID_Edit->setText(gpppdata.storedUsername()); -// PW_Edit->setText(gpppdata.storedPassword()); +// PPPData::data()->setDefaultAccount(connectto_c->text(0)); +// PPPData::data()->save(); +// ID_Edit->setText(PPPData::data()->storedUsername()); +// PW_Edit->setText(PPPData::data()->storedPassword()); // } // connect(ID_Edit, SIGNAL(textChanged(const QString &)), // this, SLOT(usernameChanged(const QString &))); // connect(PW_Edit, SIGNAL(textChanged(const QString &)), @@ -431,65 +431,65 @@ void KPPPWidget::log_window_toggled(bool on) { void KPPPWidget::interruptConnection() { // interrupt dial up // if (con->isVisible()) // emit con->cancelbutton(); // disconnect if online - if (gpppdata.pppdRunning()) + if (PPPData::data()->pppdRunning()) emit disconnect(); } void KPPPWidget::sigPPPDDied() { qDebug( "Received a SIGUSR1" ); // if we are not connected pppdpid is -1 so have have to check for that // in the followin line to make sure that we don't raise a false alarm // such as would be the case when the log file viewer exits. - if(gpppdata.pppdRunning() || gpppdata.pppdError()) { + if(PPPData::data()->pppdRunning() || PPPData::data()->pppdError()) { qDebug( "It was pppd that died" ); // when we killpppd() on Cancel in ConnectWidget // we set pppid to -1 so we won't // enter this block // just to be sure Modem::modem->removeSecret(AUTH_PAP); Modem::modem->removeSecret(AUTH_CHAP); - gpppdata.setpppdRunning(false); + PPPData::data()->setpppdRunning(false); qDebug( "Executing command on disconnect since pppd has died." ); QApplication::flushX(); - execute_command(gpppdata.command_on_disconnect()); + execute_command(PPPData::data()->command_on_disconnect()); // stopAccounting(); // con_win->stopClock(); // DockWidget::dock_widget->stop_stats(); // DockWidget::dock_widget->hide(); - if(!gpppdata.pppdError()) - gpppdata.setpppdError(E_PPPD_DIED); + if(!PPPData::data()->pppdError()) + PPPData::data()->setpppdError(E_PPPD_DIED); removedns(); Modem::modem->unlockdevice(); // con->pppdDied(); - if(!gpppdata.automatic_redial()) { + if(!PPPData::data()->automatic_redial()) { quit_b->setFocus(); show(); // con_win->stopClock(); // stopAccounting(); // con_win->hide(); // con->hide(); - gpppdata.setpppdRunning(false); + PPPData::data()->setpppdRunning(false); // // not in a signal handler !!! KNotifyClient::beep(); QString msg; - if (gpppdata.pppdError() == E_IF_TIMEOUT) + if (PPPData::data()->pppdError() == E_IF_TIMEOUT) msg = i18n("Timeout expired while waiting for the PPP interface " "to come up!"); else { msg = i18n("<p>The pppd daemon died unexpectedly!</p>"); Modem::modem->pppdExitStatus(); if (Modem::modem->lastStatus != 99) { // more recent pppds only @@ -504,28 +504,28 @@ void KPPPWidget::sigPPPDDied() { // if(QMessageBox::warning(0, msg, i18n("Error"), i18n("&OK"), i18n("&Details...")) == QMessageBox::No) // // PPPL_ShowLog(); // } else { /* reconnect on disconnect */ if (false){ qDebug( "Trying to reconnect... " ); - if(gpppdata.authMethod() == AUTH_PAP || - gpppdata.authMethod() == AUTH_CHAP || - gpppdata.authMethod() == AUTH_PAPCHAP) - Modem::modem->setSecret(gpppdata.authMethod(), - encodeWord(gpppdata.storedUsername()), - encodeWord(gpppdata.password())); + if(PPPData::data()->authMethod() == AUTH_PAP || + PPPData::data()->authMethod() == AUTH_CHAP || + PPPData::data()->authMethod() == AUTH_PAPCHAP) + Modem::modem->setSecret(PPPData::data()->authMethod(), + encodeWord(PPPData::data()->storedUsername()), + encodeWord(PPPData::data()->password())); // con_win->hide(); // con_win->stopClock(); // stopAccounting(); - gpppdata.setpppdRunning(false); + PPPData::data()->setpppdRunning(false); // not in a signal handler !!! KNotifyClient::beep(); emit cmdl_start(); } } - gpppdata.setpppdError(0); + PPPData::data()->setpppdError(0); } } // void KPPPWidget::sigChld() { // qDebug( "sigchld()" ); // // pid_t id = wait(0L); @@ -540,29 +540,29 @@ void KPPPWidget::sigPPPDDied() { // exit(1); // // } // } void KPPPWidget::newdefaultaccount(int i) { - gpppdata.setDefaultAccount(connectto_c->text(i)); - gpppdata.save(); - ID_Edit->setText(gpppdata.storedUsername()); - PW_Edit->setText(gpppdata.storedPassword()); + PPPData::data()->setDefaultAccount(connectto_c->text(i)); + PPPData::data()->save(); + ID_Edit->setText(PPPData::data()->storedUsername()); + PW_Edit->setText(PPPData::data()->storedPassword()); } void KPPPWidget::beginConnect() { // make sure to connect to the account that is selected in the combo box // (exeption: an account given by a command line argument) // if(!m_bCmdlAccount) { -// gpppdata.setAccount(connectto_c->currentText()); -// gpppdata.setPassword(PW_Edit->text()); +// PPPData::data()->setAccount(connectto_c->currentText()); +// PPPData::data()->setPassword(PW_Edit->text()); // } else { - gpppdata.setPassword(gpppdata.storedPassword()); + PPPData::data()->setPassword(PPPData::data()->storedPassword()); // } QFileInfo info(pppdPath()); if(!info.exists()){ QMessageBox::warning(this, "error", i18n("Cannot find the PPP daemon!\n" @@ -574,71 +574,71 @@ void KPPPWidget::beginConnect() { if(!info.isExecutable()){ QString string; string = i18n("kppp cannot execute:\n %1\n" "Please make sure that you have given kppp " "setuid permission and that " - "pppd is executable.").arg(gpppdata.pppdPath()); + "pppd is executable.").arg(PPPData::data()->pppdPath()); KMessageBox::error(this, string); return; } #endif - QFileInfo info2(gpppdata.modemDevice()); + QFileInfo info2(PPPData::data()->modemDevice()); if(!info2.exists()){ QString string; string = i18n("kppp can not find:\n %1\nPlease make sure you have setup " "your modem device properly " "and/or adjust the location of the modem device on " "the modem tab of " - "the setup dialog.").arg(gpppdata.modemDevice()); + "the setup dialog.").arg(PPPData::data()->modemDevice()); QMessageBox::warning(this, "error", string); return; } // if this is a PAP or CHAP account, ensure that username is // supplied - if(gpppdata.authMethod() == AUTH_PAP || - gpppdata.authMethod() == AUTH_CHAP || - gpppdata.authMethod() == AUTH_PAPCHAP ) { + if(PPPData::data()->authMethod() == AUTH_PAP || + PPPData::data()->authMethod() == AUTH_CHAP || + PPPData::data()->authMethod() == AUTH_PAPCHAP ) { if(ID_Edit->text().isEmpty()) { QMessageBox::warning(this,"error", i18n( "You have selected the authentication " "method PAP or CHAP. This requires that you " "supply a username and a password!")); return; } else { - if(!Modem::modem->setSecret(gpppdata.authMethod(), - encodeWord(gpppdata.storedUsername()), - encodeWord(gpppdata.password()))) { + if(!Modem::modem->setSecret(PPPData::data()->authMethod(), + encodeWord(PPPData::data()->storedUsername()), + encodeWord(PPPData::data()->password()))) { QString s; s = i18n("Cannot create PAP/CHAP authentication\n" "file \"%1\"").arg(PAP_AUTH_FILE); QMessageBox::warning(this, "error", s); return; } } } - if (gpppdata.phonenumber().isEmpty()) { + if (PPPData::data()->phonenumber().isEmpty()) { QString s = i18n("You must specify a telephone number!"); QMessageBox::warning(this, "error", s); return; } this->hide(); - QString tit = i18n("Connecting to: %1").arg(gpppdata.accname()); + QString tit = i18n("Connecting to: %1").arg(PPPData::data()->accname()); // con->setCaption(tit); // con->show(); - bool show_debug = gpppdata.get_show_log_window(); + bool show_debug = PPPData::data()->get_show_log_window(); // con->debug->setOn(show_debug); // toggle button debugwindow->clear(); if (!show_debug) debugwindow->hide(); else { debugwindow->show(); @@ -647,22 +647,22 @@ void KPPPWidget::beginConnect() { emit begin_connect(); } void KPPPWidget::disconnect() { - if (!gpppdata.command_before_disconnect().isEmpty()) { + if (!PPPData::data()->command_before_disconnect().isEmpty()) { // con_win->hide(); // con->show(); // con->setCaption(i18n("Disconnecting...")); // con->setMsg(i18n("Executing command before disconnection.")); qApp->processEvents(); QApplication::flushX(); // pid_t id = - execute_command(gpppdata.command_before_disconnect()); + execute_command(PPPData::data()->command_before_disconnect()); // int i, status; // do { // kapp->processEvents(); // i = waitpid(id, &status, WNOHANG); // usleep(500000); @@ -674,13 +674,13 @@ void KPPPWidget::disconnect() { qApp->processEvents(); // statdlg->stop_stats(); Modem::modem->killPPPDaemon(); QApplication::flushX(); - execute_command(gpppdata.command_on_disconnect()); + execute_command(PPPData::data()->command_on_disconnect()); Modem::modem->removeSecret(AUTH_PAP); Modem::modem->removeSecret(AUTH_CHAP); removedns(); Modem::modem->unlockdevice(); @@ -704,28 +704,28 @@ void KPPPWidget::disconnect() { // void KPPPWidget::helpbutton() { // kapp->invokeHelp(); // } void KPPPWidget::quitbutton() { - if(gpppdata.pppdRunning()) { + if(PPPData::data()->pppdRunning()) { int ok = QMessageBox::warning(this, i18n("Exiting kPPP will close your PPP Session."), i18n("Quit kPPP?")); if(ok == QMessageBox::Yes) { Modem::modem->killPPPDaemon(); QApplication::flushX(); - execute_command(gpppdata.command_on_disconnect()); + execute_command(PPPData::data()->command_on_disconnect()); removedns(); Modem::modem->unlockdevice(); } } else { - if (!gpppdata.accname().isEmpty() && !gpppdata.storePassword()) - gpppdata.setStoredPassword(""); + if (!PPPData::data()->accname().isEmpty() && !PPPData::data()->storePassword()) + PPPData::data()->setStoredPassword(""); } - gpppdata.save(); + PPPData::data()->save(); qApp->quit(); } // void KPPPWidget::rulesetLoadError() { // QMessageBox::warning(this,"error", ruleset_load_errmsg); @@ -733,31 +733,31 @@ void KPPPWidget::quitbutton() { // void KPPPWidget::startAccounting() { // // volume accounting // stats->totalbytes = 0; -// kdDebug() << "AcctEnabled: " << gpppdata.AcctEnabled() << endl; +// kdDebug() << "AcctEnabled: " << PPPData::data()->AcctEnabled() << endl; // // load the ruleset -// if(!gpppdata.AcctEnabled()) +// if(!PPPData::data()->AcctEnabled()) // return; -// QString d = AccountingBase::getAccountingFile(gpppdata.accountingFile()); +// QString d = AccountingBase::getAccountingFile(PPPData::data()->accountingFile()); // // if(::access(d.data(), X_OK) != 0) // acct = new Accounting(this, stats); // // else // // acct = new ExecutableAccounting(this); // // connect to the accounting object // connect(acct, SIGNAL(changed(QString, QString)), // con_win, SLOT(slotAccounting(QString, QString))); -// // if(!acct->loadRuleSet(gpppdata.accountingFile())) { +// // if(!acct->loadRuleSet(PPPData::data()->accountingFile())) { // // QString s= i18n("Can not load the accounting " -// // "ruleset \"%1\"!").arg(gpppdata.accountingFile()); +// // "ruleset \"%1\"!").arg(PPPData::data()->accountingFile()); // // starting the messagebox with a timer will prevent us // // from blocking the calling function ConnectWidget::timerEvent // ruleset_load_errmsg = s; // QTimer::singleShot(0, this, SLOT(rulesetLoadError())); // return; @@ -766,15 +766,15 @@ void KPPPWidget::quitbutton() { // // acct->slotStart(); // } // void KPPPWidget::stopAccounting() { // // store volume accounting // // if(stats->totalbytes != 0) -// // gpppdata.setTotalBytes(stats->totalbytes); +// // PPPData::data()->setTotalBytes(stats->totalbytes); -// if(!gpppdata.AcctEnabled()) +// if(!PPPData::data()->AcctEnabled()) // return; // // if(acct != 0) { // // acct->slotStop(); // // delete acct; // // acct = 0; @@ -789,22 +789,22 @@ void KPPPWidget::quitbutton() { // } // } void KPPPWidget::usernameChanged(const QString &) { // store username for later use - gpppdata.setStoredUsername(ID_Edit->text()); + PPPData::data()->setStoredUsername(ID_Edit->text()); } void KPPPWidget::passwordChanged(const QString &) { // store the password if so requested - if(gpppdata.storePassword()) - gpppdata.setStoredPassword(PW_Edit->text()); + if(PPPData::data()->storePassword()) + PPPData::data()->setStoredPassword(PW_Edit->text()); else - gpppdata.setStoredPassword(""); + PPPData::data()->setStoredPassword(""); } void KPPPWidget::setPW_Edit(const QString &pw) { PW_Edit->setText(pw); } @@ -838,13 +838,13 @@ QString KPPPWidget::encodeWord(const QString &s) { void KPPPWidget::showNews() { #ifdef KPPP_SHOW_NEWS /* * Introduce the QuickHelp feature to new users of this version */ #define QUICKHELP_HINT "Hint_QuickHelp" - if(gpppdata.readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { + if(PPPData::data()->readNumConfig(GENERAL_GRP, QUICKHELP_HINT, 0) == 0) { QDialog dlg(0, 0, true); dlg.setCaption(i18n("Recent Changes in KPPP")); QVBoxLayout *tl = new QVBoxLayout(&dlg, 10, 10); QHBoxLayout *l1 = new QHBoxLayout(10); QVBoxLayout *l2 = new QVBoxLayout(10); @@ -890,14 +890,14 @@ void KPPPWidget::showNews() { QWhatsThis::add(cb,tmp); QWhatsThis::add(l, tmp); dlg.exec(); if(cb->isChecked()) { - gpppdata.writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); - gpppdata.save(); + PPPData::data()->writeConfig(GENERAL_GRP, QUICKHELP_HINT, 1); + PPPData::data()->save(); } } #endif } |