diff options
author | Timothy Pearson <[email protected]> | 2012-05-30 14:36:53 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2012-05-30 14:36:53 -0500 |
commit | 6d3279772de658a37abc06c74726c72af9c0a484 (patch) | |
tree | 3740a11f3976e7809bda8f4b8b4792ad96b477f4 /src/ldapmgr.cpp | |
parent | 93a591d8f0733774cfc62329ef4b9cc5403bd16c (diff) | |
download | kcmldapmanager-6d3279772de658a37abc06c74726c72af9c0a484.tar.gz kcmldapmanager-6d3279772de658a37abc06c74726c72af9c0a484.zip |
Add machine support
Diffstat (limited to 'src/ldapmgr.cpp')
-rw-r--r-- | src/ldapmgr.cpp | 80 |
1 files changed, 74 insertions, 6 deletions
diff --git a/src/ldapmgr.cpp b/src/ldapmgr.cpp index 5481b2e..26007dc 100644 --- a/src/ldapmgr.cpp +++ b/src/ldapmgr.cpp @@ -81,11 +81,15 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) base->user_status->setEnabled(false); base->user_secondaryGroups->setEnabled(false); + base->machine_name->setEnabled(false); + base->machine_author->setEnabled(false); + 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->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->user_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewUser())); connect(base->group_buttonAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewGroup())); @@ -93,6 +97,7 @@ LDAPConfig::LDAPConfig(TQWidget *parent, const char *name, const TQStringList&) 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())); load(); @@ -183,8 +188,8 @@ void LDAPConfig::processLockouts() { // FIXME // Disable machine add/modify as they are not implemented // In fact, I don't know if I CAN implement them! - base->machine_buttonAdd->setEnabled(true); - base->machine_buttonModify->setEnabled(true); + base->machine_buttonAdd->setEnabled(false); + base->machine_buttonModify->setEnabled(false); } void LDAPConfig::connectToRealm(const TQString& realm) { @@ -210,13 +215,11 @@ void LDAPConfig::connectToRealm(const TQString& realm) { void LDAPConfig::updateAllInformation() { populateUsers(); populateGroups(); - // RAJA FIXME - // Machines?? + populateMachines(); updateUsersList(); updateGroupsList(); - // RAJA FIXME - // Machines?? + updateMachinesList(); } void LDAPConfig::populateUsers() { @@ -227,6 +230,10 @@ void LDAPConfig::populateGroups() { m_groupInfoList = m_ldapmanager->groups(); } +void LDAPConfig::populateMachines() { + m_machineInfoList = m_ldapmanager->machines(); +} + void LDAPConfig::updateUsersList() { TQListViewItem* itm = base->user_list->selectedItem(); TQString prevSelectedItemText; @@ -270,6 +277,27 @@ void LDAPConfig::updateGroupsList() { processLockouts(); } +void LDAPConfig::updateMachinesList() { + TQListViewItem* itm = base->machine_list->selectedItem(); + TQString prevSelectedItemText; + if (itm) { + prevSelectedItemText = itm->text(0); + } + + base->machine_list->clear(); + LDAPMachineInfoList::Iterator it; + for (it = m_machineInfoList.begin(); it != m_machineInfoList.end(); ++it) { + LDAPMachineInfo machine = *it; + itm = new TQListViewItem(base->machine_list, machine.name); + if (prevSelectedItemText != "") { + if (machine.name == prevSelectedItemText) { + base->machine_list->setSelected(itm, true); + } + } + } + processLockouts(); +} + LDAPUserInfo LDAPConfig::findUserInfoByName(TQString name) { // Figure out which user is selected LDAPUserInfoList::Iterator it; @@ -294,6 +322,18 @@ LDAPGroupInfo LDAPConfig::findGroupInfoByName(TQString name) { return LDAPGroupInfo(); } +LDAPMachineInfo LDAPConfig::findMachineInfoByName(TQString name) { + // Figure out which machine is selected + LDAPMachineInfoList::Iterator it; + for (it = m_machineInfoList.begin(); it != m_machineInfoList.end(); ++it) { + LDAPMachineInfo machine = *it; + if (machine.name == name) { + return machine; + } + } + return LDAPMachineInfo(); +} + LDAPUserInfo LDAPConfig::findUserInfoByNameAndUID(TQString name, TQString uid) { // Figure out which user is selected LDAPUserInfoList::Iterator it; @@ -346,6 +386,14 @@ LDAPGroupInfo LDAPConfig::selectedGroup() { return findGroupInfoByNameAndGID(lvi->text(0), lvi->text(1)); } +LDAPMachineInfo LDAPConfig::selectedMachine() { + TQListViewItem* lvi = base->machine_list->selectedItem(); + if (!lvi) { + return LDAPMachineInfo(); + } + return findMachineInfoByName(lvi->text(0)); +} + LDAPUserInfo LDAPConfig::findUserByDistinguishedName(TQString dn) { LDAPUserInfoList::Iterator it; for (it = m_userInfoList.begin(); it != m_userInfoList.end(); ++it) { @@ -415,6 +463,16 @@ void LDAPConfig::groupHighlighted() { processLockouts(); } +void LDAPConfig::machineHighlighted() { + // Show information in the quick view area + LDAPMachineInfo machine = selectedMachine(); + + base->machine_name->setText(machine.name); + base->machine_author->setText(findUserByDistinguishedName(machine.creatorsName).name); + + processLockouts(); +} + void LDAPConfig::addNewUser() { // Launch a dialog to add the user LDAPUserInfo user; @@ -603,6 +661,16 @@ void LDAPConfig::removeSelectedGroup() { updateAllInformation(); } +void LDAPConfig::removeSelectedMachine() { + LDAPMachineInfo machine = selectedMachine(); + + if (KMessageBox::warningYesNo(this, i18n("<qt><b>You are about to delete the machine %1</b><br>This action cannot be undone<p>Are you sure you want to proceed?</qt>").arg(machine.name), i18n("Confirmation Required")) == KMessageBox::Yes) { + m_ldapmanager->deleteMachineInfo(machine); + } + + updateAllInformation(); +} + TQString readFullLineFromPtyProcess(PtyProcess* proc) { TQString result = ""; while ((!result.contains("\n")) && (!result.contains(":")) && (!result.contains(">"))) { |