From 04f5e7d728d482a3f191f0275b61afd39e6a91f8 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 2 Dec 2017 12:47:07 +0100 Subject: [PATCH] Utilizzo di Territorio::init. --- docs/organigramma/examples/organigramma.conf | 4 +- src/main.c | 51 +------------------- src/persona.c | 2 +- 3 files changed, 4 insertions(+), 53 deletions(-) diff --git a/docs/organigramma/examples/organigramma.conf b/docs/organigramma/examples/organigramma.conf index 1c39a6f..206886a 100644 --- a/docs/organigramma/examples/organigramma.conf +++ b/docs/organigramma/examples/organigramma.conf @@ -1,7 +1,7 @@ -[DB_TERRITORIO] +[TERRITORIO_DB] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=territorio -[ZAKAUTHO_TERRITORIO] +[TERRITORIO_ZAKAUTHO] cnc_string=PostgreSQL://postgres:postgres@HOST=localhost;PORT=5432;DB_NAME=autoz [libzakauthe] diff --git a/src/main.c b/src/main.c index 8b96e35..483156c 100644 --- a/src/main.c +++ b/src/main.c @@ -309,7 +309,7 @@ main (int argc, char *argv[]) commons = g_new0 (OrganigrammaCommons, 1); commons->utente = utente; - commons->territorio_commons = g_new0 (TerritorioCommons, 1); + commons->territorio_commons = territorio_init (confi, "TERRITORIO_"); commons->territorio_commons->utente = utente; #ifdef G_OS_WIN32 @@ -326,8 +326,6 @@ main (int argc, char *argv[]) { commons->guidir = g_strdup (GUIDIR); commons->formdir = g_strdup (FORMDIR); - commons->territorio_commons->guidir = g_build_filename ("/mingw", "share", "territorio", "gui", NULL); - commons->territorio_commons->formdir = g_build_filename ("/mingw", "share", "territorio", "form", NULL); } else { @@ -336,21 +334,16 @@ main (int argc, char *argv[]) commons->guidir = g_build_filename (moddir, "share", PACKAGE, "gui", NULL); commons->formdir = g_build_filename (moddir, "share", PACKAGE, "form", NULL); - commons->territorio_commons->guidir = g_build_filename (moddir, "share", "territorio", "gui", NULL); - commons->territorio_commons->formdir = g_build_filename (moddir, "share", "territorio", "form", NULL); } #else commons->guidir = g_strdup (GUIDIR); commons->formdir = g_strdup (FORMDIR); - commons->territorio_commons->guidir = g_build_filename ("/usr", "local", "share", "territorio", "gui", NULL); - commons->territorio_commons->formdir = g_build_filename ("/usr", "local", "share", "territorio", "form", NULL); #endif commons->guifile = g_build_filename (commons->guidir, "organigramma.gui", NULL); - commons->territorio_commons->guifile = g_build_filename (commons->territorio_commons->guidir, "territorio.gui", NULL); /* leggo i parametri per libzakautho */ cnc_string = zak_confi_path_get_value (confi, "ZAKAUTHO/cnc_string"); @@ -424,47 +417,6 @@ main (int argc, char *argv[]) g_error ("Errore nella connessione al database: %s", cnc_string); } - /* leggo la stringa di connessione al db territorio */ - cnc_string = zak_confi_path_get_value (confi, "DB_TERRITORIO/cnc_string"); - if (cnc_string == NULL) - { - g_error ("Impossibile leggere la stringa di connessione dal file di configurazione."); - } - - commons->territorio_commons->gdaex = gdaex_new_from_string (cnc_string); - if (commons->territorio_commons->gdaex == NULL) - { - g_error ("Errore nella connessione al database: %s", cnc_string); - } - - /* leggo i parametri per libautoz 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 libzakautho dal file di configurazione."); - return 0; - } - - error = NULL; - gdacon = gda_connection_open_from_string (NULL, cnc_string, NULL, 0, &error); - if (gdacon == NULL) - { - 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 = zak_autho_new (); - if (commons->territorio_commons->autoz == NULL) - { - g_warning ("Impossibile creare l'oggetto per libzakautho."); - return 0; - } - if (!zak_autho_load_from_db (commons->territorio_commons->autoz, gdacon, NULL, TRUE)) - { - g_warning ("Impossibile caricare la configurazione per libzakautho dal db."); - return 0; - } - 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) { @@ -474,7 +426,6 @@ main (int argc, char *argv[]) /* gtkbuilder */ commons->gtkbuilder = gtk_builder_new (); - commons->territorio_commons->gtkbuilder = gtk_builder_new (); error = NULL; gtk_builder_add_objects_from_file (commons->gtkbuilder, commons->guifile, diff --git a/src/persona.c b/src/persona.c index 8e958b3..1b913cd 100644 --- a/src/persona.c +++ b/src/persona.c @@ -1215,7 +1215,7 @@ static gchar if (ht_comune != NULL) { - g_string_append (ret, g_hash_table_lookup (ht_comune, "nome")); + g_string_append (ret, g_value_get_string (g_hash_table_lookup (ht_comune, "nome"))); } return ret->str; -- 2.49.0