diff options
author | Timothy Pearson <[email protected]> | 2012-06-13 20:56:58 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-06-13 20:56:58 -0500 |
commit | ccbc653660b7df4148be5c0c2f087cd48efbcbe6 (patch) | |
tree | b973c64aa173d330a716f7b61461ddad32a0aa17 /src | |
parent | dbd589f7be46e85ac0eefe18e9feb41dbd41ae2f (diff) | |
download | kcmldapmanager-ccbc653660b7df4148be5c0c2f087cd48efbcbe6.tar.gz kcmldapmanager-ccbc653660b7df4148be5c0c2f087cd48efbcbe6.zip |
Add service editor
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/ldapconfigbase.ui | 192 | ||||
-rw-r--r-- | src/ldapmgr.cpp | 123 | ||||
-rw-r--r-- | src/ldapmgr.h | 9 | ||||
-rw-r--r-- | src/serviceconfigbase.ui | 89 | ||||
-rw-r--r-- | src/serviceconfigdlg.cpp | 98 | ||||
-rw-r--r-- | src/serviceconfigdlg.h | 49 |
7 files changed, 561 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 713e114..556ceee 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_ldapmanager.la -kcm_ldapmanager_la_SOURCES = ldapmgr.cpp ldapconfigbase.ui userconfigbase.ui groupconfigbase.ui userconfigdlg.cpp groupconfigdlg.cpp +kcm_ldapmanager_la_SOURCES = ldapmgr.cpp ldapconfigbase.ui userconfigbase.ui groupconfigbase.ui serviceconfigbase.ui userconfigdlg.cpp groupconfigdlg.cpp serviceconfigdlg.cpp kcm_ldapmanager_la_LIBADD = -lkio $(LIB_TDEUI) -lldap -ltdeldap kcm_ldapmanager_la_LDFLAGS = -avoid-version -module -no-undefined \ $(all_libraries) diff --git a/src/ldapconfigbase.ui b/src/ldapconfigbase.ui index 9c0be29..fb521d4 100644 --- a/src/ldapconfigbase.ui +++ b/src/ldapconfigbase.ui @@ -672,6 +672,198 @@ </widget> </grid> </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>servicesTab</cstring> + </property> + <attribute name="title"> + <string>Services</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="0"> + <property name="name"> + <cstring>service_icon</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="0"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Services in LDAP Realm</string> + </property> + </widget> + <widget class="KComboBox" row="0" column="3" colspan="0"> + <property name="name"> + <cstring>service_ldapRealm</cstring> + </property> + </widget> + <spacer row="0" column="2"> + <property name="name" stdset="0"> + <cstring>Spacer3</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQSplitter" row="1" column="0" colspan="4"> + <property name="name"> + <cstring>splitter1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <widget class="KListView" row="1" column="0" colspan="4"> + <column> + <property name="text"> + <string>Service Name</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizeable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Machine Name</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizeable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>service_list</cstring> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + </widget> + <widget class="TQLayoutWidget" row="2" column="0" colspan="4"> + <property name="name"> + <cstring>unnamed_layoutwidget3</cstring> + </property> + <grid> + <property name="margin"> + <number>0</number> + </property> + <widget class="TQLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>serviceControls</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQPushButton" row="0" column="1" colspan="0"> + <property name="name"> + <cstring>service_buttonModify</cstring> + </property> + <property name="text"> + <string>Modify</string> + </property> + </widget> + <widget class="TQPushButton" row="0" column="0" colspan="0"> + <property name="name"> + <cstring>service_buttonAdd</cstring> + </property> + <property name="text"> + <string>New</string> + </property> + </widget> + <widget class="TQPushButton" row="0" column="2" colspan="0"> + <property name="name"> + <cstring>service_buttonDelete</cstring> + </property> + <property name="text"> + <string>Delete</string> + </property> + </widget> + </grid> + </widget> + <widget class="TQGroupBox" row="1" column="0"> + <property name="name"> + <cstring>groupServiceDetails</cstring> + </property> + <property name="title"> + <string>Details</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="0"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Service Name:</string> + </property> + </widget> + <widget class="KLineEdit" row="0" column="1" colspan="0"> + <property name="name"> + <cstring>service_name</cstring> + </property> + <property name="enabled"> + <cstring>false</cstring> + </property> + </widget> + <widget class="TQLabel" row="0" column="2" colspan="0"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Author:</string> + </property> + </widget> + <widget class="KLineEdit" row="0" column="3" colspan="0"> + <property name="name"> + <cstring>service_author</cstring> + </property> + <property name="enabled"> + <cstring>false</cstring> + </property> + </widget> + </grid> + </widget> + <spacer row="4" column="0"> + <property name="name" stdset="0"> + <cstring>Spacer6</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + </widget> + </grid> + </widget> </widget> </grid> </widget> diff --git a/src/ldapmgr.cpp b/src/ldapmgr.cpp index a7f0993..36224e6 100644 --- a/src/ldapmgr.cpp +++ b/src/ldapmgr.cpp @@ -48,6 +48,7 @@ #include "ldappasswddlg.h" #include "userconfigdlg.h" #include "groupconfigdlg.h" +#include "serviceconfigdlg.h" // FIXME // Connect this to CMake/Automake @@ -74,6 +75,8 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) base->group_memberList->setFullWidth(true); base->machine_list->setAllColumnsShowFocus(true); base->machine_list->setFullWidth(true); + base->service_list->setAllColumnsShowFocus(true); + base->service_list->setFullWidth(true); base->user_loginName->setEnabled(false); base->user_uid->setEnabled(false); @@ -84,27 +87,34 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) base->machine_name->setEnabled(false); base->machine_author->setEnabled(false); + base->service_name->setEnabled(false); + base->service_author->setEnabled(false); base->user_icon->setPixmap(SmallIcon("personal.png")); base->group_icon->setPixmap(SmallIcon("kdmconfig.png")); base->machine_icon->setPixmap(SmallIcon("system.png")); + base->service_icon->setPixmap(SmallIcon("kcmsystem.png")); connect(base->user_ldapRealm, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(connectToRealm(const TQString&))); connect(base->group_ldapRealm, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(connectToRealm(const TQString&))); connect(base->machine_ldapRealm, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(connectToRealm(const TQString&))); + connect(base->service_ldapRealm, TQT_SIGNAL(activated(const TQString&)), this, TQT_SLOT(connectToRealm(const TQString&))); connect(base->user_list, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(userHighlighted())); connect(base->group_list, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(groupHighlighted())); connect(base->machine_list, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(machineHighlighted())); + connect(base->service_list, TQT_SIGNAL(selectionChanged()), this, TQT_SLOT(serviceHighlighted())); connect(base->user_list, TQT_SIGNAL(executed(TQListViewItem*)), this, TQT_SLOT(modifySelectedUser())); connect(base->group_list, TQT_SIGNAL(executed(TQListViewItem*)), this, TQT_SLOT(modifySelectedGroup())); connect(base->user_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewUser())); connect(base->group_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewGroup())); + connect(base->service_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewService())); connect(base->user_buttonModify, TQT_SIGNAL(clicked()), this, TQT_SLOT(modifySelectedUser())); connect(base->group_buttonModify, TQT_SIGNAL(clicked()), this, TQT_SLOT(modifySelectedGroup())); connect(base->user_buttonDelete, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeSelectedUser())); connect(base->group_buttonDelete, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeSelectedGroup())); connect(base->machine_buttonDelete, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeSelectedMachine())); + connect(base->service_buttonDelete, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeSelectedService())); load(); @@ -129,9 +139,11 @@ void LDAPConfig::load() { base->user_ldapRealm->clear(); base->group_ldapRealm->clear(); base->machine_ldapRealm->clear(); + base->service_ldapRealm->clear(); base->user_ldapRealm->insertItem("<none>"); base->group_ldapRealm->insertItem("<none>"); base->machine_ldapRealm->insertItem("<none>"); + base->service_ldapRealm->insertItem("<none>"); TQStringList cfgRealms = m_systemconfig->groupList(); for (TQStringList::Iterator it(cfgRealms.begin()); it != cfgRealms.end(); ++it) { if ((*it).startsWith("LDAPRealm-")) { @@ -141,6 +153,7 @@ void LDAPConfig::load() { base->user_ldapRealm->insertItem(realmName); base->group_ldapRealm->insertItem(realmName); base->machine_ldapRealm->insertItem(realmName); + base->service_ldapRealm->insertItem(realmName); } } TQString defaultRealm = m_systemconfig->readEntry("DefaultRealm", TQString::null); @@ -150,6 +163,7 @@ void LDAPConfig::load() { base->user_ldapRealm->setCurrentItem(i); base->group_ldapRealm->setCurrentItem(i); base->machine_ldapRealm->setCurrentItem(i); + base->service_ldapRealm->setCurrentItem(i); break; } } @@ -204,6 +218,19 @@ void LDAPConfig::processLockouts() { // Think about it...yes you can add the 'add' feature...kadmin 'ank --random-key host/HOSTNAME.FQDN'... base->machine_buttonAdd->setEnabled(false); base->machine_buttonModify->setEnabled(false); + + lvi = base->service_list->selectedItem(); + if (lvi) { + LDAPServiceInfo service = selectedService(); + base->service_buttonDelete->setEnabled(!service.tde_builtin_account); + } + else { + base->service_buttonDelete->setEnabled(false); + } + base->service_buttonAdd->setEnabled(true); + // FIXME + // Disable service modify as it is not implemented + base->service_buttonModify->setEnabled(false); } void LDAPConfig::connectToRealm(const TQString& realm) { @@ -211,6 +238,7 @@ void LDAPConfig::connectToRealm(const TQString& realm) { base->user_ldapRealm->setCurrentItem(realm, false, -1); base->group_ldapRealm->setCurrentItem(realm, false, -1); base->machine_ldapRealm->setCurrentItem(realm, false, -1); + base->service_ldapRealm->setCurrentItem(realm, false, -1); if (realm == "<none>") { abortConnection(); @@ -237,9 +265,11 @@ void LDAPConfig::abortConnection() { base->user_list->clear(); base->group_list->clear(); base->machine_list->clear(); + base->service_list->clear(); base->user_ldapRealm->setCurrentItem("<none>", false, -1); base->group_ldapRealm->setCurrentItem("<none>", false, -1); base->machine_ldapRealm->setCurrentItem("<none>", false, -1); + base->service_ldapRealm->setCurrentItem("<none>", false, -1); } void LDAPConfig::updateAllInformation() { @@ -257,12 +287,19 @@ void LDAPConfig::updateAllInformation() { abortConnection(); return; } + else { + if (populateServices() != 0) { + abortConnection(); + return; + } + } } } updateUsersList(); updateGroupsList(); updateMachinesList(); + updateServicesList(); } int LDAPConfig::populateUsers() { @@ -283,6 +320,12 @@ int LDAPConfig::populateMachines() { return retcode; } +int LDAPConfig::populateServices() { + int retcode; + m_serviceInfoList = m_ldapmanager->services(&retcode); + return retcode; +} + void LDAPConfig::updateUsersList() { TQListViewItem* itm = base->user_list->selectedItem(); TQString prevSelectedItemText; @@ -347,6 +390,27 @@ void LDAPConfig::updateMachinesList() { processLockouts(); } +void LDAPConfig::updateServicesList() { + TQListViewItem* itm = base->service_list->selectedItem(); + TQString prevSelectedItemText; + if (itm) { + prevSelectedItemText = itm->text(0); + } + + base->service_list->clear(); + LDAPServiceInfoList::Iterator it; + for (it = m_serviceInfoList.begin(); it != m_serviceInfoList.end(); ++it) { + LDAPServiceInfo service = *it; + itm = new TQListViewItem(base->service_list, service.name, service.machine); + if (prevSelectedItemText != "") { + if (service.name == prevSelectedItemText) { + base->service_list->setSelected(itm, true); + } + } + } + processLockouts(); +} + LDAPUserInfo LDAPConfig::findUserInfoByName(TQString name) { // Figure out which user is selected LDAPUserInfoList::Iterator it; @@ -383,6 +447,18 @@ LDAPMachineInfo LDAPConfig::findMachineInfoByName(TQString name) { return LDAPMachineInfo(); } +LDAPServiceInfo LDAPConfig::findServiceInfoByName(TQString name, TQString machine) { + // Figure out which service is selected + LDAPServiceInfoList::Iterator it; + for (it = m_serviceInfoList.begin(); it != m_serviceInfoList.end(); ++it) { + LDAPServiceInfo service = *it; + if ((service.name == name) && (service.machine == machine)) { + return service; + } + } + return LDAPServiceInfo(); +} + LDAPUserInfo LDAPConfig::findUserInfoByNameAndUID(TQString name, TQString uid) { // Figure out which user is selected LDAPUserInfoList::Iterator it; @@ -443,6 +519,14 @@ LDAPMachineInfo LDAPConfig::selectedMachine() { return findMachineInfoByName(lvi->text(0)); } +LDAPServiceInfo LDAPConfig::selectedService() { + TQListViewItem* lvi = base->service_list->selectedItem(); + if (!lvi) { + return LDAPServiceInfo(); + } + return findServiceInfoByName(lvi->text(0), lvi->text(1)); +} + LDAPUserInfo LDAPConfig::findUserByDistinguishedName(TQString dn) { LDAPUserInfoList::Iterator it; for (it = m_userInfoList.begin(); it != m_userInfoList.end(); ++it) { @@ -476,6 +560,10 @@ LDAPGroupInfoList LDAPConfig::groupList() { return m_groupInfoList; } +LDAPMachineInfoList LDAPConfig::machineList() { + return m_machineInfoList; +} + void LDAPConfig::userHighlighted() { // Show information in the quick view area LDAPUserInfo user = selectedUser(); @@ -524,6 +612,16 @@ void LDAPConfig::machineHighlighted() { processLockouts(); } +void LDAPConfig::serviceHighlighted() { + // Show information in the quick view area + LDAPServiceInfo service = selectedService(); + + base->service_name->setText(service.name); + base->service_author->setText(findUserByDistinguishedName(service.creatorsName).name); + + processLockouts(); +} + void LDAPConfig::addNewUser() { // Launch a dialog to add the user LDAPUserInfo user; @@ -636,6 +734,21 @@ void LDAPConfig::addNewGroup() { updateAllInformation(); } +void LDAPConfig::addNewService() { + // Launch a dialog to add the service + LDAPServiceInfo service; + + ServiceConfigDialog serviceconfigdlg(service, this); + if (serviceconfigdlg.exec() == TQDialog::Accepted) { + service = serviceconfigdlg.m_service; + TQString errorstring; + if (m_ldapmanager->addServiceInfo(service, &errorstring) != 0) { + KMessageBox::error(0, i18n("<qt>Unable to add new service!<p>%1</qt>").arg(errorstring), i18n("Internal Failure")); + } + } + updateAllInformation(); +} + void LDAPConfig::modifySelectedUser() { // Launch a dialog to edit the user LDAPUserInfo user = selectedUser(); @@ -724,6 +837,16 @@ void LDAPConfig::removeSelectedMachine() { updateAllInformation(); } +void LDAPConfig::removeSelectedService() { + LDAPServiceInfo service = selectedService(); + + if (KMessageBox::warningYesNo(this, i18n("<qt><b>You are about to delete the service %1 for host %2</b><br>This action cannot be undone<p>Are you sure you want to proceed?</qt>").arg(service.name).arg(service.machine), i18n("Confirmation Required")) == KMessageBox::Yes) { + m_ldapmanager->deleteServiceInfo(service); + } + + updateAllInformation(); +} + TQString readFullLineFromPtyProcess(PtyProcess* proc) { TQString result = ""; while ((!result.contains("\n")) && (!result.contains(":")) && (!result.contains(">"))) { diff --git a/src/ldapmgr.h b/src/ldapmgr.h index 7d38c6e..f28befe 100644 --- a/src/ldapmgr.h +++ b/src/ldapmgr.h @@ -56,19 +56,24 @@ class LDAPConfig: public KCModule int populateUsers(); int populateGroups(); int populateMachines(); + int populateServices(); void updateUsersList(); void updateGroupsList(); void updateMachinesList(); + void updateServicesList(); void userHighlighted(); void groupHighlighted(); void machineHighlighted(); + void serviceHighlighted(); void addNewUser(); void addNewGroup(); + void addNewService(); void modifySelectedUser(); void modifySelectedGroup(); void removeSelectedUser(); void removeSelectedGroup(); void removeSelectedMachine(); + void removeSelectedService(); void updateAllInformation(); void abortConnection(); @@ -76,6 +81,7 @@ class LDAPConfig: public KCModule LDAPUserInfo findUserInfoByName(TQString name); LDAPGroupInfo findGroupInfoByName(TQString name); LDAPMachineInfo findMachineInfoByName(TQString name); + LDAPServiceInfo findServiceInfoByName(TQString name, TQString machine); LDAPUserInfo findUserInfoByNameAndUID(TQString name, TQString uid); LDAPGroupInfo findGroupInfoByNameAndGID(TQString name, TQString gid); LDAPGroupInfo findGroupInfoByGID(TQString gid); @@ -83,11 +89,13 @@ class LDAPConfig: public KCModule LDAPGroupInfoList findGroupsForUserByDistinguishedName(TQString dn); LDAPUserInfoList userList(); LDAPGroupInfoList groupList(); + LDAPMachineInfoList machineList(); private: LDAPUserInfo selectedUser(); LDAPGroupInfo selectedGroup(); LDAPMachineInfo selectedMachine(); + LDAPServiceInfo selectedService(); int setPasswordForUser(LDAPUserInfo user, TQString *errstr); private: @@ -100,6 +108,7 @@ class LDAPConfig: public KCModule LDAPUserInfoList m_userInfoList; LDAPGroupInfoList m_groupInfoList; LDAPMachineInfoList m_machineInfoList; + LDAPServiceInfoList m_serviceInfoList; }; #endif diff --git a/src/serviceconfigbase.ui b/src/serviceconfigbase.ui new file mode 100644 index 0000000..c7cd2bf --- /dev/null +++ b/src/serviceconfigbase.ui @@ -0,0 +1,89 @@ +<!DOCTYPE UI><UI version="3.0" stdsetdef="1"> + <class>LDAPServiceConfigBase</class> + <widget class="TQWidget"> + <property name="name"> + <cstring>LDAPServiceConfigBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>519</width> + <height>356</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQTabWidget" row="0" column="0"> + <property name="name"> + <cstring>TabWidget2</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>detailsTab</cstring> + </property> + <attribute name="title"> + <string>Kerberos Service</string> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel" row="0" column="0" colspan="1"> + <property name="name"> + <cstring>detailsIcon</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>4</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + <widget class="TQLabel" row="0" column="1" colspan="1"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Service Name</string> + </property> + </widget> + <widget class="KLineEdit" row="0" column="2" colspan="1"> + <property name="name"> + <cstring>serviceName</cstring> + </property> + </widget> + <widget class="TQLabel" row="1" column="0" colspan="2"> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="text"> + <string>Host Machine</string> + </property> + </widget> + <widget class="KComboBox" row="1" column="2" colspan="2"> + <property name="name"> + <cstring>hostMachine</cstring> + </property> + </widget> + </grid> + </widget> + </widget> + </grid> + </widget> + <includes> + <include location="local" impldecl="in implementation">LDAPServiceConfigBase.ui.h</include> + </includes> + <includes> + <include location="local" impldecl="in implementation">kdialog.h</include> + </includes> + <layoutdefaults spacing="3" margin="6"/> + <layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI>
\ No newline at end of file diff --git a/src/serviceconfigdlg.cpp b/src/serviceconfigdlg.cpp new file mode 100644 index 0000000..cd5eaae --- /dev/null +++ b/src/serviceconfigdlg.cpp @@ -0,0 +1,98 @@ +/*************************************************************************** + * 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 <klocale.h> +#include <klineedit.h> +#include <ktextedit.h> +#include <knuminput.h> +#include <kactionselector.h> +#include <tqlistbox.h> +#include <kpushbutton.h> +#include <tqpixmap.h> +#include <tqiconset.h> +#include <tqlabel.h> +#include <kurlrequester.h> +#include <kcombobox.h> +#include <tqradiobutton.h> +#include <tqcheckbox.h> +#include <kdatetimewidget.h> +#include <kiconloader.h> + +#include "ldapmgr.h" +#include "serviceconfigdlg.h" + +ServiceConfigDialog::ServiceConfigDialog(LDAPServiceInfo service, LDAPConfig* parent, const char* name) + : KDialogBase(parent, name, true, i18n("LDAP Service Properties"), Ok|Cancel, Ok, true), m_service(service), m_ldapconfig(parent) +{ + int i; + + m_base = new LDAPServiceConfigBase(this); + setMainWidget(m_base); + + // Populate machine list + LDAPMachineInfoList machineList = m_ldapconfig->machineList(); + LDAPMachineInfoList::Iterator it; + for (it = machineList.begin(); it != machineList.end(); ++it) { + LDAPMachineInfo machine = *it; + m_base->hostMachine->insertItem(machine.name, -1); + } + + m_base->detailsIcon->setPixmap(SmallIcon("kcmsystem.png")); + + connect(m_base->serviceName, TQT_SIGNAL(textChanged(const TQString&)), this, TQT_SLOT(processLockouts())); + + // Update fields + m_base->serviceName->setText(m_service.name); + for (i=0; i<m_base->hostMachine->count(); i++) { + if (m_base->hostMachine->text(i).lower() == m_service.machine.lower()) { + m_base->hostMachine->setCurrentItem(i); + } + } + + m_base->serviceName->setFocus(); + + processLockouts(); +} + +void ServiceConfigDialog::slotOk() { + // Special handler for new service + if (m_service.distinguishedName == "") { + m_service.name = m_base->serviceName->text(); + m_service.machine = m_base->hostMachine->currentText(); + } + + accept(); +} + +void ServiceConfigDialog::processLockouts() { + // Special handler for new group + if ((m_service.distinguishedName == "") && (m_base->serviceName->text() == "")) { + enableButton(KDialogBase::Ok, false); + } + else { + enableButton(KDialogBase::Ok, true); + } +} + +LDAPServiceInfo ServiceConfigDialog::serviceProperties() { + return m_service; +} + +#include "serviceconfigdlg.moc" diff --git a/src/serviceconfigdlg.h b/src/serviceconfigdlg.h new file mode 100644 index 0000000..5ebf5a1 --- /dev/null +++ b/src/serviceconfigdlg.h @@ -0,0 +1,49 @@ +/*************************************************************************** + * 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 _SERVICECONFIGDIALOG_H_ +#define _SERVICECONFIGDIALOG_H_ + +#include <kdialogbase.h> + +#include "libtdeldap.h" +#include "serviceconfigbase.h" + +class ServiceConfigDialog : public KDialogBase +{ + Q_OBJECT + +public: + ServiceConfigDialog(LDAPServiceInfo service, LDAPConfig* parent = 0, const char* name = 0); + LDAPServiceInfo serviceProperties(); + +public slots: + void slotOk(); + void processLockouts(); + +public: + LDAPServiceConfigBase *m_base; + LDAPServiceInfo m_service; + +private: + LDAPConfig* m_ldapconfig; +}; + +#endif // _SERVICECONFIGDIALOG_H_ |