diff options
author | Timothy Pearson <[email protected]> | 2012-05-18 16:03:27 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-05-18 16:03:27 -0500 |
commit | 37acc91cacd3f5c85e3254fcfd5794fcdcbadc27 (patch) | |
tree | 8a724d562c4bf6b2024340f507f58b1d4cf82af6 /src | |
parent | 96936f9f1272296b22c7ed6d6e68e944ba78a6b6 (diff) | |
download | kcmldap-37acc91cacd3f5c85e3254fcfd5794fcdcbadc27.tar.gz kcmldap-37acc91cacd3f5c85e3254fcfd5794fcdcbadc27.zip |
Can now add/remove realms to TDE config file
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/bondfinishpage.cpp | 2 | ||||
-rw-r--r-- | src/bondintropage.cpp | 45 | ||||
-rw-r--r-- | src/bondintropage.h | 41 | ||||
-rw-r--r-- | src/bondintropagedlg.ui | 118 | ||||
-rw-r--r-- | src/bondrealmpage.cpp | 23 | ||||
-rw-r--r-- | src/bondrealmpage.h | 8 | ||||
-rw-r--r-- | src/bondrealmpagedlg.ui | 201 | ||||
-rw-r--r-- | src/bondwizard.cpp | 103 | ||||
-rw-r--r-- | src/bondwizard.h | 8 | ||||
-rw-r--r-- | src/ldap.cpp | 68 | ||||
-rw-r--r-- | src/ldap.h | 4 | ||||
-rw-r--r-- | src/ldapconfigbase.ui | 2 |
13 files changed, 582 insertions, 43 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 9ac5f38..7e6c5d2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,7 +4,7 @@ METASOURCES = AUTO # Install this plugin in the KDE modules directory kde_module_LTLIBRARIES = kcm_ldap.la -kcm_ldap_la_SOURCES = ldap.cpp ldapconfigbase.ui realmpropertiesdialog.cpp realmpropertiesbase.ui bondrealmpage.cpp bondrealmpagedlg.ui bondfinishpage.cpp bondfinishpagedlg.ui bondwizard.cpp +kcm_ldap_la_SOURCES = ldap.cpp ldapconfigbase.ui realmpropertiesdialog.cpp realmpropertiesbase.ui bondintropage.cpp bondintropagedlg.ui bondrealmpage.cpp bondrealmpagedlg.ui bondfinishpage.cpp bondfinishpagedlg.ui bondwizard.cpp kcm_ldap_la_LIBADD = -lkio $(LIB_TDEUI) kcm_ldap_la_LDFLAGS = -avoid-version -module -no-undefined \ $(all_libraries) diff --git a/src/bondfinishpage.cpp b/src/bondfinishpage.cpp index cec7bfe..813d06c 100644 --- a/src/bondfinishpage.cpp +++ b/src/bondfinishpage.cpp @@ -35,7 +35,7 @@ BondFinishPage::BondFinishPage(TQWidget *parent, const char *name ) : BondFinishPageDlg(parent,name) { - px_introSidebar->setPixmap(UserIcon("step2.png")); + px_introSidebar->setPixmap(UserIcon("step3.png")); } BondFinishPage::~BondFinishPage(){ diff --git a/src/bondintropage.cpp b/src/bondintropage.cpp new file mode 100644 index 0000000..34b6ab0 --- /dev/null +++ b/src/bondintropage.cpp @@ -0,0 +1,45 @@ +/*************************************************************************** + * Copyright (C) 2012 by Timothy Pearson * + * [email protected] * + * * + * 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 <tqstringlist.h> +#include <tqlabel.h> +#include <tqmap.h> + +#include <kapplication.h> +#include <ksimpleconfig.h> +#include <klocale.h> +#include <kdebug.h> +#include <kstandarddirs.h> +#include <kiconloader.h> +#include <dcopclient.h> +#include <kprocess.h> + +#include "bondintropage.h" + +BondIntroPage::BondIntroPage(TQWidget *parent, const char *name ) : BondIntroPageDlg(parent,name) { + + px_introSidebar->setPixmap(UserIcon("step1.png")); +} + +BondIntroPage::~BondIntroPage(){ + // +} + +#include "bondintropage.moc" diff --git a/src/bondintropage.h b/src/bondintropage.h new file mode 100644 index 0000000..b172cb9 --- /dev/null +++ b/src/bondintropage.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (C) 2012 by Timothy Pearson * + * [email protected] * + * * + * 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. * + ***************************************************************************/ + +#ifndef BONDINTROPAGE_H +#define BONDINTROPAGE_H + +#include "ldap.h" + +#include "bondintropagedlg.h" + +class TQStringList; + +/**Abstract class for the first wizard page. Sets the according selection on save() + *@author Timothy Pearson + */ + +class BondIntroPage : public BondIntroPageDlg { + Q_OBJECT +public: + BondIntroPage(TQWidget *parent=0, const char *name=0); + ~BondIntroPage(); +}; + +#endif diff --git a/src/bondintropagedlg.ui b/src/bondintropagedlg.ui new file mode 100644 index 0000000..7ca856e --- /dev/null +++ b/src/bondintropagedlg.ui @@ -0,0 +1,118 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> +<class>BondIntroPageDlg</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>BondIntroPageDlg</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>678</width> + <height>452</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" rowspan="9" colspan="1"> + <property name="name"> + <cstring>px_introSidebar</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>170</width> + <height>430</height> + </size> + </property> + <property name="frameShape"> + <enum>Panel</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="scaledContents"> + <bool>true</bool> + </property> + <property name="indent"> + <number>0</number> + </property> + </widget> + <widget class="TQLabel" row="0" column="1"> + <property name="name"> + <cstring>txt_welcome</cstring> + </property> + <property name="text"> + <string><h3>Welcome to the TDE LDAP Bonding Wizard!</h3></string> + </property> + </widget> + <widget class="TQLabel" row="1" column="1"> + <property name="name"> + <cstring>TextLabel6</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><p>This Wizard will help you bond your machine to an LDAP realm in three quick, easy steps.</p> + <p>Please note that you will need administrative access to the LDAP realm you will be bonding with.</p> + <p>If you wish to quit the Wizard, click <b>Cancel</b> at any time.</p></string> + </property> + <property name="textFormat"> + <enum>RichText</enum> + </property> + <property name="alignment"> + <set>WordBreak|AlignTop|AlignLeft</set> + </property> + <property name="vAlign" stdset="0"> + </property> + <property name="wordwrap" stdset="0"> + </property> + </widget> + <spacer row="2" column="1"> + <property name="name"> + <cstring>Spacer6</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>30</height> + </size> + </property> + </spacer> + <spacer row="7" column="1"> + <property name="name"> + <cstring>Spacer5</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + </spacer> + </grid> +</widget> +<layoutdefaults spacing="3" margin="6"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI> diff --git a/src/bondrealmpage.cpp b/src/bondrealmpage.cpp index 09d9d31..020c5a5 100644 --- a/src/bondrealmpage.cpp +++ b/src/bondrealmpage.cpp @@ -30,16 +30,35 @@ #include <kiconloader.h> #include <dcopclient.h> #include <kprocess.h> +#include <klineedit.h> +#include <kwizard.h> #include "bondrealmpage.h" BondRealmPage::BondRealmPage(TQWidget *parent, const char *name ) : BondRealmPageDlg(parent,name) { - px_introSidebar->setPixmap(UserIcon("step1.png")); + px_introSidebar->setPixmap(UserIcon("step2.png")); + + connect(txtRealmName, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(validateEntries())); + connect(txtKDC, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(validateEntries())); + connect(txtAdminServer, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(validateEntries())); + + m_parentWizard = dynamic_cast<KWizard*>(parent); } -BondRealmPage::~BondRealmPage(){ +BondRealmPage::~BondRealmPage() { // } +void BondRealmPage::validateEntries() { + if (m_parentWizard) { + if ((txtRealmName->text() != "") && (txtKDC->text() != "") && (txtAdminServer->text() != "")) { + m_parentWizard->nextButton()->setEnabled(true); + } + else { + m_parentWizard->nextButton()->setEnabled(false); + } + } +} + #include "bondrealmpage.moc" diff --git a/src/bondrealmpage.h b/src/bondrealmpage.h index 79a0153..5117d7e 100644 --- a/src/bondrealmpage.h +++ b/src/bondrealmpage.h @@ -26,6 +26,7 @@ #include "bondrealmpagedlg.h" class TQStringList; +class KWizard; /**Abstract class for the first wizard page. Sets the according selection on save() *@author Timothy Pearson @@ -33,11 +34,16 @@ class TQStringList; class BondRealmPage : public BondRealmPageDlg { Q_OBJECT + public: BondRealmPage(TQWidget *parent=0, const char *name=0); ~BondRealmPage(); - LDAPRealmConfig m_realmConfig; +public slots: + void validateEntries(); + +private: + KWizard* m_parentWizard; }; #endif diff --git a/src/bondrealmpagedlg.ui b/src/bondrealmpagedlg.ui index e888ea5..3072f75 100644 --- a/src/bondrealmpagedlg.ui +++ b/src/bondrealmpagedlg.ui @@ -47,7 +47,206 @@ <number>0</number> </property> </widget> - <spacer row="2" column="1"> + <widget class="TQGroupBox" row="0" column="1"> + <property name="name"> + <cstring>groupRealmInfo</cstring> + </property> + <property name="title"> + <string>Basic Realm Information (required)</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Realm Name</string> + </property> + </widget> + <widget class="KLineEdit" row="0" column="1" colspan="3"> + <property name="name"> + <cstring>txtRealmName</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Key Distribution Server [KDC]</string> + </property> + </widget> + <widget class="KLineEdit" row="1" column="1"> + <property name="name"> + <cstring>txtKDC</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="2"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>port</string> + </property> + </widget> + <widget class="KIntNumInput" row="1" column="3"> + <property name="name"> + <cstring>txtKDCPort</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="maxValue"> + <number>99999</number> + </property> + </widget> + <widget class="TQLabel" row="2" column="0"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Administration Server</string> + </property> + </widget> + <widget class="KLineEdit" row="2" column="1"> + <property name="name"> + <cstring>txtAdminServer</cstring> + </property> + </widget> + <widget class="TQLabel" row="2" column="2"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>port</string> + </property> + </widget> + <widget class="KIntNumInput" row="2" column="3"> + <property name="name"> + <cstring>txtAdminServerPort</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + <property name="maxValue"> + <number>99999</number> + </property> + </widget> + <widget class="TQLabel" row="3" column="0"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>UID offset</string> + </property> + </widget> + <widget class="KIntNumInput" row="3" column="1" colspan="3"> + <property name="name"> + <cstring>txtUIDOffset</cstring> + </property> + <property name="minValue"> + <number>100</number> + </property> + <property name="maxValue"> + <number>99999</number> + </property> + </widget> + <widget class="TQLabel" row="4" column="0"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>GID offset</string> + </property> + </widget> + <widget class="KIntNumInput" row="4" column="1" colspan="3"> + <property name="name"> + <cstring>txtGIDOffset</cstring> + </property> + <property name="minValue"> + <number>100</number> + </property> + <property name="maxValue"> + <number>99999</number> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="1" column="1"> + <property name="name"> + <cstring>groupDomainAliases</cstring> + </property> + <property name="title"> + <string>Realm Domain Aliases (optional)</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Enter each domain alias on a new line below</string> + </property> + </widget> + <widget class="KTextEdit" row="1" column="0"> + <property name="name"> + <cstring>txtDomains</cstring> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="2" column="1"> + <property name="name"> + <cstring>groupAdvancedPKInit</cstring> + </property> + <property name="title"> + <string>Advanced PKInit Settings (optional)</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQCheckBox" row="0" column="0"> + <property name="name"> + <cstring>checkRequireEKU</cstring> + </property> + <property name="text"> + <string>Require EKU</string> + </property> + </widget> + <widget class="TQCheckBox" row="0" column="1"> + <property name="name"> + <cstring>checkRequireKrbtgtOtherName</cstring> + </property> + <property name="text"> + <string>Require KRB TGT Other Name</string> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="0"> + <property name="name"> + <cstring>checkWin2k</cstring> + </property> + <property name="text"> + <string>Windows 2000 Compatibility</string> + </property> + </widget> + <widget class="TQCheckBox" row="1" column="1"> + <property name="name"> + <cstring>checkWin2kPkinitRequireBinding</cstring> + </property> + <property name="text"> + <string>Require Windows 2000 Binding</string> + </property> + </widget> + </grid> + </widget> + <spacer row="3" column="1"> <property name="name"> <cstring>Spacer6</cstring> </property> 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 <tqfile.h> #include <tqtimer.h> #include <tqcursor.h> +#include <tqspinbox.h> #include <ksimpleconfig.h> #include <kglobal.h> @@ -38,29 +39,45 @@ #include <krun.h> #include <kmessagebox.h> #include <kconfig.h> +#include <knuminput.h> +#include <klineedit.h> +#include <ktextedit.h> #include <stdlib.h> #include <kdebug.h> +#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("<qt><b>The specified realm is already known to this system.</b><p>If the realm name is correct, please exit the Wizard and select 'Re-Bond to Realm' in the LDAP configuration module.</qt>"), 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("<p>Are you sure you want to quit the LDAP Bonding Wizard?</p>" - "<p>If yes, click <b>Quit</b> and all changes will be lost." - "<br>If not, click <b>Cancel</b> to return and finish your setup.</p>"); - } else { - text = i18n("<p>Are you sure you want to quit the LDAP Bonding Wizard?</p>" - "<p>If not, click <b>Cancel</b> to return and finish bonding.</p>"); - } - 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("<p>Are you sure you want to quit the LDAP Bonding Wizard?</p>" + "<p>If yes, click <b>Quit</b> and all changes will be lost." + "<br>If not, click <b>Cancel</b> to return and finish your setup.</p>"); + } else { + text = i18n("<p>Are you sure you want to quit the LDAP Bonding Wizard?</p>" + "<p>If not, click <b>Cancel</b> to return and finish bonding.</p>"); + } + 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()); diff --git a/src/bondwizard.h b/src/bondwizard.h index 0cdfafd..4296bb7 100644 --- a/src/bondwizard.h +++ b/src/bondwizard.h @@ -28,8 +28,11 @@ #include <kapplication.h> #include <kwizard.h> +#include "ldap.h" + /** prototypes */ class KLanguageCombo; +class BondIntroPage; class BondRealmPage; class BondFinishPage; @@ -38,7 +41,7 @@ class BondWizard : public KWizard { Q_OBJECT public: /** construtor */ - BondWizard(TQWidget* parent=0, const char *name=0); + BondWizard(LDAPRealmConfigList *realmlist, LDAPConfig *ldapconfig, TQWidget* parent=0, const char *name=0); /** destructor */ ~BondWizard(); @@ -64,9 +67,12 @@ private: void setPosition(); private: + BondIntroPage* intropage; BondRealmPage* realmpage; BondFinishPage* finishpage; bool realm_dirty; + LDAPRealmConfigList* m_realmList; + LDAPConfig* m_ldapConfig; protected: // Protected methods // the close button on the titlebar sets e->accept() which we don't want. diff --git a/src/ldap.cpp b/src/ldap.cpp index 861ed40..a3afbbf 100644 --- a/src/ldap.cpp +++ b/src/ldap.cpp @@ -64,14 +64,17 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) base = new LDAPConfigBase(this); layout->add(base); + base->ldapRealmList->setAllColumnsShowFocus(true); setRootOnlyMsg(i18n("<b>Bonded LDAP realms take effect system wide, and require administrator access to modify</b><br>To alter the system's bonded LDAP realms, click on the \"Administrator Mode\" button below.")); setUseRootOnlyMsg(true); - connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(changed())); - connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), TQT_SLOT(processLockouts())); + connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), this, TQT_SLOT(changed())); + connect(base->systemEnableSupport, TQT_SIGNAL(clicked()), this, TQT_SLOT(processLockouts())); + connect(base->ldapRealmList, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(processLockouts())); connect(base->btnBondRealm, TQT_SIGNAL(clicked()), TQT_SLOT(bondToNewRealm())); + connect(base->btnRemoveRealm, TQT_SIGNAL(clicked()), TQT_SLOT(removeRealm())); load(); @@ -102,12 +105,13 @@ void LDAPConfig::load(bool useDefaults ) base->systemEnableSupport->setChecked(systemconfig->readBoolEntry("EnableLDAP", false)); // Load realms + m_realms.clear(); TQStringList cfgRealms = systemconfig->groupList(); for (TQStringList::Iterator it(cfgRealms.begin()); it != cfgRealms.end(); ++it) { if ((*it).startsWith("LDAPRealm-")) { systemconfig->setGroup(*it); TQString realmName=*it; - realmName.remove(strlen("LDAPRealm-")); + realmName.remove(0,strlen("LDAPRealm-")); if (!m_realms.contains(realmName)) { // Read in realm data LDAPRealmConfig realmcfg; @@ -124,18 +128,28 @@ void LDAPConfig::load(bool useDefaults ) realmcfg.pkinit_require_krbtgt_otherName = systemconfig->readBoolEntry("pkinit_require_krbtgt_otherName"); realmcfg.win2k_pkinit = systemconfig->readBoolEntry("win2k_pkinit"); realmcfg.win2k_pkinit_require_binding = systemconfig->readBoolEntry("win2k_pkinit_require_binding"); - // Add realm to lists + // Add realm to list m_realms.insert(realmName, realmcfg); - (void)new TQListViewItem(base->ldapRealmList, ((realmcfg.bonded)?i18n("Bonded"):i18n("Deactivated")), realmName); } } } + updateRealmList(); + processLockouts(); emit changed(useDefaults); } +void LDAPConfig::updateRealmList() { + base->ldapRealmList->clear(); + LDAPRealmConfigList::Iterator it; + for (it = m_realms.begin(); it != m_realms.end(); ++it) { + LDAPRealmConfig realmcfg = it.data(); + (void)new TQListViewItem(base->ldapRealmList, ((realmcfg.bonded)?i18n("Bonded"):i18n("Deactivated")), realmcfg.name); + } +} + void LDAPConfig::defaults() { } @@ -165,6 +179,23 @@ void LDAPConfig::save() { systemconfig->writeEntry("win2k_pkinit", realmcfg.win2k_pkinit); systemconfig->writeEntry("win2k_pkinit_require_binding", realmcfg.win2k_pkinit_require_binding); } + + // Delete any realms that do not exist in the m_realms database + TQStringList cfgRealms = systemconfig->groupList(); + for (TQStringList::Iterator it(cfgRealms.begin()); it != cfgRealms.end(); ++it) { + if ((*it).startsWith("LDAPRealm-")) { + systemconfig->setGroup(*it); + TQString realmName=*it; + realmName.remove(0,strlen("LDAPRealm-")); + if (!m_realms.contains(realmName)) { + systemconfig->deleteGroup(*it); + } + } + } + + systemconfig->sync(); + + load(); } void LDAPConfig::processLockouts() { @@ -174,11 +205,19 @@ void LDAPConfig::processLockouts() { TQListViewItem *selrealm = base->ldapRealmList->selectedItem(); if (selrealm) { + LDAPRealmConfig realmcfg = m_realms[selrealm->text(1)]; base->btnBondRealm->setEnabled(true); base->btnReBondRealm->setEnabled(true); - base->btnDeactivateRealm->setEnabled(true); // RAJA FIXME only if realm is bonded - base->btnRemoveRealm->setEnabled(true); // RAJA FIXME only if realm is not bonded - base->btnRealmProperties->setEnabled(true); // RAJA FIXME only if realm is not bonded + if (realmcfg.bonded) { + base->btnDeactivateRealm->setEnabled(true); + base->btnRemoveRealm->setEnabled(false); + base->btnRealmProperties->setEnabled(false); + } + else { + base->btnDeactivateRealm->setEnabled(false); + base->btnRemoveRealm->setEnabled(true); + base->btnRealmProperties->setEnabled(true); + } } else { base->btnBondRealm->setEnabled(true); @@ -195,13 +234,22 @@ void LDAPConfig::bondToNewRealm() { // Something will probably change save(); - BondWizard *bondwizard = new BondWizard(this); - bondwizard->exec(); + BondWizard bondwizard(&m_realms, this, this); + bondwizard.exec(); // Something probably changed load(); } +void LDAPConfig::removeRealm() { + TQListViewItem *selrealm = base->ldapRealmList->selectedItem(); + if (selrealm) { + m_realms.remove(selrealm->text(1)); + updateRealmList(); + changed(); + } +} + int LDAPConfig::buttons() { return KCModule::Apply|KCModule::Help; } @@ -77,6 +77,10 @@ class LDAPConfig: public KCModule private slots: void processLockouts(); void bondToNewRealm(); + void removeRealm(); + + private: + void updateRealmList(); private: KAboutData *myAboutData; diff --git a/src/ldapconfigbase.ui b/src/ldapconfigbase.ui index ef5bd4f..fa14933 100644 --- a/src/ldapconfigbase.ui +++ b/src/ldapconfigbase.ui @@ -137,7 +137,7 @@ </property> </widget> </grid> - </widget> + </widget> <spacer row="4" column="0"> <property name="name" stdset="0"> <cstring>Spacer4</cstring> |