]> saetta.ns0.it Git - zakauthe/plugins/smbldap/commitdiff
Enabled group editing.
authorAndrea Zagli <azagli@libero.it>
Sun, 5 Sep 2010 10:47:18 +0000 (12:47 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 5 Sep 2010 10:47:18 +0000 (12:47 +0200)
data/libaute-smbldap/gui/autesmbldap.gui
src/aute_smbldap.c
src/group.c

index e510878d397fe01681f3013d5c4bea1c0fbd6e32..d00327884c5e31042f6a76488341d2c0b873a6b0 100644 (file)
               <object class="GtkLabel" id="label6">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
-                <property name="label" translatable="yes">Code</property>
+                <property name="label" translatable="yes">CN</property>
               </object>
               <packing>
                 <property name="x_options">GTK_FILL</property>
               <object class="GtkEntry" id="entry1">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="max_length">10</property>
                 <property name="invisible_char">&#x25CF;</property>
               </object>
               <packing>
               <object class="GtkEntry" id="entry2">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="max_length">100</property>
                 <property name="invisible_char">&#x25CF;</property>
               </object>
               <packing>
               <object class="GtkEntry" id="entry3">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="max_length">100</property>
                 <property name="invisible_char">&#x25CF;</property>
               </object>
               <packing>
               <object class="GtkEntry" id="entry5">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="max_length">10</property>
                 <property name="invisible_char">&#x25CF;</property>
               </object>
               <packing>
index 29b887a24a9f6fc853c04f5659b427b5bb694528..5429cb148d754e197f13dc4ee6518dd4dc0975a8 100644 (file)
@@ -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
index 7893322f29968fffab2a3017e1caa371c290c5b6..b7b57577c4f94f86f58a2e96c71b6165dc6364f0 100644 (file)
@@ -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),