From: Andrea Zagli Date: Sun, 8 Aug 2010 08:13:21 +0000 (+0200) Subject: Import iniziale. X-Git-Tag: v0.0.1~3 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=ef56872c1effa7d54a5fa88643d5fa3442cd3a5d;p=solipa%2Futenti Import iniziale. --- ef56872c1effa7d54a5fa88643d5fa3442cd3a5d diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..948556f --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Andrea Zagli diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..9768a98 --- /dev/null +++ b/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src data diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..1745655 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Run this to generate all the initial makefiles, etc. + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. + +PKG_NAME="mezzi" + +(test -f $srcdir/configure.ac \ + && test -d $srcdir/src \ + && test -f $srcdir/src/main.c) || { + echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" + echo " top-level utenti directory" + exit 1 +} + +which gnome-autogen.sh || { + echo "You need to install gnome-common from GNOME and make" + echo "sure the gnome-autogen.sh script is in your \$PATH." + exit 1 +} + +USE_GNOME2_MACROS=1 . gnome-autogen.sh diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..fa592e5 --- /dev/null +++ b/config.h.in @@ -0,0 +1,25 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Version number of package */ +#undef VERSION + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..2bdc4b3 --- /dev/null +++ b/configure.ac @@ -0,0 +1,39 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.60) +AC_INIT([utenti], [0.0.1], [azagli@libero.it]) +AC_CONFIG_SRCDIR([src/main.c]) +AC_CONFIG_HEADER([config.h]) + +AM_INIT_AUTOMAKE +AM_MAINTAINER_MODE + +AC_CANONICAL_SYSTEM + +# Checks for programs. +AC_PROG_CC +AC_PROG_CXX + +# Checks for libraries. +PKG_CHECK_MODULES(UTENTI, [gtk+-2.0 >= 2.20.0 + libaute >= 0.0.2]) + +AC_SUBST(UTENTI_CFLAGS) +AC_SUBST(UTENTI_LIBS) + +# Checks for header files. + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST + +# Checks for library functions. + +AC_CONFIG_FILES([ + Makefile + src/Makefile + data/Makefile + data/utenti/Makefile + data/utenti/gui/Makefile +]) +AC_OUTPUT diff --git a/data/Makefile.am b/data/Makefile.am new file mode 100644 index 0000000..cd93d4b --- /dev/null +++ b/data/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = utenti diff --git a/data/utenti/Makefile.am b/data/utenti/Makefile.am new file mode 100644 index 0000000..13c2b3d --- /dev/null +++ b/data/utenti/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = gui diff --git a/data/utenti/gui/Makefile.am b/data/utenti/gui/Makefile.am new file mode 100644 index 0000000..75f8f6e --- /dev/null +++ b/data/utenti/gui/Makefile.am @@ -0,0 +1,5 @@ +guidir = $(datadir)/utenti/gui + +gui_DATA = utenti.gui + +EXTRA_DIST = $(gui_DATA) diff --git a/data/utenti/gui/utenti.gui b/data/utenti/gui/utenti.gui new file mode 100644 index 0000000..78ba661 --- /dev/null +++ b/data/utenti/gui/utenti.gui @@ -0,0 +1,852 @@ + + + + + + + True + Gestione Utenti - SOLIPA + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 500 + 350 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + False + + + + + True + False + 0 + + + + True + GTK_PACK_DIRECTION_LTR + GTK_PACK_DIRECTION_LTR + + + + True + _Utenti + True + + + + + + + True + gtk-new + True + + + + + + + True + gtk-edit + True + + + + + + + True + gtk-delete + True + + + + + + + True + + + + + + True + gtk-quit + True + + + + + + + + + + + True + A_iuto + True + + + + + + + True + _Sommario + True + + + + True + gtk-help + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + gtk-about + True + + + + + + + + + + 0 + False + False + + + + + + True + GTK_SHADOW_OUT + GTK_POS_LEFT + GTK_POS_TOP + + + + True + GTK_ORIENTATION_HORIZONTAL + GTK_TOOLBAR_ICONS + True + True + + + + True + Nuovo utente + gtk-new + True + True + False + + + + False + True + + + + + + True + Modifica utente + gtk-edit + True + True + False + + + + False + True + + + + + + True + Elimina utente + gtk-delete + True + True + False + + + + False + True + + + + + + True + True + True + True + + + False + False + + + + + + True + Esci + gtk-quit + True + True + False + + + + False + True + + + + + + + 0 + False + True + + + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + False + False + False + + + + + + 0 + True + True + + + + + + + + True + False + SOLIPA - Gestione Utenti + Copyright (C) 2006 Andrea Zagli + Gestione Utenti SOLIPA è software libero; è possibile ridistribuirlo e/o +modificarlo secondo i termini della licenza GNU General Public License, +come pubblicata dalla Free Software Foundation; versione 2 della +licenza, o (a scelta) una versione più recente. + +Gestione Utenti SOLIPA è distribuito nella speranza che possa +risultare utile, ma SENZA ALCUNA GARANZIA, nemmeno la garanzia +implicita di COMMERCIABILITÀ o APPLICABILITÀ PER UNO SCOPO +PARTICOLARE. Per maggiori dettagli consultare la GNU General Public +License. + +Una copia della GNU General Public License dovrebbe essere stata +fornita con Nautilus. In caso contrario scrivere a: + Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA + False + Andrea Zagli <azagli@libero.it> + translator-credits + + + + Utente - Gestione utenti SOLIPA + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + True + 450 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 5 + True + 9 + 2 + False + 3 + 3 + + + + True + Codice + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + True + True + True + 20 + + True + * + True + + + 1 + 2 + 0 + 1 + + + + + + + True + Ultimo accesso + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 7 + 8 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 1 + 2 + 7 + 8 + fill + + + + + + + True + Abilitato + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 6 + 7 + fill + + + + + + + True + True + + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 1 + 2 + 6 + 7 + fill + + + + + + + True + Conferma password + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 5 + 6 + fill + + + + + + + True + True + True + False + 0 + + True + * + True + + + 1 + 2 + 5 + 6 + + + + + + + True + Password + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 4 + 5 + fill + + + + + + + True + True + True + False + 0 + + True + * + True + + + 1 + 2 + 4 + 5 + + + + + + + True + Nome + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + True + True + True + 100 + + True + * + True + + + 1 + 2 + 3 + 4 + + + + + + + True + Cognome + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + True + True + True + 100 + + True + * + True + + + 1 + 2 + 2 + 3 + + + + + + + True + ID personale + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + True + True + True + 0 + + True + * + True + + + 1 + 2 + 1 + 2 + + + + + + + True + Descrizione + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 8 + 9 + fill + + + + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 1 + 2 + 8 + 9 + fill + fill + + + + + 0 + True + True + + + + + + + diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..ad7f710 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,12 @@ +gladedir = $(datadir)/utenti/glade + +AM_CPPFLAGS = -I.. \ + $(UTENTI_CFLAGS) \ + -DGLADEDIR=\""$(gladedir)"\" + +LIBS = $(UTENTI_LIBS) \ + -export-dynamic + +bin_PROGRAMS = utenti + +utenti_SOURCES = main.c diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..c12f115 --- /dev/null +++ b/src/main.c @@ -0,0 +1,603 @@ +/* + * Copyright (C) 2006 Andrea Zagli + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H + #include +#endif + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum +{ + COL_STATO, + COL_COD, + COL_COGNOME, + COL_NOME, + UTENTI_COLS +}; + +static GtkWidget *w, + *tr_utenti, + *txt_codice, + *txt_password, + *txt_conferma_password, + *btn_ok_utente; + +static GtkListStore *store_utenti; + +static GtkTreeSelection *sel_utenti; + +static GladeXML *gla_utente; +static GtkWidget *diag_utente; +static Form *frm_utente; + +static const SOLIPA *solipa; +static GdaO *gdao; + +/* PRIVATE */ +static gboolean +crea_tr_utenti () +{ + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + + store_utenti = gtk_list_store_new (UTENTI_COLS, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING); + + gtk_tree_view_set_model (GTK_TREE_VIEW (tr_utenti), GTK_TREE_MODEL (store_utenti)); + + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("Stato", + renderer, + "text", COL_STATO, + NULL); + gtk_tree_view_column_set_resizable (column, TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (tr_utenti), column); + + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("Codice", + renderer, + "text", COL_COD, + NULL); + gtk_tree_view_column_set_resizable (column, TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (tr_utenti), column); + + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("Cognome", + renderer, + "text", COL_COGNOME, + NULL); + gtk_tree_view_column_set_resizable (column, TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (tr_utenti), column); + + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("Nome", + renderer, + "text", COL_NOME, + NULL); + gtk_tree_view_column_set_resizable (column, TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (tr_utenti), column); + + sel_utenti = gtk_tree_view_get_selection (GTK_TREE_VIEW (tr_utenti)); +} + +static gboolean +riempi_tr_utenti () +{ + gtk_list_store_clear (store_utenti); + + GdaDataModel *dm = gdao_query (gdao, "SELECT codice, cognome, nome, abilitato, stato " + "FROM utenti"); + if (dm != NULL) + { + GtkTreeIter iter; + gint row; + gint rows = gda_data_model_get_n_rows (dm); + gchar *stato; + + for (row = 0; row < rows; row++) + { + if (strcmp (gdao_data_model_get_field_value_stringify_at (dm, row, "stato"), "E") == 0) + { + stato = g_strdup ("E"); + } + else if (!gdao_data_model_get_field_value_boolean_at (dm, row, "abilitato")) + { + stato = g_strdup ("D"); + } + else + { + stato = g_strdup (""); + } + + gtk_list_store_append (store_utenti, &iter); + gtk_list_store_set (store_utenti, &iter, + COL_STATO, stato, + COL_COD, gdao_data_model_get_field_value_stringify_at (dm, row, "codice"), + COL_COGNOME, gdao_data_model_get_field_value_stringify_at (dm, row, "cognome"), + COL_NOME, gdao_data_model_get_field_value_stringify_at (dm, row, "nome"), + -1); + } + } +} + +/* CALLBACKS */ +void +on_mnu_utenti_nuovo_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + form_clear (frm_utente); + + while (TRUE) + { + if (gtk_dialog_run (GTK_DIALOG (diag_utente)) == GTK_RESPONSE_OK) + { + if (form_check (frm_utente)) + { + gchar *password; + gchar *password_conferma; + + password = g_strdup (gtk_entry_get_text (GTK_ENTRY (txt_password))); + password_conferma = g_strdup (gtk_entry_get_text (GTK_ENTRY (txt_conferma_password))); + + g_strstrip (password); + g_strstrip (password_conferma); + + if (strcmp (password, "") != 0 + && strcmp (password, password_conferma) == 0) + { + gchar *sql; + + sql = form_get_sql (frm_utente, FORM_SQL_INSERT); + if (gdao_execute (gdao, sql) < 0) + { + g_warning ("Errore nell'inserimento del nuovo utente."); + } + else + { + gchar *codice; + GModule *module; + + codice = g_strdup (gtk_entry_get_text (GTK_ENTRY (txt_codice))); + g_strstrip (codice); + + /* carico il modulo per l'autenticazione */ + module = aute_plugin_get_module (solipa->confi); + if (module != NULL) + { + gboolean (*crea_utente) (Confi *confi, const gchar *codice, const gchar *password); + + if (!g_module_symbol (module, "crea_utente", (gpointer *)&crea_utente)) + { + g_warning ("Errore nel caricamento della funzione del plugin di autenticazione."); + } + else + { + (*crea_utente) (solipa->confi, codice, password); + } + } + + riempi_tr_utenti (); + } + break; + } + else + { + GtkWidget *diag; + + diag = gtk_message_dialog_new (GTK_WINDOW (diag_utente), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "La password o la sua conferma sono vuote o non coincidono."); + gtk_dialog_run (GTK_DIALOG (diag)); + gtk_widget_destroy (diag); + gtk_widget_grab_focus (txt_password); + } + } + else + { + GtkWidget *diag; + + diag = gtk_message_dialog_new (GTK_WINDOW (diag_utente), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Inserire tutti i campi obbligatori."); + gtk_dialog_run (GTK_DIALOG (diag)); + gtk_widget_destroy (diag); + } + } + else + { + /* GTK_RESPONSE_CANCEL */ + break; + } + } + gtk_widget_hide (diag_utente); +} + +void +on_mnu_utenti_modifica_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + GtkTreeIter iter; + + if (gtk_tree_selection_get_selected (sel_utenti, NULL, &iter)) + { + gchar *codice; + gchar *sql; + gchar *stato; + GdaDataModel *dm; + + gtk_tree_model_get (GTK_TREE_MODEL (store_utenti), &iter, + COL_COD, &codice, + COL_STATO, &stato, + -1); + + gtk_entry_set_text (GTK_ENTRY (txt_codice), codice); + gtk_editable_set_editable (GTK_EDITABLE (txt_codice), FALSE); + + sql = form_get_sql (frm_utente, FORM_SQL_SELECT); + dm = gdao_query (gdao, sql); + form_clear (frm_utente); + form_fill_from_datamodel (frm_utente, dm, 0); + + if (strcmp (stato, "E") == 0) + { + gtk_widget_set_sensitive (btn_ok_utente, FALSE); + } + else + { + gtk_widget_set_sensitive (btn_ok_utente, TRUE); + } + + while (TRUE) + { + if (gtk_dialog_run (GTK_DIALOG (diag_utente)) == GTK_RESPONSE_OK) + { + if (form_check (frm_utente)) + { + gchar *password; + gchar *password_conferma; + + password = g_strdup (gtk_entry_get_text (GTK_ENTRY (txt_password))); + password_conferma = g_strdup (gtk_entry_get_text (GTK_ENTRY (txt_conferma_password))); + + g_strstrip (password); + g_strstrip (password_conferma); + + if (strcmp (password, "") != 0 + && strcmp (password, password_conferma) == 0) + { + gchar *sql; + + sql = form_get_sql (frm_utente, FORM_SQL_UPDATE); + if (gdao_execute (gdao, sql) < 0) + { + g_warning ("Errore nella modifica dell'utente."); + } + else + { + gchar *codice; + GModule *module; + + codice = g_strdup (gtk_entry_get_text (GTK_ENTRY (txt_codice))); + g_strstrip (codice); + + /* carico il modulo per l'autenticazione */ + module = aute_plugin_get_module (solipa->confi); + if (module != NULL) + { + gboolean (*modifica_utente) (Confi *confi, const gchar *codice, const gchar *password); + + if (!g_module_symbol (module, "modifica_utente", (gpointer *)&modifica_utente)) + { + g_warning ("Errore nel caricamento della funzione del plugin di autenticazione."); + } + else + { + (*modifica_utente) (solipa->confi, codice, password); + } + } + + riempi_tr_utenti (); + } + break; + } + else + { + GtkWidget *diag; + + diag = gtk_message_dialog_new (GTK_WINDOW (diag_utente), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "La password o la sua conferma sono vuote o non coincidono."); + gtk_dialog_run (GTK_DIALOG (diag)); + gtk_widget_destroy (diag); + gtk_widget_grab_focus (txt_password); + } + } + else + { + GtkWidget *diag; + + diag = gtk_message_dialog_new (GTK_WINDOW (diag_utente), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_OK, + "Inserire tutti i campi obbligatori."); + gtk_dialog_run (GTK_DIALOG (diag)); + gtk_widget_destroy (diag); + } + } + else + { + /* GTK_RESPONSE_CANCEL */ + break; + } + } + + gtk_editable_set_editable (GTK_EDITABLE (txt_codice), TRUE); + gtk_widget_hide (diag_utente); + } + else + { + /* TO DO */ + } +} + +void +on_mnu_utenti_elimina_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + GtkTreeIter iter; + + if (gtk_tree_selection_get_selected (sel_utenti, NULL, &iter)) + { + GtkWidget *diag = gtk_message_dialog_new (GTK_WINDOW (w), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_QUESTION, + GTK_BUTTONS_YES_NO, + "Sicuri di voler eliminare l'utente selezionato?"); + if (gtk_dialog_run (GTK_DIALOG (diag)) == GTK_RESPONSE_YES) + { + gchar *sql; + gchar *codice; + + gtk_tree_model_get (GTK_TREE_MODEL (store_utenti), &iter, + COL_COD, &codice, + -1); + + sql = g_strdup_printf ("UPDATE utenti " + "SET stato = 'E' " + "WHERE codice = '%s'", + codice); + if (gdao_execute (gdao, sql) < 0) + { + g_warning ("Errore nell'eliminazione dell'utente."); + } + else + { + GModule *module; + + /* carico il modulo per l'autenticazione */ + module = aute_plugin_get_module (solipa->confi); + if (module != NULL) + { + gboolean (*elimina_utente) (Confi *confi, const gchar *codice); + + if (!g_module_symbol (module, "elimina_utente", (gpointer *)&elimina_utente)) + { + g_warning ("Errore nel caricamento della funzione del plugin di autenticazione."); + } + else + { + (*elimina_utente) (solipa->confi, codice); + } + } + + riempi_tr_utenti (); + } + } + gtk_widget_destroy (diag); + } + else + { + /* TO DO */ + } +} + +void +on_mnu_help_about_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + GladeXML *gla_about = glade_xml_new (GLADEDIR "/utenti.glade", "diag_about", NULL); + GtkWidget *diag = glade_xml_get_widget (gla_about, "diag_about"); + + gtk_dialog_run (GTK_DIALOG (diag)); + gtk_widget_destroy (diag); +} + +int +main (int argc, char **argv) +{ + GladeXML *gla_main; + gchar *provider_id; + gchar *cnc_string; + FormField *ffld; + FormWidget *fwdg; + FormKey *fkey; + + gtk_init (&argc, &argv); + + solipa = solipa_init (&argc, &argv); + if (solipa == NULL) + { + return 0; + } + + provider_id = confi_path_get_value (solipa->confi, "utenti/db/provider_id"); + cnc_string = confi_path_get_value (solipa->confi, "utenti/db/cnc_string"); + + gdao = gdao_new_from_string (NULL, provider_id, cnc_string); + + gla_main = glade_xml_new (GLADEDIR "/utenti.glade", "w_main", NULL); + glade_xml_signal_autoconnect (gla_main); + + w = glade_xml_get_widget (gla_main, "w_main"); + tr_utenti = glade_xml_get_widget (gla_main, "tr_utenti"); + + gla_utente = glade_xml_new (GLADEDIR "/utenti.glade", "diag_utente", NULL); + diag_utente = glade_xml_get_widget (gla_utente, "diag_utente"); + btn_ok_utente = glade_xml_get_widget (gla_utente, "btn_ok"); + + /* creo l'oggetto Form per diag_utente */ + frm_utente = form_new (); + + fkey = form_key_new (); + g_object_set (G_OBJECT (frm_utente), + "key", fkey, + "table", "utenti", + NULL); + + txt_codice = glade_xml_get_widget (gla_utente, "txt_codice"); + txt_password = glade_xml_get_widget (gla_utente, "txt_password"); + txt_conferma_password = glade_xml_get_widget (gla_utente, "txt_conferma_password"); + + fwdg = form_widget_entry_new (); + form_widget_set_from_glade (fwdg, gla_utente, "txt_codice"); + + ffld = form_field_text_new (); + g_object_set (G_OBJECT (ffld), + "field", "codice", + "form-widget", fwdg, + NULL); + form_add_field (frm_utente, ffld); + form_key_add_field (fkey, ffld); + + fwdg = form_widget_entry_new (); + form_widget_set_from_glade (fwdg, gla_utente, "txt_id_personale"); + + ffld = form_field_integer_new (); + g_object_set (G_OBJECT (ffld), + "field", "id_personale", + "form-widget", fwdg, + NULL); + form_add_field (frm_utente, ffld); + + fwdg = form_widget_entry_new (); + form_widget_set_from_glade (fwdg, gla_utente, "txt_cognome"); + + ffld = form_field_text_new (); + g_object_set (G_OBJECT (ffld), + "field", "cognome", + "form-widget", fwdg, + NULL); + form_add_field (frm_utente, ffld); + + fwdg = form_widget_entry_new (); + form_widget_set_from_glade (fwdg, gla_utente, "txt_nome"); + + ffld = form_field_text_new (); + g_object_set (G_OBJECT (ffld), + "field", "nome", + "form-widget", fwdg, + NULL); + form_add_field (frm_utente, ffld); + + fwdg = form_widget_entry_new (); + form_widget_set_from_glade (fwdg, gla_utente, "txt_password"); + + ffld = form_field_text_new (); + g_object_set (G_OBJECT (ffld), + "form-widget", fwdg, + NULL); + form_add_field (frm_utente, ffld); + + fwdg = form_widget_entry_new (); + form_widget_set_from_glade (fwdg, gla_utente, "txt_conferma_password"); + + ffld = form_field_text_new (); + g_object_set (G_OBJECT (ffld), + "form-widget", fwdg, + NULL); + form_add_field (frm_utente, ffld); + + fwdg = form_widget_check_new (); + form_widget_set_from_glade (fwdg, gla_utente, "chk_abilitato"); + + ffld = form_field_boolean_new (); + g_object_set (G_OBJECT (ffld), + "field", "abilitato", + "form-widget", fwdg, + "default", TRUE, + NULL); + form_add_field (frm_utente, ffld); + + fwdg = form_widget_label_new (); + form_widget_set_from_glade (fwdg, gla_utente, "lbl_ultimo_accesso"); + + ffld = form_field_datetime_new (); + g_object_set (G_OBJECT (ffld), + "field", "ultimo_accesso", + "form-widget", fwdg, + NULL); + form_add_field (frm_utente, ffld); + + fwdg = form_widget_textview_new (); + form_widget_set_from_glade (fwdg, gla_utente, "txtv_descrizione"); + + ffld = form_field_text_new (); + g_object_set (G_OBJECT (ffld), + "field", "descrizione", + "form-widget", fwdg, + NULL); + form_add_field (frm_utente, ffld); + + crea_tr_utenti (); + if (gdao != NULL) + { + riempi_tr_utenti (); + } + + gtk_main (); + + return 0; +} diff --git a/tests/test.db b/tests/test.db new file mode 100644 index 0000000..8918cd1 Binary files /dev/null and b/tests/test.db differ