/*************************************************************************** * Copyright (C) 2012 by Timothy Pearson * * kb9vqf@pearsoncomputing.net * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "realmintropage.h" #include "realmconfigpage.h" #include "realmfinishpage.h" #include "realmwizard.h" #include "realmwizard.moc" RealmWizard::RealmWizard(LDAPController* controller, TQWidget *parent, const char *name) : KWizard(parent, name, true), m_controller(controller) { setCaption(i18n("LDAP Realm Wizard")); intropage = new RealmIntroPage(this); addPage (intropage, i18n( "Step 1: Introduction" ) ); setHelpEnabled(TQWizard::page(0), false); realmpage = new RealmConfigPage(this); addPage (realmpage, i18n( "Step 2: Set Up New Realm" ) ); setHelpEnabled(TQWizard::page(1), false); finishpage = new RealmFinishPage(this); addPage (finishpage, i18n( "Step 3: Initialize New Realm" ) ); setHelpEnabled(TQWizard::page(2), false); // // // Set up some defaults // realmpage->txtKDCPort->setValue(88); // realmpage->txtAdminServerPort->setValue(749); // realmpage->txtUIDOffset->setValue(5000); // realmpage->txtGIDOffset->setValue(5000); // // // Other setup // finishpage->ldapAdminRealm->setEnabled(false); setFinishEnabled(TQWizard::page(2), true); setPosition(); } RealmWizard::~RealmWizard() { } void RealmWizard::next() { if (currentPage()==intropage) { TQWizard::next(); // RAJA FIXME // realmpage->validateEntries(); } else if (currentPage()==realmpage) { // Save realm information // RAJA FIXME TQWizard::next(); } if (currentPage()==finishpage) { backButton()->setEnabled(false); finishButton()->setFocus(); } } void RealmWizard::slotNext() { TQWizard::next(); } void RealmWizard::back() { TQWizard::back(); } bool RealmWizard::askClose(){ TQString text; if (currentPage()==intropage) { return true; } else { if (currentPage()==realmpage) { text = i18n("

Are you sure you want to quit the LDAP Realm Wizard?

" "

If yes, click Quit and all changes will be lost." "
If not, click Cancel to return and finish your setup.

"); } else if (currentPage()==finishpage) { // RAJA FIXME text = i18n("

Are you sure you want to quit the LDAP Realm Wizard?

" "

If yes, click Quit and the new realm will remain deactivated pending bonding." "
If not, click Cancel to return and finish your setup.

"); } else { text = i18n("

Are you sure you want to quit the LDAP Realm Wizard?

" "

If not, click Cancel to return and finish setup.

"); } int status = KMessageBox::warningContinueCancel(this, text, i18n("All Changes Will Be Lost"), KStdGuiItem::quit()); if(status==KMessageBox::Continue){ setDefaults(); return true; } else { return false; } } } /** the cancel button is connected to the reject() slot of TQDialog, * so we have to reimplement this here to add a dialogbox to ask if we * really want to quit the wizard. */ void RealmWizard::reject(){ if (askClose()){ done(-1); } } void RealmWizard::closeEvent(TQCloseEvent* e){ if ( askClose() ) done(0); else e->ignore(); } /** maybe call a dialog that the wizard has finished. */ void RealmWizard::accept(){ // Try to create realm TQString errorString; // RAJA FIXME // if (m_ldapConfig->bondRealm(m_finalRealm, finishpage->ldapAdminUsername->text(), finishpage->ldapAdminPassword->password(), finishpage->ldapAdminRealm->text(), &errorString) == 0) { done(0); // } // else { // KMessageBox::error(this, i18n("Unable to create new realm!

Details: %1").arg(errorString), i18n("Unable to create new realm")); // } } /** calls all save functions after resetting all features/ OS/ theme selections to Trinity default */ void RealmWizard::setDefaults(){ // if(realm_dirty) // realmpage->save(false); } /** there seems to be a bug in TQWizard, that makes this evil hack necessary */ void RealmWizard::setPosition() { TQSize hint = intropage->sizeHint(); TQSize realm_size = realmpage->sizeHint(); TQSize finish_size = finishpage->sizeHint(); // get the width of the broadest child-widget if ( hint.width() < realm_size.width() ) hint.setWidth(realm_size.width()); if ( hint.width() < finish_size.width() ) hint.setWidth(finish_size.width()); // get the height of the highest child-widget if ( hint.height() < realm_size.height() ) hint.setHeight(realm_size.height()); if ( hint.height() < finish_size.height() ) hint.setHeight(finish_size.height()); // set the position TQRect rect = KGlobalSettings::desktopGeometry(TQCursor::pos()); int w = rect.x() + (rect.width() - hint.width())/2 - 9; int h = rect.y() + (rect.height() - hint.height())/2; move(w, h); }