From 2b02cf378fdabc8bf01715f6adc223cb971b48bc Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Wed, 16 Nov 2016 17:41:34 +0100 Subject: [PATCH] Inizio migrazione a libzakconfi, libzakautho e libzakauthe. --- configure.ac | 17 ++- docs/messi/examples/messi.conf | 14 +- po/Makefile.in.in | 268 +++++++++++++++++++++++++++++++++ src/atti.c | 10 +- src/atto.c | 16 +- src/commons.h | 8 +- src/main.c | 185 ++++++++--------------- src/registro.c | 14 +- src/tipiatto.c | 14 +- src/tipoatto.c | 14 +- src/trovaatti.c | 12 +- src/trovaregistro.c | 12 +- 12 files changed, 396 insertions(+), 188 deletions(-) create mode 100644 po/Makefile.in.in diff --git a/configure.ac b/configure.ac index 2903d93..6bbe05e 100644 --- a/configure.ac +++ b/configure.ac @@ -23,14 +23,15 @@ AC_PROG_CC # Checks for libraries. PKG_CHECK_MODULES([MESSI], [gtk+-3.0 >= 3.0.0 - libgtkform >= 0.5.0 - libgtkformui >= 0.5.0 - libaute >= 0.2.0 - libautoz >= 0.0.5 - libsolipa >= 0.5.0 - liborganigramma >= 0.0.1 - libzakaudit >= 0.5.0 - libreptool >= 0.5.0]) + libzakconfi + libgtkform >= 0.5.0 + libgtkformui >= 0.5.0 + libzakauthe >= 0.5.0 + libzakautho >= 0.0.5 + libsolipa >= 0.5.0 + liborganigramma >= 0.0.1 + libzakaudit >= 0.5.0 + libreptool >= 0.5.0]) AC_SUBST(MESSI_CFLAGS) AC_SUBST(MESSI_LIBS) diff --git a/docs/messi/examples/messi.conf b/docs/messi/examples/messi.conf index 15ce247..08703da 100644 --- a/docs/messi/examples/messi.conf +++ b/docs/messi/examples/messi.conf @@ -1,23 +1,25 @@ [DB_TERRITORIO] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=territorio -[AUTOZ_TERRITORIO] +[ZAKAUTHO_TERRITORIO] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=autoz [DB_ORGANIGRAMMA] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=organigramma -[AUTOZ_ORGANIGRAMMA] +[ZAKAUTHO_ORGANIGRAMMA] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=autoz -[AUTE] -plugin=/usr/local/lib/libaute/plugins/libaute-db +[libzakauthe] +plugin=zakauthedb + +[libzakauthe/libzakauthedb/db] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=autedb -[AUTOZ] +[ZAKAUTHO] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=autoz -[AUDIT] +[ZAKAUDIT] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=audit [DB] diff --git a/po/Makefile.in.in b/po/Makefile.in.in new file mode 100644 index 0000000..e6c32cb --- /dev/null +++ b/po/Makefile.in.in @@ -0,0 +1,268 @@ +# Makefile for program source directory in GNU NLS utilities package. +# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper +# +# This file file be copied and used freely without restrictions. It can +# be used in projects which are not available under the GNU Public License +# but which still want to provide support for the GNU gettext functionality. +# Please note that the actual code is *not* freely available. +# +# - Modified by Owen Taylor to use GETTEXT_PACKAGE +# instead of PACKAGE and to look for po2tbl in ./ not in intl/ +# +# - Modified by jacob berkman to install +# Makefile.in.in and po2tbl.sed.in for use with glib-gettextize + +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = @SHELL@ +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ +datadir = @datadir@ +libdir = @libdir@ +localedir = $(libdir)/locale +gnulocaledir = $(datadir)/locale +gettextsrcdir = $(datadir)/glib-2.0/gettext/po +subdir = po + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +MKINSTALLDIRS = mkdir -p + +CC = @CC@ +GENCAT = @GENCAT@ +GMSGFMT = @GMSGFMT@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +XGETTEXT = @XGETTEXT@ +MSGMERGE = msgmerge + +DEFS = @DEFS@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ + +INCLUDES = -I.. -I$(top_srcdir)/intl + +COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS) + +SOURCES = +POFILES = @POFILES@ +GMOFILES = @GMOFILES@ +DISTFILES = LINGUAS ChangeLog Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \ +$(POFILES) $(GMOFILES) $(SOURCES) + +POTFILES = \ + +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +INSTOBJEXT = @INSTOBJEXT@ + +.SUFFIXES: +.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat + +.c.o: + $(COMPILE) $< + +.po.pox: + $(MAKE) $(GETTEXT_PACKAGE).pot + $(MSGMERGE) $< $(srcdir)/$(GETTEXT_PACKAGE).pot -o $*.pox + +.po.mo: + $(MSGFMT) -o $@ $< + +.po.gmo: + $(AM_V_GEN) file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \ + && rm -f $$file && $(GMSGFMT) $(MSGFMT_OPTS) -o $$file $< + +.po.cat: + sed -f ../intl/po2msg.sed < $< > $*.msg \ + && rm -f $@ && $(GENCAT) $@ $*.msg + + +all: all-@USE_NLS@ + +all-yes: $(CATALOGS) +all-no: + +$(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES) + $(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) \ + --msgid-bugs-address='http://bugzilla.gnome.org/enter_bug.cgi?product=glib&keywords=I18N+L10N&component=general' \ + --add-comments --keyword=_ --keyword=N_ \ + --keyword=C_:1c,2 \ + --keyword=NC_:1c,2 \ + --keyword=g_dcgettext:2 \ + --keyword=g_dngettext:2,3 \ + --keyword=g_dpgettext2:2c,3 \ + --flag=N_:1:pass-c-format \ + --flag=C_:2:pass-c-format \ + --flag=NC_:2:pass-c-format \ + --flag=g_dngettext:2:pass-c-format \ + --flag=g_strdup_printf:1:c-format \ + --flag=g_string_printf:2:c-format \ + --flag=g_string_append_printf:2:c-format \ + --flag=g_error_new:3:c-format \ + --flag=g_set_error:4:c-format \ + --flag=g_markup_printf_escaped:1:c-format \ + --flag=g_log:3:c-format \ + --flag=g_print:1:c-format \ + --flag=g_printerr:1:c-format \ + --flag=g_printf:1:c-format \ + --flag=g_fprintf:2:c-format \ + --flag=g_sprintf:2:c-format \ + --flag=g_snprintf:3:c-format \ + --flag=g_scanner_error:2:c-format \ + --flag=g_scanner_warn:2:c-format \ + $(POTFILES) \ + && test ! -f $(GETTEXT_PACKAGE).po \ + || ( rm -f $(srcdir)/$(GETTEXT_PACKAGE).pot \ + && mv $(GETTEXT_PACKAGE).po $(srcdir)/$(GETTEXT_PACKAGE).pot ) + +install: install-exec install-data +install-exec: +install-data: install-data-@USE_NLS@ +install-data-no: all +install-data-yes: all + $(MKINSTALLDIRS) $(DESTDIR)$(datadir); \ + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + case "$$cat" in \ + *.gmo) destdir=$(gnulocaledir);; \ + *) destdir=$(localedir);; \ + esac; \ + lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ + dir=$(DESTDIR)$$destdir/$$lang/LC_MESSAGES; \ + $(MKINSTALLDIRS) $$dir; \ + if test -r $$cat; then \ + $(INSTALL_DATA) $$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \ + echo "installing $$cat as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \ + else \ + $(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \ + echo "installing $(srcdir)/$$cat as" \ + "$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \ + fi; \ + if test -r $$cat.m; then \ + $(INSTALL_DATA) $$cat.m $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \ + echo "installing $$cat.m as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \ + else \ + if test -r $(srcdir)/$$cat.m ; then \ + $(INSTALL_DATA) $(srcdir)/$$cat.m \ + $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \ + echo "installing $(srcdir)/$$cat as" \ + "$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \ + else \ + true; \ + fi; \ + fi; \ + done + if test "$(PACKAGE)" = "glib"; then \ + $(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \ + $(INSTALL_DATA) $(srcdir)/Makefile.in.in \ + $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \ + else \ + : ; \ + fi + +# Define this as empty until I found a useful application. +installcheck: + +uninstall: + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ + rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \ + rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \ + rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \ + rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \ + done + if test "$(PACKAGE)" = "glib"; then \ + rm -f $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \ + fi + +check: all + +dvi info tags TAGS ID: + +mostlyclean: + rm -f core core.* *.pox $(GETTEXT_PACKAGE).po *.old.po cat-id-tbl.tmp + rm -fr *.o + +clean: mostlyclean + +distclean: clean + rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f $(GMOFILES) + +distdir = ../$(GETTEXT_PACKAGE)-$(VERSION)/$(subdir) +dist distdir: $(DISTFILES) + dists="$(DISTFILES)"; \ + for file in $$dists; do \ + ln $(srcdir)/$$file $(distdir) 2> /dev/null \ + || cp -p $(srcdir)/$$file $(distdir); \ + done + +update-po: Makefile + $(MAKE) $(GETTEXT_PACKAGE).pot + tmpdir=`pwd`; \ + cd $(srcdir); \ + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \ + echo "$$lang:"; \ + if $(MSGMERGE) $$lang.po $(GETTEXT_PACKAGE).pot -o $$tmpdir/$$lang.new.po; then \ + if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "msgmerge for $$cat failed!"; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi; \ + done + +# POTFILES is created from POTFILES.in by stripping comments, empty lines +# and Intltool tags (enclosed in square brackets), and appending a full +# relative path to them +POTFILES: POTFILES.in + ( if test 'x$(srcdir)' != 'x.'; then \ + posrcprefix='$(top_srcdir)/'; \ + else \ + posrcprefix="../"; \ + fi; \ + rm -f $@-t $@ \ + && (sed -e '/^#/d' \ + -e "s/^\[.*\] +//" \ + -e '/^[ ]*$$/d' \ + -e "s@.*@ $$posrcprefix& \\\\@" < $(srcdir)/$@.in \ + | sed -e '$$s/\\$$//') > $@-t \ + && chmod a-w $@-t \ + && mv $@-t $@ ) + +Makefile: Makefile.in.in ../config.status POTFILES + cd .. \ + && $(SHELL) ./config.status $(subdir)/$@.in + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/atti.c b/src/atti.c index 05ab168..0e63029 100644 --- a/src/atti.c +++ b/src/atti.c @@ -19,7 +19,7 @@ #include -#include +#include #include #include @@ -152,7 +152,7 @@ Atti *atti_new (Commons *commons, gboolean selezione) { GError *error; - AutozIResource *ires1; + ZakAuthoIResource *ires1; Atti *a = ATTI (g_object_new (atti_get_type (), NULL)); @@ -213,8 +213,8 @@ Atti atti_carica (a); - ires1 = autoz_get_resource_from_id (priv->commons->autoz, "messi_rw"); - if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE)) + ires1 = zak_autho_get_resource_from_id (priv->commons->autoz, "messi_rw"); + if (!zak_autho_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button4")), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button6")), FALSE); @@ -257,7 +257,7 @@ atti_carica (Atti *atti) GtkTreeIter iter; - AutozIResource *ires1; + ZakAuthoIResource *ires1; GHashTable *ht_ufficio; GValue *gv_ufficio; diff --git a/src/atto.c b/src/atto.c index a44a679..1b3d7b3 100644 --- a/src/atto.c +++ b/src/atto.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Andrea Zagli + * Copyright (C) 2013-2016 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,7 +19,7 @@ #include -#include +#include #include #include #include @@ -170,7 +170,7 @@ Atto *atto_new (Commons *commons, gint id) { GError *error; - AutozIResource *ires1; + ZakAuthoIResource *ires1; Atto *a = ATTO (g_object_new (atto_get_type (), NULL)); @@ -260,8 +260,8 @@ Atto atto_carica (a); } - ires1 = autoz_get_resource_from_id (priv->commons->autoz, "messi_rw"); - if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE)) + ires1 = zak_autho_get_resource_from_id (priv->commons->autoz, "messi_rw"); + if (!zak_autho_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE)) { gtk_form_set_sensitive_by_name (priv->form, FALSE, "button39", @@ -552,13 +552,13 @@ atto_on_ufficio_ask_toshow (gpointer instance, guint id, gpointer user_data) Atto *a = (Atto *)user_data; AttoPrivate *priv = ATTO_GET_PRIVATE (a); - AutozIResource *ires1; + ZakAuthoIResource *ires1; ret = TRUE; /* per adesso controllo solo gli uffici */ - ires1 = autoz_get_resource_from_id (priv->commons->autoz, g_strdup_printf ("opengov_u_%d_r_0", id)); - ret = autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE); + ires1 = zak_autho_get_resource_from_id (priv->commons->autoz, g_strdup_printf ("opengov_u_%d_r_0", id)); + ret = zak_autho_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE); return ret; } diff --git a/src/commons.h b/src/commons.h index dcb1d95..ae62bd5 100644 --- a/src/commons.h +++ b/src/commons.h @@ -28,8 +28,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -50,8 +50,8 @@ typedef struct const gchar *guifile; const gchar *utente; - Autoz *autoz; - AutozIRole *role_utente; + ZakAutho *autoz; + ZakAuthoIRole *role_utente; Solipa *solipa; diff --git a/src/main.c b/src/main.c index c5277e8..c5d0640 100644 --- a/src/main.c +++ b/src/main.c @@ -24,8 +24,9 @@ #include -#include -#include +#include +#include +#include #include #include #include @@ -40,8 +41,6 @@ static Commons *commons; static ZakAudit *audit; -static GKeyFile *config; - static GtkWidget *w; static GtkWidget *vbx_body; static GtkWidget *vbx_body_child; @@ -170,9 +169,11 @@ main (int argc, char *argv[]) { GError *error; + ZakConfi *confi; + GdaConnection *gdacon; - Aute *aute; + ZakAuthe *aute; gchar **aute_params; gsize n_aute_params; GSList *sl_aute_params; @@ -183,7 +184,7 @@ main (int argc, char *argv[]) gint i; - AutozIResource *ires1; + ZakAuthoIResource *ires1; #ifdef G_OS_WIN32 if (g_getenv ("TZ") == NULL) @@ -208,37 +209,26 @@ main (int argc, char *argv[]) g_error ("Occorre passare a riga di comando il file di configurazione."); } - error = NULL; - config = g_key_file_new (); - if (!g_key_file_load_from_file (config, argv[1], G_KEY_FILE_NONE, &error)) + confi = zak_confi_new (argv[1]); + if (confi == NULL) { - g_error ("Impossibile caricare il file di configurazione specificato: %s.", argv[1]); + g_error ("Impossibile leggere la configurazione specificata: %s.", argv[1]); } /* leggo i parametri per l'autenticazione */ - error = NULL; - aute_params = g_key_file_get_keys (config, "AUTE", &n_aute_params, &error); - if (aute_params == NULL) - { - g_error ("Impossibile leggere la configurazione per il sistema di autenticazione."); - } - sl_aute_params = NULL; - for (i = 0; i < n_aute_params; i++) - { - error = NULL; - sl_aute_params = g_slist_append (sl_aute_params, g_key_file_get_string (config, "AUTE", aute_params[i], &error)); - } - - g_strfreev (aute_params); + sl_aute_params = g_slist_append (sl_aute_params, "{libzakconfi}"); + sl_aute_params = g_slist_append (sl_aute_params, confi); /* autenticazione */ - aute = aute_new (); - aute_set_config (aute, sl_aute_params); + aute = zak_authe_new (); + zak_authe_set_config (aute, sl_aute_params); + + g_strfreev (aute_params); while (TRUE) { - utente = aute_autentica (aute); + utente = zak_authe_authe (aute); if (utente == NULL) { @@ -259,7 +249,6 @@ main (int argc, char *argv[]) commons->territorio_commons = g_new0 (TerritorioCommons, 1); commons->organigramma_commons = g_new0 (OrganigrammaCommons, 1); - commons->autozgui_commons = g_new0 (AutozGuiCommons, 1); commons->utente = utente; commons->territorio_commons->utente = utente; @@ -289,7 +278,6 @@ main (int argc, char *argv[]) commons->territorio_commons->formdir = g_build_filename ("/mingw", "share", "territorio", "form", NULL); commons->organigramma_commons->guidir = g_build_filename ("/mingw", "share", "organigramma", "gui", NULL); commons->organigramma_commons->formdir = g_build_filename ("/mingw", "share", "organigramma", "form", NULL); - commons->autozgui_commons->guidir = g_build_filename ("/mingw", "share", "autoz-gui", "gui", NULL); } else { @@ -302,7 +290,6 @@ main (int argc, char *argv[]) commons->territorio_commons->formdir = g_build_filename (moddir, "share", "territorio", "form", NULL); commons->organigramma_commons->guidir = g_build_filename (moddir, "share", "organigramma", "gui", NULL); commons->organigramma_commons->formdir = g_build_filename (moddir, "share", "organigramma", "form", NULL); - commons->autozgui_commons->guidir = g_build_filename (moddir, "share", "autoz-gui", "gui", NULL); } #else @@ -313,28 +300,18 @@ main (int argc, char *argv[]) commons->territorio_commons->formdir = g_build_filename ("/usr", "local", "share", "territorio", "form", NULL); commons->organigramma_commons->guidir = g_build_filename ("/usr", "local", "share", "organigramma", "gui", NULL); commons->organigramma_commons->formdir = g_build_filename ("/usr", "local", "share", "organigramma", "form", NULL); - commons->autozgui_commons->guidir = g_build_filename ("/usr", "local", "share", "autoz-gui", "gui", NULL); #endif commons->guifile = g_build_filename (commons->guidir, "messi.gui", NULL); commons->territorio_commons->guifile = g_build_filename (commons->territorio_commons->guidir, "territorio.gui", NULL); commons->organigramma_commons->guifile = g_build_filename (commons->organigramma_commons->guidir, "organigramma.gui", NULL); - commons->autozgui_commons->guifile = g_build_filename (commons->autozgui_commons->guidir, "autoz-gui.ui", NULL); /* leggo la stringa di connessione al db */ - error = NULL; - cnc_string = g_key_file_get_value (config, "DB", "cnc_string", &error); + cnc_string = zak_confi_path_get_value (confi, "DB/cnc_string"); if (cnc_string == NULL) { - if (error != NULL) - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione: %s", error->message); - } - else - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); - } + g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); } commons->gdaex = gdaex_new_from_string (cnc_string); @@ -344,18 +321,10 @@ main (int argc, char *argv[]) } /* leggo la stringa di connessione al db nativa di postgres */ - error = NULL; - cnc_string = g_key_file_get_value (config, "DB", "pg_cnc_string", &error); + cnc_string = zak_confi_path_get_value (confi, "DB/pg_cnc_string"); if (cnc_string == NULL) { - if (error != NULL) - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione: %s", error->message); - } - else - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); - } + g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); } commons->pgcon = PQconnectdb (cnc_string); @@ -365,12 +334,12 @@ main (int argc, char *argv[]) g_error ("Errore nella connessione al database: %s", cnc_string); } - /* leggo i parametri per libautoz */ + /* leggo i parametri per libzakautho */ error = NULL; - cnc_string = g_key_file_get_value (config, "AUTOZ", "cnc_string", &error); + cnc_string = zak_confi_path_get_value (confi, "ZAKAUTHO/cnc_string"); if (cnc_string == NULL) { - g_warning ("Impossibile leggere la stringa di connessione per libautoz dal file di configurazione: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); + g_warning ("Impossibile leggere la stringa di connessione per libzakautho dal file di configurazione."); return 0; } @@ -378,62 +347,48 @@ main (int argc, char *argv[]) gdacon = gda_connection_open_from_string (NULL, cnc_string, NULL, 0, &error); if (gdacon == NULL) { - g_warning ("Impossibile creare la connessione al db per libautoz: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); + g_warning ("Impossibile creare la connessione al db per libzakautho: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); return 0; } - commons->autoz = autoz_new (); + commons->autoz = zak_autho_new (); if (commons->autoz == NULL) { - g_warning ("Impossibile creare l'oggetto per libautoz."); + g_warning ("Impossibile creare l'oggetto per libzakautho."); return 0; } - if (!autoz_load_from_db (commons->autoz, gdacon, NULL, TRUE)) + if (!zak_autho_load_from_db (commons->autoz, gdacon, NULL, TRUE)) { - g_warning ("Impossibile caricare la configurazione per libautoz dal db."); + g_warning ("Impossibile caricare la configurazione per libzakautho dal db."); return 0; } - commons->role_utente = autoz_get_role_from_id (commons->autoz, commons->utente); + commons->role_utente = zak_autho_get_role_from_id (commons->autoz, commons->utente); if (commons->role_utente == NULL) { - g_warning ("Utente «%s» non trovato nell configurazione di libautoz.", commons->utente); + g_warning ("Utente «%s» non trovato nell configurazione di libzakautho.", commons->utente); return 0; } - if (!autoz_is_allowed (commons->autoz, commons->role_utente, autoz_get_resource_from_id (commons->autoz, "messi_ro"), FALSE) - && !autoz_is_allowed (commons->autoz, commons->role_utente, autoz_get_resource_from_id (commons->autoz, "messi_rw"), FALSE)) + if (!zak_autho_is_allowed (commons->autoz, commons->role_utente, zak_autho_get_resource_from_id (commons->autoz, "messi_ro"), FALSE) + && !zak_autho_is_allowed (commons->autoz, commons->role_utente, zak_autho_get_resource_from_id (commons->autoz, "messi_rw"), FALSE)) { g_critical ("Non si è autorizzati all'utilizzo di questa applicazione."); return 0; } - commons->autozgui_commons->prefix = g_strdup (""); - - commons->autozgui_commons->gdacon = gdacon; - commons->autozgui_commons->gdaparser = gda_connection_create_parser (commons->autozgui_commons->gdacon); - if (!commons->autozgui_commons->gdaparser) - { - /* @cnc doe snot provide its own parser => use default one */ - commons->autozgui_commons->gdaparser = gda_sql_parser_new (); - } - - commons->gdaex_autozgui = gdaex_new_from_connection (gdacon); - - /* leggo i parametri per libaudit */ - error = NULL; - cnc_string = g_key_file_get_value (config, "AUDIT", "cnc_string", &error); + /* leggo i parametri per libzakaudit */ + cnc_string = zak_confi_path_get_value (confi, "ZAKAUDIT/cnc_string"); if (cnc_string == NULL) { - g_warning ("Impossibile leggere la stringa di connessione per libaudit dal file di configurazione: %s\n", - error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); + g_warning ("Impossibile leggere la stringa di connessione per libzakaudit dal file di configurazione."); return 0; } audit = zak_audit_new_from_string (cnc_string); if (audit == NULL) { - g_warning ("Errore nella creazione dell'oggetto per libaudit.\n"); + g_warning ("Errore nella creazione dell'oggetto per libzakaudit."); return 0; } @@ -444,18 +399,10 @@ main (int argc, char *argv[]) commons->solipa = solipa_new (); /* leggo la stringa di connessione al db territorio */ - error = NULL; - cnc_string = g_key_file_get_value (config, "DB_TERRITORIO", "cnc_string", &error); + cnc_string = zak_confi_path_get_value (confi, "DB_TERRITORIO/cnc_string"); if (cnc_string == NULL) { - if (error != NULL) - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione: %s", error->message); - } - else - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); - } + g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); } commons->territorio_commons->gdaex = gdaex_new_from_string (cnc_string); @@ -464,12 +411,11 @@ main (int argc, char *argv[]) g_error ("Errore nella connessione al database: %s", cnc_string); } - /* leggo i parametri per libautoz di territorio */ - error = NULL; - cnc_string = g_key_file_get_value (config, "AUTOZ_TERRITORIO", "cnc_string", &error); + /* leggo i parametri per libzakautho di territorio */ + cnc_string = zak_confi_path_get_value (confi, "ZAKAUTHO_TERRITORIO/cnc_string"); if (cnc_string == NULL) { - g_warning ("Impossibile leggere la stringa di connessione per libautoz dal file di configurazione: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); + g_warning ("Impossibile leggere la stringa di connessione per libzakautho dal file di configurazione."); return 0; } @@ -477,42 +423,34 @@ main (int argc, char *argv[]) gdacon = gda_connection_open_from_string (NULL, cnc_string, NULL, 0, &error); if (gdacon == NULL) { - g_warning ("Impossibile creare la connessione al db per libautoz di territorio: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); + g_warning ("Impossibile creare la connessione al db per libzakautho di territorio: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); return 0; } - commons->territorio_commons->autoz = autoz_new (); + commons->territorio_commons->autoz = zak_autho_new (); if (commons->territorio_commons->autoz == NULL) { - g_warning ("Impossibile creare l'oggetto per libautoz."); + g_warning ("Impossibile creare l'oggetto per libzakautho."); return 0; } - if (!autoz_load_from_db (commons->territorio_commons->autoz, gdacon, NULL, TRUE)) + if (!zak_autho_load_from_db (commons->territorio_commons->autoz, gdacon, NULL, TRUE)) { - g_warning ("Impossibile caricare la configurazione per libautoz dal db."); + g_warning ("Impossibile caricare la configurazione per libzakauto dal db."); return 0; } - commons->territorio_commons->role_utente = autoz_get_role_from_id (commons->territorio_commons->autoz, commons->territorio_commons->utente); + commons->territorio_commons->role_utente = zak_autho_get_role_from_id (commons->territorio_commons->autoz, commons->territorio_commons->utente); if (commons->territorio_commons->role_utente == NULL) { - g_warning ("Utente \"%s\" non trovato nell configurazione di libautoz.", commons->territorio_commons->utente); + g_warning ("Utente \"%s\" non trovato nell configurazione di libzakautho.", commons->territorio_commons->utente); return 0; } /* leggo la stringa di connessione al db organigramma */ - error = NULL; - cnc_string = g_key_file_get_value (config, "DB_ORGANIGRAMMA", "cnc_string", &error); + cnc_string = zak_confi_path_get_value (confi, "DB_ORGANIGRAMMA/cnc_string"); if (cnc_string == NULL) { - if (error != NULL) - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione: %s", error->message); - } - else - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); - } + g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); } commons->organigramma_commons->gdaex = gdaex_new_from_string (cnc_string); @@ -521,12 +459,11 @@ main (int argc, char *argv[]) g_error ("Errore nella connessione al database: %s", cnc_string); } - /* leggo i parametri per libautoz di organigramma */ - error = NULL; - cnc_string = g_key_file_get_value (config, "AUTOZ_ORGANIGRAMMA", "cnc_string", &error); + /* leggo i parametri per libzakautho di organigramma */ + cnc_string = zak_confi_path_get_value (confi, "ZAKAUTHO_ORGANIGRAMMA/cnc_string"); if (cnc_string == NULL) { - g_warning ("Impossibile leggere la stringa di connessione per libautoz dal file di configurazione: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); + g_warning ("Impossibile leggere la stringa di connessione per libzakautho dal file di configurazione."); return 0; } @@ -534,26 +471,26 @@ main (int argc, char *argv[]) gdacon = gda_connection_open_from_string (NULL, cnc_string, NULL, 0, &error); if (gdacon == NULL) { - g_warning ("Impossibile creare la connessione al db per libautoz di organigramma: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); + g_warning ("Impossibile creare la connessione al db per libzakautho di organigramma: %s.\n", error != NULL && error->message != NULL ? error->message : "nessun dettaglio"); return 0; } - commons->organigramma_commons->autoz = autoz_new (); + commons->organigramma_commons->autoz = zak_autho_new (); if (commons->organigramma_commons->autoz == NULL) { - g_warning ("Impossibile creare l'oggetto per libautoz."); + g_warning ("Impossibile creare l'oggetto per libzakautho."); return 0; } - if (!autoz_load_from_db (commons->organigramma_commons->autoz, gdacon, NULL, TRUE)) + if (!zak_autho_load_from_db (commons->organigramma_commons->autoz, gdacon, NULL, TRUE)) { - g_warning ("Impossibile caricare la configurazione per libautoz dal db."); + g_warning ("Impossibile caricare la configurazione per libzakautho dal db."); return 0; } - commons->organigramma_commons->role_utente = autoz_get_role_from_id (commons->organigramma_commons->autoz, commons->organigramma_commons->utente); + commons->organigramma_commons->role_utente = zak_autho_get_role_from_id (commons->organigramma_commons->autoz, commons->organigramma_commons->utente); if (commons->organigramma_commons->role_utente == NULL) { - g_warning ("Utente \"%s\" non trovato nell configurazione di libautoz.", commons->organigramma_commons->utente); + g_warning ("Utente \"%s\" non trovato nell configurazione di libzakautho.", commons->organigramma_commons->utente); return 0; } diff --git a/src/registro.c b/src/registro.c index 5a359b3..29e714b 100644 --- a/src/registro.c +++ b/src/registro.c @@ -1,5 +1,5 @@ -/* - * Copyright (C) 2013 Andrea Zagli +/* + * Copyright (C) 2013-2016 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,7 +19,7 @@ #include -#include +#include #include #include @@ -155,7 +155,7 @@ Registro *registro_new (Commons *commons, gboolean selezione) { GError *error; - AutozIResource *ires1; + ZakAuthoIResource *ires1; Registro *a = REGISTRO (g_object_new (registro_get_type (), NULL)); @@ -214,8 +214,8 @@ Registro registro_carica (a); - ires1 = autoz_get_resource_from_id (priv->commons->autoz, "messi_rw"); - if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE)) + ires1 = zak_autho_get_resource_from_id (priv->commons->autoz, "messi_rw"); + if (!zak_autho_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE)) { } @@ -532,7 +532,7 @@ registro_on_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { - if (event->keyval == GDK_Escape) + if (event->keyval == GDK_KEY_Escape) { RegistroPrivate *priv = REGISTRO_GET_PRIVATE ((Registro *)user_data); diff --git a/src/tipiatto.c b/src/tipiatto.c index 1a885bd..172d477 100644 --- a/src/tipiatto.c +++ b/src/tipiatto.c @@ -1,5 +1,5 @@ -/* - * Copyright (C) 2013 Andrea Zagli +/* + * Copyright (C) 2013-2016 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,7 +19,7 @@ #include -#include +#include #include #include "tipiatto.h" @@ -128,7 +128,7 @@ TipiAtto *tipi_atto_new (Commons *commons, gboolean selezione) { GError *error; - AutozIResource *ires1; + ZakAuthoIResource *ires1; TipiAtto *a = TIPI_ATTO (g_object_new (tipi_atto_get_type (), NULL)); @@ -180,8 +180,8 @@ TipiAtto tipi_atto_carica (a); - ires1 = autoz_get_resource_from_id (priv->commons->autoz, "opengov_tab_tipi_atto_rw"); - if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE)) + ires1 = zak_autho_get_resource_from_id (priv->commons->autoz, "opengov_tab_tipi_atto_rw"); + if (!zak_autho_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button211")), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button213")), FALSE); @@ -334,7 +334,7 @@ tipi_atto_on_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { - if (event->keyval == GDK_Escape) + if (event->keyval == GDK_KEY_Escape) { TipiAttoPrivate *priv = TIPI_ATTO_GET_PRIVATE ((TipiAtto *)user_data); diff --git a/src/tipoatto.c b/src/tipoatto.c index 418d2c8..90f0bf4 100644 --- a/src/tipoatto.c +++ b/src/tipoatto.c @@ -1,5 +1,5 @@ -/* - * Copyright (C) 2013 Andrea Zagli +/* + * Copyright (C) 2013-2016 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -19,7 +19,7 @@ #include -#include +#include #include #include "tipoatto.h" @@ -122,7 +122,7 @@ TipoAtto *tipo_atto_new (Commons *commons, gint id) { GError *error; - AutozIResource *ires1; + ZakAuthoIResource *ires1; TipoAtto *a = TIPO_ATTO (g_object_new (tipo_atto_get_type (), NULL)); @@ -178,8 +178,8 @@ TipoAtto tipo_atto_carica (a); } - ires1 = autoz_get_resource_from_id (priv->commons->autoz, "opengov_tab_titoli_rw"); - if (!autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE)) + ires1 = zak_autho_get_resource_from_id (priv->commons->autoz, "opengov_tab_titoli_rw"); + if (!zak_autho_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE)) { gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button224")), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (commons->gtkbuilder, "button34")), FALSE); @@ -325,7 +325,7 @@ tipo_atto_on_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { - if (event->keyval == GDK_Escape) + if (event->keyval == GDK_KEY_Escape) { TipoAttoPrivate *priv = TIPO_ATTO_GET_PRIVATE ((TipoAtto *)user_data); diff --git a/src/trovaatti.c b/src/trovaatti.c index 8195eff..e7da6d8 100644 --- a/src/trovaatti.c +++ b/src/trovaatti.c @@ -1,5 +1,5 @@ -/* - * Copyright (C) 2013 Andrea Zagli +/* + * Copyright (C) 2013-2016 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -238,13 +238,13 @@ trova_atti_on_ufficio_ask_toshow (gpointer instance, guint id, gpointer user_dat TrovaAtti *a = (TrovaAtti *)user_data; TrovaAttiPrivate *priv = TROVA_ATTI_GET_PRIVATE (a); - AutozIResource *ires1; + ZakAuthoIResource *ires1; ret = TRUE; /* per adesso controllo solo gli uffici */ - ires1 = autoz_get_resource_from_id (priv->commons->autoz, g_strdup_printf ("opengov_u_%d_r_0", id)); - ret = autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE); + ires1 = zak_autho_get_resource_from_id (priv->commons->autoz, g_strdup_printf ("opengov_u_%d_r_0", id)); + ret = zak_autho_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE); return ret; } @@ -254,7 +254,7 @@ trova_atti_on_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { - if (event->keyval == GDK_Escape) + if (event->keyval == GDK_KEY_Escape) { TrovaAttiPrivate *priv = TROVA_ATTI_GET_PRIVATE ((TrovaAtti *)user_data); diff --git a/src/trovaregistro.c b/src/trovaregistro.c index addd2ba..959b7df 100644 --- a/src/trovaregistro.c +++ b/src/trovaregistro.c @@ -1,5 +1,5 @@ -/* - * Copyright (C) 2013 Andrea Zagli +/* + * Copyright (C) 2013-2016 Andrea Zagli * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -238,13 +238,13 @@ trova_registro_on_ufficio_ask_toshow (gpointer instance, guint id, gpointer user TrovaRegistro *a = (TrovaRegistro *)user_data; TrovaRegistroPrivate *priv = TROVA_REGISTRO_GET_PRIVATE (a); - AutozIResource *ires1; + ZakAuthoIResource *ires1; ret = TRUE; /* per adesso controllo solo gli uffici */ - ires1 = autoz_get_resource_from_id (priv->commons->autoz, g_strdup_printf ("opengov_u_%d_r_0", id)); - ret = autoz_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE); + ires1 = zak_autho_get_resource_from_id (priv->commons->autoz, g_strdup_printf ("opengov_u_%d_r_0", id)); + ret = zak_autho_is_allowed (priv->commons->autoz, priv->commons->role_utente, ires1, FALSE); return ret; } @@ -254,7 +254,7 @@ trova_registro_on_key_release_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { - if (event->keyval == GDK_Escape) + if (event->keyval == GDK_KEY_Escape) { TrovaRegistroPrivate *priv = TROVA_REGISTRO_GET_PRIVATE ((TrovaRegistro *)user_data); -- 2.50.0