From e0c578579c9357f66289372eb758d0e816a0f8c9 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Fri, 11 Nov 2016 12:52:41 +0100 Subject: [PATCH] Utilizzo di libzakconfi. --- configure.ac | 1 + docs/territorio/examples/territorio.conf | 8 +++-- libterritorio.pc.in | 2 +- src/main.c | 40 +++++++++--------------- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index 5947756..c4db977 100644 --- a/configure.ac +++ b/configure.ac @@ -37,6 +37,7 @@ PKG_CHECK_MODULES(TERRITORIO, [gio-2.0 >= 2.36 libgda-ui-5.0 >= 5.0.0 libgdaex >= 0.5.0 libgdaexgrid + libzakconfi >= 0.10.0 libgtkform >= 0.5.0 libgtkformui >= 0.5.0 libzakauthe >= 0.2.0 diff --git a/docs/territorio/examples/territorio.conf b/docs/territorio/examples/territorio.conf index d9da643..86df1bb 100644 --- a/docs/territorio/examples/territorio.conf +++ b/docs/territorio/examples/territorio.conf @@ -1,8 +1,10 @@ -[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 [DB] diff --git a/libterritorio.pc.in b/libterritorio.pc.in index 48ff6c1..c8837cd 100644 --- a/libterritorio.pc.in +++ b/libterritorio.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: @PACKAGE_NAME@ Description: Libreria con l'interfaccia per la gestione del territorio. Version: @PACKAGE_VERSION@ -Requires: libgdaex >= 0.5.0 libgtkform >= 0.5.0 libgtkformui >= 0.5.0 libzakauthe >= 0.2.0 libzakautho >= 0.0.5 libsolipa >= 0.5.0 libgda-ui-5.0 >= 5.0.0 +Requires: libgdaex >= 0.5.0 libgtkform >= 0.5.0 libgtkformui >= 0.5.0 libzakauthe >= 0.2.0 libzakautho >= 0.0.5 libsolipa >= 0.5.0 libgda-ui-5.0 >= 5.0.0 libzakconfi >= 0.10.0 Libs: -L${libdir} -lterritorio Cflags: -I${includedir} diff --git a/src/main.c b/src/main.c index d4fb33c..6c5bc42 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -43,8 +44,6 @@ static TerritorioCommons *commons; -static GKeyFile *config; - static GtkWidget *w; static GtkWidget *vbx_body; static GtkWidget *vbx_body_child; @@ -216,6 +215,8 @@ main (int argc, char *argv[]) { GError *error; + ZakConfi *confi; + GdaConnection *gdacon; ZakAuthe *zak_authe; @@ -247,31 +248,20 @@ 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)) + /* utilizzo di libzakconfi */ + confi = zak_confi_new (argv[1]); + if (confi == NULL) { - g_error ("Impossibile caricare il file di configurazione specificato: %s.", argv[1]); - } - - /* leggo i parametri per l'zak_authe */ - error = NULL; - zak_authe_params = g_key_file_get_keys (config, "AUTE", &n_zak_authe_params, &error); - if (zak_authe_params == NULL) - { - g_error ("Impossibile leggere la configurazione per il sistema di zak_authe."); + g_error ("Impossibile caricare la configurazione specificata: %s", argv[1]); + return 0; } + /* leggo i parametri per l'autenticazione */ sl_zak_authe_params = NULL; - for (i = 0; i < n_zak_authe_params; i++) - { - error = NULL; - sl_zak_authe_params = g_slist_append (sl_zak_authe_params, g_key_file_get_string (config, "AUTE", zak_authe_params[i], &error)); - } - - g_strfreev (zak_authe_params); + sl_zak_authe_params = g_slist_append (sl_zak_authe_params, "{libzakconfi}"); + sl_zak_authe_params = g_slist_append (sl_zak_authe_params, confi); - /* zak_authenticazione */ + /* autenticazione */ zak_authe = zak_authe_new (); zak_authe_set_config (zak_authe, sl_zak_authe_params); @@ -300,7 +290,7 @@ main (int argc, char *argv[]) /* 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 libzakautho dal file di configurazione: %s.", @@ -320,7 +310,7 @@ main (int argc, char *argv[]) commons->autoz = zak_autho_new (); if (commons->autoz == NULL) { - g_warning ("Impossibile creare l'oggetto per libzak_autho."); + g_warning ("Impossibile creare l'oggetto per libzakautho."); return 0; } if (!zak_autho_load_from_db_with_monitor (commons->autoz, gdacon, NULL, TRUE)) @@ -371,7 +361,7 @@ main (int argc, char *argv[]) /* 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) { g_error ("Impossibile leggere la stringa di connessione dal file di configurazione: %s.", -- 2.49.0