From 37acc91cacd3f5c85e3254fcfd5794fcdcbadc27 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 18 May 2012 16:03:27 -0500 Subject: Can now add/remove realms to TDE config file --- src/bondwizard.cpp | 103 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 78 insertions(+), 25 deletions(-) (limited to 'src/bondwizard.cpp') diff --git a/src/bondwizard.cpp b/src/bondwizard.cpp index 3a7fc17..eeddfa6 100644 --- a/src/bondwizard.cpp +++ b/src/bondwizard.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -38,29 +39,45 @@ #include #include #include +#include +#include +#include #include #include +#include "bondintropage.h" #include "bondrealmpage.h" #include "bondfinishpage.h" #include "bondwizard.h" #include "bondwizard.moc" -BondWizard::BondWizard(TQWidget *parent, const char *name) - : KWizard(parent, name, true) { +BondWizard::BondWizard(LDAPRealmConfigList *realmlist, LDAPConfig *ldapconfig, TQWidget *parent, const char *name) + : KWizard(parent, name, true), m_realmList(realmlist), m_ldapConfig(ldapconfig) { - realmpage= new BondRealmPage(this); - addPage( realmpage, i18n( "Step 1: Introduction" ) ); + setCaption(i18n("LDAP Bonding Wizard")); + + intropage = new BondIntroPage(this); + addPage (intropage, i18n( "Step 1: Introduction" ) ); setHelpEnabled(TQWizard::page(0), false); - finishpage= new BondFinishPage(this); - addPage(finishpage, i18n( "Step 2: I want it my Way..." ) ); + realmpage = new BondRealmPage(this); + addPage (realmpage, i18n( "Step 2: Add New Realm" ) ); setHelpEnabled(TQWizard::page(1), false); - setFinishEnabled(TQWizard::page(1), true); + finishpage = new BondFinishPage(this); + addPage (finishpage, i18n( "Step 3: Bond to 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); + + setFinishEnabled(TQWizard::page(2), true); setPosition(); } @@ -70,12 +87,38 @@ BondWizard::~BondWizard() { void BondWizard::next() { - if(currentPage()==realmpage) { - realm_dirty=true; // set the dirty flag, changes done that need reverting - // realmpage->save(); + if (currentPage()==intropage) { TQWizard::next(); + realmpage->validateEntries(); } - if(currentPage()==finishpage) { + else if (currentPage()==realmpage) { + // Save realm information + LDAPRealmConfig realm; + + realm.name = realmpage->txtRealmName->text(); + realm.bonded = false; + realm.uid_offset = realmpage->txtUIDOffset->value(); + realm.gid_offset = realmpage->txtGIDOffset->value(); + realm.domain_mappings = TQStringList::split("\n", realmpage->txtDomains->text(), FALSE); + realm.kdc = realmpage->txtKDC->text(); + realm.kdc_port = realmpage->txtKDCPort->value(); + realm.admin_server = realmpage->txtAdminServer->text(); + realm.admin_server_port = realmpage->txtAdminServerPort->value(); + realm.pkinit_require_eku = realmpage->checkRequireEKU->isChecked(); + realm.pkinit_require_krbtgt_otherName = realmpage->checkRequireKrbtgtOtherName->isChecked(); + realm.win2k_pkinit = realmpage->checkWin2k->isChecked(); + realm.win2k_pkinit_require_binding = realmpage->checkWin2kPkinitRequireBinding->isChecked(); + + if (!m_realmList->contains(realm.name)) { + m_realmList->insert(realm.name, realm); + m_ldapConfig->save(); + TQWizard::next(); + } + else { + KMessageBox::error(this, i18n("The specified realm is already known to this system.

If the realm name is correct, please exit the Wizard and select 'Re-Bond to Realm' in the LDAP configuration module."), i18n("Duplicate Realm Entry Detected")); + } + } + if (currentPage()==finishpage) { finishButton()->setFocus(); } } @@ -90,20 +133,25 @@ void BondWizard::back() { bool BondWizard::askClose(){ TQString text; - if (currentPage()==realmpage) { - text = i18n("

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

" - "

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

"); - } else { - text = i18n("

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

" - "

If not, click Cancel to return and finish bonding.

"); - } - int status = KMessageBox::warningContinueCancel(this, text, i18n("All Changes Will Be Lost"), KStdGuiItem::quit()); - if(status==KMessageBox::Continue){ - setDefaults(); + if (currentPage()==intropage) { return true; - } else { - return false; + } + else { + if (currentPage()==realmpage) { + text = i18n("

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

" + "

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

"); + } else { + text = i18n("

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

" + "

If not, click Cancel to return and finish bonding.

"); + } + int status = KMessageBox::warningContinueCancel(this, text, i18n("All Changes Will Be Lost"), KStdGuiItem::quit()); + if(status==KMessageBox::Continue){ + setDefaults(); + return true; + } else { + return false; + } } } @@ -137,14 +185,19 @@ void BondWizard::setDefaults(){ /** there seems to be a bug in TQWizard, that makes this evil hack necessary */ void BondWizard::setPosition() { - TQSize hint = realmpage->sizeHint(); + 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()); -- cgit v1.2.1