mirror of
https://github.com/altlinux/admc.git
synced 2025-03-17 02:50:12 +03:00
add signals to load_children and load_attributes
fix attribute_value_exists() calls
This commit is contained in:
parent
548b4c03aa
commit
9ff3ec63c5
@ -264,8 +264,6 @@ QList<QString> load_children(const QString &dn) {
|
||||
const char *dn_cstr = qstring_to_cstr(dn);
|
||||
char **children_raw = ad_list(dn_cstr);
|
||||
|
||||
// TODO: error check
|
||||
|
||||
if (children_raw != NULL) {
|
||||
auto children = QList<QString>();
|
||||
|
||||
@ -281,22 +279,21 @@ QList<QString> load_children(const QString &dn) {
|
||||
|
||||
return children;
|
||||
} else {
|
||||
// TODO: is this still a fail if there are no children?
|
||||
emit ad_interface.load_children_failed(dn, get_error_str());
|
||||
|
||||
return QList<QString>();
|
||||
}
|
||||
}
|
||||
|
||||
void load_attributes(const QString &dn) {
|
||||
if (FAKE_AD) {
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: save original attributes ordering and load it like that into model
|
||||
|
||||
const char *dn_cstr = qstring_to_cstr(dn);
|
||||
char** attributes_raw = ad_get_attribute(dn_cstr, NULL);
|
||||
|
||||
// TODO: handle errors
|
||||
|
||||
if (attributes_raw != NULL) {
|
||||
attributes_map[dn] = QMap<QString, QList<QString>>();
|
||||
|
||||
@ -322,6 +319,8 @@ void load_attributes(const QString &dn) {
|
||||
free(attributes_raw[i]);
|
||||
}
|
||||
free(attributes_raw);
|
||||
} else {
|
||||
emit ad_interface.load_attributes_failed(dn, get_error_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -386,8 +385,6 @@ bool set_attribute(const QString &dn, const QString &attribute, const QString &v
|
||||
const char *attribute_cstr = qstring_to_cstr(attribute);
|
||||
const char *value_cstr = qstring_to_cstr(value);
|
||||
|
||||
// TODO: handle errors
|
||||
|
||||
result = ad_mod_replace(dn_cstr, attribute_cstr, value_cstr);
|
||||
}
|
||||
|
||||
@ -409,8 +406,6 @@ bool set_attribute(const QString &dn, const QString &attribute, const QString &v
|
||||
bool create_entry(const QString &name, const QString &dn, NewEntryType type) {
|
||||
int result = AD_INVALID_DN;
|
||||
|
||||
// TODO: handle errors
|
||||
|
||||
if (FAKE_AD) {
|
||||
switch (type) {
|
||||
case User: {
|
||||
@ -479,15 +474,12 @@ void delete_entry(const QString &dn) {
|
||||
} else {
|
||||
const char *dn_cstr = qstring_to_cstr(dn);
|
||||
|
||||
// TODO: handle all possible side-effects?
|
||||
// probably a lot of stuff, like group membership and stuff
|
||||
|
||||
// TODO: handle errors
|
||||
|
||||
result = ad_object_delete(dn_cstr);
|
||||
}
|
||||
|
||||
if (result == AD_SUCCESS) {
|
||||
// TODO: handle all possible side-effects?
|
||||
// probably a lot of stuff, like group membership and stuff
|
||||
emit ad_interface.delete_entry_complete(dn);
|
||||
|
||||
attributes_map.remove(dn);
|
||||
@ -499,7 +491,6 @@ void delete_entry(const QString &dn) {
|
||||
void move_user(const QString &user_dn, const QString &container_dn) {
|
||||
int result = AD_INVALID_DN;
|
||||
|
||||
// TODO: duplicated
|
||||
QString user_name = extract_name_from_dn(user_dn);
|
||||
QString new_dn = "CN=" + user_name + "," + container_dn;
|
||||
|
||||
|
@ -34,6 +34,9 @@ public:
|
||||
public slots:
|
||||
|
||||
signals:
|
||||
void load_children_failed(const QString &dn, const QString &error_str);
|
||||
void load_attributes_failed(const QString &dn, const QString &error_str);
|
||||
|
||||
void delete_entry_complete(const QString &dn);
|
||||
void set_attribute_complete(const QString &dn, const QString &attribute, const QString &old_value, const QString &value);
|
||||
void create_entry_complete(const QString &dn, NewEntryType type);
|
||||
|
@ -113,7 +113,7 @@ void init_row(QList<QStandardItem*> row, const QString &dn) {
|
||||
bool is_container = false;
|
||||
const QList<QString> container_objectClasses = {"container", "organizationalUnit", "builtinDomain", "domain"};
|
||||
for (auto c : container_objectClasses) {
|
||||
if (attribute_value_exists("objectClass", c)) {
|
||||
if (attribute_value_exists(dn, "objectClass", c)) {
|
||||
is_container = true;
|
||||
break;
|
||||
}
|
||||
@ -144,7 +144,7 @@ void init_row(QList<QStandardItem*> row, const QString &dn) {
|
||||
};
|
||||
QString icon_name = "dialog-question";
|
||||
for (auto c : class_to_icon.keys()) {
|
||||
if (attribute_value_exists("objectClass", c)) {
|
||||
if (attribute_value_exists(dn, "objectClass", c)) {
|
||||
icon_name = class_to_icon[c];
|
||||
break;
|
||||
}
|
||||
|
@ -63,4 +63,4 @@ void AttributesModel::on_delete_entry_complete(const QString &dn) {
|
||||
if (target_dn == dn) {
|
||||
change_target(QString(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,13 @@ StatusBar::StatusBar()
|
||||
showMessage(tr("Ready"), 10 * 1000);
|
||||
|
||||
// Connect signals
|
||||
connect(
|
||||
&ad_interface, &AdInterface::load_children_failed,
|
||||
this, &StatusBar::on_load_children_failed);
|
||||
connect(
|
||||
&ad_interface, &AdInterface::load_attributes_failed,
|
||||
this, &StatusBar::on_load_attributes_failed);
|
||||
|
||||
connect(
|
||||
&ad_interface, &AdInterface::create_entry_complete,
|
||||
this, &StatusBar::on_create_entry_complete);
|
||||
@ -35,6 +42,17 @@ StatusBar::StatusBar()
|
||||
this, &StatusBar::on_move_user_failed);
|
||||
}
|
||||
|
||||
void StatusBar::on_load_children_failed(const QString &dn, const QString &error_str) {
|
||||
QString msg = QString("Failed to load children of \"%1\". Error: \"%2\"").arg(dn, error_str);
|
||||
|
||||
showMessage(msg);
|
||||
}
|
||||
void StatusBar::on_load_attributes_failed(const QString &dn, const QString &error_str) {
|
||||
QString msg = QString("Failed to load attributes of \"%1\". Error: \"%2\"").arg(dn, error_str);
|
||||
|
||||
showMessage(msg);
|
||||
}
|
||||
|
||||
void StatusBar::on_delete_entry_complete(const QString &dn) {
|
||||
QString msg = QString("Deleted entry \"%1\"").arg(dn);
|
||||
|
||||
|
@ -17,6 +17,9 @@ public:
|
||||
explicit StatusBar();
|
||||
|
||||
private slots:
|
||||
void on_load_children_failed(const QString &dn, const QString &error_str);
|
||||
void on_load_attributes_failed(const QString &dn, const QString &error_str);
|
||||
|
||||
void on_delete_entry_complete(const QString &dn);
|
||||
void on_set_attribute_complete(const QString &dn, const QString &attribute, const QString &old_value, const QString &value);
|
||||
void on_create_entry_complete(const QString &dn, NewEntryType type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user