-
Notifications
You must be signed in to change notification settings - Fork 27
PSO fixes #452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
PSO fixes #452
Changes from all commits
92299be
49ea381
2062c86
bc8abc5
9b4540a
5931022
615469b
28fbb35
67ad01d
3c9ef8a
abc54f1
7196f77
5aee846
9dd5f16
cbbabf8
280293d
328bdb8
2c77e5a
9866ef8
eae8fd6
9f6482b
8d0dfd5
22022a1
b05bf4d
97898f5
8570daf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| /* | ||
| * ADMC - AD Management Center | ||
| * | ||
| * Copyright (C) 2020-2025 BaseALT Ltd. | ||
| * Copyright (C) 2020-2025 Dmitry Degtyarev | ||
| * | ||
| * 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 3 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, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #include "console_impls/password_settings_impl.h" | ||
|
|
||
| #include "ad_defines.h" | ||
| #include "adldap.h" | ||
| #include "console_impls/item_type.h" | ||
| #include "console_impls/object_impl/object_impl.h" | ||
| #include "console_impls/policy_impl.h" | ||
| #include "console_widget/results_view.h" | ||
| #include "create_dialogs/create_policy_dialog.h" | ||
| #include "fsmo/fsmo_utils.h" | ||
| #include "globals.h" | ||
| #include "object_impl/console_object_operations.h" | ||
| #include "results_widgets/pso_results_widget/pso_results_widget.h" | ||
| #include "status.h" | ||
| #include "utils.h" | ||
|
|
||
| #include <QAction> | ||
| #include <QList> | ||
| #include <QMessageBox> | ||
| #include <QStandardItem> | ||
|
|
||
| PasswordSettingsImpl::PasswordSettingsImpl(ConsoleWidget *console_arg) | ||
| : ConsoleImpl(console_arg) { | ||
| results_widget = new PSOResultsWidget(console_arg); | ||
|
|
||
| create_pso_action = | ||
| new QAction(tr("Create password settings object"), this); | ||
|
|
||
| connect(create_pso_action, &QAction::triggered, this, [this]() { | ||
| const QString parent_dn = get_selected_target_dn( | ||
| console, ItemType_PasswordSettings, ObjectRole_DN); | ||
| ConsoleObjectTreeOperations::console_object_create( | ||
| {console}, CLASS_PSO, parent_dn); | ||
| }); | ||
| } | ||
|
|
||
| void PasswordSettingsImpl::fetch(const QModelIndex &index) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd put a Doxygen comment before methods, to document what the method does, what it accepts as parameters, what it asserts (if it does so) and what it returns. Also, if there are any exceptions that can be thrown in the method, I'd document them too. |
||
| AdInterface ad; | ||
| if (ad_failed(ad, console)) { | ||
| return; | ||
| } | ||
|
|
||
| //TODO:(kozyrevid) refactor this cast and other like it | ||
| dynamic_cast<PSOResultsWidget *>(results_widget) | ||
| ->update(global_password_settings()); | ||
|
|
||
| QHash<QString, AdObject> results = ad.search( | ||
| g_adconfig->pso_container_dn(), SearchScope_All, "", QStringList()); | ||
| is_PSO_container_available = !results.isEmpty(); | ||
| results.removeIf([](QHash<QString, AdObject>::iterator object) { | ||
| return object.value().get_string(ATTRIBUTE_OBJECT_CLASS) == | ||
| CLASS_PSO_CONTAINER; | ||
| }); | ||
|
|
||
| ConsoleObjectTreeOperations::add_objects_to_console( | ||
| console, results.values(), index); | ||
| } | ||
|
|
||
| void PasswordSettingsImpl::refresh(const QList<QModelIndex> &index_list) { | ||
| const QModelIndex index = index_list[0]; | ||
|
|
||
| console->delete_children(index); | ||
| fetch(index); | ||
| } | ||
|
|
||
| QList<QAction *> PasswordSettingsImpl::get_all_custom_actions() const { | ||
| return {create_pso_action}; | ||
| } | ||
|
|
||
| QSet<QAction *> PasswordSettingsImpl::get_custom_actions( | ||
| const QModelIndex &index, const bool single_selection) const { | ||
| UNUSED_ARG(index); | ||
| UNUSED_ARG(single_selection); | ||
|
|
||
| auto all_actions = get_all_custom_actions(); | ||
| return {all_actions.begin(), all_actions.end()}; | ||
| } | ||
|
|
||
| QSet<QAction *> PasswordSettingsImpl::get_disabled_custom_actions( | ||
| const QModelIndex &index, const bool single_selection) const { | ||
| UNUSED_ARG(index); | ||
| UNUSED_ARG(single_selection); | ||
|
|
||
| return is_PSO_container_available ? QSet<QAction *>{} : | ||
| QSet<QAction *>{create_pso_action}; | ||
| } | ||
|
|
||
| QSet<StandardAction> PasswordSettingsImpl::get_standard_actions( | ||
| const QModelIndex &index, const bool single_selection) const { | ||
| UNUSED_ARG(index); | ||
| UNUSED_ARG(single_selection); | ||
|
|
||
| return {StandardAction_Refresh, StandardAction_Properties}; | ||
| } | ||
|
|
||
| QList<QString> PasswordSettingsImpl::column_labels() const { | ||
| return ConsoleObjectTreeOperations::object_impl_column_labels(); | ||
| } | ||
|
|
||
| QList<int> PasswordSettingsImpl::default_columns() const { | ||
| return ConsoleObjectTreeOperations::object_impl_default_columns(); | ||
| } | ||
|
|
||
| void PasswordSettingsImpl::properties(const QList<QModelIndex> &index_list) { | ||
| ConsoleObjectTreeOperations::console_object_properties( | ||
| {console}, index_list, ObjectRole_DN, {CLASS_PSO_CONTAINER}); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * ADMC - AD Management Center | ||
| * | ||
| * Copyright (C) 2020-2025 BaseALT Ltd. | ||
| * Copyright (C) 2020-2025 Dmitry Degtyarev | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same comment about the copyright header here. |
||
| * | ||
| * 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 3 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, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #ifndef PASSWORD_SETTINGS_IMPL_H | ||
| #define PASSWORD_SETTINGS_IMPL_H | ||
|
|
||
| /** | ||
| * Impl for a virtual container for "All policies". Displays | ||
| * all of the policies present in the domain. | ||
| */ | ||
|
|
||
| #include "console_widget/console_impl.h" | ||
| #include "console_widget/console_widget.h" | ||
|
|
||
| class AdObject; | ||
| class AdInterface; | ||
|
|
||
| class PasswordSettingsImpl final : public ConsoleImpl { | ||
| Q_OBJECT | ||
|
|
||
| public: | ||
| PasswordSettingsImpl(ConsoleWidget *console_arg); | ||
|
|
||
| void fetch(const QModelIndex &index) override; | ||
| void refresh(const QList<QModelIndex> &index_list) override; | ||
| void properties(const QList<QModelIndex> &index_list) override; | ||
|
|
||
| QList<QAction *> get_all_custom_actions() const override; | ||
| QSet<QAction *> get_custom_actions( | ||
| const QModelIndex &index, const bool single_selection) const override; | ||
| QSet<QAction *> get_disabled_custom_actions( | ||
| const QModelIndex &index, const bool single_selection) const override; | ||
| QSet<StandardAction> get_standard_actions( | ||
| const QModelIndex &index, const bool single_selection) const override; | ||
|
|
||
| QList<QString> column_labels() const override; | ||
| QList<int> default_columns() const override; | ||
|
|
||
| private: | ||
| QAction *create_pso_action; | ||
| bool is_PSO_container_available = false; | ||
| }; | ||
|
|
||
| #endif /* PASSWORD_SETTINGS_IMPL_H */ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to put here another line with copyright date and your name, if you are one of the authors of the file.