1
0
mirror of https://github.com/altlinux/admc.git synced 2025-01-08 01:18:25 +03:00

Update Gplink class

Add copy ctor and assignment operator, link order move and max order
getter methods. Gpo order getter fixed and arguments rename is also
performed.
This commit is contained in:
Semyon Knyazev 2024-02-09 00:06:05 +04:00
parent 7b5e9a7af7
commit d2f5f76b57
2 changed files with 37 additions and 5 deletions

View File

@ -9,6 +9,10 @@
Gplink::Gplink() {
}
Gplink::Gplink(const Gplink &other) : gpo_list(other.gpo_list), options(other.options) {
}
Gplink::Gplink(const QString &gplink_string) {
if (gplink_string.isEmpty()) {
return;
@ -60,6 +64,16 @@ Gplink::Gplink(const QString &gplink_string) {
}
}
Gplink &Gplink::operator=(const Gplink &other) {
if (this == &other) {
return *this;
}
gpo_list = other.gpo_list;
options = other.options;
return *this;
}
// Transform into gplink format. Have to uppercase some
// parts of the output.
QString Gplink::to_string() const {
@ -242,6 +256,15 @@ void Gplink::move_down(const QString &gpo_case) {
}
}
void Gplink::move(int from_order, int to_order) {
if (from_order > (int)gpo_list.size() || to_order > (int)gpo_list.size() ||
from_order < 1 || to_order < 1) {
return;
}
gpo_list.move(from_order - 1, to_order - 1);
}
bool Gplink::get_option(const QString &gpo_case, const GplinkOption option) const {
const QString gpo = gpo_case.toLower();
@ -273,11 +296,15 @@ bool Gplink::equals(const Gplink &other) const {
int Gplink::get_gpo_order(const QString &gpo_case) const {
const QString gpo = gpo_case.toLower();
const int out = gpo_list.indexOf(gpo);
const int out = gpo_list.indexOf(gpo) + 1;
return out;
}
int Gplink::get_max_order() const {
return gpo_list.size();
}
QStringList Gplink::enforced_gpo_dn_list() const
{
QStringList enforced_dn_list;

View File

@ -41,8 +41,11 @@ enum GplinkOption {
class Gplink {
public:
Gplink();
Gplink(const Gplink &other);
Gplink(const QString &gplink_string);
Gplink &operator=(const Gplink &other);
QString to_string() const;
bool contains(const QString &gpo) const;
@ -52,10 +55,11 @@ public:
// LDAP operations.
QList<QString> get_gpo_list() const;
void add(const QString &gpo);
void remove(const QString &gpo);
void move_up(const QString &gpo);
void move_down(const QString &gpo);
void add(const QString &gpo_case);
void remove(const QString &gpo_case);
void move_up(const QString &gpo_case);
void move_down(const QString &gpo_case);
void move(int from_order, int to_order);
bool get_option(const QString &gpo, const GplinkOption option) const;
void set_option(const QString &gpo, const GplinkOption option, const bool value);
@ -63,6 +67,7 @@ public:
bool equals(const Gplink &other) const;
int get_gpo_order(const QString &gpo) const;
int get_max_order() const;
QStringList enforced_gpo_dn_list() const;
QStringList disabled_gpo_dn_list() const;