From: Andrea Zagli Date: Sun, 5 Sep 2010 10:47:18 +0000 (+0200) Subject: Enabled group editing. X-Git-Tag: v0.1.1~4 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=476aee43a82247a1fcc4f81740c69ce0336af414;p=zakauthe%2Fplugins%2Fsmbldap Enabled group editing. --- diff --git a/data/libaute-smbldap/gui/autesmbldap.gui b/data/libaute-smbldap/gui/autesmbldap.gui index e510878..d003278 100644 --- a/data/libaute-smbldap/gui/autesmbldap.gui +++ b/data/libaute-smbldap/gui/autesmbldap.gui @@ -460,7 +460,7 @@ True 0 - Code + CN GTK_FILL @@ -552,7 +552,6 @@ True True - 10 @@ -565,7 +564,6 @@ True True - 100 @@ -580,7 +578,6 @@ True True - 100 @@ -722,7 +719,6 @@ True True - 10 diff --git a/src/aute_smbldap.c b/src/aute_smbldap.c index 29b887a..5429cb1 100644 --- a/src/aute_smbldap.c +++ b/src/aute_smbldap.c @@ -636,23 +636,75 @@ autesmbldap_on_group_aggiornato (gpointer instance, gpointer user_data) static void autesmbldap_edit_user () { - /*GtkTreeIter iter; - gchar *code; + GtkTreeIter iter; + gchar *cn; + + GtkListStore *lstore; + GtkTreeSelection *selection; + gchar *str_type; + guint col_cn; - if (gtk_tree_selection_get_selected (sel_users, NULL, &iter)) + GtkWidget *w; + GtkWidget *dialog; + + if (gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)) == 0) + { + lstore = lstore_users; + selection = sel_users; + str_type = g_strdup ("user"); + col_cn = COL_USERS_CN; + } + else if (gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)) == 1) + { + lstore = lstore_groups; + selection = sel_groups; + str_type = g_strdup ("group"); + col_cn = COL_GROUPS_CN; + } + else { - GtkWidget *w; + dialog = gtk_message_dialog_new (autesmbldap_get_gtkwidget_parent_gtkwindow (w_users), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Wrong notebook page."); + return; + } - gtk_tree_model_get (GTK_TREE_MODEL (lstore_users), &iter, - COL_CODE, &code, + if (gtk_tree_selection_get_selected (selection, NULL, &iter)) + { + gtk_tree_model_get (GTK_TREE_MODEL (lstore), &iter, + col_cn, &cn, -1); - User *u = user_new (gtkbuilder, gdaex, guifile, formdir, code); + if (gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)) == 0) + { + /*User *u = user_new (gtkbuilder, gdaex, guifile, formdir, NULL); - g_signal_connect (G_OBJECT (u), "aggiornato", - G_CALLBACK (autesmbldap_on_user_aggiornato), NULL); + g_signal_connect (G_OBJECT (u), "aggiornato", + G_CALLBACK (autesmbldap_on_user_aggiornato), NULL); + + w = user_get_widget (u);*/ + } + else if (gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)) == 1) + { + Group *u = group_new (gtkbuilder, guifile, ldap, cn, groups_ou, base_dn); + + g_signal_connect (G_OBJECT (u), "aggiornato", + G_CALLBACK (autesmbldap_on_group_aggiornato), NULL); + + w = group_get_widget (u); + } + else + { + dialog = gtk_message_dialog_new (autesmbldap_get_gtkwidget_parent_gtkwindow (w_users), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Wrong notebook page."); + return; + } - w = user_get_widget (u); gtk_window_set_transient_for (GTK_WINDOW (w), autesmbldap_get_gtkwidget_parent_gtkwindow (w_users)); gtk_widget_show (w); } @@ -662,10 +714,10 @@ autesmbldap_edit_user () GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, - "Occorre prima selezionare un modello"); + "You must select a %s before.", str_type); gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); - }*/ + } } static void diff --git a/src/group.c b/src/group.c index 7893322..b7b5757 100644 --- a/src/group.c +++ b/src/group.c @@ -243,21 +243,21 @@ group_salva (Group *group) GroupPrivate *priv = GROUP_GET_PRIVATE (group); + if (g_strcmp0 (priv->cn, "") == 0) + { + autesmbldap_exec_ssh_command (g_strdup_printf ("sudo /usr/sbin/smbldap-groupadd -a \"%s\"", + gtk_entry_get_text (GTK_ENTRY (priv->txt_cn)))); + priv->cn = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->txt_cn))); + group_carica (group); + } + else + { + autesmbldap_exec_ssh_command (g_strdup_printf ("sudo /usr/sbin/smbldap-groupmod -n \"%s\" \"%s\"", + gtk_entry_get_text (GTK_ENTRY (priv->txt_cn)), priv->cn)); + } + /*if (gdaex_execute (priv->gdaex, sql) == 1) {*/ - if (g_strcmp0 (priv->cn, "") == 0) - { - autesmbldap_exec_ssh_command (g_strdup_printf ("sudo /usr/sbin/smbldap-groupadd -a %s", - gtk_entry_get_text (GTK_ENTRY (priv->txt_cn)))); - priv->cn = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->txt_cn))); - group_carica (group); - } - else - { - /* TODO */ - return; - } - g_signal_emit (group, klass->aggiornato_signal_id, 0); dialog = gtk_message_dialog_new (GTK_WINDOW (priv->w),